mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-03 05:26:07 +00:00
feat: Embed struct
This commit is contained in:
parent
dba2de7305
commit
37f4071da6
1
mod.ts
1
mod.ts
@ -5,6 +5,7 @@ export * from "./structures/BaseGuild.ts";
|
||||
export * from "./structures/Channel.ts";
|
||||
export * from "./structures/Component.ts";
|
||||
export * from "./structures/DMChannel.ts";
|
||||
export * from "./structures/Embed.ts";
|
||||
export * from "./structures/Emoji.ts";
|
||||
export * from "./structures/Guild.ts";
|
||||
export * from "./structures/GuildChannel.ts";
|
||||
|
102
structures/Embed.ts
Normal file
102
structures/Embed.ts
Normal file
@ -0,0 +1,102 @@
|
||||
import type { DiscordEmbed, EmbedTypes } from "../vendor/external.ts";
|
||||
|
||||
export interface Embed {
|
||||
title?: string;
|
||||
timestamp?: string;
|
||||
type?: EmbedTypes;
|
||||
url?: string;
|
||||
color?: number;
|
||||
description?: string;
|
||||
author?: {
|
||||
name: string;
|
||||
iconURL?: string;
|
||||
proxyIconURL?: string;
|
||||
url?: string;
|
||||
};
|
||||
footer?: {
|
||||
text: string;
|
||||
iconURL?: string;
|
||||
proxyIconURL?: string;
|
||||
};
|
||||
fields?: Array<{
|
||||
name: string;
|
||||
value: string;
|
||||
inline?: boolean;
|
||||
}>;
|
||||
thumbnail?: {
|
||||
url: string;
|
||||
proxyURL?: string;
|
||||
width?: number;
|
||||
height?: number;
|
||||
};
|
||||
video?: {
|
||||
url?: string;
|
||||
proxyURL?: string;
|
||||
width?: number;
|
||||
height?: number;
|
||||
};
|
||||
image?: {
|
||||
url: string;
|
||||
proxyURL?: string;
|
||||
width?: number;
|
||||
height?: number;
|
||||
};
|
||||
provider?: {
|
||||
url?: string;
|
||||
name?: string;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export function embed(data: Embed): DiscordEmbed {
|
||||
return {
|
||||
title: data.title,
|
||||
timestamp: data.timestamp,
|
||||
type: data.type,
|
||||
url: data.url,
|
||||
color: data.color,
|
||||
description: data.description,
|
||||
author: {
|
||||
name: data.author?.name!,
|
||||
url: data.author?.url,
|
||||
icon_url: data.author?.iconURL,
|
||||
proxy_icon_url: data.author?.proxyIconURL,
|
||||
},
|
||||
footer: data.footer || {
|
||||
text: data.footer!.text,
|
||||
icon_url: data.footer!.iconURL,
|
||||
proxy_icon_url: data.footer!.proxyIconURL,
|
||||
},
|
||||
fields: data.fields?.map((f) => {
|
||||
return {
|
||||
name: f.name,
|
||||
value: f.value,
|
||||
inline: f.inline,
|
||||
};
|
||||
}),
|
||||
thumbnail: data.thumbnail || {
|
||||
url: data.thumbnail!.url,
|
||||
proxy_url: data.thumbnail!.proxyURL,
|
||||
width: data.thumbnail!.width,
|
||||
height: data.thumbnail!.height,
|
||||
},
|
||||
video: {
|
||||
url: data.video?.url,
|
||||
proxy_url: data.video?.proxyURL,
|
||||
width: data.video?.width,
|
||||
height: data.video?.height,
|
||||
},
|
||||
image: data.image || {
|
||||
url: data.image!.url,
|
||||
proxy_url: data.image!.proxyURL,
|
||||
width: data.image!.width,
|
||||
height: data.image!.height,
|
||||
},
|
||||
provider: {
|
||||
url: data.provider?.url,
|
||||
name: data.provider?.name,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export default Embed;
|
@ -1,7 +1,7 @@
|
||||
import type { Model } from "./Base.ts";
|
||||
import type { Snowflake } from "../util/Snowflake.ts";
|
||||
import type { Session } from "../session/Session.ts";
|
||||
import type { AllowedMentionsTypes, DiscordMessage, DiscordUser, FileContent } from "../vendor/external.ts";
|
||||
import type { AllowedMentionsTypes, DiscordEmbed, DiscordMessage, DiscordUser, FileContent } from "../vendor/external.ts";
|
||||
import type { GetReactions } from "../util/Routes.ts";
|
||||
import { MessageFlags } from "../util/shared/flags.ts";
|
||||
import User from "./User.ts";
|
||||
@ -34,6 +34,7 @@ export interface CreateMessage {
|
||||
allowedMentions?: AllowedMentions;
|
||||
files?: FileContent[];
|
||||
messageReference?: CreateMessageReference;
|
||||
embeds?: DiscordEmbed[];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -110,20 +111,21 @@ export class Message implements Model {
|
||||
}
|
||||
|
||||
/** Edits the current message */
|
||||
async edit({ content, allowedMentions, flags }: EditMessage): Promise<Message> {
|
||||
async edit(options: EditMessage): Promise<Message> {
|
||||
const message = await this.session.rest.runMethod(
|
||||
this.session.rest,
|
||||
"POST",
|
||||
Routes.CHANNEL_MESSAGE(this.id, this.channelId),
|
||||
{
|
||||
content,
|
||||
content: options.content,
|
||||
allowed_mentions: {
|
||||
parse: allowedMentions?.parse,
|
||||
roles: allowedMentions?.roles,
|
||||
users: allowedMentions?.users,
|
||||
replied_user: allowedMentions?.repliedUser,
|
||||
parse: options.allowedMentions?.parse,
|
||||
roles: options.allowedMentions?.roles,
|
||||
users: options.allowedMentions?.users,
|
||||
replied_user: options.allowedMentions?.repliedUser,
|
||||
},
|
||||
flags,
|
||||
flags: options.flags,
|
||||
embeds: options.embeds,
|
||||
},
|
||||
);
|
||||
|
||||
@ -176,6 +178,7 @@ export class Message implements Model {
|
||||
fail_if_not_exists: options.messageReference.failIfNotExists ?? true,
|
||||
}
|
||||
: undefined,
|
||||
embeds: options.embeds,
|
||||
},
|
||||
);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user