Skip to content

Commit b0cbbd3

Browse files
committed
feat: Add setImageFromFile & seThumbnailFromFile.
1 parent a7e396d commit b0cbbd3

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/BetterEmbed.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import {MessageEmbed, MessageEmbedOptions} from 'discord.js';
1+
import {MessageAttachment, MessageEmbed, MessageEmbedOptions} from 'discord.js';
2+
import path from 'path';
23

34
type AnyObject = {[k: string]: any};
45

@@ -153,6 +154,18 @@ export class BetterEmbed extends MessageEmbed {
153154
}
154155
}
155156

157+
public setImageFromFile(link: string) {
158+
const attachment = new MessageAttachment(link, path.basename(link));
159+
this.attachFiles([attachment]);
160+
this.setImage(`attachment://${attachment.name}`);
161+
}
162+
163+
public setThumbnailFromFile(link: string) {
164+
const attachment = new MessageAttachment(link, path.basename(link));
165+
this.attachFiles([attachment]);
166+
this.setThumbnail(`attachment://${attachment.name}`);
167+
}
168+
156169
public throwIfTooLong(field: keyof Template): void;
157170
public throwIfTooLong(field?: keyof Template) {
158171
if (field) {

0 commit comments

Comments
 (0)