@magicyan/discord 1.0.35 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constants/colors.cjs +7 -0
- package/dist/constants/colors.mjs +5 -0
- package/dist/functions/embeds/embedplus.cjs +5 -11
- package/dist/functions/embeds/embedplus.mjs +5 -11
- package/dist/functions/embeds/fields.cjs +5 -0
- package/dist/functions/embeds/fields.mjs +5 -0
- package/dist/index.d.cts +5 -6
- package/dist/index.d.mts +5 -6
- package/dist/index.d.ts +5 -6
- package/package.json +1 -1
|
@@ -5,6 +5,7 @@ const assets = require('./assets.cjs');
|
|
|
5
5
|
const fields = require('./fields.cjs');
|
|
6
6
|
const footer = require('./footer.cjs');
|
|
7
7
|
const chars = require('../../constants/chars.cjs');
|
|
8
|
+
const colors = require('../../constants/colors.cjs');
|
|
8
9
|
|
|
9
10
|
var __defProp = Object.defineProperty;
|
|
10
11
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
@@ -36,8 +37,7 @@ class EmbedPlusBuilder extends discord_js.EmbedBuilder {
|
|
|
36
37
|
embed.setTimestamp(
|
|
37
38
|
typeof timestamp === "string" ? new Date(timestamp) : timestamp
|
|
38
39
|
);
|
|
39
|
-
|
|
40
|
-
embed.setColor(color);
|
|
40
|
+
embed.setColor(color || colors.colors.embedbg);
|
|
41
41
|
super(embed.data);
|
|
42
42
|
__publicField(this, "fields");
|
|
43
43
|
this.fields = new fields.EmbedPlusFields(this);
|
|
@@ -62,7 +62,7 @@ class EmbedPlusBuilder extends discord_js.EmbedBuilder {
|
|
|
62
62
|
}
|
|
63
63
|
setBorderColor(color) {
|
|
64
64
|
if (color === null) {
|
|
65
|
-
this.setColor(
|
|
65
|
+
this.setColor(colors.colors.embedbg);
|
|
66
66
|
} else if (typeof color === "number") {
|
|
67
67
|
this.update({ color });
|
|
68
68
|
} else {
|
|
@@ -100,17 +100,11 @@ class EmbedPlusBuilder extends discord_js.EmbedBuilder {
|
|
|
100
100
|
}
|
|
101
101
|
return this;
|
|
102
102
|
}
|
|
103
|
-
static fromInteraction(interaction, index = 0, data = {}) {
|
|
104
|
-
return EmbedPlusBuilder.fromMessage(interaction.message, index, data);
|
|
105
|
-
}
|
|
106
|
-
static fromMessage(message, index = 0, data = {}) {
|
|
107
|
-
return new EmbedPlusBuilder(Object.assign({ extends: message.embeds[index] }, data));
|
|
108
|
-
}
|
|
109
103
|
}
|
|
110
104
|
function createEmbed(options) {
|
|
111
105
|
const { array = false, from, fromIndex = 0, ...data } = options;
|
|
112
|
-
const
|
|
113
|
-
return array ? [
|
|
106
|
+
const fromEmbeds = from ? "message" in from ? from.message.embeds : from.embeds : [];
|
|
107
|
+
return array ? from && fromEmbeds.length > 0 ? fromEmbeds.map((embed) => new EmbedPlusBuilder({ extends: embed })) : [new EmbedPlusBuilder(data)] : from && fromEmbeds.length > 0 ? new EmbedPlusBuilder({ extends: fromEmbeds[fromIndex], ...data }) : new EmbedPlusBuilder(data);
|
|
114
108
|
}
|
|
115
109
|
|
|
116
110
|
exports.EmbedPlusBuilder = EmbedPlusBuilder;
|
|
@@ -3,6 +3,7 @@ import { createEmbedAsset } from './assets.mjs';
|
|
|
3
3
|
import { EmbedPlusFields } from './fields.mjs';
|
|
4
4
|
import { createEmbedFooter } from './footer.mjs';
|
|
5
5
|
import { chars } from '../../constants/chars.mjs';
|
|
6
|
+
import { colors } from '../../constants/colors.mjs';
|
|
6
7
|
|
|
7
8
|
var __defProp = Object.defineProperty;
|
|
8
9
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
@@ -34,8 +35,7 @@ class EmbedPlusBuilder extends EmbedBuilder {
|
|
|
34
35
|
embed.setTimestamp(
|
|
35
36
|
typeof timestamp === "string" ? new Date(timestamp) : timestamp
|
|
36
37
|
);
|
|
37
|
-
|
|
38
|
-
embed.setColor(color);
|
|
38
|
+
embed.setColor(color || colors.embedbg);
|
|
39
39
|
super(embed.data);
|
|
40
40
|
__publicField(this, "fields");
|
|
41
41
|
this.fields = new EmbedPlusFields(this);
|
|
@@ -60,7 +60,7 @@ class EmbedPlusBuilder extends EmbedBuilder {
|
|
|
60
60
|
}
|
|
61
61
|
setBorderColor(color) {
|
|
62
62
|
if (color === null) {
|
|
63
|
-
this.setColor(
|
|
63
|
+
this.setColor(colors.embedbg);
|
|
64
64
|
} else if (typeof color === "number") {
|
|
65
65
|
this.update({ color });
|
|
66
66
|
} else {
|
|
@@ -98,17 +98,11 @@ class EmbedPlusBuilder extends EmbedBuilder {
|
|
|
98
98
|
}
|
|
99
99
|
return this;
|
|
100
100
|
}
|
|
101
|
-
static fromInteraction(interaction, index = 0, data = {}) {
|
|
102
|
-
return EmbedPlusBuilder.fromMessage(interaction.message, index, data);
|
|
103
|
-
}
|
|
104
|
-
static fromMessage(message, index = 0, data = {}) {
|
|
105
|
-
return new EmbedPlusBuilder(Object.assign({ extends: message.embeds[index] }, data));
|
|
106
|
-
}
|
|
107
101
|
}
|
|
108
102
|
function createEmbed(options) {
|
|
109
103
|
const { array = false, from, fromIndex = 0, ...data } = options;
|
|
110
|
-
const
|
|
111
|
-
return array ? [
|
|
104
|
+
const fromEmbeds = from ? "message" in from ? from.message.embeds : from.embeds : [];
|
|
105
|
+
return array ? from && fromEmbeds.length > 0 ? fromEmbeds.map((embed) => new EmbedPlusBuilder({ extends: embed })) : [new EmbedPlusBuilder(data)] : from && fromEmbeds.length > 0 ? new EmbedPlusBuilder({ extends: fromEmbeds[fromIndex], ...data }) : new EmbedPlusBuilder(data);
|
|
112
106
|
}
|
|
113
107
|
|
|
114
108
|
export { EmbedPlusBuilder, createEmbed };
|
|
@@ -51,9 +51,14 @@ class EmbedPlusFields {
|
|
|
51
51
|
}
|
|
52
52
|
push(...fields) {
|
|
53
53
|
this.embed.addFields(fields.map(this.fieldFormat));
|
|
54
|
+
return this;
|
|
54
55
|
}
|
|
55
56
|
set(...fields) {
|
|
56
57
|
this.embed.setFields(fields.map(this.fieldFormat));
|
|
58
|
+
return this;
|
|
59
|
+
}
|
|
60
|
+
insert(index, ...fields) {
|
|
61
|
+
this.fields.splice(index, 0, ...fields.map(this.fieldFormat));
|
|
57
62
|
}
|
|
58
63
|
map(callback) {
|
|
59
64
|
return this.toArray().map(callback);
|
|
@@ -49,9 +49,14 @@ class EmbedPlusFields {
|
|
|
49
49
|
}
|
|
50
50
|
push(...fields) {
|
|
51
51
|
this.embed.addFields(fields.map(this.fieldFormat));
|
|
52
|
+
return this;
|
|
52
53
|
}
|
|
53
54
|
set(...fields) {
|
|
54
55
|
this.embed.setFields(fields.map(this.fieldFormat));
|
|
56
|
+
return this;
|
|
57
|
+
}
|
|
58
|
+
insert(index, ...fields) {
|
|
59
|
+
this.fields.splice(index, 0, ...fields.map(this.fieldFormat));
|
|
55
60
|
}
|
|
56
61
|
map(callback) {
|
|
57
62
|
return this.toArray().map(callback);
|
package/dist/index.d.cts
CHANGED
|
@@ -77,8 +77,9 @@ declare class EmbedPlusFields {
|
|
|
77
77
|
*/
|
|
78
78
|
get(index: number): EmbedPlusFieldData | undefined;
|
|
79
79
|
find(predicate: FieldPredicate): EmbedPlusFieldData | undefined;
|
|
80
|
-
push(...fields: Partial<EmbedPlusFieldData>[]):
|
|
81
|
-
set(...fields: Partial<EmbedPlusFieldData>[]):
|
|
80
|
+
push(...fields: Partial<EmbedPlusFieldData>[]): this;
|
|
81
|
+
set(...fields: Partial<EmbedPlusFieldData>[]): this;
|
|
82
|
+
insert(index: number, ...fields: Partial<EmbedPlusFieldData>[]): void;
|
|
82
83
|
map<U>(callback: (value: EmbedPlusFieldData, index: number, array: EmbedPlusFieldData[]) => U): U[];
|
|
83
84
|
update(predicate: string | number | FieldPredicate, field: Partial<EmbedPlusFieldData>): boolean;
|
|
84
85
|
delete(predicate: string | number | FieldPredicate): boolean;
|
|
@@ -97,6 +98,7 @@ type EmbedPlusFooterData = {
|
|
|
97
98
|
};
|
|
98
99
|
declare function createEmbedFooter(options: EmbedPlusFooterData): EmbedFooterData | undefined;
|
|
99
100
|
|
|
101
|
+
type EmbedPlusBuilderReturn<B> = undefined extends B ? EmbedPlusBuilder : false extends B ? EmbedPlusBuilder : EmbedPlusBuilder[];
|
|
100
102
|
type EmbedPlusColorData = string & {} | ColorResolvable | null;
|
|
101
103
|
type EmbedPlusAuthorData = {
|
|
102
104
|
name: string;
|
|
@@ -139,8 +141,6 @@ declare class EmbedPlusBuilder extends EmbedBuilder {
|
|
|
139
141
|
setBorderColor(color: EmbedPlusColorData | null): this;
|
|
140
142
|
setAsset(asset: "thumbnail" | "image", source: EmbedPlusAssetData): this;
|
|
141
143
|
setElementImageURL(element: "thumbnail" | "image" | "author" | "footer", url: string | null): this;
|
|
142
|
-
static fromInteraction(interaction: InteractionWithEmbeds, index?: number, data?: EmbedPlusData): EmbedPlusBuilder;
|
|
143
|
-
static fromMessage(message: MessageWithEmbeds, index?: number, data?: EmbedPlusData): EmbedPlusBuilder;
|
|
144
144
|
}
|
|
145
145
|
type EmbedPlusProperty<P extends keyof EmbedPlusData> = EmbedPlusData[P];
|
|
146
146
|
interface CreateEmbedOptions<B extends boolean> extends EmbedPlusOptions {
|
|
@@ -148,8 +148,7 @@ interface CreateEmbedOptions<B extends boolean> extends EmbedPlusOptions {
|
|
|
148
148
|
from?: InteractionWithEmbeds | MessageWithEmbeds;
|
|
149
149
|
fromIndex?: number;
|
|
150
150
|
}
|
|
151
|
-
|
|
152
|
-
declare function createEmbed<B extends boolean>(options: CreateEmbedOptions<B>): CreateEmbedReturn<B>;
|
|
151
|
+
declare function createEmbed<B extends boolean>(options: CreateEmbedOptions<B>): EmbedPlusBuilderReturn<B>;
|
|
153
152
|
|
|
154
153
|
type ImageFileExtention = "png" | "jpg" | "gif" | "webp";
|
|
155
154
|
type ImageElementProperty = "author" | "thumbnail" | "image" | "footer";
|
package/dist/index.d.mts
CHANGED
|
@@ -77,8 +77,9 @@ declare class EmbedPlusFields {
|
|
|
77
77
|
*/
|
|
78
78
|
get(index: number): EmbedPlusFieldData | undefined;
|
|
79
79
|
find(predicate: FieldPredicate): EmbedPlusFieldData | undefined;
|
|
80
|
-
push(...fields: Partial<EmbedPlusFieldData>[]):
|
|
81
|
-
set(...fields: Partial<EmbedPlusFieldData>[]):
|
|
80
|
+
push(...fields: Partial<EmbedPlusFieldData>[]): this;
|
|
81
|
+
set(...fields: Partial<EmbedPlusFieldData>[]): this;
|
|
82
|
+
insert(index: number, ...fields: Partial<EmbedPlusFieldData>[]): void;
|
|
82
83
|
map<U>(callback: (value: EmbedPlusFieldData, index: number, array: EmbedPlusFieldData[]) => U): U[];
|
|
83
84
|
update(predicate: string | number | FieldPredicate, field: Partial<EmbedPlusFieldData>): boolean;
|
|
84
85
|
delete(predicate: string | number | FieldPredicate): boolean;
|
|
@@ -97,6 +98,7 @@ type EmbedPlusFooterData = {
|
|
|
97
98
|
};
|
|
98
99
|
declare function createEmbedFooter(options: EmbedPlusFooterData): EmbedFooterData | undefined;
|
|
99
100
|
|
|
101
|
+
type EmbedPlusBuilderReturn<B> = undefined extends B ? EmbedPlusBuilder : false extends B ? EmbedPlusBuilder : EmbedPlusBuilder[];
|
|
100
102
|
type EmbedPlusColorData = string & {} | ColorResolvable | null;
|
|
101
103
|
type EmbedPlusAuthorData = {
|
|
102
104
|
name: string;
|
|
@@ -139,8 +141,6 @@ declare class EmbedPlusBuilder extends EmbedBuilder {
|
|
|
139
141
|
setBorderColor(color: EmbedPlusColorData | null): this;
|
|
140
142
|
setAsset(asset: "thumbnail" | "image", source: EmbedPlusAssetData): this;
|
|
141
143
|
setElementImageURL(element: "thumbnail" | "image" | "author" | "footer", url: string | null): this;
|
|
142
|
-
static fromInteraction(interaction: InteractionWithEmbeds, index?: number, data?: EmbedPlusData): EmbedPlusBuilder;
|
|
143
|
-
static fromMessage(message: MessageWithEmbeds, index?: number, data?: EmbedPlusData): EmbedPlusBuilder;
|
|
144
144
|
}
|
|
145
145
|
type EmbedPlusProperty<P extends keyof EmbedPlusData> = EmbedPlusData[P];
|
|
146
146
|
interface CreateEmbedOptions<B extends boolean> extends EmbedPlusOptions {
|
|
@@ -148,8 +148,7 @@ interface CreateEmbedOptions<B extends boolean> extends EmbedPlusOptions {
|
|
|
148
148
|
from?: InteractionWithEmbeds | MessageWithEmbeds;
|
|
149
149
|
fromIndex?: number;
|
|
150
150
|
}
|
|
151
|
-
|
|
152
|
-
declare function createEmbed<B extends boolean>(options: CreateEmbedOptions<B>): CreateEmbedReturn<B>;
|
|
151
|
+
declare function createEmbed<B extends boolean>(options: CreateEmbedOptions<B>): EmbedPlusBuilderReturn<B>;
|
|
153
152
|
|
|
154
153
|
type ImageFileExtention = "png" | "jpg" | "gif" | "webp";
|
|
155
154
|
type ImageElementProperty = "author" | "thumbnail" | "image" | "footer";
|
package/dist/index.d.ts
CHANGED
|
@@ -77,8 +77,9 @@ declare class EmbedPlusFields {
|
|
|
77
77
|
*/
|
|
78
78
|
get(index: number): EmbedPlusFieldData | undefined;
|
|
79
79
|
find(predicate: FieldPredicate): EmbedPlusFieldData | undefined;
|
|
80
|
-
push(...fields: Partial<EmbedPlusFieldData>[]):
|
|
81
|
-
set(...fields: Partial<EmbedPlusFieldData>[]):
|
|
80
|
+
push(...fields: Partial<EmbedPlusFieldData>[]): this;
|
|
81
|
+
set(...fields: Partial<EmbedPlusFieldData>[]): this;
|
|
82
|
+
insert(index: number, ...fields: Partial<EmbedPlusFieldData>[]): void;
|
|
82
83
|
map<U>(callback: (value: EmbedPlusFieldData, index: number, array: EmbedPlusFieldData[]) => U): U[];
|
|
83
84
|
update(predicate: string | number | FieldPredicate, field: Partial<EmbedPlusFieldData>): boolean;
|
|
84
85
|
delete(predicate: string | number | FieldPredicate): boolean;
|
|
@@ -97,6 +98,7 @@ type EmbedPlusFooterData = {
|
|
|
97
98
|
};
|
|
98
99
|
declare function createEmbedFooter(options: EmbedPlusFooterData): EmbedFooterData | undefined;
|
|
99
100
|
|
|
101
|
+
type EmbedPlusBuilderReturn<B> = undefined extends B ? EmbedPlusBuilder : false extends B ? EmbedPlusBuilder : EmbedPlusBuilder[];
|
|
100
102
|
type EmbedPlusColorData = string & {} | ColorResolvable | null;
|
|
101
103
|
type EmbedPlusAuthorData = {
|
|
102
104
|
name: string;
|
|
@@ -139,8 +141,6 @@ declare class EmbedPlusBuilder extends EmbedBuilder {
|
|
|
139
141
|
setBorderColor(color: EmbedPlusColorData | null): this;
|
|
140
142
|
setAsset(asset: "thumbnail" | "image", source: EmbedPlusAssetData): this;
|
|
141
143
|
setElementImageURL(element: "thumbnail" | "image" | "author" | "footer", url: string | null): this;
|
|
142
|
-
static fromInteraction(interaction: InteractionWithEmbeds, index?: number, data?: EmbedPlusData): EmbedPlusBuilder;
|
|
143
|
-
static fromMessage(message: MessageWithEmbeds, index?: number, data?: EmbedPlusData): EmbedPlusBuilder;
|
|
144
144
|
}
|
|
145
145
|
type EmbedPlusProperty<P extends keyof EmbedPlusData> = EmbedPlusData[P];
|
|
146
146
|
interface CreateEmbedOptions<B extends boolean> extends EmbedPlusOptions {
|
|
@@ -148,8 +148,7 @@ interface CreateEmbedOptions<B extends boolean> extends EmbedPlusOptions {
|
|
|
148
148
|
from?: InteractionWithEmbeds | MessageWithEmbeds;
|
|
149
149
|
fromIndex?: number;
|
|
150
150
|
}
|
|
151
|
-
|
|
152
|
-
declare function createEmbed<B extends boolean>(options: CreateEmbedOptions<B>): CreateEmbedReturn<B>;
|
|
151
|
+
declare function createEmbed<B extends boolean>(options: CreateEmbedOptions<B>): EmbedPlusBuilderReturn<B>;
|
|
153
152
|
|
|
154
153
|
type ImageFileExtention = "png" | "jpg" | "gif" | "webp";
|
|
155
154
|
type ImageElementProperty = "author" | "thumbnail" | "image" | "footer";
|