python - 角色特定命令
问题描述
角色特定的命令是的,它的工作终于得到了它。
from discord.ext import commands
bot = commands.Bot('?')
@bot.command(pass_context=True)
@commands.has_any_role("Admin", "Moderator")
async def hello(ctx):
await bot.say("Hello {}".format(ctx.message.author.mention))
解决方案
您可以使用discord.ext.commands
提供has_any_role
装饰器的扩展程序。
from discord.ext import commands
bot = commands.Bot('?')
@bot.command(pass_context=True)
@commands.has_any_role("Admin", "Moderator")
async def hello(ctx):
await bot.say("Hello {}".format(ctx.message.author.mention))
推荐阅读
- kubernetes - Istio 虚拟服务:仅允许通过 IP 地址列表访问某些 api
- neural-network - 使用 Brain.js 神经网络比较数组中的字符串和数字
- javascript - 无法迭代到隐藏值字段
- r - 通过插值替换 NA
- jsf - 点击建议后 inputtextarea 会触发任何事件吗?
- azure - 用于 webhook 的 Azure RM 模板 resourceId()
- email - 通过 Godaddy 使用 Classic ASP 发送电子邮件
- python - 在一行中用函数填充一个 numpy 二维数组
- r - list.files 输出,语言环境依赖
- css - 使用方尖碑时将css文件放在哪里