所以我想做的是,当成员使用这个afk命令时,它会在他们的昵称中添加[afk],当他们回来时,它会更改为og用户名
afkdict = {}
@client.command(name = "afk", brief = "Away From Keyboard",
description = "I'll give you the afk status and if someone pings you before you come back, I'll tell "
"them that you are not available. You can add your own afk message!")
async def afk(ctx, message = "Gatau ngapain"):
global afkdict
if ctx.message.author in afkdict:
afkdict.pop(ctx.message.author)
await ctx.send('Welkom bek :-)')
else:
afkdict[ctx.message.author] = message
await ctx.send("Siap bang jago")
@client.event
async def on_message(message):
global afkdict
for member in message.mentions:
if member != message.author:
if member in afkdict:
afkmsg = afkdict[member]
await message.channel.send(f"{member}lagi afk. {afkmsg}")
await client.process_commands(message)
您只需要使用
member.edit(nick=nickname)
。因此,在您的例子中是await ctx.author.edit(nick="[AFK]")
,删除昵称await ctx.author.edit(nick="")
所以完整的命令应该是这样的
相关问题 更多 >
编程相关推荐