Skip to content

Commit 9481254

Browse files
committed
description add + CasinoSlash bug fix
1 parent 2ece8b0 commit 9481254

File tree

8 files changed

+76
-80
lines changed

8 files changed

+76
-80
lines changed

database/db.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def __init__(self, filename: str, encoder: Encoder) -> None:
3333
self.msg: MIMEMultipart = MIMEMultipart()
3434
self.part2: MIMEBase = MIMEBase('application', "octet-stream")
3535
self.part1: MIMEBase = MIMEBase('application', "octet-stream")
36-
self.check_str_cash = lambda cash, user_cash: int(cash) > user_cash if cash.isdigit() else False
36+
self.check_str_cash = lambda cash, user_cash: int(cash) > user_cash if str(cash).isdigit() else False
3737
self.time = None
3838
self.now2 = None
3939
self.minutes: int = 0
@@ -397,7 +397,7 @@ def get_from_coinflip(self, ID1: int, ID2: int, guild_id: int, item: str) -> int
397397
return self.cursor.execute(
398398
f"SELECT `{item}` FROM `Coinflip` WHERE `GuildID` = ? AND "
399399
f"`FirstPlayerID` = ? AND `SecondPlayerID` = ?",
400-
(item, guild_id, ID1, ID2)
400+
(guild_id, ID1, ID2)
401401
).fetchone()[0]
402402

403403
def get_from_promo_codes(self, code: str, item: Union[str, List[str]], ID: int = None) -> Union[int, str, Cursor]:
@@ -834,12 +834,10 @@ def get_active_coinflip(
834834
return self.cursor.execute(
835835
"SELECT * FROM `Coinflip` WHERE `SecondPlayerID` = ? AND `GuildID` = ? AND `FirstPlayerID` = ?",
836836
(first_player_id, guild_id, second_player_id)
837-
).fetchone() is None \
838-
or \
839-
self.cursor.execute(
840-
"SELECT * FROM `Coinflip` WHERE `SecondPlayerID` = ? AND `GuildID` = ? AND `FirstPlayerID` = ?",
841-
(second_player_id, guild_id, first_player_id)
842-
).fetchone() is None
837+
).fetchone() is not None or self.cursor.execute(
838+
"SELECT * FROM `Coinflip` WHERE `SecondPlayerID` = ? AND `GuildID` = ? AND `FirstPlayerID` = ?",
839+
(second_player_id, guild_id, first_player_id)
840+
).fetchone() is not None
843841

