catto.js 0.9.8 → 1.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/Bot.js +59 -15
- package/package.json +1 -1
package/Bot.js
CHANGED
|
@@ -22,7 +22,8 @@ module.exports = class extends EventEmitter {
|
|
|
22
22
|
"publicKey": "",
|
|
23
23
|
"debug": !1,
|
|
24
24
|
"mobile": !1,
|
|
25
|
-
"sharded": !1
|
|
25
|
+
"sharded": !1,
|
|
26
|
+
"partials": !1
|
|
26
27
|
}, options || {});
|
|
27
28
|
if (client) {
|
|
28
29
|
this.client = client;
|
|
@@ -35,11 +36,13 @@ module.exports = class extends EventEmitter {
|
|
|
35
36
|
}
|
|
36
37
|
var opts = {
|
|
37
38
|
"intents": new Discord.IntentsBitField(this.options.intents),
|
|
38
|
-
"partials": [Discord.Partials.Channel, Discord.Partials.GuildMember, Discord.Partials.GuildScheduledEvent, Discord.Partials.Message, Discord.Partials.Reaction, Discord.Partials.ThreadMember, Discord.Partials.User],
|
|
39
39
|
"rest": {
|
|
40
40
|
"version": this.options.apiv
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
|
+
if (this.options.partials) {
|
|
44
|
+
opts.partials = [Discord.Partials.Channel, Discord.Partials.GuildMember, Discord.Partials.GuildScheduledEvent, Discord.Partials.Message, Discord.Partials.Reaction, Discord.Partials.ThreadMember, Discord.Partials.User];
|
|
45
|
+
}
|
|
43
46
|
if (this.options.sharded) {
|
|
44
47
|
opts.shards = getInfo().SHARD_LIST;
|
|
45
48
|
opts.shardCount = getInfo().TOTAL_SHARDS;
|
|
@@ -59,7 +62,8 @@ module.exports = class extends EventEmitter {
|
|
|
59
62
|
this.client.on("debug", console.log);
|
|
60
63
|
}
|
|
61
64
|
this.client.on("ready", () => {
|
|
62
|
-
var
|
|
65
|
+
var gcmds = [];
|
|
66
|
+
var scmds = [];
|
|
63
67
|
for (var cmd of this.slashCommands.values()) {
|
|
64
68
|
var cmdo = new Discord.SlashCommandBuilder();
|
|
65
69
|
cmdo.setName(cmd.name).setDescription(cmd.description).setDMPermission(cmd.dm);
|
|
@@ -165,29 +169,69 @@ module.exports = class extends EventEmitter {
|
|
|
165
169
|
if (cmd.user) {
|
|
166
170
|
contexts.push(2);
|
|
167
171
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
172
|
+
if (cmd.servers) {
|
|
173
|
+
cmd.servers.forEach(id => {
|
|
174
|
+
if (!scmds[id]) {
|
|
175
|
+
scmds[id] = [];
|
|
176
|
+
}
|
|
177
|
+
scmds[id].push(Object.assign(cmdo.toJSON(), {
|
|
178
|
+
integration_types, contexts
|
|
179
|
+
}));
|
|
180
|
+
});
|
|
181
|
+
} else {
|
|
182
|
+
gcmds.push(Object.assign(cmdo.toJSON(), {
|
|
183
|
+
integration_types, contexts
|
|
184
|
+
}));
|
|
185
|
+
}
|
|
171
186
|
}
|
|
172
187
|
for (var cmd of this.userContexts.values()) {
|
|
173
188
|
var cmdo = new Discord.ContextMenuCommandBuilder();
|
|
174
189
|
cmdo.setType(2).setName(cmd.name).setDMPermission(cmd.dm);
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
190
|
+
if (cmd.servers) {
|
|
191
|
+
cmd.servers.forEach(id => {
|
|
192
|
+
if (!scmds[id]) {
|
|
193
|
+
scmds[id] = [];
|
|
194
|
+
}
|
|
195
|
+
scmds[id].push(Object.assign(cmdo.toJSON(), {
|
|
196
|
+
"integration_types": [0, 1].slice(0, (cmd.user ? 2 : 1)),
|
|
197
|
+
"contexts": [0, 1, 2].slice(0, (cmd.user ? 3 : 2)),
|
|
198
|
+
}));
|
|
199
|
+
});
|
|
200
|
+
} else {
|
|
201
|
+
gcmds.push(Object.assign(cmdo.toJSON(), {
|
|
202
|
+
"integration_types": [0, 1].slice(0, (cmd.user ? 2 : 1)),
|
|
203
|
+
"contexts": [0, 1, 2].slice(0, (cmd.user ? 3 : 2)),
|
|
204
|
+
}));
|
|
205
|
+
}
|
|
179
206
|
}
|
|
180
207
|
for (var cmd of this.messageContexts.values()) {
|
|
181
208
|
var cmdo = new Discord.ContextMenuCommandBuilder();
|
|
182
209
|
cmdo.setType(3).setName(cmd.name).setDMPermission(cmd.dm);
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
210
|
+
if (cmd.servers) {
|
|
211
|
+
cmd.servers.forEach(id => {
|
|
212
|
+
if (!scmds[id]) {
|
|
213
|
+
scmds[id] = [];
|
|
214
|
+
}
|
|
215
|
+
scmds[id].push(Object.assign(cmdo.toJSON(), {
|
|
216
|
+
"integration_types": [0, 1].slice(0, (cmd.user ? 2 : 1)),
|
|
217
|
+
"contexts": [0, 1, 2].slice(0, (cmd.user ? 3 : 2)),
|
|
218
|
+
}));
|
|
219
|
+
});
|
|
220
|
+
} else {
|
|
221
|
+
gcmds.push(Object.assign(cmdo.toJSON(), {
|
|
222
|
+
"integration_types": [0, 1].slice(0, (cmd.user ? 2 : 1)),
|
|
223
|
+
"contexts": [0, 1, 2].slice(0, (cmd.user ? 3 : 2)),
|
|
224
|
+
}));
|
|
225
|
+
}
|
|
187
226
|
}
|
|
188
227
|
if (this.options.slashListener) {
|
|
189
228
|
this.client.rest.put(`/applications/${this.client.application.id}/commands`, {
|
|
190
|
-
"body":
|
|
229
|
+
"body": gcmds
|
|
230
|
+
});
|
|
231
|
+
Object.keys(scmds).forEach(id => {
|
|
232
|
+
this.client.rest.put(`/applications/${this.client.application.id}/guilds/${id}/commands`, {
|
|
233
|
+
"body": scmds[id]
|
|
234
|
+
});
|
|
191
235
|
});
|
|
192
236
|
}
|
|
193
237
|
this.emit("running", { Discord });
|