本文整理匯總了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`")