selfbot-legacy/bot/cogs/user_management.py
2025-05-09 22:43:55 +03:00

47 lines
1.8 KiB
Python

from bot.cogs.cog_manager import BaseCog
import discord
import asyncio
class UserManagementCog(BaseCog):
def __init__(self, bot):
super().__init__(bot)
async def cmd_close(self, message):
"""
Close the DM channel
Usage: .close
"""
try:
# Only works in DM channels
if isinstance(message.channel, discord.DMChannel):
await message.edit(content="✅ Closing DM...")
await asyncio.sleep(1) # Give a second for the message to be seen
await message.channel.close()
else:
await message.edit(content="❌ This command only works in DM channels.")
except Exception as e:
await message.edit(content=f"❌ Error closing DM: {str(e)}")
async def cmd_block(self, message):
"""
Block a user using Discord's native block function
Usage: .block @user or .block [in reply to a message]
"""
try:
# Check if we have a mention or if it's a reply
if message.mentions:
user = message.mentions[0]
elif message.reference and message.reference.resolved:
user = message.reference.resolved.author
else:
await message.edit(content="❌ Usage: `.block @user` or reply to a message with `.block`")
return
if user == self.bot.user:
await message.edit(content="❌ Cannot block yourself.")
return
await user.block()
await message.edit(content=f"✅ Blocked {user.name}#{user.discriminator}")
except Exception as e:
await message.edit(content=f"❌ Error blocking user: {str(e)}")