From 6b39a903ac743ed81b58a9f74031807e4e8c9991 Mon Sep 17 00:00:00 2001 From: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com> Date: Thu, 4 Nov 2021 01:27:05 +0000 Subject: [PATCH 1/9] Closes [api-docs] Suppress member join sticker replies system channel flag. #1709 --- src/types/guilds/system_channel_flags.ts | 2 ++ tests/helpers/channels/editChannel.ts | 36 ++++++++++++++++++++++++ tests/mod.ts | 17 +++++++++-- 3 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 tests/helpers/channels/editChannel.ts diff --git a/src/types/guilds/system_channel_flags.ts b/src/types/guilds/system_channel_flags.ts index 81a5e2e79..9439a58d3 100644 --- a/src/types/guilds/system_channel_flags.ts +++ b/src/types/guilds/system_channel_flags.ts @@ -6,6 +6,8 @@ export enum DiscordSystemChannelFlags { SuppressPremiumSubscriptions = 1 << 1, /** Suppress server setup tips */ SuppressGuildReminderNotifications = 1 << 2, + /** Hide member join sticker reply buttons */ + SuppressJoinNotificationReplies = 1 << 3, } export type SystemChannelFlags = DiscordSystemChannelFlags; diff --git a/tests/helpers/channels/editChannel.ts b/tests/helpers/channels/editChannel.ts new file mode 100644 index 000000000..b52a8a256 --- /dev/null +++ b/tests/helpers/channels/editChannel.ts @@ -0,0 +1,36 @@ +import { Bot } from "../../../src/bot.ts"; +import { Cache } from "../../../src/cache.ts"; +import { assertEquals } from "../../deps.ts"; +import { delayUntil } from "../../utils.ts"; + +export async function editChannelTests( + bot: Bot, + guildId: bigint, + options: { reason?: string }, + t: Deno.TestContext +) { + // Create the necessary channels + const channel = await bot.helpers.createChannel(guildId, { + name: "edit-channel", + }); + // wait 5 seconds to give it time for CHANNEL_CREATE event + await delayUntil(3000, () => bot.cache.channels.has(channel.id)); + // Make sure the channel was created. + if (!bot.cache.channels.has(channel.id)) { + throw new Error("The channel should have been created but it is not in the cache."); + } + + // Edit the channel now + + await bot.helpers.editChannel( + channel.id, + { + name: "new-name", + }, + options.reason + ); + + // wait 5 seconds to give it time for CHANNEL_UPDATE event + await delayUntil(3000, () => bot.cache.channels.get(channel.id)?.name === "new-name"); + assertEquals(bot.cache.channels.get(channel.id)?.name, "new-name"); +} diff --git a/tests/mod.ts b/tests/mod.ts index 778fae9df..75541f53b 100644 --- a/tests/mod.ts +++ b/tests/mod.ts @@ -61,6 +61,7 @@ import { categoryChildrenTest } from "./helpers/channels/categoryChannels.ts"; import { channelOverwriteHasPermissionTest } from "./helpers/channels/channelOverwriteHasPermission.ts"; import { cloneChannelTests } from "./helpers/channels/cloneChannel.ts"; import { deleteChannelOverwriteTests } from "./helpers/channels/deleteChannelOverwrite.ts"; +import { editChannelTests } from "./helpers/channels/editChannel.ts"; // CHANGE TO TRUE WHEN DEBUGGING SANITIZATION ERRORS const sanitizeMode = { @@ -565,7 +566,7 @@ Deno.test({ } }), t.step({ - name: "[channel] clone a channel w a reason", + name: "[channel] clone a channel w/ a reason", async fn() { await cloneChannelTests(bot, guild.id, channel, { reason: "Blame wolf"}, t); } @@ -575,7 +576,19 @@ Deno.test({ async fn() { await deleteChannelOverwriteTests(bot, guild.id, t); } - }) + }), + t.step({ + name: "[channel] edit a channel w/o a reason", + async fn() { + await editChannelTests(bot, guild.id, {}, t); + } + }), + t.step({ + name: "[channel] edit a channel w/ a reason", + async fn() { + await editChannelTests(bot, guild.id, { reason: "Blame wolf"}, t); + } + }), ]); // ALL TEST RELATED TO INVITES From f94957bfe358a0787a71452cbb4f96f4ad158e7e Mon Sep 17 00:00:00 2001 From: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com> Date: Thu, 4 Nov 2021 01:37:17 +0000 Subject: [PATCH 2/9] Closes #1707 --- src/types/users/user_flags.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/types/users/user_flags.ts b/src/types/users/user_flags.ts index 44a481cc2..cac03389a 100644 --- a/src/types/users/user_flags.ts +++ b/src/types/users/user_flags.ts @@ -14,6 +14,7 @@ export enum DiscordUserFlags { VerifiedBot = 1 << 16, EarlyVerifiedBotDeveloper = 1 << 17, DiscordCertifiedModerator = 1 << 18, + BotHttpInteractions = 1 << 19, } export type UserFlags = DiscordUserFlags; From d3be9ab852ec8451688b407cc4b0661758cbcd54 Mon Sep 17 00:00:00 2001 From: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com> Date: Thu, 4 Nov 2021 01:44:58 +0000 Subject: [PATCH 3/9] Closes #1705 --- src/types/applications/application_flags.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/types/applications/application_flags.ts b/src/types/applications/application_flags.ts index d2ada528b..9c13ad61f 100644 --- a/src/types/applications/application_flags.ts +++ b/src/types/applications/application_flags.ts @@ -6,6 +6,8 @@ export enum DiscordApplicationFlags { GatewayGuildMembersLimited = 1 << 15, VerificationPendingGuildLimit = 1 << 16, Embedded = 1 << 17, + GatewayMessageCount = 1 << 18, + GatewayMessageContentLimited = 1 << 19, } export type ApplicationFlags = DiscordApplicationFlags; From 74f5d72cfaadc5b1e12e1f13c86963ac93cffac0 Mon Sep 17 00:00:00 2001 From: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com> Date: Thu, 4 Nov 2021 01:46:37 +0000 Subject: [PATCH 4/9] Closes #1704 --- src/types/activity/activity_flags.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/types/activity/activity_flags.ts b/src/types/activity/activity_flags.ts index a51521231..eafe0e0d9 100644 --- a/src/types/activity/activity_flags.ts +++ b/src/types/activity/activity_flags.ts @@ -6,6 +6,9 @@ export enum DiscordActivityFlags { JoinRequest = 1 << 3, Sync = 1 << 4, Play = 1 << 5, + PartyPrivacyFriends = 1 << 6, + PartyPrivacyVoiceChannel = 1 << 7, + Embedded = 1 << 8, } export type ActivityFlags = DiscordActivityFlags; From 2cc1ef02281d67c2718370097a86b4588c03d8f8 Mon Sep 17 00:00:00 2001 From: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com> Date: Thu, 4 Nov 2021 01:48:03 +0000 Subject: [PATCH 5/9] Closes #1680 --- src/types/voice/voice_region.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/types/voice/voice_region.ts b/src/types/voice/voice_region.ts index e7c311444..8b54821e8 100644 --- a/src/types/voice/voice_region.ts +++ b/src/types/voice/voice_region.ts @@ -4,8 +4,6 @@ export interface VoiceRegion { id: string; /** Name of the region */ name: string; - /** true if this is a vip-only server */ - vip: boolean; /** true for a single server that is closest to the current user's client */ optimal: boolean; /** Whether this is a deprecated voice region (avoid swithing to these) */ From 6e5b0b01f1156c8131f676a53073085ff2eb8031 Mon Sep 17 00:00:00 2001 From: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com> Date: Thu, 4 Nov 2021 01:52:34 +0000 Subject: [PATCH 6/9] Closes #1609 --- src/transformers/component.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/transformers/component.ts b/src/transformers/component.ts index 29a86f14d..ab646422f 100644 --- a/src/transformers/component.ts +++ b/src/transformers/component.ts @@ -73,11 +73,11 @@ export interface Component { } export interface SelectOption { - /** The user-facing name of the option. Maximum 25 characters. */ + /** The user-facing name of the option. Maximum 100 characters. */ label: string; /** The dev-defined value of the option. Maximum 100 characters. */ value: string; - /** An additional description of the option. Maximum 50 characters. */ + /** An additional description of the option. Maximum 100 characters. */ description?: string; /** The id, name, and animated properties of an emoji. */ emoji?: { From 47dd2f4dd58117f435f87529f8359cffc470ce8f Mon Sep 17 00:00:00 2001 From: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com> Date: Thu, 4 Nov 2021 13:10:02 +0000 Subject: [PATCH 7/9] Closes #1412 --- src/types/codes/voice_close_event_codes.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/types/codes/voice_close_event_codes.ts b/src/types/codes/voice_close_event_codes.ts index a447dd853..f626c8c70 100644 --- a/src/types/codes/voice_close_event_codes.ts +++ b/src/types/codes/voice_close_event_codes.ts @@ -9,6 +9,7 @@ export enum DiscordVoiceCloseEventCodes { SessionTimedOut = 4009, ServerNotFound = 4011, UnknownProtocol, + /** Channel was deleted, you were kicked, voice server changed, or the main gateway session was dropped. Should not reconnect. */ Disconnect = 4014, VoiceServerCrashed, UnknownEncryptionMode, From bae1de4a81c8a724b22b4670477a6775e5b5640f Mon Sep 17 00:00:00 2001 From: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com> Date: Thu, 4 Nov 2021 15:52:26 +0000 Subject: [PATCH 8/9] Closes #1427 --- src/rest/simplify_url.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/rest/simplify_url.ts b/src/rest/simplify_url.ts index a2e0b7077..4e3078f40 100644 --- a/src/rest/simplify_url.ts +++ b/src/rest/simplify_url.ts @@ -7,10 +7,9 @@ export function simplifyUrl(url: string, method: string) { let route = url .replace(/\/([a-z-]+)\/(?:[0-9]{17,19})/g, function (match, p) { - return ["channels", "guilds", "webhooks"].includes(p) ? match : `/${p}/skillzPrefersID`; + return ["channels", "guilds"].includes(p) ? match : `/${p}/skillzPrefersID`; }) .replace(/\/reactions\/[^/]+/g, "/reactions/skillzPrefersID") - .replace(/^\/webhooks\/(\d+)\/[A-Za-z0-9-_]{64,}/, "/webhooks/$1/:itohIsAHoti"); // GENERAL /reactions and /reactions/emoji/@me share the buckets if (route.includes("/reactions")) { From c4bc2c03d24014aa1e1786073c2149c2088ac16d Mon Sep 17 00:00:00 2001 From: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com> Date: Fri, 5 Nov 2021 15:07:28 +0000 Subject: [PATCH 9/9] support custom url on rest --- src/bot.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/bot.ts b/src/bot.ts index b70c8ab4d..07d00846a 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -193,6 +193,7 @@ export function createEventHandlers(events: Partial): EventHandle export interface CreateRestManagerOptions { token: string; + customUrl?: string; maxRetryCount?: number; version?: number; secretKey?: string; @@ -210,10 +211,16 @@ export interface CreateRestManagerOptions { } export function createRestManager(options: CreateRestManagerOptions) { + const version = options.version || "9"; + + if (options.customUrl) { + baseEndpoints.BASE_URL = `${options.customUrl}/v${version}` + } + return { + version, token: `${options.token.startsWith("Bot ") ? "" : "Bot "}${options.token}`, maxRetryCount: options.maxRetryCount || 10, - version: options.version || "9", secretKey: options.secretKey || "discordeno_best_lib_ever", pathQueues: new Map< string,