I am working on a project for verification purposes, but I am having trouble finding any sources that point to how you can check for responses and their validity, as well as whether or not it is a response to the bot question. Any suggestions or sources would be greatly appreciated.
You can either use the on_message
event or wait_for
@bot.event
async def on_message(message):
# Checking if the type of the channel is `discord.DMChannel`
if isinstance(message.channel, discord.DMChannel):
await message.channel.send("Responding in dm's")
@bot.command()
async def command(ctx):
def check(message):
# Checking if the author of the message is the same as the author of the command
# And if the channel is a `discord.DMChannel` instance
return message.author == ctx.author and isinstance(message.channel, discord.DMChannel)
await ctx.author.send("Waiting for a reply in dm's")
message = await bot.wait_for('message', check=check)
await ctx.author.send("Responding in dm's")
Reference:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.