Better docs
This commit is contained in:
45
examples/newCommand.txt
Normal file
45
examples/newCommand.txt
Normal file
@ -0,0 +1,45 @@
|
||||
import {
|
||||
ApplicationCommandOptionTypes,
|
||||
ApplicationCommandTypes,
|
||||
InteractionResponseTypes,
|
||||
} from "../../deps.ts";
|
||||
|
||||
import { createCommand } from "./mod.ts";
|
||||
|
||||
// This is the command definition. Please ensure the name matches the file name
|
||||
// Also, make sure the description is meaningfull
|
||||
createCommand({
|
||||
name: "command",
|
||||
description: "This is an example command",
|
||||
type: ApplicationCommandTypes.ChatInput,
|
||||
scope: "Global",
|
||||
options: [
|
||||
// This is an option that can be sent after the command and used for input
|
||||
{
|
||||
type: ApplicationCommandOptionTypes.String,
|
||||
name: "input",
|
||||
description: "Text you would like to send to this command.",
|
||||
// This will make the option required
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
execute: async (bot, interaction) => {
|
||||
// In this example, we only use "input", so we just need the one item from an array of length 1.
|
||||
// Options always returns an array, even if there is a single element.
|
||||
const input = interaction.data?.options?.find(
|
||||
(option) => option.name === "input"
|
||||
);
|
||||
|
||||
// This is how the bot responds to interactions. In this case, it is via a reply.
|
||||
await bot.helpers.sendInteractionResponse(
|
||||
interaction.id,
|
||||
interaction.token,
|
||||
{
|
||||
type: InteractionResponseTypes.ChannelMessageWithSource,
|
||||
data: {
|
||||
content: `${input?.value} was ${interaction.user.username}'s nickname in highschool.`,
|
||||
},
|
||||
}
|
||||
);
|
||||
},
|
||||
});
|
15
examples/newEvent.txt
Normal file
15
examples/newEvent.txt
Normal file
@ -0,0 +1,15 @@
|
||||
import { events } from "./mod.ts";
|
||||
import { logger } from "../utils/logger.ts";
|
||||
|
||||
// Log the event name here
|
||||
const log = logger({ name: "Event: messageCreate" });
|
||||
|
||||
/*
|
||||
The properties of events are tied to specific discord events.
|
||||
Please ensure that both the event type and the property (in this case message)
|
||||
accurately reflect what you want to listen for.
|
||||
*/
|
||||
events.exampleEvent = (bot, message) => {
|
||||
// In this example, the message contents are simply being logged
|
||||
log.info(`${message.tag}: ${message.content}`);
|
||||
};
|
Reference in New Issue
Block a user