39 lines
724 B
Python
39 lines
724 B
Python
import discord
|
|
from discord.ext import commands
|
|
from discord.ext.commands.context import Context
|
|
|
|
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)
|
|
|
|
|
|
bot.add_command(roll)
|