mirror of
https://github.com/neoarz/Syntrel.git
synced 2025-12-25 11:40:12 +01:00
chore(baitbot): better logging
This commit is contained in:
@@ -43,9 +43,10 @@ class Events(commands.GroupCog, name="events"):
|
|||||||
await context.send(f"Unknown events command: {name}")
|
await context.send(f"Unknown events command: {name}")
|
||||||
|
|
||||||
@events_group.command(name="baitbot")
|
@events_group.command(name="baitbot")
|
||||||
|
@has_protected_role()
|
||||||
async def events_group_baitbot(self, context: Context):
|
async def events_group_baitbot(self, context: Context):
|
||||||
await self._invoke_hybrid(context, "baitbot")
|
await self._invoke_hybrid(context, "baitbot")
|
||||||
|
|
||||||
@commands.check(_require_group_prefix)
|
@commands.check(_require_group_prefix)
|
||||||
@has_protected_role()
|
@has_protected_role()
|
||||||
@commands.hybrid_command(
|
@commands.hybrid_command(
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ BAN_REASON = 'Detected bot/scammer in bait channel'
|
|||||||
def has_protected_role():
|
def has_protected_role():
|
||||||
async def predicate(context: Context):
|
async def predicate(context: Context):
|
||||||
if not context.guild:
|
if not context.guild:
|
||||||
|
context.bot.logger.warning(f'[BAITBOT] Unauthorized baitbot command attempt by {context.author} ({context.author.id}) in DMs')
|
||||||
embed = discord.Embed(
|
embed = discord.Embed(
|
||||||
title="Permission Denied",
|
title="Permission Denied",
|
||||||
description="You don't have permission to use this command.",
|
description="You don't have permission to use this command.",
|
||||||
@@ -33,6 +34,7 @@ def has_protected_role():
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
if not hasattr(context.author, 'roles'):
|
if not hasattr(context.author, 'roles'):
|
||||||
|
context.bot.logger.warning(f'[BAITBOT] Unauthorized baitbot command attempt by {context.author} ({context.author.id}) in {context.guild.name} - no roles')
|
||||||
embed = discord.Embed(
|
embed = discord.Embed(
|
||||||
title="Permission Denied",
|
title="Permission Denied",
|
||||||
description="You don't have permission to use this command.",
|
description="You don't have permission to use this command.",
|
||||||
@@ -51,6 +53,7 @@ def has_protected_role():
|
|||||||
if role.position >= protected_role.position and role.id != context.guild.default_role.id:
|
if role.position >= protected_role.position and role.id != context.guild.default_role.id:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
context.bot.logger.warning(f'[BAITBOT] Unauthorized baitbot command attempt by {context.author} ({context.author.id}) in {context.guild.name} - insufficient role permissions')
|
||||||
embed = discord.Embed(
|
embed = discord.Embed(
|
||||||
title="Permission Denied",
|
title="Permission Denied",
|
||||||
description="You don't have permission to use this command.",
|
description="You don't have permission to use this command.",
|
||||||
@@ -64,7 +67,7 @@ def has_protected_role():
|
|||||||
def baitbot_command():
|
def baitbot_command():
|
||||||
async def wrapper(self, context: Context):
|
async def wrapper(self, context: Context):
|
||||||
embed = discord.Embed(
|
embed = discord.Embed(
|
||||||
title="Bait Bot Configuration",
|
title="Bait Bot",
|
||||||
description="Bans people who post in a specific channel.\n\n"
|
description="Bans people who post in a specific channel.\n\n"
|
||||||
"**Configuration:**",
|
"**Configuration:**",
|
||||||
color=0x7289DA
|
color=0x7289DA
|
||||||
@@ -139,9 +142,9 @@ class BaitBotListener(commands.Cog):
|
|||||||
break
|
break
|
||||||
try:
|
try:
|
||||||
await message.delete()
|
await message.delete()
|
||||||
self.bot.logger.info(f'[BAITBOT] Deleted triggering message from {message.author} in #{message.channel.name}')
|
self.bot.logger.info(f'[BAITBOT] Deleted message from {message.author} in #{message.channel.name}')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.bot.logger.warning(f'[BAITBOT] Could not delete triggering message from {message.author}: {e}')
|
self.bot.logger.warning(f'[BAITBOT] Could not delete message from {message.author}: {e}')
|
||||||
if is_protected:
|
if is_protected:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user