async def playingr_processr(self, ctx, reaction, user): if reaction.emoji in self.controls: if self.controls[reaction.emoji] == "pause_resume": if utilities.get_permission(ctx, "pause", id = user.id) or user == ctx.message.server.owner or user.id == clients.owner_id: embed = discord.Embed(color = clients.bot_color).set_author(name = user.display_name, icon_url = user.avatar_url or user.default_avatar_url) try: self.bot.cogs["Audio"].players[ctx.message.server.id].pause() except errors.AudioNotPlaying: embed.description = ":no_entry: There is no song to pause" except errors.AudioAlreadyDone: self.bot.cogs["Audio"].players[ctx.message.server.id].resume() embed.description = ":play_pause: Resumed song" else: embed.description = ":pause_button: Paused song" await self.bot.send_message(ctx.message.channel, embed = embed) await self.bot.attempt_delete_message(ctx.message) elif self.controls[reaction.emoji] in ("skip", "replay", "shuffle", "radio"): if utilities.get_permission(ctx, self.controls[reaction.emoji], id = user.id) or user.id in (ctx.message.server.owner.id, clients.owner_id): message = copy.copy(ctx.message) message.content = "{}{}".format(ctx.prefix, self.controls[reaction.emoji]) await self.bot.process_commands(message) # Timestamp for radio elif self.controls[reaction.emoji] in ("volume_down", "volume_up"): if utilities.get_permission(ctx, "volume", id = user.id) or user.id in (ctx.message.server.owner, clients.owner_id): try: current_volume = self.bot.cogs["Audio"].players[ctx.message.server.id].get_volume() except errors.AudioNotPlaying: await self.bot.embed_reply(":no_entry: Couldn't change volume\nThere's nothing playing right now") if self.controls[reaction.emoji] == "volume_down": set_volume = current_volume - 10 elif self.controls[reaction.emoji] == "volume_up": set_volume = current_volume + 10 message = copy.copy(ctx.message) message.content = "{}volume {}".format(ctx.prefix, set_volume) await self.bot.process_commands(message)
def is_permitted_check(ctx): if ctx.message.channel.is_private: return True command = ctx.command permitted = utilities.get_permission(ctx, command.name, id=ctx.message.author.id) while command.parent is not None and not permitted: # permitted is None instead? command = command.parent permitted = utilities.get_permission(ctx, command.name, id=ctx.message.author.id) # include non-final parent commands? return permitted or is_server_owner_check(ctx)
async def getpermission_user(self, ctx, user : str, permission : str): if permission not in self.bot.commands: return (await self.bot.embed_reply("Error: {} is not a command".format(permission))) command = self.bot.commands[permission].name _user = await utilities.get_user(ctx, user) if not _user: return (await self.bot.embed_reply("Error: user not found")) setting = utilities.get_permission(ctx, command, id = _user.id) await self.bot.embed_reply("{} is set to {} for {}".format(permission, setting, _user))
def predicate(ctx): if not is_voice_connected_check(ctx): if is_server_owner_check(ctx) or utilities.get_permission( ctx, "join", id=ctx.message.author.id): raise errors.PermittedVoiceNotConnected else: raise errors.NotPermittedVoiceNotConnected return True
def not_forbidden_check(ctx): if ctx.message.channel.is_private: return True permitted = utilities.get_permission(ctx, ctx.command.name, id=ctx.message.author.id) # TODO: Include subcommands? return permitted or permitted is None or is_server_owner_check(ctx)
async def getpermission_role(self, ctx, role : str, permission : str): if permission not in self.bot.commands: return (await self.bot.embed_reply("Error: {} is not a command".format(permission))) command = self.bot.commands[permission].name matches = [_role for _role in ctx.message.server.roles if _role.name == role] if len(matches) > 1: return (await self.bot.embed_reply("Error: multiple roles with the name, {}".format(role))) elif len(matches) == 0: return (await self.bot.embed_reply('Error: role with name, "{}", not found'.format(role))) else: _role = matches[0] setting = utilities.get_permission(ctx, command, type = "role", id = _role.id) await self.bot.embed_reply("{} is set to {} for the {} role".format(permission, setting, _role.name))
async def getpermission(self, ctx, *options : str): '''Get a permission''' if len(options) == 2: if options[1] not in self.bot.commands: return (await self.bot.embed_reply("Error: {} is not a command".format(options[1]))) command = self.bot.commands[options[1]].name user = await utilities.get_user(ctx, options[0]) if not user: return (await self.bot.embed_reply("Error: user not found")) setting = utilities.get_permission(ctx, command, id = user.id) await self.bot.embed_reply("{} is set to {} for {}".format(options[1], setting, user)) else: await self.bot.embed_reply(":no_entry: Invalid input\ngetpermission everyone|role|user or <user> <permission>") #options
async def getpermission_everyone(self, ctx, permission : str): if permission not in self.bot.commands: return (await self.bot.embed_reply("Error: {} is not a command".format(permission))) command = self.bot.commands[permission].name setting = utilities.get_permission(ctx, command, type = "everyone") await self.bot.embed_reply("{} is set to {} for everyone".format(permission, setting))