Browse Source

added purge command

tags/v1.6.0
Roxie Gibson 6 years ago
parent
commit
4cb49a5897
2 changed files with 29 additions and 11 deletions
  1. +2
    -1
      README.md
  2. +27
    -10
      Roxbot/cogs/admin.py

+ 2
- 1
README.md View File

- `waifurate` command can now do husbando and spousu rates as well. - `waifurate` command can now do husbando and spousu rates as well.
- `pet` command for your headpats needs. - `pet` command for your headpats needs.
- `roll` command rewrite by TBTerra#5677. It can now do a lot more complex rolls that makes it actually useful! - `roll` command rewrite by TBTerra#5677. It can now do a lot more complex rolls that makes it actually useful!
- `purge` command added for clearing a chat. Only available to users with the `manage_messages` perms.
- Internal settings now have automatic and manual local backups. Manual backups activated by the `backup` command. - Internal settings now have automatic and manual local backups. Manual backups activated by the `backup` command.
###### Minor Changes ###### Minor Changes
- Logging is now easier internally. - Logging is now easier internally.
- Added more helpful error handling for missing argument errors. - Added more helpful error handling for missing argument errors.
- Reddit cog got some lovely refactoring, which includes some author credit when posting. - Reddit cog got some lovely refactoring, which includes some author credit when posting.
###### Bug Fixes ###### Bug Fixes
- ;-; now no longer raises the CommandNotFound error with a better way of stopping t
- ";-;" and other similar text emoticons now no longer raises the CommandNotFound error.


#### v1.5.1 #### v1.5.1
##### Hot Fixes ##### Hot Fixes

+ 27
- 10
Roxbot/cogs/admin.py View File

import time import time
import discord import discord
import datetime import datetime
from discord.ext.commands import bot, group, guild_only, bot_has_permissions, has_permissions
from discord.ext import commands
from discord.ext.commands import bot


from Roxbot import checks from Roxbot import checks
from Roxbot.settings import guild_settings as gs from Roxbot.settings import guild_settings as gs
else: else:
pass pass


@guild_only()
@commands.guild_only()
@checks.is_admin_or_mod() @checks.is_admin_or_mod()
@bot_has_permissions(manage_messages=True)
@commands.bot_has_permissions(manage_messages=True)
@bot.command() @bot.command()
async def slowmode(self, ctx, time): async def slowmode(self, ctx, time):
"""Puts the current channel in slowmode. """Puts the current channel in slowmode.
else: else:
pass pass


@commands.has_permissions(manage_messages=True)
@commands.bot_has_permissions(manage_messages=True, read_message_history=True)
@commands.cooldown(1, 5)
@bot.command()
async def purge(self, ctx, limit=0,*, author: discord.Member = None):
"""Purges messages from the text channel.
Limit = Limit of messages to be deleted
Author (optional) = If given, Roxbot will selectively only delete this user's messages."""
if author:
predicate = lambda message: message.author.id == author.id
else:
predicate = None
messages = await ctx.channel.purge(limit=limit, check=predicate)
return await ctx.send("{} message(s) purged from chat.".format(len(messages)))


@checks.is_admin_or_mod() @checks.is_admin_or_mod()
@group()
@commands.group()
async def warn(self, ctx): async def warn(self, ctx):
"""Group of commands handling warnings""" """Group of commands handling warnings"""
if ctx.invoked_subcommand is None: if ctx.invoked_subcommand is None:
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)
@commands.has_permissions(kick_members=True)
@commands.bot_has_permissions(kick_members=True)
@bot.command() @bot.command()
async def kick(self, ctx, member:discord.Member, *, reason = ""): async def kick(self, ctx, member:discord.Member, *, reason = ""):
"""Kicks mentioned user. Allows you to give a reason.""" """Kicks mentioned user. Allows you to give a reason."""
except discord.Forbidden: except discord.Forbidden:
return await ctx.send("I can't kick the owner or users higher or equal to me.") return await ctx.send("I can't kick the owner or users higher or equal to me.")


@has_permissions(ban_members=True)
@bot_has_permissions(ban_members=True)
@commands.has_permissions(ban_members=True)
@commands.bot_has_permissions(ban_members=True)
@bot.command() @bot.command()
async def ban(self, ctx, member:discord.Member, *, reason = ""): async def ban(self, ctx, member:discord.Member, *, reason = ""):
"""Bans mentioned user. Allows you to give a reason.""" """Bans mentioned user. Allows you to give a reason."""
except discord.Forbidden: except discord.Forbidden:
return await ctx.send("I can't kick the owner or users higher or equal to me.") return await ctx.send("I can't kick the owner or users higher or equal to me.")


@has_permissions(ban_members=True)
@bot_has_permissions(ban_members=True)
@commands.has_permissions(ban_members=True)
@commands.bot_has_permissions(ban_members=True)
@bot.command() @bot.command()
async def unban(self, ctx, member:discord.Member, *, reason = ""): async def unban(self, ctx, member:discord.Member, *, reason = ""):
"""Unbans mentioned user. Allows you to give a reason.""" """Unbans mentioned user. Allows you to give a reason."""

Loading…
Cancel
Save