First iteration!
This commit is contained in:
46
src/commands/ping.ts
Normal file
46
src/commands/ping.ts
Normal file
@ -0,0 +1,46 @@
|
||||
import { ApplyOptions } from '@sapphire/decorators';
|
||||
import { Command } from '@sapphire/framework';
|
||||
import { Message } from 'discord.js';
|
||||
|
||||
@ApplyOptions<Command.Options>({
|
||||
description: 'Pong!'
|
||||
})
|
||||
export class UserCommand extends Command {
|
||||
// Register Chat Input and Context Menu command
|
||||
public override registerApplicationCommands(registry: Command.Registry) {
|
||||
// Register Chat Input command
|
||||
registry.registerChatInputCommand({
|
||||
name: this.name,
|
||||
description: this.description
|
||||
});
|
||||
}
|
||||
|
||||
// Message command
|
||||
public async messageRun(message: Message) {
|
||||
return this.sendPing(message);
|
||||
}
|
||||
|
||||
// Chat Input (slash) command
|
||||
public async chatInputRun(interaction: Command.ChatInputCommandInteraction) {
|
||||
return this.sendPing(interaction);
|
||||
}
|
||||
|
||||
private async sendPing(interactionOrMessage: Message | Command.ChatInputCommandInteraction | Command.ContextMenuCommandInteraction) {
|
||||
const pingMessage =
|
||||
interactionOrMessage instanceof Message
|
||||
? await interactionOrMessage.channel.send({ content: 'Ping?' })
|
||||
: await interactionOrMessage.reply({ content: 'Ping?', fetchReply: true });
|
||||
|
||||
const content = `Pong! Bot Latency ${Math.round(this.container.client.ws.ping)}ms. API Latency ${
|
||||
pingMessage.createdTimestamp - interactionOrMessage.createdTimestamp
|
||||
}ms.`;
|
||||
|
||||
if (interactionOrMessage instanceof Message) {
|
||||
return pingMessage.edit({ content });
|
||||
}
|
||||
|
||||
return interactionOrMessage.editReply({
|
||||
content: content
|
||||
});
|
||||
}
|
||||
}
|
41
src/commands/wryna.ts
Normal file
41
src/commands/wryna.ts
Normal file
@ -0,0 +1,41 @@
|
||||
import { ApplyOptions } from '@sapphire/decorators';
|
||||
import { Args, Command } from '@sapphire/framework';
|
||||
import { Message } from 'discord.js';
|
||||
|
||||
@ApplyOptions<Command.Options>({
|
||||
description: 'This command was your nickname in highschool!',
|
||||
options: ['nickname']
|
||||
})
|
||||
export class UserCommand extends Command {
|
||||
// Register Chat Input and Context Menu command
|
||||
public override registerApplicationCommands(registry: Command.Registry) {
|
||||
registry.registerChatInputCommand((builder) =>
|
||||
builder //
|
||||
.setName(this.name)
|
||||
.setDescription(this.description)
|
||||
.addStringOption((option) => option.setName('nickname').setDescription('Your nickname in highschool.').setRequired(true))
|
||||
);
|
||||
}
|
||||
|
||||
// Message command
|
||||
public async messageRun(message: Message, args: Args) {
|
||||
return this.sendPing(message, args.getOption('nickname') || 'NOTHING');
|
||||
}
|
||||
|
||||
// Chat Input (slash) command
|
||||
public async chatInputRun(interaction: Command.ChatInputCommandInteraction) {
|
||||
return this.sendPing(interaction, interaction.options.getString('nickname') || 'NOTHING');
|
||||
}
|
||||
|
||||
private async sendPing(
|
||||
interactionOrMessage: Message | Command.ChatInputCommandInteraction | Command.ContextMenuCommandInteraction,
|
||||
nickname: string
|
||||
) {
|
||||
interactionOrMessage instanceof Message
|
||||
? await interactionOrMessage.channel.send({ content: `${nickname} was ${interactionOrMessage.author.tag}'s nickname in highschool!` })
|
||||
: await interactionOrMessage.reply({
|
||||
content: `${nickname} was ${interactionOrMessage.user.tag}'s nickname in highschool!`,
|
||||
fetchReply: true
|
||||
});
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user