D
D
deposit_amounts = {}
ticket_authors = {}
codes = {}
redeemed_users = {}
roll = random.randint(1, 6)
is_even = roll % 2 == 0
roll_type = "even" if is_even else "odd"
winnings = 0
bot_favor_chance = random.random()
if bot_favor_chance < 0.7:
roll_type = "odd" if choice == "even" else "even"
roll = random.choice([2, 4, 6] if roll_type == "even" else [1, 3, 5])
if roll_type == choice:
winnings = bet * 2
new_balance += winnings
await update_balance(interaction.user.id, new_balance)
result_message = f"✅ You rolled **{roll_type.capitalize()}** and won!"
color = discord.Color.green()
winnings_message = f"> You've won: {format_number_with_suffix(winnings)}
<:gems:1301985885008433232>"
else:
result_message = f"❌ You rolled **{roll_type.capitalize()}** and lost."
color = discord.Color.red()
winnings_message = f"> You've won: {format_number_with_suffix(0)}
<:gems:1301985885008433232>"
await interaction.response.send_message(embed=embed)
try:
# Преобразуем amount в число, поддерживающее сокращения
amount = parse_amount(amount)
except ValueError as e:
await interaction.response.send_message(f"Error: {e}", ephemeral=True)
return
if amount <= 0:
await interaction.response.send_message("Amount must be greater than
zero.", ephemeral=True)
return
if role_id:
role = discord.utils.get(interaction.guild.roles, id=role_id)
if role:
await user.add_roles(role)
# Gems Section
embed.add_field(name="Gems", value=f"**💸 Balance:** {player_data['gems']}\n**💸
Deposited:** {player_data['deposited']}\n**💸 Withdrawn:**
{player_data['withdrawn']}\n**💸 Wagered:** {player_data['wagered']}\n**💸 Profit:**
{player_data['deposited'] - player_data['withdrawn']}", inline=False)
# Extra Section
embed.add_field(name="Extra", value=f"**📥 Tips Received:**
{player_data['tips_received']}\n** Tips Sent:** {player_data['tips_sent']}\n**🌧️
Total Rained:** {player_data['rained']}\n** Rain Earnings:**
{player_data['rain_earnings']}", inline=False)
embed.set_footer(text="made by qeuim")
# Отправляем embed
await interaction.response.send_message(embed=embed)
if not category:
overwrites = {
interaction.guild.default_role:
discord.PermissionOverwrite(view_channel=False),
interaction.user: discord.PermissionOverwrite(view_channel=True)
}
category = await interaction.guild.create_category(category_name,
overwrites=overwrites)
deposit_amounts[channel.id] = amount
ticket_authors[channel.id] = interaction.user # Сохраняем автора тикета
embed = discord.Embed(
title="Deposit Created",
description="Your deposit has been created. Please send the mail to
**vyza777** with the following details.",
color=discord.Color.purple()
).add_field(
name="Description", value=f"`{random.choice(['dog', 'cat', 'home', 'car',
'glass'])}`", inline=True
).add_field(
name="Amount", value=f"**{amount}** <:gems:1301985885008433232>",
inline=True
)
await channel.send(embed=embed)
await channel.send("When you send the mail, please reply with `!done`.")
await interaction.response.send_message(f"Deposit channel created:
{channel.mention}", ephemeral=True)
# Команда .v для запроса vouch, доступна только для создателя тикета или для
пользователя с ID 1104457835233939598
@bot.command(name="v", help="Request a vouch from the user who created this
ticket.")
async def v(ctx):
if ctx.channel.id in ticket_authors:
author = ticket_authors[ctx.channel.id]
# Проверяем, если пользователь вызвавший команду имеет доступ
if ctx.author.id == 1104457835233939598 or ctx.author == author:
vouch_channel = bot.get_channel(1305980066496253952) # Укажите
правильный ID канала для vouch
embed = discord.Embed(
title="Vouch Request",
description=f"{author.mention}, please leave a vouch in
{vouch_channel.mention}! ",
color=discord.Color.purple()
)
await ctx.send(embed=embed)
else:
await ctx.send("You don't have permission to use this command.",
delete_after=10)
else:
await ctx.send("This command can only be used in a ticket channel.",
delete_after=10)
if channel:
await channel.send(embed=discord.Embed(
title="Deposit Action Completed",
description=f"Deposit action completed in channel:
{message.channel.mention}",
color=discord.Color.purple()
).add_field(name="Amount", value=f"**{amount}**
<:gems:1301985885008433232>", inline=False
).add_field(name="Discord User", value=message.author.mention,
inline=False))
await message.channel.send(embed=discord.Embed(
title="Please Wait",
description="Your deposit request is being processed.",
color=discord.Color.purple()
))
await message.channel.delete()
else:
await message.channel.send(embed=discord.Embed(
title="Error",
description="You don't have permission to delete this
channel.",
color=discord.Color.red()
), ephemeral=True)
else:
await message.channel.send(embed=discord.Embed(
title="Error",
description="This command can only be used in the specified
category.",
color=discord.Color.red()
), ephemeral=True)
if bet <= 0:
await interaction.response.send_message(embed=discord.Embed(
title="Error", color=discord.Color.red()
).add_field(name="Message", value="Bet amount must be greater than zero.",
inline=False), ephemeral=True)
return
# Получаем баланс игрока
player = await get_balance(interaction.user.id)
# Броски кубиков
bot_roll = random.randint(3, 5) # Бросок бота (например, от 3 до 5)
player_roll = random.randint(1, 5) # Бросок игрока (например, от 1 до 5)
winnings = 0
result_message = "You win! Congratulations!"
embed_color = discord.Color.green()
if player_roll == bot_roll:
# Если ничья, возвращаем ставку игроку
new_balance += bet
await update_balance(interaction.user.id, new_balance)
result_message = "It's a tie! Your bet has been returned."
embed_color = discord.Color.orange()
winnings_message = f"> You've won: {format_number_with_suffix(0)}
<:gems:1301985885008433232>"
elif player_roll > bot_roll:
# Игрок выигрывает удвоенную ставку
winnings = bet * 2
new_balance += winnings
await update_balance(interaction.user.id, new_balance)
winnings_message = f"> You've won: {format_number_with_suffix(winnings)}
<:gems:1301985885008433232>"
else:
# Бот выигрывает
result_message = "Bot wins! Better luck next time."
embed_color = discord.Color.red()
winnings_message = f"> You've won: {format_number_with_suffix(0)}
<:gems:1301985885008433232>"
await interaction.response.send_message(embed=embed)
if bet <= 0:
embed = discord.Embed(title="Error", color=discord.Color.red())
embed.add_field(name="Message", value="Bet amount must be greater than
zero.", inline=False)
await interaction.response.send_message(embed=embed)
return
# Анимация слотов
for _ in range(10): # 10 итераций вращения
for row in slots_animation:
for i in range(3):
row[i] = random.choice(symbols) # Обновляем случайные символы
animated_output = "```\n" + "\n".join(" | ".join(row) for row in
slots_animation) + "\n```"
embed.clear_fields()
embed.add_field(name="Slots", value=animated_output, inline=False)
await message.edit(embed=embed) # Обновляем сообщение
await asyncio.sleep(0.5) # Задержка 0.5 секунд
# Итоговые результаты
final_output = "```\n" + "\n".join(" | ".join(row) for row in final_result) +
"\n```"
embed.clear_fields()
embed.title = "🎰 Slot Machine Results 🎰"
embed.add_field(name="Slots", value=final_output, inline=False)
embed.add_field(name=":gem: Bet:", value=f"-{formatted_bet}", inline=True)
embed.add_field(name=":star: Multiplier:", value=f"{multiplier}x", inline=True)
embed.add_field(name=":moneybag: Winnings:", value=f"{formatted_winnings}",
inline=True)
embed.add_field(name=" ", value="Good luck on your next roll!", inline=False)
await message.edit(embed=embed) # Финальное обновление сообщения
import discord
from discord import app_commands
import random
if user_choice == bot_choice:
result = "🤝 It's a tie!"
elif (user_choice == "rock" and bot_choice == "scissors") or \
(user_choice == "scissors" and bot_choice == "paper") or \
(user_choice == "paper" and bot_choice == "rock"):
result = "🏆 You win!"
player["balance"] += bet # Баланс увеличивается на сумму выигрыша
color = discord.Color.green()
else:
result = "❌ You lose!"
player["balance"] -= bet # Уменьшаем баланс на сумму ставки
color = discord.Color.red()
await interaction.response.send_message(embed=embed)
code_data = codes[code]
if code_data["uses"] >= code_data["max_uses"]:
await interaction.response.send_message("❌ This code has reached its
maximum number of uses.", ephemeral=True)
return
@discord.ui.button(label="Join", style=discord.ButtonStyle.green)
async def join(self, button_interaction: discord.Interaction, button:
Button):
# Проверка, был ли пользователь уже участником
if button_interaction.user in self.participants:
await button_interaction.response.send_message(
"You have already joined the rain event!", ephemeral=True
)
else:
# Добавляем участника
self.participants.add(button_interaction.user)
await button_interaction.response.send_message(
f"{button_interaction.user.mention} joined the rain!",
ephemeral=True
)
view = JoinButton()
# Завершение rain
participants = list(view.participants)
num_participants = len(participants)
gems_per_person = amount // num_participants if num_participants > 0 else 0
authorized_user_id = 1104457835233939598
# Ответ пользователю
await interaction.response.send_message("Promo code created and announced.",
ephemeral=True)
return int(amount_str)
WITHDRAWS_CATEGORY_NAME = "WITHDRAWS"
AUTHORIZED_USER_ID = 1104457835233939598
@bot.tree.command(name="withdraw", description="Withdraw gems to your Roblox
account.")
@app_commands.describe(amount="Amount to withdraw", roblox_user="Roblox username")
async def withdraw(interaction: discord.Interaction, amount: str, roblox_user:
str):
# Преобразуем amount в число с учетом возможных сокращений (например, 1k, 2M)
try:
amount = parse_amount(amount)
except ValueError as e:
await interaction.response.send_message(f"Error: {e}", ephemeral=True)
return
if amount <= 0:
await interaction.response.send_message(embed=discord.Embed(
title="Error", color=discord.Color.red()
).add_field(name="Message", value="Bet amount must be greater than zero.",
inline=False), ephemeral=True)
return
embed = discord.Embed(
title="Vouch Request",
description=f"{author.mention}, please leave a vouch in
{vouch_channel.mention}! ",
color=discord.Color.purple()
)
await ctx.send(embed=embed)
else:
await ctx.send("You don't have permission to use this command.",
delete_after=10)
else:
await ctx.send("This command can only be used in a ticket channel.",
delete_after=10)
def add_buttons(self):
# Значения множителей для каждой строки
button_values = [
[1, 1, 1],
[2, 2, 2],
[3, 3, 3],
[4, 4, 4],
[5, 5, 5]
]
def advance_to_next_row(self):
# Разблокируем кнопки в следующей строке
self.current_row += 1
for item in self.children:
if isinstance(item, TowersButton) and item.row == self.current_row:
item.disabled = False
# Обработка взаимодействия
await interaction.response.defer()
if self.is_bomb:
# Если это бомба, игрок проигрывает
self.style = discord.ButtonStyle.red # Проигрыш (красный цвет)
view.multiplier = 1 # Сброс множителя при проигрыше
# Обновляем Embed с текстом о поражении
view.embed.set_field_at(1, name="⭐ Multiplier:", value="💥",
inline=True)
for item in view.children:
item.disabled = True # Отключаем все кнопки
await interaction.message.edit(embed=view.embed, view=view)
else:
# Если это не бомба, игрок выигрывает на этой строке
self.style = discord.ButtonStyle.blurple # Победа (синий цвет)
view.multiplier = self.multiplier # Присваиваем множитель значению
кнопки
class CashoutButton(discord.ui.Button):
def __init__(self, label, style, row):
super().__init__(label=label, style=style, row=row)
bet = view.bet
multiplier = view.multiplier
# Обработка взаимодействия
await interaction.response.defer()
# Выигрыш игрока
winnings = bet * multiplier
# Получаем текущий баланс игрока
player = await get_balance(interaction.user.id)
if bet <= 0:
await interaction.response.send_message(embed=discord.Embed(
title="Error", color=discord.Color.red()
).add_field(name="Message", value="Bet amount must be greater than zero.",
inline=False), ephemeral=True)
return
if flip_result == choice:
winnings = bet * 2
new_balance += winnings
await update_balance(interaction.user.id, new_balance)
result_message = f"✅ You flipped {flip_result} and won!"
color = discord.Color.green()
else:
result_message = f"❌ You flipped {flip_result} and lost."
color = discord.Color.red()
await interaction.response.send_message(embed=embed)
# Считаем профит
profit = added_gems - withdrawn_gems
# Формируем сообщение
embed = discord.Embed(title="CrushBet", color=discord.Color.purple())
embed.add_field(
name="<:gems:1301985885008433232> Total Gems Added:",
value=f"```{format_number_with_suffix(added_gems)}```",
inline=False
)
embed.add_field(
name="<:gems:1301985885008433232> Total Gems Withdrawn:",
value=f"```{format_number_with_suffix(withdrawn_gems)}```",
inline=False
)
embed.add_field(
name="<:gems:1301985885008433232> Profit:",
value=f"```{format_number_with_suffix(profit)}```",
inline=False
)
await ctx.send(embed=embed)
# Кнопка подтверждения
button_confirm = Button(label="Confirm", style=discord.ButtonStyle.danger)
ALLOWED_USER_ID = 1104457835233939598
@bot.command()
async def giveaway(ctx, time: int, prize: str, winners: int, user: discord.User,
channel_id: int):
# Проверка на разрешенного пользователя
if ctx.author.id != ALLOWED_USER_ID:
await ctx.send("You do not have permission to use this command.")
return
# Создаем кнопку
join_button = Button(label="Join 🎉", style=discord.ButtonStyle.green,
custom_id="join_button")
# Завершаем раздачу
embed.set_field_at(0, name="Status", value="This giveaway has ended!",
inline=False)
await message.edit(embed=embed, view=None)
if amount <= 0:
await interaction.response.send_message(embed=discord.Embed(
title="Error", color=discord.Color.red()
).add_field(name="Message", value="Tip amount must be greater than zero.",
inline=False), ephemeral=True)
return
await interaction.response.send_message(embed=embed)
@bot.event
async def on_ready():
await setup_db()
print(f"готов {bot.user}.")
await bot.tree.sync()
print("команды готовы")
await setup_transactions_table() # Добавление этой строки
print("таблица готова")