xernerx 2.7.4 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +0 -0
  3. package/dist/build/ContextCommand.d.ts +39 -0
  4. package/dist/build/ContextCommand.js +86 -0
  5. package/dist/build/Event.d.ts +15 -0
  6. package/dist/build/Event.js +31 -0
  7. package/dist/build/Inhibitor.d.ts +12 -0
  8. package/dist/build/Inhibitor.js +20 -0
  9. package/dist/build/MessageCommand.d.ts +39 -0
  10. package/dist/build/MessageCommand.js +77 -0
  11. package/dist/build/SlashCommand.d.ts +32 -0
  12. package/dist/build/SlashCommand.js +119 -0
  13. package/dist/client/XernerxClient.d.ts +22 -0
  14. package/dist/client/XernerxClient.js +76 -0
  15. package/dist/handlers/CommandHandler.d.ts +27 -0
  16. package/dist/handlers/CommandHandler.js +42 -0
  17. package/dist/handlers/EventHandler.d.ts +13 -0
  18. package/dist/handlers/EventHandler.js +16 -0
  19. package/dist/handlers/Handler.d.ts +37 -0
  20. package/dist/handlers/Handler.js +242 -0
  21. package/dist/handlers/InhibitorHandler.d.ts +18 -0
  22. package/dist/handlers/InhibitorHandler.js +21 -0
  23. package/dist/interfaces/ClientInterfaces.d.ts +58 -0
  24. package/dist/interfaces/ClientInterfaces.js +1 -0
  25. package/dist/interfaces/CommandInterfaces.d.ts +94 -0
  26. package/dist/interfaces/CommandInterfaces.js +1 -0
  27. package/dist/interfaces/HandlerInterfaces.d.ts +70 -0
  28. package/dist/interfaces/HandlerInterfaces.js +1 -0
  29. package/dist/main.d.ts +26 -0
  30. package/dist/main.js +40 -0
  31. package/dist/models/CommandArguments.d.ts +9 -0
  32. package/dist/models/CommandArguments.js +128 -0
  33. package/dist/models/CommandValidations.d.ts +3 -0
  34. package/dist/models/CommandValidations.js +193 -0
  35. package/dist/models/Events.d.ts +23 -0
  36. package/dist/models/Events.js +328 -0
  37. package/dist/models/Functions.d.ts +1 -0
  38. package/dist/models/Functions.js +30 -0
  39. package/dist/models/InhibitorValidations.d.ts +17 -0
  40. package/dist/models/InhibitorValidations.js +42 -0
  41. package/dist/types/EventTypes.d.ts +1 -0
  42. package/dist/types/EventTypes.js +1 -0
  43. package/dist/types/InhibitorTypes.d.ts +12 -0
  44. package/dist/types/InhibitorTypes.js +13 -0
  45. package/dist/types/Types.d.ts +24 -0
  46. package/dist/types/Types.js +21 -0
  47. package/dist/utils/ClientUtil.d.ts +25 -0
  48. package/dist/utils/ClientUtil.js +232 -0
  49. package/dist/utils/CommandUtil.d.ts +24 -0
  50. package/dist/utils/CommandUtil.js +163 -0
  51. package/package.json +5 -8
  52. package/main.js +0 -49
  53. package/models/Client.js +0 -60
  54. package/models/commands/ContextMenuCommand.js +0 -68
  55. package/models/commands/Event.js +0 -33
  56. package/models/commands/Inhibitor.js +0 -31
  57. package/models/commands/InteractionCommand.js +0 -142
  58. package/models/commands/MessageCommand.js +0 -86
  59. package/models/data/colors.json +0 -16
  60. package/models/data/options.json +0 -27
  61. package/models/events/interactionCreate.js +0 -84
  62. package/models/events/messageCreate.js +0 -84
  63. package/models/events/messageUpdate.js +0 -83
  64. package/models/events/readyOnce.js +0 -58
  65. package/models/handlers/CommandHandler.js +0 -37
  66. package/models/handlers/EventHandler.js +0 -67
  67. package/models/handlers/Handler.js +0 -111
  68. package/models/handlers/InhibitorHandler.js +0 -16
  69. package/models/handlers/LanguageHandler.js +0 -37
  70. package/models/utils/Arguments.js +0 -120
  71. package/models/utils/CommandValidation.js +0 -96
  72. package/models/utils/CommandsUtil.js +0 -70
  73. package/models/utils/Functions.js +0 -266
  74. package/models/utils/InhibitorsUtil.js +0 -24
  75. package/models/utils/InhibitorsValidation.js +0 -40
  76. package/models/utils/Util.js +0 -96
