dolfies / discord.py-self

A fork of the popular discord.py for user accounts.
https://discordpy-self.rtfd.io/en/latest/
MIT License
680 stars 162 forks source link

wait_for not returning message #123

Closed Mehul343 closed 2 years ago

Mehul343 commented 2 years ago

Summary

wait_for function is not returning contents of message

Reproduction Steps

Run the code the do ;p then wait for an embed.

Code

config import token, channelid, userid
from selfcord.ext import commands

bot = commands.Bot(command_prefix=';', self_bot=True)

meowid = 664508672713424926

def check(msg):
      lambda m: m.author.id == meowid and m.channel == msg.channel

def footer(ctx):
     embeds = ctx.embeds
     for embed in embeds:
         print(embed)
         footer=str(embed.footer)
         print(footer)
         return footer

@bot.command()
async def p(ctx):
      if ctx.channel.id == channelid and ctx.author.id == userid:
         try:
            try:        
                  msg = await bot.wait_for("message", check=check(ctx), timeout=10)

            except:
                  print("Test 1 Failed")

            else:
                  print(str(msg.embeds))
                  if f"Common" in footer(msg):
                        await ctx.send("gb")
         except:
               pass

bot.run(token)

Expected Results

print(str(msg.embeds)) should return contents of the embed.

Actual Results

It is returning an empty list but the message does have an embed.

System Information

Checklist

Additional Information

No response

Buster-2002 commented 2 years ago

dont pass ctx to your check, you're also passing ctx.embeds to a function that takes ctx directly, not to mention that its Context.message.embeds

Mehul343 commented 2 years ago

dont pass ctx to your check

Then what should I pass?

Buster-2002 commented 2 years ago

dont pass ctx to your check

Then what should I pass?

nothing, read the docs https://discordpy.readthedocs.io/en/latest/ext/commands/api.html?highlight=wait_for#discord.ext.commands.Bot.wait_for

channelid, userid and your imports, and probably more stuff are busted. Please read up on providing a minimal reproducable example for future issues/questions. (this applies basically anywhere)

Mehul343 commented 2 years ago

dont pass ctx to your check

Then what should I pass?

nothing, read the docs https://discordpy.readthedocs.io/en/latest/ext/commands/api.html?highlight=wait_for#discord.ext.commands.Bot.wait_for

channelid, userid and your imports, and probably more stuff are busted. Please read up on providing a minimal reproducable example for future issues/questions. (this applies basically anywhere)

thanks it now works