aboutsummaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorV <vendicated@riseup.net>2023-05-23 03:47:09 +0200
committerV <vendicated@riseup.net>2023-05-23 03:47:09 +0200
commit368d2bcdbb5489123f0810c75ea092311e20ff75 (patch)
tree8e1020f7b8ba52b38c22ab9e18e8683c23a18a43 /src/utils
parentbc46bfa4675bb78d9044edf8793653358652548d (diff)
downloadVencord-368d2bcdbb5489123f0810c75ea092311e20ff75.tar.gz
Vencord-368d2bcdbb5489123f0810c75ea092311e20ff75.tar.bz2
Vencord-368d2bcdbb5489123f0810c75ea092311e20ff75.zip
DiscordUtils: Add sendMessage
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/discord.ts32
1 files changed, 30 insertions, 2 deletions
diff --git a/src/utils/discord.ts b/src/utils/discord.ts
index dfd20e6..228e2b4 100644
--- a/src/utils/discord.ts
+++ b/src/utils/discord.ts
@@ -16,11 +16,13 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-import { findLazy } from "@webpack";
+import { MessageObject } from "@api/MessageEvents";
+import { findByPropsLazy, findLazy } from "@webpack";
import { ChannelStore, ComponentDispatch, GuildStore, PrivateChannelsStore, SelectedChannelStore } from "@webpack/common";
-import { Guild } from "discord-types/general";
+import { Guild, Message } from "discord-types/general";
const PreloadedUserSettings = findLazy(m => m.ProtoClass?.typeName.endsWith("PreloadedUserSettings"));
+const MessageActions = findByPropsLazy("editMessage", "sendMessage");
export function getCurrentChannel() {
return ChannelStore.getChannel(SelectedChannelStore.getChannelId());
@@ -49,3 +51,29 @@ export function insertTextIntoChatInputBox(text: string) {
plainText: text
});
}
+
+interface MessageExtra {
+ messageReference: Message["messageReference"];
+ allowedMentions: {
+ parse: string[];
+ replied_user: boolean;
+ };
+ stickerIds: string[];
+}
+
+export function sendMessage(
+ channelId: string,
+ data: Partial<MessageObject>,
+ waitForChannelReady?: boolean,
+ extra?: Partial<MessageExtra>
+) {
+ const messageData = {
+ content: "",
+ invalidEmojis: [],
+ tts: false,
+ validNonShortcutEmojis: [],
+ ...data
+ };
+
+ return MessageActions.sendMessage(channelId, messageData, waitForChannelReady, extra);
+}