(rewrite): Rewritten /rename to /rename-general.

This commit is contained in:
2026-08-11 17:54:11 +08:00
parent d2b30ad060
commit fb24129634
3 changed files with 72 additions and 54 deletions
+68
View File
@@ -0,0 +1,68 @@
// 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 })
)
class RenameGeneralCommand extends Command<CommandClient> {
cooldown = 360;
userPermissions = [Constants.PermissionFlagsBits.ManageChannels];
async handleCommand(context: CommandClient<any, any>, 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');