mirror of
https://github.com/discordeno/discordeno.git
synced 2026-05-31 16:00:07 +00:00
feat: add scheduled events unit tests
This commit is contained in:
@@ -1,12 +1,30 @@
|
||||
import { Bot } from "../../../bot.ts";
|
||||
import { CreateScheduledEvent, ScheduledEvent } from "../../../types/guilds/scheduledEvents.ts";
|
||||
import {
|
||||
CreateScheduledEvent,
|
||||
ScheduledEvent,
|
||||
ScheduledEventEntityType,
|
||||
ScheduledEventPrivacyLevel,
|
||||
} from "../../../types/guilds/scheduledEvents.ts";
|
||||
|
||||
/** Create a guild scheduled event in the guild. A guild can have a maximum of 100 events with `SCHEDULED` or `ACTIVE` status at any time. */
|
||||
export async function createScheduledEvent(bot: Bot, guildId: bigint, options: CreateScheduledEvent) {
|
||||
// TODO: validate name length
|
||||
// TODO: validate description length
|
||||
// TODO: validate location length
|
||||
// TODO: validate speaker ids length
|
||||
if (!bot.utils.validateLength(options.name, { min: 1, max: 100 }))
|
||||
throw new Error("Name must be between 1-100 characters.");
|
||||
if (options.description && !bot.utils.validateLength(options.description, { max: 1000 }))
|
||||
throw new Error("Description must be below 1000 characters.");
|
||||
if (options.location) {
|
||||
if (!bot.utils.validateLength(options.location, { max: 100 }))
|
||||
throw new Error("Location must be below 100 characters.");
|
||||
if (options.entityType === ScheduledEventEntityType.Voice)
|
||||
throw new Error("Location can not be provided for a Voice event.");
|
||||
}
|
||||
if (options.entityType === ScheduledEventEntityType.External) {
|
||||
if (!options.scheduledEndTime) throw new Error("A scheduled end time is required when making an External event.");
|
||||
if (!options.location) throw new Error("A location is required when making an External event.");
|
||||
}
|
||||
if (options.scheduledStartTime && options.scheduledEndTime && options.scheduledStartTime > options.scheduledEndTime) {
|
||||
throw new Error("Cannot schedule event to end before starting.");
|
||||
}
|
||||
|
||||
const event = await bot.rest.runMethod<ScheduledEvent>(
|
||||
bot.rest,
|
||||
@@ -14,15 +32,12 @@ export async function createScheduledEvent(bot: Bot, guildId: bigint, options: C
|
||||
bot.constants.endpoints.GUILD_SCHEDULED_EVENTS(guildId),
|
||||
{
|
||||
channel_id: options.channelId?.toString(),
|
||||
entity_metadata:
|
||||
options.location || options.speakerIds
|
||||
? { location: options.location, speakerIds: options.speakerIds?.map((id) => id.toString()) }
|
||||
: undefined,
|
||||
entity_metadata: options.location ? { location: options.location } : undefined,
|
||||
name: options.name,
|
||||
description: options.description,
|
||||
scheduled_start_time: new Date(options.scheduledStartTime).toISOString(),
|
||||
scheduled_end_time: options.scheduledEndTime ? new Date(options.scheduledEndTime).toISOString() : undefined,
|
||||
privacy_level: options.privacyLevel,
|
||||
privacy_level: options.privacyLevel || ScheduledEventPrivacyLevel.GuildOnly,
|
||||
entity_type: options.entityType,
|
||||
}
|
||||
);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Bot } from "../../../bot.ts";
|
||||
import { EditScheduledEvent, ScheduledEvent } from "../../../types/guilds/scheduledEvents.ts";
|
||||
import { EditScheduledEvent, ScheduledEvent, ScheduledEventEntityType } from "../../../types/guilds/scheduledEvents.ts";
|
||||
|
||||
/** Modify a guild scheduled event. To start or end an event, use this endpoint to modify the event's status. */
|
||||
export async function editScheduledEvent(
|
||||
@@ -8,21 +8,23 @@ export async function editScheduledEvent(
|
||||
eventId: bigint,
|
||||
options: Partial<EditScheduledEvent>
|
||||
) {
|
||||
// TODO: validate name length
|
||||
// TODO: validate description length
|
||||
// TODO: validate location length
|
||||
// TODO: validate speaker ids length
|
||||
if (options.name && !bot.utils.validateLength(options.name, { min: 1, max: 100 }))
|
||||
throw new Error("Name must be between 1-100 characters.");
|
||||
if (options.description && !bot.utils.validateLength(options.description, { max: 1000 }))
|
||||
throw new Error("Description must be below 1000 characters.");
|
||||
if (options.location && !bot.utils.validateLength(options.location, { max: 100 }))
|
||||
throw new Error("Location must be below 100 characters.");
|
||||
if (options.scheduledStartTime && options.scheduledEndTime && options.scheduledStartTime > options.scheduledEndTime) {
|
||||
throw new Error("Cannot schedule event to end before starting.");
|
||||
}
|
||||
|
||||
const event = await bot.rest.runMethod<ScheduledEvent>(
|
||||
bot.rest,
|
||||
"patch",
|
||||
bot.constants.endpoints.GUILD_SCHEDULED_EVENT(guildId, eventId),
|
||||
{
|
||||
channel_id: options.channelId?.toString(),
|
||||
entity_metadata:
|
||||
options.location || options.speakerIds
|
||||
? { location: options.location, speakerIds: options.speakerIds?.map((id) => id.toString()) }
|
||||
: undefined,
|
||||
channel_id: options.channelId === null ? null : options.channelId?.toString(),
|
||||
entity_metadata: options.location ? { location: options.location } : undefined,
|
||||
name: options.name,
|
||||
description: options.description,
|
||||
scheduled_start_time: options.scheduledStartTime ? new Date(options.scheduledStartTime).toISOString() : undefined,
|
||||
|
||||
@@ -5,7 +5,7 @@ export function processRateLimitedPaths(rest: RestManager) {
|
||||
const now = Date.now();
|
||||
|
||||
for (const [key, value] of rest.ratelimitedPaths.entries()) {
|
||||
rest.debug(`[REST - processRateLimitedPaths] Running for of loop.`);
|
||||
rest.debug(`[REST - processRateLimitedPaths] Running for of loop. ${value.resetTimestamp - now}`);
|
||||
// IF THE TIME HAS NOT REACHED CANCEL
|
||||
if (value.resetTimestamp > now) continue;
|
||||
|
||||
|
||||
@@ -85,7 +85,8 @@ export function transformGuild(
|
||||
),
|
||||
|
||||
id: guildId,
|
||||
ownerId: bot.transformers.snowflake(payload.guild.owner_id),
|
||||
// WEIRD EDGE CASE WITH BOT CREATED SERVERS
|
||||
ownerId: payload.guild.owner_id ? bot.transformers.snowflake(payload.guild.owner_id) : 0n,
|
||||
permissions: payload.guild.permissions ? bot.transformers.snowflake(payload.guild.permissions) : 0n,
|
||||
afkChannelId: payload.guild.afk_channel_id ? bot.transformers.snowflake(payload.guild.afk_channel_id) : undefined,
|
||||
widgetChannelId: payload.guild.widget_channel_id
|
||||
|
||||
@@ -20,7 +20,6 @@ export function transformScheduledEvent(
|
||||
scheduledStartTime: Date.parse(payload.scheduled_start_time),
|
||||
scheduledEndTime: payload.scheduled_end_time ? Date.parse(payload.scheduled_end_time) : undefined,
|
||||
entityId: payload.entity_id ? bot.transformers.snowflake(payload.entity_id) : undefined,
|
||||
speakerIds: payload.entity_metadata?.speaker_ids?.map((id) => bot.transformers.snowflake(id)),
|
||||
creator: payload.creator ? bot.transformers.user(bot, payload.creator) : undefined,
|
||||
|
||||
name: payload.name,
|
||||
@@ -58,8 +57,6 @@ export interface DiscordenoScheduledEvent {
|
||||
entityType: ScheduledEventEntityType;
|
||||
/** any additional id of the hosting entity associated with event */
|
||||
entityId?: bigint;
|
||||
/** the speakers of the stage channel */
|
||||
speakerIds?: bigint[];
|
||||
/** location of the event */
|
||||
location?: string;
|
||||
/** the user that created the scheduled event */
|
||||
|
||||
@@ -34,15 +34,14 @@ export interface ScheduledEvent {
|
||||
}
|
||||
|
||||
export enum ScheduledEventPrivacyLevel {
|
||||
/** the scheduled event is public and available in discovery */
|
||||
Public = 1,
|
||||
/** the scheduled event is public and available in discovery. DISCORD DEVS DISABLED THIS! WILL ERROR IF USED! */
|
||||
// Public = 1,
|
||||
/** the scheduled event is only accessible to guild members */
|
||||
GuildOnly,
|
||||
GuildOnly = 2,
|
||||
}
|
||||
|
||||
export enum ScheduledEventEntityType {
|
||||
None,
|
||||
StageInstance,
|
||||
StageInstance = 1,
|
||||
Voice,
|
||||
External,
|
||||
}
|
||||
@@ -55,8 +54,6 @@ export enum ScheduledEventStatus {
|
||||
}
|
||||
|
||||
export interface ScheduledEventEntityMetadata {
|
||||
/** the speakers of the stage channel */
|
||||
speakerIds?: string[];
|
||||
/** location of the event */
|
||||
location?: string;
|
||||
}
|
||||
@@ -82,8 +79,6 @@ export interface ScheduledEventUserAdd {
|
||||
export interface CreateScheduledEvent {
|
||||
/** the channel id of the scheduled event */
|
||||
channelId?: bigint;
|
||||
/** the speakers of the stage channel */
|
||||
speakerIds?: bigint[];
|
||||
/** location of the event */
|
||||
location?: string;
|
||||
/** the name of the scheduled event */
|
||||
@@ -95,7 +90,7 @@ export interface CreateScheduledEvent {
|
||||
/** the time the scheduled event will end if it does end. */
|
||||
scheduledEndTime?: number;
|
||||
/** the privacy level of the scheduled event */
|
||||
privacyLevel: ScheduledEventPrivacyLevel;
|
||||
privacyLevel?: ScheduledEventPrivacyLevel;
|
||||
/** the type of hosting entity associated with a scheduled event */
|
||||
entityType: ScheduledEventEntityType;
|
||||
}
|
||||
@@ -103,8 +98,6 @@ export interface CreateScheduledEvent {
|
||||
export interface EditScheduledEvent {
|
||||
/** the channel id of the scheduled event */
|
||||
channelId: bigint;
|
||||
/** the speakers of the stage channel */
|
||||
speakerIds: bigint[];
|
||||
/** location of the event */
|
||||
location: string;
|
||||
/** the name of the scheduled event */
|
||||
@@ -126,8 +119,6 @@ export interface EditScheduledEvent {
|
||||
export interface EditScheduledEvent {
|
||||
/** the channel id of the scheduled event */
|
||||
channelId: bigint;
|
||||
/** the speakers of the stage channel */
|
||||
speakerIds: bigint[];
|
||||
/** location of the event */
|
||||
location: string;
|
||||
/** the name of the scheduled event */
|
||||
|
||||
@@ -2,6 +2,7 @@ import { Bot } from "../../../../src/bot.ts";
|
||||
import { ChannelTypes } from "../../../../src/types/channels/channelTypes.ts";
|
||||
import { CreateScheduledEvent, ScheduledEventEntityType } from "../../../../src/types/guilds/scheduledEvents.ts";
|
||||
import { assertEquals, assertExists } from "../../../deps.ts";
|
||||
import { CACHED_COMMUNITY_GUILD_ID } from "../../../mod.ts";
|
||||
|
||||
export async function createScheduledEventTests(
|
||||
bot: Bot,
|
||||
@@ -9,23 +10,34 @@ export async function createScheduledEventTests(
|
||||
options: CreateScheduledEvent,
|
||||
t: Deno.TestContext
|
||||
) {
|
||||
if ([ScheduledEventEntityType.StageInstance, ScheduledEventEntityType.Voice].includes(options.entityType)) {
|
||||
const channel = await bot.helpers.createChannel(guildId, {
|
||||
name: "entity",
|
||||
type:
|
||||
options.entityType === ScheduledEventEntityType.Voice ? ChannelTypes.GuildVoice : ChannelTypes.GuildStageVoice,
|
||||
});
|
||||
const channel = [
|
||||
ScheduledEventEntityType.StageInstance,
|
||||
ScheduledEventEntityType.Voice,
|
||||
ScheduledEventEntityType.External,
|
||||
].includes(options.entityType)
|
||||
? await bot.helpers.createChannel(guildId, {
|
||||
name: "entity",
|
||||
type:
|
||||
options.entityType === ScheduledEventEntityType.Voice
|
||||
? ChannelTypes.GuildVoice
|
||||
: options.entityType === ScheduledEventEntityType.StageInstance
|
||||
? ChannelTypes.GuildStageVoice
|
||||
: ChannelTypes.GuildText,
|
||||
})
|
||||
: undefined;
|
||||
|
||||
options.channelId = channel.id;
|
||||
}
|
||||
if (channel && options.entityType !== ScheduledEventEntityType.External) options.channelId = channel.id;
|
||||
|
||||
const event = await bot.helpers.createScheduledEvent(guildId, options);
|
||||
|
||||
if (channel && guildId === CACHED_COMMUNITY_GUILD_ID) {
|
||||
await bot.helpers.deleteChannel(channel.id);
|
||||
}
|
||||
|
||||
// Assertions
|
||||
assertExists(event.id);
|
||||
|
||||
assertEquals(event.channelId, options.channelId);
|
||||
assertEquals(event.speakerIds?.length, options.speakerIds?.length);
|
||||
assertEquals(event.location, options.location);
|
||||
assertEquals(event.name, options.name);
|
||||
assertEquals(event.description, options.description);
|
||||
|
||||
15
tests/helpers/guilds/scheduledEvents/deleteScheduledEvent.ts
Normal file
15
tests/helpers/guilds/scheduledEvents/deleteScheduledEvent.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { Bot } from "../../../../src/bot.ts";
|
||||
import { ScheduledEventEntityType, ScheduledEventPrivacyLevel } from "../../../../src/types/guilds/scheduledEvents.ts";
|
||||
|
||||
export async function deleteScheduledEventTests(bot: Bot, guildId: bigint, t: Deno.TestContext) {
|
||||
const event = await bot.helpers.createScheduledEvent(guildId, {
|
||||
name: "lfg",
|
||||
description: "itoh is an imposter",
|
||||
scheduledStartTime: Date.now() + 600000,
|
||||
scheduledEndTime: Date.now() + 1200000,
|
||||
privacyLevel: ScheduledEventPrivacyLevel.GuildOnly,
|
||||
entityType: ScheduledEventEntityType.External,
|
||||
location: "heaven",
|
||||
});
|
||||
await bot.helpers.deleteScheduledEvent(guildId, event.id);
|
||||
}
|
||||
65
tests/helpers/guilds/scheduledEvents/editScheduledEvent.ts
Normal file
65
tests/helpers/guilds/scheduledEvents/editScheduledEvent.ts
Normal file
@@ -0,0 +1,65 @@
|
||||
import { Bot } from "../../../../src/bot.ts";
|
||||
import { ChannelTypes } from "../../../../src/types/channels/channelTypes.ts";
|
||||
import { CreateScheduledEvent, ScheduledEventEntityType, ScheduledEventPrivacyLevel } from "../../../../src/types/guilds/scheduledEvents.ts";
|
||||
import { assertEquals } from "../../../deps.ts";
|
||||
|
||||
export async function editScheduledEventTests(bot: Bot, guildId: bigint, t: Deno.TestContext) {
|
||||
const channel = await bot.helpers.createChannel(guildId, {
|
||||
name: "entity",
|
||||
type: ChannelTypes.GuildStageVoice,
|
||||
});
|
||||
const event = await bot.helpers.createScheduledEvent(guildId, {
|
||||
name: "lfg",
|
||||
description: "itoh is an imposter",
|
||||
scheduledStartTime: Date.now() + 600000,
|
||||
privacyLevel: ScheduledEventPrivacyLevel.GuildOnly,
|
||||
entityType: ScheduledEventEntityType.StageInstance,
|
||||
channelId: channel.id,
|
||||
});
|
||||
let edited = await bot.helpers.editScheduledEvent(guildId, event.id, {
|
||||
name: "lfg2",
|
||||
});
|
||||
|
||||
assertEquals(event.name, "lfg");
|
||||
assertEquals(edited.name, "lfg2");
|
||||
assertEquals(edited.description, "itoh is an imposter");
|
||||
|
||||
edited = await bot.helpers.editScheduledEvent(guildId, event.id, {
|
||||
description: "skillz is not an imposter",
|
||||
});
|
||||
assertEquals(edited.description, "skillz is not an imposter");
|
||||
|
||||
let edited2 = await bot.helpers.editScheduledEvent(guildId, event.id, {
|
||||
scheduledStartTime: edited.scheduledStartTime - 60000,
|
||||
});
|
||||
assertEquals(edited.scheduledStartTime > edited2.scheduledStartTime, true);
|
||||
|
||||
let edited3 = await bot.helpers.editScheduledEvent(guildId, event.id, {
|
||||
scheduledStartTime: edited.scheduledStartTime + 600000,
|
||||
});
|
||||
assertEquals(edited2.scheduledStartTime < edited3.scheduledStartTime, true);
|
||||
|
||||
const voice = await bot.helpers.createChannel(guildId, {
|
||||
name: "xxx",
|
||||
type: ChannelTypes.GuildVoice,
|
||||
});
|
||||
edited2 = await bot.helpers.editScheduledEvent(guildId, event.id, {
|
||||
entityType: ScheduledEventEntityType.Voice,
|
||||
channelId: voice.id,
|
||||
});
|
||||
assertEquals(edited.entityType, ScheduledEventEntityType.StageInstance);
|
||||
assertEquals(edited2.entityType, ScheduledEventEntityType.Voice);
|
||||
|
||||
edited2 = await bot.helpers.editScheduledEvent(guildId, event.id, {
|
||||
entityType: ScheduledEventEntityType.External,
|
||||
// @ts-ignore
|
||||
channelId: null,
|
||||
scheduledStartTime: Date.now() + 60000,
|
||||
scheduledEndTime: Date.now() + 600000,
|
||||
location: "heaven",
|
||||
});
|
||||
assertEquals(edited2.entityType, ScheduledEventEntityType.External);
|
||||
|
||||
await bot.helpers.deleteChannel(voice.id);
|
||||
await bot.helpers.deleteChannel(channel.id);
|
||||
}
|
||||
259
tests/mod.ts
259
tests/mod.ts
@@ -65,6 +65,9 @@ import { deleteChannelOverwriteTests } from "./helpers/channels/deleteChannelOve
|
||||
import { editChannelTests } from "./helpers/channels/editChannel.ts";
|
||||
import { createScheduledEventTests } from "./helpers/guilds/scheduledEvents/createScheduledEvent.ts";
|
||||
import { ScheduledEventEntityType, ScheduledEventPrivacyLevel } from "../src/types/guilds/scheduledEvents.ts";
|
||||
import { GuildFeatures } from "../src/types/guilds/guildFeatures.ts";
|
||||
import { editScheduledEventTests } from "./helpers/guilds/scheduledEvents/editScheduledEvent.ts";
|
||||
import { deleteScheduledEventTests } from "./helpers/guilds/scheduledEvents/deleteScheduledEvent.ts";
|
||||
|
||||
// CHANGE TO TRUE WHEN DEBUGGING SANITIZATION ERRORS
|
||||
const sanitizeMode = {
|
||||
@@ -73,6 +76,8 @@ const sanitizeMode = {
|
||||
sanitizeExit: false,
|
||||
};
|
||||
|
||||
export const CACHED_COMMUNITY_GUILD_ID = 907350958810480671n;
|
||||
|
||||
Deno.test({
|
||||
name: "[Bot] - Starting Tests",
|
||||
fn: async (t) => {
|
||||
@@ -95,7 +100,15 @@ Deno.test({
|
||||
},
|
||||
// debug: console.log,
|
||||
}),
|
||||
intents: ["Guilds", "GuildEmojis", "GuildMessages", "GuildMessageReactions", "GuildBans", "GuildMembers", "GuildScheduledEvents"],
|
||||
intents: [
|
||||
"Guilds",
|
||||
"GuildEmojis",
|
||||
"GuildMessages",
|
||||
"GuildMessageReactions",
|
||||
"GuildBans",
|
||||
"GuildMembers",
|
||||
"GuildScheduledEvents",
|
||||
],
|
||||
cache: {
|
||||
isAsync: false,
|
||||
},
|
||||
@@ -112,6 +125,8 @@ Deno.test({
|
||||
// DELETE GUILDS IF LESS THAN 10 SERVERS AS SAFETY MEASURE
|
||||
if (bot.cache.guilds.size() <= 10) {
|
||||
bot.cache.guilds.forEach(async (guild) => {
|
||||
// DO NOT DELETE OUR CACHED TEST SERVER FOR COMMUNITY FEATURES
|
||||
if (guild.id === CACHED_COMMUNITY_GUILD_ID) return;
|
||||
if (guild.ownerId === bot.id) await bot.helpers.deleteGuild(guild.id);
|
||||
});
|
||||
}
|
||||
@@ -137,119 +152,134 @@ Deno.test({
|
||||
// GUILD SCHEDULED EVENTS TESTS
|
||||
await t.step("Guild Scheduled Event related tests", async (t) => {
|
||||
await Promise.all([
|
||||
// channelId?: bigint;
|
||||
// speakerIds?: bigint[];
|
||||
// location?: string;
|
||||
// name: string;
|
||||
// description: string;
|
||||
// scheduledStartTime: number;
|
||||
// scheduledEndTime?: number;
|
||||
// privacyLevel: ScheduledEventPrivacyLevel;
|
||||
// entityType: ScheduledEventEntityType;
|
||||
// t.step({
|
||||
// name: "[scheduled event] create a public scheduled event with no entity",
|
||||
// fn: async (t) => {
|
||||
// await createScheduledEventTests(bot, guild.id, {
|
||||
// name: "lfg",
|
||||
// description: "lfg it is",
|
||||
// scheduledStartTime: Date.now() + 600000,
|
||||
// privacyLevel: ScheduledEventPrivacyLevel.Public,
|
||||
// entityType: ScheduledEventEntityType.None,
|
||||
// }, t);
|
||||
// },
|
||||
// ...sanitizeMode,
|
||||
// }),
|
||||
// t.step({
|
||||
// name: "[scheduled event] create a guild scheduled event with no entity",
|
||||
// fn: async (t) => {
|
||||
// await createScheduledEventTests(bot, guild.id, {
|
||||
// name: "lfg",
|
||||
// description: "lfg it is",
|
||||
// scheduledStartTime: Date.now() + 600000,
|
||||
// privacyLevel: ScheduledEventPrivacyLevel.GuildOnly,
|
||||
// entityType: ScheduledEventEntityType.None,
|
||||
// }, t);
|
||||
// },
|
||||
// ...sanitizeMode,
|
||||
// }),
|
||||
// t.step({
|
||||
// name: "[scheduled event] create a public scheduled event with stage entity",
|
||||
// fn: async (t) => {
|
||||
// await createScheduledEventTests(bot, guild.id, {
|
||||
// name: "lfg",
|
||||
// description: "lfg it is",
|
||||
// scheduledStartTime: Date.now() + 600000,
|
||||
// privacyLevel: ScheduledEventPrivacyLevel.Public,
|
||||
// entityType: ScheduledEventEntityType.StageInstance,
|
||||
// }, t);
|
||||
// },
|
||||
// ...sanitizeMode,
|
||||
// }),
|
||||
// t.step({
|
||||
// name: "[scheduled event] create a guild scheduled event with stage entity",
|
||||
// fn: async (t) => {
|
||||
// await createScheduledEventTests(bot, guild.id, {
|
||||
// name: "lfg",
|
||||
// description: "lfg it is",
|
||||
// scheduledStartTime: Date.now() + 600000,
|
||||
// privacyLevel: ScheduledEventPrivacyLevel.GuildOnly,
|
||||
// entityType: ScheduledEventEntityType.StageInstance,
|
||||
// }, t);
|
||||
// },
|
||||
// ...sanitizeMode,
|
||||
// }),
|
||||
// t.step({
|
||||
// name: "[scheduled event] create a public scheduled event with voice entity",
|
||||
// fn: async (t) => {
|
||||
// await createScheduledEventTests(bot, guild.id, {
|
||||
// name: "lfg",
|
||||
// description: "lfg it is",
|
||||
// scheduledStartTime: Date.now() + 600000,
|
||||
// privacyLevel: ScheduledEventPrivacyLevel.Public,
|
||||
// entityType: ScheduledEventEntityType.Voice,
|
||||
// }, t);
|
||||
// },
|
||||
// ...sanitizeMode,
|
||||
// }),
|
||||
// t.step({
|
||||
// name: "[scheduled event] create a guild scheduled event with voice entity",
|
||||
// fn: async (t) => {
|
||||
// await createScheduledEventTests(bot, guild.id, {
|
||||
// name: "lfg",
|
||||
// description: "lfg it is",
|
||||
// scheduledStartTime: Date.now() + 600000,
|
||||
// privacyLevel: ScheduledEventPrivacyLevel.GuildOnly,
|
||||
// entityType: ScheduledEventEntityType.Voice,
|
||||
// }, t);
|
||||
// },
|
||||
// ...sanitizeMode,
|
||||
// }),
|
||||
// t.step({
|
||||
// name: "[scheduled event] create a public scheduled event with external entity",
|
||||
// fn: async (t) => {
|
||||
// await createScheduledEventTests(bot, guild.id, {
|
||||
// name: "lfg",
|
||||
// description: "lfg it is",
|
||||
// scheduledStartTime: Date.now() + 600000,
|
||||
// privacyLevel: ScheduledEventPrivacyLevel.Public,
|
||||
// entityType: ScheduledEventEntityType.External,
|
||||
// }, t);
|
||||
// },
|
||||
// ...sanitizeMode,
|
||||
// }),
|
||||
// t.step({
|
||||
// name: "[scheduled event] create a guild scheduled event with external entity",
|
||||
// fn: async (t) => {
|
||||
// await createScheduledEventTests(bot, guild.id, {
|
||||
// name: "lfg",
|
||||
// description: "lfg it is",
|
||||
// scheduledStartTime: Date.now() + 600000,
|
||||
// privacyLevel: ScheduledEventPrivacyLevel.GuildOnly,
|
||||
// entityType: ScheduledEventEntityType.External,
|
||||
// }, t);
|
||||
// },
|
||||
// ...sanitizeMode,
|
||||
// }),
|
||||
t.step({
|
||||
name: "[scheduled event] create a guild scheduled event with stage entity",
|
||||
fn: async (t) => {
|
||||
await createScheduledEventTests(
|
||||
bot,
|
||||
CACHED_COMMUNITY_GUILD_ID,
|
||||
{
|
||||
name: "lfg",
|
||||
description: "itoh is an imposter",
|
||||
scheduledStartTime: Date.now() + 600000,
|
||||
privacyLevel: ScheduledEventPrivacyLevel.GuildOnly,
|
||||
entityType: ScheduledEventEntityType.StageInstance,
|
||||
},
|
||||
t
|
||||
);
|
||||
},
|
||||
...sanitizeMode,
|
||||
}),
|
||||
t.step({
|
||||
name: "[scheduled event] create a guild scheduled event with stage entity with an end time.",
|
||||
fn: async (t) => {
|
||||
await createScheduledEventTests(
|
||||
bot,
|
||||
CACHED_COMMUNITY_GUILD_ID,
|
||||
{
|
||||
name: "lfg",
|
||||
description: "itoh is an imposter",
|
||||
scheduledStartTime: Date.now() + 600000,
|
||||
scheduledEndTime: Date.now() + (600000 + 1),
|
||||
privacyLevel: ScheduledEventPrivacyLevel.GuildOnly,
|
||||
entityType: ScheduledEventEntityType.StageInstance,
|
||||
},
|
||||
t
|
||||
);
|
||||
},
|
||||
...sanitizeMode,
|
||||
}),
|
||||
t.step({
|
||||
name: "[scheduled event] create a guild scheduled event with voice entity",
|
||||
fn: async (t) => {
|
||||
await createScheduledEventTests(
|
||||
bot,
|
||||
guild.id,
|
||||
{
|
||||
name: "lfg",
|
||||
description: "itoh is an imposter",
|
||||
scheduledStartTime: Date.now() + 600000,
|
||||
privacyLevel: ScheduledEventPrivacyLevel.GuildOnly,
|
||||
entityType: ScheduledEventEntityType.Voice,
|
||||
},
|
||||
t
|
||||
);
|
||||
},
|
||||
...sanitizeMode,
|
||||
}),
|
||||
t.step({
|
||||
name: "[scheduled event] create a guild scheduled event with voice entity with an end time.",
|
||||
fn: async (t) => {
|
||||
await createScheduledEventTests(
|
||||
bot,
|
||||
guild.id,
|
||||
{
|
||||
name: "lfg",
|
||||
description: "itoh is an imposter",
|
||||
scheduledStartTime: Date.now() + 600000,
|
||||
scheduledEndTime: Date.now() + (600000 + 1),
|
||||
privacyLevel: ScheduledEventPrivacyLevel.GuildOnly,
|
||||
entityType: ScheduledEventEntityType.Voice,
|
||||
},
|
||||
t
|
||||
);
|
||||
},
|
||||
...sanitizeMode,
|
||||
}),
|
||||
t.step({
|
||||
name: "[scheduled event] create a guild scheduled event with external entity",
|
||||
fn: async (t) => {
|
||||
await createScheduledEventTests(
|
||||
bot,
|
||||
guild.id,
|
||||
{
|
||||
name: "lfg",
|
||||
description: "itoh is an imposter",
|
||||
scheduledStartTime: Date.now() + 600000,
|
||||
scheduledEndTime: Date.now() + 1200000,
|
||||
privacyLevel: ScheduledEventPrivacyLevel.GuildOnly,
|
||||
entityType: ScheduledEventEntityType.External,
|
||||
location: "heaven",
|
||||
},
|
||||
t
|
||||
);
|
||||
},
|
||||
...sanitizeMode,
|
||||
}),
|
||||
t.step({
|
||||
name: "[scheduled event] create a guild scheduled event with external entity with an end time.",
|
||||
fn: async (t) => {
|
||||
await createScheduledEventTests(
|
||||
bot,
|
||||
guild.id,
|
||||
{
|
||||
name: "lfg",
|
||||
description: "itoh is an imposter",
|
||||
scheduledStartTime: Date.now() + 600000,
|
||||
scheduledEndTime: Date.now() + (600000 + 1),
|
||||
privacyLevel: ScheduledEventPrivacyLevel.GuildOnly,
|
||||
entityType: ScheduledEventEntityType.External,
|
||||
location: "heaven",
|
||||
},
|
||||
t
|
||||
);
|
||||
},
|
||||
...sanitizeMode,
|
||||
}),
|
||||
t.step({
|
||||
name: "[scheduled event] edit a scheduled event",
|
||||
fn: async (t) => {
|
||||
await editScheduledEventTests(bot, CACHED_COMMUNITY_GUILD_ID, t);
|
||||
},
|
||||
...sanitizeMode,
|
||||
}),
|
||||
t.step({
|
||||
name: "[scheduled event] delete a scheduled event",
|
||||
fn: async (t) => {
|
||||
await deleteScheduledEventTests(bot, guild.id, t);
|
||||
},
|
||||
...sanitizeMode,
|
||||
}),
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -985,6 +1015,7 @@ Deno.test({
|
||||
}),
|
||||
]);
|
||||
|
||||
await bot.helpers.deleteGuild(guild.id);
|
||||
await stopBot(bot);
|
||||
},
|
||||
...sanitizeMode,
|
||||
|
||||
Reference in New Issue
Block a user