Archived
Fixed errors and upgraded to discordjs 13
This commit is contained in:
1 parent
8e3c3afc6d
commit
296460a062
6 files changed
+125
-59
No files matched your search
+7
-6
@@ -1,9 +1,10 @@
|
||||
//IMPORTS
|
||||
import {
|
||||
Permissions,
|
||||
PermissionResolvable,
|
||||
Message,
|
||||
MessageEmbed,
|
||||
BitFieldResolvable,
|
||||
PermissionString,
|
||||
} from "discord.js";
|
||||
import { MissingParameterError, PermissionsError } from "./Error.js";
|
||||
import {
|
||||
@@ -27,7 +28,7 @@ interface CommandBuilder {
|
||||
description?: string;
|
||||
usage?: string;
|
||||
permissionCheck?: PermissionCheckTypes;
|
||||
permissions?: PermissionResolvable;
|
||||
permissions?: BitFieldResolvable<PermissionString, bigint>;
|
||||
visible?: boolean;
|
||||
function: (
|
||||
message?: Message,
|
||||
@@ -65,7 +66,7 @@ export class Command {
|
||||
* @param {string} [options.description="No description"] - command description shown in the help message
|
||||
* @param {string} [options.usage] - command usage description shown in the help message
|
||||
* @param {PermissionCheckTypes} [options.permissionCheck='ANY'] - specifies if the caller has to have all of the specified permissions or any of that
|
||||
* @param {PermissionResolvable} [options.permissions] - permissions needed to run the command
|
||||
* @param {BitFieldResolvable} [options.permissions] - permissions needed to run the command
|
||||
* @param {boolean} [options.visible=true] - show command in the help message
|
||||
* @param {Function} options.function - function that will trigger when the commands gets called
|
||||
*/
|
||||
@@ -80,7 +81,7 @@ export class Command {
|
||||
options.permissionCheck == "ALL" || options.permissionCheck == "ANY"
|
||||
? options.permissionCheck
|
||||
: "ANY";
|
||||
this.permissions = new Permissions(options.permissions || 0);
|
||||
this.permissions = new Permissions(options.permissions);
|
||||
this.visible = options.visible != undefined ? options.visible : true;
|
||||
this.function = options.function;
|
||||
}
|
||||
@@ -93,7 +94,7 @@ export class Command {
|
||||
*/
|
||||
async start(message?: Message, cmdParams?: string[]): Promise<void> {
|
||||
const memberPermissions: Readonly<Permissions> =
|
||||
message?.member?.permissions || new Permissions(0);
|
||||
message?.member?.permissions || new Permissions();
|
||||
if (
|
||||
this.permissionCheck == "ALL"
|
||||
? memberPermissions.has(this.permissions, true)
|
||||
@@ -116,7 +117,7 @@ export class Command {
|
||||
if (typeof fnResult == "string") {
|
||||
await message?.reply(fnResult);
|
||||
} else if (fnResult instanceof MessageEmbed) {
|
||||
await message?.channel.send(fnResult);
|
||||
await message?.channel.send({ embeds: [fnResult] });
|
||||
}
|
||||
} else {
|
||||
throw new PermissionsError(this, message?.member);
|
||||
|
||||
Reference in new issue
Block a user