Skip to content
Snippets Groups Projects
Commit 1926b840 authored by dnns01's avatar dnns01
Browse files

Added feature to roll dice

parent 9d565bd8
No related branches found
No related tags found
No related merge requests found
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)
...@@ -6,6 +6,7 @@ from dotenv import load_dotenv ...@@ -6,6 +6,7 @@ from dotenv import load_dotenv
from bati_cog import BatiCog from bati_cog import BatiCog
from poll_cog import PollCog from poll_cog import PollCog
from roll_cog import RollCog
# .env file is necessary in the same directory, that contains several strings. # .env file is necessary in the same directory, that contains several strings.
load_dotenv() load_dotenv()
...@@ -17,6 +18,7 @@ intents = discord.Intents.default() ...@@ -17,6 +18,7 @@ intents = discord.Intents.default()
intents.members = True intents.members = True
bot = commands.Bot(command_prefix='!', help_command=None, activity=discord.Game(ACTIVITY), intents=intents) bot = commands.Bot(command_prefix='!', help_command=None, activity=discord.Game(ACTIVITY), intents=intents)
bot.add_cog(PollCog(bot)) bot.add_cog(PollCog(bot))
bot.add_cog(RollCog(bot))
bot.add_cog(BatiCog(bot)) bot.add_cog(BatiCog(bot))
...@@ -33,6 +35,10 @@ bot.add_cog(BatiCog(bot)) ...@@ -33,6 +35,10 @@ bot.add_cog(BatiCog(bot))
@bot.event @bot.event
async def on_ready(): async def on_ready():
print("Client started!") print("Client started!")
# channel = await bot.fetch_channel(682590504948334684)
# await channel.send("!poll \"Wie kluk bin ich?\" Sehr")
#
bot.run(TOKEN) bot.run(TOKEN)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment