mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -05:00
[Mod] Prevent users from expelling themselves
This commit is contained in:
parent
a0aa69e083
commit
31426ca7c6
19
cogs/mod.py
19
cogs/mod.py
@ -258,6 +258,12 @@ class Mod:
|
|||||||
"""Kicks user."""
|
"""Kicks user."""
|
||||||
author = ctx.message.author
|
author = ctx.message.author
|
||||||
server = author.server
|
server = author.server
|
||||||
|
|
||||||
|
if author == user:
|
||||||
|
await self.bot.say("I cannot let you do that. Self-harm is "
|
||||||
|
"bad \N{PENSIVE FACE}")
|
||||||
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await self.bot.kick(user)
|
await self.bot.kick(user)
|
||||||
logger.info("{}({}) kicked {}({})".format(
|
logger.info("{}({}) kicked {}({})".format(
|
||||||
@ -285,6 +291,11 @@ class Mod:
|
|||||||
author = ctx.message.author
|
author = ctx.message.author
|
||||||
server = author.server
|
server = author.server
|
||||||
|
|
||||||
|
if author == user:
|
||||||
|
await self.bot.say("I cannot let you do that. Self-harm is "
|
||||||
|
"bad \N{PENSIVE FACE}")
|
||||||
|
return
|
||||||
|
|
||||||
if days:
|
if days:
|
||||||
if days.isdigit():
|
if days.isdigit():
|
||||||
days = int(days)
|
days = int(days)
|
||||||
@ -330,6 +341,12 @@ class Mod:
|
|||||||
channel = ctx.message.channel
|
channel = ctx.message.channel
|
||||||
can_ban = channel.permissions_for(server.me).ban_members
|
can_ban = channel.permissions_for(server.me).ban_members
|
||||||
author = ctx.message.author
|
author = ctx.message.author
|
||||||
|
|
||||||
|
if author == user:
|
||||||
|
await self.bot.say("I cannot let you do that. Self-harm is "
|
||||||
|
"bad \N{PENSIVE FACE}")
|
||||||
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
invite = await self.bot.create_invite(server, max_age=3600*24)
|
invite = await self.bot.create_invite(server, max_age=3600*24)
|
||||||
invite = "\nInvite: " + invite
|
invite = "\nInvite: " + invite
|
||||||
@ -382,7 +399,7 @@ class Mod:
|
|||||||
await self.bot.say("Done.")
|
await self.bot.say("Done.")
|
||||||
except discord.Forbidden:
|
except discord.Forbidden:
|
||||||
await self.bot.say("I cannot do that, I lack the "
|
await self.bot.say("I cannot do that, I lack the "
|
||||||
"\"Manage Nicknames\" permission.")
|
"\"Manage Nicknames\" permission.")
|
||||||
|
|
||||||
@commands.group(pass_context=True, no_pm=True, invoke_without_command=True)
|
@commands.group(pass_context=True, no_pm=True, invoke_without_command=True)
|
||||||
@checks.mod_or_permissions(administrator=True)
|
@checks.mod_or_permissions(administrator=True)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user