@magicyan/discord 1.0.24 → 1.0.25
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/functions/components.cjs +1 -1
- package/dist/functions/components.mjs +1 -1
- package/dist/functions/embeds/author.cjs +1 -1
- package/dist/functions/embeds/author.mjs +1 -1
- package/dist/functions/embeds/embedplus.cjs +31 -48
- package/dist/functions/embeds/embedplus.mjs +31 -48
- package/dist/functions/embeds/fields.cjs +93 -0
- package/dist/functions/embeds/fields.mjs +91 -0
- package/dist/functions/members.cjs +7 -6
- package/dist/functions/members.mjs +7 -6
- package/dist/functions/modals.cjs +1 -1
- package/dist/functions/modals.mjs +1 -1
- package/dist/index.d.cts +56 -25
- package/dist/index.d.mts +56 -25
- package/dist/index.d.ts +56 -25
- package/package.json +2 -2
|
@@ -27,7 +27,7 @@ function createComponentsManager(components) {
|
|
|
27
27
|
(row) => row.components.filter((c) => c.type === discord_js.ComponentType.RoleSelect)
|
|
28
28
|
);
|
|
29
29
|
const mentionableSelects = components.flatMap(
|
|
30
|
-
(row) => row.components.filter((c) => c.type === discord_js.ComponentType.
|
|
30
|
+
(row) => row.components.filter((c) => c.type === discord_js.ComponentType.MentionableSelect)
|
|
31
31
|
);
|
|
32
32
|
return {
|
|
33
33
|
getButton(customId) {
|
|
@@ -25,7 +25,7 @@ function createComponentsManager(components) {
|
|
|
25
25
|
(row) => row.components.filter((c) => c.type === ComponentType.RoleSelect)
|
|
26
26
|
);
|
|
27
27
|
const mentionableSelects = components.flatMap(
|
|
28
|
-
(row) => row.components.filter((c) => c.type === ComponentType.
|
|
28
|
+
(row) => row.components.filter((c) => c.type === ComponentType.MentionableSelect)
|
|
29
29
|
);
|
|
30
30
|
return {
|
|
31
31
|
getButton(customId) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
function createEmbedAuthor(options) {
|
|
4
|
-
const { prefix, suffix, url, iconURL } = options;
|
|
4
|
+
const { prefix = "", suffix = "", url, iconURL } = options;
|
|
5
5
|
const { size = 512, extension, forceStatic } = options;
|
|
6
6
|
const avatarOptions = { size, extension, forceStatic };
|
|
7
7
|
if ("member" in options) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function createEmbedAuthor(options) {
|
|
2
|
-
const { prefix, suffix, url, iconURL } = options;
|
|
2
|
+
const { prefix = "", suffix = "", url, iconURL } = options;
|
|
3
3
|
const { size = 512, extension, forceStatic } = options;
|
|
4
4
|
const avatarOptions = { size, extension, forceStatic };
|
|
5
5
|
if ("member" in options) {
|
|
@@ -4,36 +4,44 @@ const discord_js = require('discord.js');
|
|
|
4
4
|
const chars = require('../../constants/chars.cjs');
|
|
5
5
|
const assets = require('./assets.cjs');
|
|
6
6
|
const footer = require('./footer.cjs');
|
|
7
|
+
const fields = require('./fields.cjs');
|
|
7
8
|
|
|
9
|
+
var __defProp = Object.defineProperty;
|
|
10
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
+
var __publicField = (obj, key, value) => {
|
|
12
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
13
|
+
return value;
|
|
14
|
+
};
|
|
8
15
|
class EmbedPlusBuilder extends discord_js.EmbedBuilder {
|
|
9
16
|
constructor(data) {
|
|
10
17
|
const extendsEmbed = data.extends ? new EmbedPlusBuilder(
|
|
11
18
|
data.extends instanceof discord_js.Embed || data.extends instanceof discord_js.EmbedBuilder ? data.extends.data : data.extends
|
|
12
19
|
).data : {};
|
|
13
|
-
const { fields: extendsFields, ...
|
|
14
|
-
const
|
|
20
|
+
const { fields: extendsFields, ...extendData } = extendsEmbed;
|
|
21
|
+
const { mergeFields = true } = data;
|
|
22
|
+
const fields$1 = (mergeFields ? [extendsFields ?? [], data.fields ?? []].flat() : data.fields ?? extendsFields ?? []).map(({ name = chars.chars.invisible, value = chars.chars.invisible, inline }) => ({
|
|
15
23
|
name,
|
|
16
24
|
value,
|
|
17
25
|
inline
|
|
18
26
|
}));
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
});
|
|
30
|
-
if (data.timestamp)
|
|
27
|
+
const builderData = Object.assign({}, extendData, data, { fields: fields$1 });
|
|
28
|
+
const { color, footer: footer$1, image, thumbnail, timestamp } = data;
|
|
29
|
+
if (footer$1)
|
|
30
|
+
Object.assign(builderData, { footer: footer.createEmbedFooter(footer$1) });
|
|
31
|
+
if (image)
|
|
32
|
+
Object.assign(builderData, { image: assets.createEmbedAsset(image) });
|
|
33
|
+
if (thumbnail)
|
|
34
|
+
Object.assign(builderData, { thumbnail: assets.createEmbedAsset(thumbnail) });
|
|
35
|
+
const embed = new discord_js.EmbedBuilder(builderData);
|
|
36
|
+
if (timestamp)
|
|
31
37
|
embed.setTimestamp(
|
|
32
|
-
typeof
|
|
38
|
+
typeof timestamp === "string" ? new Date(timestamp) : timestamp
|
|
33
39
|
);
|
|
34
|
-
if (
|
|
35
|
-
embed.setColor(
|
|
40
|
+
if (color)
|
|
41
|
+
embed.setColor(color);
|
|
36
42
|
super(embed.data);
|
|
43
|
+
__publicField(this, "fields");
|
|
44
|
+
this.fields = new fields.EmbedPlusField(this);
|
|
37
45
|
}
|
|
38
46
|
has(property) {
|
|
39
47
|
return Boolean(this.data[property]);
|
|
@@ -44,31 +52,6 @@ class EmbedPlusBuilder extends discord_js.EmbedBuilder {
|
|
|
44
52
|
toString(space = 2) {
|
|
45
53
|
return JSON.stringify(this, null, space);
|
|
46
54
|
}
|
|
47
|
-
updateField(index, field) {
|
|
48
|
-
if (this.fields.at(index)) {
|
|
49
|
-
const fields = Array.from(this.fields);
|
|
50
|
-
if (field.name)
|
|
51
|
-
fields[index].name = field.name;
|
|
52
|
-
if (field.value)
|
|
53
|
-
fields[index].value = field.value;
|
|
54
|
-
if (field.inline)
|
|
55
|
-
fields[index].inline = field.inline;
|
|
56
|
-
this.setFields(fields);
|
|
57
|
-
}
|
|
58
|
-
return this;
|
|
59
|
-
}
|
|
60
|
-
deleteField(index) {
|
|
61
|
-
if (this.fields.at(index)) {
|
|
62
|
-
this.setFields(this.fields.toSpliced(index, 1));
|
|
63
|
-
}
|
|
64
|
-
return this;
|
|
65
|
-
}
|
|
66
|
-
popField() {
|
|
67
|
-
const fields = Array.from(this.fields);
|
|
68
|
-
const field = fields.pop();
|
|
69
|
-
this.setFields(fields);
|
|
70
|
-
return field;
|
|
71
|
-
}
|
|
72
55
|
setAsset(asset, source) {
|
|
73
56
|
const assetData = assets.createEmbedAsset(source);
|
|
74
57
|
if (!assetData?.url)
|
|
@@ -76,16 +59,16 @@ class EmbedPlusBuilder extends discord_js.EmbedBuilder {
|
|
|
76
59
|
asset === "image" ? this.setImage(assetData.url) : this.setThumbnail(assetData.url);
|
|
77
60
|
return this;
|
|
78
61
|
}
|
|
79
|
-
|
|
80
|
-
return
|
|
62
|
+
static fromInteraction(interaction, index = 0, data = {}) {
|
|
63
|
+
return EmbedPlusBuilder.fromMessage(interaction.message, index, data);
|
|
81
64
|
}
|
|
82
|
-
|
|
83
|
-
return
|
|
65
|
+
static fromMessage(message, index = 0, data = {}) {
|
|
66
|
+
return new EmbedPlusBuilder(Object.assign({ extends: message.embeds[index] }, data));
|
|
84
67
|
}
|
|
85
68
|
}
|
|
86
69
|
function createEmbed(options) {
|
|
87
|
-
const { array = false, ...data } = options;
|
|
88
|
-
const embed = new EmbedPlusBuilder(data);
|
|
70
|
+
const { array = false, interaction, ...data } = options;
|
|
71
|
+
const embed = interaction ? EmbedPlusBuilder.fromInteraction(interaction, 0, data) : new EmbedPlusBuilder(data);
|
|
89
72
|
return array ? [embed] : embed;
|
|
90
73
|
}
|
|
91
74
|
|
|
@@ -2,36 +2,44 @@ import { EmbedBuilder, Embed } from 'discord.js';
|
|
|
2
2
|
import { chars } from '../../constants/chars.mjs';
|
|
3
3
|
import { createEmbedAsset } from './assets.mjs';
|
|
4
4
|
import { createEmbedFooter } from './footer.mjs';
|
|
5
|
+
import { EmbedPlusField } from './fields.mjs';
|
|
5
6
|
|
|
7
|
+
var __defProp = Object.defineProperty;
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
+
var __publicField = (obj, key, value) => {
|
|
10
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
11
|
+
return value;
|
|
12
|
+
};
|
|
6
13
|
class EmbedPlusBuilder extends EmbedBuilder {
|
|
7
14
|
constructor(data) {
|
|
8
15
|
const extendsEmbed = data.extends ? new EmbedPlusBuilder(
|
|
9
16
|
data.extends instanceof Embed || data.extends instanceof EmbedBuilder ? data.extends.data : data.extends
|
|
10
17
|
).data : {};
|
|
11
|
-
const { fields: extendsFields, ...
|
|
12
|
-
const
|
|
18
|
+
const { fields: extendsFields, ...extendData } = extendsEmbed;
|
|
19
|
+
const { mergeFields = true } = data;
|
|
20
|
+
const fields = (mergeFields ? [extendsFields ?? [], data.fields ?? []].flat() : data.fields ?? extendsFields ?? []).map(({ name = chars.invisible, value = chars.invisible, inline }) => ({
|
|
13
21
|
name,
|
|
14
22
|
value,
|
|
15
23
|
inline
|
|
16
24
|
}));
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
});
|
|
28
|
-
if (data.timestamp)
|
|
25
|
+
const builderData = Object.assign({}, extendData, data, { fields });
|
|
26
|
+
const { color, footer, image, thumbnail, timestamp } = data;
|
|
27
|
+
if (footer)
|
|
28
|
+
Object.assign(builderData, { footer: createEmbedFooter(footer) });
|
|
29
|
+
if (image)
|
|
30
|
+
Object.assign(builderData, { image: createEmbedAsset(image) });
|
|
31
|
+
if (thumbnail)
|
|
32
|
+
Object.assign(builderData, { thumbnail: createEmbedAsset(thumbnail) });
|
|
33
|
+
const embed = new EmbedBuilder(builderData);
|
|
34
|
+
if (timestamp)
|
|
29
35
|
embed.setTimestamp(
|
|
30
|
-
typeof
|
|
36
|
+
typeof timestamp === "string" ? new Date(timestamp) : timestamp
|
|
31
37
|
);
|
|
32
|
-
if (
|
|
33
|
-
embed.setColor(
|
|
38
|
+
if (color)
|
|
39
|
+
embed.setColor(color);
|
|
34
40
|
super(embed.data);
|
|
41
|
+
__publicField(this, "fields");
|
|
42
|
+
this.fields = new EmbedPlusField(this);
|
|
35
43
|
}
|
|
36
44
|
has(property) {
|
|
37
45
|
return Boolean(this.data[property]);
|
|
@@ -42,31 +50,6 @@ class EmbedPlusBuilder extends EmbedBuilder {
|
|
|
42
50
|
toString(space = 2) {
|
|
43
51
|
return JSON.stringify(this, null, space);
|
|
44
52
|
}
|
|
45
|
-
updateField(index, field) {
|
|
46
|
-
if (this.fields.at(index)) {
|
|
47
|
-
const fields = Array.from(this.fields);
|
|
48
|
-
if (field.name)
|
|
49
|
-
fields[index].name = field.name;
|
|
50
|
-
if (field.value)
|
|
51
|
-
fields[index].value = field.value;
|
|
52
|
-
if (field.inline)
|
|
53
|
-
fields[index].inline = field.inline;
|
|
54
|
-
this.setFields(fields);
|
|
55
|
-
}
|
|
56
|
-
return this;
|
|
57
|
-
}
|
|
58
|
-
deleteField(index) {
|
|
59
|
-
if (this.fields.at(index)) {
|
|
60
|
-
this.setFields(this.fields.toSpliced(index, 1));
|
|
61
|
-
}
|
|
62
|
-
return this;
|
|
63
|
-
}
|
|
64
|
-
popField() {
|
|
65
|
-
const fields = Array.from(this.fields);
|
|
66
|
-
const field = fields.pop();
|
|
67
|
-
this.setFields(fields);
|
|
68
|
-
return field;
|
|
69
|
-
}
|
|
70
53
|
setAsset(asset, source) {
|
|
71
54
|
const assetData = createEmbedAsset(source);
|
|
72
55
|
if (!assetData?.url)
|
|
@@ -74,16 +57,16 @@ class EmbedPlusBuilder extends EmbedBuilder {
|
|
|
74
57
|
asset === "image" ? this.setImage(assetData.url) : this.setThumbnail(assetData.url);
|
|
75
58
|
return this;
|
|
76
59
|
}
|
|
77
|
-
|
|
78
|
-
return
|
|
60
|
+
static fromInteraction(interaction, index = 0, data = {}) {
|
|
61
|
+
return EmbedPlusBuilder.fromMessage(interaction.message, index, data);
|
|
79
62
|
}
|
|
80
|
-
|
|
81
|
-
return
|
|
63
|
+
static fromMessage(message, index = 0, data = {}) {
|
|
64
|
+
return new EmbedPlusBuilder(Object.assign({ extends: message.embeds[index] }, data));
|
|
82
65
|
}
|
|
83
66
|
}
|
|
84
67
|
function createEmbed(options) {
|
|
85
|
-
const { array = false, ...data } = options;
|
|
86
|
-
const embed = new EmbedPlusBuilder(data);
|
|
68
|
+
const { array = false, interaction, ...data } = options;
|
|
69
|
+
const embed = interaction ? EmbedPlusBuilder.fromInteraction(interaction, 0, data) : new EmbedPlusBuilder(data);
|
|
87
70
|
return array ? [embed] : embed;
|
|
88
71
|
}
|
|
89
72
|
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5
|
+
var __publicField = (obj, key, value) => {
|
|
6
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
7
|
+
return value;
|
|
8
|
+
};
|
|
9
|
+
class EmbedPlusField {
|
|
10
|
+
constructor(embed) {
|
|
11
|
+
__publicField(this, "embed");
|
|
12
|
+
this.embed = embed;
|
|
13
|
+
}
|
|
14
|
+
set fields(fields) {
|
|
15
|
+
this.embed.setFields(fields);
|
|
16
|
+
}
|
|
17
|
+
get fields() {
|
|
18
|
+
return this.embed.data.fields ?? [];
|
|
19
|
+
}
|
|
20
|
+
[Symbol.iterator]() {
|
|
21
|
+
let pointer = 0;
|
|
22
|
+
const fields = this.fields;
|
|
23
|
+
return {
|
|
24
|
+
next() {
|
|
25
|
+
return {
|
|
26
|
+
done: pointer >= fields.length,
|
|
27
|
+
value: fields[pointer++] ?? null
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
get length() {
|
|
33
|
+
return this.fields.length;
|
|
34
|
+
}
|
|
35
|
+
get record() {
|
|
36
|
+
return this.fields.reduce(
|
|
37
|
+
(record, { name, value }) => Object.assign(record, { [name]: value }),
|
|
38
|
+
{}
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
get(query) {
|
|
42
|
+
const isIndex = typeof query == "number";
|
|
43
|
+
if (isIndex)
|
|
44
|
+
return this.fields[query];
|
|
45
|
+
return this.fields.find((f) => f.name === query);
|
|
46
|
+
}
|
|
47
|
+
find(predicate) {
|
|
48
|
+
return this.fields.find(predicate);
|
|
49
|
+
}
|
|
50
|
+
push(...fields) {
|
|
51
|
+
this.embed.addFields(fields);
|
|
52
|
+
}
|
|
53
|
+
set(...fields) {
|
|
54
|
+
this.embed.setFields(fields);
|
|
55
|
+
}
|
|
56
|
+
update(predicate, field) {
|
|
57
|
+
const index = this.getPredicateIndex(predicate);
|
|
58
|
+
if (index == -1)
|
|
59
|
+
return false;
|
|
60
|
+
const embedField = this.get(index);
|
|
61
|
+
if (!embedField)
|
|
62
|
+
return false;
|
|
63
|
+
this.embed.spliceFields(index, 1, Object.assign(embedField, field));
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
delete(predicate) {
|
|
67
|
+
const index = this.getPredicateIndex(predicate);
|
|
68
|
+
if (index == -1)
|
|
69
|
+
return false;
|
|
70
|
+
const embedField = this.get(index);
|
|
71
|
+
if (!embedField)
|
|
72
|
+
return false;
|
|
73
|
+
this.embed.spliceFields(index, 1);
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
toArray() {
|
|
77
|
+
return Array.from(this);
|
|
78
|
+
}
|
|
79
|
+
getPredicateIndex(predicate) {
|
|
80
|
+
switch (typeof predicate) {
|
|
81
|
+
case "function":
|
|
82
|
+
return this.fields.findIndex(predicate);
|
|
83
|
+
case "string":
|
|
84
|
+
return this.fields.findIndex((f) => f.name == predicate);
|
|
85
|
+
case "number":
|
|
86
|
+
return predicate;
|
|
87
|
+
default:
|
|
88
|
+
return -1;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
exports.EmbedPlusField = EmbedPlusField;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => {
|
|
4
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
return value;
|
|
6
|
+
};
|
|
7
|
+
class EmbedPlusField {
|
|
8
|
+
constructor(embed) {
|
|
9
|
+
__publicField(this, "embed");
|
|
10
|
+
this.embed = embed;
|
|
11
|
+
}
|
|
12
|
+
set fields(fields) {
|
|
13
|
+
this.embed.setFields(fields);
|
|
14
|
+
}
|
|
15
|
+
get fields() {
|
|
16
|
+
return this.embed.data.fields ?? [];
|
|
17
|
+
}
|
|
18
|
+
[Symbol.iterator]() {
|
|
19
|
+
let pointer = 0;
|
|
20
|
+
const fields = this.fields;
|
|
21
|
+
return {
|
|
22
|
+
next() {
|
|
23
|
+
return {
|
|
24
|
+
done: pointer >= fields.length,
|
|
25
|
+
value: fields[pointer++] ?? null
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
get length() {
|
|
31
|
+
return this.fields.length;
|
|
32
|
+
}
|
|
33
|
+
get record() {
|
|
34
|
+
return this.fields.reduce(
|
|
35
|
+
(record, { name, value }) => Object.assign(record, { [name]: value }),
|
|
36
|
+
{}
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
get(query) {
|
|
40
|
+
const isIndex = typeof query == "number";
|
|
41
|
+
if (isIndex)
|
|
42
|
+
return this.fields[query];
|
|
43
|
+
return this.fields.find((f) => f.name === query);
|
|
44
|
+
}
|
|
45
|
+
find(predicate) {
|
|
46
|
+
return this.fields.find(predicate);
|
|
47
|
+
}
|
|
48
|
+
push(...fields) {
|
|
49
|
+
this.embed.addFields(fields);
|
|
50
|
+
}
|
|
51
|
+
set(...fields) {
|
|
52
|
+
this.embed.setFields(fields);
|
|
53
|
+
}
|
|
54
|
+
update(predicate, field) {
|
|
55
|
+
const index = this.getPredicateIndex(predicate);
|
|
56
|
+
if (index == -1)
|
|
57
|
+
return false;
|
|
58
|
+
const embedField = this.get(index);
|
|
59
|
+
if (!embedField)
|
|
60
|
+
return false;
|
|
61
|
+
this.embed.spliceFields(index, 1, Object.assign(embedField, field));
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
delete(predicate) {
|
|
65
|
+
const index = this.getPredicateIndex(predicate);
|
|
66
|
+
if (index == -1)
|
|
67
|
+
return false;
|
|
68
|
+
const embedField = this.get(index);
|
|
69
|
+
if (!embedField)
|
|
70
|
+
return false;
|
|
71
|
+
this.embed.spliceFields(index, 1);
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
toArray() {
|
|
75
|
+
return Array.from(this);
|
|
76
|
+
}
|
|
77
|
+
getPredicateIndex(predicate) {
|
|
78
|
+
switch (typeof predicate) {
|
|
79
|
+
case "function":
|
|
80
|
+
return this.fields.findIndex(predicate);
|
|
81
|
+
case "string":
|
|
82
|
+
return this.fields.findIndex((f) => f.name == predicate);
|
|
83
|
+
case "number":
|
|
84
|
+
return predicate;
|
|
85
|
+
default:
|
|
86
|
+
return -1;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export { EmbedPlusField };
|
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
function findMember(guild) {
|
|
4
|
+
const cache = guild.members.cache;
|
|
4
5
|
return {
|
|
5
6
|
byGlobalName(globalName, and = () => true) {
|
|
6
|
-
return
|
|
7
|
+
return cache.find((member) => member.user.globalName == globalName && and(member));
|
|
7
8
|
},
|
|
8
9
|
byNickname(nickname, and = () => true) {
|
|
9
|
-
return
|
|
10
|
+
return cache.find((member) => member.nickname && member.nickname == nickname && and(member));
|
|
10
11
|
},
|
|
11
12
|
byUsername(username, and = () => true) {
|
|
12
|
-
return
|
|
13
|
+
return cache.find((member) => member.user.username === username && and(member));
|
|
13
14
|
},
|
|
14
15
|
byDisplayName(displayName, and = () => true) {
|
|
15
|
-
return
|
|
16
|
+
return cache.find((member) => member.displayName === displayName && and(member));
|
|
16
17
|
},
|
|
17
18
|
byId(id) {
|
|
18
|
-
return
|
|
19
|
+
return cache.get(id);
|
|
19
20
|
},
|
|
20
21
|
byFilter(filter) {
|
|
21
|
-
return
|
|
22
|
+
return cache.find(filter);
|
|
22
23
|
}
|
|
23
24
|
};
|
|
24
25
|
}
|
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
function findMember(guild) {
|
|
2
|
+
const cache = guild.members.cache;
|
|
2
3
|
return {
|
|
3
4
|
byGlobalName(globalName, and = () => true) {
|
|
4
|
-
return
|
|
5
|
+
return cache.find((member) => member.user.globalName == globalName && and(member));
|
|
5
6
|
},
|
|
6
7
|
byNickname(nickname, and = () => true) {
|
|
7
|
-
return
|
|
8
|
+
return cache.find((member) => member.nickname && member.nickname == nickname && and(member));
|
|
8
9
|
},
|
|
9
10
|
byUsername(username, and = () => true) {
|
|
10
|
-
return
|
|
11
|
+
return cache.find((member) => member.user.username === username && and(member));
|
|
11
12
|
},
|
|
12
13
|
byDisplayName(displayName, and = () => true) {
|
|
13
|
-
return
|
|
14
|
+
return cache.find((member) => member.displayName === displayName && and(member));
|
|
14
15
|
},
|
|
15
16
|
byId(id) {
|
|
16
|
-
return
|
|
17
|
+
return cache.get(id);
|
|
17
18
|
},
|
|
18
19
|
byFilter(filter) {
|
|
19
|
-
return
|
|
20
|
+
return cache.find(filter);
|
|
20
21
|
}
|
|
21
22
|
};
|
|
22
23
|
}
|
|
@@ -8,7 +8,7 @@ function createModalInput(data) {
|
|
|
8
8
|
}
|
|
9
9
|
function createModalFields(data) {
|
|
10
10
|
return Object.entries(data).map(
|
|
11
|
-
([customId, data2]) => createModalInput({ customId,
|
|
11
|
+
([customId, data2]) => createModalInput(Object.assign({ customId }, data2))
|
|
12
12
|
);
|
|
13
13
|
}
|
|
14
14
|
|
|
@@ -6,7 +6,7 @@ function createModalInput(data) {
|
|
|
6
6
|
}
|
|
7
7
|
function createModalFields(data) {
|
|
8
8
|
return Object.entries(data).map(
|
|
9
|
-
([customId, data2]) => createModalInput({ customId,
|
|
9
|
+
([customId, data2]) => createModalInput(Object.assign({ customId }, data2))
|
|
10
10
|
);
|
|
11
11
|
}
|
|
12
12
|
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as discord_js from 'discord.js';
|
|
2
|
-
import { GatewayIntentBits, Partials, ChannelType, Guild, CommandInteractionOption, Client, ApplicationCommand, AnyComponentBuilder, ActionRowBuilder, ButtonBuilder, ActionRow, MessageActionRowComponent, LinkButtonComponentData, ButtonComponent, StringSelectMenuComponent, UserSelectMenuComponent, ChannelSelectMenuComponent, RoleSelectMenuComponent, MentionableSelectMenuComponent, TextInputBuilder, TextInputComponentData, GuildEmoji, GuildBasedChannel, Role, User, GuildMember, GuildTextBasedChannel, Message, Attachment, AttachmentBuilder, EmbedAssetData, EmbedAuthorData, ImageURLOptions,
|
|
2
|
+
import { GatewayIntentBits, Partials, ChannelType, Guild, CommandInteractionOption, Client, ApplicationCommand, AnyComponentBuilder, ActionRowBuilder, ButtonBuilder, ActionRow, MessageActionRowComponent, LinkButtonComponentData, ButtonComponent, StringSelectMenuComponent, UserSelectMenuComponent, ChannelSelectMenuComponent, RoleSelectMenuComponent, MentionableSelectMenuComponent, TextInputBuilder, TextInputComponentData, GuildEmoji, GuildBasedChannel, Role, User, GuildMember, GuildTextBasedChannel, Message, Attachment, AttachmentBuilder, EmbedAssetData, EmbedAuthorData, ImageURLOptions, EmbedFooterData, APIEmbed, Embed, EmbedBuilder, EmbedData, ColorResolvable } from 'discord.js';
|
|
3
3
|
export * from '@magicyan/core';
|
|
4
4
|
|
|
5
5
|
declare const chars: {
|
|
@@ -163,9 +163,9 @@ declare function findRole(guild: Guild): {
|
|
|
163
163
|
*/
|
|
164
164
|
declare function extractMentionId(mention: string): string | null;
|
|
165
165
|
|
|
166
|
+
type EmbedPlusAssetData = string | Attachment | AttachmentBuilder | EmbedAssetData | undefined | null;
|
|
166
167
|
type EmbedAssetOptions = Omit<EmbedAssetData, "url">;
|
|
167
|
-
|
|
168
|
-
declare function createEmbedAsset(source: AssetSource, options?: EmbedAssetOptions): EmbedAssetData | undefined;
|
|
168
|
+
declare function createEmbedAsset(source: EmbedPlusAssetData, options?: EmbedAssetOptions): EmbedAssetData | undefined;
|
|
169
169
|
|
|
170
170
|
interface UserAuthorOption {
|
|
171
171
|
user: User;
|
|
@@ -184,17 +184,48 @@ type CreateEmbedAuthorOptions = AuthorOption & ImageURLOptions & {
|
|
|
184
184
|
};
|
|
185
185
|
declare function createEmbedAuthor(options: CreateEmbedAuthorOptions): EmbedAuthorData;
|
|
186
186
|
|
|
187
|
-
type
|
|
188
|
-
|
|
187
|
+
type EmbedPlusFooterData = {
|
|
188
|
+
text?: string | null;
|
|
189
|
+
iconURL?: string | null;
|
|
190
|
+
};
|
|
191
|
+
declare function createEmbedFooter(options: EmbedPlusFooterData): EmbedFooterData | undefined;
|
|
192
|
+
|
|
189
193
|
type EmbedPlusFieldData = {
|
|
190
194
|
name: string;
|
|
191
195
|
value: string;
|
|
192
196
|
inline?: boolean;
|
|
193
197
|
};
|
|
194
|
-
type
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
+
type FieldPredicate = (field: EmbedPlusFieldData, index: number, obj: EmbedPlusFieldData[]) => boolean;
|
|
199
|
+
declare class EmbedPlusField {
|
|
200
|
+
private embed;
|
|
201
|
+
private set fields(value);
|
|
202
|
+
private get fields();
|
|
203
|
+
constructor(embed: EmbedPlusBuilder);
|
|
204
|
+
[Symbol.iterator](): {
|
|
205
|
+
next(): IteratorResult<EmbedPlusFieldData>;
|
|
206
|
+
};
|
|
207
|
+
get length(): number;
|
|
208
|
+
get record(): Record<string, string>;
|
|
209
|
+
/**
|
|
210
|
+
* Get a filed by index
|
|
211
|
+
* @param name Field name
|
|
212
|
+
*/
|
|
213
|
+
get(name: string): EmbedPlusFieldData | undefined;
|
|
214
|
+
/**
|
|
215
|
+
* Get a field by name
|
|
216
|
+
* @param index Field index
|
|
217
|
+
*/
|
|
218
|
+
get(index: number): EmbedPlusFieldData | undefined;
|
|
219
|
+
find(predicate: FieldPredicate): EmbedPlusFieldData | undefined;
|
|
220
|
+
push(...fields: EmbedPlusFieldData[]): void;
|
|
221
|
+
set(...fields: EmbedPlusFieldData[]): void;
|
|
222
|
+
update(predicate: string | number | FieldPredicate, field: Partial<EmbedPlusFieldData>): boolean;
|
|
223
|
+
delete(predicate: number | FieldPredicate): boolean;
|
|
224
|
+
toArray(): EmbedPlusFieldData[];
|
|
225
|
+
private getPredicateIndex;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
type EmbedPlusColorData = string & {} | ColorResolvable | null;
|
|
198
229
|
type EmbedPlusAuthorData = {
|
|
199
230
|
name: string;
|
|
200
231
|
url?: string;
|
|
@@ -205,40 +236,40 @@ interface EmbedPlusData {
|
|
|
205
236
|
color?: EmbedPlusColorData | null;
|
|
206
237
|
description?: string | null;
|
|
207
238
|
url?: string | null;
|
|
208
|
-
thumbnail?: EmbedPlusAssetData
|
|
209
|
-
image?: EmbedPlusAssetData
|
|
239
|
+
thumbnail?: EmbedPlusAssetData;
|
|
240
|
+
image?: EmbedPlusAssetData;
|
|
210
241
|
fields?: Partial<EmbedPlusFieldData>[] | null;
|
|
211
242
|
timestamp?: string | number | Date | null;
|
|
212
243
|
footer?: EmbedPlusFooterData;
|
|
213
244
|
author?: EmbedPlusAuthorData;
|
|
214
245
|
}
|
|
246
|
+
type AnyEmbed = APIEmbed | Embed | EmbedBuilder | EmbedData;
|
|
247
|
+
interface MessageWithEmbeds {
|
|
248
|
+
embeds: Array<Embed>;
|
|
249
|
+
}
|
|
250
|
+
interface InteractionWithEmbeds {
|
|
251
|
+
message: MessageWithEmbeds;
|
|
252
|
+
}
|
|
215
253
|
interface EmbedPlusOptions extends EmbedPlusData {
|
|
216
|
-
extends?: Omit<EmbedPlusData, keyof EmbedPlusOptions> |
|
|
254
|
+
extends?: Omit<EmbedPlusData, keyof EmbedPlusOptions> | AnyEmbed;
|
|
217
255
|
mergeFields?: boolean;
|
|
218
256
|
}
|
|
219
257
|
declare class EmbedPlusBuilder extends EmbedBuilder {
|
|
258
|
+
fields: EmbedPlusField;
|
|
220
259
|
constructor(data: EmbedPlusOptions);
|
|
221
260
|
has(property: keyof Omit<EmbedPlusData, keyof EmbedPlusOptions>): boolean;
|
|
222
|
-
toArray():
|
|
261
|
+
toArray(): EmbedPlusBuilder[];
|
|
223
262
|
toString(space?: number): string;
|
|
224
|
-
updateField(index: number, field: Partial<EmbedPlusFieldData>): this;
|
|
225
|
-
deleteField(index: number): this;
|
|
226
|
-
popField(): discord_js.APIEmbedField | undefined;
|
|
227
263
|
setAsset(asset: "thumbnail" | "image", source: EmbedPlusAssetData): this;
|
|
228
|
-
|
|
229
|
-
|
|
264
|
+
static fromInteraction(interaction: InteractionWithEmbeds, index?: number, data?: EmbedPlusData): EmbedPlusBuilder;
|
|
265
|
+
static fromMessage(message: MessageWithEmbeds, index?: number, data?: EmbedPlusData): EmbedPlusBuilder;
|
|
230
266
|
}
|
|
231
267
|
type EmbedPlusProperty<P extends keyof EmbedPlusData> = EmbedPlusData[P];
|
|
232
268
|
interface CreateEmbedOptions<B extends boolean> extends EmbedPlusOptions {
|
|
233
269
|
array?: B;
|
|
270
|
+
interaction?: InteractionWithEmbeds;
|
|
234
271
|
}
|
|
235
272
|
type CreateEmbedReturn<B> = undefined extends B ? EmbedPlusBuilder : false extends B ? EmbedPlusBuilder : EmbedPlusBuilder[];
|
|
236
273
|
declare function createEmbed<B extends boolean>(options: CreateEmbedOptions<B>): CreateEmbedReturn<B>;
|
|
237
274
|
|
|
238
|
-
|
|
239
|
-
text?: string | null;
|
|
240
|
-
iconURL?: string | null;
|
|
241
|
-
}
|
|
242
|
-
declare function createEmbedFooter(options: CreateEmbedFooterOptions): EmbedFooterData | undefined;
|
|
243
|
-
|
|
244
|
-
export { type AssetSource, CustomItents, CustomPartials, EmbedPlusBuilder, type EmbedPlusProperty, chars, createComponentsManager, createEmbed, createEmbedAsset, createEmbedAuthor, createEmbedFooter, createLinkButton, createModalFields, createModalInput, createRow, extractMentionId, findChannel, findCommand, findEmoji, findMember, findMessage, findRole, formatedMention, getChannelUrlInfo, getMessageUrlInfo, setMobileStatus };
|
|
275
|
+
export { type AnyEmbed, CustomItents, CustomPartials, type EmbedPlusAssetData, EmbedPlusBuilder, type EmbedPlusData, type EmbedPlusFooterData, type EmbedPlusProperty, chars, createComponentsManager, createEmbed, createEmbedAsset, createEmbedAuthor, createEmbedFooter, createLinkButton, createModalFields, createModalInput, createRow, extractMentionId, findChannel, findCommand, findEmoji, findMember, findMessage, findRole, formatedMention, getChannelUrlInfo, getMessageUrlInfo, setMobileStatus };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as discord_js from 'discord.js';
|
|
2
|
-
import { GatewayIntentBits, Partials, ChannelType, Guild, CommandInteractionOption, Client, ApplicationCommand, AnyComponentBuilder, ActionRowBuilder, ButtonBuilder, ActionRow, MessageActionRowComponent, LinkButtonComponentData, ButtonComponent, StringSelectMenuComponent, UserSelectMenuComponent, ChannelSelectMenuComponent, RoleSelectMenuComponent, MentionableSelectMenuComponent, TextInputBuilder, TextInputComponentData, GuildEmoji, GuildBasedChannel, Role, User, GuildMember, GuildTextBasedChannel, Message, Attachment, AttachmentBuilder, EmbedAssetData, EmbedAuthorData, ImageURLOptions,
|
|
2
|
+
import { GatewayIntentBits, Partials, ChannelType, Guild, CommandInteractionOption, Client, ApplicationCommand, AnyComponentBuilder, ActionRowBuilder, ButtonBuilder, ActionRow, MessageActionRowComponent, LinkButtonComponentData, ButtonComponent, StringSelectMenuComponent, UserSelectMenuComponent, ChannelSelectMenuComponent, RoleSelectMenuComponent, MentionableSelectMenuComponent, TextInputBuilder, TextInputComponentData, GuildEmoji, GuildBasedChannel, Role, User, GuildMember, GuildTextBasedChannel, Message, Attachment, AttachmentBuilder, EmbedAssetData, EmbedAuthorData, ImageURLOptions, EmbedFooterData, APIEmbed, Embed, EmbedBuilder, EmbedData, ColorResolvable } from 'discord.js';
|
|
3
3
|
export * from '@magicyan/core';
|
|
4
4
|
|
|
5
5
|
declare const chars: {
|
|
@@ -163,9 +163,9 @@ declare function findRole(guild: Guild): {
|
|
|
163
163
|
*/
|
|
164
164
|
declare function extractMentionId(mention: string): string | null;
|
|
165
165
|
|
|
166
|
+
type EmbedPlusAssetData = string | Attachment | AttachmentBuilder | EmbedAssetData | undefined | null;
|
|
166
167
|
type EmbedAssetOptions = Omit<EmbedAssetData, "url">;
|
|
167
|
-
|
|
168
|
-
declare function createEmbedAsset(source: AssetSource, options?: EmbedAssetOptions): EmbedAssetData | undefined;
|
|
168
|
+
declare function createEmbedAsset(source: EmbedPlusAssetData, options?: EmbedAssetOptions): EmbedAssetData | undefined;
|
|
169
169
|
|
|
170
170
|
interface UserAuthorOption {
|
|
171
171
|
user: User;
|
|
@@ -184,17 +184,48 @@ type CreateEmbedAuthorOptions = AuthorOption & ImageURLOptions & {
|
|
|
184
184
|
};
|
|
185
185
|
declare function createEmbedAuthor(options: CreateEmbedAuthorOptions): EmbedAuthorData;
|
|
186
186
|
|
|
187
|
-
type
|
|
188
|
-
|
|
187
|
+
type EmbedPlusFooterData = {
|
|
188
|
+
text?: string | null;
|
|
189
|
+
iconURL?: string | null;
|
|
190
|
+
};
|
|
191
|
+
declare function createEmbedFooter(options: EmbedPlusFooterData): EmbedFooterData | undefined;
|
|
192
|
+
|
|
189
193
|
type EmbedPlusFieldData = {
|
|
190
194
|
name: string;
|
|
191
195
|
value: string;
|
|
192
196
|
inline?: boolean;
|
|
193
197
|
};
|
|
194
|
-
type
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
+
type FieldPredicate = (field: EmbedPlusFieldData, index: number, obj: EmbedPlusFieldData[]) => boolean;
|
|
199
|
+
declare class EmbedPlusField {
|
|
200
|
+
private embed;
|
|
201
|
+
private set fields(value);
|
|
202
|
+
private get fields();
|
|
203
|
+
constructor(embed: EmbedPlusBuilder);
|
|
204
|
+
[Symbol.iterator](): {
|
|
205
|
+
next(): IteratorResult<EmbedPlusFieldData>;
|
|
206
|
+
};
|
|
207
|
+
get length(): number;
|
|
208
|
+
get record(): Record<string, string>;
|
|
209
|
+
/**
|
|
210
|
+
* Get a filed by index
|
|
211
|
+
* @param name Field name
|
|
212
|
+
*/
|
|
213
|
+
get(name: string): EmbedPlusFieldData | undefined;
|
|
214
|
+
/**
|
|
215
|
+
* Get a field by name
|
|
216
|
+
* @param index Field index
|
|
217
|
+
*/
|
|
218
|
+
get(index: number): EmbedPlusFieldData | undefined;
|
|
219
|
+
find(predicate: FieldPredicate): EmbedPlusFieldData | undefined;
|
|
220
|
+
push(...fields: EmbedPlusFieldData[]): void;
|
|
221
|
+
set(...fields: EmbedPlusFieldData[]): void;
|
|
222
|
+
update(predicate: string | number | FieldPredicate, field: Partial<EmbedPlusFieldData>): boolean;
|
|
223
|
+
delete(predicate: number | FieldPredicate): boolean;
|
|
224
|
+
toArray(): EmbedPlusFieldData[];
|
|
225
|
+
private getPredicateIndex;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
type EmbedPlusColorData = string & {} | ColorResolvable | null;
|
|
198
229
|
type EmbedPlusAuthorData = {
|
|
199
230
|
name: string;
|
|
200
231
|
url?: string;
|
|
@@ -205,40 +236,40 @@ interface EmbedPlusData {
|
|
|
205
236
|
color?: EmbedPlusColorData | null;
|
|
206
237
|
description?: string | null;
|
|
207
238
|
url?: string | null;
|
|
208
|
-
thumbnail?: EmbedPlusAssetData
|
|
209
|
-
image?: EmbedPlusAssetData
|
|
239
|
+
thumbnail?: EmbedPlusAssetData;
|
|
240
|
+
image?: EmbedPlusAssetData;
|
|
210
241
|
fields?: Partial<EmbedPlusFieldData>[] | null;
|
|
211
242
|
timestamp?: string | number | Date | null;
|
|
212
243
|
footer?: EmbedPlusFooterData;
|
|
213
244
|
author?: EmbedPlusAuthorData;
|
|
214
245
|
}
|
|
246
|
+
type AnyEmbed = APIEmbed | Embed | EmbedBuilder | EmbedData;
|
|
247
|
+
interface MessageWithEmbeds {
|
|
248
|
+
embeds: Array<Embed>;
|
|
249
|
+
}
|
|
250
|
+
interface InteractionWithEmbeds {
|
|
251
|
+
message: MessageWithEmbeds;
|
|
252
|
+
}
|
|
215
253
|
interface EmbedPlusOptions extends EmbedPlusData {
|
|
216
|
-
extends?: Omit<EmbedPlusData, keyof EmbedPlusOptions> |
|
|
254
|
+
extends?: Omit<EmbedPlusData, keyof EmbedPlusOptions> | AnyEmbed;
|
|
217
255
|
mergeFields?: boolean;
|
|
218
256
|
}
|
|
219
257
|
declare class EmbedPlusBuilder extends EmbedBuilder {
|
|
258
|
+
fields: EmbedPlusField;
|
|
220
259
|
constructor(data: EmbedPlusOptions);
|
|
221
260
|
has(property: keyof Omit<EmbedPlusData, keyof EmbedPlusOptions>): boolean;
|
|
222
|
-
toArray():
|
|
261
|
+
toArray(): EmbedPlusBuilder[];
|
|
223
262
|
toString(space?: number): string;
|
|
224
|
-
updateField(index: number, field: Partial<EmbedPlusFieldData>): this;
|
|
225
|
-
deleteField(index: number): this;
|
|
226
|
-
popField(): discord_js.APIEmbedField | undefined;
|
|
227
263
|
setAsset(asset: "thumbnail" | "image", source: EmbedPlusAssetData): this;
|
|
228
|
-
|
|
229
|
-
|
|
264
|
+
static fromInteraction(interaction: InteractionWithEmbeds, index?: number, data?: EmbedPlusData): EmbedPlusBuilder;
|
|
265
|
+
static fromMessage(message: MessageWithEmbeds, index?: number, data?: EmbedPlusData): EmbedPlusBuilder;
|
|
230
266
|
}
|
|
231
267
|
type EmbedPlusProperty<P extends keyof EmbedPlusData> = EmbedPlusData[P];
|
|
232
268
|
interface CreateEmbedOptions<B extends boolean> extends EmbedPlusOptions {
|
|
233
269
|
array?: B;
|
|
270
|
+
interaction?: InteractionWithEmbeds;
|
|
234
271
|
}
|
|
235
272
|
type CreateEmbedReturn<B> = undefined extends B ? EmbedPlusBuilder : false extends B ? EmbedPlusBuilder : EmbedPlusBuilder[];
|
|
236
273
|
declare function createEmbed<B extends boolean>(options: CreateEmbedOptions<B>): CreateEmbedReturn<B>;
|
|
237
274
|
|
|
238
|
-
|
|
239
|
-
text?: string | null;
|
|
240
|
-
iconURL?: string | null;
|
|
241
|
-
}
|
|
242
|
-
declare function createEmbedFooter(options: CreateEmbedFooterOptions): EmbedFooterData | undefined;
|
|
243
|
-
|
|
244
|
-
export { type AssetSource, CustomItents, CustomPartials, EmbedPlusBuilder, type EmbedPlusProperty, chars, createComponentsManager, createEmbed, createEmbedAsset, createEmbedAuthor, createEmbedFooter, createLinkButton, createModalFields, createModalInput, createRow, extractMentionId, findChannel, findCommand, findEmoji, findMember, findMessage, findRole, formatedMention, getChannelUrlInfo, getMessageUrlInfo, setMobileStatus };
|
|
275
|
+
export { type AnyEmbed, CustomItents, CustomPartials, type EmbedPlusAssetData, EmbedPlusBuilder, type EmbedPlusData, type EmbedPlusFooterData, type EmbedPlusProperty, chars, createComponentsManager, createEmbed, createEmbedAsset, createEmbedAuthor, createEmbedFooter, createLinkButton, createModalFields, createModalInput, createRow, extractMentionId, findChannel, findCommand, findEmoji, findMember, findMessage, findRole, formatedMention, getChannelUrlInfo, getMessageUrlInfo, setMobileStatus };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as discord_js from 'discord.js';
|
|
2
|
-
import { GatewayIntentBits, Partials, ChannelType, Guild, CommandInteractionOption, Client, ApplicationCommand, AnyComponentBuilder, ActionRowBuilder, ButtonBuilder, ActionRow, MessageActionRowComponent, LinkButtonComponentData, ButtonComponent, StringSelectMenuComponent, UserSelectMenuComponent, ChannelSelectMenuComponent, RoleSelectMenuComponent, MentionableSelectMenuComponent, TextInputBuilder, TextInputComponentData, GuildEmoji, GuildBasedChannel, Role, User, GuildMember, GuildTextBasedChannel, Message, Attachment, AttachmentBuilder, EmbedAssetData, EmbedAuthorData, ImageURLOptions,
|
|
2
|
+
import { GatewayIntentBits, Partials, ChannelType, Guild, CommandInteractionOption, Client, ApplicationCommand, AnyComponentBuilder, ActionRowBuilder, ButtonBuilder, ActionRow, MessageActionRowComponent, LinkButtonComponentData, ButtonComponent, StringSelectMenuComponent, UserSelectMenuComponent, ChannelSelectMenuComponent, RoleSelectMenuComponent, MentionableSelectMenuComponent, TextInputBuilder, TextInputComponentData, GuildEmoji, GuildBasedChannel, Role, User, GuildMember, GuildTextBasedChannel, Message, Attachment, AttachmentBuilder, EmbedAssetData, EmbedAuthorData, ImageURLOptions, EmbedFooterData, APIEmbed, Embed, EmbedBuilder, EmbedData, ColorResolvable } from 'discord.js';
|
|
3
3
|
export * from '@magicyan/core';
|
|
4
4
|
|
|
5
5
|
declare const chars: {
|
|
@@ -163,9 +163,9 @@ declare function findRole(guild: Guild): {
|
|
|
163
163
|
*/
|
|
164
164
|
declare function extractMentionId(mention: string): string | null;
|
|
165
165
|
|
|
166
|
+
type EmbedPlusAssetData = string | Attachment | AttachmentBuilder | EmbedAssetData | undefined | null;
|
|
166
167
|
type EmbedAssetOptions = Omit<EmbedAssetData, "url">;
|
|
167
|
-
|
|
168
|
-
declare function createEmbedAsset(source: AssetSource, options?: EmbedAssetOptions): EmbedAssetData | undefined;
|
|
168
|
+
declare function createEmbedAsset(source: EmbedPlusAssetData, options?: EmbedAssetOptions): EmbedAssetData | undefined;
|
|
169
169
|
|
|
170
170
|
interface UserAuthorOption {
|
|
171
171
|
user: User;
|
|
@@ -184,17 +184,48 @@ type CreateEmbedAuthorOptions = AuthorOption & ImageURLOptions & {
|
|
|
184
184
|
};
|
|
185
185
|
declare function createEmbedAuthor(options: CreateEmbedAuthorOptions): EmbedAuthorData;
|
|
186
186
|
|
|
187
|
-
type
|
|
188
|
-
|
|
187
|
+
type EmbedPlusFooterData = {
|
|
188
|
+
text?: string | null;
|
|
189
|
+
iconURL?: string | null;
|
|
190
|
+
};
|
|
191
|
+
declare function createEmbedFooter(options: EmbedPlusFooterData): EmbedFooterData | undefined;
|
|
192
|
+
|
|
189
193
|
type EmbedPlusFieldData = {
|
|
190
194
|
name: string;
|
|
191
195
|
value: string;
|
|
192
196
|
inline?: boolean;
|
|
193
197
|
};
|
|
194
|
-
type
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
+
type FieldPredicate = (field: EmbedPlusFieldData, index: number, obj: EmbedPlusFieldData[]) => boolean;
|
|
199
|
+
declare class EmbedPlusField {
|
|
200
|
+
private embed;
|
|
201
|
+
private set fields(value);
|
|
202
|
+
private get fields();
|
|
203
|
+
constructor(embed: EmbedPlusBuilder);
|
|
204
|
+
[Symbol.iterator](): {
|
|
205
|
+
next(): IteratorResult<EmbedPlusFieldData>;
|
|
206
|
+
};
|
|
207
|
+
get length(): number;
|
|
208
|
+
get record(): Record<string, string>;
|
|
209
|
+
/**
|
|
210
|
+
* Get a filed by index
|
|
211
|
+
* @param name Field name
|
|
212
|
+
*/
|
|
213
|
+
get(name: string): EmbedPlusFieldData | undefined;
|
|
214
|
+
/**
|
|
215
|
+
* Get a field by name
|
|
216
|
+
* @param index Field index
|
|
217
|
+
*/
|
|
218
|
+
get(index: number): EmbedPlusFieldData | undefined;
|
|
219
|
+
find(predicate: FieldPredicate): EmbedPlusFieldData | undefined;
|
|
220
|
+
push(...fields: EmbedPlusFieldData[]): void;
|
|
221
|
+
set(...fields: EmbedPlusFieldData[]): void;
|
|
222
|
+
update(predicate: string | number | FieldPredicate, field: Partial<EmbedPlusFieldData>): boolean;
|
|
223
|
+
delete(predicate: number | FieldPredicate): boolean;
|
|
224
|
+
toArray(): EmbedPlusFieldData[];
|
|
225
|
+
private getPredicateIndex;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
type EmbedPlusColorData = string & {} | ColorResolvable | null;
|
|
198
229
|
type EmbedPlusAuthorData = {
|
|
199
230
|
name: string;
|
|
200
231
|
url?: string;
|
|
@@ -205,40 +236,40 @@ interface EmbedPlusData {
|
|
|
205
236
|
color?: EmbedPlusColorData | null;
|
|
206
237
|
description?: string | null;
|
|
207
238
|
url?: string | null;
|
|
208
|
-
thumbnail?: EmbedPlusAssetData
|
|
209
|
-
image?: EmbedPlusAssetData
|
|
239
|
+
thumbnail?: EmbedPlusAssetData;
|
|
240
|
+
image?: EmbedPlusAssetData;
|
|
210
241
|
fields?: Partial<EmbedPlusFieldData>[] | null;
|
|
211
242
|
timestamp?: string | number | Date | null;
|
|
212
243
|
footer?: EmbedPlusFooterData;
|
|
213
244
|
author?: EmbedPlusAuthorData;
|
|
214
245
|
}
|
|
246
|
+
type AnyEmbed = APIEmbed | Embed | EmbedBuilder | EmbedData;
|
|
247
|
+
interface MessageWithEmbeds {
|
|
248
|
+
embeds: Array<Embed>;
|
|
249
|
+
}
|
|
250
|
+
interface InteractionWithEmbeds {
|
|
251
|
+
message: MessageWithEmbeds;
|
|
252
|
+
}
|
|
215
253
|
interface EmbedPlusOptions extends EmbedPlusData {
|
|
216
|
-
extends?: Omit<EmbedPlusData, keyof EmbedPlusOptions> |
|
|
254
|
+
extends?: Omit<EmbedPlusData, keyof EmbedPlusOptions> | AnyEmbed;
|
|
217
255
|
mergeFields?: boolean;
|
|
218
256
|
}
|
|
219
257
|
declare class EmbedPlusBuilder extends EmbedBuilder {
|
|
258
|
+
fields: EmbedPlusField;
|
|
220
259
|
constructor(data: EmbedPlusOptions);
|
|
221
260
|
has(property: keyof Omit<EmbedPlusData, keyof EmbedPlusOptions>): boolean;
|
|
222
|
-
toArray():
|
|
261
|
+
toArray(): EmbedPlusBuilder[];
|
|
223
262
|
toString(space?: number): string;
|
|
224
|
-
updateField(index: number, field: Partial<EmbedPlusFieldData>): this;
|
|
225
|
-
deleteField(index: number): this;
|
|
226
|
-
popField(): discord_js.APIEmbedField | undefined;
|
|
227
263
|
setAsset(asset: "thumbnail" | "image", source: EmbedPlusAssetData): this;
|
|
228
|
-
|
|
229
|
-
|
|
264
|
+
static fromInteraction(interaction: InteractionWithEmbeds, index?: number, data?: EmbedPlusData): EmbedPlusBuilder;
|
|
265
|
+
static fromMessage(message: MessageWithEmbeds, index?: number, data?: EmbedPlusData): EmbedPlusBuilder;
|
|
230
266
|
}
|
|
231
267
|
type EmbedPlusProperty<P extends keyof EmbedPlusData> = EmbedPlusData[P];
|
|
232
268
|
interface CreateEmbedOptions<B extends boolean> extends EmbedPlusOptions {
|
|
233
269
|
array?: B;
|
|
270
|
+
interaction?: InteractionWithEmbeds;
|
|
234
271
|
}
|
|
235
272
|
type CreateEmbedReturn<B> = undefined extends B ? EmbedPlusBuilder : false extends B ? EmbedPlusBuilder : EmbedPlusBuilder[];
|
|
236
273
|
declare function createEmbed<B extends boolean>(options: CreateEmbedOptions<B>): CreateEmbedReturn<B>;
|
|
237
274
|
|
|
238
|
-
|
|
239
|
-
text?: string | null;
|
|
240
|
-
iconURL?: string | null;
|
|
241
|
-
}
|
|
242
|
-
declare function createEmbedFooter(options: CreateEmbedFooterOptions): EmbedFooterData | undefined;
|
|
243
|
-
|
|
244
|
-
export { type AssetSource, CustomItents, CustomPartials, EmbedPlusBuilder, type EmbedPlusProperty, chars, createComponentsManager, createEmbed, createEmbedAsset, createEmbedAuthor, createEmbedFooter, createLinkButton, createModalFields, createModalInput, createRow, extractMentionId, findChannel, findCommand, findEmoji, findMember, findMessage, findRole, formatedMention, getChannelUrlInfo, getMessageUrlInfo, setMobileStatus };
|
|
275
|
+
export { type AnyEmbed, CustomItents, CustomPartials, type EmbedPlusAssetData, EmbedPlusBuilder, type EmbedPlusData, type EmbedPlusFooterData, type EmbedPlusProperty, chars, createComponentsManager, createEmbed, createEmbedAsset, createEmbedAuthor, createEmbedFooter, createLinkButton, createModalFields, createModalInput, createRow, extractMentionId, findChannel, findCommand, findEmoji, findMember, findMessage, findRole, formatedMention, getChannelUrlInfo, getMessageUrlInfo, setMobileStatus };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magicyan/discord",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.25",
|
|
4
4
|
"description": "Simple functions to facilitate discord bot development",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"unbuild": "^2.0.0"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@magicyan/core": "^1.0.
|
|
42
|
+
"@magicyan/core": "^1.0.18"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"discord.js": "^14.14.1"
|