🖥️
Discord Base
  • Welcome
  • Getting Started
    • Quickstart
  • Templates
    • Command
    • Events
    • Component
    • Route
  • Utilities
    • Colors
    • Logger
    • Remote MySQL
    • Local MySQL
    • Query Builder
  • DataTypes
    • Commands
    • Events
    • Routes
Powered by GitBook
On this page
  • Decorator
  • Template
  • Permissions
  • Globals (only available to commands)
  • Definition
  • Usage
  • Example
  • Options
  1. Templates

Command

You can create new commands in app/commands

Decorator

parameter
type
required

cooldown

number

guilds

string[]

builder

any

You can specify guilds by their ids as an array. ["1", "2", "3"] or ["*"]

Template

import { Client, CommandInteraction, SlashCommandBuilder } from "discord.js";
import { Command } from "engine";

@Command(5, ["*"], new SlashCommandBuilder().setName("ping").setDescription("Replies with Pong!"))
export default class PingCommand {
	public static async callback(client: Client, interaction: CommandInteraction) {
		await interaction.reply("Pong!");
	}
}

Permissions

import { Client, CommandInteraction, SlashCommandBuilder, PermissionFlagsBits } from "discord.js";
import { Command } from "engine";

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

		await interaction.reply("Pong!");
	}
}

Globals (only available to commands)

Definition

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

Usage

client.globals.get("COMMAND_NAME")

Example

import { Client, CommandInteraction, SlashCommandBuilder, PermissionFlagsBits } from "discord.js";
import { Command } from "engine";

export const globals = {
	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) {
		const ping_globals = client.globals.get("ping")
		console.log(ping_globals.some_variable) // will log: test
		await interaction.reply("Pong!");
	}
}

Options

import { Client, CommandInteraction, SlashCommandBuilder, PermissionFlagsBits } from "discord.js";
import { Command, CommandOptions } from "engine";

export const globals = {
	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) {
		
		const cooldown = options.cooldown; // is: 3
		const command_name = options.data.name; // is: ping

		// get current global variables
		const globals = client.globals.get(command_name);
		console.log(globals.some_variable); // is: test

		await interaction.reply("Pong!");
	}
}
PreviousQuickstartNextEvents

Last updated 8 months ago

You can use PermissionFlagsBits

(all permissions)