discord.py - 如何制作 Discord.py 仅用于开发的命令
问题描述
如何制作 Discord.py 仅用于开发的命令
def restart_bot():
os.execv(sys.executable, ['python'] + sys.argv)
@Bot.command(name= 'restart')
async def restart(ctx):
await ctx.send("Restarting bot...")
restart_bot()
解决方案
你可以做@commands.is_owner()
基本上是这样的:
@Bot.command(name = 'restart')
@commands.is_owner()
async def restart(ctx):
await ctx.send("Restarting bot...")
restart_bot()
稍后谢谢我 :D
推荐阅读
- c - 将“ifdef”放在源文件的第一行有什么意义?
- wpf - WPF:长期持有 ListViewItem
- python - 排序列表时如何保留变量名?
- python - 作业前引用的“问卷”以 Tkinter 格式
- python - 查找数组中自定义范围内的最小值
- github - 为什么从我的 Github 加载 CSV 时出现“错误标记数据”错误,但从硬盘驱动器加载完全相同的文件时没有错误?
- javascript - 如何使用 bcrypt 对应用进行身份验证
- javascript - JS函数和lambdas是否保存在进程的代码段中?
- c# - Visual Studio 调试器不会进入“调用”指令
- ruby-on-rails - Rails 单选按钮嵌套表单