0

This is the line of code with the error:

number = await self.client.wait_for("message", check=lambda m: m.author == ctx.author and m.channel == ctx.channel, timeout=20.0)

This line is inside a 'Shop' class that looks like this:

class Shop(commands.Cog, name="Shop"):
    """asks for a number of how much to buy"""

   def __init__(self, bot: commands.Bot):
    self.bot = bot

   # That line of code is somewhere here

def setup(bot: commands.Bot):
    bot.add_cog(Shop(bot))  

The full error looks like this:

number = await self.client.wait_for("message", check=lambda m: m.author == ctx.author and m.channel == ctx.channel, timeout=20.0)
AttributeError: 'Shop' object has no attribute 'client'

I am dealing with cogs for the first time so it makes sense that I encountered so many errors. But this error specifically hung me for a very long time and I do not no what I should do

I tried:

number = await client.wait_for("message", check=lambda m: # and so on..)

number = await Bot.wait_for("message", check=lambda m: # and so on..)

number = await self.client.wait_for("message", check=lambda m: # and so on..)

And non of them worked for me... This is dealing with discord.py and I am developing a bot with the command "Shop" that asks for input (a number) with "wait_for" and it stores it in the variable "number" so that I can use it in the rest of the command. Would appreciate some help, Thanks -

1 Answer 1

2

If you set up cogs correctly, the client is the bot itself, so you should be using self.bot:

number = await self.bot.wait_for("message", check=lambda m: m.author == ctx.author and m.channel == ctx.channel, timeout=20.0)
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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.