-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for Message.edit(), added MessageEmbeds and support to …
…send embeds
- Loading branch information
Showing
17 changed files
with
368 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export { MessageEmbed } from './MessageEmbed.ts'; | ||
export { MessageEmbedFooter } from './MessageEmbedFooter.ts'; | ||
export { MessageEmbedImage } from './MessageEmbedImage.ts'; | ||
export { MessageEmbedAuthor } from './MessageEmbedAuthor.ts'; | ||
export { MessageEmbedField } from './MessageEmbedField.ts'; | ||
export { MessageEmbedProvider } from './MessageEmbedProvider.ts'; | ||
export { MessageEmbedThumbnail } from './MessageEmbedThumbnail.ts'; | ||
export { MessageEmbedVideo } from './MessageEmbedVideo.ts'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
import { | ||
MessageEmbedAuthor, | ||
MessageEmbedField, | ||
MessageEmbedFooter, | ||
MessageEmbedImage, | ||
MessageEmbedProvider, | ||
MessageEmbedThumbnail, | ||
MessageEmbedVideo | ||
} from './Embeds.ts'; | ||
|
||
export class MessageEmbed { | ||
|
||
private title?: string; | ||
private type?: string; | ||
private description?: string; | ||
private url?: string; | ||
private timestamp?: Date; | ||
private color?: number; | ||
private footer?: MessageEmbedFooter; | ||
private image?: MessageEmbedImage; | ||
private thumbnail?: MessageEmbedThumbnail; | ||
private video?: MessageEmbedVideo; | ||
private provider?: MessageEmbedProvider; | ||
private author?: MessageEmbedAuthor; | ||
private fields: Array<MessageEmbedField> = []; | ||
|
||
constructor( | ||
title?: string, | ||
type?: string, | ||
description?: string, | ||
url?: string, | ||
timestamp?: Date, | ||
color?: number, | ||
footer?: MessageEmbedFooter, | ||
image?: MessageEmbedImage, | ||
thumbnail?: MessageEmbedThumbnail, | ||
video?: MessageEmbedVideo, | ||
provider?: MessageEmbedProvider, | ||
author?: MessageEmbedAuthor, | ||
) { | ||
this.title = title; | ||
this.type = type; | ||
this.description = description; | ||
this.url = url; | ||
this.timestamp = timestamp; | ||
this.color = color; | ||
this.footer = footer; | ||
this.image = image; | ||
this.thumbnail = thumbnail; | ||
this.video = video; | ||
this.provider = provider; | ||
this.author = author; | ||
} | ||
|
||
getTitle(): string | undefined { return this.title; } | ||
setTitle(title: string | undefined): MessageEmbed { | ||
this.title = title; | ||
return this; | ||
} | ||
|
||
getType(): string | undefined { return this.type; } | ||
setType(type: string | undefined): MessageEmbed { | ||
this.type = type; | ||
return this; | ||
} | ||
|
||
getDescription(): string | undefined { return this.description; } | ||
setDescription(description: string) { | ||
this.description = description; | ||
return this; | ||
} | ||
|
||
getUrl(): string | undefined { return this.url; } | ||
setUrl(url: string | undefined) { | ||
this.url = url; | ||
return this; | ||
} | ||
|
||
getTimestamp(): Date | undefined { return this.timestamp; } | ||
setTimestamp(timestamp?: Date | undefined) { | ||
if (timestamp) this.timestamp = timestamp; | ||
else this.timestamp = new Date(); | ||
return this; | ||
} | ||
|
||
getColor(): number | undefined { return this.color; } | ||
setColor(color: number | undefined) { | ||
this.color = color; | ||
return this; | ||
} | ||
|
||
getFooter(): MessageEmbedFooter | undefined { return this.footer; } | ||
setFooter(text?: string, icon?: string, proxyIconUrl?: string) { | ||
this.footer = new MessageEmbedFooter(text, icon, proxyIconUrl); | ||
return this; | ||
} | ||
|
||
getImage(): MessageEmbedImage | undefined { return this.image; } | ||
setImage(url?: string, proxyUrl?: string, height?: number, width?: number): MessageEmbed { | ||
this.image = new MessageEmbedImage(url, proxyUrl, height, width); | ||
return this; | ||
} | ||
|
||
getThumbnail(): MessageEmbedThumbnail | undefined { return this.thumbnail; } | ||
setThumbnail(url?: string, proxyUrl?: string, height?: number, width?: number): MessageEmbed { | ||
this.thumbnail = new MessageEmbedThumbnail(url, proxyUrl, height, width); | ||
return this; | ||
} | ||
|
||
getVideo(): MessageEmbedVideo | undefined { return this.video; } | ||
// setVideo(url?: string, height?: number, width?: number): MessageEmbed { | ||
// this.video = new MessageEmbedVideo(url, height, width); | ||
// return this; | ||
// } | ||
|
||
getProvider(): MessageEmbedProvider | undefined { return this.provider; } | ||
setProvider(name?: string, url?: string): MessageEmbed { | ||
this.provider = new MessageEmbedProvider(name, url); | ||
return this; | ||
} | ||
|
||
getAuthor(): MessageEmbedAuthor | undefined { return this.author; } | ||
setAuthor(name?: string, url?: string, iconUrl?: string, proxyIconUrl?: string): MessageEmbed { | ||
this.author = new MessageEmbedAuthor(name, url, iconUrl, proxyIconUrl); | ||
return this; | ||
} | ||
|
||
addField(text: string, value: string, inline?: boolean): MessageEmbed { | ||
this.fields.push(new MessageEmbedField(text,value,inline)); | ||
return this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
export class MessageEmbedAuthor { | ||
|
||
private _name: string | undefined; | ||
private _url: string | undefined; | ||
private _iconUrl: string | undefined; | ||
private _proxyIconUrl: string | undefined; | ||
|
||
constructor( | ||
name?: string, | ||
url?: string, | ||
iconUrl?: string, | ||
proxyIconUrl?: string, | ||
) { | ||
this._name = name; | ||
this._url = url; | ||
this._iconUrl = iconUrl; | ||
this._proxyIconUrl = proxyIconUrl; | ||
} | ||
|
||
get name(): string | undefined { return this._name; } | ||
get url(): string | undefined { return this._url; } | ||
get iconUrl(): string | undefined { return this._iconUrl; } | ||
get proxyIconUrl(): string | undefined { return this._proxyIconUrl; } | ||
|
||
set name(name: string | undefined) { this._name = name; } | ||
set url(url: string | undefined ) { this._url = url; } | ||
set iconUrl(iconUrl: string | undefined) { this._iconUrl = iconUrl; } | ||
set proxyIconUrl(proxyIconUrl: string | undefined) { this._proxyIconUrl = proxyIconUrl; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
export class MessageEmbedField { | ||
|
||
private name: string; | ||
private value: string; | ||
private inline?: boolean; | ||
|
||
constructor( | ||
name: string, | ||
value: string, | ||
inline?: boolean | ||
) { | ||
this.name = name; | ||
this.value = value; | ||
this.inline = inline; | ||
} | ||
|
||
getName(): string { return this.name; } | ||
getValue(): string { return this.value; } | ||
getInline(): boolean | undefined { return this.inline; } | ||
|
||
setName(name: string) { this.name = name; } | ||
setValue(value: string) { this.value = value; } | ||
setInline(inline: boolean) { this.inline = inline; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
export class MessageEmbedFooter { | ||
|
||
private text: string | undefined; | ||
private icon_url: string | undefined; | ||
private proxy_icon_url: string | undefined; | ||
constructor( | ||
text?: string, | ||
iconUrl?: string, | ||
proxyIconUrl?: string | ||
) { | ||
this.text = text; | ||
this.icon_url = iconUrl; | ||
this.proxy_icon_url = proxyIconUrl; | ||
} | ||
|
||
getText(): string | undefined { return this.text; } | ||
getIconUrl(): string | undefined { return this.icon_url; } | ||
getProxyIconUrl(): string | undefined { return this.proxy_icon_url; } | ||
|
||
setText(text: string | undefined) { this.text = text; } | ||
setIconUrl(iconUrl: string | undefined) { this.icon_url = iconUrl; } | ||
setProxyIconUrl(proxyIconUrl: string | undefined) { this.proxy_icon_url = proxyIconUrl; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
export class MessageEmbedImage { | ||
|
||
private url: string | undefined; | ||
private proxyUrl: string | undefined; | ||
private height: number | undefined; | ||
private width: number | undefined; | ||
|
||
constructor( | ||
url?: string, | ||
proxyUrl?: string, | ||
height?: number, | ||
width?: number | ||
) { | ||
this.url = url; | ||
this.proxyUrl = proxyUrl; | ||
this.height = height; | ||
this.width = width; | ||
} | ||
|
||
getUrl(): string | undefined { return this.url; } | ||
getProxyUrl(): string | undefined { return this.proxyUrl; } | ||
getHeight(): number | undefined { return this.height; } | ||
getWidth(): number | undefined { return this.width; } | ||
|
||
setUrl(url: string | undefined ) { this.url = url; } | ||
setProxyUrl(proxyUrl: string | undefined) { this.proxyUrl = proxyUrl; } | ||
setHeight(height: number | undefined){ this.height = height; } | ||
setWidth(width: number | undefined) { this.width = width; } | ||
} |
Oops, something went wrong.