Python discord.ext.commands.RoleConverter() Examples

The following are 3 code examples of discord.ext.commands.RoleConverter(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module discord.ext.commands , or try the search function .
Example #1
Source File: settings.py    From rewrite with GNU General Public License v3.0 6 votes vote down vote up
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") 
Example #2
Source File: data.py    From RPGBot with GNU General Public License v3.0 5 votes vote down vote up
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) 
Example #3
Source File: botdatatypes.py    From MangoByte with MIT License 5 votes vote down vote up
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`")