feat: implement embed message handling and create Embed structure for improved message formatting
This commit is contained in:
66
src/structures/embeds.ts
Normal file
66
src/structures/embeds.ts
Normal file
@@ -0,0 +1,66 @@
|
||||
import { DiscordEmbed, DiscordEmbedAuthor, DiscordEmbedField, DiscordEmbedImage } from "npm:discordeno@18.0.1";
|
||||
|
||||
export type Field = {name: string, value: string}
|
||||
|
||||
export class Embed implements DiscordEmbed{
|
||||
title: string
|
||||
url: string
|
||||
author: DiscordEmbedAuthor
|
||||
fields: Field[]
|
||||
image: DiscordEmbedImage
|
||||
// timestamp: Time
|
||||
|
||||
constructor(
|
||||
title: string,
|
||||
url: string,
|
||||
author:DiscordEmbedAuthor,
|
||||
fields: EmbedField[],
|
||||
image: DiscordEmbedImage,
|
||||
){
|
||||
this.title = title
|
||||
this.url = url
|
||||
this.author = author
|
||||
this.fields= fields
|
||||
this.image = image
|
||||
|
||||
}
|
||||
toJSON() {
|
||||
return {
|
||||
title: this.title,
|
||||
url : this.url,
|
||||
author: this.author,
|
||||
fields: this.fields,
|
||||
image: this.image
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class EmbedImage implements DiscordEmbedImage {
|
||||
url: string
|
||||
height: number
|
||||
width: number
|
||||
constructor(url: string, height: number, width : number){
|
||||
this.url = url
|
||||
this.height = height
|
||||
this.width = width
|
||||
}
|
||||
}
|
||||
|
||||
export class EmbedAuthor implements DiscordEmbedAuthor {
|
||||
name: string
|
||||
constructor(name: string){
|
||||
this.name = name
|
||||
}
|
||||
}
|
||||
|
||||
export class EmbedField implements DiscordEmbedField {
|
||||
name: string
|
||||
value: string
|
||||
inline: boolean
|
||||
|
||||
constructor(name: string, value: string, inline: boolean) {
|
||||
this.name = name
|
||||
this.value = value
|
||||
this.inline = inline
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user