xernerx 1.2.6 → 2.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.
- package/models/Client.js +3 -2
- package/models/commands/Event.js +3 -3
- package/models/events/interactionCreate.js +27 -29
- package/models/events/messageCreate.js +1 -0
- package/models/events/messageUpdate.js +1 -0
- package/models/events/readyOnce.js +1 -0
- package/models/handlers/CommandHandler.js +17 -12
- package/models/handlers/EventHandler.js +15 -23
- package/package.json +2 -3
package/models/Client.js
CHANGED
|
@@ -26,10 +26,11 @@ class Client extends Discord.Client {
|
|
|
26
26
|
ignoreOwner: s.boolean.optional,
|
|
27
27
|
defaultCooldown: s.number.optional,
|
|
28
28
|
logging: s.boolean.optional,
|
|
29
|
-
cacheTime: s.number.optional
|
|
29
|
+
cacheTime: s.number.optional,
|
|
30
|
+
dummi: s.boolean.optional
|
|
30
31
|
}).parse(options)
|
|
31
32
|
|
|
32
|
-
this.client = new Discord.Client({ intents: [
|
|
33
|
+
this.client = new Discord.Client({ intents: [options.intents], partials: [options.partials] });
|
|
33
34
|
|
|
34
35
|
this.client.messages = {};
|
|
35
36
|
|
package/models/commands/Event.js
CHANGED
|
@@ -4,21 +4,21 @@ const { s } = require('@sapphire/shapeshift')
|
|
|
4
4
|
* @param {String} id - The id of the event. @required
|
|
5
5
|
* @param {object} options - of the event. @required
|
|
6
6
|
* @param {string} name - The name of the event. @required
|
|
7
|
-
* @param {boolean} once - Whether the event should be ran once or
|
|
7
|
+
* @param {boolean} once - Whether the event should be ran once or continuously.
|
|
8
8
|
*/
|
|
9
9
|
class Event {
|
|
10
10
|
constructor(id, options = {}) {
|
|
11
11
|
s.object({
|
|
12
12
|
name: s.string,
|
|
13
13
|
once: s.boolean.optional,
|
|
14
|
-
|
|
14
|
+
type: s.string.optional
|
|
15
15
|
}).parse(options)
|
|
16
16
|
|
|
17
17
|
this.name = options.name;
|
|
18
18
|
|
|
19
19
|
this.once = options.once || false;
|
|
20
20
|
|
|
21
|
-
this.
|
|
21
|
+
this.type = options.type || 'client';
|
|
22
22
|
|
|
23
23
|
this.config = options.config;
|
|
24
24
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
const { Event } = require('../commands/Event.js');
|
|
2
2
|
const { interactionArgs, access } = require('./../data/Functions.js');
|
|
3
|
-
const
|
|
4
|
-
|
|
3
|
+
const { InteractionType } = require('discord.js')
|
|
5
4
|
/**
|
|
6
5
|
* @returns interaction command executor.
|
|
7
6
|
*/
|
|
@@ -9,50 +8,49 @@ class BuildInInteractionEvent extends Event {
|
|
|
9
8
|
constructor() {
|
|
10
9
|
super('interactionCreate', {
|
|
11
10
|
name: 'interactionCreate',
|
|
11
|
+
type: 'client',
|
|
12
12
|
once: false,
|
|
13
13
|
})
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
async run(interaction) {
|
|
17
|
-
if (interaction.
|
|
18
|
-
if (
|
|
19
|
-
|
|
20
|
-
let command = interaction.client.interactionCommands.get(interaction.commandName);
|
|
17
|
+
if (interaction.type == InteractionType.ApplicationCommand) {
|
|
18
|
+
if (interaction.client.interactionCommands.has(interaction.commandName)) {
|
|
19
|
+
let command = interaction.client.interactionCommands.get(interaction.commandName);
|
|
21
20
|
|
|
22
|
-
|
|
21
|
+
command.client = interaction.client;
|
|
23
22
|
|
|
24
|
-
|
|
23
|
+
let group = interactionArgs(interaction).group;
|
|
25
24
|
|
|
26
|
-
|
|
25
|
+
let sub = interactionArgs(interaction).sub;
|
|
27
26
|
|
|
28
|
-
|
|
27
|
+
let options = interactionArgs(interaction).options;
|
|
29
28
|
|
|
30
|
-
|
|
29
|
+
if (access(interaction, command)) return;
|
|
31
30
|
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
try {
|
|
32
|
+
await command.exec(interaction, { group: group, sub: sub, options: options });
|
|
34
33
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
return interaction.client.emit('commandRun', interaction, "interaction", command)
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
return interaction.client.emit("error", interaction, error);
|
|
38
|
+
}
|
|
39
39
|
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (interaction.isContextMenu()) {
|
|
43
|
-
if (!interaction.client.contextMenuCommands.has(interaction.commandName)) return;
|
|
44
40
|
|
|
45
|
-
|
|
41
|
+
if (interaction.client.contextMenuCommands.has(interaction.commandName)) {
|
|
42
|
+
let command = interaction.client.contextMenuCommands.get(interaction.commandName);
|
|
46
43
|
|
|
47
|
-
|
|
44
|
+
command.client = interaction.client;
|
|
48
45
|
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
try {
|
|
47
|
+
await command.exec(interaction);
|
|
51
48
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
49
|
+
return interaction.client.emit('commandRun', interaction, 'contextMenu', command);
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
return interaction.client.emit("error", interaction, error);
|
|
53
|
+
}
|
|
56
54
|
}
|
|
57
55
|
}
|
|
58
56
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const Discord = require('discord.js');
|
|
3
3
|
const { REST } = require('@discordjs/rest');
|
|
4
|
-
const { Routes } = require('discord-api-types/
|
|
4
|
+
const { Routes, GatewayVersion } = require('discord-api-types/v10');
|
|
5
5
|
const { delay, logStyle } = require('dumfunctions')
|
|
6
6
|
const paths = require("path")
|
|
7
7
|
|
|
@@ -91,20 +91,25 @@ class CommandHandler {
|
|
|
91
91
|
|
|
92
92
|
#deployCommands(type, logging = false) {
|
|
93
93
|
this.client.once('ready', client => {
|
|
94
|
-
const rest = new REST({ version:
|
|
94
|
+
const rest = new REST({ version: GatewayVersion }).setToken(client.token);
|
|
95
95
|
|
|
96
96
|
(async () => {
|
|
97
|
-
|
|
98
|
-
if (
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
97
|
+
try {
|
|
98
|
+
if (client.global == true) {
|
|
99
|
+
if (logging || this.client.logging) console.info(logStyle(`Loaded ${type} in ${(await client.guilds.fetch()).size} server(s) globally.`, 'text', 'purple'));
|
|
100
|
+
rest.put(Routes.applicationCommands(client.user.id), {
|
|
101
|
+
body: this.commands
|
|
102
|
+
})
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
if (logging || this.client.logging) console.info(logStyle(`Loaded ${type} locally.`, 'text', 'purple'));
|
|
106
|
+
rest.put(Routes.applicationGuildCommands(client.user.id, client.guildId), {
|
|
107
|
+
body: this.commands
|
|
108
|
+
})
|
|
109
|
+
}
|
|
102
110
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
rest.put(Routes.applicationGuildCommands(client.user.id, client.guildId), {
|
|
106
|
-
body: this.commands
|
|
107
|
-
})
|
|
111
|
+
catch (e) {
|
|
112
|
+
throw new Error(e)
|
|
108
113
|
}
|
|
109
114
|
})();
|
|
110
115
|
})
|
|
@@ -23,20 +23,13 @@ class EventHandler {
|
|
|
23
23
|
|
|
24
24
|
events.push(event.name);
|
|
25
25
|
|
|
26
|
-
if (event.
|
|
27
|
-
|
|
28
|
-
event.run(...args)
|
|
29
|
-
})
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
else if (event.once) {
|
|
33
|
-
this.client.once(event.name, (...args) => {
|
|
34
|
-
event.run(...args);
|
|
26
|
+
if (event.once) {
|
|
27
|
+
this.emitter(event.type).once(event.name, (...args) => {
|
|
28
|
+
event.run(...args)
|
|
35
29
|
})
|
|
36
30
|
}
|
|
37
|
-
|
|
38
31
|
else {
|
|
39
|
-
this.
|
|
32
|
+
this.emitter(event.type).on(event.name, (...args) => {
|
|
40
33
|
event.run(...args)
|
|
41
34
|
})
|
|
42
35
|
}
|
|
@@ -51,25 +44,24 @@ class EventHandler {
|
|
|
51
44
|
|
|
52
45
|
event = new event;
|
|
53
46
|
|
|
54
|
-
if (event.
|
|
55
|
-
|
|
56
|
-
event.run(...args)
|
|
57
|
-
})
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
else if (event.once) {
|
|
61
|
-
this.client.once(event.name, (...args) => {
|
|
62
|
-
event.run(...args);
|
|
47
|
+
if (event.once) {
|
|
48
|
+
this.emitter(event.type).once(event.name, (...args) => {
|
|
49
|
+
event.run(...args)
|
|
63
50
|
})
|
|
64
51
|
}
|
|
65
|
-
|
|
66
52
|
else {
|
|
67
|
-
this.
|
|
68
|
-
event.run(...args)
|
|
53
|
+
this.emitter(event.type).on(event.name, (...args) => {
|
|
54
|
+
event.run(...args)
|
|
69
55
|
})
|
|
70
56
|
}
|
|
71
57
|
}
|
|
72
58
|
}
|
|
59
|
+
|
|
60
|
+
emitter(type) {
|
|
61
|
+
if (type == 'client') return this.client;
|
|
62
|
+
if (type == 'rest') return this.client.rest;
|
|
63
|
+
else return eval(type)
|
|
64
|
+
}
|
|
73
65
|
}
|
|
74
66
|
|
|
75
67
|
module.exports = { EventHandler };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xernerx",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "A bot framework for discord.js. [BETA]",
|
|
5
5
|
"main": "main.js",
|
|
6
6
|
"scripts": {
|
|
@@ -17,11 +17,10 @@
|
|
|
17
17
|
},
|
|
18
18
|
"homepage": "https://github.com/TheDummi/xernerx#readme",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@discordjs/builders": "1.0.0",
|
|
21
20
|
"@discordjs/rest": "1.0.0",
|
|
22
21
|
"@sapphire/shapeshift": "3.5.1",
|
|
23
22
|
"discord-api-types": "^0.36.3",
|
|
24
|
-
"discord.js": "^
|
|
23
|
+
"discord.js": "^14.0.3",
|
|
25
24
|
"dumdiscord.js": "^1.0.5",
|
|
26
25
|
"dumfunctions": "^1.0.5",
|
|
27
26
|
"i18next": "^21.8.14"
|