mirror of
https://github.com/TotalFreedomMC/TotalFreedomBot.git
synced 2024-12-22 15:44:57 +00:00
Update moderation.py
This commit is contained in:
parent
0322c158f5
commit
813c190130
1 changed files with 29 additions and 12 deletions
|
@ -1,9 +1,10 @@
|
||||||
import discord
|
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
|
import discord
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from checks import *
|
|
||||||
from functions import *
|
from checks import is_mod_or_has_perms
|
||||||
|
from functions import read_json, write_json
|
||||||
|
|
||||||
muted_role_id = 769659653121900546
|
muted_role_id = 769659653121900546
|
||||||
|
|
||||||
|
@ -18,24 +19,30 @@ class Moderation(commands.Cog):
|
||||||
async def kick(self, ctx, user: discord.Member, *, reason="No reason specified"):
|
async def kick(self, ctx, user: discord.Member, *, reason="No reason specified"):
|
||||||
"""Kicks a user from the guild."""
|
"""Kicks a user from the guild."""
|
||||||
await user.kick(reason=f'{reason}** **by: {ctx.author.name}')
|
await user.kick(reason=f'{reason}** **by: {ctx.author.name}')
|
||||||
await ctx.send(embed=discord.Embed(embed=f'{user.name} has been kicked by: {ctx.author.name} for reason: {reason}'))
|
await ctx.send(
|
||||||
print(f"[{datetime.datetime.utcnow().replace(microsecond=0)} INFO]: [Moderation] Kicked {user.name} from {ctx.guild.name}")
|
embed=discord.Embed(embed=f'{user.name} has been kicked by: {ctx.author.name} for reason: {reason}'))
|
||||||
|
print(
|
||||||
|
f"[{datetime.datetime.utcnow().replace(microsecond=0)} INFO]: [Moderation] Kicked {user.name} from {ctx.guild.name}")
|
||||||
|
|
||||||
@commands.command(aliases=['gtfo'])
|
@commands.command(aliases=['gtfo'])
|
||||||
@commands.has_permissions(ban_members=True)
|
@commands.has_permissions(ban_members=True)
|
||||||
async def ban(self, ctx, user: discord.Member, *, reason="No reason specified"):
|
async def ban(self, ctx, user: discord.Member, *, reason="No reason specified"):
|
||||||
"""Bans a user from the guild."""
|
"""Bans a user from the guild."""
|
||||||
await user.ban(reason=f'{reason} || by: {ctx.author.name}', delete_message_days=0)
|
await user.ban(reason=f'{reason} || by: {ctx.author.name}', delete_message_days=0)
|
||||||
await ctx.send(embed=discord.Embed(description=f'{user.name} has been banned by: {ctx.author.name} for reason: {reason}'))
|
await ctx.send(
|
||||||
print(f"[{datetime.datetime.utcnow().replace(microsecond=0)} INFO]: [Moderation] Banned {user.name} from {ctx.guild.name}")
|
embed=discord.Embed(description=f'{user.name} has been banned by: {ctx.author.name} for reason: {reason}'))
|
||||||
|
print(
|
||||||
|
f"[{datetime.datetime.utcnow().replace(microsecond=0)} INFO]: [Moderation] Banned {user.name} from {ctx.guild.name}")
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
@commands.has_permissions(ban_members=True)
|
@commands.has_permissions(ban_members=True)
|
||||||
async def unban(self, ctx, user: discord.User, *, reason="No reason specified"):
|
async def unban(self, ctx, user: discord.User, *, reason="No reason specified"):
|
||||||
"""Unbans a user from the guild."""
|
"""Unbans a user from the guild."""
|
||||||
await ctx.guild.unban(user, reason=f'{reason} || by: {ctx.author.name}')
|
await ctx.guild.unban(user, reason=f'{reason} || by: {ctx.author.name}')
|
||||||
await ctx.send(embed=discord.Embed(description=f'{user.name} has been unbanned by: {ctx.author.name} for reason: {reason}'))
|
await ctx.send(embed=discord.Embed(
|
||||||
print(f"[{datetime.datetime.utcnow().replace(microsecond=0)} INFO]: [Moderation] Banned {user.name} from {ctx.guild.name}")
|
description=f'{user.name} has been unbanned by: {ctx.author.name} for reason: {reason}'))
|
||||||
|
print(
|
||||||
|
f"[{datetime.datetime.utcnow().replace(microsecond=0)} INFO]: [Moderation] Banned {user.name} from {ctx.guild.name}")
|
||||||
|
|
||||||
@commands.command(aliases=['massdelete', 'purge'])
|
@commands.command(aliases=['massdelete', 'purge'])
|
||||||
@commands.has_permissions(manage_messages=True)
|
@commands.has_permissions(manage_messages=True)
|
||||||
|
@ -44,7 +51,8 @@ class Moderation(commands.Cog):
|
||||||
channel = ctx.channel
|
channel = ctx.channel
|
||||||
await channel.purge(limit=(int(msgs) + 1))
|
await channel.purge(limit=(int(msgs) + 1))
|
||||||
await ctx.send(embed=discord.Embed(description=f'{ctx.author.name} deleted {msgs} messages'))
|
await ctx.send(embed=discord.Embed(description=f'{ctx.author.name} deleted {msgs} messages'))
|
||||||
print(f'[{datetime.datetime.utcnow().replace(microsecond=0)} INFO]: [Moderation] {ctx.author.name} purged {msgs} messages in {ctx.guild.name}')
|
print(
|
||||||
|
f'[{datetime.datetime.utcnow().replace(microsecond=0)} INFO]: [Moderation] {ctx.author.name} purged {msgs} messages in {ctx.guild.name}')
|
||||||
|
|
||||||
@commands.command(aliases=['stfu'])
|
@commands.command(aliases=['stfu'])
|
||||||
@commands.has_permissions(manage_messages=True)
|
@commands.has_permissions(manage_messages=True)
|
||||||
|
@ -55,7 +63,8 @@ class Moderation(commands.Cog):
|
||||||
if reason == '':
|
if reason == '':
|
||||||
reason = 'No reason specified'
|
reason = 'No reason specified'
|
||||||
await ctx.send(embed=discord.Embed(description=f'{member} muted by: {ctx.author.name} for: {reason}'))
|
await ctx.send(embed=discord.Embed(description=f'{member} muted by: {ctx.author.name} for: {reason}'))
|
||||||
print(f'[{datetime.datetime.utcnow().replace(microsecond=0)} INFO]: [Moderation] Muted {member} in {ctx.guild.name}')
|
print(
|
||||||
|
f'[{datetime.datetime.utcnow().replace(microsecond=0)} INFO]: [Moderation] Muted {member} in {ctx.guild.name}')
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
@commands.has_permissions(manage_messages=True)
|
@commands.has_permissions(manage_messages=True)
|
||||||
|
@ -64,7 +73,8 @@ class Moderation(commands.Cog):
|
||||||
muted_role = ctx.guild.get_role(muted_role_id)
|
muted_role = ctx.guild.get_role(muted_role_id)
|
||||||
await member.remove_roles(muted_role, reason=f'{reason} || by {ctx.author.name}')
|
await member.remove_roles(muted_role, reason=f'{reason} || by {ctx.author.name}')
|
||||||
await ctx.send(embed=discord.Embed(description=f'{member} unmuted by {ctx.author.name}'))
|
await ctx.send(embed=discord.Embed(description=f'{member} unmuted by {ctx.author.name}'))
|
||||||
print(f'[{datetime.datetime.utcnow().replace(microsecond=0)} INFO]: [Moderation] Unmuted {member} in {ctx.guild.name}')
|
print(
|
||||||
|
f'[{datetime.datetime.utcnow().replace(microsecond=0)} INFO]: [Moderation] Unmuted {member} in {ctx.guild.name}')
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
@commands.has_permissions(manage_roles=True)
|
@commands.has_permissions(manage_roles=True)
|
||||||
|
@ -77,6 +87,13 @@ class Moderation(commands.Cog):
|
||||||
print(data['reaction_roles'])
|
print(data['reaction_roles'])
|
||||||
write_json('config', data)
|
write_json('config', data)
|
||||||
|
|
||||||
|
@commands.command()
|
||||||
|
@is_mod_or_has_perms(manage_roles=True)
|
||||||
|
async def verify(self, ctx, member: discord.Member):
|
||||||
|
verify_role = ctx.guild.get_role(self.bot.verification_role)
|
||||||
|
await member.add_roles(verify_role)
|
||||||
|
await ctx.send(f'```Successfully verified: {member.name}```')
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
def setup(bot):
|
||||||
bot.add_cog(Moderation(bot))
|
bot.add_cog(Moderation(bot))
|
||||||
|
|
Loading…
Reference in a new issue