From 40c9d3ffa0b4e72f06cc2924978d7540eadac2e8 Mon Sep 17 00:00:00 2001 From: Xargana Date: Fri, 9 May 2025 22:11:53 +0300 Subject: [PATCH] fixed c0d5dd52499db8f35943b270c2e8a5d21afe099f --- bot/commands/user_management_commands.py | 64 ++---------------------- bot/handlers/message_handler.py | 18 +------ bot/selfbot.py | 9 +--- 3 files changed, 7 insertions(+), 84 deletions(-) diff --git a/bot/commands/user_management_commands.py b/bot/commands/user_management_commands.py index 3410eee..533e59c 100644 --- a/bot/commands/user_management_commands.py +++ b/bot/commands/user_management_commands.py @@ -4,37 +4,6 @@ import asyncio class UserManagementCommands: def __init__(self, bot): self.bot = bot - # Store lists of ignored/muted users and channels - self.ignored_channels = set() - self.muted_channels = set() - self.muted_users = set() - - async def cmd_ignore(self, message): - """ - Ignore all users in the current channel except for self - Usage: .ignore - """ - try: - channel_id = message.channel.id - self.ignored_channels.add(channel_id) - await message.edit(content=f"✅ Ignoring users in this channel. Use `.unignore` to revert.") - except Exception as e: - await message.edit(content=f"❌ Error ignoring channel: {str(e)}") - - async def cmd_unignore(self, message): - """ - Stop ignoring users in the current channel - Usage: .unignore - """ - try: - channel_id = message.channel.id - if channel_id in self.ignored_channels: - self.ignored_channels.remove(channel_id) - await message.edit(content=f"✅ No longer ignoring users in this channel.") - else: - await message.edit(content=f"❌ This channel is not being ignored.") - except Exception as e: - await message.edit(content=f"❌ Error: {str(e)}") async def cmd_close(self, message): """ @@ -52,36 +21,9 @@ class UserManagementCommands: except Exception as e: await message.edit(content=f"❌ Error closing DM: {str(e)}") - async def cmd_mute(self, message): - """ - Mute the current channel (no notifications) - Usage: .mute - """ - try: - channel_id = message.channel.id - self.muted_channels.add(channel_id) - await message.edit(content=f"✅ Channel muted. Use `.unmute` to revert.") - except Exception as e: - await message.edit(content=f"❌ Error muting channel: {str(e)}") - - async def cmd_unmute(self, message): - """ - Unmute the current channel - Usage: .unmute - """ - try: - channel_id = message.channel.id - if channel_id in self.muted_channels: - self.muted_channels.remove(channel_id) - await message.edit(content=f"✅ Channel unmuted.") - else: - await message.edit(content=f"❌ This channel is not muted.") - except Exception as e: - await message.edit(content=f"❌ Error: {str(e)}") - async def cmd_block(self, message): """ - Block a user + Block a user using Discord's native block function Usage: .block @user or .block [in reply to a message] """ try: @@ -99,7 +41,7 @@ class UserManagementCommands: return await user.block() - await message.edit(content=f"✅ Blocked user {user.name}#{user.discriminator}.") + await message.edit(content=f"✅ Blocked {user.name}#{user.discriminator}") except Exception as e: await message.edit(content=f"❌ Error blocking user: {str(e)}") @@ -139,4 +81,4 @@ class UserManagementCommands: # Method to check if a channel is muted def is_channel_muted(self, channel_id): - return channel_id in self.muted_channels \ No newline at end of file + return channel_id in self.muted_channels diff --git a/bot/handlers/message_handler.py b/bot/handlers/message_handler.py index d0f0203..2a176d2 100644 --- a/bot/handlers/message_handler.py +++ b/bot/handlers/message_handler.py @@ -80,12 +80,6 @@ class MessageHandler: if message.author.bot: return - # Check if the channel is in ignored channels list and message is not from bot user - if (message.author != self.bot.user and - hasattr(self, 'user_management_commands') and - self.user_management_commands.is_channel_ignored(message.channel.id)): - return - # Look for and replace time patterns (only for non-command messages) if not message.content.startswith('.'): original_content = message.content @@ -155,17 +149,9 @@ class MessageHandler: await message.channel.send(f"Error executing command: {e}") return - # User Management Commands - if content.startswith(".ignore"): - await self.user_management_commands.cmd_ignore(message) - elif content.startswith(".unignore"): - await self.user_management_commands.cmd_unignore(message) - elif content.startswith(".close"): + # User Management Commands - only keeping close and block + if content.startswith(".close"): await self.user_management_commands.cmd_close(message) - elif content.startswith(".mute"): - await self.user_management_commands.cmd_mute(message) - elif content.startswith(".unmute"): - await self.user_management_commands.cmd_unmute(message) elif content.startswith(".block"): await self.user_management_commands.cmd_block(message) elif content.startswith(".unblock"): diff --git a/bot/selfbot.py b/bot/selfbot.py index a044c6b..20d7dbc 100644 --- a/bot/selfbot.py +++ b/bot/selfbot.py @@ -25,13 +25,8 @@ class Selfbot(discord.Client): print(f"Logged in as {self.user}") async def on_message(self, message): - # Skip notifications for muted channels - if (message.channel.id in self.user_management_commands.muted_channels and - message.author != self.user): - # Still process the message, but don't trigger notifications - pass - - # Regular message handling + # Don't use muted_channels anymore since we're using Discord's native functionality + # Instead, just process all messages await self.message_handler.handle_message(message) async def on_message_delete(self, message):