create server

This commit is contained in:
Skillz
2020-09-24 12:03:43 -04:00
parent 5d274b90b6
commit 77b8dde667
3 changed files with 33 additions and 1 deletions

View File

@@ -51,6 +51,7 @@ export const endpoints = {
`${baseEndpoints.BASE_URL}/channels/${id}/messages/${messageID}/crosspost`,
// Guild Endpoints
GUILDS: `${baseEndpoints.BASE_URL}/guilds`,
GUILD: (id: string) => `${GUILDS_BASE(id)}`,
GUILD_AUDIT_LOGS: (id: string) => `${GUILDS_BASE(id)}/audit-logs`,
GUILD_BAN: (id: string, userID: string) =>

View File

@@ -19,6 +19,7 @@ import type {
ChannelCreateOptions,
BannedUser,
UserPayload,
CreateServerOptions,
} from "../types/guild.ts";
import type { RoleData } from "../types/role.ts";
import type { MemberCreatePayload } from "../types/member.ts";
@@ -38,6 +39,11 @@ import { structures } from "../structures/mod.ts";
import { cacheHandlers } from "../controllers/cache.ts";
import { formatImageURL } from "../utils/cdn.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 function createServer(options: CreateServerOptions) {
return RequestManager.post(endpoints.GUILDS, options);
}
/** Gets an array of all the channels ids that are the children of this category. */
export function categoryChildrenIDs(guild: Guild, id: string) {
return guild.channels.filter((channel) => channel.parentID === id);
@@ -99,7 +105,7 @@ export async function createGuildChannel(
name,
permission_overwrites: options?.permission_overwrites?.map((perm) => ({
...perm,
allow: perm.allow.reduce(
(bits, p) => bits |= BigInt(Permissions[p]),
BigInt(0),

View File

@@ -583,3 +583,28 @@ export interface FetchMembersOptions {
/** Maximum number of members to return that match the query. Default = 0 which will return all members. */
limit?: number;
}
export interface CreateServerOptions {
/** name of the guild (2-100 characters) */
name: string;
/** voice region id */
region?: string;
/** guild icon image url or base64 128x128 image for the guild icon */
icon?: string;
/** verification level */
verification_level?: number;
/** default message notification level */
default_message_notifications?: number;
/** explicit content filter level */
explicit_content_filter?: number;
/** array of role objects new guild roles */
roles?: RoleData[];
/** array of partial channel objects new guild's channels */
channels?: ChannelCreatePayload[];
/** id for afk channel */
afk_channel_id?: string;
/** afk timeout in seconds */
afk_timeout?: number;
/** the id of the channel where guild notices such as welcome messages and boost events are posted */
system_channel_id?: string;
}