finished role and emojis

This commit is contained in:
Skillz
2020-02-12 13:37:28 -05:00
parent cb4d3cee86
commit 5fe4e4e822
4 changed files with 51 additions and 10 deletions

View File

@@ -2,12 +2,13 @@ import Client from '../module/client'
import { endpoints } from '../constants/discord'
import { formatImageURL } from '../utils/cdn'
import { Guild, CreateGuildPayload, ChannelTypes, Permissions, PrunePayload } from '../types/guild'
import { create_role } from './role'
export const createGuild = (data: CreateGuildPayload, client: Client) => {
const guild: Guild = {
...data,
roles: new Map(data.roles.map(r => [r.id, create_role(r)])),
emojis: new Map(data.emojis.map(e => [e.id, create_emoji(e)])),
emojis: new Map(data.emojis.map(e => [e.id, e])),
joined_at: Date.parse(data.joined_at),
voice_states: new Map(data.voice_states.map(vs => [vs.id, create_voice_state(vs)])),
members: new Map(data.members.map(m => [m.id, create_member(m)])),

View File

@@ -1,3 +1,10 @@
export const createRole = (data: unknown) => {
console.log(data)
import { Role, Role_Data } from "../types/role"
export const create_role = (data: Role_Data) => {
const role: Role = {
...data,
mention: () => `<@&${data.id}>`
}
return role
}

16
types/emoji.ts Normal file
View File

@@ -0,0 +1,16 @@
export interface Emoji {
/** emoji id. It will be null for default discord emojis. */
id: string | null
/** The name of the emoji. (can be null only in reaction emoji objects when the custom emoji doesnt exist anymore) */
name: string | null
/** array of role ids roles this emoji is whitelisted to */
roles?: string[]
/** User that created this emoji */
user?: User
/** whether this emoji must be wrapped in colons */
require_colons?: boolean
/** whether this emoji is managed */
managed?: boolean
/** whether this emoji is animated */
animated?: boolean
}

View File

@@ -1,3 +1,6 @@
import { Role } from './role'
import { Emoji } from './discord'
export interface CreateGuildPayload {
/** The guild id */
id: string
@@ -26,7 +29,7 @@ export interface CreateGuildPayload {
/** The custom guild emojis */
emojis: Emoji[]
/** Enabled guild features */
features: GuildFeatures[]
features: Guild_Features[]
/** Required MFA level for the guild */
mfa_level: number
/** The id of the channel to which system mesages are sent */
@@ -188,17 +191,31 @@ export interface Guild {
/** Remove the ban for a user. REquires BAN_MEMBERS permission */
unban(id: string): Promise<void>
/** Modify a guilds settings. Requires the MANAGE_GUILD permission. */
edit(options: Guild_Edit_Options): Promise<Guild>
/** Get all the invites for this guild. Requires MANAGE_GUILD permission */
get_invites(): Promise<Invite[]>
edit(options: Guild_Edit_Options): Promise<Guild>
/** Get all the invites for this guild. Requires MANAGE_GUILD permission */
get_invites(): Promise<Invite[]>
/** Leave a guild */
leave(): Promise<void>
/** Returns a list of voice region objects for the guild. Unlike the similar /voice route, this returns VIP servers when the guild is VIP-enabled. */
get_voice_regions(): Promise<Voice_Region[]>
/** Returns a list of guild webhooks objects. Requires the MANAGE_WEBHOOKs permission. */
get_webhooks(): Promise<Webhook[]>
get_voice_regions(): Promise<Voice_Region[]>
/** Returns a list of guild webhooks objects. Requires the MANAGE_WEBHOOKs permission. */
get_webhooks(): Promise<Webhook[]>
}
export type Guild_Features =
| `INVITE_SPLASH`
| `VIP_REGIONS`
| `VANITY_URL`
| `VERIFIED`
| `PARTNERED`
| `PUBLIC`
| `COMMERCE`
| `NEWS`
| `DISCOVERABLE`
| `FEATURABLE`
| `ANIMATED_ICON`
| `BANNER`
export interface Voice_Region {
/** unique ID for the region */
id: string