From aefd5c75f5488e8351a0df7fdb2c75becd2e9603 Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Tue, 4 May 2021 21:05:43 +0200 Subject: [PATCH] fix changes --- src/handlers/channels/CHANNEL_DELETE.ts | 2 +- src/helpers/channels/clone_channel.ts | 2 +- src/helpers/channels/start_typing.ts | 2 +- src/helpers/members/fetch_members.ts | 2 +- src/helpers/members/get_members.ts | 2 +- src/helpers/messages/send_message.ts | 2 +- src/structures/guild.ts | 4 ++-- src/types/channels/channel_types.ts | 2 +- src/util/utils.ts | 8 ++++---- tests/channels/channel_overwrite_has_permission.ts | 2 +- tests/channels/clone_channel.ts | 2 +- tests/channels/create_channel.ts | 2 +- tests/channels/delete_channel_overwrite.ts | 2 +- tests/channels/edit_channel_overwrite.ts | 4 ++-- tests/channels/is_channel_synced.ts | 2 +- tests/ws/start_bot.ts | 9 ++++----- 16 files changed, 24 insertions(+), 25 deletions(-) diff --git a/src/handlers/channels/CHANNEL_DELETE.ts b/src/handlers/channels/CHANNEL_DELETE.ts index 511aae6c9..a2e07b828 100644 --- a/src/handlers/channels/CHANNEL_DELETE.ts +++ b/src/handlers/channels/CHANNEL_DELETE.ts @@ -37,7 +37,7 @@ export async function handleChannelDelete(data: DiscordGatewayPayload) { if ( [ DiscordChannelTypes.GuildText, - DiscordChannelTypes.Dm, + DiscordChannelTypes.DM, DiscordChannelTypes.GroupDm, DiscordChannelTypes.GuildNews, ].includes(payload.type) diff --git a/src/helpers/channels/clone_channel.ts b/src/helpers/channels/clone_channel.ts index 632fc770f..6a3696fac 100644 --- a/src/helpers/channels/clone_channel.ts +++ b/src/helpers/channels/clone_channel.ts @@ -14,7 +14,7 @@ export async function cloneChannel(channelId: bigint, reason?: string) { //Check for DM channel if ( - channelToClone.type === DiscordChannelTypes.Dm || + channelToClone.type === DiscordChannelTypes.DM || channelToClone.type === DiscordChannelTypes.GroupDm ) { throw new Error(Errors.CHANNEL_NOT_IN_GUILD); diff --git a/src/helpers/channels/start_typing.ts b/src/helpers/channels/start_typing.ts index 4f65aa771..8a48c8ccc 100644 --- a/src/helpers/channels/start_typing.ts +++ b/src/helpers/channels/start_typing.ts @@ -16,7 +16,7 @@ export async function startTyping(channelId: bigint) { if (channel) { if ( ![ - DiscordChannelTypes.Dm, + DiscordChannelTypes.DM, DiscordChannelTypes.GuildNews, DiscordChannelTypes.GuildText, DiscordChannelTypes.GuildNewsThread, diff --git a/src/helpers/members/fetch_members.ts b/src/helpers/members/fetch_members.ts index eca4c7720..2781bafa1 100644 --- a/src/helpers/members/fetch_members.ts +++ b/src/helpers/members/fetch_members.ts @@ -24,7 +24,7 @@ export function fetchMembers( // You can request 1 member without the intent if ( (!options?.limit || options.limit > 1) && - !(ws.identifyPayload.intents & DiscordGatewayIntents.GUILD_MEMBERS) + !(ws.identifyPayload.intents & DiscordGatewayIntents.GuildMembers) ) { throw new Error(Errors.MISSING_INTENT_GUILD_MEMBERS); } diff --git a/src/helpers/members/get_members.ts b/src/helpers/members/get_members.ts index 6a7c95dd4..2305d0cbc 100644 --- a/src/helpers/members/get_members.ts +++ b/src/helpers/members/get_members.ts @@ -24,7 +24,7 @@ export async function getMembers( guildId: bigint, options?: ListGuildMembers & { addToCache?: boolean }, ) { - if (!(ws.identifyPayload.intents && DiscordGatewayIntents.GUILD_MEMBERS)) { + if (!(ws.identifyPayload.intents && DiscordGatewayIntents.GuildMembers)) { throw new Error(Errors.MISSING_INTENT_GUILD_MEMBERS); } diff --git a/src/helpers/messages/send_message.ts b/src/helpers/messages/send_message.ts index ff80dfb53..4e1249b0c 100644 --- a/src/helpers/messages/send_message.ts +++ b/src/helpers/messages/send_message.ts @@ -26,7 +26,7 @@ export async function sendMessage( if (channel) { if ( ![ - DiscordChannelTypes.Dm, + DiscordChannelTypes.DM, DiscordChannelTypes.GuildNews, DiscordChannelTypes.GuildText, DiscordChannelTypes.GuildPublicThread, diff --git a/src/structures/guild.ts b/src/structures/guild.ts index e90f0f5b2..02da59f03 100644 --- a/src/structures/guild.ts +++ b/src/structures/guild.ts @@ -92,10 +92,10 @@ const baseGuild: Partial = { return cache.members.get(this.ownerId!); }, get partnered() { - return Boolean(this.features?.includes(DiscordGuildFeatures.PARTNERED)); + return Boolean(this.features?.includes(DiscordGuildFeatures.Partnered)); }, get verified() { - return Boolean(this.features?.includes(DiscordGuildFeatures.VERIFIED)); + return Boolean(this.features?.includes(DiscordGuildFeatures.Verified)); }, bannerURL(size, format) { return guildBannerURL(this.id!, this.banner!, size, format); diff --git a/src/types/channels/channel_types.ts b/src/types/channels/channel_types.ts index 26a3ce5e4..aec5aed04 100644 --- a/src/types/channels/channel_types.ts +++ b/src/types/channels/channel_types.ts @@ -3,7 +3,7 @@ export enum DiscordChannelTypes { /** A text channel within a server */ GuildText, /** A direct message between users */ - Dm, + DM, /** A voice channel within a server */ GuildVoice, /** A direct message between multiple users */ diff --git a/src/util/utils.ts b/src/util/utils.ts index c37bcb0fd..4b81719c6 100644 --- a/src/util/utils.ts +++ b/src/util/utils.ts @@ -130,11 +130,11 @@ function validateSlashOptionChoices( } if ( - (optionType === DiscordApplicationCommandOptionTypes.STRING && + (optionType === DiscordApplicationCommandOptionTypes.String && (typeof choice.value !== "string" || choice.value.length < 1 || choice.value.length > 100)) || - (optionType === DiscordApplicationCommandOptionTypes.INTEGER && + (optionType === DiscordApplicationCommandOptionTypes.Integer && typeof choice.value !== "number") ) { throw new Error(Errors.INVALID_SLASH_OPTIONS_CHOICES); @@ -152,8 +152,8 @@ function validateSlashOptions(options: ApplicationCommandOption[]) { if ( option.choices?.length && (option.choices.length > 25 || - (option.type !== DiscordApplicationCommandOptionTypes.STRING && - option.type !== DiscordApplicationCommandOptionTypes.INTEGER)) + (option.type !== DiscordApplicationCommandOptionTypes.String && + option.type !== DiscordApplicationCommandOptionTypes.Integer)) ) { throw new Error(Errors.INVALID_SLASH_OPTIONS_CHOICES); } diff --git a/tests/channels/channel_overwrite_has_permission.ts b/tests/channels/channel_overwrite_has_permission.ts index 71d3402b3..ff84e4add 100644 --- a/tests/channels/channel_overwrite_has_permission.ts +++ b/tests/channels/channel_overwrite_has_permission.ts @@ -53,7 +53,7 @@ Deno.test({ permissionOverwrites: [ { id: bigintToSnowflake(botId), - type: DiscordOverwriteTypes.MEMBER, + type: DiscordOverwriteTypes.Member, allow: ["VIEW_CHANNEL"], deny: [], }, diff --git a/tests/channels/clone_channel.ts b/tests/channels/clone_channel.ts index 4b526da61..9838a7698 100644 --- a/tests/channels/clone_channel.ts +++ b/tests/channels/clone_channel.ts @@ -141,7 +141,7 @@ Deno.test({ permissionOverwrites: [ { id: bigintToSnowflake(botId), - type: DiscordOverwriteTypes.MEMBER, + type: DiscordOverwriteTypes.Member, allow: ["VIEW_CHANNEL"], deny: [], }, diff --git a/tests/channels/create_channel.ts b/tests/channels/create_channel.ts index fbc85d1d5..63b44ec7e 100644 --- a/tests/channels/create_channel.ts +++ b/tests/channels/create_channel.ts @@ -160,7 +160,7 @@ Deno.test({ permissionOverwrites: [ { id: bigintToSnowflake(botId), - type: DiscordOverwriteTypes.MEMBER, + type: DiscordOverwriteTypes.Member, allow: ["VIEW_CHANNEL"], deny: [], }, diff --git a/tests/channels/delete_channel_overwrite.ts b/tests/channels/delete_channel_overwrite.ts index fc033dff3..d5337c631 100644 --- a/tests/channels/delete_channel_overwrite.ts +++ b/tests/channels/delete_channel_overwrite.ts @@ -56,7 +56,7 @@ Deno.test({ permissionOverwrites: [ { id: bigintToSnowflake(botId), - type: DiscordOverwriteTypes.MEMBER, + type: DiscordOverwriteTypes.Member, allow: ["VIEW_CHANNEL"], deny: [], }, diff --git a/tests/channels/edit_channel_overwrite.ts b/tests/channels/edit_channel_overwrite.ts index b1482b4f5..e74c244cd 100644 --- a/tests/channels/edit_channel_overwrite.ts +++ b/tests/channels/edit_channel_overwrite.ts @@ -35,7 +35,7 @@ async function ifItFailsBlameWolf(options: CreateGuildChannel) { } await editChannelOverwrite(channel.guildId, channel.id, botId, { - type: DiscordOverwriteTypes.MEMBER, + type: DiscordOverwriteTypes.Member, allow: ["VIEW_CHANNEL", "ADD_REACTIONS"], deny: [], }); @@ -71,7 +71,7 @@ Deno.test({ permissionOverwrites: [ { id: bigintToSnowflake(botId), - type: DiscordOverwriteTypes.MEMBER, + type: DiscordOverwriteTypes.Member, allow: ["VIEW_CHANNEL"], deny: [], }, diff --git a/tests/channels/is_channel_synced.ts b/tests/channels/is_channel_synced.ts index c341b3374..6a4d96db7 100644 --- a/tests/channels/is_channel_synced.ts +++ b/tests/channels/is_channel_synced.ts @@ -18,7 +18,7 @@ Deno.test({ permissionOverwrites: [ { id: bigintToSnowflake(botId), - type: DiscordOverwriteTypes.MEMBER, + type: DiscordOverwriteTypes.Member, allow: ["VIEW_CHANNEL"], deny: [], }, diff --git a/tests/ws/start_bot.ts b/tests/ws/start_bot.ts index a68b2d0fc..266da17e9 100644 --- a/tests/ws/start_bot.ts +++ b/tests/ws/start_bot.ts @@ -36,11 +36,10 @@ Deno.test({ await startBot({ token, intents: [ - "GUILD_MESSAGES", - "GUILDS", - "GUILD_EMOJIS", - "GUILD_MESSAGE_REACTIONS", - "GUILD_EMOJIS", + "GuildMessages", + "Guilds", + "GuildEmojis", + "GuildMessageReactions", ], });