xernerx 4.17.9 → 5.0.2
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/README.md +14 -67
- package/dist/main.cjs +63 -0
- package/dist/main.cjs.map +1 -0
- package/dist/main.d.cts +21 -0
- package/dist/main.d.ts +18 -37
- package/dist/main.js +23 -42
- package/dist/main.js.map +1 -0
- package/package.json +63 -48
- package/src/main.ts +26 -0
- package/dist/build/XernerxContextCommand.d.ts +0 -54
- package/dist/build/XernerxContextCommand.js +0 -121
- package/dist/build/XernerxEvent.d.ts +0 -21
- package/dist/build/XernerxEvent.js +0 -27
- package/dist/build/XernerxInhibitor.d.ts +0 -29
- package/dist/build/XernerxInhibitor.js +0 -27
- package/dist/build/XernerxMessageCommand.d.ts +0 -58
- package/dist/build/XernerxMessageCommand.js +0 -119
- package/dist/build/XernerxSlashCommand.d.ts +0 -70
- package/dist/build/XernerxSlashCommand.js +0 -178
- package/dist/client/XernerxClient.d.ts +0 -64
- package/dist/client/XernerxClient.js +0 -109
- package/dist/client/XernerxShardClient.d.ts +0 -21
- package/dist/client/XernerxShardClient.js +0 -54
- package/dist/functions/deploy.d.ts +0 -3
- package/dist/functions/deploy.js +0 -63
- package/dist/functions/load.d.ts +0 -4
- package/dist/functions/load.js +0 -35
- package/dist/functions/reload.d.ts +0 -3
- package/dist/functions/reload.js +0 -30
- package/dist/functions/setPresence.d.ts +0 -4
- package/dist/functions/setPresence.js +0 -21
- package/dist/handlers/CommandHandler.d.ts +0 -16
- package/dist/handlers/CommandHandler.js +0 -351
- package/dist/handlers/EventHandler.d.ts +0 -11
- package/dist/handlers/EventHandler.js +0 -84
- package/dist/handlers/ExtensionHandler.d.ts +0 -9
- package/dist/handlers/ExtensionHandler.js +0 -29
- package/dist/handlers/Handler.d.ts +0 -26
- package/dist/handlers/Handler.js +0 -64
- package/dist/handlers/InhibitorHandler.d.ts +0 -9
- package/dist/handlers/InhibitorHandler.js +0 -31
- package/dist/handlers/IntegrationHandler.d.ts +0 -15
- package/dist/handlers/IntegrationHandler.js +0 -26
- package/dist/models/Arguments.d.ts +0 -9
- package/dist/models/Arguments.js +0 -154
- package/dist/models/Cooldowns.d.ts +0 -11
- package/dist/models/Cooldowns.js +0 -33
- package/dist/models/XernerxEntitlement.d.ts +0 -45
- package/dist/models/XernerxEntitlement.js +0 -57
- package/dist/models/XernerxUser.d.ts +0 -14
- package/dist/models/XernerxUser.js +0 -13
- package/dist/tools/XernerxError.d.ts +0 -7
- package/dist/tools/XernerxError.js +0 -11
- package/dist/tools/XernerxIntents.d.ts +0 -6
- package/dist/tools/XernerxIntents.js +0 -26
- package/dist/tools/XernerxLog.d.ts +0 -31
- package/dist/tools/XernerxLog.js +0 -139
- package/dist/tools/XernerxText.d.ts +0 -31
- package/dist/tools/XernerxText.js +0 -94
- package/dist/types/extenders.d.ts +0 -76
- package/dist/types/extenders.js +0 -2
- package/dist/types/interfaces.d.ts +0 -258
- package/dist/types/interfaces.js +0 -2
- package/dist/types/types.d.ts +0 -12
- package/dist/types/types.js +0 -2
- package/dist/utils/ClientUtil.d.ts +0 -20
- package/dist/utils/ClientUtil.js +0 -123
- package/dist/utils/InteractionUtil.d.ts +0 -25
- package/dist/utils/InteractionUtil.js +0 -153
- package/dist/utils/MessageUtil.d.ts +0 -26
- package/dist/utils/MessageUtil.js +0 -167
- package/dist/utils/Util.d.ts +0 -12
- package/dist/utils/Util.js +0 -11
- package/dist/validators/commandValidation.d.ts +0 -7
- package/dist/validators/commandValidation.js +0 -124
- package/dist/validators/inhibitorValidations.d.ts +0 -9
- package/dist/validators/inhibitorValidations.js +0 -44
- package/tsup.config.ts +0 -19
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/** @format */
|
|
2
|
-
import XernerxSlashCommand from '../build/XernerxSlashCommand.js';
|
|
3
|
-
import XernerxContextCommand from '../build/XernerxContextCommand.js';
|
|
4
|
-
import MessageCommandBuilder from '../build/XernerxMessageCommand.js';
|
|
5
|
-
import { XernerxMessage, XernerxMessageContextInteraction, XernerxSlashInteraction, XernerxUserContextInteraction } from '../types/extenders.js';
|
|
6
|
-
import { MessageCommandArguments } from '../types/interfaces.js';
|
|
7
|
-
import { XernerxInteraction } from '../types/types.js';
|
|
8
|
-
export declare function messageArguments(message: XernerxMessage, command: MessageCommandBuilder, prefix: string): Promise<MessageCommandArguments>;
|
|
9
|
-
export declare function interactionArguments(interaction: XernerxInteraction<XernerxSlashInteraction | XernerxUserContextInteraction | XernerxMessageContextInteraction> | any, command: XernerxContextCommand | XernerxSlashCommand): Promise<any>;
|
package/dist/models/Arguments.js
DELETED
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
/** @format */
|
|
2
|
-
export async function messageArguments(message, command, prefix) {
|
|
3
|
-
const separator = command.separator || ' ', content = message.content
|
|
4
|
-
.replace(new RegExp(`${prefix} +?`), '')
|
|
5
|
-
.split(separator)
|
|
6
|
-
.slice(1);
|
|
7
|
-
let args = {}, flags = {};
|
|
8
|
-
if (command.flags)
|
|
9
|
-
command.flags.map((flag) => {
|
|
10
|
-
if (!flags)
|
|
11
|
-
flags = {};
|
|
12
|
-
if (content.includes(flag.match))
|
|
13
|
-
flags[flag.name] = true;
|
|
14
|
-
else
|
|
15
|
-
flags[flag.name] = false;
|
|
16
|
-
const index = content.indexOf(flag.match);
|
|
17
|
-
if (index > 0)
|
|
18
|
-
content.splice(index, 1);
|
|
19
|
-
});
|
|
20
|
-
if (command.args)
|
|
21
|
-
for (const argument of command.args) {
|
|
22
|
-
const element = content.at(0) || null;
|
|
23
|
-
if (!element) {
|
|
24
|
-
if (typeof argument.default === 'function')
|
|
25
|
-
args[argument.name] = argument.default(message);
|
|
26
|
-
args[argument.name] = argument.default || null;
|
|
27
|
-
continue;
|
|
28
|
-
}
|
|
29
|
-
if (argument.type === 'option')
|
|
30
|
-
argument.match?.includes(element) ? (args[argument.name] = element) : (args[argument.name] = null);
|
|
31
|
-
if (argument.type === 'number')
|
|
32
|
-
args[argument.name] = parseInt(element);
|
|
33
|
-
if (argument.type === 'integer')
|
|
34
|
-
args[argument.name] = parseInt(element);
|
|
35
|
-
if (argument.type === 'boolean')
|
|
36
|
-
args[argument.name] = element === 'true' ? true : false;
|
|
37
|
-
if (argument.type === 'confirm')
|
|
38
|
-
args[argument.name] = element === 'yes' ? 'yes' : 'no';
|
|
39
|
-
if (argument.type === 'string')
|
|
40
|
-
args[argument.name] = element;
|
|
41
|
-
if (argument.type === 'channel') {
|
|
42
|
-
try {
|
|
43
|
-
const channel = await message.client.channels.fetch(element);
|
|
44
|
-
args[argument.name] = channel;
|
|
45
|
-
}
|
|
46
|
-
catch (e) {
|
|
47
|
-
args[argument.name] = null;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
if (argument.type === 'guild') {
|
|
51
|
-
try {
|
|
52
|
-
const guild = await message.client.guilds.fetch(element);
|
|
53
|
-
args[argument.name] = guild;
|
|
54
|
-
}
|
|
55
|
-
catch (e) {
|
|
56
|
-
args[argument.name] = null;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
if (argument.type === 'mentionable') {
|
|
60
|
-
(await Promise.all([message.guild?.roles, message.client.users, message.client.guilds, message.client.channels, message.guild?.members, message.channel.messages].map((req) => req
|
|
61
|
-
? req
|
|
62
|
-
.fetch(element)
|
|
63
|
-
.then((r) => r)
|
|
64
|
-
.catch(() => null)
|
|
65
|
-
: null))).map((mentionable) => {
|
|
66
|
-
if (!args)
|
|
67
|
-
args = {};
|
|
68
|
-
if (mentionable)
|
|
69
|
-
return (args[argument.name] = mentionable);
|
|
70
|
-
else
|
|
71
|
-
return (args[argument.name] = null);
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
if (argument.type === 'role') {
|
|
75
|
-
try {
|
|
76
|
-
const role = await message.guild?.roles.fetch(element);
|
|
77
|
-
args[argument.name] = role;
|
|
78
|
-
}
|
|
79
|
-
catch (e) {
|
|
80
|
-
args[argument.name] = null;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
if (argument.type === 'user') {
|
|
84
|
-
try {
|
|
85
|
-
const user = await message.client.users.fetch(element);
|
|
86
|
-
args[argument.name] = user;
|
|
87
|
-
}
|
|
88
|
-
catch (e) {
|
|
89
|
-
args[argument.name] = null;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
if (argument.type === 'member') {
|
|
93
|
-
try {
|
|
94
|
-
const member = await message.guild?.members.fetch(element);
|
|
95
|
-
args[argument.name] = member;
|
|
96
|
-
}
|
|
97
|
-
catch (e) {
|
|
98
|
-
args[argument.name] = null;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
if (argument.type === 'message') {
|
|
102
|
-
try {
|
|
103
|
-
const msg = await message.channel?.messages.fetch(element);
|
|
104
|
-
args[argument.name] = msg;
|
|
105
|
-
}
|
|
106
|
-
catch (e) {
|
|
107
|
-
args[argument.name] = null;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
if (argument.type === 'list') {
|
|
111
|
-
let separator = String(argument.separator) || ',';
|
|
112
|
-
if (separator.startsWith('/') && separator.endsWith('/'))
|
|
113
|
-
separator = separator.replace(/^\/|\/$/gim, '');
|
|
114
|
-
const items = content.join(' ').split(new RegExp(' *' + separator + ' *', 'gi'));
|
|
115
|
-
if (!argument.content)
|
|
116
|
-
args[argument.name] = items;
|
|
117
|
-
else {
|
|
118
|
-
const contents = argument.content.map((content) => content.toLowerCase()), itemList = [];
|
|
119
|
-
items.map((item) => (contents.includes(item.toLowerCase()) ? itemList.push(argument.content?.at(contents.indexOf(item.toLowerCase()))) : null));
|
|
120
|
-
args[argument.name] = itemList;
|
|
121
|
-
break;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
if (argument.type === 'rest') {
|
|
125
|
-
args[argument.name] = content.join(separator);
|
|
126
|
-
break;
|
|
127
|
-
}
|
|
128
|
-
content.splice(0, 1);
|
|
129
|
-
}
|
|
130
|
-
if (!command.flags)
|
|
131
|
-
flags = null;
|
|
132
|
-
if (!command.args)
|
|
133
|
-
args = null;
|
|
134
|
-
return { args, flags };
|
|
135
|
-
}
|
|
136
|
-
export async function interactionArguments(interaction, command) {
|
|
137
|
-
if (command.filetype === 'SlashCommand') {
|
|
138
|
-
const options = {};
|
|
139
|
-
let args = interaction?.options?._hoistedOptions, group = interaction?.options?._group, subcommand = interaction?.options?._subcommand;
|
|
140
|
-
if (interaction.options._hoistedOptions) {
|
|
141
|
-
for (const option of interaction.options._hoistedOptions) {
|
|
142
|
-
options[option.name] = option.member || option.channel || option.user || option.role || option.value;
|
|
143
|
-
}
|
|
144
|
-
args = options;
|
|
145
|
-
}
|
|
146
|
-
return { args, group, subcommand };
|
|
147
|
-
}
|
|
148
|
-
if (command.filetype === 'ContextCommand') {
|
|
149
|
-
if (command.type === 'user')
|
|
150
|
-
return await interaction.client.users.fetch(interaction.targetId);
|
|
151
|
-
if (command.type === 'message')
|
|
152
|
-
return await interaction.channel.messages.fetch(interaction.targetId);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/** @format */
|
|
2
|
-
import { Collection } from 'discord.js';
|
|
3
|
-
import XernerxClient from '../client/XernerxClient.js';
|
|
4
|
-
export default class Cooldowns {
|
|
5
|
-
private readonly _client;
|
|
6
|
-
readonly collections: Record<string, Collection<string, unknown>>;
|
|
7
|
-
constructor(client: XernerxClient, collections?: Array<string>);
|
|
8
|
-
add(collection: keyof typeof this.collections, id: string, value: unknown): string | Collection<string, unknown>;
|
|
9
|
-
delete(collection: keyof typeof this.collections, id: string): string | boolean;
|
|
10
|
-
has(id: string): Record<string, Collection<string, unknown>>;
|
|
11
|
-
}
|
package/dist/models/Cooldowns.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/** @format */
|
|
2
|
-
import { Collection } from 'discord.js';
|
|
3
|
-
export default class Cooldowns {
|
|
4
|
-
constructor(client, collections = []) {
|
|
5
|
-
this._client = client;
|
|
6
|
-
this.collections = {
|
|
7
|
-
commands: new Collection(),
|
|
8
|
-
};
|
|
9
|
-
for (const collection of collections) {
|
|
10
|
-
this.collections[collection] = new Collection();
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
add(collection, id, value) {
|
|
14
|
-
if (!this.collections[collection])
|
|
15
|
-
return `${collection} collection does not exist!`;
|
|
16
|
-
return this.collections[collection].set(id, value);
|
|
17
|
-
}
|
|
18
|
-
delete(collection, id) {
|
|
19
|
-
if (!this.collections[collection])
|
|
20
|
-
return `${collection} collection does not exist!`;
|
|
21
|
-
return this.collections[collection].delete(id);
|
|
22
|
-
}
|
|
23
|
-
has(id) {
|
|
24
|
-
const collected = {};
|
|
25
|
-
for (const [name, collection] of Object.entries(this.collections)) {
|
|
26
|
-
if (collection.has(id))
|
|
27
|
-
collected[name] = collection;
|
|
28
|
-
else
|
|
29
|
-
continue;
|
|
30
|
-
}
|
|
31
|
-
return collected;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/** @format */
|
|
2
|
-
import { XernerxClient } from '../main.js';
|
|
3
|
-
import XernerxError from '../tools/XernerxError.js';
|
|
4
|
-
export default class XernerxEntitlement {
|
|
5
|
-
readonly id: string;
|
|
6
|
-
readonly skuId: string;
|
|
7
|
-
readonly clientId: string;
|
|
8
|
-
readonly userId: string;
|
|
9
|
-
readonly promotionId: string;
|
|
10
|
-
readonly dependentId: string;
|
|
11
|
-
readonly deleted: boolean;
|
|
12
|
-
readonly consumed: boolean;
|
|
13
|
-
readonly startsAt: Date;
|
|
14
|
-
readonly endsAt: Date;
|
|
15
|
-
readonly item: {
|
|
16
|
-
type: string;
|
|
17
|
-
flags: number;
|
|
18
|
-
};
|
|
19
|
-
readonly sku: {
|
|
20
|
-
type: string;
|
|
21
|
-
flags: string;
|
|
22
|
-
productLine: number;
|
|
23
|
-
manifestLabels: any;
|
|
24
|
-
};
|
|
25
|
-
readonly details: {
|
|
26
|
-
slug: string;
|
|
27
|
-
name: string;
|
|
28
|
-
description: string;
|
|
29
|
-
features: Array<any>;
|
|
30
|
-
cost: number;
|
|
31
|
-
currency: string;
|
|
32
|
-
currencyExponent: number;
|
|
33
|
-
releaseDate: Date;
|
|
34
|
-
accessType: number;
|
|
35
|
-
premium: boolean;
|
|
36
|
-
nsfw: boolean;
|
|
37
|
-
};
|
|
38
|
-
private readonly client;
|
|
39
|
-
constructor(client: XernerxClient, sku: any, item: any);
|
|
40
|
-
consume(): Promise<XernerxError | {
|
|
41
|
-
message: string;
|
|
42
|
-
code: number;
|
|
43
|
-
entitlement: XernerxEntitlement;
|
|
44
|
-
}>;
|
|
45
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/** @format */
|
|
2
|
-
import { EntitlementType, SKUFlags, SKUType } from 'discord.js';
|
|
3
|
-
import XernerxError from '../tools/XernerxError.js';
|
|
4
|
-
export default class XernerxEntitlement {
|
|
5
|
-
constructor(client, sku, item) {
|
|
6
|
-
this.id = item.id;
|
|
7
|
-
this.skuId = item.sku_id;
|
|
8
|
-
this.clientId = item.application_id;
|
|
9
|
-
this.userId = item.user_id;
|
|
10
|
-
this.promotionId = item.promotion_id;
|
|
11
|
-
this.dependentId = sku.dependent_sku_id;
|
|
12
|
-
this.deleted = item.deleted;
|
|
13
|
-
this.consumed = item.consumed;
|
|
14
|
-
this.startsAt = item.starts_at;
|
|
15
|
-
this.endsAt = item.ends_at;
|
|
16
|
-
this.item = {
|
|
17
|
-
type: EntitlementType[item.type],
|
|
18
|
-
flags: item.gift_code_flags,
|
|
19
|
-
};
|
|
20
|
-
this.sku = {
|
|
21
|
-
type: SKUType[sku.type],
|
|
22
|
-
flags: SKUFlags[sku.flags],
|
|
23
|
-
productLine: sku.product_line,
|
|
24
|
-
manifestLabels: sku.manifest_labels,
|
|
25
|
-
};
|
|
26
|
-
this.details = {
|
|
27
|
-
slug: sku.slug,
|
|
28
|
-
name: sku.name,
|
|
29
|
-
description: sku.description,
|
|
30
|
-
features: sku.features,
|
|
31
|
-
cost: sku.price?.amount,
|
|
32
|
-
currency: sku.price?.currency,
|
|
33
|
-
currencyExponent: sku.price?.currency_exponent,
|
|
34
|
-
releaseDate: sku.release_date,
|
|
35
|
-
accessType: sku.access_type,
|
|
36
|
-
premium: sku.premium,
|
|
37
|
-
nsfw: sku.show_age_gate,
|
|
38
|
-
};
|
|
39
|
-
this.client = client;
|
|
40
|
-
}
|
|
41
|
-
async consume() {
|
|
42
|
-
if (this.consumed)
|
|
43
|
-
return new XernerxError('This entitlement has already been consumed.');
|
|
44
|
-
const request = await fetch(`https://discord.com/api/v10/applications/${this.clientId}/entitlements/${this.id}/consume`, {
|
|
45
|
-
method: 'POST',
|
|
46
|
-
headers: {
|
|
47
|
-
'Authorization': `Bot ${this.client.token}`,
|
|
48
|
-
'Content-Type': 'application/json',
|
|
49
|
-
},
|
|
50
|
-
});
|
|
51
|
-
if (request.ok) {
|
|
52
|
-
this.client.emit('skuConsumed', this.client, this);
|
|
53
|
-
return { message: 'Entitlement consumed successfully.', code: 200, entitlement: this };
|
|
54
|
-
}
|
|
55
|
-
return (await request.json().then((error) => ({ ...error, entitlement: this })));
|
|
56
|
-
}
|
|
57
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/** @format */
|
|
2
|
-
import { User } from 'discord.js';
|
|
3
|
-
import { Client } from 'discord.js';
|
|
4
|
-
import { XernerxClient } from '../main.js';
|
|
5
|
-
import XernerxEntitlement from './XernerxEntitlement.js';
|
|
6
|
-
export default class XernerxUser extends User {
|
|
7
|
-
readonly owner: boolean;
|
|
8
|
-
readonly premium: {
|
|
9
|
-
items: Array<XernerxEntitlement>;
|
|
10
|
-
archive: Array<XernerxEntitlement>;
|
|
11
|
-
tier: XernerxEntitlement | null;
|
|
12
|
-
};
|
|
13
|
-
constructor(client: XernerxClient & Client<true>, data: any);
|
|
14
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/** @format */
|
|
2
|
-
import { User } from 'discord.js';
|
|
3
|
-
export default class XernerxUser extends User {
|
|
4
|
-
constructor(client, data) {
|
|
5
|
-
super(client, data);
|
|
6
|
-
this.owner = client.settings.ownerId.includes(this.id);
|
|
7
|
-
this.premium = {
|
|
8
|
-
tier: client.store.items.find((item) => item.userId == this.id && item.sku.type == 'Subscription') || null,
|
|
9
|
-
items: client.store.items.filter((item) => item.userId == this.id),
|
|
10
|
-
archive: client.store.archive.filter((item) => item.userId == this.id),
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/** @format */
|
|
2
|
-
import { GatewayIntentBits } from 'discord.js';
|
|
3
|
-
export const XernerxIntents = {
|
|
4
|
-
Default: [
|
|
5
|
-
GatewayIntentBits.Guilds,
|
|
6
|
-
GatewayIntentBits.GuildModeration,
|
|
7
|
-
GatewayIntentBits.GuildBans,
|
|
8
|
-
GatewayIntentBits.GuildModeration,
|
|
9
|
-
GatewayIntentBits.GuildEmojisAndStickers,
|
|
10
|
-
GatewayIntentBits.GuildIntegrations,
|
|
11
|
-
GatewayIntentBits.GuildWebhooks,
|
|
12
|
-
GatewayIntentBits.GuildInvites,
|
|
13
|
-
GatewayIntentBits.GuildVoiceStates,
|
|
14
|
-
GatewayIntentBits.GuildMessages,
|
|
15
|
-
GatewayIntentBits.GuildMessageReactions,
|
|
16
|
-
GatewayIntentBits.GuildMessageTyping,
|
|
17
|
-
GatewayIntentBits.DirectMessages,
|
|
18
|
-
GatewayIntentBits.DirectMessageReactions,
|
|
19
|
-
GatewayIntentBits.DirectMessageTyping,
|
|
20
|
-
GatewayIntentBits.GuildScheduledEvents,
|
|
21
|
-
GatewayIntentBits.AutoModerationConfiguration,
|
|
22
|
-
GatewayIntentBits.AutoModerationExecution,
|
|
23
|
-
],
|
|
24
|
-
All: [GatewayIntentBits.GuildMembers, GatewayIntentBits.GuildPresences, GatewayIntentBits.MessageContent],
|
|
25
|
-
};
|
|
26
|
-
XernerxIntents.All.push(...XernerxIntents.Default);
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/** @format */
|
|
2
|
-
import XernerxError from './XernerxError.js';
|
|
3
|
-
import XernerxClient from '../client/XernerxClient.js';
|
|
4
|
-
import { XernerxClientType } from '../types/extenders.js';
|
|
5
|
-
export default class XernerxLog {
|
|
6
|
-
private readonly client;
|
|
7
|
-
private readonly errorLog;
|
|
8
|
-
private readonly infoLog;
|
|
9
|
-
private readonly warnLog;
|
|
10
|
-
private readonly readyLog;
|
|
11
|
-
private readonly tableLog;
|
|
12
|
-
private readonly format;
|
|
13
|
-
private readonly time;
|
|
14
|
-
private readonly ram;
|
|
15
|
-
private shard;
|
|
16
|
-
private readonly base;
|
|
17
|
-
constructor(client: XernerxClient | XernerxClientType | true);
|
|
18
|
-
info(message: string, force?: boolean): void | null;
|
|
19
|
-
warn(message: string): void | null;
|
|
20
|
-
debug(message: string): void;
|
|
21
|
-
update(version: string, url: string): Promise<void>;
|
|
22
|
-
error(message: string, error?: XernerxError | unknown): void | null;
|
|
23
|
-
ready(): void;
|
|
24
|
-
private cyan;
|
|
25
|
-
private blue;
|
|
26
|
-
private yellow;
|
|
27
|
-
private purple;
|
|
28
|
-
private red;
|
|
29
|
-
private green;
|
|
30
|
-
private turquoise;
|
|
31
|
-
}
|
package/dist/tools/XernerxLog.js
DELETED
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
/** @format */
|
|
2
|
-
import { Style } from 'dumfunctions';
|
|
3
|
-
import * as fs from 'fs';
|
|
4
|
-
import * as Discord from 'discord.js';
|
|
5
|
-
import { version } from '../main.js';
|
|
6
|
-
const pkg = JSON.parse(fs.readFileSync('./package.json', 'utf-8'));
|
|
7
|
-
let i = 0;
|
|
8
|
-
export default class XernerxLog {
|
|
9
|
-
constructor(client) {
|
|
10
|
-
this.client = client;
|
|
11
|
-
if (client == true || (typeof client.settings.log == 'boolean' && client.settings.log)) {
|
|
12
|
-
this.errorLog = true;
|
|
13
|
-
this.infoLog = true;
|
|
14
|
-
this.warnLog = true;
|
|
15
|
-
this.format = ['ram', 'time'];
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
this.errorLog = client.settings.log?.error;
|
|
19
|
-
this.infoLog = client.settings.log?.info;
|
|
20
|
-
this.warnLog = client.settings.log?.warn;
|
|
21
|
-
this.readyLog = client.settings.log?.ready;
|
|
22
|
-
this.tableLog = client.settings.log?.table;
|
|
23
|
-
this.format = client.settings.log?.format || ['ram', 'time'];
|
|
24
|
-
}
|
|
25
|
-
const format = {
|
|
26
|
-
name: this.blue(pkg.name),
|
|
27
|
-
node: this.green(process.version),
|
|
28
|
-
xernerx: this.cyan(version),
|
|
29
|
-
discordjs: this.cyan(Discord.version),
|
|
30
|
-
platform: this.green(process.platform),
|
|
31
|
-
time: () => this.cyan(new Date().toLocaleTimeString()),
|
|
32
|
-
date: () => this.cyan(new Date().toLocaleDateString()),
|
|
33
|
-
ram: () => `${this.cyan(Math.round(process.memoryUsage().rss / 1000000))}mb`,
|
|
34
|
-
version: this.cyan(pkg.version),
|
|
35
|
-
author: this.blue(pkg.author),
|
|
36
|
-
shard: this.cyan(''),
|
|
37
|
-
index: () => {
|
|
38
|
-
i++;
|
|
39
|
-
return i;
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
process.on('message', (message) => {
|
|
43
|
-
if (message.type == 'xernerx')
|
|
44
|
-
format.shard = message?.data?.sharded ? `| ${message?.data?.shardId} |` : '';
|
|
45
|
-
});
|
|
46
|
-
this.base = (type, message) => `${type == 'info'
|
|
47
|
-
? `✔️ | ${this.purple('Xernerx')}`
|
|
48
|
-
: type == `error`
|
|
49
|
-
? `❗ | ${this.red('Xernerx')}`
|
|
50
|
-
: type == `update`
|
|
51
|
-
? `⬆️ | ${this.blue('Xernerx')}`
|
|
52
|
-
: type == `debug`
|
|
53
|
-
? `🐛 | ${this.turquoise('Xernerx')}`
|
|
54
|
-
: `⚠️ | ${this.yellow('Xernerx')}`} | ${this.format
|
|
55
|
-
?.map((c) => (typeof format[c] == 'function' ? format[c]() : format[c]) || null)
|
|
56
|
-
.filter((x) => x)
|
|
57
|
-
.join(' | ')} | ${message}`;
|
|
58
|
-
}
|
|
59
|
-
info(message, force = false) {
|
|
60
|
-
return this.infoLog || force ? console.info(this.base('info', message)) : null;
|
|
61
|
-
}
|
|
62
|
-
warn(message) {
|
|
63
|
-
return this.warnLog ? console.warn(this.base('warn', message)) : null;
|
|
64
|
-
}
|
|
65
|
-
debug(message) {
|
|
66
|
-
return console.debug(this.base('debug', message));
|
|
67
|
-
}
|
|
68
|
-
async update(version, url) {
|
|
69
|
-
try {
|
|
70
|
-
const pkg = await fetch(url)
|
|
71
|
-
.then(async (res) => await res.json())
|
|
72
|
-
.catch(() => ({ version }));
|
|
73
|
-
if (version !== pkg.version)
|
|
74
|
-
console.info(this.base('update', `A new version for ${pkg.name} is available, you're using version ${this.cyan(version)}, new version is ${this.cyan(pkg.version)}, run ${Style.log(`npm i ${pkg.name}@${pkg.version}`, {
|
|
75
|
-
color: Style.BackgroundColor.Grey,
|
|
76
|
-
})} to update to the latest version.`));
|
|
77
|
-
}
|
|
78
|
-
catch (error) {
|
|
79
|
-
console.warn(this.base('error', `An error occured while trying to check for a new version for ${pkg.name}, please try again later.`));
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
error(message, error) {
|
|
83
|
-
return this.errorLog ? console.error(this.base('error', message), error || '') : null;
|
|
84
|
-
}
|
|
85
|
-
ready() {
|
|
86
|
-
if (typeof this.client == 'boolean')
|
|
87
|
-
return;
|
|
88
|
-
const client = this.client;
|
|
89
|
-
// @ts-ignore
|
|
90
|
-
this.client.prependOnceListener('ready', async (synced) => {
|
|
91
|
-
this.info(`${Style.log(synced.user.tag, { color: Style.TextColor.Blue })} is now ${this.green('online')}, watching ${this.cyan(String(client.guilds.cache.size))} guild${client.guilds.cache.size > 1 ? 's' : ''}, using ${client.settings.local ? this.blue((await client.guilds.fetch(client.settings.local))?.name) : 'none'} as local guild.`, this.readyLog);
|
|
92
|
-
const files = [];
|
|
93
|
-
for (const [id, data] of client.commands.message) {
|
|
94
|
-
files.push(data);
|
|
95
|
-
id;
|
|
96
|
-
}
|
|
97
|
-
for (const [id, data] of client.commands.slash) {
|
|
98
|
-
files.push(data);
|
|
99
|
-
id;
|
|
100
|
-
}
|
|
101
|
-
for (const [id, data] of client.commands.context) {
|
|
102
|
-
files.push(data);
|
|
103
|
-
id;
|
|
104
|
-
}
|
|
105
|
-
for (const [id, data] of client.events) {
|
|
106
|
-
files.push(data);
|
|
107
|
-
id;
|
|
108
|
-
}
|
|
109
|
-
for (const [id, data] of client.inhibitors) {
|
|
110
|
-
files.push(data);
|
|
111
|
-
id;
|
|
112
|
-
}
|
|
113
|
-
if (this.tableLog) {
|
|
114
|
-
console.table(files, this.tableLog);
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
cyan(string) {
|
|
119
|
-
return Style.log(String(string), { color: Style.TextColor.Cyan });
|
|
120
|
-
}
|
|
121
|
-
blue(string) {
|
|
122
|
-
return Style.log(String(string), { color: Style.TextColor.Blue });
|
|
123
|
-
}
|
|
124
|
-
yellow(string) {
|
|
125
|
-
return Style.log(String(string), { color: Style.TextColor.Yellow });
|
|
126
|
-
}
|
|
127
|
-
purple(string) {
|
|
128
|
-
return Style.log(String(string), { color: Style.TextColor.Purple });
|
|
129
|
-
}
|
|
130
|
-
red(string) {
|
|
131
|
-
return Style.log(String(string), { color: Style.TextColor.Red });
|
|
132
|
-
}
|
|
133
|
-
green(string) {
|
|
134
|
-
return Style.log(String(string), { color: Style.TextColor.Green });
|
|
135
|
-
}
|
|
136
|
-
turquoise(string) {
|
|
137
|
-
return Style.log(String(string), { color: Style.TextColor.Turquoise });
|
|
138
|
-
}
|
|
139
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/** @format */
|
|
2
|
-
import { Emoji, Role } from 'discord.js';
|
|
3
|
-
import { XernerxGuildChannel, XernerxMember, XernerxUser } from '../types/extenders.js';
|
|
4
|
-
export default class XernerxText {
|
|
5
|
-
user(user: string | XernerxUser): string;
|
|
6
|
-
channel(channel: string | XernerxGuildChannel): string;
|
|
7
|
-
role(role: string | Role): string;
|
|
8
|
-
emoji(emoji: string | Emoji, animated?: boolean): string;
|
|
9
|
-
member(member: string | XernerxMember): string;
|
|
10
|
-
command(id: string, name: string): string | null;
|
|
11
|
-
timestamp(timestamp?: number | Date, format?: 't' | 'T' | 'd' | 'D' | 'f' | 'F' | 'R'): string;
|
|
12
|
-
codeBlock(code: string, language: string): string;
|
|
13
|
-
iCodeBlock(code: string): string;
|
|
14
|
-
bold(text: string): string;
|
|
15
|
-
italic(text: string): string;
|
|
16
|
-
underline(text: string): string;
|
|
17
|
-
strike(text: string): string;
|
|
18
|
-
spoiler(text: string): string;
|
|
19
|
-
quote(text: string): string;
|
|
20
|
-
blockQuote(text: string): string;
|
|
21
|
-
hyperlink(text: string, url: string): string;
|
|
22
|
-
Progressbar(min: number, max: number, cur: number, options?: ProgressBarOptions): string;
|
|
23
|
-
}
|
|
24
|
-
interface ProgressBarOptions {
|
|
25
|
-
fill?: string;
|
|
26
|
-
fade?: string;
|
|
27
|
-
empty?: string;
|
|
28
|
-
percentage?: boolean;
|
|
29
|
-
length?: number;
|
|
30
|
-
}
|
|
31
|
-
export {};
|