mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -05:00
Added !softban
This commit is contained in:
parent
9e09b405b2
commit
b0a017c34e
30
cogs/mod.py
30
cogs/mod.py
@ -84,6 +84,36 @@ class Mod:
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
@commands.command(no_pm=True, pass_context=True)
|
||||
@checks.admin_or_permissions(ban_members=True)
|
||||
async def softban(self, ctx, user: discord.Member):
|
||||
"""Kicks the user, deleting 1 day worth of messages."""
|
||||
server = ctx.message.server
|
||||
channel = ctx.message.channel
|
||||
can_ban = channel.permissions_for(server.me).ban_members
|
||||
author = ctx.message.author
|
||||
if can_ban:
|
||||
try:
|
||||
try: # We don't want blocked DMs preventing us from banning
|
||||
msg = await self.bot.send_message(user, "You have been banned and "
|
||||
"then unbanned as a quick way to delete your messages.\n"
|
||||
"You can now join the server again.")
|
||||
except:
|
||||
pass
|
||||
await self.bot.ban(user, 1)
|
||||
logger.info("{}({}) softbanned {}({}), deleting 1 day worth "
|
||||
"of messages".format(author.name, author.id, user.name,
|
||||
user.id))
|
||||
await self.bot.unban(server, user)
|
||||
await self.bot.say("Done. Enough chaos.")
|
||||
except discord.errors.Forbidden:
|
||||
await self.bot.say("My role is not high enough to softban that user.")
|
||||
await self.bot.delete_message(msg)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
else:
|
||||
await self.bot.say("I'm not allowed to do that.")
|
||||
|
||||
@commands.command(no_pm=True, pass_context=True)
|
||||
@checks.admin_or_permissions(manage_nicknames=True)
|
||||
async def rename(self, ctx, user : discord.Member, *, nickname=""):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user