Guilds helpers

This commit is contained in:
TriForMine
2021-10-21 19:38:09 +02:00
parent baf8583976
commit 20616e8a36
29 changed files with 156 additions and 167 deletions
+14 -5
View File
@@ -1,9 +1,18 @@
import { rest } from "../../rest/rest.ts";
import type { ModifyGuildWelcomeScreen } from "../../types/guilds/modify_guild_welcome_screen.ts";
import type { WelcomeScreen } from "../../types/guilds/welcome_screen.ts";
import { endpoints } from "../../util/constants.ts";
import { snakelize } from "../../util/utils.ts";
import type { Bot } from "../../bot.ts";
export async function editWelcomeScreen(guildId: bigint, options: ModifyGuildWelcomeScreen) {
return await rest.runMethod<WelcomeScreen>("patch", endpoints.GUILD_WELCOME_SCREEN(guildId), snakelize(options));
export async function editWelcomeScreen(bot: Bot, guildId: bigint, options: ModifyGuildWelcomeScreen) {
return await bot.rest.runMethod<WelcomeScreen>("patch", bot.constants.endpoints.GUILD_WELCOME_SCREEN(guildId), {
enabled: options.enabled,
welcomeScreen: options.welcomeScreen?.map((welcomeScreen) => {
return {
channel_id: welcomeScreen.channelId,
description: welcomeScreen.description,
emoji_id: welcomeScreen.emojiId,
emoji_name: welcomeScreen.emojiName
}
}),
description: options.description
});
}