diff --git a/roll_cog.py b/roll_cog.py new file mode 100644 index 0000000000000000000000000000000000000000..6bf3111cf11b6ecc6ced3711653641d60b34048b --- /dev/null +++ b/roll_cog.py @@ -0,0 +1,19 @@ +import random + +from discord.ext import commands + + +class RollCog(commands.Cog): + def __init__(self, bot): + self.bot = bot + + @commands.command(name="roll") + async def cmd_roll(self, ctx, dice="w6", qty=1): + """ Roll a/multiple dice """ + + eyes = int(dice[1:]) + answer = f"Es wurden {qty} {dice.upper()} geworfen, mit folgenden Ergebnissen:\n" + for i in range(qty): + answer += f"{i + 1}. Wurf: {random.randrange(1, eyes + 1)}\n" + + await ctx.send(answer) diff --git a/strolly.py b/strolly.py index ab108e7c72a721736bb6784ed01d454a393ac3ab..3b009f113c5758fc20964383c544fb0d8b2080c8 100644 --- a/strolly.py +++ b/strolly.py @@ -6,6 +6,7 @@ from dotenv import load_dotenv from bati_cog import BatiCog from poll_cog import PollCog +from roll_cog import RollCog # .env file is necessary in the same directory, that contains several strings. load_dotenv() @@ -17,6 +18,7 @@ intents = discord.Intents.default() intents.members = True bot = commands.Bot(command_prefix='!', help_command=None, activity=discord.Game(ACTIVITY), intents=intents) bot.add_cog(PollCog(bot)) +bot.add_cog(RollCog(bot)) bot.add_cog(BatiCog(bot)) @@ -33,6 +35,10 @@ bot.add_cog(BatiCog(bot)) @bot.event async def on_ready(): print("Client started!") + # channel = await bot.fetch_channel(682590504948334684) + # await channel.send("!poll \"Wie kluk bin ich?\" Sehr") +# + bot.run(TOKEN)