Home > Enterprise >  How can I make my Discord Bot send a message every-time a user types 'verify'
How can I make my Discord Bot send a message every-time a user types 'verify'

Time:01-23

I have tried to search the web for ways to do this, but I've had no luck. I know this is seems very easy, but I am just starting with discord.py and I'm looking for some help. Thanks.

CodePudding user response:

Here

@client.event
async def on_message(message):
    if message.content == "verify":
        #Your code

    

CodePudding user response:

import discord

token = '<insert-token-here>'

# Make sure to enable the Message Content intent in the Discord developer portal
client = discord.Client(intents=discord.Intents.all())

@client.event
async def on_ready():
    print(f"Logged on as {client.user}")

@client.event
async def on_message(message: discord.Message):
    if message.author == client.user:
        # skip message from self
        return
    print(f"Message: {message.content}")
    await message.channel.send(message.content)

if __name__ == '__main__':
    client.run(token)
  • Related