fix: few more typings errors

This commit is contained in:
Skillz4Killz
2021-04-12 18:22:47 +00:00
committed by GitHub
parent 6d0529e8ce
commit 3ce5871eb9
5 changed files with 14 additions and 9 deletions
+3 -3
View File
@@ -7,7 +7,7 @@ import { DiscordMessage, Message } from "../../types/messages/message.ts";
import { snakeKeysToCamelCase } from "../../util/utils.ts"; import { snakeKeysToCamelCase } from "../../util/utils.ts";
export async function handleMessageCreate(data: DiscordGatewayPayload) { export async function handleMessageCreate(data: DiscordGatewayPayload) {
const payload: Message = snakeKeysToCamelCase(data.d as DiscordMessage); const payload = snakeKeysToCamelCase(data.d as DiscordMessage) as Message;
const channel = await cacheHandlers.get("channels", payload.channelId); const channel = await cacheHandlers.get("channels", payload.channelId);
if (channel) channel.lastMessageId = payload.id; if (channel) channel.lastMessageId = payload.id;
@@ -34,13 +34,13 @@ export async function handleMessageCreate(data: DiscordGatewayPayload) {
return cacheHandlers.set( return cacheHandlers.set(
"members", "members",
discordenoMember.id, mention.id,
discordenoMember, discordenoMember,
); );
} }
})); }));
const message = await structures.createDiscordenoMessage(payload); const message = await structures.createDiscordenoMessage(data.d as DiscordMessage);
// Cache the message // Cache the message
await cacheHandlers.set("messages", payload.id, message); await cacheHandlers.set("messages", payload.id, message);
+2 -1
View File
@@ -9,6 +9,7 @@ import {
requireBotChannelPermissions, requireBotChannelPermissions,
requireBotGuildPermissions, requireBotGuildPermissions,
} from "../../util/permissions.ts"; } from "../../util/permissions.ts";
import { snakeKeysToCamelCase } from "../../util/utils.ts";
/** Edit the member */ /** Edit the member */
export async function editMember( export async function editMember(
@@ -72,7 +73,7 @@ export async function editMember(
endpoints.GUILD_MEMBER(guildId, memberId), endpoints.GUILD_MEMBER(guildId, memberId),
options, options,
) as DiscordGuildMember; ) as DiscordGuildMember;
const member = await structures.createDiscordenoMember(result, guildId); const member = await structures.createDiscordenoMember(snakeKeysToCamelCase(result), guildId);
return member; return member;
} }
+6 -3
View File
@@ -1,12 +1,15 @@
import { rest } from "../../rest/rest.ts"; import { rest } from "../../rest/rest.ts";
import { ModifyWebhook } from "../../types/webhooks/modify_webhook.ts";
import { Webhook, DiscordWebhook } from "../../types/webhooks/webhook.ts";
import { endpoints } from "../../util/constants.ts"; import { endpoints } from "../../util/constants.ts";
import { requireBotChannelPermissions } from "../../util/permissions.ts"; import { requireBotChannelPermissions } from "../../util/permissions.ts";
import { snakeKeysToCamelCase } from "../../util/utils.ts";
/** Edit a webhook. Requires the `MANAGE_WEBHOOKS` permission. Returns the updated webhook object on success. */ /** Edit a webhook. Requires the `MANAGE_WEBHOOKS` permission. Returns the updated webhook object on success. */
export async function editWebhook( export async function editWebhook(
channelId: string, channelId: string,
webhookId: string, webhookId: string,
options: WebhookEditOptions, options: ModifyWebhook
) { ) {
await requireBotChannelPermissions(channelId, ["MANAGE_WEBHOOKS"]); await requireBotChannelPermissions(channelId, ["MANAGE_WEBHOOKS"]);
@@ -16,8 +19,8 @@ export async function editWebhook(
{ {
...options, ...options,
channel_id: options.channelId, channel_id: options.channelId,
}, }
); );
return result as WebhookPayload; return snakeKeysToCamelCase(result as DiscordWebhook) as Webhook;
} }
+1 -1
View File
@@ -22,7 +22,7 @@ export async function editWebhookMessage(
if (options.allowedMentions) { if (options.allowedMentions) {
if (options.allowedMentions.users?.length) { if (options.allowedMentions.users?.length) {
if (options.allowedMentions.parse.includes("users")) { if (options.allowedMentions.parse.includes(DiscordAllowedMentionsTypes.UserMentions)) {
options.allowedMentions.parse = options.allowedMentions.parse.filter( options.allowedMentions.parse = options.allowedMentions.parse.filter(
(p) => p !== "users" (p) => p !== "users"
); );
@@ -1,4 +1,5 @@
import { rest } from "../../rest/rest.ts"; import { rest } from "../../rest/rest.ts";
import { ModifyWebhook } from "../../types/webhooks/modify_webhook.ts";
import { Webhook } from "../../types/webhooks/webhook.ts"; import { Webhook } from "../../types/webhooks/webhook.ts";
import { endpoints } from "../../util/constants.ts"; import { endpoints } from "../../util/constants.ts";
import { snakeKeysToCamelCase } from "../../util/utils.ts"; import { snakeKeysToCamelCase } from "../../util/utils.ts";
@@ -7,7 +8,7 @@ import { snakeKeysToCamelCase } from "../../util/utils.ts";
export async function editWebhookWithToken( export async function editWebhookWithToken(
webhookId: string, webhookId: string,
webhookToken: string, webhookToken: string,
options: Omit<WebhookEditOptions, "channelId">, options: Omit<ModifyWebhook, "channelId">,
) { ) {
const result = await rest.runMethod( const result = await rest.runMethod(
"patch", "patch",