mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-02 17:00:08 +00:00
check channel type before sendmessage
This commit is contained in:
4
egg.yml
4
egg.yml
@@ -2,16 +2,16 @@ name: Discordeno
|
||||
description: >-
|
||||
Discord Deno TypeScript API library wrapper(Officially vetted library by
|
||||
Discord Team) https://discordeno.netlify.app
|
||||
version: 9.0.5
|
||||
version: 9.0.7
|
||||
stable: true
|
||||
entry: mod.ts
|
||||
repository: 'https://github.com/Skillz4Killz/Discordeno'
|
||||
files:
|
||||
- ./src/**/*
|
||||
- LICENSE
|
||||
- mod.ts
|
||||
- README.md
|
||||
- tsconfig.json
|
||||
- ./deps.ts
|
||||
- mod.ts
|
||||
checkAll: false
|
||||
unlisted: false
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import { endpoints } from "../constants/discord.ts";
|
||||
import { cacheHandlers } from "../controllers/cache.ts";
|
||||
import { RequestManager } from "../module/requestManager.ts";
|
||||
import { structures } from "../structures/mod.ts";
|
||||
import type {
|
||||
import {
|
||||
ChannelEditOptions,
|
||||
ChannelTypes,
|
||||
CreateInviteOptions,
|
||||
FollowedChannelPayload,
|
||||
GetMessages,
|
||||
@@ -160,6 +162,10 @@ export async function sendMessage(
|
||||
}
|
||||
}
|
||||
|
||||
const channel = await cacheHandlers.get("channels", channelID);
|
||||
if (!channel) throw new Error(Errors.CHANNEL_NOT_FOUND);
|
||||
if (![ChannelTypes.DM, ChannelTypes.GUILD_NEWS, ChannelTypes.GUILD_TEXT].includes(channel.type)) throw new Error(Errors.CHANNEL_NOT_TEXT_BASED)
|
||||
|
||||
const result = await RequestManager.post(
|
||||
endpoints.CHANNEL_MESSAGES(channelID),
|
||||
{
|
||||
|
||||
@@ -31,4 +31,6 @@ export enum Errors {
|
||||
CHANNEL_NOT_IN_GUILD = "CHANNEL_NOT_IN_GUILD",
|
||||
INVALID_WEBHOOK_NAME = "INVALID_WEBHOOK_NAME",
|
||||
INVALID_WEBHOOK_OPTIONS = "INVALID_WEBHOOK_OPTIONS",
|
||||
CHANNEL_NOT_FOUND = "CHANNEL_NOT_FOUND",
|
||||
CHANNEL_NOT_TEXT_BASED = "CHANNEL_NOT_TEXT_BASED",
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user