Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
docs(Readme): update readme content [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
ijsblokjeee[bot] authored May 8, 2023
1 parent ffa3ffc commit 3416f6f
Showing 1 changed file with 96 additions and 3 deletions.
99 changes: 96 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,106 @@

## 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).
@snowcrystals/iglo is a [Discord.js](https://discordjs.dev) 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

```bash,yarn add @snowcrystals/iglo,npm install @snowcrystals/iglo,```
```bash
yarn add @snowcrystals/iglo
npm install @snowcrystals/iglo
```

### 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)

```js
class Command extends SlashCommand {
constructor(client) {
super(client, options); // <-- Options are the options from the decorator
}
}
```

#### Command Example

```ts
@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

```ts
@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

```ts
@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

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

.github/readme_extension.md

## Author

Expand Down

0 comments on commit 3416f6f

Please sign in to comment.