// External Imports import { Command, CommandBuilder, CommandClient, CommandInteraction, Constants, SlashCommand } from 'athena-prime'; // Internal Imports import { Database } from '../../shared/Database'; import { CreateDefaultEmbed, SetSeverity } from '../../utils'; // --------------- @SlashCommand( new CommandBuilder('rename-channel', 'Rename the general channel.') .setIntegrationTypes(Constants.ApplicationIntegrationType.GuildInstall) .setContexts(Constants.InteractionContextType.Guild) .setCommandType(Constants.ApplicationCommandType.ChatInput) .setMemberPermission(Constants.PermissionFlagsBits.ManageChannels) .addStringOption({ name: 'name', description: 'The new general chat name.', required: true, max_length: 32 }) ) class RenameGeneralCommand extends Command { cooldown = 360; userPermissions = [Constants.PermissionFlagsBits.ManageChannels]; async handleCommand(context: CommandClient, interaction: CommandInteraction, data: any) { if (!interaction.inGuild()) return; interaction.defer(); const settings = await Database.GetOrCreateSettings(interaction.guild.id); if (!settings.general_chat_id) { await interaction.createMessage({ embeds: [{ ...CreateDefaultEmbed(context), ...SetSeverity('warning'), description: 'No general channel has been configured. Please check your configuration and try again.' }] }); return; } const channel = context.getChannel(settings.general_chat_id); if (!channel || !channel.isTextBased()) { await interaction.createMessage({ embeds: [{ ...CreateDefaultEmbed(context), ...SetSeverity('error'), description: 'There was an issue trying to locate the configured general channel role. Please check your configuration and try again.' }] }); return; } const name = interaction.getRequiredString('name'); await context.editChannel(settings.general_chat_id, { name: name }); await interaction.createMessage({ embeds: [{ ...CreateDefaultEmbed(context), ...SetSeverity('success'), description: `Successfully updated ${channel.mention}` }] }); } } export default new RenameGeneralCommand('name-sync');