mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-02 08:50:07 +00:00
Merge pull request #1712 from Skillz4Killz/fp-attempt-9001
Fp attempt 9001
This commit is contained in:
@@ -193,6 +193,7 @@ export function createEventHandlers(events: Partial<EventHandlers>): 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,
|
||||
|
||||
@@ -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")) {
|
||||
|
||||
@@ -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?: {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -14,6 +14,7 @@ export enum DiscordUserFlags {
|
||||
VerifiedBot = 1 << 16,
|
||||
EarlyVerifiedBotDeveloper = 1 << 17,
|
||||
DiscordCertifiedModerator = 1 << 18,
|
||||
BotHttpInteractions = 1 << 19,
|
||||
}
|
||||
|
||||
export type UserFlags = DiscordUserFlags;
|
||||
|
||||
@@ -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) */
|
||||
|
||||
36
tests/helpers/channels/editChannel.ts
Normal file
36
tests/helpers/channels/editChannel.ts
Normal file
@@ -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<Cache>,
|
||||
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");
|
||||
}
|
||||
15
tests/mod.ts
15
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);
|
||||
},
|
||||
}),
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user