import random import logging from discord.ext import commands logger = logging.getLogger(__name__) class RandomizerCog(commands.Cog): def __init__(self, bot: commands.Bot): self.bot = bot logger.info("Randomizer cog loaded successfully") @commands.command(name="rng") async def rng(self, ctx: commands.Context, maximum: int = 100): if maximum < 1: await ctx.send("Please provide a maximum number greater than 0.") return result = random.randint(1, maximum) await ctx.send(f" I rolled a **{result}** (from 1-{maximum}).") @commands.command(name="choose") async def choose(self, ctx: commands.Context, *options: str): if not options: await ctx.send("No options provided.") return if len(options) == 1: await ctx.send(f"I choose **{options[0]}**.") return choice = random.choice(options) await ctx.send(f"Out of those options, I have chosen **{choice}**.") async def setup(bot: commands.Bot): await bot.add_cog(RandomizerCog(bot))