xernerx 4.5.6 → 4.5.7
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/dist/build/XernerxContextCommand.d.ts +46 -44
- package/dist/build/XernerxContextCommand.js +64 -62
- package/dist/build/XernerxEvent.d.ts +16 -14
- package/dist/build/XernerxEvent.js +21 -19
- package/dist/build/XernerxInhibitor.d.ts +19 -17
- package/dist/build/XernerxInhibitor.js +13 -11
- package/dist/build/XernerxMessageCommand.d.ts +44 -42
- package/dist/build/XernerxMessageCommand.js +58 -56
- package/dist/build/XernerxSlashCommand.d.ts +56 -54
- package/dist/build/XernerxSlashCommand.js +110 -108
- package/dist/client/XernerxClient.d.ts +46 -44
- package/dist/client/XernerxClient.js +75 -73
- package/dist/client/XernerxShardClient.d.ts +12 -10
- package/dist/client/XernerxShardClient.js +50 -48
- package/dist/functions/deploy.d.ts +2 -0
- package/dist/functions/deploy.js +32 -30
- package/dist/functions/load.d.ts +2 -0
- package/dist/functions/load.js +29 -27
- package/dist/functions/reload.d.ts +2 -0
- package/dist/functions/reload.js +36 -34
- package/dist/functions/sendWebhook.d.ts +2 -0
- package/dist/functions/sendWebhook.js +12 -10
- package/dist/functions/setPresence.d.ts +2 -0
- package/dist/functions/setPresence.js +19 -17
- package/dist/functions/xernerxUser.d.ts +2 -0
- package/dist/functions/xernerxUser.js +10 -8
- package/dist/handlers/CommandHandler.d.ts +10 -8
- package/dist/handlers/CommandHandler.js +241 -239
- package/dist/handlers/EventHandler.d.ts +4 -2
- package/dist/handlers/EventHandler.js +20 -18
- package/dist/handlers/ExtensionHandler.d.ts +4 -2
- package/dist/handlers/ExtensionHandler.js +19 -17
- package/dist/handlers/Handler.d.ts +9 -7
- package/dist/handlers/Handler.js +33 -31
- package/dist/handlers/InhibitorHandler.d.ts +4 -2
- package/dist/handlers/InhibitorHandler.js +20 -18
- package/dist/handlers/WebhookHandler.d.ts +5 -3
- package/dist/handlers/WebhookHandler.js +48 -46
- package/dist/main.d.ts +28 -26
- package/dist/main.js +28 -26
- package/dist/models/Arguments.d.ts +4 -2
- package/dist/models/Arguments.js +136 -134
- package/dist/tools/XernerxError.d.ts +6 -4
- package/dist/tools/XernerxError.js +10 -8
- package/dist/tools/XernerxLog.d.ts +14 -12
- package/dist/tools/XernerxLog.js +77 -80
- package/dist/types/extenders.d.ts +13 -11
- package/dist/types/extenders.js +2 -0
- package/dist/types/interfaces.d.ts +184 -172
- package/dist/types/interfaces.d.ts.map +1 -1
- package/dist/types/interfaces.js +2 -0
- package/dist/types/interfaces.js.map +1 -1
- package/dist/types/types.d.ts +173 -171
- package/dist/types/types.js +2 -0
- package/dist/utils/ClientUtil.d.ts +8 -5
- package/dist/utils/ClientUtil.d.ts.map +1 -1
- package/dist/utils/ClientUtil.js +45 -26
- package/dist/utils/ClientUtil.js.map +1 -1
- package/dist/utils/InteractionUtil.d.ts +11 -5
- package/dist/utils/InteractionUtil.d.ts.map +1 -1
- package/dist/utils/InteractionUtil.js +98 -8
- package/dist/utils/InteractionUtil.js.map +1 -1
- package/dist/utils/MessageUtil.d.ts +14 -9
- package/dist/utils/MessageUtil.d.ts.map +1 -1
- package/dist/utils/MessageUtil.js +131 -37
- package/dist/utils/MessageUtil.js.map +1 -1
- package/dist/utils/Util.d.ts +5 -3
- package/dist/utils/Util.js +9 -7
- package/dist/validators/commandValidation.d.ts +4 -2
- package/dist/validators/commandValidation.js +44 -42
- package/dist/validators/inhibitorValidations.d.ts +16 -14
- package/dist/validators/inhibitorValidations.js +32 -30
- package/package.json +1 -1
package/dist/types/types.d.ts
CHANGED
|
@@ -1,186 +1,188 @@
|
|
|
1
|
+
/** @format */
|
|
2
|
+
|
|
1
3
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
SlashCommandBooleanOption,
|
|
5
|
+
SlashCommandChannelOption,
|
|
6
|
+
SlashCommandIntegerOption,
|
|
7
|
+
SlashCommandMentionableOption,
|
|
8
|
+
SlashCommandNumberOption,
|
|
9
|
+
SlashCommandRoleOption,
|
|
10
|
+
SlashCommandStringOption,
|
|
11
|
+
SlashCommandUserOption,
|
|
10
12
|
} from 'discord.js';
|
|
11
13
|
import { XernerxMessageContextInteraction, XernerxSlashInteraction, XernerxUserContextInteraction } from './extenders.js';
|
|
12
14
|
export type FileType = 'MessageCommand' | 'SlashCommand' | 'ContextCommand' | 'Event' | 'Inhibitor';
|
|
13
15
|
export type Locales =
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
16
|
+
| 'en-US'
|
|
17
|
+
| 'en-GB'
|
|
18
|
+
| 'bg'
|
|
19
|
+
| 'zh-CN'
|
|
20
|
+
| 'zh-TW'
|
|
21
|
+
| 'hr'
|
|
22
|
+
| 'cs'
|
|
23
|
+
| 'da'
|
|
24
|
+
| 'nl'
|
|
25
|
+
| 'fi'
|
|
26
|
+
| 'fr'
|
|
27
|
+
| 'de'
|
|
28
|
+
| 'el'
|
|
29
|
+
| 'hi'
|
|
30
|
+
| 'hu'
|
|
31
|
+
| 'it'
|
|
32
|
+
| 'ja'
|
|
33
|
+
| 'ko'
|
|
34
|
+
| 'lt'
|
|
35
|
+
| 'no'
|
|
36
|
+
| 'pl'
|
|
37
|
+
| 'pt-BR'
|
|
38
|
+
| 'ro'
|
|
39
|
+
| 'ru'
|
|
40
|
+
| 'es-ES'
|
|
41
|
+
| 'sv-SE'
|
|
42
|
+
| 'th'
|
|
43
|
+
| 'tr'
|
|
44
|
+
| 'uk'
|
|
45
|
+
| 'vi';
|
|
44
46
|
export type SlashCommandArgumentType = 'attachment' | 'boolean' | 'channel' | 'integer' | 'mentionable' | 'number' | 'role' | 'string' | 'user';
|
|
45
47
|
export type SlashCommandOptionChoices = SlashCommandStringOption | SlashCommandNumberOption | SlashCommandIntegerOption;
|
|
46
48
|
export type SlashCommandOption = SlashCommandOptionChoices | SlashCommandBooleanOption | SlashCommandUserOption | SlashCommandChannelOption | SlashCommandRoleOption | SlashCommandMentionableOption;
|
|
47
49
|
export type MessageCommandArgumentType =
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
50
|
+
| 'string'
|
|
51
|
+
| 'number'
|
|
52
|
+
| 'boolean'
|
|
53
|
+
| 'confirm'
|
|
54
|
+
| 'channel'
|
|
55
|
+
| 'guild'
|
|
56
|
+
| 'integer'
|
|
57
|
+
| 'mentionable'
|
|
58
|
+
| 'role'
|
|
59
|
+
| 'user'
|
|
60
|
+
| 'message'
|
|
61
|
+
| 'member'
|
|
62
|
+
| 'list'
|
|
63
|
+
| 'option'
|
|
64
|
+
| 'rest';
|
|
63
65
|
export type DiscordEventType =
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
66
|
+
| 'applicationCommandPermissionsUpdate'
|
|
67
|
+
| 'autoModerationActionExecution'
|
|
68
|
+
| 'autoModerationRuleCreate'
|
|
69
|
+
| 'autoModerationRuleDelete'
|
|
70
|
+
| 'autoModerationRuleUpdate'
|
|
71
|
+
| 'ready'
|
|
72
|
+
| 'guildCreate'
|
|
73
|
+
| 'guildDelete'
|
|
74
|
+
| 'guildUpdate'
|
|
75
|
+
| 'guildUnavailable'
|
|
76
|
+
| 'guildMemberAdd'
|
|
77
|
+
| 'guildMemberRemove'
|
|
78
|
+
| 'guildMemberUpdate'
|
|
79
|
+
| 'guildMemberAvailable'
|
|
80
|
+
| 'guildMembersChunk'
|
|
81
|
+
| 'guildIntegrationsUpdate'
|
|
82
|
+
| 'roleCreate'
|
|
83
|
+
| 'roleDelete'
|
|
84
|
+
| 'inviteCreate'
|
|
85
|
+
| 'inviteDelete'
|
|
86
|
+
| 'roleUpdate'
|
|
87
|
+
| 'emojiCreate'
|
|
88
|
+
| 'emojiDelete'
|
|
89
|
+
| 'emojiUpdate'
|
|
90
|
+
| 'guildBanAdd'
|
|
91
|
+
| 'guildBanRemove'
|
|
92
|
+
| 'channelCreate'
|
|
93
|
+
| 'channelDelete'
|
|
94
|
+
| 'channelUpdate'
|
|
95
|
+
| 'channelPinsUpdate'
|
|
96
|
+
| 'messageCreate'
|
|
97
|
+
| 'messageDelete'
|
|
98
|
+
| 'messageUpdate'
|
|
99
|
+
| 'messageDeleteBulk'
|
|
100
|
+
| 'messageReactionAdd'
|
|
101
|
+
| 'messageReactionRemove'
|
|
102
|
+
| 'messageReactionRemoveAll'
|
|
103
|
+
| 'messageReactionRemoveEmoji'
|
|
104
|
+
| 'threadCreate'
|
|
105
|
+
| 'threadDelete'
|
|
106
|
+
| 'threadUpdate'
|
|
107
|
+
| 'threadListSync'
|
|
108
|
+
| 'threadMemberUpdate'
|
|
109
|
+
| 'threadMembersUpdate'
|
|
110
|
+
| 'userUpdate'
|
|
111
|
+
| 'presenceUpdate'
|
|
112
|
+
| 'voiceServerUpdate'
|
|
113
|
+
| 'voiceStateUpdate'
|
|
114
|
+
| 'typingStart'
|
|
115
|
+
| 'webhookUpdate'
|
|
116
|
+
| 'interactionCreate'
|
|
117
|
+
| 'error'
|
|
118
|
+
| 'warn'
|
|
119
|
+
| 'debug'
|
|
120
|
+
| 'cacheSweep'
|
|
121
|
+
| 'shardDisconnect'
|
|
122
|
+
| 'shardError'
|
|
123
|
+
| 'shardReconnecting'
|
|
124
|
+
| 'shardReady'
|
|
125
|
+
| 'shardResume'
|
|
126
|
+
| 'invalidated'
|
|
127
|
+
| 'raw'
|
|
128
|
+
| 'stageInstanceCreate'
|
|
129
|
+
| 'stageInstanceUpdate'
|
|
130
|
+
| 'stageInstanceDelete'
|
|
131
|
+
| 'stickerCreate'
|
|
132
|
+
| 'stickerDelete'
|
|
133
|
+
| 'stickerUpdate'
|
|
134
|
+
| 'guildScheduledEventCreate'
|
|
135
|
+
| 'guildScheduledEventUpdate'
|
|
136
|
+
| 'guildScheduledEventDelete'
|
|
137
|
+
| 'guildScheduledEventUserAdd'
|
|
138
|
+
| 'guildScheduledEventUserRemove';
|
|
137
139
|
export type XernerxEventType = DiscordEventType | 'webhookCreate' | 'webhookError' | 'commandBlock' | 'commandError' | 'commandStart' | 'commandFinish' | 'commandCooldown';
|
|
138
140
|
export type XernerxInteraction<T extends XernerxSlashInteraction | XernerxUserContextInteraction | XernerxMessageContextInteraction> = T extends XernerxSlashInteraction
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
141
|
+
? XernerxSlashInteraction
|
|
142
|
+
: T extends XernerxUserContextInteraction
|
|
143
|
+
? XernerxUserContextInteraction
|
|
144
|
+
: XernerxMessageContextInteraction;
|
|
143
145
|
export type PermissionNames =
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
146
|
+
| 'create instant invite'
|
|
147
|
+
| 'kick members'
|
|
148
|
+
| 'ban members'
|
|
149
|
+
| 'administrator'
|
|
150
|
+
| 'manage channels'
|
|
151
|
+
| 'manage guild'
|
|
152
|
+
| 'add reactions'
|
|
153
|
+
| 'view audit log'
|
|
154
|
+
| 'priority speaker'
|
|
155
|
+
| 'stream'
|
|
156
|
+
| 'view channel'
|
|
157
|
+
| 'send messages'
|
|
158
|
+
| 'send tts messages'
|
|
159
|
+
| 'manage messages'
|
|
160
|
+
| 'embed links'
|
|
161
|
+
| 'attach files'
|
|
162
|
+
| 'read message history'
|
|
163
|
+
| 'mention everyone'
|
|
164
|
+
| 'use external emojis'
|
|
165
|
+
| 'view guild insights'
|
|
166
|
+
| 'connect'
|
|
167
|
+
| 'speak'
|
|
168
|
+
| 'mute members'
|
|
169
|
+
| 'deafen members'
|
|
170
|
+
| 'move members'
|
|
171
|
+
| 'use vad'
|
|
172
|
+
| 'change nickname'
|
|
173
|
+
| 'manage nicknames'
|
|
174
|
+
| 'manage roles'
|
|
175
|
+
| 'manage webhooks'
|
|
176
|
+
| 'manage emojis and stickers'
|
|
177
|
+
| 'use application commands'
|
|
178
|
+
| 'request to speak'
|
|
179
|
+
| 'manage events'
|
|
180
|
+
| 'manage threads'
|
|
181
|
+
| 'create public threads'
|
|
182
|
+
| 'create private threads'
|
|
183
|
+
| 'use external stickers'
|
|
184
|
+
| 'send messages in threads'
|
|
185
|
+
| 'start embedded activities'
|
|
186
|
+
| 'moderate members';
|
|
185
187
|
export type InhibitorType = 'message' | 'interaction' | 'command' | 'channel' | 'user' | 'member' | 'guild' | 'contextCommand' | 'messageCommand' | 'slashCommand';
|
|
186
188
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types/types.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
/** @format */
|
|
2
|
+
|
|
1
3
|
import XernerxClient from '../client/XernerxClient.js';
|
|
2
4
|
import { PresenceOptions } from '../types/interfaces.js';
|
|
3
5
|
import Util from './Util.js';
|
|
4
6
|
export default class ClientUtil extends Util {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
hasVoted: Function;
|
|
8
|
+
constructor(client: XernerxClient);
|
|
9
|
+
setPresence(options: PresenceOptions): import('discord.js').ClientPresence | undefined;
|
|
10
|
+
resolveChannel(query: string | Record<string, string>): Promise<import('discord.js').Channel | null>;
|
|
11
|
+
resolveGuild(query: string | Record<string, string>): Promise<import('discord.js').Guild | null>;
|
|
12
|
+
uptime(timestamp?: number | null): string;
|
|
10
13
|
}
|
|
11
14
|
//# sourceMappingURL=ClientUtil.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClientUtil.d.ts","sourceRoot":"","sources":["../../src/utils/ClientUtil.ts"],"names":[],"mappings":"AACA,OAAO,aAAa,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,IAAI;IACzB,QAAQ,EAAE,QAAQ,CAAC;gBAEtB,MAAM,EAAE,aAAa;IAI1B,WAAW,CAAC,OAAO,EAAE,eAAe;IAI9B,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAiBrD,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"ClientUtil.d.ts","sourceRoot":"","sources":["../../src/utils/ClientUtil.ts"],"names":[],"mappings":"AACA,OAAO,aAAa,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,IAAI;IACzB,QAAQ,EAAE,QAAQ,CAAC;gBAEtB,MAAM,EAAE,aAAa;IAI1B,WAAW,CAAC,OAAO,EAAE,eAAe;IAI9B,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAiBrD,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAczD,MAAM,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI;CAkB1C"}
|
package/dist/utils/ClientUtil.js
CHANGED
|
@@ -1,31 +1,50 @@
|
|
|
1
|
+
/** @format */
|
|
2
|
+
|
|
1
3
|
import setPresence from '../functions/setPresence.js';
|
|
2
4
|
import Util from './Util.js';
|
|
3
5
|
export default class ClientUtil extends Util {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
6
|
+
constructor(client) {
|
|
7
|
+
super(client);
|
|
8
|
+
}
|
|
9
|
+
setPresence(options) {
|
|
10
|
+
return setPresence(this.client, options);
|
|
11
|
+
}
|
|
12
|
+
async resolveChannel(query) {
|
|
13
|
+
if (typeof query == 'object') query = query.id;
|
|
14
|
+
try {
|
|
15
|
+
let channel = this.client.channels.cache.find((channel) => (channel.name == query.toLowerCase() || channel.id == query.toLowerCase() ? channel : null)) || null;
|
|
16
|
+
if (!channel) channel = (await this.client.channels.fetch(query)) || null;
|
|
17
|
+
return channel;
|
|
18
|
+
} catch {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
async resolveGuild(query) {
|
|
23
|
+
if (typeof query == 'object') query = query.id;
|
|
24
|
+
try {
|
|
25
|
+
let guild = this.client.guilds.cache.find((guild) => guild.name.toLowerCase() == query.toLowerCase()) || null;
|
|
26
|
+
if (!guild) guild = (await this.client.guilds.fetch(query)) || null;
|
|
27
|
+
return guild;
|
|
28
|
+
} catch {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
uptime(timestamp) {
|
|
33
|
+
if (!timestamp) timestamp = this.client.uptime || 0;
|
|
34
|
+
let totalSeconds = timestamp / 1000;
|
|
35
|
+
let years = Math.floor(totalSeconds / 31536000);
|
|
36
|
+
totalSeconds %= 31536000;
|
|
37
|
+
let days = Math.floor(totalSeconds / 86400);
|
|
38
|
+
totalSeconds %= 86400;
|
|
39
|
+
let hours = Math.floor(totalSeconds / 3600);
|
|
40
|
+
totalSeconds %= 3600;
|
|
41
|
+
let minutes = Math.floor(totalSeconds / 60);
|
|
42
|
+
let seconds = Math.floor(totalSeconds % 60);
|
|
43
|
+
if (years >= 1) return `${years}y ${days}d ${hours}h ${minutes}m`;
|
|
44
|
+
else if (days >= 1) return `${days}d ${hours}h ${minutes}m`;
|
|
45
|
+
else if (hours >= 1) return `${hours}h ${minutes}m`;
|
|
46
|
+
else if (minutes >= 1) return `${minutes}m ${seconds}s`;
|
|
47
|
+
else return `${seconds}s`;
|
|
48
|
+
}
|
|
30
49
|
}
|
|
31
50
|
//# sourceMappingURL=ClientUtil.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClientUtil.js","sourceRoot":"","sources":["../../src/utils/ClientUtil.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,6BAA6B,CAAC;AAGtD,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,IAAI;IAGxC,YAAY,MAAqB;QAC7B,KAAK,CAAC,MAAM,CAAC,CAAC;IAClB,CAAC;IAEM,WAAW,CAAC,OAAwB;QACvC,OAAO,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC7C,CAAC;IAEM,KAAK,CAAC,cAAc,CAAC,KAAsC;QAC9D,IAAI,OAAO,KAAK,IAAI,QAAQ;YAAE,KAAK,GAAG,KAAK,CAAC,EAAE,CAAC;QAE/C,IAAI;YACA,IAAI,OAAO,GACP,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAI,OAAU,EAAE,EAAE,CAC7C,OAAkC,CAAC,IAAI,IAAK,KAAgB,CAAC,WAAW,EAAE,IAAK,OAAkC,CAAC,EAAE,IAAK,KAAgB,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAC5K,IAAI,IAAI,CAAC;YAEd,IAAI,CAAC,OAAO;gBAAE,OAAO,GAAG,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,IAAI,CAAC;YAE1E,OAAO,OAAO,CAAC;SAClB;QAAC,MAAM;YACJ,OAAO,IAAI,CAAC;SACf;IACL,CAAC;IAEM,KAAK,CAAC,YAAY,CAAC,KAAsC;QAC5D,IAAI,OAAO,KAAK,IAAI,QAAQ;YAAE,KAAK,GAAG,KAAK,CAAC,EAAE,CAAC;QAE/C,IAAI;YACA,IAAI,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,IAAK,KAAgB,CAAC,WAAW,EAAE,CAAC,IAAI,IAAI,CAAC;YAE1H,IAAI,CAAC,KAAK;gBAAE,KAAK,GAAG,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,IAAI,CAAC;YAEpE,OAAO,KAAK,CAAC;SAChB;QAAC,MAAM;YACJ,OAAO,IAAI,CAAC;SACf;IACL,CAAC;CACJ","sourcesContent":["import setPresence from '../functions/setPresence.js';\nimport XernerxClient from '../client/XernerxClient.js';\nimport { PresenceOptions } from '../types/interfaces.js';\nimport Util from './Util.js';\n\nexport default class ClientUtil extends Util {\n public declare hasVoted: Function;\n\n constructor(client: XernerxClient) {\n super(client);\n }\n\n public setPresence(options: PresenceOptions) {\n return setPresence(this.client, options);\n }\n\n public async resolveChannel(query: string | Record<string, string>) {\n if (typeof query == 'object') query = query.id;\n\n try {\n let channel =\n this.client.channels.cache.find(<T>(channel: T) =>\n (channel as Record<string, string>).name == (query as string).toLowerCase() || (channel as Record<string, string>).id == (query as string).toLowerCase() ? channel : null\n ) || null;\n\n if (!channel) channel = (await this.client.channels.fetch(query)) || null;\n\n return channel;\n } catch {\n return null;\n }\n }\n\n public async resolveGuild(query: string | Record<string, string>) {\n if (typeof query == 'object') query = query.id;\n\n try {\n let guild = this.client.guilds.cache.find((guild) => guild.name.toLowerCase() == (query as string).toLowerCase()) || null;\n\n if (!guild) guild = (await this.client.guilds.fetch(query)) || null;\n\n return guild;\n } catch {\n return null;\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ClientUtil.js","sourceRoot":"","sources":["../../src/utils/ClientUtil.ts"],"names":[],"mappings":"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","sourcesContent":["import setPresence from '../functions/setPresence.js';\nimport XernerxClient from '../client/XernerxClient.js';\nimport { PresenceOptions } from '../types/interfaces.js';\nimport Util from './Util.js';\n\nexport default class ClientUtil extends Util {\n public declare hasVoted: Function;\n\n constructor(client: XernerxClient) {\n super(client);\n }\n\n public setPresence(options: PresenceOptions) {\n return setPresence(this.client, options);\n }\n\n public async resolveChannel(query: string | Record<string, string>) {\n if (typeof query == 'object') query = query.id;\n\n try {\n let channel =\n this.client.channels.cache.find(<T>(channel: T) =>\n (channel as Record<string, string>).name == (query as string).toLowerCase() || (channel as Record<string, string>).id == (query as string).toLowerCase() ? channel : null\n ) || null;\n\n if (!channel) channel = (await this.client.channels.fetch(query)) || null;\n\n return channel;\n } catch {\n return null;\n }\n }\n\n public async resolveGuild(query: string | Record<string, string>) {\n if (typeof query == 'object') query = query.id;\n\n try {\n let guild = this.client.guilds.cache.find((guild) => guild.name.toLowerCase() == (query as string).toLowerCase()) || null;\n\n if (!guild) guild = (await this.client.guilds.fetch(query)) || null;\n\n return guild;\n } catch {\n return null;\n }\n }\n\n public uptime(timestamp?: number | null) {\n if (!timestamp) timestamp = this.client.uptime || 0;\n let totalSeconds = timestamp / 1000;\n let years = Math.floor(totalSeconds / 31536000);\n totalSeconds %= 31536000;\n let days = Math.floor(totalSeconds / 86400);\n totalSeconds %= 86400;\n let hours = Math.floor(totalSeconds / 3600);\n totalSeconds %= 3600;\n let minutes = Math.floor(totalSeconds / 60);\n let seconds = Math.floor(totalSeconds % 60);\n\n if (years >= 1) return `${years}y ${days}d ${hours}h ${minutes}m`;\n else if (days >= 1) return `${days}d ${hours}h ${minutes}m`;\n else if (hours >= 1) return `${hours}h ${minutes}m`;\n else if (minutes >= 1) return `${minutes}m ${seconds}s`;\n else return `${seconds}s`;\n }\n}\n"]}
|
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
/** @format */
|
|
2
|
+
|
|
3
|
+
import { EmbedBuilder, InteractionEditReplyOptions, InteractionReplyOptions, MessagePayload } from 'discord.js';
|
|
2
4
|
import XernerxClient from '../client/XernerxClient.js';
|
|
5
|
+
import { PaginatorOptions } from '../types/interfaces.js';
|
|
3
6
|
import { XernerxInteraction } from '../types/types.js';
|
|
4
7
|
import Util from './Util.js';
|
|
5
|
-
import { XernerxMessageContextInteraction, XernerxSlashInteraction, XernerxUserContextInteraction } from '../
|
|
8
|
+
import { XernerxMessageContextInteraction, XernerxSlashInteraction, XernerxUserContextInteraction } from '../types/extenders.js';
|
|
6
9
|
export default class InteractionUtil extends Util {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
private interaction;
|
|
11
|
+
constructor(client: XernerxClient, interaction: XernerxInteraction<XernerxSlashInteraction | XernerxUserContextInteraction | XernerxMessageContextInteraction>);
|
|
12
|
+
send(content: any): Promise<import('discord.js').Message<false> | import('discord.js').Message<true> | undefined>;
|
|
13
|
+
reply(content: string | MessagePayload | InteractionReplyOptions | InteractionEditReplyOptions): Promise<import('discord.js').InteractionResponse<boolean> | import('discord.js').Message<boolean>>;
|
|
14
|
+
commandName(): void;
|
|
15
|
+
paginator(embeds: Array<EmbedBuilder>, options?: PaginatorOptions): Promise<void | import('discord.js').Message<false> | import('discord.js').Message<true>>;
|
|
10
16
|
}
|
|
11
17
|
//# sourceMappingURL=InteractionUtil.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InteractionUtil.d.ts","sourceRoot":"","sources":["../../src/utils/InteractionUtil.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,uBAAuB,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"InteractionUtil.d.ts","sourceRoot":"","sources":["../../src/utils/InteractionUtil.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgD,YAAY,EAAE,2BAA2B,EAAE,uBAAuB,EAAE,cAAc,EAA2B,MAAM,YAAY,CAAC;AAEvL,OAAO,aAAa,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,gCAAgC,EAAE,uBAAuB,EAAE,6BAA6B,EAAE,MAAM,uBAAuB,CAAC;AAEjI,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,IAAI;IAC7C,OAAO,CAAC,WAAW,CAAC;gBAER,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,kBAAkB,CAAC,uBAAuB,GAAG,6BAA6B,GAAG,gCAAgC,CAAC;IAMjJ,IAAI,CAAC,OAAO,EAAE,GAAG;IAMjB,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,cAAc,GAAG,uBAAuB,GAAG,2BAA2B;IAMpG,WAAW;IAEL,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC,YAAY,CAAC,EAAE,OAAO,GAAE,gBAAqB;CAkGrF"}
|
|
@@ -1,12 +1,102 @@
|
|
|
1
|
+
/** @format */
|
|
2
|
+
|
|
3
|
+
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, StringSelectMenuBuilder } from 'discord.js';
|
|
1
4
|
import Util from './Util.js';
|
|
5
|
+
import XernerxError from '../tools/XernerxError.js';
|
|
2
6
|
export default class InteractionUtil extends Util {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
interaction;
|
|
8
|
+
constructor(client, interaction) {
|
|
9
|
+
super(client);
|
|
10
|
+
this.interaction = interaction;
|
|
11
|
+
}
|
|
12
|
+
async send(content) {
|
|
13
|
+
if (!content) throw new XernerxError(`Can't send a message without content.`);
|
|
14
|
+
return await this.interaction.channel?.send(content);
|
|
15
|
+
}
|
|
16
|
+
async reply(content) {
|
|
17
|
+
if (!content) throw new XernerxError(`Can't send a message without content.`);
|
|
18
|
+
return await (this.interaction.replied || this.interaction.deferred ? this.interaction.editReply(content) : this.interaction.reply(content));
|
|
19
|
+
}
|
|
20
|
+
commandName() {}
|
|
21
|
+
async paginator(embeds, options = {}) {
|
|
22
|
+
let buttonRow, menuRow;
|
|
23
|
+
if (embeds.length <= 0) throw new XernerxError(`Can't make a paginator without embeds`);
|
|
24
|
+
options = {
|
|
25
|
+
type: options.type ?? 'combined',
|
|
26
|
+
buttons: options.buttons ?? ['⏪', '◀️', '⏹️', '▶️', '⏩'],
|
|
27
|
+
description: options.description ?? false,
|
|
28
|
+
placeholder: options.placeholder ?? 'Change page',
|
|
29
|
+
index: options.index ?? 0,
|
|
30
|
+
send: options.send ?? false,
|
|
31
|
+
filter: options.filter ?? (() => true),
|
|
32
|
+
time: options.time ?? 300000,
|
|
33
|
+
};
|
|
34
|
+
if (options.type == 'button' || options.type == 'combined') {
|
|
35
|
+
if (!options.buttons) throw new XernerxError(`¯\\_(ツ)_/¯ Somehow there are no buttons? ¯\\_(ツ)_/¯`);
|
|
36
|
+
buttonRow = new ActionRowBuilder().addComponents(
|
|
37
|
+
...options.buttons.map((button, i) => new ButtonBuilder().setCustomId(`${this.interaction.id}-${i}`).setEmoji(button).setStyle(ButtonStyle.Primary))
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
if (options.type == 'select-menu' || options.type == 'combined') {
|
|
41
|
+
menuRow = new ActionRowBuilder().addComponents(
|
|
42
|
+
new StringSelectMenuBuilder()
|
|
43
|
+
.setCustomId(`${this.interaction.id}-select-menu`)
|
|
44
|
+
.setPlaceholder(options.placeholder)
|
|
45
|
+
.addOptions(...embeds.map((embed, i) => ({ label: embed.data.title || 'No Title', description: (options.description ? embed.data.description : undefined) || undefined, value: `${i}` })))
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
let index = options.index || 0;
|
|
49
|
+
return options.send
|
|
50
|
+
? await this.interaction.util.send({
|
|
51
|
+
embeds: [embeds[index]],
|
|
52
|
+
components: [options.type == 'combined' || options.type == 'button' ? buttonRow : null, options.type == 'combined' || options.type == 'select-menu' ? menuRow : null].filter((x) => x),
|
|
53
|
+
})
|
|
54
|
+
: await this.interaction.util
|
|
55
|
+
.reply({
|
|
56
|
+
embeds: [embeds[index]],
|
|
57
|
+
components: [options.type == 'combined' || options.type == 'button' ? buttonRow : null, options.type == 'combined' || options.type == 'select-menu' ? menuRow : null].filter((x) => x),
|
|
58
|
+
})
|
|
59
|
+
.then(async (msg) => {
|
|
60
|
+
const collector = this.interaction.channel
|
|
61
|
+
?.createMessageComponentCollector({ time: options.time })
|
|
62
|
+
.on('collect', (collect) => {
|
|
63
|
+
if (!collect.customId.startsWith(this.interaction.id)) return;
|
|
64
|
+
if (collect.customId.endsWith('select-menu')) {
|
|
65
|
+
index = Number(collect.values[0]);
|
|
66
|
+
collect.update({ embeds: [embeds[index]] });
|
|
67
|
+
} else {
|
|
68
|
+
const option = Number(collect.customId.split(/-/)[1]);
|
|
69
|
+
let embed = embeds[index];
|
|
70
|
+
if (option == 0) {
|
|
71
|
+
index = 0;
|
|
72
|
+
embed = embeds[index];
|
|
73
|
+
collect.update({ embeds: [embed] });
|
|
74
|
+
}
|
|
75
|
+
if (option == 1) {
|
|
76
|
+
index = embeds.indexOf(embed) >= 1 ? embeds.indexOf(embed) - 1 : 0;
|
|
77
|
+
embed = embeds[index];
|
|
78
|
+
collect.update({ embeds: [embed] });
|
|
79
|
+
}
|
|
80
|
+
if (option == 2) {
|
|
81
|
+
collect.update({ components: [] });
|
|
82
|
+
collector?.stop();
|
|
83
|
+
}
|
|
84
|
+
if (option == 3) {
|
|
85
|
+
index = embeds.indexOf(embed) < embeds.length - 1 ? embeds.indexOf(embed) + 1 : embeds.length - 1;
|
|
86
|
+
embed = embeds[index];
|
|
87
|
+
collect.update({ embeds: [embed] });
|
|
88
|
+
}
|
|
89
|
+
if (option == 4) {
|
|
90
|
+
index = embeds.length - 1;
|
|
91
|
+
embed = embeds[index];
|
|
92
|
+
collect.update({ embeds: [embed] });
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
})
|
|
96
|
+
.on('end', async () => {
|
|
97
|
+
this.interaction.editReply({ components: [] });
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
}
|
|
11
101
|
}
|
|
12
102
|
//# sourceMappingURL=InteractionUtil.js.map
|