Skip to content

Commit

Permalink
Fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
hiraeeth committed Aug 28, 2024
1 parent efffebe commit 732f1cc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
16 changes: 8 additions & 8 deletions app/commands/test/ping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ import { Client, CommandInteraction, SlashCommandBuilder, PermissionFlagsBits }
import { Command, CommandOptions } from "engine";

export const globals = {
some_variable: "test",
};
some_variable: "test"
}

@Command(5, ["*"], new SlashCommandBuilder().setName("ping").setDescription("Replies with Pong!"))
export default class PingCommand {
public static async callback(client: Client, interaction: CommandInteraction, options: CommandOptions) {
if (!interaction.memberPermissions?.has(PermissionFlagsBits.SendMessages)) {
await interaction.reply({ content: "You do not have the required permissions to use this command.", ephemeral: true });
return;
}
// get options
const cooldown = options.cooldown; // is: 3
const command_name = options.data.name; // is: ping

console.log(options.data.name) // will log: ping
console.log(options.cooldown) // will log: 5
// get current global variables
const globals = client.globals.get(command_name);
console.log(globals.some_variable); // is: test

await interaction.reply("Pong!");
}
Expand Down
2 changes: 2 additions & 0 deletions app/events/interaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default class InteractionCreateEvent {
cooldown: command.cooldown,
used: command.used,
data: command.data,
options: command.options,
});
command.used = new Date();
} else {
Expand All @@ -29,6 +30,7 @@ export default class InteractionCreateEvent {
cooldown: command.cooldown,
used: command.used,
data: command.data,
options: command.options,
});
command.used = new Date();
}
Expand Down
2 changes: 1 addition & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export type CallbackOptions = {
cooldown: number;
data: SlashCommandBuilder;
used: Date;
options: CommandOptions;
};

export type Command = {
Expand All @@ -85,7 +86,6 @@ export type Event = {
};

export type Methods = "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "HEAD" | "OPTIONS";

export type Route = {
path: string;
method: Methods | Methods[];
Expand Down

0 comments on commit 732f1cc

Please sign in to comment.