@magicyan/discord 1.0.35 → 1.1.1
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 +4 -9
- package/dist/functions/embeds/embedplus.mjs +4 -9
- 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;
|
|
@@ -62,7 +63,7 @@ class EmbedPlusBuilder extends discord_js.EmbedBuilder {
|
|
|
62
63
|
}
|
|
63
64
|
setBorderColor(color) {
|
|
64
65
|
if (color === null) {
|
|
65
|
-
this.setColor(
|
|
66
|
+
this.setColor(colors.colors.embedbg);
|
|
66
67
|
} else if (typeof color === "number") {
|
|
67
68
|
this.update({ color });
|
|
68
69
|
} else {
|
|
@@ -100,17 +101,11 @@ class EmbedPlusBuilder extends discord_js.EmbedBuilder {
|
|
|
100
101
|
}
|
|
101
102
|
return this;
|
|
102
103
|
}
|
|
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
104
|
}
|
|
110
105
|
function createEmbed(options) {
|
|
111
106
|
const { array = false, from, fromIndex = 0, ...data } = options;
|
|
112
|
-
const
|
|
113
|
-
return array ? [
|
|
107
|
+
const fromEmbeds = from ? "message" in from ? from.message.embeds : from.embeds : [];
|
|
108
|
+
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
109
|
}
|
|
115
110
|
|
|
116
111
|
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;
|
|
@@ -60,7 +61,7 @@ class EmbedPlusBuilder extends EmbedBuilder {
|
|
|
60
61
|
}
|
|
61
62
|
setBorderColor(color) {
|
|
62
63
|
if (color === null) {
|
|
63
|
-
this.setColor(
|
|
64
|
+
this.setColor(colors.embedbg);
|
|
64
65
|
} else if (typeof color === "number") {
|
|
65
66
|
this.update({ color });
|
|
66
67
|
} else {
|
|
@@ -98,17 +99,11 @@ class EmbedPlusBuilder extends EmbedBuilder {
|
|
|
98
99
|
}
|
|
99
100
|
return this;
|
|
100
101
|
}
|
|
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
102
|
}
|
|
108
103
|
function createEmbed(options) {
|
|
109
104
|
const { array = false, from, fromIndex = 0, ...data } = options;
|
|
110
|
-
const
|
|
111
|
-
return array ? [
|
|
105
|
+
const fromEmbeds = from ? "message" in from ? from.message.embeds : from.embeds : [];
|
|
106
|
+
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
107
|
}
|
|
113
108
|
|
|
114
109
|
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";
|