Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions docs/docs/discordx/basics/args-of.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ You can get the list of the events and the payload type in the [**List of events
```ts
@Discord()
class Example {
@On({ event: "messageCreate" })
@On({ event: Events.MessageCreate })
onMessage(
// The type of message is Message
[message]: ArgsOf<"messageCreate">,
[message]: ArgsOf<Events.MessageCreate>,
) {
// ...
}

@On({ event: "channelUpdate" })
@On({ event: Events.ChannelUpdate })
onMessage(
// The type of channel1 and channel2 is TextChannel
[channel1, channel2]: ArgsOf<"channelUpdate">,
[channel1, channel2]: ArgsOf<Events.ChannelUpdate>,
) {
// ...
}
Expand Down
6 changes: 3 additions & 3 deletions docs/docs/discordx/basics/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const client = new Client({
silent: false,
});

client.on("ready", async () => {
client.on(Events.ClientReady, async () => {
console.log(">> Bot started");

// to create/update/delete discord application commands
Expand All @@ -42,7 +42,7 @@ If an event of your app isn't triggered, you probably missed an **Intent**
### Basic intents, just text messages

```ts
import { IntentsBitField } from "discord.js";
import { Events, IntentsBitField } from "discord.js";

const client = new Client({
botId: "test",
Expand Down Expand Up @@ -72,7 +72,7 @@ const client = new Client({
### Voice activity intent, the ability to speak

```ts
import { IntentsBitField } from "discord.js";
import { Events, IntentsBitField } from "discord.js";

const client = new Client({
botId: "test",
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/discordx/basics/dependency-injection.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ DIService.engine = myCustomEngine;
It is recommended to do this in your main class where you define your `new Client()` code; for example:

```ts
import { IntentsBitField } from "discord.js";
import { Events, IntentsBitField } from "discord.js";
import { Client, DIService, tsyringeDependencyRegistryEngine } from "discordx";

async function start() {
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/discordx/decorators/command/simple-command.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ async function start() {
],
});

client.on("messageCreate", (message) => {
client.on(Events.MessageCreate, (message) => {
client.executeCommand(message);
});

Expand Down
8 changes: 4 additions & 4 deletions docs/docs/discordx/decorators/command/slash.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ async function start() {
],
});

client.once("ready", async () => {
client.once(Events.ClientReady, async () => {
await client.initApplicationCommands();
});

client.on("interactionCreate", (interaction) => {
client.on(Events.InteractionCreate, (interaction) => {
client.executeInteraction(interaction);
});

Expand Down Expand Up @@ -80,7 +80,7 @@ You can remove application commands from the Discord cache by using `client.clea
> If you do not specify the guild id you operate on global application commands

```ts
client.once("ready", async () => {
client.once(Events.ClientReady, async () => {
await client.clearApplicationCommands();
await client.clearApplicationCommands("546281071751331840");
await client.initApplicationCommands();
Expand All @@ -94,7 +94,7 @@ or fetch them by using `client.fetchApplicationCommands(guildId: string)`
> If you do not specify the guild id you operate on global application commands

```ts
client.once("ready", async () => {
client.once(Events.ClientReady, async () => {
// ...
const applicationCommands = await client.fetchApplicationCommands();
});
Expand Down
14 changes: 8 additions & 6 deletions docs/docs/discordx/decorators/general/guard.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ import { Client, Discord, Guard, On } from "discordx";

@Discord()
class Example {
@On("messageCreate")
@On(Events.MessageCreate)
@Guard(
NotBot, // You can use multiple guard functions, they are executed in the same order!
)
async onMessage([message]: ArgsOf<"messageCreate">) {
async onMessage([message]: ArgsOf<Events.MessageCreate>) {
switch (message.content.toLowerCase()) {
case "hello":
message.reply("Hello!");
Expand Down Expand Up @@ -73,7 +73,7 @@ import {
@Guard(NotBot)
class Example {
@On({ event: Events.MessageCreate })
message([message]: ArgsOf<"messageCreate">) {
message([message]: ArgsOf<Events.MessageCreate>) {
//...
}

Expand Down Expand Up @@ -118,7 +118,7 @@ Guards work like `Koa`'s, it's a function passed in parameter (third parameter i
```typescript
import { ArgsOf, GuardFunction } from "discordx";

export const NotBot: GuardFunction<ArgsOf<"messageCreate">> = async (
export const NotBot: GuardFunction<ArgsOf<Events.MessageCreate>> = async (
[message],
client,
next,
Expand All @@ -134,7 +134,7 @@ If you have to indicate parameters for a guard function you can simple use the "
```typescript
export function Prefix(text: string, replace: boolean = true) {
const guard: GuardFunction<
ArgsOf<"messageCreate"> | CommandInteraction
ArgsOf<Events.MessageCreate> | CommandInteraction
> = async (arg, client, next) => {
const argObj = arg instanceof Array ? arg[0] : arg;
if (argObj instanceof CommandInteraction) {
Expand All @@ -161,7 +161,9 @@ As 4th parameter you receive a basic empty object that can be used to transmit d

```typescript
export const NotBot: GuardFunction<
| ArgsOf<"messageCreate" | "messageReactionAdd" | "voiceStateUpdate">
| ArgsOf<
Events.MessageCreate | Events.MessageReactionAdd | Events.VoiceStateUpdate
>
| ButtonInteraction
| ChannelSelectMenuInteraction
| CommandInteraction
Expand Down
8 changes: 4 additions & 4 deletions docs/docs/discordx/decorators/general/on.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ It's that simple, when the event is triggered, the method is called:
```typescript
@Discord()
class Example {
@On({ event: "messageCreate" })
@On({ event: Events.MessageCreate })
onMessage() {
// ...
}

@Once({ event: "messageDelete" })
@Once({ event: Events.MessageDelete })
onMessageDelete() {
// ...
}
Expand All @@ -38,9 +38,9 @@ import { ArgsOf, Client, Discord, On } from "discordx";

@Discord()
class Example {
@On({ event: "messageCreate" })
@On({ event: Events.MessageCreate })
onMessage(
[message]: ArgsOf<"messageCreate">, // Type message automatically
[message]: ArgsOf<Events.MessageCreate>, // Type message automatically
client: Client, // Client instance injected here,
guardPayload: any,
) {
Expand Down
6 changes: 3 additions & 3 deletions docs/docs/discordx/decorators/general/once.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ It's exactly the same behavior as [@On](./on) but the method is only executed on
```typescript
@Discord()
class Example {
@Once({ event: "messageDelete" })
@Once({ event: Events.MessageDelete })
onMessageDelete() {
// ...
}
Expand Down Expand Up @@ -33,9 +33,9 @@ You also receive other useful arguments after that:
```typescript
@Discord()
class Example {
@Once({ event: "messageCreate" })
@Once({ event: Events.MessageCreate })
onMessage(
[message]: ArgsOf<"messageCreate">, // Type message automatically
[message]: ArgsOf<Events.MessageCreate>, // Type message automatically
client: Client, // Client instance injected here,
guardPayload: any,
) {
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/discordx/decorators/general/reaction.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ async function start() {
partials: [Partials.Message, Partials.Channel, Partials.Reaction], // Necessary to receive reactions for uncached messages
});

client.on("messageReactionAdd", (reaction, user) => {
client.on(Events.MessageReactionAdd, (reaction, user) => {
client.executeReaction(reaction, user);
});

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/discordx/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ const client = new Client({
silent: false,
});

client.on("ready", async () => {
client.on(Events.ClientReady, async () => {
console.log(">> Bot started");

// to create/update/delete discord application commands
Expand Down
2 changes: 1 addition & 1 deletion packages/discordx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ class Example {
@Guard(
NotBot, // You can use multiple guard functions, they are executed in the same order!
)
messageCreate([message]: ArgsOf<"messageCreate">) {
messageCreate([message]: ArgsOf<Events.MessageCreate>) {
switch (message.content.toLowerCase()) {
case "hello":
message.reply("Hello!");
Expand Down
6 changes: 3 additions & 3 deletions packages/discordx/examples/attachment/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* -------------------------------------------------------------------------------------------------------
*/
import { dirname, importx } from "@discordx/importer";
import { IntentsBitField } from "discord.js";
import { Events, IntentsBitField } from "discord.js";
import { Client } from "discordx";

// eslint-disable-next-line @typescript-eslint/no-extraneous-class
Expand All @@ -27,13 +27,13 @@ export class Main {
silent: false,
});

this._client.once("ready", () => {
this._client.once(Events.ClientReady, () => {
void this._client.initApplicationCommands();

console.log(">> Bot started");
});

this._client.on("interactionCreate", (interaction) => {
this._client.on(Events.InteractionCreate, (interaction) => {
this._client.executeInteraction(interaction);
});

Expand Down
6 changes: 3 additions & 3 deletions packages/discordx/examples/builders/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* -------------------------------------------------------------------------------------------------------
*/
import { dirname, importx } from "@discordx/importer";
import { IntentsBitField } from "discord.js";
import { Events, IntentsBitField } from "discord.js";
import { Client } from "discordx";

// eslint-disable-next-line @typescript-eslint/no-extraneous-class
Expand All @@ -27,7 +27,7 @@ export class Main {
silent: false,
});

this._client.once("ready", () => {
this._client.once(Events.ClientReady, () => {
// An example of how guild commands can be cleared
//
// await this._client.clearApplicationCommands(
Expand All @@ -39,7 +39,7 @@ export class Main {
console.log(">> Bot started");
});

this._client.on("interactionCreate", (interaction) => {
this._client.on(Events.InteractionCreate, (interaction) => {
this._client.executeInteraction(interaction);
});

Expand Down
6 changes: 3 additions & 3 deletions packages/discordx/examples/button/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* -------------------------------------------------------------------------------------------------------
*/
import { dirname, importx } from "@discordx/importer";
import { IntentsBitField } from "discord.js";
import { Events, IntentsBitField } from "discord.js";
import { Client } from "discordx";

// eslint-disable-next-line @typescript-eslint/no-extraneous-class
Expand All @@ -26,13 +26,13 @@ export class Main {
silent: false,
});

this._client.once("ready", () => {
this._client.once(Events.ClientReady, () => {
void this._client.initApplicationCommands();

console.log("Bot started");
});

this._client.on("interactionCreate", (interaction) => {
this._client.on(Events.InteractionCreate, (interaction) => {
this._client.executeInteraction(interaction);
});

Expand Down
8 changes: 4 additions & 4 deletions packages/discordx/examples/contextmenu/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* -------------------------------------------------------------------------------------------------------
*/
import { dirname, importx } from "@discordx/importer";
import { IntentsBitField } from "discord.js";
import { Events, IntentsBitField } from "discord.js";
import { Client } from "discordx";

// eslint-disable-next-line @typescript-eslint/no-extraneous-class
Expand All @@ -26,17 +26,17 @@ export class Main {
silent: false,
});

this._client.on("messageCreate", (message) => {
this._client.on(Events.MessageCreate, (message) => {
void this._client.executeCommand(message);
});

this._client.once("ready", () => {
this._client.once(Events.ClientReady, () => {
void this._client.initApplicationCommands();

console.log("Bot started");
});

this._client.on("interactionCreate", (interaction) => {
this._client.on(Events.InteractionCreate, (interaction) => {
this._client.executeInteraction(interaction);
});

Expand Down
6 changes: 3 additions & 3 deletions packages/discordx/examples/di/tsyringe/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import "reflect-metadata";

import { tsyringeDependencyRegistryEngine } from "@discordx/di";
import { dirname, importx } from "@discordx/importer";
import { IntentsBitField } from "discord.js";
import { Events, IntentsBitField } from "discord.js";
import { Client, DIService } from "discordx";
import { container } from "tsyringe";

Expand All @@ -34,13 +34,13 @@ export class Main {
silent: false,
});

this._client.once("ready", () => {
this._client.once(Events.ClientReady, () => {
void this._client.initApplicationCommands();

console.log("Bot started");
});

this._client.on("interactionCreate", (interaction) => {
this._client.on(Events.InteractionCreate, (interaction) => {
this._client.executeInteraction(interaction);
});

Expand Down
6 changes: 3 additions & 3 deletions packages/discordx/examples/di/typedi/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* -------------------------------------------------------------------------------------------------------
*/
import { dirname, importx } from "@discordx/importer";
import { IntentsBitField } from "discord.js";
import { Events, IntentsBitField } from "discord.js";
import { Client, DIService, typeDiDependencyRegistryEngine } from "discordx";
import { Container, Service } from "typedi";

Expand Down Expand Up @@ -33,13 +33,13 @@ export class Main {
silent: false,
});

this._client.once("ready", () => {
this._client.once(Events.ClientReady, () => {
void this._client.initApplicationCommands();

console.log("Bot started");
});

this._client.on("interactionCreate", (interaction) => {
this._client.on(Events.InteractionCreate, (interaction) => {
this._client.executeInteraction(interaction);
});

Expand Down
Loading