Reputation: 119
number = await self.client.wait_for("message", check=lambda m: m.author == ctx.author and m.channel == ctx.channel, timeout=20.0)
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))
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 -
Upvotes: 0
Views: 891
Reputation: 3852
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)
Upvotes: 2