Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@checks.has_permissions(**{"manage_messages": True})
async def makesay(self, ctx: NabCtx, *, message: str):
"""Makes the bot say a message.
If the user using the command doesn't have mention everyone permissions, the message will be cleaned of
mass mentions.
"""
if not ctx.bot_permissions.manage_messages:
return await ctx.error("I need `Manage Messages` permissions here to use the command.")
# If bot or user don't have mention everyone permissions, clean @everyone and @here
if not ctx.bot_permissions.mention_everyone or not ctx.author_permissions.mention_everyone:
message = message.replace("@everyone", "@\u200beveryone").replace("@here", "@\u200bhere")
await safe_delete_message(ctx.message)
await ctx.send(message)
@checks.has_permissions(manage_roles=True)
async def pingy(self, ctx, *roles: commands.clean_content):
"""
Pings all the roles in the command
"""
if not roles:
await ctx.send(":thinking:", delete_after=3)
await ctx.message.delete()
guild_roles = ctx.guild.roles
found_roles = []
for role in roles:
if role.lower() not in \
['dedicated', 'updated', 'events', 'moderator',
'admin', 'representative']:
continue
guild_role = find(
lambda m: m.name.lower() == role.lower(), guild_roles)
@checks.has_permissions(manage_roles=True)
async def untimeout(self, ctx, member: discord.Member):
guild_roles = ctx.guild.roles
timeout_role = ctx.guild.get_role(self.bot.timeout_id)
confirm = await helpers.confirm(ctx, member, '')
removed_from_channels = []
if confirm:
try:
await member.remove_roles(timeout_role)
all_channels = await self.bot.postgres_controller.get_all_channels()
for row in all_channels:
channel = self.bot.get_channel(row['host_channel'])
if not channel:
continue
try:
message = await channel.get_message(row['message_id'])
except:
@checks.has_permissions(kick_members=True)
async def kick(self, ctx, member: MemberID, *, reason: ActionReason = None):
"""Kicks a member from the server.
In order for this to work, the bot must have Kick Member permissions.
To use this command you must have Kick Members permission.
"""
if reason is None:
reason = f'Action done by {ctx.author} (ID: {ctx.author.id})'
await ctx.guild.kick(member, reason=reason)
await ctx.send('\N{OK HAND SIGN}')
@checks.has_permissions(manage_roles=True)
async def cleanrole(self, ctx, *, role_name):
"""(Testing) Removes all members from a certain role."""
found_role = None
for role in ctx.guild.roles:
if role.name.lower() == role_name.lower():
found_role = role
if not found_role:
await ctx.send(embed=discord.Embed(
title='Couldn\'t find role',
description=f'Couldn\'t find the given role to remove',
color=0x419400
))
return
count = 0
for user in found_role.members:
try:
@checks.has_permissions(manage_roles=True)
async def voiceroles(self, ctx):
"""Check if voiceroles are enabled."""
if ctx.invoked_subcommand is None:
desc = ''
vcrole_enabled = await\
self.bot.pg_utils.get_voice_enabled(ctx.guild.id)
desc = 'Enabled' if vcrole_enabled else 'Disabled'
local_embed = discord.Embed(
title=f'Voice channel roles are:',
description=f'**{desc}**',
color=0x419400
)
await ctx.send(embed=local_embed)
@checks.has_permissions(manage_messages=True)
async def slowmode(self, ctx):
"""
Adds or removes a channel to slowmode list
"""
if not await checks.is_channel_blacklisted(self, ctx):
return
if ctx.invoked_subcommand is None:
return
@checks.has_permissions(manage_roles=True)
async def warn(self, ctx):
"""
Base command for warning system
"""
if ctx.invoked_subcommand is None:
local_embed = discord.Embed(
title=f'Command Error',
description=f"Please use either"
f"`.warn minor` or `.warn major`",
color=0x419400
)
await ctx.send(embed=local_embed, delete_after=5)
@checks.has_permissions(manage_roles=True)
async def timeout(self, ctx, member: discord.Member):
guild_roles = ctx.guild.roles
timeout_role = ctx.guild.get_role(self.bot.timeout_id)
confirm = await helpers.confirm(ctx, member, '')
removed_from_channels = []
if confirm:
try:
await member.add_roles(timeout_role)
all_channels = await self.bot.postgres_controller.get_all_channels()
for row in all_channels:
channel = self.bot.get_channel(row['host_channel'])
if not channel:
continue
try:
message = await channel.get_message(row['message_id'])
except: