fix some getmessages stuff

This commit is contained in:
ITOH
2021-05-08 11:44:05 +02:00
parent 83455c1742
commit c98b0e089a
4 changed files with 10 additions and 5 deletions
+4 -1
View File
@@ -1,5 +1,6 @@
import { rest } from "../../rest/rest.ts";
import { structures } from "../../structures/mod.ts";
import { Errors } from "../../types/discordeno/errors.ts";
import {
GetMessagesAfter,
GetMessagesAround,
@@ -24,7 +25,9 @@ export async function getMessages(
"READ_MESSAGE_HISTORY",
]);
if (options?.limit && options.limit > 100) return;
if (options?.limit && (options.limit < 0 || options.limit > 100)) {
throw new Error(Errors.INVALID_GET_MESSAGES_LIMIT);
}
const result = await rest.runMethod<Message[]>(
"get",
+2
View File
@@ -23,6 +23,8 @@ export enum Errors {
GUILD_NEWS_CHANNEL_ONLY_SUPPORT_PUBLIC_THREADS =
"GUILD_NEWS_CHANNEL_ONLY_SUPPORT_PUBLIC_THREADS",
NOT_A_THREAD_CHANNEL = "NOT_A_THREAD_CHANNEL",
// Message Get Errors
INVALID_GET_MESSAGES_LIMIT = "INVALID_GET_MESSAGES_LIMIT",
// Message Delete Errors
DELETE_MESSAGES_MIN = "DELETE_MESSAGES_MIN",
PRUNE_MIN_DAYS = "PRUNE_MIN_DAYS",
+3 -3
View File
@@ -7,19 +7,19 @@ export interface GetMessagesLimit {
/** https://discord.com/developers/docs/resources/channel#get-channel-messages-query-string-params */
export interface GetMessagesAround extends GetMessagesLimit {
/** Get messages around this message id */
around?: string;
around?: bigint;
}
/** https://discord.com/developers/docs/resources/channel#get-channel-messages-query-string-params */
export interface GetMessagesBefore extends GetMessagesLimit {
/** Get messages before this message id */
before?: string;
before?: bigint;
}
/** https://discord.com/developers/docs/resources/channel#get-channel-messages-query-string-params */
export interface GetMessagesAfter extends GetMessagesLimit {
/** Get messages after this message id */
after?: string;
after?: bigint;
}
/** https://discord.com/developers/docs/resources/channel#get-channel-messages-query-string-params */
+1 -1
View File
@@ -39,7 +39,7 @@ Deno.test({
// Fetch the messages
const fetchedMessages = await getMessages(tempData.channelId, {
after: message.id.toString(),
after: message.id,
limit: 2,
});
// Check if getMessages has worked