Where and what should I put in the discord program to make the person who sent the message comment?

Asked 2 years ago, Updated 2 years ago, 133 views

I use Python 3.7

import discord

client=discord.Client()

@client.event
async def on_ready():
    print('We have logged in as {0.user}'.format(client))

@client.event
async def on_message(message):
    if message.author==client.user:
        return

    if message.content.startswith('Hi'):
        wait message.channel.send('hello')

client.run ("Token")

python python3 discord

2022-09-30 19:20

1 Answers

User class ment can be used.Below is a sample code.

@client.event
async def on_message(message):
    if message.author==client.user:
        return

    if message.content.startswith('Hi'):
        msg = f "{message.author.ment} Hello!"
        wait message.channel.send(msg)

f"..." is the format string, verified to work with Python 3.7.2, discord.py 1.0.0a1691+gf686924.


2022-09-30 19:20

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.