844842
def delete_from_online_stats(self, ID: int) -> Cursor:
845843
with self.connection:
@@ -1263,7 +1261,7 @@ async def stats_update(
12631261

12641262
if third_arg == "LosesCount":
12651263
self.add_lose(self.author_id, ctx.guild.id)
1266-
self.add_win(ctx.author.id, ctx.guild.id, True)
1264+
self.add_win(self.author_id, ctx.guild.id, True)
12671265

12681266
elif third_arg == "WinsCount":
12691267
self.add_win(self.author_id, ctx.guild.id)

slashbotsections/elements/admin.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def __init__(self, bot: commands.Bot, db: Database, *args, **kwargs) -> None:
3131
print(f"[{get_time()}] [INFO]: AdminSlash connected")
3232
write_log(f"[{get_time()}] [INFO]: AdminSlash connected")
3333

34-
@app_commands.command(name="give")
34+
@app_commands.command(name="give", description="Выдать коины")
3535
@commands.cooldown(1, 5, commands.BucketType.user)
3636
async def __give(self, inter: discord.Interaction, member: discord.Member, cash: int) -> None:
3737
self.administrator_role_id = self.db.get_administrator_role_id(inter.guild.id) # !
@@ -49,7 +49,7 @@ async def __give(self, inter: discord.Interaction, member: discord.Member, cash:
4949
self.db.add_coins(member.id, inter.guild.id, cash)
5050
await inter.response.send_message('✅')
5151

52-
@app_commands.command(name="take")
52+
@app_commands.command(name="take", description="Снять коины")
5353
@commands.cooldown(1, 5, commands.BucketType.user)
5454
async def __take(self, inter: discord.Interaction, member: discord.Member, cash: str) -> None:
5555
self.administrator_role_id = self.db.get_administrator_role_id(inter.guild.id) # !
@@ -72,7 +72,7 @@ async def __take(self, inter: discord.Interaction, member: discord.Member, cash:
7272
self.db.take_coins(member.id, inter.guild.id, int(cash))
7373
await inter.response.send_message('✅')
7474

75-
@app_commands.command(name="give-role")
75+
@app_commands.command(name="give-role", description="Выдать коины по роли")
7676
@commands.cooldown(1, 5, commands.BucketType.user)
7777
async def __give_role(self, inter: discord.Interaction, role: discord.Role, cash: int) -> None:
7878
self.administrator_role_id = self.db.get_administrator_role_id(inter.guild.id) # !
@@ -92,7 +92,7 @@ async def __give_role(self, inter: discord.Interaction, role: discord.Role, cash
9292
self.db.add_coins(member.id, inter.guild.id, cash)
9393
await inter.response.send_message('✅')
9494

95-
@app_commands.command(name="take-role")
95+
@app_commands.command(name="take-role", description="Забрать коины по роли")
9696
@commands.cooldown(1, 5, commands.BucketType.user)
9797
async def __take_role(self, inter: discord.Interaction, role: discord.Role, cash: str) -> None:
9898
self.administrator_role_id = self.db.get_administrator_role_id(inter.guild.id) # !
@@ -124,14 +124,14 @@ async def __take_role(self, inter: discord.Interaction, role: discord.Role, cash
124124
self.db.take_coins(member.id, inter.guild.id, int(cash))
125125
await inter.response.send_message('✅')
126126

127-
@app_commands.command(name="remove-shop")
127+
@app_commands.command(name="remove-shop", description="Удалить роль из магазина")
128128
@commands.cooldown(1, 5, commands.BucketType.user)
129129
async def __remove_shop(self, inter: discord.Interaction, role: discord.Role) -> None:
130130
if inter.user.guild_permissions.administrator or inter.user.id == 401555829620211723:
131131
self.db.delete_from_shop(role.id, inter.guild.id)
132132
await inter.response.send_message('✅')
133133

134-
@app_commands.command(name="add-shop")
134+
@app_commands.command(name="add-shop", description="Добавить роль в магазин")
135135
@commands.cooldown(1, 5, commands.BucketType.user)
136136
async def __add_shop(self, inter: discord.Interaction, role: discord.Role, price: int) -> None:
137137
if inter.user.guild_permissions.administrator or inter.user.id == 401555829620211723:
@@ -149,7 +149,7 @@ async def __add_shop(self, inter: discord.Interaction, role: discord.Role, price
149149
self.db.insert_into_shop(role.id, inter.guild.id, price)
150150
await inter.response.send_message('✅')
151151

152-
@app_commands.command(name="add-else")
152+
@app_commands.command(name="add-else", description="Добавить предмет в магазин")
153153
@commands.cooldown(1, 5, commands.BucketType.user)
154154
async def __add_item_shop(self, inter: discord.Interaction, item: str, price: int) -> None:
155155
if inter.user.guild_permissions.administrator or inter.user.id == 401555829620211723:
@@ -183,7 +183,7 @@ async def __add_item_shop(self, inter: discord.Interaction, item: str, price: in
183183
self.db.insert_into_item_shop(self.ind + 1, str(self.msg), inter.guild.id, price)
184184
await inter.response.send_message('✅')
185185

186-
@app_commands.command(name="remove-else")
186+
@app_commands.command(name="remove-else", description="Удалить вещь из магазина")
187187
@commands.cooldown(1, 5, commands.BucketType.user)
188188
async def __remove_item_shop(self, inter: discord.Interaction, item_id: int) -> None:
189189
if inter.user.guild_permissions.administrator or inter.user.id == 401555829620211723:

slashbotsections/elements/casino.py

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ def __init__(self, bot: commands.Bot, db: Database, *args, **kwargs) -> None:
5151
print(f"[{get_time()}] [INFO]: Casino connected")
5252
write_log(f"[{get_time()}] [INFO]: Casino connected")
5353

54-
@app_commands.command(name="wheel")
54+
@app_commands.command(name="wheel", description="Рулетка! (прямо как в расте)")
5555
async def __casino_3(
5656
self, inter: discord.Interaction,
57-
bid: int = None, number: int = None
57+
bid: int, number: int
5858
) -> None:
59-
if self.db.is_the_casino_allowed(inter.message.channel.id):
59+
if self.db.is_the_casino_allowed(inter.channel.id):
6060
if bid is None:
6161
await inter.response.send_message("Вы ну ввели Вашу ставку!", ephemeral=True)
6262
elif bid <= 0:
@@ -113,13 +113,13 @@ async def __casino_3(
113113
f"Вы можете играть в казино только в специальном канале!", ephemeral=True
114114
)
115115

116-
@app_commands.command(name="fail")
116+
@app_commands.command(name="fail", description="Казино с коэффицентом!")
117117
@commands.cooldown(1, 2, commands.BucketType.user)
118118
async def __fail(
119119
self, inter: discord.Interaction,
120-
bid: int = None, coefficient: float = None
120+
bid: int, coefficient: float
121121
) -> None:
122-
if self.db.is_the_casino_allowed(inter.message.channel.id):
122+
if self.db.is_the_casino_allowed(inter.channel.id):
123123
if bid is None:
124124
await inter.response.send_message(f"Вы не ввели вашу ставку", ephemeral=True)
125125
elif bid < 10:
@@ -176,12 +176,12 @@ async def __fail(
176176
else:
177177
await inter.response.send_message(f"Вы можете играть в казино только в специальном канале!", ephemeral=True)
178178

179-
@app_commands.command(name="777")
179+
@app_commands.command(name="777", description="Рулетка! (в разработке)")
180180
@commands.cooldown(1, 2, commands.BucketType.user)
181181
async def __casino777(self, inter: discord.Interaction, bid: int) -> None:
182182
if inter.user.id != 0:
183183
return
184-
if self.db.is_the_casino_allowed(inter.message.channel.id):
184+
if self.db.is_the_casino_allowed(inter.channel.id):
185185
if bid is None:
186186
await inter.response.send_message(f"Вы не ввели вашу ставку", ephemeral=True)
187187
elif bid < 10:
@@ -222,7 +222,7 @@ async def __casino777(self, inter: discord.Interaction, bid: int) -> None:
222222
self.db.add_coins(inter.user.id, inter.guild.id, self.result_bid)
223223
self.emb = discord.Embed(title="🎰Вы выиграли!🎰", colour=self.color)
224224
self.emb.add_field(
225-
name=f'🎰Поздравляем!🎰',
225+
name=f'🎰{inter.user}, Поздравляем!🎰',
226226
value='`{}\t{}\t{}`\n`{}\t{}\t{}`\n`{}\t{}\t{}\n{}, Вы выиграли **{}** DP коинов!'.format(
227227
*self.line1[0], *self.line1[1], *self.line1[2],
228228
*self.line2[0], *self.line2[1], *self.line2[2],
@@ -238,7 +238,7 @@ async def __casino777(self, inter: discord.Interaction, bid: int) -> None:
238238
self.db.add_coins(inter.user.id, inter.guild.id, self.result_bid)
239239
self.emb = discord.Embed(title="🎰Вы выиграли!🎰", colour=self.color)
240240
self.emb.add_field(
241-
name=f'🎰Вы выиграли!🎰',
241+
name=f'🎰{inter.user}, Поздравляем!🎰',
242242
value='`{}\t{}\t{}`\n`{}\t{}\t{}`\n`{}\t{}\t{}\n{}, Вы выиграли **{}** DP коинов!'.format(
243243
*self.line1[0], *self.line1[1], *self.line1[2],
244244
*self.line2[0], *self.line2[1], *self.line2[2],
@@ -254,7 +254,7 @@ async def __casino777(self, inter: discord.Interaction, bid: int) -> None:
254254
else:
255255
self.emb = discord.Embed(title="🎰Вы проиграли:(🎰", colour=self.color)
256256
self.emb.add_field(
257-
name=f':(',
257+
name=f'🎰{inter.user}, Поздравляем!🎰',
258258
value='{}\t{}\t{}`\n`{}\t{}\t{}`\n`{}\t{}\t{}\n{}, Вы выиграли **{}** DP коинов!'.format(
259259
*self.line1[0], *self.line1[1], *self.line1[2],
260260
*self.line2[0], *self.line2[1], *self.line2[2],
@@ -274,7 +274,7 @@ async def __casino777(self, inter: discord.Interaction, bid: int) -> None:
274274
async def __casino_2(self, inter: discord.Interaction, count: int, member: discord.Member = None):
275275
self.date_now = get_time()
276276
self.color = get_color(inter.user.roles)
277-
if self.db.is_the_casino_allowed(inter.message.channel.id):
277+
if self.db.is_the_casino_allowed(inter.channel.id):
278278
if member is None:
279279
if await self.db.cash_check(inter, count, min_cash=10, check=True):
280280
self.db.take_coins(inter.user.id, inter.guild.id, count)
@@ -315,8 +315,7 @@ async def __casino_2(self, inter: discord.Interaction, count: int, member: disco
315315
if self.db.get_active_coinflip(inter.user.id, member.id, inter.guild.id):
316316
await inter.response.send_message(
317317
f"{inter.user.mention}, такая игра уже существует! Для удаления - "
318-
f"{settings['prefix']}del_games "
319-
f"{member.mention}"
318+
f"{settings['prefix']}del_games", ephemeral=True
320319
)
321320
else:
322321
self.db.insert_into_coinflip(
@@ -328,13 +327,12 @@ async def __casino_2(self, inter: discord.Interaction, count: int, member: disco
328327
self.emb = discord.Embed(title=f"{member}, вас упомянули в коинфлипе!", colour=self.color)
329328
self.emb.add_field(
330329
name=f'Коинфлип на {count} DP коинов!',
331-
value=f"{inter.user.mention}, значит в следующий раз"
332-
f"{settings['prefix']}accept {inter.user.mention}\n\nЧтобы отменить - "
330+
value=f"{settings['prefix']}accept {inter.user.mention}\n\nЧтобы отменить - "
333331
f"{settings['prefix']}reject {inter.user.mention}",
334332
inline=False
335333
)
336334
await inter.response.send_message(embed=self.emb)
337-
await inter.response.send_message(member.mention)
335+
await inter.channel.send(member.mention)
338336
else:
339337
await inter.response.send_message(f"Вы можете играть в казино только в специальном канале!", ephemeral=True)
340338

@@ -343,7 +341,7 @@ async def __casino_2(self, inter: discord.Interaction, count: int, member: disco
343341
async def __roll(self, inter: discord.Interaction, count: int, arg: str):
344342
self.color = get_color(inter.user.roles)
345343
self.count = count
346-
if self.db.is_the_casino_allowed(inter.message.channel.id):
344+
if self.db.is_the_casino_allowed(inter.channel.id):
347345
if await self.db.cash_check(inter, self.count, min_cash=10, check=True):
348346
self.texts[inter.user.id] = ""
349347
self.casino[inter.user.id] = {}
@@ -618,7 +616,7 @@ async def __roll(self, inter: discord.Interaction, count: int, arg: str):
618616
async def __del_games(self, inter: discord.Interaction, member: discord.Member = None):
619617
if member is None:
620618
self.db.delete_from_coinflip(inter.user.id, inter.guild.id, inter.guild.id)
621-
await inter.message.add_reaction('✅')
619+
await inter.response.send_message('✅')
622620
else:
623621
if inter.user.guild_permissions.administrator or inter.user.id == 401555829620211723:
624622
self.db.delete_from_coinflip(member.id, member.id, inter.guild.id)
@@ -673,17 +671,17 @@ async def __c_accept(self, inter: discord.Interaction, member: discord.Member):
673671
f"Такой игры не существует, посмотреть все ваши активные игры - {settings['prefix']}games",
674672
ephemeral=True
675673
)
676-
elif reladdons.long.minutes(self.db.get_from_coinflip(inter.user.id, member.id, inter.guild.id, "Date")) > 5:
674+
elif reladdons.long.minutes(self.db.get_from_coinflip(member.id, inter.user.id, inter.guild.id, "Date")) > 5:
677675
await inter.response.send_message(f"Время истекло:(", ephemeral=True)
678676
self.db.delete_from_coinflip(inter.user.id, member.id, inter.guild.id)
679677
elif self.db.get_cash(inter.user.id, inter.guild.id) < \
680-
self.db.get_from_coinflip(inter.user.id, member.id, inter.guild.id, "Cash"):
678+
self.db.get_from_coinflip(member.id, inter.user.id, inter.guild.id, "Cash"):
681679
await inter.response.send_message(f"У Вас недостаточно средств!", ephemeral=True)
682680
elif self.db.get_cash(member.id, inter.guild.id) < \
683-
self.db.get_from_coinflip(inter.user.id, member.id, inter.guild.id, "Cash"):
681+
self.db.get_from_coinflip(member.id, inter.user.id, inter.guild.id, "Cash"):
684682
await inter.response.send_message(f"У Вашего cоперника недостаточно средств", ephemeral=True)
685683
else:
686-
self.num = self.db.get_from_coinflip(inter.user.id, member.id, inter.guild.id, "Cash")
684+
self.num = self.db.get_from_coinflip(member.id, inter.user.id, inter.guild.id, "Cash")
687685
self.db.take_coins(inter.user.id, inter.guild.id, self.num)
688686
self.db.take_coins(member.id, inter.guild.id, self.num)
689687
self.ch = random.randint(1, 2)

slashbotsections/elements/guild.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def __init__(self, bot: commands.Bot, db: Database, *args, **kwargs) -> None:
3838
print(f"[{get_time()}] [INFO]: Guild connected")
3939
write_log(f"[{get_time()}] [INFO]: Guild connected")
4040

41-
@app_commands.command(name="auto_setup")
41+
@app_commands.command(name="auto_setup", description="Авто-настройка сервера")
4242
@commands.cooldown(1, 4, commands.BucketType.user)
4343
async def __cat_create(self, inter: discord.Interaction) -> None:
4444
if inter.user.guild_permissions.administrator or inter.user.id == 401555829620211723:
@@ -95,7 +95,7 @@ async def __cat_create(self, inter: discord.Interaction) -> None:
9595
inline=False)
9696
await inter.response.send_message(embed=self.emb)
9797

98-
@app_commands.command(name="start_money")
98+
@app_commands.command(name="start_money", description="Стартовый баланс")
9999
@app_commands.choices(arg=[
100100
app_commands.Choice(name="Получить", value="get"),
101101
app_commands.Choice(name="Установить", value="set")

slashbotsections/elements/public.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def __init__(self, bot: commands.Bot, db: Database, *args, **kwargs) -> None:
3535
print(f"[{get_time()}] [INFO]: Public connected")
3636
write_log(f"[{get_time()}] [INFO]: Public connected")
3737

38-
@app_commands.command(name="info")
38+
@app_commands.command(name="info", description="За что выдают коины?")
3939
@commands.cooldown(1, 10, commands.BucketType.user)
4040
async def __info(self, inter: discord.Interaction):
4141
self.emb = discord.Embed(title="За что выдают коины?")
@@ -55,7 +55,7 @@ async def __info(self, inter: discord.Interaction):
5555
)
5656
await inter.response.send_message(embed=self.emb)
5757

58-
@app_commands.command(name="help")
58+
@app_commands.command(name="help", description="Информация о командах бота")
5959
@app_commands.choices(arg=[
6060
app_commands.Choice(name="Пользователь", value="user"),
6161
app_commands.Choice(name="Казино", value="casino"),

0 commit comments

Comments
 (0)