fix: more typings errors

This commit is contained in:
Skillz4Killz
2021-04-12 20:02:56 +00:00
committed by GitHub
parent 2fc28165f3
commit 9a7747b7ab
8 changed files with 32 additions and 28 deletions
+2 -2
View File
@@ -23,7 +23,7 @@ export async function editSlashResponse(
if (options.allowedMentions) {
if (options.allowedMentions.users?.length) {
if (
options.allowedMentions.parse.includes(
options.allowedMentions.parse?.includes(
DiscordAllowedMentionsTypes.UserMentions,
)
) {
@@ -42,7 +42,7 @@ export async function editSlashResponse(
if (options.allowedMentions.roles?.length) {
if (
options.allowedMentions.parse.includes(
options.allowedMentions.parse?.includes(
DiscordAllowedMentionsTypes.RoleMentions,
)
) {
+11 -5
View File
@@ -2,15 +2,21 @@ import { CreateGuildBan } from "../../types/guilds/create_guild_ban.ts";
import { rest } from "../../rest/rest.ts";
import { endpoints } from "../../util/constants.ts";
import { requireBotGuildPermissions } from "../../util/permissions.ts";
import { camelKeysToSnakeCase } from "../../util/utils.ts";
/** Ban a user from the guild and optionally delete previous messages sent by the user. Requires the BAN_MEMBERS permission. */
export async function ban(guildId: string, id: string, options: CreateGuildBan) {
export async function ban(
guildId: string,
id: string,
options: CreateGuildBan
) {
await requireBotGuildPermissions(guildId, ["BAN_MEMBERS"]);
const result = await rest.runMethod("put", endpoints.GUILD_BAN(guildId, id), {
...options,
delete_message_days: options.days,
});
const result = await rest.runMethod(
"put",
endpoints.GUILD_BAN(guildId, id),
camelKeysToSnakeCase(options)
);
return result;
}
+5 -5
View File
@@ -10,7 +10,7 @@ import {
requireBotChannelPermissions,
requireBotGuildPermissions,
} from "../../util/permissions.ts";
import { snakeKeysToCamelCase } from "../../util/utils.ts";
import { camelKeysToSnakeCase, snakeKeysToCamelCase } from "../../util/utils.ts";
/** Edit the member */
export async function editMember(
@@ -32,7 +32,7 @@ export async function editMember(
if (
typeof options.mute !== "undefined" ||
typeof options.deaf !== "undefined" ||
(typeof options.channel_id !== "undefined" || "null")
(typeof options.channelId !== "undefined" || "null")
) {
const memberVoiceState = (await cacheHandlers.get("guilds", guildId))
?.voiceStates.get(memberId);
@@ -49,7 +49,7 @@ export async function editMember(
requiredPerms.add("DEAFEN_MEMBERS");
}
if (options.channel_id) {
if (options.channelId) {
const requiredVoicePerms: Set<PermissionStrings> = new Set([
"CONNECT",
"MOVE_MEMBERS",
@@ -61,7 +61,7 @@ export async function editMember(
);
}
await requireBotChannelPermissions(
options.channel_id,
options.channelId,
[...requiredVoicePerms],
);
}
@@ -72,7 +72,7 @@ export async function editMember(
const result = await rest.runMethod(
"patch",
endpoints.GUILD_MEMBER(guildId, memberId),
options,
camelKeysToSnakeCase(options),
) as DiscordGuildMember;
const member = await structures.createDiscordenoMember(
snakeKeysToCamelCase(result),
+1 -1
View File
@@ -11,5 +11,5 @@ export function moveMember(
memberId: string,
channelId: string,
) {
return editMember(guildId, memberId, { channel_id: channelId });
return editMember(guildId, memberId, { channelId });
}
+8 -7
View File
@@ -1,16 +1,19 @@
import { botId } from "../../bot.ts";
import { rest } from "../../rest/rest.ts";
import { Message, structures } from "../../structures/mod.ts";
import { DiscordenoMessage } from "../../structures/message.ts";
import { structures } from "../../structures/mod.ts";
import { CreateMessage } from "../../types/messages/create_message.ts";
import { EditMessage } from "../../types/messages/edit_message.ts";
import { DiscordMessage } from "../../types/messages/message.ts";
import { Errors } from "../../types/misc/errors.ts";
import { DiscordMessage } from "../../types/mod.ts";
import { PermissionStrings } from "../../types/permissions/permission_strings.ts";
import { endpoints } from "../../util/constants.ts";
import { requireBotChannelPermissions } from "../../util/permissions.ts";
/** Edit the message. */
export async function editMessage(
message: Message,
content: string | MessageContent,
message: DiscordenoMessage,
content: string | EditMessage
) {
if (message.author.id !== botId) {
throw "You can only edit a message that was sent by the bot.";
@@ -20,8 +23,6 @@ export async function editMessage(
const requiredPerms: PermissionStrings[] = ["SEND_MESSAGES"];
if (content.tts) requiredPerms.push("SEND_TTS_MESSAGES");
await requireBotChannelPermissions(message.channelId, requiredPerms);
if (content.content && content.content.length > 2000) {
@@ -31,7 +32,7 @@ export async function editMessage(
const result: DiscordMessage = await rest.runMethod(
"patch",
endpoints.CHANNEL_MESSAGE(message.channelId, message.id),
content,
content
);
return structures.createDiscordenoMessage(result);
+2 -2
View File
@@ -23,7 +23,7 @@ export async function editWebhookMessage(
if (options.allowedMentions) {
if (options.allowedMentions.users?.length) {
if (
options.allowedMentions.parse.includes(
options.allowedMentions.parse?.includes(
DiscordAllowedMentionsTypes.UserMentions,
)
) {
@@ -42,7 +42,7 @@ export async function editWebhookMessage(
if (options.allowedMentions.roles?.length) {
if (
options.allowedMentions.parse.includes(
options.allowedMentions.parse?.includes(
DiscordAllowedMentionsTypes.RoleMentions,
)
) {
+2 -5
View File
@@ -27,7 +27,7 @@ export async function executeWebhook(
if (options.allowedMentions) {
if (options.allowedMentions.users?.length) {
if (
options.allowedMentions.parse.includes(
options.allowedMentions.parse?.includes(
DiscordAllowedMentionsTypes.UserMentions,
)
) {
@@ -46,7 +46,7 @@ export async function executeWebhook(
if (options.allowedMentions.roles?.length) {
if (
options.allowedMentions.parse.includes(
options.allowedMentions.parse?.includes(
DiscordAllowedMentionsTypes.RoleMentions,
)
) {
@@ -80,6 +80,3 @@ export async function executeWebhook(
return structures.createDiscordenoMessage(result as DiscordMessage);
}
function DiscordAllowedMentionTypes(DiscordAllowedMentionTypes: any) {
throw new Error("Function not implemented.");
}
+1 -1
View File
@@ -57,7 +57,7 @@ const baseMessage: Partial<DiscordenoMessage> = {
return deleteMessage(this.channelId!, this.id!, reason, delayMilliseconds);
},
edit(content) {
return editMessage(this as Message, content);
return editMessage(this as DiscordenoMessage, content);
},
pin() {
return pinMessage(this.channelId!, this.id!);