tickets-bot/commands/manage.py
Neil Revin 00d90dea36
feat: initial
Signed-off-by: ItsNeil17 <neil@willofsteel.me>
2025-11-29 20:44:22 +05:30

43 lines
2 KiB
Python

import discord
from discord.ext import commands
from discord import app_commands
from database import get_ticket
class ManageCommands(commands.Cog):
def __init__(self, bot):
self.bot = bot
@app_commands.command(name="add", description="Add a user to the ticket")
async def add(self, interaction: discord.Interaction, user: discord.Member):
ticket = await get_ticket(interaction.channel_id)
if not ticket:
await interaction.response.send_message("❌ This is not a ticket channel.", ephemeral=True)
return
if not interaction.user.guild_permissions.manage_channels:
await interaction.response.send_message("❌ You don't have permission to add users.", ephemeral=True)
return
await interaction.channel.set_permissions(user, read_messages=True, send_messages=True)
await interaction.response.send_message(f"{user.mention} has been added to the ticket.")
@app_commands.command(name="remove", description="Remove a user from the ticket")
async def remove(self, interaction: discord.Interaction, user: discord.Member):
ticket = await get_ticket(interaction.channel_id)
if not ticket:
await interaction.response.send_message("❌ This is not a ticket channel.", ephemeral=True)
return
if not interaction.user.guild_permissions.manage_channels:
await interaction.response.send_message("❌ You don't have permission to remove users.", ephemeral=True)
return
if user.id == ticket.user_id:
await interaction.response.send_message("❌ You cannot remove the ticket owner.", ephemeral=True)
return
await interaction.channel.set_permissions(user, overwrite=None)
await interaction.response.send_message(f"{user.mention} has been removed from the ticket.")
async def setup(bot):
await bot.add_cog(ManageCommands(bot))