0

I have a problem in line 19 of my code. It says that there is a missing argument, which is 'event'. However, I don't know how to fix this. I have looked into the docs for discord.py but I can't find anything. Can anyone help me?

from discord import Client
from discord.ext import commands
from random import randint

class Guess(commands.Cog, name="Guess the number game"):
    """This is a guess the number game."""

    def __init__(self, bot):
        self.bot = bot
            
    @commands.command(name="guess")
    async def _guess(self, ctx):
        number = randint(1, 100)
        guesses = 0

        while True:
            await ctx.send("Guess a number (send 'exit()') to stop:")

            response = await Client.wait_for("message")

            if response.content == "exit()":
                await ctx.send(":thumbsup: Stopped the game!")
                break
            else:
                try:
                    guess = int(response.content)
                except Exception:
                    await ctx.send(":question: That's not a valid input! Try again.")

            if guess > number:
                await ctx.send("Too high! Try again.")
                guesses += 1
            elif guess < number:
                await ctx.send("Too low! Try again.")
                guesses += 1
            else:
                await ctx.send(f":white_check_mark: That's correct! It took you {guesses} {'guess' if guesses == 1 else 'guesses'} to get it.")

def setup(bot):
    bot.add_cog(Guess(bot))
2
  • 1
    What is unclear from the Discord API example? Commented Jan 8, 2022 at 19:38
  • The difference is that in the Discord API example, all the code is in one file. However, in my code, the cogs are split into different files. Commented Jan 9, 2022 at 10:31

1 Answer 1

1

You must change Client.wait_for("message") to self.bot.wait_for("message")

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.