mirror of
https://github.com/thedrewen/protojx-manager.git
synced 2026-03-21 09:48:56 +01:00
49 lines
1.9 KiB
TypeScript
49 lines
1.9 KiB
TypeScript
import { ApplicationIntegrationType, ButtonInteraction, ButtonStyle, ChatInputCommandInteraction, ContainerBuilder, InteractionContextType, MessageFlags, SlashCommandBuilder } from "discord.js";
|
|
import { CommandDefinition } from "../../type";
|
|
|
|
const cmd : CommandDefinition = {
|
|
data: new SlashCommandBuilder()
|
|
.setName('ping')
|
|
.setDescription('Pong again!')
|
|
.setIntegrationTypes(
|
|
ApplicationIntegrationType.GuildInstall,
|
|
ApplicationIntegrationType.UserInstall
|
|
)
|
|
.setContexts(
|
|
InteractionContextType.BotDM,
|
|
InteractionContextType.Guild,
|
|
InteractionContextType.PrivateChannel
|
|
),
|
|
async execute(interaction : ChatInputCommandInteraction) {
|
|
|
|
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]})
|
|
}}
|
|
]
|
|
}
|
|
|
|
export default cmd; |