sir-rollington/bot.py

45 lines
841 B
Python
Raw Normal View History

2025-01-15 08:54:17 -05:00
import discord
from discord.ext import commands
from discord.ext.commands.context import Context
2025-01-15 22:00:37 -05:00
from os import environ
2025-01-15 08:54:17 -05:00
from dice import Dice, DiceTextError
prefix = "$"
intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix=prefix, intents=intents)
@bot.event
async def on_ready():
print("Hello World!")
@bot.command()
async def roll(ctx: Context, *args: str):
dice = []
for arg in args:
dice.append(Dice(arg))
try:
results = ["(" + ",".join(d.roll()) + "," for d in dice]
except DiceTextError as e:
print(e)
await ctx.send(str(e))
return
msg = ",".join(results)
print(msg)
await ctx.send(msg)
2025-01-15 22:00:37 -05:00
token = environ.get("DISCORD_TOKEN")
if token is None:
print("Could not load token")
quit()
bot.run(token)