export async function replyWithCommands(
interaction: ChatInputCommandInteraction | MessageComponentInteraction,
groupName: string
) {
await autoDeferReply(interaction);
// Check the group exists
const group = await getGroup(interaction.client, interaction, groupName);
if (!group) {
return sendDeferredEphermeralResponse(interaction, {
content: `The group \`${groupName}\` does not exist.`,
});
}
// Get all the commands for the group
const commands = await getCommandsForGroup(
interaction.client,
interaction,
group.name
);
// Create a button for going back to the groups
const backButton = new ButtonBuilder() //
.setCustomId(GroupButtonIDs.BackToGroup)
.setEmoji(":back:")
.setStyle(ButtonStyle.Primary);
// Add the button to a action row
const row = new ActionRowBuilder<ButtonBuilder>();
row.addComponents(backButton);
// Embed builder
const embed = new EmbedBuilder() //
.setColor(0x2095ab)
.setAuthor({
name: interaction.user.username,
iconURL: interaction.user.displayAvatarURL(),
})
.addFields([
{
name: "Information",
value: `Click on the 🔙 button to go back to the groups.`,
},
{
name: `${group.name} Commands`,
value:
commands
.map(
(command) =>
`\`/${command.name}\` ${command.description}`
)
.join("\n") || "No commands found",
},
]);
return sendDeferredResponse(interaction, {
embeds: [embed],
components: [row],
});
}
export async function replyWithCommands(
interaction: ChatInputCommandInteraction | MessageComponentInteraction,
groupName: string
) {
await autoDeferReply(interaction);
// Check the group exists
const group = await getGroup(interaction.client, interaction, groupName);
if (!group) {
return sendDeferredEphermeralResponse(interaction, {
content: `The group \`${groupName}\` does not exist.`,
});
}
// Get all the commands for the group
const commands = await getCommandsForGroup(
interaction.client,
interaction,
group.name
);
// Create a button for going back to the groups
const backButton = new ButtonBuilder() //
.setCustomId(GroupButtonIDs.BackToGroup)
.setEmoji(":back:")
.setStyle(ButtonStyle.Primary);
// Add the button to a action row
const row = new ActionRowBuilder<ButtonBuilder>();
row.addComponents(backButton);
// Embed builder
const embed = new EmbedBuilder() //
.setColor(0x2095ab)
.setAuthor({
name: interaction.user.username,
iconURL: interaction.user.displayAvatarURL(),
})
.addFields([
{
name: "Information",
value: `Click on the 🔙 button to go back to the groups.`,
},
{
name: `${group.name} Commands`,
value:
commands
.map(
(command) =>
`\`/${command.name}\` ${command.description}`
)
.join("\n") || "No commands found",
},
]);
return sendDeferredResponse(interaction, {
embeds: [embed],
components: [row],
});
}