Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@commands.check(is_owner)
async def shutdown(self, ctx):
await ctx.send(content = success_string + ' **Shutting down.**')
DBService.commit()
await self.bot.logout()
def is_staff(role):
async def predicate(ctx):
if isinstance(ctx.channel, discord.abc.GuildChannel):
return await check_staff(ctx, role) if not ctx.author == ctx.guild.owner else True
else:
return await check_staff(ctx, role)
return commands.check(predicate)
@commands.check(check_if_staff)
@commands.command(aliases=["addnoteid"])
async def noteid(self, ctx, target: int, *, note: str = ""):
"""Adds a note to a user by userid, staff only."""
userlog(target, ctx.author, note,
"notes")
await ctx.send(f"{target.mention}: noted!")
def is_mod():
async def pred(ctx):
return await check_guild_permissions(ctx, {'manage_guild': True})
return commands.check(pred)
def can_manage_message():
def predicate(ctx):
try:
return ctx.message.channel.permissions_for(ctx.message.author).manage_messages
except:
return False
return commands.check(predicate)
def suggest_box():
"""Custom commands.guild_only with different error checking."""
def pred(ctx):
if ctx.guild is None:
raise UnavailableTagCommand()
return True
return commands.check(pred)
def with_role(*role_ids: int) -> Callable:
"""Returns True if the user has any one of the roles in role_ids."""
async def predicate(ctx: Context) -> bool:
"""With role checker predicate."""
return with_role_check(ctx, *role_ids)
return commands.check(predicate)
def owner_or_permissions(**perms):
def predicate(ctx):
return role_or_permissions(ctx, lambda ctx: is_owner_check(ctx.message))
return commands.check(predicate)
def need_perms():
def predicate(ctx):
with db_session:
settings = VoiceSingle.get(guild_id=ctx.guild.id)
if settings.need_perms:
return roxbot.utils.has_permissions_or_owner(ctx, manage_channels=True)
else:
return True
return commands.check(predicate)