我试图让我的 !say 命令只对机器人所有者有效。这是我目前拥有的
@bot.command(pass_context = True)
async def say(ctx, *args):
mesg = ' '.join(args)
await bot.delete_message(ctx.message)
return await bot.say(mesg)
Run Code Online (Sandbox Code Playgroud)
该代码有效,但我想让它只有我(机器人所有者)才能运行该命令。
小智 11
您也可以使用装饰器@is_owner()
。
@bot.command(pass_context = True)
@commands.is_owner()
async def say(ctx):
your code...
Run Code Online (Sandbox Code Playgroud)
尝试通过添加 if 语句来这样做
@bot.command(pass_context=True)
async def say(ctx):
if ctx.message.author.id =='bot owner id':
then execute the following code
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
11320 次 |
最近记录: |