mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-04 14:38:49 +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 {
|
import {
|
||||||
|
APIActionRowComponent,
|
||||||
|
APIButtonComponent,
|
||||||
|
APIMessageActionRowComponent,
|
||||||
|
ButtonBuilder,
|
||||||
|
ButtonStyle,
|
||||||
Collection,
|
Collection,
|
||||||
|
ComponentType,
|
||||||
EmbedBuilder,
|
EmbedBuilder,
|
||||||
SlashCommandBuilder,
|
SlashCommandBuilder,
|
||||||
SlashCommandNumberOption,
|
SlashCommandNumberOption,
|
||||||
@@ -19,24 +25,43 @@ class HelpCommand extends BaseSlashCommandInteraction {
|
|||||||
const { executionId, client, interaction } = params;
|
const { executionId, client, interaction } = params;
|
||||||
const logger = this.getLogger(this.name, executionId, interaction);
|
const logger = this.getLogger(this.name, executionId, interaction);
|
||||||
|
|
||||||
const [commandEmbedString, supportServerString, addBotString] = await Promise.all([
|
const commandEmbedString = await this.getCommandEmbedString(client!);
|
||||||
this.getCommandEmbedString(client!),
|
|
||||||
this.getSupportServerString(),
|
const components: APIMessageActionRowComponent[] = [];
|
||||||
this.getAddBotString()
|
|
||||||
]);
|
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.');
|
logger.debug('Responding with info embed.');
|
||||||
return await interaction.editReply({
|
return await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setDescription(
|
.setDescription(`${this.embedOptions.icons.rule} **List of commands**\n` + commandEmbedString)
|
||||||
`${this.embedOptions.icons.rule} **List of commands**\n` +
|
|
||||||
commandEmbedString +
|
|
||||||
supportServerString +
|
|
||||||
addBotString
|
|
||||||
)
|
|
||||||
.setColor(this.embedOptions.colors.info)
|
.setColor(this.embedOptions.colors.info)
|
||||||
]
|
],
|
||||||
|
components: [embedActionRow]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,7 +83,7 @@ class HelpCommand extends BaseSlashCommandInteraction {
|
|||||||
return this.getCommandString(command);
|
return this.getCommandString(command);
|
||||||
});
|
});
|
||||||
|
|
||||||
const commandString = commandStringList.join('\n') + '\n';
|
const commandString = commandStringList.join('\n');
|
||||||
return commandString;
|
return commandString;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,34 +101,6 @@ class HelpCommand extends BaseSlashCommandInteraction {
|
|||||||
}
|
}
|
||||||
return '';
|
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();
|
export default new HelpCommand();
|
||||||
Reference in new issue
Block a user