只说命令机器人所有者 [英] Making say command bot owner only

查看:13
本文介绍了只说命令机器人所有者的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试让我的 !say 命令仅适用于机器人所有者.这是我目前拥有的

I am trying to make my !say command only work for the bot owner. This is what I currently have

@bot.command(pass_context = True)
async def say(ctx, *args):
    mesg = ' '.join(args)
    await bot.delete_message(ctx.message)
    return await bot.say(mesg)

代码有效,但我想让它只有我(机器人所有者)才能运行命令.

The code works but I want to make it so only I (the bot owner) can run the command.

推荐答案

通过添加 if 语句尝试这样做

Try doing it this way by adding an if statement

@bot.command(pass_context=True)
async def say(ctx):
      if ctx.message.author.id =='bot owner id':
      then execute the following code

这篇关于只说命令机器人所有者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