所以我知道有一个关于堆栈溢出的类似问题,但它是针对 discord.js 的,我使用的是 discord.py 所以有人可以告诉我(这也是我关于堆栈溢出的第一个问题)
(This is my first reply aswell!)
so lets say
import discord
from discord.ext import commands #or command I can't remember)
#setup setting(on_ready.. etc)
@client.command(ctx, target:discord.Member == None) #CTX represents your command, target means your mentioned member
if target == None:
await ctx.send("You didn't mention anyone!")
else:
await ctx.send(target.mention)
#client run token
Okay so the above one is almost correct. The solution is:
@client.command()
async def something(ctx, target:discord.Member = None):
if target == None:
await ctx.send("You didn't mention anyone!")
else:
await ctx.send(target.mention)
#whatever other code
so it's target:discord.Member = None
instead of target:discord.Member == None
and that async def thingy ofcourse :)
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.