@snowcrystals/iglo is a Discord.js framework which makes building a bot a lot easier. With its built-in SlashCommand registry system it checks updates the data once a change to the command is detected (a restart is required if code changes are made). The framework currently only supports SlashCommands (no idea why you want to use message commands now that Discord restricted the content to only a limited amount of eligible bots).
yarn add @snowcrystals/iglo
npm install @snowcrystals/iglo
The documentation (API Reference) can be found on our website
The following examples are written in TypeScript with decorators enabled. The examples do not show the required imports (because the only imports you will need are @snowcrystals/iglo components).
For a non-decorator version, use a constructor and move the options to the super function inside the constructor (example below)
class Command extends SlashCommand {
constructor(client) {
super(client, options); // <-- Options are the options from the decorator
}
}
@ApplyOptions<CommandOptions>({
name: "test",
description: "Replies with 'Hello World!'"
})
class Command extends Command {
public async run(interaction: CommandInteraction) {
await interaction.reply("Hello World!");
}
}
@ApplyOptions<SubCommandOptions>({
name: "test",
description: "Replies with 'Hello World!'",
options: [
{
name: "world",
description: "A very cool command",
type: ApplicationCommandOptionType.Subcommand
}
],
subcommands: [
{
name: "world",
functionName: "world"
}
]
})
class Command extends SubCommand {
public async world(interaction: CommandInteraction) {
await interaction.reply("Hello World!");
}
}
@ApplyOptions<EventListenerOptions>({
name: "ready",
once: true
})
export class ReadyEvent extends EventListener {
public run() {
void this.client.commandHandler.registry.start();
this.client.logger.info(`(Bot): Connected to Discord as ${bold(this.client.user?.tag ?? "")}.`);
}
}
@ApplyOptions<InteractionListenerOptions>({
name: "modal",
type: InteractionType.ModalSubmit
})
export default class extends InteractionListener {
public async run(interaction: ModalSubmitInteraction) {
const title = interaction.fields.getTextInputValue("contact-title");
const description = interaction.fields.getField("contact-description");
console.log(title, description);
await interaction.reply({
content: "Data received",
ephemeral: true
});
}
}
π€ ijsKoud
- Website: https://ijskoud.dev/
- Email: hi@ijskoud.dev
- Twitter: @ijsKoud
- Github: @ijsKoud
This will always be open source project, even if I don't receive donations. But there are still people out there that want to donate, so if you do here is the link PayPal or to Ko-Fi. Thanks in advance! I really appriciate it <3
Project is licensed under the Β© MIT License