IanToujou d6314a82dc 🎉 Initial commit
Took 4 minutes
2025-02-11 15:08:34 +01:00

49 lines
1.3 KiB
Python

from random import randint
import os
import discord
from discord import app_commands
discord_bot_token = os.environ["TOKEN"]
intents = discord.Intents.all()
bot_client = discord.Client(intents=intents)
tree = app_commands.CommandTree(bot_client)
"""
My Bots Overview:
https://discordapp.com/developers/applications
Discord Developer Portal:
https://discordapp.com/developers/docs/resources/channel
Discord Bot API Documentation:
https://discordpy.readthedocs.io/en/latest/api.html
Changelog:
https://discordpy.readthedocs.io/en/latest/whats_new.html
"""
@bot_client.event
async def on_ready():
print("Discord.py version {}\n".format(discord.__version__))
await tree.sync()
@tree.command(name="roll", description="rolles Dice")
async def __command_roll(interaction: discord.Interaction, amount: int, dice_size: int):
try:
rolles = [randint(1, int(dice_size)) for _ in range(int(amount))]
embed = discord.Embed(color=randint(0, 0xFFFFFF))
embed.add_field(name="Rolles", value=str(rolles), inline=False)
embed.add_field(name="Sum", value=sum(rolles), inline=False)
await interaction.response.send_message(embed=embed, ephemeral=True)
except Exception as e:
await interaction.response.send_message(content=f"Error: {e}", ephemeral=True)
###
# Start Bot
###
bot_client.run(discord_bot_token)