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, 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")) { 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?: { 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; 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; 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, 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/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; 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) */ 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 3cdede3b5..ad6f99956 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); }, @@ -574,6 +575,18 @@ Deno.test({ name: "[channel] delete a channel overwrite", 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); }, }), ]);