From 3f714eb295c16a59b6fe67c478aed5aaa453b900 Mon Sep 17 00:00:00 2001 From: Yuzu Date: Fri, 1 Jul 2022 16:10:56 -0500 Subject: [PATCH] feat: TextChannel.sendMessage/editMessage --- structures/Embed.ts | 3 +-- structures/Message.ts | 8 +++++++- structures/TextChannel.ts | 10 +++++++++- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/structures/Embed.ts b/structures/Embed.ts index 2d5e624..19b5de3 100644 --- a/structures/Embed.ts +++ b/structures/Embed.ts @@ -44,8 +44,7 @@ export interface Embed { provider?: { url?: string; name?: string; - } - + }; } export function embed(data: Embed): DiscordEmbed { diff --git a/structures/Message.ts b/structures/Message.ts index 483f661..65f3c35 100644 --- a/structures/Message.ts +++ b/structures/Message.ts @@ -1,7 +1,13 @@ import type { Model } from "./Base.ts"; import type { Snowflake } from "../util/Snowflake.ts"; import type { Session } from "../session/Session.ts"; -import type { AllowedMentionsTypes, DiscordEmbed, 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"; diff --git a/structures/TextChannel.ts b/structures/TextChannel.ts index 7bade2f..7ecd39b 100644 --- a/structures/TextChannel.ts +++ b/structures/TextChannel.ts @@ -2,7 +2,7 @@ import type { Session } from "../session/Session.ts"; import type { Snowflake } from "../util/Snowflake.ts"; import type { GetMessagesOptions, GetReactions } from "../util/Routes.ts"; import type { DiscordChannel, DiscordInvite, DiscordMessage, TargetTypes } from "../vendor/external.ts"; -import type { ReactionResolvable } from "./Message.ts"; +import type { CreateMessage, EditMessage, ReactionResolvable } from "./Message.ts"; import GuildChannel from "./GuildChannel.ts"; import ThreadChannel from "./ThreadChannel.ts"; import Message from "./Message.ts"; @@ -151,6 +151,14 @@ export class TextChannel extends GuildChannel { return users; } + + sendMessage(options: CreateMessage) { + return Message.prototype.reply.call({ channelId: this.id, session: this.session }, options); + } + + editMessage(messageId: Snowflake, options: EditMessage) { + return Message.prototype.edit.call({ channelId: this.id, id: messageId, session: this.session }, options); + } } export default TextChannel;