@snowcrystals/iglo
TypeScript icon, indicating that this package has built-in type declarations

1.2.8ย โ€ขย Publicย โ€ขย Published

@snowcrystals/iglo

Just like any other Discord.js framework, but better. ๐ŸงŠ

Version License: MIT


Information

@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).

Install

yarn add @snowcrystals/iglo
npm install @snowcrystals/iglo

Documentation

The documentation (API Reference) can be found on our website

Examples

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
	}
}

Command Example

@ApplyOptions<CommandOptions>({
	name: "test",
	description: "Replies with 'Hello World!'"
})
class Command extends Command {
	public async run(interaction: CommandInteraction) {
		await interaction.reply("Hello World!");
	}
}

SubCommand Example

@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!");
	}
}

EventListener Example

@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 ?? "")}.`);
	}
}

InteractionListener Example

@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
		});
	}
}

Author

๐Ÿ‘ค ijsKoud

Donate

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

License

Project is licensed under the ยฉ MIT License


Readme

Keywords

none

Package Sidebar

Install

npm i @snowcrystals/iglo

Weekly Downloads

23

Version

1.2.8

License

MIT

Unpacked Size

1.87 MB

Total Files

136

Last publish

Collaborators

  • ijskoud