Skip to content

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 7, 2023
1 parent 4826110 commit 99082c0
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 @@ -5,7 +5,7 @@
<p>Just like any other Discord.js framework, but better. 🧊</p>

<p align="center">
<img alt="Version" src="https://img.shields.io/badge/version-1.2.3-blue.svg" />
<img alt="Version" src="https://img.shields.io/badge/version-1.2.4-blue.svg" />
<a href="/LICENSE" target="_blank">
<img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-yellow.svg" />
</a>
Expand All @@ -31,9 +31,102 @@

## 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 99082c0

Please sign in to comment.