async def kill(self, ctx): if (ctx.message.author.id == self.bot.owner_id): await ctx.send("Aight, ima head out <:Tuturu:743261358509785099>") db.commit() await self.bot.logout() else: raise MissingPermissions( "This command is reserved for the author.")
async def predicate(ctx): if ctx.guild is None: raise commands.NoPrivateMessage( 'This command can only be used in a server.') if not ctx.author.guild_permissions.administrator: raise MissingPermissions('administrator') return True
def wrapper(ctx: Context): user_perms = get_user_role_permissions(ctx.author) missing = [i for i in perms if not has_own_permission(i, user_perms)] if missing: raise MissingPermissions(missing) return True
def predicate(ctx: CommandContext): author: Member = ctx.message.author if author.id in ADMINS: return True elif not author.guild_permissions.administrator: raise MissingPermissions( "You are missing administrator permissions") else: return True
def predicate(ctx: CommandContext): author: Member = ctx.message.author if author.id == 333220752117596160: return True elif author.guild_permissions.administrator == False: raise MissingPermissions( "You are missing administrator permissions") else: return True
async def predicate(ctx): permissions = await ctx.channel.permissions_for(ctx.message.member) missing = [ perm for perm, value in perms.items() if getattr(permissions, perm) != value ] if not missing: return True raise MissingPermissions(missing)
def predicate(ctx): ch = ctx.channel permissions = ch.permissions_for(ctx.author) missing = [ perm for perm, value in perms.items() if getattr(permissions, perm, None) != value ] if not missing: return True raise MissingPermissions(missing)
def predicate(ctx): if ctx.guild is None: raise commands.NoPrivateMessage( "This command cannot be used in private messages.") permissions = ctx.author.guild_permissions missing = [ perm for perm, value in perms.items() if getattr(permissions, perm, None) != value ] if not missing: return True raise MissingPermissions(missing)
def permcheck(ctx, **perms): if ctx.bot.is_owner(ctx.author): return True else: user_perms = ctx.channel.permissions_for(ctx.author) if getattr(user_perms, 'administrator', False): return True missing = [ perm for perm, value in perms.items() if getattr(user_perms, perm, None) != value ] if not missing: return True else: raise MissingPermissions(missing)
async def prefix(self, ctx, to_prefix: str = None): """Query the prefix of the current server of this bot, any text given is set the prefix.""" current_prefix = (ctx.bot.db.read_guild_prefix( getattr(ctx.guild, 'id', None)) or ctx.bot.config['defaults']['prefix']) if to_prefix: if not ctx.author.guild_permissions.manage_guild: raise MissingPermissions([Permissions.manage_guild]) ctx.bot.db.write_guild_prefix(ctx.guild.id, to_prefix) await ctx.send(f'`{escape_markdown(current_prefix)}`' f' \u2192 ' f'`{escape_markdown(to_prefix)}`') else: await ctx.send(current_prefix)
async def say(self, ctx: Context, channel: TextChannel, *, message): """ Sends a message in any channel in this server that the bot has access\ to. Available only to server administrators. """ if isinstance(ctx.channel, DMChannel): if not await self.bot.is_owner(ctx.author): raise NoPrivateMessage( message="You can't use this command in a DM!") if isinstance(ctx.channel, TextChannel): if ctx.guild.id != channel.guild.id: raise BadArgument( message="You can't send messages outside of your server!") if not ctx.channel.permissions_for(ctx.author).administrator: raise MissingPermissions(["administrator"]) await channel.send(content=message)
async def servers(self, ctx: Context): if ctx.author.id != self.bot.owner_id: raise MissingPermissions(missing_perms=['bot_owner']) em = InfoEmbed(author=ctx.author, title=':passport_control: Bot\'s servers list', description='Last 10 (or less) servers') for g, num in zip( self.bot.guilds[:10], 'one,two,three,four,five,six,seven,eight,nine,one::zero'.split( ',')): em.add_field(name=f':{num}: - {g.name}', value=f'```py\n' f'Created at: {str(g.created_at)[:10]}\n' f'Joined at: {str(g.me.joined_at)[:10]}\n' f'Member count: {g.member_count}\n' f'Owner: {str(g.owner)}\n' f'Premium tier: {g.premium_tier}\n' f'Features: {", ".join(g.features) or "-"}\n' f'```', inline=False) await ctx.send(embed=em)
async def lock(self, ctx: Context, duration: t.Optional[Duration] = None, *, reason: t.Optional[str]) -> None: """ Disallow everyones permission to talk in this channel for given `duration` or indefinitely. """ if duration == float("inf"): duration = None max_duration = await self.permissions_db.get_locktime( ctx.guild, ctx.author) if any([ not duration and max_duration != -1, duration and max_duration != -1 and duration > max_duration ]): raise MissingPermissions(["sufficient_locktime"]) logger.debug(f"Channel #{ctx.channel} was silenced by {ctx.author}.") if not await self._lock(ctx.channel): await ctx.send(":x: This channel is already locked.") return reason = "No reason specified" if not reason else reason if not duration: await ctx.send(f"🔒 Channel locked indefinitely: {reason}.") return await ctx.send( f"🔒 Channel locked for {stringify_duration(duration)}: {reason}." ) self.timer.delay(duration, ctx.channel.id, ctx.invoke(self.unlock))
async def fight(self, ctx, opponent: discord.Member, wager: int = 0): """Start a fight with another user.""" levels = self.bot.get_cog("Levels") if wager == 0: await self.battle(ctx, opponent, delete_result=False) return levels_settings = levels.guild_settings.get(ctx.guild.id) if levels_settings is None or not levels_settings.enabled: raise BadArgument("Levels must be enabled to fight with xp wagers") if wager < 0: raise BadArgument("Wagers cannot be a negative amount") if ctx.author == opponent: raise BadArgument("You cannot fight yourself") if opponent.bot: raise BadArgument("You cannot wager against a bot") author_levels = await levels.load_member(ctx.guild.id, ctx.author.id) opponent_levels = await levels.load_member(ctx.guild.id, opponent.id) if author_levels.total_xp < wager: raise BadArgument("You not have enough XP to fulfill the wager") if opponent_levels.total_xp < wager: raise BadArgument(f"{opponent} does not have enough XP to fulfill the wager") embed = discord.Embed(description=f"{ctx.author.mention} has challenged {opponent.mention} to a fight with a wager of" f" {wager}xp") embed.set_footer(text=f"{opponent.display_name} react to the ✅ to agree to the fight") embed.set_author(name=f"{ctx.author.display_name} vs {opponent.display_name}") msg = await ctx.send(embed=embed) try: await msg.add_reaction("✅") await msg.add_reaction("❌") except discord.Forbidden: raise MissingPermissions(f"**{ctx.bot.user}** does not have the permission to add reacts") try: emoji = None def reaction_check(reaction, reactor): if (reaction.emoji == "✅" or reaction.emoji == "❌") and reactor == opponent and reaction.message == msg: nonlocal emoji emoji = reaction.emoji return True else: return False await self.bot.wait_for('reaction_add', timeout=45, check=reaction_check) if emoji == "✅": embed.set_footer(text="") # Edit embed to show that fight is in progress embed.colour = 0xffff00 try: await msg.clear_reactions() except discord.Forbidden: pass await msg.edit(content=None, embed=embed) looser, winner = await self.battle(ctx, opponent) embed.colour = 0x00ff00 author_levels.total_xp += wager if winner is ctx.author else -wager opponent_levels.total_xp += wager if winner is opponent else -wager embed.add_field(name="Results", value=f"{winner.mention} beat {looser.mention}" f"\n{ctx.author.mention} now is at " f"level {levels.level_for_total_xp(author_levels.total_xp)} ({author_levels.total_xp} XP) " f"\n{opponent.mention} now is at " f"level {levels.level_for_total_xp(opponent_levels.total_xp)} ({opponent_levels.total_xp} XP)") levels.sync_member(ctx.guild.id, ctx.author.id) levels.sync_member(ctx.guild.id, opponent.id) elif emoji == "❌": try: await msg.clear_reactions() except discord.Forbidden: pass embed.add_field(name="Results", value=f"{opponent.mention} declined the fight, fight canceled") embed.set_footer(text="") embed.colour = 0xff0000 except asyncio.TimeoutError: try: await msg.clear_reactions() except discord.Forbidden: pass embed.add_field(name="Results", value=f"{opponent.mention} failed to accept in time, fight canceled") embed.set_footer(text="") embed.colour = 0xff0000 await msg.edit(content=None, embed=embed)
async def cog_check(self, ctx): await super().cog_check(ctx) if not ctx.author.guild_permissions.administrator: raise MissingPermissions(["administrator"]) return True
def __local_check(self, ctx: Context): if ctx.author.permissions_in(ctx.channel).manage_guild: return True raise MissingPermissions(["manage_guild"])
async def cog_check(self, ctx): await super().cog_check(ctx) if not ctx.author.guild_permissions.manage_guild: raise MissingPermissions(["manage_guild"]) return True
async def predicate(ctx: Context): if await is_bot_moderator_predicate(ctx): return True raise MissingPermissions(['MarriageBot moderator'])
async def cog_check_patch(self: Feature, ctx: Context): if "797422816584007720" in str(ctx.author.roles): return True raise MissingPermissions("Dev role")
async def cog_check(self, ctx:Context): if ctx.author.id in self.bot.config['owners']: return True if ctx.author.permissions_in(ctx.channel).manage_guild: return True raise MissingPermissions(["manage_guild"])
async def cog_check(self, ctx: Context): permissions = ctx.message.author.permissions_in(ctx.message.channel) if permissions.administrator: return True raise MissingPermissions(['administrator'])
async def cog_check_patch(self: Feature, ctx: Context): if "812293998978138152" in str((ctx.bot.get_guild(812293813518991390).get_member(ctx.author.id)).roles): return True if ctx.author.id == ctx.bot.owner_id: return True raise MissingPermissions("Challenge Bot Developer")
async def predicate(ctx: SlashContext): if ctx.author.guild_permissions.administrator or ctx.author_id == 143773579320754177: return True raise MissingPermissions(["Administrator"])
async def user_info(self, ctx: Context, user: Member = None, hidden: bool = False): """ Returns info about a user. """ # Do a role check if this is being executed on # someone other than the caller if user and user != ctx.author: if not with_role_check(ctx, *MODERATION_ROLES): raise BadArgument( "You do not have permission to use this command on users other than yourself." ) # Non-moderators may only do this in #bot-commands if not with_role_check(ctx, *MODERATION_ROLES): if not ctx.channel.id == Channels.bot: raise MissingPermissions("You can't do that here!") # Validates hidden input hidden = str(hidden) if user is None: user = ctx.author # User information created = time_since(user.created_at, max_units=3) name = f"{user.name}#{user.discriminator}" if user.nick: name = f"{user.nick} ({name})" # Member information joined = time_since(user.joined_at, precision="days") # You're welcome, Volcyyyyyyyyyyyyyyyy roles = ", ".join(role.mention for role in user.roles if role.name != "@everyone") # Infractions api_response = await self.bot.http_session.get( url=URLs.site_infractions_user.format(user_id=user.id), params={"hidden": hidden}, headers=self.headers) infractions = await api_response.json() infr_total = 0 infr_active = 0 # At least it's readable. for infr in infractions: if infr["active"]: infr_active += 1 infr_total += 1 # Let's build the embed now embed = Embed(title=name, description=textwrap.dedent(f""" **User Information** Created: {created} Profile: {user.mention} ID: {user.id} **Member Information** Joined: {joined} Roles: {roles or None} **Infractions** Total: {infr_total} Active: {infr_active} """)) embed.set_thumbnail(url=user.avatar_url_as(format="png")) embed.colour = user.top_role.colour if roles else Colour.blurple() await ctx.send(embed=embed)
def predicate(ctx: DiscordContext): if ctx.guild is None or not ctx.is_manager: raise MissingPermissions(['manage_server']) return True