當前位置: 首頁>>代碼示例>>Python>>正文


Python commands.RoleConverter方法代碼示例

本文整理匯總了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") 
開發者ID:initzx,項目名稱:rewrite,代碼行數:19,代碼來源:settings.py

示例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) 
開發者ID:henry232323,項目名稱:RPGBot,代碼行數:10,代碼來源:data.py

示例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`") 
開發者ID:mdiller,項目名稱:MangoByte,代碼行數:8,代碼來源:botdatatypes.py


注:本文中的discord.ext.commands.RoleConverter方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。