Files
discordeno/helpers/guilds/editGuild.ts
Skillz4Killz a0a1554756 refactor: typings using ReturnType (#2105)
* fix: check new types idea

* fix: type errors

* fix: new style

* fix: more cleanup

* fix: more cleanup

* fix: cleanup audit logs

* fix: cleanup stickers

* fix: cleanup integrations

* fix: more cleanup

* fix: organize into 1 place

* fix: few errors

* fix: some broken import fixes

* fix: quite a lot of fixes across the board

* fix: more fixes for broken imports

* fix: more fixes for broken imports

* fix: handler imports

* fix: all remaining import errors

* fix: more errors needing fixes

* fix: clearing up transformers

* fix: few moer types

* fix: more cleanup of extra types

* fix: fmt

* fix: cleanup discordeno file

* Nuke Base Types (#2102)

* fix: cleanup snake stuff

* convert camelCase to snake_case (#2103)

* fix: add camelize

* fix: finalize remaining errors

* fix: imports in test

Co-authored-by: LTS20050703 <87189679+lts20050703@users.noreply.github.com>
2022-03-14 22:11:22 -04:00

77 lines
3.0 KiB
TypeScript

import type { Bot } from "../../bot.ts";
import { DiscordGuild } from "../../types/discord.ts";
import {
DefaultMessageNotificationLevels,
ExplicitContentFilterLevels,
GuildFeatures,
SystemChannelFlags,
VerificationLevels,
} from "../../types/shared.ts";
/** Modify a guilds settings. Requires the MANAGE_GUILD permission. */
export async function editGuild(bot: Bot, guildId: bigint, options: ModifyGuild, shardId: number) {
if (options.icon && !options.icon.startsWith("data:image/")) {
options.icon = await bot.utils.urlToBase64(options.icon);
}
if (options.banner && !options.banner.startsWith("data:image/")) {
options.banner = await bot.utils.urlToBase64(options.banner);
}
if (options.splash && !options.splash.startsWith("data:image/")) {
options.splash = await bot.utils.urlToBase64(options.splash);
}
const result = await bot.rest.runMethod<DiscordGuild>(
bot.rest,
"patch",
bot.constants.endpoints.GUILDS_BASE(guildId),
options,
);
return bot.transformers.guild(bot, {
guild: result,
shardId,
});
}
/** https://discord.com/developers/docs/resources/guild#modify-guild */
export interface ModifyGuild {
/** Guild name */
name?: string;
/** Verification level */
verificationLevel?: VerificationLevels | null;
/** Default message notification filter level */
defaultMessageNotifications?: DefaultMessageNotificationLevels | null;
/** Explicit content filter level */
explicitContentFilter?: ExplicitContentFilterLevels | null;
/** Id for afk channel */
afkChannelId?: bigint | null;
/** Afk timeout in seconds */
afkTimeout?: number;
/** Base64 1024x1024 png/jpeg/gif image for the guild icon (can be animated gif when the server has the `ANIMATED_ICON` feature) */
icon?: string | null;
/** User id to transfer guild ownership to (must be owner) */
ownerId?: bigint;
/** Base64 16:9 png/jpeg image for the guild splash (when the server has `INVITE_SPLASH` feature) */
splash?: string | null;
/** Base64 16:9 png/jpeg image for the guild discovery spash (when the server has the `DISCOVERABLE` feature) */
discoverySplash?: string | null;
/** Base64 16:9 png/jpeg image for the guild banner (when the server has BANNER feature) */
banner?: string | null;
/** The id of the channel where guild notices such as welcome messages and boost events are posted */
systemChannelId?: bigint | null;
/** System channel flags */
systemChannelFlags?: SystemChannelFlags;
/** The id of the channel where Community guilds display rules and/or guidelines */
rulesChannelId?: bigint | null;
/** The id of the channel where admins and moderators of Community guilds receive notices from Discord */
publicUpdatesChannelId?: bigint | null;
/** The preferred locale of a Community guild used in server discovery and notices from Discord; defaults to "en-US" */
preferredLocale?: string | null;
/** Enabled guild features */
features?: GuildFeatures[];
/** Whether the guild's boost progress bar should be enabled */
premiumProgressBarEnabled?: boolean;
}