Archived
Revert "Fixed errors and upgraded to discordjs 13"
This reverts commit 296460a062.
This commit is contained in:
1 parent
296460a062
commit
6e966b243b
6 files changed
+56
-122
No files matched your search
+5
-15
@@ -1,11 +1,5 @@
|
||||
//IMPORTS
|
||||
import {
|
||||
Client,
|
||||
ClientOptions,
|
||||
Intents,
|
||||
Message,
|
||||
TextChannel,
|
||||
} from "discord.js";
|
||||
import { Client, ClientOptions, Message } from "discord.js";
|
||||
import { Command, CommandManager, CommandMessageStructure } from "./Command.js";
|
||||
import { PermissionsError } from "./Error.js";
|
||||
import { HelpMessage, HelpMessageParams } from "./Help.js";
|
||||
@@ -55,11 +49,7 @@ export class Bot extends EventEmitter {
|
||||
constructor(options: ConstructorOptions) {
|
||||
super();
|
||||
this.name = options.name;
|
||||
this.client = new Client(
|
||||
options.clientOptions || {
|
||||
intents: Intents.FLAGS.GUILDS,
|
||||
}
|
||||
);
|
||||
this.client = new Client(options.clientOptions);
|
||||
this.commands = new CommandManager(
|
||||
options.prefix,
|
||||
options.argumentSeparator
|
||||
@@ -129,7 +119,7 @@ export class Bot extends EventEmitter {
|
||||
user: m.member || undefined,
|
||||
command: cmdMsg.command,
|
||||
},
|
||||
m.channel as TextChannel
|
||||
m.channel
|
||||
);
|
||||
} else {
|
||||
this.messages.system.send(
|
||||
@@ -139,7 +129,7 @@ export class Bot extends EventEmitter {
|
||||
user: m.member || undefined,
|
||||
error: e,
|
||||
},
|
||||
m.channel as TextChannel
|
||||
m.channel
|
||||
);
|
||||
console.error(e);
|
||||
}
|
||||
@@ -151,7 +141,7 @@ export class Bot extends EventEmitter {
|
||||
this.messages.system.send(
|
||||
"NOT_FOUND",
|
||||
{ phrase: m.content, user: m.member || undefined },
|
||||
m.channel as TextChannel
|
||||
m.channel
|
||||
);
|
||||
} else {
|
||||
this.emit("MESSAGE", m);
|
||||
|
||||
+6
-7
@@ -1,10 +1,9 @@
|
||||
//IMPORTS
|
||||
import {
|
||||
Permissions,
|
||||
PermissionResolvable,
|
||||
Message,
|
||||
MessageEmbed,
|
||||
BitFieldResolvable,
|
||||
PermissionString,
|
||||
} from "discord.js";
|
||||
import { MissingParameterError, PermissionsError } from "./Error.js";
|
||||
import {
|
||||
@@ -28,7 +27,7 @@ interface CommandBuilder {
|
||||
description?: string;
|
||||
usage?: string;
|
||||
permissionCheck?: PermissionCheckTypes;
|
||||
permissions?: BitFieldResolvable<PermissionString, bigint>;
|
||||
permissions?: PermissionResolvable;
|
||||
visible?: boolean;
|
||||
function: (
|
||||
message?: Message,
|
||||
@@ -66,7 +65,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 {BitFieldResolvable} [options.permissions] - permissions needed to run the command
|
||||
* @param {PermissionResolvable} [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
|
||||
*/
|
||||
@@ -81,7 +80,7 @@ export class Command {
|
||||
options.permissionCheck == "ALL" || options.permissionCheck == "ANY"
|
||||
? options.permissionCheck
|
||||
: "ANY";
|
||||
this.permissions = new Permissions(options.permissions);
|
||||
this.permissions = new Permissions(options.permissions || 0);
|
||||
this.visible = options.visible != undefined ? options.visible : true;
|
||||
this.function = options.function;
|
||||
}
|
||||
@@ -94,7 +93,7 @@ export class Command {
|
||||
*/
|
||||
async start(message?: Message, cmdParams?: string[]): Promise<void> {
|
||||
const memberPermissions: Readonly<Permissions> =
|
||||
message?.member?.permissions || new Permissions();
|
||||
message?.member?.permissions || new Permissions(0);
|
||||
if (
|
||||
this.permissionCheck == "ALL"
|
||||
? memberPermissions.has(this.permissions, true)
|
||||
@@ -117,7 +116,7 @@ export class Command {
|
||||
if (typeof fnResult == "string") {
|
||||
await message?.reply(fnResult);
|
||||
} else if (fnResult instanceof MessageEmbed) {
|
||||
await message?.channel.send({ embeds: [fnResult] });
|
||||
await message?.channel.send(fnResult);
|
||||
}
|
||||
} else {
|
||||
throw new PermissionsError(this, message?.member);
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ export class HelpMessage extends Command {
|
||||
super({
|
||||
name: "help",
|
||||
usage: params.usage,
|
||||
permissions: undefined,
|
||||
permissions: 0,
|
||||
description: params.description,
|
||||
parameters: [
|
||||
{
|
||||
|
||||
@@ -79,10 +79,10 @@ export class SystemMessageManager {
|
||||
const embed = new MessageEmbed();
|
||||
embed.setTitle(this[type].title);
|
||||
if (this[type].bottomText)
|
||||
embed.setDescription(this[type].bottomText || "");
|
||||
embed.setDescription(this[type].bottomText);
|
||||
embed.setColor(this[type].accentColor || "#000");
|
||||
if (this[type].showTimestamp) embed.setTimestamp();
|
||||
if (this[type].footer) embed.setFooter(this[type].footer || "");
|
||||
if (this[type].footer) embed.setFooter(this[type].footer);
|
||||
if (data) {
|
||||
switch (type) {
|
||||
case "ERROR":
|
||||
@@ -153,11 +153,9 @@ export class SystemMessageManager {
|
||||
}
|
||||
}
|
||||
if (channel) {
|
||||
const message = await channel.send({ embeds: [embed] });
|
||||
const message = await channel.send(embed);
|
||||
if (this.deleteTimeout != Infinity && message.deletable) {
|
||||
setTimeout(async () => {
|
||||
await message.delete();
|
||||
}, this.deleteTimeout || 0);
|
||||
await message.delete({ timeout: this.deleteTimeout });
|
||||
}
|
||||
return message;
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user