@magicyan/discord 1.5.1 → 1.5.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.
|
@@ -7,7 +7,8 @@ const message = require('../../guards/message.cjs');
|
|
|
7
7
|
|
|
8
8
|
class ContainerPlusBuilder extends discord_js.ContainerBuilder {
|
|
9
9
|
constructor(data) {
|
|
10
|
-
const
|
|
10
|
+
const extractData = (message) => message.components.filter((v) => v.type === discord_js.ComponentType.Container).at(data?.fromIndex ?? 0)?.toJSON() ?? {};
|
|
11
|
+
const constructorData = core.isDefined(data?.from) ? "message" in data.from ? extractData(data.from.message) : message.isMessage(data.from) ? extractData(data.from) : data.from.toJSON() : {};
|
|
11
12
|
if (core.isDefined(data?.accentColor)) {
|
|
12
13
|
constructorData.accent_color = discord_js.resolveColor(
|
|
13
14
|
data.accentColor
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { isDefined } from '@magicyan/core';
|
|
2
|
-
import { ContainerBuilder,
|
|
2
|
+
import { ContainerBuilder, resolveColor, ComponentType } from 'discord.js';
|
|
3
3
|
import { createComponents } from './components.mjs';
|
|
4
4
|
import { isMessage } from '../../guards/message.mjs';
|
|
5
5
|
|
|
6
6
|
class ContainerPlusBuilder extends ContainerBuilder {
|
|
7
7
|
constructor(data) {
|
|
8
|
-
const
|
|
8
|
+
const extractData = (message) => message.components.filter((v) => v.type === ComponentType.Container).at(data?.fromIndex ?? 0)?.toJSON() ?? {};
|
|
9
|
+
const constructorData = isDefined(data?.from) ? "message" in data.from ? extractData(data.from.message) : isMessage(data.from) ? extractData(data.from) : data.from.toJSON() : {};
|
|
9
10
|
if (isDefined(data?.accentColor)) {
|
|
10
11
|
constructorData.accent_color = resolveColor(
|
|
11
12
|
data.accentColor
|
package/dist/index.d.cts
CHANGED
|
@@ -237,10 +237,13 @@ declare function createComponents<IsContainer extends boolean = false, Data exte
|
|
|
237
237
|
type ContainerColor = (string & {}) | ColorResolvable;
|
|
238
238
|
type ContainerInComponentType = ComponentType.TextDisplay | ComponentType.ActionRow | ComponentType.Section | ComponentType.Separator | ComponentType.MediaGallery | ComponentType.File;
|
|
239
239
|
type ContainerType = ContainerBuilder | ContainerPlusBuilder | ContainerComponent;
|
|
240
|
+
type InteractionWithMessage = {
|
|
241
|
+
message: Message;
|
|
242
|
+
};
|
|
240
243
|
interface ContainerData extends Omit<ContainerComponentData, "accentColor" | "type" | "components"> {
|
|
241
244
|
accentColor?: ContainerColor | null;
|
|
242
245
|
components?: ComponentData[];
|
|
243
|
-
from?: ContainerType | Message;
|
|
246
|
+
from?: ContainerType | Message | InteractionWithMessage;
|
|
244
247
|
fromIndex?: number;
|
|
245
248
|
}
|
|
246
249
|
declare class ContainerPlusBuilder extends ContainerBuilder {
|
package/dist/index.d.mts
CHANGED
|
@@ -237,10 +237,13 @@ declare function createComponents<IsContainer extends boolean = false, Data exte
|
|
|
237
237
|
type ContainerColor = (string & {}) | ColorResolvable;
|
|
238
238
|
type ContainerInComponentType = ComponentType.TextDisplay | ComponentType.ActionRow | ComponentType.Section | ComponentType.Separator | ComponentType.MediaGallery | ComponentType.File;
|
|
239
239
|
type ContainerType = ContainerBuilder | ContainerPlusBuilder | ContainerComponent;
|
|
240
|
+
type InteractionWithMessage = {
|
|
241
|
+
message: Message;
|
|
242
|
+
};
|
|
240
243
|
interface ContainerData extends Omit<ContainerComponentData, "accentColor" | "type" | "components"> {
|
|
241
244
|
accentColor?: ContainerColor | null;
|
|
242
245
|
components?: ComponentData[];
|
|
243
|
-
from?: ContainerType | Message;
|
|
246
|
+
from?: ContainerType | Message | InteractionWithMessage;
|
|
244
247
|
fromIndex?: number;
|
|
245
248
|
}
|
|
246
249
|
declare class ContainerPlusBuilder extends ContainerBuilder {
|
package/dist/index.d.ts
CHANGED
|
@@ -237,10 +237,13 @@ declare function createComponents<IsContainer extends boolean = false, Data exte
|
|
|
237
237
|
type ContainerColor = (string & {}) | ColorResolvable;
|
|
238
238
|
type ContainerInComponentType = ComponentType.TextDisplay | ComponentType.ActionRow | ComponentType.Section | ComponentType.Separator | ComponentType.MediaGallery | ComponentType.File;
|
|
239
239
|
type ContainerType = ContainerBuilder | ContainerPlusBuilder | ContainerComponent;
|
|
240
|
+
type InteractionWithMessage = {
|
|
241
|
+
message: Message;
|
|
242
|
+
};
|
|
240
243
|
interface ContainerData extends Omit<ContainerComponentData, "accentColor" | "type" | "components"> {
|
|
241
244
|
accentColor?: ContainerColor | null;
|
|
242
245
|
components?: ComponentData[];
|
|
243
|
-
from?: ContainerType | Message;
|
|
246
|
+
from?: ContainerType | Message | InteractionWithMessage;
|
|
244
247
|
fromIndex?: number;
|
|
245
248
|
}
|
|
246
249
|
declare class ContainerPlusBuilder extends ContainerBuilder {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magicyan/discord",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.2",
|
|
4
4
|
"description": "Simple functions to facilitate discord bot development",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -49,6 +49,6 @@
|
|
|
49
49
|
"vitest": "^2.1.9"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@magicyan/core": "^1.1.
|
|
52
|
+
"@magicyan/core": "^1.1.2"
|
|
53
53
|
}
|
|
54
54
|
}
|