@@ -1,142 +0,0 @@
1
- const { s } = require('@sapphire/shapeshift');
2
- const { SlashCommandSubcommandGroupBuilder, SlashCommandSubcommandBuilder, SlashCommandBuilder } = require('discord.js');
3
- const { toTitleCase } = require('dumfunctions');
4
-
5
- /**
6
- * @param {string} name - The name of the command. @required
7
- * @param {string} description - The brief description of the command. @required
8
- * @param {string} detailedDescription - The detailed description of the command.
9
- * @param {boolean} owner - Wether the command can be executed by the bot owner only or not.
10
- * @param {boolean} admin - Wether the command can be executed by the guild admins only or not.
11
- * @param {string} channel - Wheter the command can only be executed in a DM, a Guild, or both.
12
- */
13
- class InteractionCommand {
14
- constructor(id, options = {}) {
15
-
16
- s.object({
17
- name: s.string,
18
- description: s.string,
19
- info: s.string.optional,
20
- owner: s.boolean.optional,
21
- admin: s.boolean.optional,
22
- channel: s.string.optional,
23
- category: s.string.optional,
24
- cooldown: s.number.optional,
25
- ignoreOwner: s.boolean.optional,
26
- inVoice: s.boolean.optional,
27
- channels: s.array(s.string).optional,
28
- guilds: s.array(s.string).optional,
29
- userPermissions: s.array(s.string).optional,
30
- clientPermissions: s.array(s.string).optional,
31
- defer: s.object({
32
- reply: s.boolean.optional,
33
- ephemeral: s.boolean.optional
34
- }).optional
35
- }).parse(options);
36
-
37
- this.data = new SlashCommandBuilder()
38
- .setName(options.name)
39
- .setDescription(options.description)
40
-
41
- if (["args", "subcommands", "groups"].map(x => options[x]?.length).filter(x => x).length > 1) throw new Error("Args, subs, and groups are mutually exclusive");
42
-
43
- if (options?.args?.length > 0) {
44
- this.addOptions(this.data, options.args);
45
- }
46
-
47
- else if (options?.subs?.length > 0) {
48
- this.addSubcommands(this.data, options.subs);
49
- }
50
-
51
- else if (options?.groups?.length > 0) {
52
- this.addSubcommandGroups(options.groups);
53
- }
54
-
55
- this.id = id;
56
-
57
- this.owner = options.owner || false;
58
-
59
- this.admin = options.admin || false;
60
-
61
- this.channel = options.channel || undefined;
62
-
63
- this.category = options.category || undefined;
64
-
65
- this.config = options.config;
66
-
67
- this.cooldown = options.cooldown || 0;
68
-
69
- this.ignoreOwner = options.ignoreOwner || false;
70
-
71
- this.inVoice = options.inVoice || false;
72
-
73
- this.info = options.info || undefined;
74
-
75
- this.channels = options.channels || [];
76
-
77
- this.guilds = options.guilds || [];
78
-
79
- this.userPermissions = options.userPermissions || [];
80
-
81
- this.clientPermissions = options.clientPermissions || [];
82
-
83
- this.defer = {
84
- reply: options?.defer?.reply === undefined ? null : options?.defer?.reply,
85
- ephemeral: options?.defer?.ephemeral === undefined ? null : options?.defer?.ephemeral
86
- }
87
- }
88
-
89
- exec(interaction) {
90
- /*
91
- * Make your custom command here.
92
- */
93
- }
94
-
95
- addOptions(where, args) {
96
- const types = ["boolean", "integer", "number", "string", "user", "role", "channel", "mentionable"];
97
-
98
- for (const argument of args) {
99
- if (!types.includes(argument.type.toLowerCase())) throw new Error(`Expected one of ${types.join(', ')}, received ${argument.type} instead.`);
100
-
101
- where[`add${toTitleCase(argument.type, true)}Option`](option => {
102
- option
103
- .setName(argument.name)
104
- .setDescription(argument.description)
105
- .setRequired(argument.required || false)
106
- if (argument.choices) option.setChoices(...argument?.choices);
107
-
108
- return option;
109
- })
110
- }
111
- }
112
-
113
- addSubcommands(where, subs) {
114
- for (const sub of subs) {
115
- let subCommand = new SlashCommandSubcommandBuilder()
116
- .setName(sub.name)
117
- .setDescription(sub.description);
118
- if (sub?.args?.length > 0) {
119
- this.addOptions(subCommand, sub.args)
120
- }
121
- where.addSubcommand(subCommand);
122
- }
123
- }
124
-
125
- addSubcommandGroups(groups) {
126
- for (const group of groups) {
127
- let subcommandGroup = new SlashCommandSubcommandGroupBuilder()
128
- .setName(group.name)
129
- .setDescription(group.description)
130
-
131
- if (group?.subs?.length > 0) {
132
- this.addSubcommands(subcommandGroup, group.subs)
133
- if (group?.subs?.args) {
134
- this.addOptions(group.subs, group.subs.args)
135
- }
136
- }
137
- this.data.addSubcommandGroup(subcommandGroup);
138
- }
139
- }
140
- }
141
-
142
- module.exports = { InteractionCommand };
@@ -1,86 +0,0 @@
1
- const { s } = require('@sapphire/shapeshift');
2
-
3
- /**
4
- * @param {string} name - The name of the command. @required
5
- * @param {string} aliases - Optional aliases of the command.
6
- * @param {string} description - The brief description of the command. @required
7
- * @param {string} detailedDescription - The detailed description of the command.
8
- * @param {boolean} owner - Wether the command can be executed by the bot owner only or not.
9
- * @param {boolean} admin - Wether the command can be executed by the guild admins only or not.
10
- * @param {string} channel - Whether the command can only be executed in a DM, a Guild, or both.
11
- * @param {string} separator - A string used to separate arguments.
12
- */
13
- class MessageCommand {
14
- constructor(id, options = {}) {
15
-
16
- s.object({
17
- name: s.string,
18
- aliases: s.array(s.string).optional,
19
- description: s.string,
20
- prefix: s.array(s.string).optional,
21
- info: s.string.optional,
22
- owner: s.boolean.optional,
23
- admin: s.boolean.optional,
24
- channel: s.string.optional,
25
- separator: s.string.optional,
26
- category: s.string.optional,
27
- cooldown: s.number.optional,
28
- ignoreOwner: s.boolean.optional,
29
- inVoice: s.boolean.optional,
30
- channels: s.array(s.string).optional,
31
- guilds: s.array(s.string).optional,
32
- userPermissions: s.array(s.string).optional,
33
- clientPermissions: s.array(s.string).optional
34
- }).parse(options);
35
-
36
- this.id = id;
37
-
38
- this.name = options.name;
39
-
40
- this.aliases = [options.name, ...(options.aliases ? options.aliases : [])];
41
-
42
- this.regex = options.regex instanceof RegExp ? String(options.regex) : undefined;
43
-
44
- this.prefix = options.prefix || [];
45
-
46
- this.description = options.description || undefined;
47
-
48
- this.owner = options.owner || undefined;
49
-
50
- this.admin = options.admin || undefined;
51
-
52
- this.channel = options.channel || undefined;
53
-
54
- this.separator = options.separator || ' '
55
-
56
- this.args = options.args;
57
-
58
- this.category = options.category || undefined;
59
-
60
- this.config = options.config;
61
-
62
- this.cooldown = options.cooldown || 0;
63
-
64
- this.ignoreOwner = options.ignoreOwner || false;
65
-
66
- this.inVoice = options.inVoice || false;
67
-
68
- this.info = options.info || undefined;
69
-
70
- this.channels = options.channels || [];
71
-
72
- this.guilds = options.guilds || [];
73
-
74
- this.userPermissions = options.userPermissions || [];
75
-
76
- this.clientPermissions = options.clientPermissions || [];
77
- }
78
-
79
- exec(message) {
80
- /*
81
- * Make your custom command here.
82
- */
83
- }
84
- }
85
-
86
- module.exports = { MessageCommand };
@@ -1,16 +0,0 @@
1
- {
2
- "red": "#ff0000",
3
- "orange": "#ff8000",
4
- "yellow": "#ffff00",
5
- "chartreuse": "#80ff00",
6
- "green": "#00ff00",
7
- "springGreen": "#00ff80",
8
- "cyan": "#00ffff",
9
- "dodgerBlue": "#0080ff",
10
- "blue": "#0000ff",
11
- "purple": "#8000ff",
12
- "violet": "#ff00ff",
13
- "magenta": "#ff0080",
14
- "black": "#000000",
15
- "white": "#FFFFFF"
16
- }
@@ -1,27 +0,0 @@
1
- [
2
- "one",
3
- "two",
4
- "three",
5
- "four",
6
- "five",
7
- "six",
8
- "seven",
9
- "eight",
10
- "nine",
11
- "ten",
12
- "eleven",
13
- "twelve",
14
- "thirteen",
15
- "fourteen",
16
- "fifteen",
17
- "sixteen",
18
- "seventeen",
19
- "eighteen",
20
- "nineteen",
21
- "twenty",
22
- "twentyone",
23
- "twentytwo",
24
- "twentythree",
25
- "twentyfour",
26
- "twentyfive"
27
- ]
@@ -1,84 +0,0 @@
1
- const { Event } = require('../commands/Event.js');
2
- const { interactionArgs } = require('./../utils/Arguments.js');
3
- const { InteractionType } = require('discord.js')
4
- const { commandValidation } = require('./../utils/CommandValidation.js');
5
- const { interactionUtil } = require('./../utils/Util.js');
6
- const { inhibitorsValidation } = require('../utils/InhibitorsValidation.js');
7
- /**
8
- * @returns interaction command executor.
9
- */
10
- class BuildInInteractionEvent extends Event {
11
- constructor() {
12
- super('interactionCreate', {
13
- name: 'interactionCreate',
14
- type: 'client',
15
- once: false,
16
- })
17
- }
18
-
19
- async run(interaction) {
20
- await interactionUtil(interaction);
21
-
22
- if (interaction.type == InteractionType.ApplicationCommand) {
23
- if (interaction.client.commands.interaction.has(interaction.commandName)) {
24
- let command = interaction.client.commands.interaction.get(interaction.commandName);
25
-
26
- if (await inhibitorsValidation(interaction, command)) return;
27
-
28
- await this.defer(interaction, command);
29
-
30
- command.client = interaction.client;
31
-
32
- const group = interactionArgs(interaction).group;
33
-
34
- const subcommand = interactionArgs(interaction).sub;
35
-
36
- const args = interactionArgs(interaction).options;
37
-
38
- if (commandValidation(interaction, command)) return;
39
-
40
- try {
41
- if (command.conditions && await command.conditions(interaction, { group, subcommand, args })) return;
42
-
43
- await command.exec(interaction, { group, subcommand, args });
44
-
45
- return interaction.client.emit('commandRun', interaction, "interaction", command)
46
- }
47
- catch (error) {
48
- return interaction.client.emit("error", interaction, error);
49
- }
50
- }
51
-
52
- if (interaction.client.commands.contextMenu.has(interaction.commandName)) {
53
- let command = interaction.client.commands.contextMenu.get(interaction.commandName);
54
-
55
- if (await inhibitorsValidation(interaction, command)) return;
56
-
57
- await this.defer(interaction, command);
58
-
59
- command.client = interaction.client;
60
-
61
- try {
62
- if (command.conditions && await command.conditions(interaction)) return;
63
-
64
- await command.exec(interaction);
65
-
66
- return interaction.client.emit('commandRun', interaction, 'contextMenu', command);
67
- }
68
- catch (error) {
69
- return interaction.client.emit("error", interaction, error);
70
- }
71
- }
72
- }
73
- }
74
-
75
- async defer(interaction, command) {
76
- if (command?.defer?.reply) return await interaction.deferReply({ ephemeral: command?.defer?.ephemeral });
77
-
78
- else if (command?.defer?.reply === false && interaction.client?.settings?.defer?.reply) return;
79
-
80
- else if (interaction.client?.settings?.defer?.reply) return await interaction.deferReply({ ephemeral: interaction.client?.settings?.defer?.ephemeral || command?.defer?.ephemeral });
81
- }
82
- }
83
-
84
- module.exports = BuildInInteractionEvent;
@@ -1,84 +0,0 @@
1
- const { Event } = require('../commands/Event.js');
2
- const { messageArgs } = require("./../utils/Arguments.js");
3
- const { commandValidation } = require('./../utils/CommandValidation.js');
4
- const { messageUtil } = require('../utils/Util.js');
5
- const { inhibitorsValidation } = require('../utils/InhibitorsValidation.js');
6
-
7
- /**
8
- * @returns message command executor.
9
- */
10
- class BuildInMessageEvent extends Event {
11
- constructor() {
12
- super('messageCreate', {
13
- name: 'messageCreate',
14
- type: 'client',
15
- once: false,
16
- })
17
- }
18
-
19
- async run(message) {
20
- if (!message.author.bot) {
21
- await messageUtil(message, "create");
22
-
23
- let commands = message.client.commands.message;
24
-
25
- commands.filter(c => c.regex).map(async command => {
26
- let regex = command.regex.split(/\//).slice(1);
27
-
28
- regex = RegExp(...regex);
29
-
30
- if (message.content.match(regex)) {
31
- try {
32
- if (command.conditions && (await command.conditions(message))) return;
33
-
34
- return await command.exec(message);
35
- }
36
- catch (error) {
37
- message.client.emit("error", message, error);
38
- }
39
- };
40
- })
41
-
42
- if (message?.client?.settings?.prefix?.length <= 0 && !message.client.settings.mentionPrefix) return;
43
-
44
- commands.filter(c => !c.regex).map(async command => {
45
- command?.prefix?.map(prefix => {
46
- this.commandCheck(message, prefix, command);
47
- })
48
-
49
- if (message.client.settings.mentionPrefix && !message.client.settings.prefix.includes(`<@${message.client.user.id}>`)) message.client.settings.prefix.push(`<@${message.client.user.id}>`)
50
-
51
- message.client.settings.prefix.map(prefix => {
52
- this.commandCheck(message, prefix, command);
53
- });
54
- })
55
- }
56
- }
57
-
58
- async commandCheck(message, prefix, command) {
59
- for (const alias of command.aliases) {
60
- if (message.content.split(/ +/)[0] !== prefix + alias) continue;
61
-
62
- if (await inhibitorsValidation(message, command)) break;
63
-
64
- const args = await messageArgs({ message: message, command: command });
65
-
66
- if (commandValidation(message, command)) break;
67
-
68
- try {
69
- if (command.conditions && (await command.conditions(message, args))) break;
70
-
71
- await command.exec(message, args);
72
-
73
- return message.client.emit('commandRun', message, 'message', command);
74
- }
75
- catch (error) {
76
- message.client.emit("error", message, error);
77
-
78
- break;
79
- }
80
- }
81
- }
82
- };
83
-
84
- module.exports = BuildInMessageEvent;
@@ -1,83 +0,0 @@
1
- const { Event } = require('../commands/Event.js');
2
- const { messageArgs } = require("./../utils/Arguments.js");
3
- const { commandValidation } = require('./../utils/CommandValidation.js');
4
- const { messageUtil } = require('../utils/Util.js');
5
- const { inhibitorsValidation } = require('../utils/InhibitorsValidation.js');
6
-
7
- /**
8
- * @returns message command executor.
9
- */
10
- class BuildInMessageUpdateEvent extends Event {
11
- constructor() {
12
- super('messageUpdate', {
13
- name: 'messageUpdate',
14
- type: 'client',
15
- once: false,
16
- })
17
- }
18
-
19
- async run(oldMessage, newMessage) {
20
- if (!oldMessage.author.bot && !newMessage.author.bot) {
21
- await messageUtil(newMessage, "edit");
22
-
23
- let commands = newMessage.client.commands.message;
24
-
25
- commands.filter(c => c.regex).map(async command => {
26
- let regex = command.regex.split(/\//).slice(1);
27
-
28
- regex = RegExp(...regex);
29
-
30
- if (newMessage.content.match(regex)) {
31
- try {
32
- if (command.conditions && (await command.conditions(newMessage))) return;
33
-
34
- return await command.exec(newMessage);
35
- }
36
- catch (error) {
37
- newMessage.client.emit("error", newMessage, error);
38
- }
39
- };
40
- })
41
-
42
- if (newMessage?.client?.settings?.prefix?.length <= 0) return;
43
-
44
- if (!newMessage.client.data.messages[newMessage.id] === undefined) return;
45
-
46
- commands.filter(c => !c.regex).map(async command => {
47
- command?.prefix?.map(prefix => {
48
- this.commandCheck(newMessage, prefix, command);
49
- })
50
-
51
- newMessage.client.settings.prefix.map(prefix => {
52
- this.commandCheck(newMessage, prefix, command);
53
- });
54
- })
55
- }
56
- }
57
-
58
- async commandCheck(message, prefix, command) {
59
- for (const alias of command.aliases) {
60
- if (message.content.split(/ +/)[0] !== prefix + alias) continue;
61
-
62
- if (await inhibitorsValidation(message, command)) break;
63
-
64
- const args = await messageArgs({ message: message, command: command });
65
-
66
- if (commandValidation(message, command)) break;
67
-
68
- try {
69
- if (command.conditions && (await command.conditions(message, args))) break;
70
-
71
- await command.exec(message, args);
72
-
73
- return message.client.emit('commandRun', message, 'message', command);
74
- }
75
- catch (error) {
76
- message.client.emit("error", message, error);
77
- break;
78
- }
79
- }
80
- }
81
- };
82
-
83
- module.exports = BuildInMessageUpdateEvent;
@@ -1,58 +0,0 @@
1
- const { Event } = require('../commands/Event.js');
2
- const { logStyle } = require('dumfunctions');
3
-
4
- /**
5
- * @returns message command executor.
6
- */
7
- class BuildInReadyOnceEvent extends Event {
8
- constructor() {
9
- super('ready', {
10
- name: 'ready',
11
- once: true,
12
- })
13
- }
14
-
15
- async run(client) {
16
- if (client.settings.logging) console.info(logStyle(`${client.user.tag} is online in ${(await client.guilds.fetch()).size} servers.`, "text", "cyan"));
17
-
18
- if (Array.isArray(client.settings.logging)) {
19
- let loaded = [];
20
-
21
- for (const [type, commands] of Object.entries(client.commands)) {
22
- for (let [id, command] of commands) {
23
- command.name = command?.data?.name || command?.aliases[0] || command.id;
24
-
25
- command.description = command?.data?.description || command.description;
26
-
27
- command.runType = type;
28
-
29
- if (!loaded.includes(command)) loaded.push(command);
30
- }
31
- }
32
-
33
- for (const [id, event] of [...client.events]) {
34
- event.runType = 'event';
35
-
36
- loaded.push(event);
37
- }
38
-
39
- for (const [id, inhibitor] of [...client.inhibitors]) {
40
- inhibitor.runType = 'inhibitor';
41
-
42
- loaded.push(inhibitor);
43
- }
44
-
45
- console.table(loaded, client.settings.logging);
46
- }
47
- else {
48
- Object.entries(client.commands).map(([type, commands]) => {
49
- console.info(logStyle(`Loaded ${type} commands: ${commands.map(command => command?.data?.name || command?.name || command?.id).join(', ')}`, "text", "cyan"));
50
- })
51
-
52
- // add events and inhibitors;
53
- }
54
- }
55
-
56
- };
57
-
58
- module.exports = BuildInReadyOnceEvent;
@@ -1,37 +0,0 @@
1
- const Discord = require('discord.js');
2
- const Handler = require('./Handler.js');
3
-
4
- /**
5
- * @param {object} client - The client.
6
- * @returns a command handler.
7
- */
8
- class CommandHandler {
9
- constructor({ client: client }) {
10
-
11
- this.client = client;
12
-
13
- client.commands = {
14
- message: new Discord.Collection(),
15
-
16
- interaction: new Discord.Collection(),
17
-
18
- contextMenu: new Discord.Collection()
19
- }
20
-
21
- this.load = new Handler(client);
22
- }
23
-
24
- loadAllInteractionCommands(path, logging = false) {
25
- this.load.loadAllInteractionCommands(path, logging);
26
- }
27
-
28
- loadAllContextMenuCommands(path, logging = false) {
29
- this.load.loadAllContextMenuCommands(path, logging);
30
- }
31
-
32
- loadAllMessageCommands(path, logging = false) {
33
- this.load.loadAllMessageCommands(path, logging);
34
- }
35
- }
36
-
37
- module.exports = { CommandHandler };
@@ -1,67 +0,0 @@
1
- const fs = require('fs');
2
- const Discord = require('discord.js');
3
-
4
- /**
5
- * @param {object} client - Client object.
6
- */
7
- class EventHandler {
8
- constructor({ client: client }) {
9
- this.client = client;
10
-
11
- client.events = new Discord.Collection()
12
- }
13
-
14
- loadAllEvents(path, logging) {
15
- const eventFiles = fs.readdirSync(path).filter(file => file.endsWith('.js'))
16
-
17
- for (const file of eventFiles) {
18
- let event = require(`${require("path").resolve(path)}/${file}`);
19
-
20
- event = new event;
21
-
22
- event.client = this.client;
23
-
24
- this.client.events.set(event.name, event);
25
-
26
- if (event.once) {
27
- this.emitter(event.type).once(event.name, (...args) => {
28
- event.run(...args)
29
- })
30
- }
31
- else {
32
- this.emitter(event.type).on(event.name, (...args) => {
33
- event.run(...args)
34
- })
35
- }
36
- }
37
-
38
- const builderFiles = fs.readdirSync(`${__dirname}/../events`).filter(file => file.endsWith('.js'))
39
-
40
- for (const file of builderFiles) {
41
- let event = require(`../events/${file}`);
42
-
43
- event = new event;
44
-
45
- if (event.once) {
46
- this.emitter(event.type).once(event.name, (...args) => {
47
- event.run(...args)
48
- })
49
- }
50
- else {
51
- this.emitter(event.type).on(event.name, (...args) => {
52
- event.run(...args)
53
- })
54
- }
55
- }
56
- }
57
-
58
- emitter(type) {
59
- const client = this.client;
60
-
61
- if (type == 'client') return client;
62
- if (type == 'rest') return client.rest;
63
- else return eval(type);
64
- }
65
- }
66
-
67
- module.exports = { EventHandler };