Merge branch 'main' into search-members

This commit is contained in:
ITOH
2021-04-16 18:52:01 +02:00
6 changed files with 59 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
import { rest } from "../../rest/rest.ts";
import { ModifyGuildWelcomeScreen } from "../../types/guilds/modify_guild_welcome_screen.ts";
import { WelcomeScreen } from "../../types/mod.ts";
import { endpoints } from "../../util/constants.ts";
import {
camelKeysToSnakeCase,
snakeKeysToCamelCase,
} from "../../util/utils.ts";
export async function editWelcomeScreen(
guildId: string,
options: ModifyGuildWelcomeScreen,
) {
const result = await rest.runMethod(
"patch",
endpoints.GUILD_WELCOME_SCREEN(guildId),
camelKeysToSnakeCase(options),
);
return snakeKeysToCamelCase<WelcomeScreen>(result);
}
+13
View File
@@ -0,0 +1,13 @@
import { rest } from "../../rest/rest.ts";
import { WelcomeScreen } from "../../types/mod.ts";
import { endpoints } from "../../util/constants.ts";
import { snakeKeysToCamelCase } from "../../util/utils.ts";
export async function getWelcomeScreen(guildId: string) {
const result = await rest.runMethod(
"get",
endpoints.GUILD_WELCOME_SCREEN(guildId),
);
return snakeKeysToCamelCase<WelcomeScreen>(result);
}
+6
View File
@@ -31,6 +31,7 @@ import { getEmojis } from "./emojis/get_emojis.ts";
import { createGuild } from "./guilds/create_guild.ts"; import { createGuild } from "./guilds/create_guild.ts";
import { deleteServer } from "./guilds/delete_server.ts"; import { deleteServer } from "./guilds/delete_server.ts";
import { editGuild } from "./guilds/edit_guild.ts"; import { editGuild } from "./guilds/edit_guild.ts";
import { editWelcomeScreen } from "./guilds/edit_welcome_screen.ts";
import { editWidget } from "./guilds/edit_widget.ts"; import { editWidget } from "./guilds/edit_widget.ts";
import { getAuditLogs } from "./guilds/get_audit_logs.ts"; import { getAuditLogs } from "./guilds/get_audit_logs.ts";
import { getAvailableVoiceRegions } from "./guilds/get_available_voice_regions.ts"; import { getAvailableVoiceRegions } from "./guilds/get_available_voice_regions.ts";
@@ -41,6 +42,7 @@ import { getGuildPreview } from "./guilds/get_guild_preview.ts";
import { getPruneCount } from "./guilds/get_prune_count.ts"; import { getPruneCount } from "./guilds/get_prune_count.ts";
import { getVanityURL } from "./guilds/get_vainty_url.ts"; import { getVanityURL } from "./guilds/get_vainty_url.ts";
import { getVoiceRegions } from "./guilds/get_voice_regions.ts"; import { getVoiceRegions } from "./guilds/get_voice_regions.ts";
import { getWelcomeScreen } from "./guilds/get_welcome_screen.ts";
import { getWidget } from "./guilds/get_widget.ts"; import { getWidget } from "./guilds/get_widget.ts";
import { getWidgetImageURL } from "./guilds/get_widget_image_url.ts"; import { getWidgetImageURL } from "./guilds/get_widget_image_url.ts";
import { getWidgetSettings } from "./guilds/get_widget_settings.ts"; import { getWidgetSettings } from "./guilds/get_widget_settings.ts";
@@ -163,6 +165,7 @@ export {
editWebhook, editWebhook,
editWebhookMessage, editWebhookMessage,
editWebhookWithToken, editWebhookWithToken,
editWelcomeScreen,
editWidget, editWidget,
emojiURL, emojiURL,
executeWebhook, executeWebhook,
@@ -203,6 +206,7 @@ export {
getWebhook, getWebhook,
getWebhooks, getWebhooks,
getWebhookWithToken, getWebhookWithToken,
getWelcomeScreen,
getWidget, getWidget,
getWidgetImageURL, getWidgetImageURL,
getWidgetSettings, getWidgetSettings,
@@ -275,6 +279,7 @@ export let helpers = {
deleteServer, deleteServer,
editGuild, editGuild,
editWidget, editWidget,
editWelcomeScreen,
emojiURL, emojiURL,
getAuditLogs, getAuditLogs,
getAvailableVoiceRegions, getAvailableVoiceRegions,
@@ -282,6 +287,7 @@ export let helpers = {
getBans, getBans,
getGuildPreview, getGuildPreview,
getGuild, getGuild,
getWelcomeScreen,
getPruneCount, getPruneCount,
getVanityURL, getVanityURL,
getVoiceRegions, getVoiceRegions,
@@ -0,0 +1,16 @@
import { SnakeCasedPropertiesDeep } from "../util.ts";
import { WelcomeScreenChannel } from "./welcome_screen_channel.ts";
export interface ModifyGuildWelcomeScreen {
/** Whether the welcome screen is enabled */
enabled?: boolean | null;
/** Channels linked in the welcome screen and their display options */
welcomeScreen?: WelcomeScreenChannel[] | null;
/** The server description to show in the welcome screen */
description?: string | null;
}
// TODO: add documentation link
export type DiscordModifyGuildWelcomeScreen = SnakeCasedPropertiesDeep<
ModifyGuildWelcomeScreen
>;
+1
View File
@@ -84,6 +84,7 @@ export * from "./guilds/modify_guild_channel_position.ts";
export * from "./guilds/modify_guild_member.ts"; export * from "./guilds/modify_guild_member.ts";
export * from "./guilds/modify_guild_role.ts"; export * from "./guilds/modify_guild_role.ts";
export * from "./guilds/modify_guild_role_positions.ts"; export * from "./guilds/modify_guild_role_positions.ts";
export * from "./guilds/modify_guild_welcome_screen.ts";
export * from "./guilds/premium_tiers.ts"; export * from "./guilds/premium_tiers.ts";
export * from "./guilds/request_guild_members.ts"; export * from "./guilds/request_guild_members.ts";
export * from "./guilds/system_channel_flags.ts"; export * from "./guilds/system_channel_flags.ts";
+2
View File
@@ -123,6 +123,8 @@ export const endpoints = {
GUILD_PREVIEW: (guildId: string) => `${GUILDS_BASE(guildId)}/preview`, GUILD_PREVIEW: (guildId: string) => `${GUILDS_BASE(guildId)}/preview`,
UPDATE_VOICE_STATE: (guildId: string, userId?: string) => UPDATE_VOICE_STATE: (guildId: string, userId?: string) =>
`${GUILDS_BASE(guildId)}/voice-states/${userId ?? "@me"}`, `${GUILDS_BASE(guildId)}/voice-states/${userId ?? "@me"}`,
GUILD_WELCOME_SCREEN: (guildId: string) =>
`${GUILDS_BASE(guildId)}/welcome-screen`,
// Voice // Voice
VOICE_REGIONS: `${baseEndpoints.BASE_URL}/voice/regions`, VOICE_REGIONS: `${baseEndpoints.BASE_URL}/voice/regions`,