mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-02 06:28:54 +00:00
fix: Replace support server and add bot info with link buttons in /help
This commit is contained in:
1 parent
bc83216c45
commit
612e3a00a6
1 file changed
+38
-41
@@ -1,5 +1,11 @@
|
||||
import {
|
||||
APIActionRowComponent,
|
||||
APIButtonComponent,
|
||||
APIMessageActionRowComponent,
|
||||
ButtonBuilder,
|
||||
ButtonStyle,
|
||||
Collection,
|
||||
ComponentType,
|
||||
EmbedBuilder,
|
||||
SlashCommandBuilder,
|
||||
SlashCommandNumberOption,
|
||||
@@ -19,24 +25,43 @@ class HelpCommand extends BaseSlashCommandInteraction {
|
||||
const { executionId, client, interaction } = params;
|
||||
const logger = this.getLogger(this.name, executionId, interaction);
|
||||
|
||||
const [commandEmbedString, supportServerString, addBotString] = await Promise.all([
|
||||
this.getCommandEmbedString(client!),
|
||||
this.getSupportServerString(),
|
||||
this.getAddBotString()
|
||||
]);
|
||||
const commandEmbedString = await this.getCommandEmbedString(client!);
|
||||
|
||||
const components: APIMessageActionRowComponent[] = [];
|
||||
|
||||
if (this.botOptions.serverInviteUrl && this.botOptions.serverInviteUrl !== '') {
|
||||
const supportServerButton: APIButtonComponent = new ButtonBuilder()
|
||||
.setURL(this.botOptions.serverInviteUrl)
|
||||
.setStyle(ButtonStyle.Link)
|
||||
.setEmoji(this.embedOptions.icons.support)
|
||||
.setLabel('Support server')
|
||||
.toJSON();
|
||||
components.push(supportServerButton);
|
||||
}
|
||||
|
||||
if (this.botOptions.botInviteUrl && this.botOptions.botInviteUrl !== '') {
|
||||
const addBotButton: APIButtonComponent = new ButtonBuilder()
|
||||
.setURL(this.botOptions.botInviteUrl)
|
||||
.setStyle(ButtonStyle.Link)
|
||||
.setEmoji(this.embedOptions.icons.bot)
|
||||
.setLabel('Add bot')
|
||||
.toJSON();
|
||||
components.push(addBotButton);
|
||||
}
|
||||
|
||||
const embedActionRow: APIActionRowComponent<APIMessageActionRowComponent> = {
|
||||
type: ComponentType.ActionRow,
|
||||
components
|
||||
};
|
||||
|
||||
logger.debug('Responding with info embed.');
|
||||
return await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
.setDescription(
|
||||
`${this.embedOptions.icons.rule} **List of commands**\n` +
|
||||
commandEmbedString +
|
||||
supportServerString +
|
||||
addBotString
|
||||
)
|
||||
.setDescription(`${this.embedOptions.icons.rule} **List of commands**\n` + commandEmbedString)
|
||||
.setColor(this.embedOptions.colors.info)
|
||||
]
|
||||
],
|
||||
components: [embedActionRow]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -58,7 +83,7 @@ class HelpCommand extends BaseSlashCommandInteraction {
|
||||
return this.getCommandString(command);
|
||||
});
|
||||
|
||||
const commandString = commandStringList.join('\n') + '\n';
|
||||
const commandString = commandStringList.join('\n');
|
||||
return commandString;
|
||||
}
|
||||
|
||||
@@ -76,34 +101,6 @@ class HelpCommand extends BaseSlashCommandInteraction {
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
private async getSupportServerString(): Promise<string> {
|
||||
if (!this.botOptions.serverInviteUrl) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const embedString = `
|
||||
${this.embedOptions.icons.support} **Support server**
|
||||
Join the support server for help or to suggest improvements:
|
||||
**${this.botOptions.serverInviteUrl}**
|
||||
`;
|
||||
|
||||
return embedString;
|
||||
}
|
||||
|
||||
private async getAddBotString(): Promise<string> {
|
||||
if (!this.botOptions.botInviteUrl) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const embedString = `
|
||||
${this.embedOptions.icons.bot} **Enjoying ${this.botOptions.name}?**
|
||||
Add me to another server:
|
||||
**[Click me!](${this.botOptions.botInviteUrl})**
|
||||
`;
|
||||
|
||||
return embedString;
|
||||
}
|
||||
}
|
||||
|
||||
export default new HelpCommand();
|
||||
Reference in new issue
Block a user