mirror of
https://github.com/thedrewen/protojx-manager.git
synced 2026-03-21 09:48:56 +01:00
feat(command): enhance ping command with button interaction and improved response format
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { ApplicationIntegrationType, ChatInputCommandInteraction, CommandInteraction, InteractionContextType, SlashCommandBuilder } from "discord.js";
|
||||
import { ApplicationIntegrationType, ButtonInteraction, ButtonStyle, ChatInputCommandInteraction, CommandInteraction, ComponentType, ContainerBuilder, InteractionContextType, MessageFlags, SlashCommandBuilder } from "discord.js";
|
||||
|
||||
export default {
|
||||
data: new SlashCommandBuilder()
|
||||
@@ -14,6 +14,33 @@ export default {
|
||||
InteractionContextType.PrivateChannel
|
||||
),
|
||||
async execute(interaction : ChatInputCommandInteraction) {
|
||||
await interaction.reply(`🏓 Latency is ${Date.now() - interaction.createdTimestamp}ms. API Latency : ${interaction.client.ws.ping}ms`);
|
||||
}
|
||||
|
||||
const container = new ContainerBuilder()
|
||||
.addTextDisplayComponents((textDisplay) => textDisplay.setContent(`🏓 Latency is ${Date.now() - interaction.createdTimestamp}ms. API Latency : ${interaction.client.ws.ping}ms`))
|
||||
.addSeparatorComponents((s) => s)
|
||||
.addSectionComponents((section) =>
|
||||
section
|
||||
.addTextDisplayComponents((textDisplay) =>
|
||||
textDisplay
|
||||
.setContent('Oh, that\'s a beautiful button!')
|
||||
)
|
||||
.setButtonAccessory((button) =>
|
||||
button
|
||||
.setCustomId('testClick')
|
||||
.setLabel('Click Me !')
|
||||
.setStyle(ButtonStyle.Success)
|
||||
)
|
||||
)
|
||||
|
||||
// await interaction.reply();
|
||||
await interaction.reply({
|
||||
components: [container],
|
||||
flags: MessageFlags.IsComponentsV2
|
||||
})
|
||||
},
|
||||
buttons: [
|
||||
{id: 'testClick', handle: (interaction : ButtonInteraction) => {
|
||||
interaction.reply({content: 'Ho !', flags: [MessageFlags.Ephemeral]})
|
||||
}}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user