本文整理汇总了Python中discord.ext.commands.RoleConverter方法的典型用法代码示例。如果您正苦于以下问题:Python commands.RoleConverter方法的具体用法?Python commands.RoleConverter怎么用?Python commands.RoleConverter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类discord.ext.commands
的用法示例。
在下文中一共展示了commands.RoleConverter方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: dj
# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import RoleConverter [as 别名]
def dj(self, ctx, *, role):
settings = await SettingsDB.get_instance().get_guild_settings(ctx.guild.id)
if role.lower() == "none":
settings.djroleId = "NONE"
await SettingsDB.get_instance().set_guild_settings(settings)
await ctx.send(f"{SUCCESS} The DJ role has been cleared, only people with the manage server permission "
f"can use DJ commands now")
else:
try:
role = await commands.RoleConverter().convert(ctx, role)
except commands.BadArgument:
await ctx.send(f"{WARNING} That role was not found!")
return
settings.djroleId = role.id
await SettingsDB.get_instance().set_guild_settings(settings)
await ctx.send(f"{SUCCESS} DJ commands can now only be used by people who have the **{role.name}** role "
f"or the manage server permission")
示例2: convert
# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import RoleConverter [as 别名]
def convert(self, ctx, argument):
if argument == 'everyone' or argument == '@everyone':
return ctx.guild.members
try:
role = await commands.RoleConverter.convert(self, ctx, argument)
return role.members
except:
return await super().convert(ctx, argument)
示例3: _parse
# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import RoleConverter [as 别名]
def _parse(cls, value, ctx):
try:
role = await commands.RoleConverter().convert(ctx, value)
return role.id
except commands.BadArgument:
raise InvalidInputError("Try giving me a role reference like `@BotAdmin`")