Files
discordeno/helpers/guilds/createGuild.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

56 lines
2.2 KiB
TypeScript

import type { Bot } from "../../bot.ts";
import { Channel } from "../../transformers/channel.ts";
import { Role } from "../../transformers/role.ts";
import { DiscordGuild } from "../../types/discord.ts";
import {
DefaultMessageNotificationLevels,
ExplicitContentFilterLevels,
SystemChannelFlags,
VerificationLevels,
} from "../../types/shared.ts";
/** Create a new guild. Returns a guild object on success. Fires a Guild Create Gateway event. This endpoint can be used only by bots in less than 10 guilds. */
export async function createGuild(bot: Bot, options: CreateGuild) {
const result = await bot.rest.runMethod<DiscordGuild>(bot.rest, "post", bot.constants.endpoints.GUILDS, {
name: options.name,
afk_channel_id: options.afkChannelId,
afk_timeout: options.afkTimeout,
channels: options.channels,
default_message_notifications: options.defaultMessageNotifications,
explicit_content_filter: options.explicitContentFilter,
icon: options.icon,
roles: options.roles,
system_channel_flags: options.systemChannelFlags,
system_channel_id: options.systemChannelId,
verification_level: options.verificationLevel,
});
return bot.transformers.guild(bot, { guild: result, shardId: 0 });
}
/** https://discord.com/developers/docs/resources/guild#create-guild */
export interface CreateGuild {
/** Name of the guild (1-100 characters) */
name: string;
/** Base64 128x128 image for the guild icon */
icon?: string;
/** Verification level */
verificationLevel?: VerificationLevels;
/** Default message notification level */
defaultMessageNotifications?: DefaultMessageNotificationLevels;
/** Explicit content filter level */
explicitContentFilter?: ExplicitContentFilterLevels;
/** New guild roles (first role is the everyone role) */
roles?: Role[];
/** New guild's channels */
channels?: Partial<Channel>[];
/** Id for afk channel */
afkChannelId?: string;
/** Afk timeout in seconds */
afkTimeout?: number;
/** The id of the channel where guild notices such as welcome messages and boost events are posted */
systemChannelId?: string;
/** System channel flags */
systemChannelFlags?: SystemChannelFlags;
}