fixed c0d5dd5249
This commit is contained in:
parent
c0d5dd5249
commit
40c9d3ffa0
|
@ -4,37 +4,6 @@ import asyncio
|
||||||
class UserManagementCommands:
|
class UserManagementCommands:
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = 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):
|
async def cmd_close(self, message):
|
||||||
"""
|
"""
|
||||||
|
@ -52,36 +21,9 @@ class UserManagementCommands:
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
await message.edit(content=f"❌ Error closing DM: {str(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):
|
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]
|
Usage: .block @user or .block [in reply to a message]
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
|
@ -99,7 +41,7 @@ class UserManagementCommands:
|
||||||
return
|
return
|
||||||
|
|
||||||
await user.block()
|
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:
|
except Exception as e:
|
||||||
await message.edit(content=f"❌ Error blocking user: {str(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
|
# Method to check if a channel is muted
|
||||||
def is_channel_muted(self, channel_id):
|
def is_channel_muted(self, channel_id):
|
||||||
return channel_id in self.muted_channels
|
return channel_id in self.muted_channels
|
||||||
|
|
|
@ -80,12 +80,6 @@ class MessageHandler:
|
||||||
if message.author.bot:
|
if message.author.bot:
|
||||||
return
|
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)
|
# Look for and replace time patterns (only for non-command messages)
|
||||||
if not message.content.startswith('.'):
|
if not message.content.startswith('.'):
|
||||||
original_content = message.content
|
original_content = message.content
|
||||||
|
@ -155,17 +149,9 @@ class MessageHandler:
|
||||||
await message.channel.send(f"Error executing command: {e}")
|
await message.channel.send(f"Error executing command: {e}")
|
||||||
return
|
return
|
||||||
|
|
||||||
# User Management Commands
|
# User Management Commands - only keeping close and block
|
||||||
if content.startswith(".ignore"):
|
if content.startswith(".close"):
|
||||||
await self.user_management_commands.cmd_ignore(message)
|
|
||||||
elif content.startswith(".unignore"):
|
|
||||||
await self.user_management_commands.cmd_unignore(message)
|
|
||||||
elif content.startswith(".close"):
|
|
||||||
await self.user_management_commands.cmd_close(message)
|
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"):
|
elif content.startswith(".block"):
|
||||||
await self.user_management_commands.cmd_block(message)
|
await self.user_management_commands.cmd_block(message)
|
||||||
elif content.startswith(".unblock"):
|
elif content.startswith(".unblock"):
|
||||||
|
|
|
@ -25,13 +25,8 @@ class Selfbot(discord.Client):
|
||||||
print(f"Logged in as {self.user}")
|
print(f"Logged in as {self.user}")
|
||||||
|
|
||||||
async def on_message(self, message):
|
async def on_message(self, message):
|
||||||
# Skip notifications for muted channels
|
# Don't use muted_channels anymore since we're using Discord's native functionality
|
||||||
if (message.channel.id in self.user_management_commands.muted_channels and
|
# Instead, just process all messages
|
||||||
message.author != self.user):
|
|
||||||
# Still process the message, but don't trigger notifications
|
|
||||||
pass
|
|
||||||
|
|
||||||
# Regular message handling
|
|
||||||
await self.message_handler.handle_message(message)
|
await self.message_handler.handle_message(message)
|
||||||
|
|
||||||
async def on_message_delete(self, message):
|
async def on_message_delete(self, message):
|
||||||
|
|
Loading…
Reference in a new issue