mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 19:28:17 +00:00
fix some getmessages stuff
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user