from Roxbot import checks | from Roxbot import checks | ||||
import discord | import discord | ||||
from Roxbot.settings import guild_settings as gs | from Roxbot.settings import guild_settings as gs | ||||
from discord.ext.commands import bot, group, guild_only, bot_has_permissions | |||||
from discord.ext.commands import bot, group, guild_only, bot_has_permissions, has_permissions | |||||
class Admin(): | class Admin(): | ||||
except KeyError: | except KeyError: | ||||
return await ctx.send("Could not find user in warning list.") | return await ctx.send("Could not find user in warning list.") | ||||
@has_permissions(kick_members=True) | |||||
@bot_has_permissions(kick_members=True) | |||||
@bot.command() | |||||
async def kick(self, ctx, member:discord.Member, *, reason = ""): | |||||
"""Kicks mentioned user. Allows you to give a reason.""" | |||||
await member.kick(reason=reason) | |||||
return await ctx.send("Kicked {} with reason: '{}'".format(member, reason)) | |||||
@has_permissions(ban_members=True) | |||||
@bot_has_permissions(ban_members=True) | |||||
@bot.command() | |||||
async def ban(self, ctx, member:discord.Member, *, reason = ""): | |||||
"""Bans mentioned user. Allows you to give a reason.""" | |||||
await member.ban(reason=reason, delete_message_days=0) | |||||
return await ctx.send("Banned {} with reason: '{}'".format(member, reason)) | |||||
@has_permissions(ban_members=True) | |||||
@bot_has_permissions(ban_members=True) | |||||
@bot.command() | |||||
async def unban(self, ctx, member:discord.Member, *, reason = ""): | |||||
"""Unbans mentioned user. Allows you to give a reason.""" | |||||
await member.unban(reason=reason) | |||||
return await ctx.send("Unbanned {} with reason: '{}'".format(member, reason)) | |||||
def setup(bot_client): | def setup(bot_client): | ||||
bot_client.add_cog(Admin(bot_client)) | bot_client.add_cog(Admin(bot_client)) |
embed = discord.Embed(description="This command cannot be used in private messages.") | embed = discord.Embed(description="This command cannot be used in private messages.") | ||||
elif isinstance(error, commands.DisabledCommand): | elif isinstance(error, commands.DisabledCommand): | ||||
embed = discord.Embed(description="This command is disabled.") | embed = discord.Embed(description="This command is disabled.") | ||||
elif isinstance(error, commands.CheckFailure): | |||||
embed = discord.Embed(description="You do not have permission to do this. Back off, thot!") | |||||
elif isinstance(error, commands.MissingRequiredArgument): | elif isinstance(error, commands.MissingRequiredArgument): | ||||
embed = discord.Embed(description="Argument missing.") | embed = discord.Embed(description="Argument missing.") | ||||
elif isinstance(error, commands.BadArgument): | elif isinstance(error, commands.BadArgument): | ||||
embed = discord.Embed(description="You do not have permission to do this. You are not Roxie!") | embed = discord.Embed(description="You do not have permission to do this. You are not Roxie!") | ||||
elif isinstance(error, commands.CommandOnCooldown): | elif isinstance(error, commands.CommandOnCooldown): | ||||
embed = discord.Embed(description="This command is on cooldown, please wait {} seconds before trying again.".format(error.retry_after)) | embed = discord.Embed(description="This command is on cooldown, please wait {} seconds before trying again.".format(error.retry_after)) | ||||
elif isinstance(error, commands.CheckFailure): | |||||
embed = discord.Embed(description="You do not have permission to do this. Back off, thot!") | |||||
else: | else: | ||||
embed = discord.Embed( | embed = discord.Embed( | ||||
description="Placeholder embed. If you see this please message {}.".format(str(self.owner))) | description="Placeholder embed. If you see this please message {}.".format(str(self.owner))) |