This commit is contained in:
Skillz4Killz
2021-11-19 02:36:58 +00:00
committed by GitHub
5 changed files with 18 additions and 8 deletions

View File

@@ -134,9 +134,7 @@ export async function sendInteractionResponse(
};
// A reply has never been send
if (bot.cache.unrepliedInteractions.has(id)) {
bot.cache.unrepliedInteractions.delete(id);
if (bot.cache.unrepliedInteractions.delete(id)) {
return await bot.rest.runMethod(bot.rest, "post", bot.constants.endpoints.INTERACTION_ID_TOKEN(id, token), {
type: options.type,
data,

View File

@@ -11,6 +11,7 @@ export async function addReaction(bot: Bot, channelId: bigint, messageId: bigint
return await bot.rest.runMethod<undefined>(
bot.rest,
"put",
bot.constants.endpoints.CHANNEL_MESSAGE_REACTION_ME(channelId, messageId, reaction)
bot.constants.endpoints.CHANNEL_MESSAGE_REACTION_ME(channelId, messageId, encodeURIComponent(reaction)),
{}
);
}

View File

@@ -11,10 +11,16 @@ export async function getReactions(
reaction: string,
options?: GetReactions
) {
if (reaction.startsWith("<:")) {
reaction = reaction.substring(2, reaction.length - 1);
} else if (reaction.startsWith("<a:")) {
reaction = reaction.substring(3, reaction.length - 1);
}
const users = await bot.rest.runMethod<User[]>(
bot.rest,
"get",
bot.constants.endpoints.CHANNEL_MESSAGE_REACTION(channelId, messageId, reaction),
bot.constants.endpoints.CHANNEL_MESSAGE_REACTION(channelId, messageId, encodeURIComponent(reaction)),
options
);

View File

@@ -18,7 +18,12 @@ export async function removeReaction(
bot.rest,
"delete",
options?.userId
? bot.constants.endpoints.CHANNEL_MESSAGE_REACTION_USER(channelId, messageId, reaction, options.userId)
: bot.constants.endpoints.CHANNEL_MESSAGE_REACTION_ME(channelId, messageId, reaction)
? bot.constants.endpoints.CHANNEL_MESSAGE_REACTION_USER(
channelId,
messageId,
encodeURIComponent(reaction),
options.userId
)
: bot.constants.endpoints.CHANNEL_MESSAGE_REACTION_ME(channelId, messageId, encodeURIComponent(reaction))
);
}

View File

@@ -44,7 +44,7 @@ export function createRequestBody(rest: RestManager, queuedRequest: { request: R
return {
headers,
body: (queuedRequest.payload.body?.file || JSON.stringify(queuedRequest.payload.body)) as FormData | string,
body: (queuedRequest.payload.body?.file ?? JSON.stringify(queuedRequest.payload.body)) as FormData | string,
method: queuedRequest.request.method.toUpperCase(),
};
}