feat: Message.reply accepts strings and embeds

This commit is contained in:
Yuzu 2022-09-04 11:44:32 -05:00
parent e654c75455
commit 9a299a5e49

View File

@ -458,7 +458,29 @@ export class Message implements Model {
} }
/** Replies directly in the channel where the message was sent */ /** Replies directly in the channel where the message was sent */
async reply(options: CreateMessage): Promise<Message> { async reply(options: CreateMessage | string | Embed[]): Promise<Message> {
// Options is plain content
if (typeof options === 'string') {
const message = await this.session.rest.post<DiscordMessage>(
CHANNEL_MESSAGES(this.channelId),
{ content: options }
);
return new Message(this.session, message);
}
// Opptions are multiple embeds
if (Array.isArray(options)) {
const message = await this.session.rest.post<DiscordMessage>(
CHANNEL_MESSAGES(this.channelId),
{ embeds: options.map(NewEmbed) }
);
return new Message(this.session, message);
}
// Options is of type CreateMessage
const message = await this.session.rest.post<DiscordMessage>( const message = await this.session.rest.post<DiscordMessage>(
CHANNEL_MESSAGES(this.channelId), CHANNEL_MESSAGES(this.channelId),
{ {