简体   繁体   中英

How do I get the user who wrote the bot command? Discord.py

How do I get the user who wrote the bot command? So the author of the message.

Code:

import discord
from discord.ext import commands

client = commands.Bot(command_prefix='!')

@client.event
async def on_ready():
    print('Bot wurde gestartet: ' + client.user.name)
#wts        
@client.command()
async def wts(ctx,name_schuh,preis,festpreis,url):
    channel = client.get_channel(693503741156130897)
    embed=discord.Embed(title="WTS", description= "@USER", color=0x00ff00)
    embed.add_field(name="**Sneaker:** ", value= name_schuh)
    embed.add_field(name="**Price:** ", value=preis)
    embed.add_field(name="**Negotiable:** ", value=festpreis)
    embed.set_thumbnail(url= url)
    await channel.send( embed = embed)

ctx.author will give you the Member that sent the message.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM