xernerx 3.3.6 → 3.4.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 (79) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +21 -21
  3. package/dist/build/ContextCommandBuilder.d.ts +6 -4
  4. package/dist/build/ContextCommandBuilder.js +8 -4
  5. package/dist/build/EventBuilder.d.ts +2 -2
  6. package/dist/build/EventBuilder.js +4 -4
  7. package/dist/build/InhibitorBuilder.d.ts +4 -3
  8. package/dist/build/InhibitorBuilder.js +2 -2
  9. package/dist/build/MessageCommandBuilder.d.ts +1 -1
  10. package/dist/build/MessageCommandBuilder.js +2 -2
  11. package/dist/build/SlashCommandBuilder.d.ts +7 -3
  12. package/dist/build/SlashCommandBuilder.js +21 -13
  13. package/dist/build/{ContextCommand.d.ts → XContextCommandBuilder.d.ts} +5 -5
  14. package/dist/build/{ContextCommand.js → XContextCommandBuilder.js} +5 -5
  15. package/dist/build/{Event.d.ts → XEventBuilder.d.ts} +3 -3
  16. package/dist/build/{Event.js → XEventBuilder.js} +5 -5
  17. package/dist/build/XInhibitorBuilder.d.ts +20 -0
  18. package/dist/build/{Inhibitor.js → XInhibitorBuilder.js} +4 -4
  19. package/dist/build/{MessageCommand.d.ts → XMessageCommandBuilder.d.ts} +8 -7
  20. package/dist/build/{MessageCommand.js → XMessageCommandBuilder.js} +9 -11
  21. package/dist/build/{SlashCommand.d.ts → XSlashCommandBuilder.d.ts} +4 -4
  22. package/dist/build/{SlashCommand.js → XSlashCommandBuilder.js} +13 -24
  23. package/dist/client/XernerxClient.d.ts +1 -1
  24. package/dist/client/XernerxClient.js +1 -2
  25. package/dist/handlers/CommandHandler.d.ts +4 -5
  26. package/dist/handlers/CommandHandler.js +2 -2
  27. package/dist/handlers/EventHandler.d.ts +4 -5
  28. package/dist/handlers/EventHandler.js +1 -1
  29. package/dist/handlers/Handler.d.ts +25 -6
  30. package/dist/handlers/Handler.js +41 -36
  31. package/dist/handlers/InhibitorHandler.d.ts +2 -3
  32. package/dist/main.d.ts +5 -71
  33. package/dist/main.js +7 -12
  34. package/dist/models/CommandArguments.d.ts +2 -2
  35. package/dist/models/CommandArguments.js +4 -2
  36. package/dist/models/CommandValidations.d.ts +3 -3
  37. package/dist/models/CommandValidations.js +26 -28
  38. package/dist/models/Events.d.ts +5 -5
  39. package/dist/models/Events.js +77 -30
  40. package/dist/models/Extensions.d.ts +4 -3
  41. package/dist/models/Extensions.js +5 -3
  42. package/dist/tools/package.d.ts +38 -0
  43. package/dist/tools/package.js +37 -0
  44. package/dist/types/enums.js +4 -4
  45. package/dist/types/options.d.ts +3 -2
  46. package/dist/types/{Types.d.ts → types.d.ts} +0 -0
  47. package/dist/{interfaces/ClientInterfaces.js → types/types.js} +0 -0
  48. package/dist/utils/ClientUtil.d.ts +1 -1
  49. package/dist/utils/ClientUtil.js +0 -11
  50. package/dist/utils/CommandUtil.d.ts +12 -6
  51. package/dist/utils/CommandUtil.js +26 -14
  52. package/dist/validators/CommandValidations.d.ts +7 -0
  53. package/dist/validators/CommandValidations.js +185 -0
  54. package/dist/validators/InhibitorValidations.d.ts +11 -0
  55. package/dist/validators/InhibitorValidations.js +42 -0
  56. package/package.json +7 -6
  57. package/dist/build/ExtensionBuilder.d.ts +0 -7
  58. package/dist/build/ExtensionBuilder.js +0 -9
  59. package/dist/build/Inhibitor.d.ts +0 -18
  60. package/dist/build/XernerxExtension.d.ts +0 -7
  61. package/dist/build/XernerxExtension.js +0 -9
  62. package/dist/handlers/WebhookHandler.d.ts +0 -12
  63. package/dist/handlers/WebhookHandler.js +0 -36
  64. package/dist/interfaces/ClientInterfaces.d.ts +0 -65
  65. package/dist/interfaces/CommandInterfaces.d.ts +0 -94
  66. package/dist/interfaces/CommandInterfaces.js +0 -1
  67. package/dist/interfaces/HandlerInterfaces.d.ts +0 -62
  68. package/dist/interfaces/HandlerInterfaces.js +0 -1
  69. package/dist/models/Functions.d.ts +0 -1
  70. package/dist/models/Functions.js +0 -1
  71. package/dist/types/EventTypes.d.ts +0 -1
  72. package/dist/types/EventTypes.js +0 -1
  73. package/dist/types/InhibitorTypes.d.ts +0 -12
  74. package/dist/types/InhibitorTypes.js +0 -13
  75. package/dist/types/Types.js +0 -1
  76. package/dist/types/objects.d.ts +0 -18
  77. package/dist/types/objects.js +0 -1
  78. package/scripts/package.d.ts +0 -1
  79. package/scripts/package.js +0 -3
@@ -1,4 +1,4 @@
1
- import { ActionRowBuilder, ButtonBuilder, ButtonStyle, EmbedBuilder, StringSelectMenuBuilder } from 'discord.js';
1
+ import { ActionRowBuilder, ButtonBuilder, ButtonStyle, EmbedBuilder, StringSelectMenuBuilder, } from 'discord.js';
2
2
  import XernerxError from '../tools/XernerxError.js';
3
3
  export class MessageCommandUtil {
4
4
  client;
@@ -77,14 +77,14 @@ export class MessageCommandUtil {
77
77
  getCommands() {
78
78
  return this.client.commands.message;
79
79
  }
80
- #getCommandName() { }
81
- #selectMenuPaginator(embeds, options) { }
82
- #buttonPaginator(embeds, options) { }
83
- #buttonMenuPaginator(embeds, options) { }
80
+ getCommandName() { }
81
+ selectMenuPaginator(embeds, options) { }
82
+ buttonPaginator(embeds, options) { }
83
+ buttonMenuPaginator(embeds, options) { }
84
84
  isOwner() {
85
85
  return this.client.util.isOwner(this.message.author.id);
86
86
  }
87
- #createModal() { }
87
+ createModal() { }
88
88
  }
89
89
  export class InteractionCommandUtil {
90
90
  client;
@@ -94,7 +94,9 @@ export class InteractionCommandUtil {
94
94
  this.interaction = interaction;
95
95
  }
96
96
  reply(content) {
97
- return this.interaction.replied || this.interaction.deferred ? this.interaction.editReply(content) : this.interaction.reply(content);
97
+ return this.interaction.replied || this.interaction.deferred
98
+ ? this.interaction.editReply(content)
99
+ : this.interaction.reply(content);
98
100
  }
99
101
  async defer(time) {
100
102
  return new Promise((resolve) => setTimeout(resolve, time));
@@ -105,7 +107,7 @@ export class InteractionCommandUtil {
105
107
  else
106
108
  return this.client.commands.context;
107
109
  }
108
- #getCommandName() { }
110
+ getCommandName() { }
109
111
  selectMenuPaginator(embeds, options) {
110
112
  if (!Array.isArray(embeds))
111
113
  throw new XernerxError(`Expected embeds to be of type array, received ${typeof embeds} instead.`);
@@ -131,7 +133,12 @@ export class InteractionCommandUtil {
131
133
  options.row = new ActionRowBuilder();
132
134
  if (!options.id)
133
135
  options.id = `${this.interaction.id}-menu`;
134
- options.component = new StringSelectMenuBuilder().setCustomId(options.id).setMaxValues(1).setMinValues(1).setPlaceholder('Select a page.').addOptions({ label: 'index', value: '0' });
136
+ options.component = new StringSelectMenuBuilder()
137
+ .setCustomId(options.id)
138
+ .setMaxValues(1)
139
+ .setMinValues(1)
140
+ .setPlaceholder('Select a page.')
141
+ .addOptions({ label: 'index', value: '0' });
135
142
  embeds.map((embed, i = 0) => {
136
143
  options?.component?.addOptions({
137
144
  label: embed.data.title || 'No Name',
@@ -147,7 +154,9 @@ export class InteractionCommandUtil {
147
154
  components: [options.row, ...options.components],
148
155
  ephemeral: !!options.ephemeral,
149
156
  };
150
- (options.reply === undefined || options.reply === true ? this.interaction.util.reply(content) : this.interaction.channel.send(content)).then(() => {
157
+ (options.reply === undefined || options.reply === true
158
+ ? this.interaction.util.reply(content)
159
+ : this.interaction.channel.send(content)).then(() => {
151
160
  const collector = this.interaction.channel
152
161
  .createMessageComponentCollector({
153
162
  filter: options?.filter,
@@ -193,7 +202,9 @@ export class InteractionCommandUtil {
193
202
  components: [options.row, ...options.components],
194
203
  ephemeral: !!options.ephemeral,
195
204
  };
196
- (options.reply === undefined || options.reply === true ? this.interaction.util.reply(content) : this.interaction.channel.send(content)).then((message) => {
205
+ (options.reply === undefined || options.reply === true
206
+ ? this.interaction.util.reply(content)
207
+ : this.interaction.channel.send(content)).then((message) => {
197
208
  const collector = message.channel
198
209
  .createMessageComponentCollector({
199
210
  filter: options.filter,
@@ -217,7 +228,8 @@ export class InteractionCommandUtil {
217
228
  break;
218
229
  }
219
230
  case 3: {
220
- embed = embeds[embeds.indexOf(embed) < embeds.length - 1 ? embeds.indexOf(embed) + 1 : embeds.length - 1];
231
+ embed =
232
+ embeds[embeds.indexOf(embed) < embeds.length - 1 ? embeds.indexOf(embed) + 1 : embeds.length - 1];
221
233
  break;
222
234
  }
223
235
  case 4: {
@@ -240,9 +252,9 @@ export class InteractionCommandUtil {
240
252
  });
241
253
  });
242
254
  }
243
- #buttonMenuPaginator(embeds, options) { }
255
+ buttonMenuPaginator(embeds, options) { }
244
256
  isOwner() {
245
257
  return this.client.util.isOwner(this.interaction.user.id);
246
258
  }
247
- #createModal() { }
259
+ createModal() { }
248
260
  }
@@ -0,0 +1,7 @@
1
+ import { Interaction } from 'discord.js';
2
+ import ContextCommandBuilder from '../build/ContextCommandBuilder.js';
3
+ import MessageCommandBuilder from '../build/MessageCommandBuilder.js';
4
+ import SlashCommandBuilder from '../build/SlashCommandBuilder.js';
5
+ import XernerxClient from '../client/XernerxClient.js';
6
+ import { XernerxMessage } from '../types/types.js';
7
+ export default function commandValidation(action: XernerxMessage | Interaction, command: SlashCommandBuilder | MessageCommandBuilder | ContextCommandBuilder | any, client: XernerxClient, res?: boolean): boolean;
@@ -0,0 +1,185 @@
1
+ import { Message } from 'discord.js';
2
+ import { CommandType } from '../types/enums.js';
3
+ function getUser(from) {
4
+ if (from instanceof Message)
5
+ return from.author;
6
+ else
7
+ return from.user;
8
+ }
9
+ export default function commandValidation(action, command, client, res = false) {
10
+ let user = getUser(action);
11
+ if ((command.ignoreOwner || client.settings.ignoreOwner) && client.util.isOwner(user.id))
12
+ return res;
13
+ else if (inCooldown(user, client, command, action))
14
+ return true;
15
+ else if (command.owner && !client.util.isOwner(user.id)) {
16
+ res = true;
17
+ emit(client, action, command, 'Not an owner', client.settings.ownerId);
18
+ }
19
+ else if (command.channelType?.length > 0 || command.channelType) {
20
+ if (!Array.isArray(command.channelType))
21
+ command.channelType = [command.channelType];
22
+ if (!command?.channelType?.includes(action.channel?.type)) {
23
+ res = true;
24
+ emit(client, action, command, 'Not the correct channel', command.channelType);
25
+ }
26
+ }
27
+ else if (command.channels?.length > 0 && !command.channels.includes(action.channel?.id)) {
28
+ res = true;
29
+ emit(client, action, command, 'Not a whitelisted channel', command.channels);
30
+ }
31
+ else if (command.guilds?.length > 0 && !command.guilds.includes(action.guild?.id)) {
32
+ res = true;
33
+ emit(client, action, command, 'Not a whitelisted guild', command.guilds);
34
+ }
35
+ else if (command.channelType && command.channelType !== action.channel?.type) {
36
+ res = true;
37
+ emit(client, action, command, 'Not the correct type of channel', command.channelType);
38
+ }
39
+ else if (action?.guild && (command.userPermissions || client.settings.userPermissions)) {
40
+ const permissions = command.userPermissions ||
41
+ client?.settings?.userPermissions?.push(...handlerPermissions(client, command.commandType, 'user')), missing = [];
42
+ if (Array.isArray(permissions))
43
+ permissions.map((permission) => {
44
+ if (!(action.member?.permissions).has(permission)) {
45
+ missing.push(permission);
46
+ }
47
+ });
48
+ if (missing.length > 0) {
49
+ res = true;
50
+ emit(client, action, command, 'Missing User Permissions', missing);
51
+ }
52
+ }
53
+ else if (action?.guild && (command.clientPermissions || client.settings.clientPermissions)) {
54
+ const permissions = command.clientPermissions ||
55
+ client?.settings?.clientPermissions?.push(...handlerPermissions(client, command.commandType, 'client')), missing = [];
56
+ if (Array.isArray(permissions))
57
+ permissions.map((permission) => {
58
+ if (!(action.member?.permissions).has(permission)) {
59
+ missing.push(permission);
60
+ }
61
+ });
62
+ if (missing.length > 0) {
63
+ res = true;
64
+ emit(client, action, command, 'Missing Client Permissions', missing);
65
+ }
66
+ }
67
+ return res;
68
+ }
69
+ function emit(client, action, command, reason, extra) {
70
+ return client.emit('commandBlock', action, command, reason, extra);
71
+ }
72
+ function inCooldown(user, client, command, action) {
73
+ let res = false, downs = {};
74
+ const { cooldowns, messageCommands, slashCommands, contextCommands, commands } = client.cache;
75
+ if (command.commandType === CommandType.MessageCommand && client.handlerOptions.message.cooldown) {
76
+ if (messageCommands.has(user.id)) {
77
+ const usr = messageCommands.get(user.id);
78
+ usr.timeRemaining = usr.endsAt - Date.now();
79
+ downs.message = usr;
80
+ res = true;
81
+ }
82
+ if (!messageCommands.has(user.id)) {
83
+ messageCommands.set(user.id, toCooldown(action, command, client.handlerOptions.message.cooldown, user.id));
84
+ setInterval(() => {
85
+ messageCommands.delete(user.id);
86
+ }, client.handlerOptions.message.cooldown);
87
+ }
88
+ }
89
+ if (command.commandType === CommandType.SlashCommand && client.handlerOptions.slash.cooldown) {
90
+ if (slashCommands.has(user.id)) {
91
+ const usr = slashCommands.get(user.id);
92
+ usr.timeRemaining = usr.endsAt - Date.now();
93
+ downs.slash = usr;
94
+ res = true;
95
+ }
96
+ if (!slashCommands.has(user.id)) {
97
+ slashCommands.set(user.id, toCooldown(action, command, client.handlerOptions.slash.cooldown, user.id));
98
+ setInterval(() => {
99
+ slashCommands.delete(user.id);
100
+ }, client.handlerOptions.slash.cooldown);
101
+ }
102
+ }
103
+ if (command.commandType === CommandType.ContextCommand && client.handlerOptions.context.cooldown) {
104
+ if (contextCommands.has(user.id)) {
105
+ const usr = contextCommands.get(user.id);
106
+ usr.timeRemaining = usr.endsAt - Date.now();
107
+ downs.context = usr;
108
+ res = true;
109
+ }
110
+ if (!contextCommands.has(user.id)) {
111
+ contextCommands.set(user.id, toCooldown(action, command, client.handlerOptions.context.cooldown, user.id));
112
+ setInterval(() => {
113
+ contextCommands.delete(user.id);
114
+ }, client.handlerOptions.context.cooldown);
115
+ }
116
+ }
117
+ if (client.settings?.cooldown?.default) {
118
+ if (cooldowns.has(user.id)) {
119
+ const usr = cooldowns.get(user.id);
120
+ usr.timeRemaining = usr.endsAt - Date.now();
121
+ downs.default = usr;
122
+ res = true;
123
+ }
124
+ if (!cooldowns.has(user.id)) {
125
+ cooldowns.set(user.id, toCooldown(action, command, client.settings.cooldown.default, user.id));
126
+ setInterval(() => {
127
+ cooldowns.delete(user.id);
128
+ }, client.settings.cooldown.default);
129
+ }
130
+ }
131
+ if (command.cooldown) {
132
+ const name = user.id + '-' + (command.data?.name || command?.name) + '-' + command.commandType;
133
+ if (commands.has(name)) {
134
+ const usr = commands.get(name);
135
+ usr.timeRemaining = usr.endsAt - Date.now();
136
+ downs.command = usr;
137
+ res = true;
138
+ }
139
+ if (!commands.has(name)) {
140
+ commands.set(name, toCooldown(action, command, command.cooldown, name));
141
+ setInterval(() => {
142
+ commands.delete(name);
143
+ }, command.cooldown);
144
+ }
145
+ }
146
+ if (Object.keys(downs).length > 0)
147
+ client.emit('commandCooldown', action, command, downs);
148
+ return res;
149
+ }
150
+ function toCooldown(action, command, cooldown, name) {
151
+ let user = getUser(action);
152
+ return {
153
+ name,
154
+ id: user.id,
155
+ tag: user.tag,
156
+ commandType: command.commandType,
157
+ commandName: command?.data?.name || command?.name,
158
+ guildId: action?.guild?.id,
159
+ channelId: action?.channel?.id,
160
+ startsAt: Number(Date.now()),
161
+ endsAt: Number(Date.now()) + cooldown,
162
+ };
163
+ }
164
+ function handlerPermissions(client, commandType, type) {
165
+ let permissions = [];
166
+ if (commandType === CommandType.MessageCommand) {
167
+ if (type === 'user')
168
+ permissions = client.handlerOptions.message?.userPermissions || [];
169
+ else if (type === 'client')
170
+ permissions = client.handlerOptions.message?.clientPermissions || [];
171
+ }
172
+ else if (commandType === CommandType.SlashCommand) {
173
+ if (type === 'user')
174
+ permissions = client.handlerOptions.slash?.userPermissions || [];
175
+ else if (type === 'client')
176
+ permissions = client.handlerOptions.slash?.clientPermissions || [];
177
+ }
178
+ else if (commandType === CommandType.ContextCommand) {
179
+ if (type === 'user')
180
+ permissions = client.handlerOptions.context?.userPermissions || [];
181
+ else if (type === 'client')
182
+ permissions = client.handlerOptions.context?.clientPermissions || [];
183
+ }
184
+ return permissions;
185
+ }
@@ -0,0 +1,11 @@
1
+ import XernerxClient from '../client/XernerxClient.js';
2
+ import { XernerxInteraction, XernerxMessage } from '../types/types.js';
3
+ export declare class InhibitorValidation {
4
+ private client;
5
+ private action;
6
+ private command;
7
+ private inhibited;
8
+ constructor(client: XernerxClient, action: XernerxMessage | XernerxInteraction, command: string);
9
+ inhibit(): Promise<Record<string, string | void> | undefined>;
10
+ private args;
11
+ }
@@ -0,0 +1,42 @@
1
+ import { InhibitorType } from '../types/enums.js';
2
+ export class InhibitorValidation {
3
+ client;
4
+ action;
5
+ command;
6
+ inhibited;
7
+ constructor(client, action, command) {
8
+ this.client = client;
9
+ this.action = action;
10
+ this.command = command;
11
+ this.inhibited = {};
12
+ }
13
+ async inhibit() {
14
+ for (const inhibitor of this.client.inhibitors) {
15
+ const inhibit = inhibitor[1];
16
+ if (inhibit)
17
+ this.inhibited[inhibit.name] = await inhibit.check(this.action, this.args(this.action, inhibit.type));
18
+ }
19
+ for (const inhibit of Object.values(this.inhibited)) {
20
+ if (inhibit)
21
+ return this.inhibited;
22
+ }
23
+ }
24
+ args(action, type) {
25
+ if (type === InhibitorType.Channel)
26
+ return action.channel;
27
+ if (type === InhibitorType.User)
28
+ return action.author || action.user;
29
+ if (type === InhibitorType.Guild)
30
+ return action.guild;
31
+ if (type === InhibitorType.Member)
32
+ return action.member;
33
+ // if (type === InhibitorType.Command)
34
+ // return this.client.util.getAllCommands().filter(this.command.name);
35
+ // if (type === InhibitorType.MessageCommand)
36
+ // return this.client.util.getAllMessageCommands().find(this.command.name);
37
+ // if (type === InhibitorType.SlashCommand)
38
+ // return this.client.util.getAllSlashCommands().find(this.command.name);
39
+ // if (type === InhibitorType.ContextCommand)
40
+ // return this.client.util.getAllContextCommands().find(this.command.name);
41
+ }
42
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xernerx",
3
- "version": "3.3.6",
3
+ "version": "3.4.0",
4
4
  "type": "module",
5
5
  "description": "A bot framework for discord.js.",
6
6
  "main": "dist/main.js",
@@ -11,22 +11,23 @@
11
11
  ],
12
12
  "author": "Dummi",
13
13
  "license": "MIT",
14
- "homepage": "https://thedummi.github.io/xernerx/home.html",
14
+ "homepage": "https://xernerx.github.io/xernerx/home.html",
15
15
  "packageManager": "npm@8.5.5",
16
16
  "scripts": {
17
- "checks": "npm i && npm fund && npm audit fix --force && npm link && tsc -w",
17
+ "start": "npm i && npm fund && npm audit fix --force && npm link && npm run package && tsc -w",
18
18
  "patch": "git add . && npm run commit && npm version patch && npm publish && git push",
19
19
  "minor": "git add . && npm run commit && npm version minor && npm publish && git push",
20
20
  "major": "git add . && npm run commit && npm version major && npm publish && git push",
21
21
  "site": "git add docs && npm run commit && git push",
22
- "commit": "node scripts/commit.js"
22
+ "commit": "node ../.scripts/commit.js",
23
+ "package": "node ../.scripts/rewritePackage.js"
23
24
  },
24
25
  "repository": {
25
26
  "type": "git",
26
- "url": "git+https://github.com/TheDummi/xernerx.git"
27
+ "url": "git+https://github.com/xernerx/xernerx.git"
27
28
  },
28
29
  "bugs": {
29
- "url": "https://github.com/TheDummi/xernerx/issues"
30
+ "url": "https://github.com/xernerx/xernerx/issues"
30
31
  },
31
32
  "dependencies": {
32
33
  "@sapphire/shapeshift": "^3.8.1",
@@ -1,7 +0,0 @@
1
- /**
2
- * A class constructor you can use to make any extension work.
3
- */
4
- export default class ExtensionBuilder {
5
- name: string;
6
- constructor(name: string);
7
- }
@@ -1,9 +0,0 @@
1
- /**
2
- * A class constructor you can use to make any extension work.
3
- */
4
- export default class ExtensionBuilder {
5
- name;
6
- constructor(name) {
7
- this.name = name;
8
- }
9
- }
@@ -1,18 +0,0 @@
1
- import { InhibitorOptions } from "../interfaces/HandlerInterfaces.js";
2
- import { XernerxClient } from "../main.js";
3
- /**
4
- * @description - The inhibitor builder for inhibitors.
5
- * @param {String} id - The unique ID of the inhibitor.
6
- * @param {InhibitorOptions} options - The inhibitor options.
7
- */
8
- export declare class Inhibitor {
9
- id: string;
10
- name: string;
11
- type: string;
12
- client: XernerxClient | object;
13
- constructor(id: string, options: InhibitorOptions);
14
- /**
15
- *
16
- */
17
- check(): Promise<void>;
18
- }
@@ -1,7 +0,0 @@
1
- /**
2
- * A class constructor you can use to make any extension work.
3
- */
4
- export default class XernerxExtension {
5
- name: string;
6
- constructor(name: string);
7
- }
@@ -1,9 +0,0 @@
1
- /**
2
- * A class constructor you can use to make any extension work.
3
- */
4
- export default class XernerxExtension {
5
- name;
6
- constructor(name) {
7
- this.name = name;
8
- }
9
- }
@@ -1,12 +0,0 @@
1
- import { XernerxClient } from "../main.js";
2
- interface WebhookOptions {
3
- token: string;
4
- logging: boolean;
5
- }
6
- export default class WebhookHandler {
7
- client: XernerxClient;
8
- constructor(client: XernerxClient);
9
- post(options: WebhookOptions): import("topgg-autoposter/dist/structs/BasePoster.js").BasePoster;
10
- vote(options: WebhookOptions): void;
11
- }
12
- export {};
@@ -1,36 +0,0 @@
1
- "use strict";
2
- import { AutoPoster } from 'topgg-autoposter';
3
- import SDK from '@top-gg/sdk';
4
- import { Style } from 'dumfunctions';
5
- import express from 'express';
6
- export default class WebhookHandler {
7
- client;
8
- constructor(client) {
9
- this.client = client;
10
- this.vote = this.vote;
11
- this.post = this.post;
12
- }
13
- post(options) {
14
- const auto = AutoPoster(options.token, this.client);
15
- auto
16
- .on('posted', post => {
17
- if (options.logging)
18
- console.info(Style.log(`Xernerx | Successfully posted bot stats to Top.gg!`, { color: Style.TextColor.Cyan }));
19
- return this.client.emit('webhookPost', post);
20
- })
21
- .on('error', error => {
22
- if (options.logging)
23
- console.info(Style.log(`Xernerx | An error occurred while posting stats to Top.gg, ${error}.`, { color: Style.BackgroundColor.Red }));
24
- return this.client.emit('webhookError', error);
25
- });
26
- return auto;
27
- }
28
- vote(options) {
29
- const app = express();
30
- const webhook = new SDK.Webhook(options.token);
31
- app.post("/dblwebhook", webhook.listener(vote => {
32
- console.log(vote);
33
- }));
34
- app.listen(80);
35
- }
36
- }
@@ -1,65 +0,0 @@
1
- import { CacheFactory, Collection, MessageMentionOptions, Partials, PresenceData, RESTOptions, SweeperOptions, WebSocketOptions } from "discord.js";
2
- import CommandHandler from "../handlers/CommandHandler.js";
3
- import EventHandler from "../handlers/EventHandler.js";
4
- import InhibitorHandler from "../handlers/InhibitorHandler.js";
5
- import { ContextCommandOptions, MessageCommandOptions, SlashCommandOptions, EventLoadOptions, InhibitorLoadOptions } from "./HandlerInterfaces.js";
6
- import MessageCommandBuilder from "../build/MessageCommandBuilder.js";
7
- import ContextCommandBuilder from "../build/ContextCommandBuilder.js";
8
- import SlashCommandBuilder from "../build/SlashCommandBuilder.js";
9
- import ExtensionBuilder from "../build/ExtensionBuilder.js";
10
- export interface DiscordOptions {
11
- shards?: number | number[] | "auto";
12
- closeTimeout?: number;
13
- shardCount?: number;
14
- makeCache?: CacheFactory;
15
- allowedMentions?: MessageMentionOptions;
16
- partials?: Array<Partials>;
17
- failIfNotExists?: boolean;
18
- presence?: PresenceData;
19
- intents: number[];
20
- waitGuildTimeout?: number;
21
- sweepers?: SweeperOptions;
22
- ws?: WebSocketOptions;
23
- rest?: RESTOptions;
24
- jsonTransformer?: (obj: unknown) => unknown;
25
- }
26
- export interface ClientOptions {
27
- ownerId?: string | string[];
28
- clientPermissions?: bigint[];
29
- userPermissions?: bigint[];
30
- ignoreOwner?: boolean;
31
- logging?: boolean;
32
- cooldown?: {
33
- default?: number;
34
- cache?: number;
35
- };
36
- }
37
- export interface HandlerOptions {
38
- message?: MessageCommandOptions;
39
- slash?: SlashCommandOptions;
40
- context?: ContextCommandOptions;
41
- events?: EventLoadOptions;
42
- inhibitors?: InhibitorLoadOptions;
43
- }
44
- export interface Commands {
45
- message: Collection<string, MessageCommandBuilder>;
46
- slash: Collection<string, SlashCommandBuilder>;
47
- context: Collection<string, ContextCommandBuilder>;
48
- }
49
- export interface Cache {
50
- messages: Collection<string, object>;
51
- cooldowns: Collection<string, object>;
52
- messageCommands: Collection<string, object>;
53
- slashCommands: Collection<string, object>;
54
- contextCommands: Collection<string, object>;
55
- commands: Collection<string, object>;
56
- }
57
- export interface Modules {
58
- commandHandler: CommandHandler;
59
- eventHandler: EventHandler;
60
- inhibitorHandler: InhibitorHandler;
61
- }
62
- export interface ExtensionOptions {
63
- extensions: Array<ExtensionBuilder>;
64
- logging?: boolean;
65
- }
@@ -1,94 +0,0 @@
1
- import { ChannelType, ContextMenuCommandType } from "discord.js";
2
- import { ContextCommandType } from "../types/enums.js";
3
- export interface MessageCommandOptions {
4
- name: string;
5
- regex?: string;
6
- aliases?: string[];
7
- description?: string;
8
- prefix?: string | string[];
9
- info?: string;
10
- category?: string;
11
- owner?: boolean;
12
- channelType?: ChannelType | ChannelType[];
13
- separator?: string;
14
- cooldown?: number;
15
- ignoreOwner?: boolean;
16
- channels?: string[];
17
- guilds?: string[];
18
- userPermissions?: bigint[];
19
- clientPermissions?: bigint[];
20
- commandType?: string;
21
- args: object[];
22
- }
23
- export interface ContextCommandOptions {
24
- name: string;
25
- type: ContextMenuCommandType | number | ContextCommandType;
26
- description?: string;
27
- info?: string;
28
- category?: string;
29
- owner?: boolean;
30
- channelType?: ChannelType;
31
- cooldown?: number;
32
- ignoreOwner?: boolean;
33
- channels?: string[];
34
- guilds?: string[];
35
- userPermissions?: bigint[];
36
- clientPermissions?: bigint[];
37
- defaultMemberPermissions?: bigint | number | bigint | null | undefined;
38
- DMPermission?: undefined | null | boolean;
39
- nameLocalization?: {
40
- locale: "en-US" | "en-GB" | "bg" | "zh-CN" | "zh-TW" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "es-ES" | "sv-SE" | "th" | "tr" | "uk" | "vi";
41
- localizedName: null | string;
42
- };
43
- nameLocalizations?: null | Partial<Record<"en-US" | "en-GB" | "bg" | "zh-CN" | "zh-TW" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "es-ES" | "sv-SE" | "th" | "tr" | "uk" | "vi", null | string>>;
44
- commandType?: string;
45
- defer?: {
46
- reply?: boolean;
47
- ephemeral?: boolean;
48
- fetchReply?: boolean;
49
- };
50
- }
51
- export interface SlashArg {
52
- type: "string" | "number" | "boolean" | "user" | "channel" | "role" | "mentionable" | "integer";
53
- name: string;
54
- choices: Array<{
55
- name: string;
56
- value: string;
57
- }>;
58
- required: boolean;
59
- description: string;
60
- }
61
- export interface SlashSubcommand {
62
- name: string;
63
- description: string;
64
- args: Array<SlashArg>;
65
- }
66
- export interface SlashGroup {
67
- name: string;
68
- description: string;
69
- subcommands: Array<SlashSubcommand>;
70
- }
71
- export interface SlashCommandOptions {
72
- name: string;
73
- description: string;
74
- info?: string;
75
- category?: string;
76
- owner?: boolean;
77
- channelType?: ChannelType;
78
- separator?: string;
79
- cooldown?: number;
80
- ignoreOwner?: boolean;
81
- channels?: string[];
82
- guilds?: string[];
83
- userPermissions?: bigint[];
84
- clientPermissions?: bigint[];
85
- args?: Array<SlashArg>;
86
- subcommands?: Array<SlashSubcommand>;
87
- groups?: Array<SlashGroup>;
88
- commandType?: string;
89
- defer?: {
90
- reply?: boolean;
91
- ephemeral?: boolean;
92
- fetchReply?: boolean;
93
- };
94
- }
@@ -1 +0,0 @@
1
- export {};