Skip to content Skip to sidebar Skip to footer

Discord.py Check Mentioned Id With List Of Id

My bot would save my id if I type -afk, and when another user mentions me, my bot would send message that I'm afk. The problem is that my if statements are not working when I'm try

Solution 1:

Message.raw_mentions returns a list. You can use any(id in afk_list for id in mentioned) to see if anything from that list is also in afk_list. If you use Message.mentions instead, you can also specify which users are afk.

asyncdefon_message(self, message):
    mentioned = message.mentions

    for user in mentions:
        if user.idin afk_list:
            await self.client.send_message(message.channel, '{} is AFK'.format(user.display_name))

You also can't use Bot.say outside of commands.

Post a Comment for "Discord.py Check Mentioned Id With List Of Id"