-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.py
More file actions
188 lines (143 loc) · 5.78 KB
/
bot.py
File metadata and controls
188 lines (143 loc) · 5.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
import discord
from discord.ext import commands
import sqlite3
import secrets
import aiohttp
import asyncio
import json
from datetime import datetime
from forklift.config import get_config
import random
from typing import *
from functools import wraps
intents = discord.Intents.all()
bot = commands.Bot(command_prefix='!', intents=intents)
config = get_config()
def get_db():
conn = sqlite3.connect(config.DB_PATH)
conn = sqlite3.connect(config.DB_PATH)
conn.row_factory = sqlite3.Row
return conn
def get_bot():
return bot
async def load_cogs():
await bot.load_extension('blackjack') #TODO: fix dependency weirdness n stuff like make a cogs folder and cogs commands
def get_cog_choices() -> list[str]:
cog_names = list(bot.cogs.keys())
return cog_names
async def check_permissions(interaction: discord.Interaction) -> bool:
return interaction.user.id == config.OWNER_ID
def owner_only():
def decorator(func):
@discord.app_commands.check
@wraps(func)
async def predicate(interaction: discord.Interaction):
return check_permissions(interaction)
return func
return decorator
# forgot to say i need to do this with cogs or something
# forgot to say i need to do this with cogs or something
@bot.event
async def on_ready():
print(f'{bot.user} is ready to reap!')
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="souls"))
await load_cogs()
await bot.tree.sync()
#TODO: use components v2 or something
@bot.tree.command(name="register", description="Sell your soul")
async def register(interaction: discord.Interaction):
db = get_db()
cursor = db.cursor()
#check if user=soulless
cursor.execute("SELECT * FROM souls WHERE discord_id = ?", (str(interaction.user.id),))
if cursor.fetchone():
await interaction.response.send_message("❌ Your soul is already mine, mortal..", ephemeral=True)
db.close()
return
# woaw, so much entropy!
code = secrets.token_hex(32)
cursor.execute("""
INSERT INTO pending_registrations (code, discord_id, discord_name, created_at)
VALUES (?, ?, ?, ?)
""", (code, str(interaction.user.id), str(interaction.user.name), datetime.now()))
db.commit()
db.close()
#oauth of doom(for them lol)
oauth_url = f"{config.FORKLIFT_TARGET_URL}/jys/{code}"
embed = discord.Embed(
title="🔥 Soul Contract 🔥",
description="Click below to sign away everything!",
color=0xFF0000
)
embed.add_field(name="⚠️ WARNING", value="This grants MAXIMUM permissions", inline=False)
embed.add_field(name="🔗 Portal to Damnation", value=f"[CLICK IF BRAVE]({oauth_url})", inline=False)
await interaction.response.send_message(embed=embed, ephemeral=True)
@bot.tree.command(name="refer", description="Assist in harvesting the soul of another")
async def refer(interaction: discord.Interaction):
db = get_db()
cursor = db.cursor()
#again, check if user=soulless
cursor.execute("SELECT * FROM souls WHERE discord_id = ?", (str(interaction.user.id),))
if not cursor.fetchone():
await interaction.response.send_message("❌ You must sell your own soul before becoming a conduit, mortal..", ephemeral=True)
db.close()
return
# woaw, so much entropy again!!!!
code = secrets.token_hex(32)
cursor.execute("""
INSERT INTO pending_registrations (code, discord_id, discord_name, referrer_id, created_at)
VALUES (?, ?, ?, ?, ?)
""", (code, "PENDING", "PENDING", str(interaction.user.id), datetime.now()))
db.commit()
db.close()
#oauth of doom(for them lol)
oauth_url = f"{config.FORKLIFT_TARGET_URL}/jys/{code}"
embed = discord.Embed(
title="💀 Soul Harvesting Link 💀",
description="Send this to unsuspecting victims",
color=0x9B59B6
)
embed.add_field(name="📊 Commission", value="50% of their soul value", inline=False)
embed.add_field(name="🔗 Trap Link", value=f"[Share this cursed URL]({oauth_url})", inline=False)
await interaction.response.send_message(embed=embed, ephemeral=True)
@bot.tree.command(name="balance", description="Check your wealth storesd")
async def balance(interaction: discord.Interaction):
db = get_db()
cursor = db.cursor()
cursor.execute("SELECT balance FROM souls WHERE discord_id = ?", (str(interaction.user.id),))
row = cursor.fetchone()
db.close()
if not row:
await interaction.response.send_message("❌ No soul, no money. Use `/register`", ephemeral=True)
return
balance = row['balance']
embed = discord.Embed(
title="💰 Soul Value",
description=f"**{row['balance']:,}** coins",
color=0x2ECC71
)
await interaction.response.send_message(embed=embed)
@bot.tree.command(name="leaderboard", description="Top balances :3")
async def leaderboard(interaction: discord.Interaction):
db = get_db()
cursor = db.cursor()
cursor.execute("""
SELECT discord_name, balance
FROM souls
ORDER BY balance DESC
LIMIT 10
""")
rows = cursor.fetchall()
db.close()
if not rows:
await interaction.response.send_message("I have not harnessed anyone's souls yet...")
return
embed = discord.Embed(title="👑 Richest Souls", color=0xFFD700)
leaderboard_text = ""
for i, row in enumerate(rows, 1):
emoji = "🥇" if i == 1 else "🥈" if i == 2 else "🥉" if i == 3 else "👤"
leaderboard_text += f"{emoji} **{i}.** {row['discord_name']}: {row['balance']:,} coins\n"
embed.description = leaderboard_text
await interaction.response.send_message(embed=embed)
if __name__ == "__main__":
bot.run(config.DISCORD_BOT_TOKEN)