Parcourir la source

fixed checkfailure triggering before other options which wouldnt be as accurate.

tags/v1.5.0
Roxie Gibson il y a 6 ans
Parent
révision
3660df0e51
2 fichiers modifiés avec 26 ajouts et 3 suppressions
  1. +24
    -1
      Roxbot/cogs/admin.py
  2. +2
    -2
      Roxbot/err_handle.py

+ 24
- 1
Roxbot/cogs/admin.py Voir le fichier

@@ -3,7 +3,7 @@ import time
from Roxbot import checks
import discord
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():
@@ -176,6 +176,29 @@ class Admin():
except KeyError:
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):
bot_client.add_cog(Admin(bot_client))

+ 2
- 2
Roxbot/err_handle.py Voir le fichier

@@ -38,8 +38,6 @@ class ErrHandle:
embed = discord.Embed(description="This command cannot be used in private messages.")
elif isinstance(error, commands.DisabledCommand):
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):
embed = discord.Embed(description="Argument missing.")
elif isinstance(error, commands.BadArgument):
@@ -62,6 +60,8 @@ class ErrHandle:
embed = discord.Embed(description="You do not have permission to do this. You are not Roxie!")
elif isinstance(error, commands.CommandOnCooldown):
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:
embed = discord.Embed(
description="Placeholder embed. If you see this please message {}.".format(str(self.owner)))

Chargement…
Annuler
Enregistrer