diff --git a/src/helpers/messages/add_reaction.ts b/src/helpers/messages/add_reaction.ts index 1a5861abb..6c2fe402b 100644 --- a/src/helpers/messages/add_reaction.ts +++ b/src/helpers/messages/add_reaction.ts @@ -19,10 +19,8 @@ export async function addReaction( reaction = reaction.substring(3, reaction.length - 1); } - const result = await rest.runMethod( + return await rest.runMethod( "put", endpoints.CHANNEL_MESSAGE_REACTION_ME(channelId, messageId, reaction), ); - - return result; } diff --git a/src/helpers/messages/delete_message.ts b/src/helpers/messages/delete_message.ts index c053a1787..9b84ae248 100644 --- a/src/helpers/messages/delete_message.ts +++ b/src/helpers/messages/delete_message.ts @@ -20,11 +20,9 @@ export async function deleteMessage( if (delayMilliseconds) await delay(delayMilliseconds); - const result = await rest.runMethod( + return await rest.runMethod( "delete", endpoints.CHANNEL_MESSAGE(channelId, messageId), { reason }, ); - - return result; } diff --git a/src/helpers/messages/edit_message.ts b/src/helpers/messages/edit_message.ts index 220f605b8..860aa7616 100644 --- a/src/helpers/messages/edit_message.ts +++ b/src/helpers/messages/edit_message.ts @@ -3,7 +3,7 @@ import { rest } from "../../rest/rest.ts"; import { DiscordenoMessage } from "../../structures/message.ts"; import { structures } from "../../structures/mod.ts"; import { EditMessage } from "../../types/messages/edit_message.ts"; -import { DiscordMessage } from "../../types/messages/message.ts"; +import { Message } from "../../types/messages/message.ts"; import { Errors } from "../../types/misc/errors.ts"; import { PermissionStrings } from "../../types/permissions/permission_strings.ts"; import { endpoints } from "../../util/constants.ts"; @@ -28,11 +28,11 @@ export async function editMessage( throw new Error(Errors.MESSAGE_MAX_LENGTH); } - const result: DiscordMessage = await rest.runMethod( + const result = await rest.runMethod( "patch", endpoints.CHANNEL_MESSAGE(message.channelId, message.id), content, ); - return structures.createDiscordenoMessage(result); + return await structures.createDiscordenoMessage(result); } diff --git a/src/helpers/messages/get_message.ts b/src/helpers/messages/get_message.ts index 9c6c11a57..fc3f00cf6 100644 --- a/src/helpers/messages/get_message.ts +++ b/src/helpers/messages/get_message.ts @@ -1,7 +1,7 @@ import { cacheHandlers } from "../../cache.ts"; import { rest } from "../../rest/rest.ts"; import { structures } from "../../structures/mod.ts"; -import { DiscordMessage } from "../../types/messages/message.ts"; +import { Message } from "../../types/messages/message.ts"; import { endpoints } from "../../util/constants.ts"; import { requireBotChannelPermissions } from "../../util/permissions.ts"; @@ -14,10 +14,10 @@ export async function getMessage(channelId: string, id: string) { ]); } - const result = (await rest.runMethod( + const result = await rest.runMethod( "get", endpoints.CHANNEL_MESSAGE(channelId, id), - )) as DiscordMessage; + ); - return structures.createDiscordenoMessage(result); + return await structures.createDiscordenoMessage(result); } diff --git a/src/helpers/messages/get_messages.ts b/src/helpers/messages/get_messages.ts index 959504e9a..1429b495b 100644 --- a/src/helpers/messages/get_messages.ts +++ b/src/helpers/messages/get_messages.ts @@ -6,7 +6,7 @@ import { GetMessagesBefore, GetMessagesLimit, } from "../../types/messages/get_messages.ts"; -import { DiscordMessage } from "../../types/messages/message.ts"; +import { Message } from "../../types/messages/message.ts"; import { endpoints } from "../../util/constants.ts"; import { requireBotChannelPermissions } from "../../util/permissions.ts"; @@ -26,13 +26,13 @@ export async function getMessages( if (options?.limit && options.limit > 100) return; - const result = (await rest.runMethod( + const result = await rest.runMethod( "get", endpoints.CHANNEL_MESSAGES(channelId), options, - )) as DiscordMessage[]; + ); - return Promise.all( + return await Promise.all( result.map((res) => structures.createDiscordenoMessage(res)), ); } diff --git a/src/helpers/messages/get_reactions.ts b/src/helpers/messages/get_reactions.ts index 0506f5b48..bf10d2d6d 100644 --- a/src/helpers/messages/get_reactions.ts +++ b/src/helpers/messages/get_reactions.ts @@ -1,8 +1,8 @@ import { rest } from "../../rest/rest.ts"; -import { DiscordUser } from "../../types/users/user.ts"; +import { GetReactions } from "../../types/messages/message_get_reactions.ts"; +import { User } from "../../types/users/user.ts"; import { Collection } from "../../util/collection.ts"; import { endpoints } from "../../util/constants.ts"; -import { GetReactions } from "../../types/messages/message_get_reactions.ts"; /** Get a list of users that reacted with this emoji. */ export async function getReactions( @@ -11,11 +11,11 @@ export async function getReactions( reaction: string, options?: GetReactions, ) { - const users = (await rest.runMethod( + const users = await rest.runMethod( "get", endpoints.CHANNEL_MESSAGE_REACTION(channelId, messageId, reaction), options, - )) as DiscordUser[]; + ); return new Collection(users.map((user) => [user.id, user])); } diff --git a/src/helpers/messages/pin_message.ts b/src/helpers/messages/pin_message.ts index 3e3001142..f96cac8f0 100644 --- a/src/helpers/messages/pin_message.ts +++ b/src/helpers/messages/pin_message.ts @@ -6,12 +6,10 @@ import { requireBotChannelPermissions } from "../../util/permissions.ts"; export async function pin(channelId: string, messageId: string) { await requireBotChannelPermissions(channelId, ["MANAGE_MESSAGES"]); - const result = await rest.runMethod( + return await rest.runMethod( "put", endpoints.CHANNEL_PIN(channelId, messageId), ); - - return result; } // aliases diff --git a/src/helpers/messages/publish_message.ts b/src/helpers/messages/publish_message.ts index 277f06a22..7d9d2ca17 100644 --- a/src/helpers/messages/publish_message.ts +++ b/src/helpers/messages/publish_message.ts @@ -1,14 +1,14 @@ import { rest } from "../../rest/rest.ts"; import { structures } from "../../structures/mod.ts"; -import { DiscordMessage } from "../../types/messages/message.ts"; +import { Message } from "../../types/messages/message.ts"; import { endpoints } from "../../util/constants.ts"; /** Crosspost a message in a News Channel to following channels. */ export async function publishMessage(channelId: string, messageId: string) { - const data = (await rest.runMethod( + const data = await rest.runMethod( "post", endpoints.CHANNEL_MESSAGE_CROSSPOST(channelId, messageId), - )) as DiscordMessage; + ); - return structures.createDiscordenoMessage(data); + return await structures.createDiscordenoMessage(data); } diff --git a/src/helpers/messages/remove_all_reactions.ts b/src/helpers/messages/remove_all_reactions.ts index c228ddfde..a97b81d9e 100644 --- a/src/helpers/messages/remove_all_reactions.ts +++ b/src/helpers/messages/remove_all_reactions.ts @@ -6,10 +6,8 @@ import { requireBotChannelPermissions } from "../../util/permissions.ts"; export async function removeAllReactions(channelId: string, messageId: string) { await requireBotChannelPermissions(channelId, ["MANAGE_MESSAGES"]); - const result = await rest.runMethod( + return await rest.runMethod( "delete", endpoints.CHANNEL_MESSAGE_REACTIONS(channelId, messageId), ); - - return result; } diff --git a/src/helpers/messages/remove_reaction.ts b/src/helpers/messages/remove_reaction.ts index 087cf6659..b8bd2f707 100644 --- a/src/helpers/messages/remove_reaction.ts +++ b/src/helpers/messages/remove_reaction.ts @@ -13,10 +13,8 @@ export async function removeReaction( reaction = reaction.substring(3, reaction.length - 1); } - const result = await rest.runMethod( + return await rest.runMethod( "delete", endpoints.CHANNEL_MESSAGE_REACTION_ME(channelId, messageId, reaction), ); - - return result; } diff --git a/src/helpers/messages/remove_reaction_emoji.ts b/src/helpers/messages/remove_reaction_emoji.ts index 0ed789a82..85a68a0be 100644 --- a/src/helpers/messages/remove_reaction_emoji.ts +++ b/src/helpers/messages/remove_reaction_emoji.ts @@ -16,10 +16,8 @@ export async function removeReactionEmoji( reaction = reaction.substring(3, reaction.length - 1); } - const result = await rest.runMethod( + return await rest.runMethod( "delete", endpoints.CHANNEL_MESSAGE_REACTION(channelId, messageId, reaction), ); - - return result; } diff --git a/src/helpers/messages/remove_user_reaction.ts b/src/helpers/messages/remove_user_reaction.ts index 4ae4ffb2b..7f5b67dfd 100644 --- a/src/helpers/messages/remove_user_reaction.ts +++ b/src/helpers/messages/remove_user_reaction.ts @@ -17,7 +17,7 @@ export async function removeUserReaction( reaction = reaction.substring(3, reaction.length - 1); } - const result = await rest.runMethod( + return await rest.runMethod( "delete", endpoints.CHANNEL_MESSAGE_REACTION_USER( channelId, @@ -26,6 +26,4 @@ export async function removeUserReaction( userId, ), ); - - return result; } diff --git a/src/helpers/messages/send_message.ts b/src/helpers/messages/send_message.ts index 802e876c4..73d00246f 100644 --- a/src/helpers/messages/send_message.ts +++ b/src/helpers/messages/send_message.ts @@ -4,7 +4,7 @@ import { structures } from "../../structures/mod.ts"; import { DiscordChannelTypes } from "../../types/channels/channel_types.ts"; import { DiscordAllowedMentionsTypes } from "../../types/messages/allowed_mentions_types.ts"; import { CreateMessage } from "../../types/messages/create_message.ts"; -import { DiscordMessage } from "../../types/messages/message.ts"; +import { DiscordMessage, Message } from "../../types/messages/message.ts"; import { Errors } from "../../types/misc/errors.ts"; import { PermissionStrings } from "../../types/permissions/permission_strings.ts"; import { endpoints } from "../../util/constants.ts"; @@ -93,7 +93,7 @@ export async function sendMessage( } } - const result = (await rest.runMethod( + const result = await rest.runMethod( "post", endpoints.CHANNEL_MESSAGES(channelId), camelKeysToSnakeCase({ @@ -107,7 +107,7 @@ export async function sendMessage( } : {}), }), - )) as DiscordMessage; + ); return structures.createDiscordenoMessage(result); } diff --git a/src/helpers/messages/unpin_message.ts b/src/helpers/messages/unpin_message.ts index c2a5630bf..1af948620 100644 --- a/src/helpers/messages/unpin_message.ts +++ b/src/helpers/messages/unpin_message.ts @@ -9,12 +9,10 @@ export async function unpin( ): Promise { await requireBotChannelPermissions(channelId, ["MANAGE_MESSAGES"]); - const result = await rest.runMethod( + return await rest.runMethod( "delete", endpoints.CHANNEL_PIN(channelId, messageId), ); - - return result; } // aliases