Home computickets Disord Bot and Mention

Disord Bot and Mention

Author

Date

Category

I want to do so that at the mention of the bot, he answered something to it. However, how to do it, I did not understand.

async def & lt; here is id & gt; (CTX):
  await ctx.send ("Something wanted?")

Answer 1, Authority 100%

For this you do not need to create a function with a form of mentioning the bot – it will not work.

The easiest way to create a messaging handler is on_message () and check if the bot is mentioned in the list of all references that the message contains.

import discord
from discord.ext import commands
Bot = Commands.bot (Command_Prefix = '!', Intens = Discord.intens.all ())
@ Bot.Event
ASYNC DEF ON_MESSAGE (Message):
  If Message.Author == Bot.user:
    Return.
  ELSE:
    If Bot.user in Message.Mentions:
      await message.channel.send ('Something wanted?')
Bot.Run ('Token')

Do not forget to specify a token from your bot!

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions