Add Types and Finish Endpoints (TODO: ENDPOINT #1)

Co-Authored-By: yky4589 <8479056+yky4589@users.noreply.github.com>
Co-Authored-By: Choi Minseo <minseo0388@outlook.com>
Co-Authored-By: Aki <akiacode@users.noreply.github.com>
This commit is contained in:
Catry 2020-10-22 15:10:51 +09:00
parent 9b34b59b38
commit 599997414b
13 changed files with 631 additions and 88 deletions

231
src/types/channelTypes.ts Normal file
View file

@ -0,0 +1,231 @@
interface Channel {
id: string
type: number
guild_id?: string
position?: number
approximate_member_count?: Overwrite
name?: string
topic?: string | undefined
nsfw?: boolean
last_message_id?: string
bitrate?: number
user_limit?: number
rate_limit_per_user?: number
recipients?: User
icon?: string | undefined
owner_id?: string
application_id?: string
parent_id?: string | undefined
last_pin_timestamp?: string
}
interface Overwrite {
id: string
type: number
allow: string
deny: string
}
enum ChannelTypes {
GUILD_TEXT = 0,
DM = 1,
GUILD_VOICE = 2,
GROUP_DM = 3,
GUILD_CATEGORY = 4,
GUILD_NEWS = 5,
GUILD_STORE = 6
}
interface Message {
id: string
channel_id: string
guild_id?: string
suthor: User
member?: GuildMember
content: string
timestamp: string
edited_timestamp: string | undefined
tts: boolean
mention_everyone: boolean
mentions: User[]
mention_roles: Role[]
mention_channels?: ChannelMention[]
attachments: Attachment[]
embeds: Embed[]
reactions?: Reaction[]
nonce?: number | string
pinned: boolean
webhook_id?: string
type: number
activity?: MessageActivity
application?: MessageApplication
message_reference?: MessageReference
flags?: number
}
interface ChannelMention {
id: string
guild_id: string
type: ChannelTypes
name: string
}
interface Attachment {
id: string
filename: string
size: number
url: string
proxy_url: string
height: number | undefined
width: number | undefined
}
interface Embed {
title?: string
type?: EmbedTypes
description?: string
url?: string
timestamp?: string
color?: number
footer?: EmbedFooter
image?: EmbedImage
thumbnail?: EmbedThumbnail
video?: EmbedVideo
provider?: EmbedProvider
author?: EmbedAuthor
fields?: EmbedField[]
}
type EmbedTypes =
| "rich"
| "image"
| "video"
| "gifv"
| "article"
| "link"
interface EmbedField {
name: string
value: string
inline?: boolean
}
interface EmbedAuthor {
name?: string
url?: string
icon_url?: string
proxy_icon_url?: string
}
interface EmbedFooter {
text: string
icon_url?: string
proxy_icon_url?: string
}
interface EmbedImage {
url?: string
proxy_url?: string
height?: number
width?: number
}
interface EmbedProvider {
name?: string
url?: string
}
interface EmbedVideo {
url?: string
height?: number
width?: number
}
interface EmbedThumbnail {
url?: string
proxy_url?: string
height?: number
width?: number
}
interface Reaction {
count: number
me: boolean
emoji: Emoji
}
interface MessageActivity {
type: MessageTypes
party_id?: string
}
interface MessageApplication {
id: string
cover_image?: string
desription: string
icon: string | undefined
name: string
}
interface MessageReference {
message_id?: string
channel_id?: string
guild_id?: string
}
enum MessageTypes {
DEFAULT = 0,
RECIPIENT_ADD = 1,
RECIPIENT_REMOVE = 2,
CALL = 3,
CHANNEL_NAME_CHANGE = 4,
CHANNEL_ICON_CHANGE = 5,
CHANNEL_PINNED_MESSAGE = 6,
GUILD_MEMBER_JOIN = 7,
USER_PREMIUM_GUILD_SUBSCRIPTION = 8,
USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_1 = 9,
USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_2 = 10,
USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_3 = 11,
CHANNEL_FOLLOW_ADD = 12,
GUILD_DISCOVERY_DISQUALIFIED = 14,
GUILD_DISCOVERY_REQUALIFIED = 15
}
enum MessageActivityTypes {
JOIN = 1,
SPECTATE = 2,
LISTEN = 3,
JOIN_REQUEST = 4
}
enum MessageFlags {
CROSSPOSTED = 1 << 0,
IS_CROSSPOST = 1 << 1,
SUPPRESS_EMBEDS = 1 << 2,
SOURCE_MESSAGE_DELETED = 1 << 3,
URGENT = 1 << 4
}
interface FollowedChannel {
channel_id: string,
webhook_id: string
}
interface Reaction {
count: number,
me: boolean
emoji: Emoji
}
interface Overwrite {
id: string,
type: number
allow: string
deny: string
}
interface ChannelMention {
id: string
guild_id: string
type: ChannelTypes
name: string
}

10
src/types/emojiTypes.ts Normal file
View file

@ -0,0 +1,10 @@
interface Emoji {
id: string
name: string | undefined
roles?: []
user?: User
require_colons?: boolean
managed?: boolean
animated?: boolean
available?: boolean
}

View file

@ -3,145 +3,180 @@
import {
DISCORD_API_URL,
DISCORD_API_VERSION,
DISCORD_CDN_URL
} from '../consts/urlsAndVersions'
DISCORD_CDN_URL,
} from "../consts/urlsAndVersions";
//Guild Endpoints
const GUILDS = `${DISCORD_API_URL}/v${DISCORD_API_VERSION}/guilds`
const GUILDS = `${DISCORD_API_URL}/v${DISCORD_API_VERSION}/guilds`;
const GUILD = (guildID: string) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/guilds/${guildID}`
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/guilds/${guildID}`;
const GUILD_AUDIT_LOGS = (guildID: string) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/guilds/${guildID}/audit-logs`
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/guilds/${guildID}/audit-logs`;
const GUILD_WIDGET = (guildID: string) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/guilds/${guildID}/widget`
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/guilds/${guildID}/widget`;
const GUILD_EMOJI = (guildID: string, emoji_id: string) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/guilds/${guildID}/emojis/${emoji_id}`
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/guilds/${guildID}/emojis/${emoji_id}`;
const GUILD_ROLE = (guildID: string, roleID: string) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/guilds/${guildID}/roles/${roleID}`
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/guilds/${guildID}/roles/${roleID}`;
const GUILD_ROLES = (guildID: string) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/guilds/${guildID}/roles`
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/guilds/${guildID}/roles`;
const GUILD_INTEGRATION = (guildID: string, integrationID: string) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/guilds/${guildID}/integrations/${integrationID}`
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/guilds/${guildID}/integrations/${integrationID}`;
const GUILD_INTEGRATIONS = (guildID: string) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/guilds/${guildID}/integrations`
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/guilds/${guildID}/integrations`;
const GUILD_INTEGARTION_SYNC = (guildID: string) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/guilds/${guildID}/integrations?include_appilications=true`
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/guilds/${guildID}/integrations?include_appilications=true`;
const GUILD_BAN = (guildID: string, userID: string) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/guilds/${guildID}/bans/${userID}`
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/guilds/${guildID}/bans/${userID}`;
const GUILD_BANS = (guildID: string) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/guilds/${guildID}/bans`
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/guilds/${guildID}/bans`;
const GUILD_CHANNEL = (channelID: string) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/channels/${channelID}`
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/channels/${channelID}`;
const GUILD_CHANNELS = (guildID: string, channelID: string) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/guilds/${guildID}/channels`
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/guilds/${guildID}/channels`;
const GUILD_MEMBER = (guildID: string, memberID: string) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/guilds/${guildID}/members/${memberID}`
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/guilds/${guildID}/members/${memberID}`;
const GUILD_MEMBERS = (guildID: string) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/guilds/${guildID}/members`;
const GUILD_MEMBER_ROLE = (guildID: string, memberID: string, roleID: string) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/guilds/${guildID}/members/${memberID}/roles/${roleID}`
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/guilds/${guildID}/members/${memberID}/roles/${roleID}`;
const GUILD_INVITES = (guildID: string) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/guilds/${guildID}/invites`
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/guilds/${guildID}/invites`;
const GUILD_LEAVE = (guildID: string) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/users/@me/guilds/${guildID}`
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/users/@me/guilds/${guildID}`;
const GUILD_PRUNE = (guildID: string) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/guilds/${guildID}/prune`
const VANITY_URL = (guildID: string) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/guilds/${guildID}/vanity-url`
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/guilds/${guildID}/prune`;
const GUILD_VANITY_URL = (guildID: string) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/guilds/${guildID}/vanity-url`;
const GUILD_NICK = (guildID: string) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/guilds/${guildID}/members/@me/nick`;
const GUILD_WIDGET_IMAGE = (guildID: string) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/guilds/${guildID}/widget.png`;
const GUILD_PREVIEW = (guildID: string) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/guilds/${guildID}/preview`;
//Channel Endpoints
const CHANNEL = (channelID: string) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/channels/${channelID}`
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/channels/${channelID}`;
const CHANNELS = (channelID: string) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/guilds/${channelID}/channels`
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/guilds/${channelID}/channels`;
const CHANNEL_MESSAGES = (channelID: string) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/channels/${channelID}/messages`
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/channels/${channelID}/messages`;
const CHANNEL_MESSAGE = (channelID: string, messageID: string) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/channels/${channelID}/messages/${messageID}`
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/channels/${channelID}/messages/${messageID}`;
const CHANNEL_CROSSPOST = (channelID: string, messageID: string) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/channels/${channelID}/messages/${messageID}/crosspost`
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/channels/${channelID}/messages/${messageID}/crosspost`;
const MESSAGE_REACTIONS = (channelID: string, messageID: string) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/channels/${channelID}/messages/${messageID}/reactions`
const MESSAGE_REACTION = (channelID: string, messageID: string, emoji: string) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/channels/${channelID}/messages/${messageID}/reactions/${emoji}`
const MESSAGE_REACTION_ME = (channelID: string, messageID: string, emojiID: string) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/channels/${channelID}/messages/${messageID}/reactions/${emojiID}/@me`
const MESSAGE_REACTION_USER = (channelID: string, messageID: string, emojiID: string, userID: string) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/channels/${channelID}/messages/${messageID}/reactions/${emojiID}/${userID}`
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/channels/${channelID}/messages/${messageID}/reactions`;
const MESSAGE_REACTION = (
channelID: string,
messageID: string,
emoji: string,
) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/channels/${channelID}/messages/${messageID}/reactions/${emoji}`;
const MESSAGE_REACTION_ME = (
channelID: string,
messageID: string,
emojiID: string,
) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/channels/${channelID}/messages/${messageID}/reactions/${emojiID}/@me`;
const MESSAGE_REACTION_USER = (
channelID: string,
messageID: string,
emojiID: string,
userID: string,
) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/channels/${channelID}/messages/${messageID}/reactions/${emojiID}/${userID}`;
const CHANNEL_BULK_DELETE = (channelID: string) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/channels/${channelID}/messages/bulk-delete`
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/channels/${channelID}/messages/bulk-delete`;
const CHANNEL_FOLLOW = (channelID: string) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/channels/${channelID}/followers`
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/channels/${channelID}/followers`;
const CHANNEL_INVITES = (channelID: string) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/channels/${channelID}/invites`
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/channels/${channelID}/invites`;
const CHANNEL_PIN = (channelID: string, messageID: string) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/channels/${channelID}/pins/${messageID}`;
const CHANNEL_PINS = (channelID: string) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/channels/${channelID}/pins`
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/channels/${channelID}/pins`;
const CHANNEL_PERMISSION = (channelID: string, overrideID: string) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/channels/${channelID}/permissions/${overrideID}`;
const CHANNEL_TYPING = (channelID: string) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/channels/${channelID}/typing`;
const GROUP_RECIPIENT = (channelID: string, userID: string) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/channels/${channelID}/recipient/${userID}`;
//User Endpoints
const CURRENT_USER = `${DISCORD_API_URL}/v${DISCORD_API_VERSION}/users/@me`
const CURRENT_USER_GUILDS = `${DISCORD_API_URL}/v${DISCORD_API_VERSION}/users/@me/guilds`
const USER_DM = `${DISCORD_API_URL}/v${DISCORD_API_VERSION}/users/@me/channels`
const USER_CONNECTIONS = `${DISCORD_API_URL}/v${DISCORD_API_VERSION}/users/@me/connections`
const CURRENT_USER = `${DISCORD_API_URL}/v${DISCORD_API_VERSION}/users/@me`;
const CURRENT_USER_GUILDS =
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/users/@me/guilds`;
const USER_DM = `${DISCORD_API_URL}/v${DISCORD_API_VERSION}/users/@me/channels`;
const USER_CONNECTIONS =
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/users/@me/connections`;
const LEAVE_GUILD = (guildID: string) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/users/@me/guilds/${guildID}`
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/users/@me/guilds/${guildID}`;
const USER = (userID: string) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/users/${userID}`
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/users/${userID}`;
//Webhook Endpoints
const CHANNEL_WEBHOOKS = (channelID: string) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/channels/${channelID}/webhooks`
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/channels/${channelID}/webhooks`;
const GUILD_WEBHOOK = (guildID: string) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/guilds/${guildID}/webhooks`
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/guilds/${guildID}/webhooks`;
const WEBHOOK = (webhookID: string) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/webhooks/${webhookID}`
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/webhooks/${webhookID}`;
const WEBHOOK_WITH_TOKEN = (webhookID: string, webhookTOKEN: string) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/webhooks/${webhookID}/${webhookTOKEN}`
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/webhooks/${webhookID}/${webhookTOKEN}`;
const SLACK_WEBHOOK = (webhookID: string, webhookTOKEN: string) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/webhooks/${webhookID}/${webhookTOKEN}/slack`
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/webhooks/${webhookID}/${webhookTOKEN}/slack`;
const GITHUB_WEBHOOK = (webhookID: string, webhookTOKEN: string) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/webhooks/${webhookID}/${webhookTOKEN}/github`
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/webhooks/${webhookID}/${webhookTOKEN}/github`;
//Gateway Endpoints
const GATEWAY = `${DISCORD_API_URL}/v${DISCORD_API_VERSION}/gateway`
const GATEWAY_BOT = `${DISCORD_API_URL}/v${DISCORD_API_VERSION}/gateway/bot`
const GATEWAY = `${DISCORD_API_URL}/v${DISCORD_API_VERSION}/gateway`;
const GATEWAY_BOT = `${DISCORD_API_URL}/v${DISCORD_API_VERSION}/gateway/bot`;
//CDN Endpoints
const CUSTOM_EMOJI = (emojiID: string) =>
`${DISCORD_CDN_URL}/emojis/${emojiID}.png`
`${DISCORD_CDN_URL}/emojis/${emojiID}.png`;
const GUILD_ICON = (guildID: string, iconID: number) =>
`${DISCORD_CDN_URL}/icons/${guildID}/${iconID}.png`
`${DISCORD_CDN_URL}/icons/${guildID}/${iconID}.png`;
const GUILD_SPLASH = (guildID: string, guildSPLASH: string) =>
`${DISCORD_CDN_URL}/splashes/${guildID}/${guildSPLASH}.png`
const GUILD_DISCOVERY_SPLASH = (guildID: string, guildDiscoverySplash: string) =>
`${DISCORD_CDN_URL}/discovery-splashes/${guildID}/${guildDiscoverySplash}.png `
`${DISCORD_CDN_URL}/splashes/${guildID}/${guildSPLASH}.png`;
const GUILD_DISCOVERY_SPLASH = (
guildID: string,
guildDiscoverySplash: string,
) =>
`${DISCORD_CDN_URL}/discovery-splashes/${guildID}/${guildDiscoverySplash}.png `;
const GUILD_BANNER = (guildID: string, guildBANNER: string) =>
`${DISCORD_CDN_URL}/banners/${guildID}/${guildBANNER}.png`
`${DISCORD_CDN_URL}/banners/${guildID}/${guildBANNER}.png`;
const DEFAULT_USER_AVATAR = (iconID: string) =>
`${DISCORD_CDN_URL}/embed/avatars/${iconID}.png`
`${DISCORD_CDN_URL}/embed/avatars/${iconID}.png`;
const USER_AVATAR = (userID: string, iconID: string) =>
`${DISCORD_CDN_URL}/avatars/${userID}/${iconID}.png`
`${DISCORD_CDN_URL}/avatars/${userID}/${iconID}.png`;
const APPLICATION_ASSET = (applicationID: string, assetID: number) =>
`${DISCORD_CDN_URL}/app-icons/${applicationID}/${assetID}.png`
const ACHIEVEMENT_ICON = (applicationID: string, achievementID: string, iconHASH: string) =>
`${DISCORD_CDN_URL}/app-assets/${applicationID}/achievements/${achievementID}/icons/${iconHASH}.png`
`${DISCORD_CDN_URL}/app-icons/${applicationID}/${assetID}.png`;
const ACHIEVEMENT_ICON = (
applicationID: string,
achievementID: string,
iconHASH: string,
) =>
`${DISCORD_CDN_URL}/app-assets/${applicationID}/achievements/${achievementID}/icons/${iconHASH}.png`;
const TEAM_ICON = (teamID: string, iconID: string) =>
`${DISCORD_CDN_URL}/team-icons/${teamID}/${iconID}.png`
`${DISCORD_CDN_URL}/team-icons/${teamID}/${iconID}.png`;
//Emoji Endpoints
const EMOJI = (guildID: string, emojiID: string) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/guilds/${guildID}/emojis/${emojiID}`
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/guilds/${guildID}/emojis/${emojiID}`;
const EMOJIS = (guildID: string) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/guilds/${guildID}/emojis`
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/guilds/${guildID}/emojis`;
//Template Endpoint
const TEMPLATE = (templateCODE: string) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/guilds/templates/${templateCODE}`
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/guilds/templates/${templateCODE}`;
//Invite Endpoint
const INVITE = (inviteCODE: string) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/invites/${inviteCODE}`
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/invites/${inviteCODE}`;
//Voice Endpoint
const VOICE_REGIONS= (guildID: string) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/guilds/${guildID}/regions`
const VOICE_REGIONS = (guildID: string) =>
`${DISCORD_API_URL}/v${DISCORD_API_VERSION}/guilds/${guildID}/regions`;

107
src/types/guildTypes.ts Normal file
View file

@ -0,0 +1,107 @@
interface Guild {
id: string
name: string
icon: string | undefined
icon_hash?: string | undefined
splash: string | undefined
discovery_splash: string | undefined
owner?: boolean
owner_id: string
permissions?: string
region: string
afk_channel_id: string | undefined
afk_timeout: number
widget_enabled?: boolean
widge_channel_id?: string | undefined
verification_level: string
default_message_notifications: string
explicit_content_filter: string
roles: Role[]
emojis: Emoji[]
features: GuildFeatures[]
mfa_level: string
application_id: string | undefined
system_channel_id: string | undefined
system_channel_flags: string
rules_channel_id: string | undefined
joined_at?: string
large?: boolean
unavailable: boolean
member_count?: number
voice_states?: VoiceState[]
members?: GuildMember[]
channels?: Channel[]
presences?: PresenceUpdate[]
max_presences?: number | undefined
max_members?: number
vanity_url_code: string | undefined
description: string | undefined
banner: string | undefined
premium_tier: number
premium_subscription_count?: number
preferred_locale: string
public_updates_channel_id: string | undefined
max_video_channel_users?: number
approximate_number_count?: number
approximate_presence_count?: number
}
interface GuildMember {
user?: User
nick: string | undefined
roles: Role[]
joined_at: string
premium_since?: string | undefined
deaf: boolean
mute: boolean
}
enum MessageNotification {
ALL_MESSAGES = 0,
ONLY_MENTIONS = 1
}
enum ContentFilter {
DISABLED = 0,
MEMBERS_WITHOUT_ROLES = 1,
ALL_MEMBERS = 3,
}
enum MFA {
NONE = 0,
ELEVATED = 1
}
enum Verification {
NONE = 0,
LOW = 1,
MEDIUM = 2,
HIGH = 3,
VERY_HIGH = 4
}
enum PremiumTier {
NONE = 0,
TIER_1 = 1,
TIER_2 = 2,
TIER_3 = 3
}
enum SystemChannelFlags {
SUPPRESS_JOIN_NOTIFICATIONS = 1 << 0,
SUPPRESS_PREMIUM_SUBSCRIPTIONS = 1 << 1
}
type GuildFeatures =
| "INVITE_SPLASH"
| "VIP_REGIONS"
| "VANITY_URL"
| "VERIFIED"
| "PARTNERED"
| "PUBLIC"
| "COMMERCE"
| "NEWS"
| "DISCOVERABLE"
| "FEATURABLE"
| "ANIMATED_ICON"
| "BANNER"

10
src/types/inviteTypes.ts Normal file
View file

@ -0,0 +1,10 @@
interface Invite {
code: string
guild?: any //guild object
channel: any //channel object
inviter?: User
target_user?: User
target_user_type?: number
approximate_presence_count?: number
approximate_member_count?: number
}

View file

@ -0,0 +1,72 @@
interface PresenceUpdate {
user: User
guild_id: string
status: string
activities: Activity
client_status:
}
interface ClientStatus {
desktop?: string
mobile?: string
web?: string
}
interface Activity {
name: string
type: 0 | 1 | 2 | 3 | 4 | 5
url?: string | undefined
created_at: number
timestamps?: ActivityTimestamps
application_id?: string
details?: string | undefined
state?: string | undefined
emoji?: ActivityEmoji
party?: ActivityParty
assets?: ActivityAssets
secrets?: ActivitySecrets
instance?: boolean
flags?: number
}
interface ActivityTimestamps {
start?: number
end?: number
}
interface ActivityEmoji {
name: string
id?: string
animated?: boolean
}
interface ActivityParty {
id?: string
size?: number[]
}
interface ActivityAssets {
large_image?: string
large_text?: string
small_image?: string
small_text?: string
}
interface ActivitySecrets {
join?: string
spectate?: string
match?: string
}
enum ActivityFlags {
INSTANCE = 1 << 0,
JOIN = 1 << 1,
SPECTATE = 1 << 2,
JOIN_REQUEST = 1 << 3,
SYNC = 1 << 4,
PLAY = 1 << 5
}
// channel 에서 message 부분 하삼 ㄳ
//시1 오늘 7교시 수업안듣고 이거 ㅋㅋ 에바 온라인수업이라 ㅆㄱㄴ
//나도 한다 디코에서 알려주셈 뭐하면되는지

10
src/types/roleTypes.ts Normal file
View file

@ -0,0 +1,10 @@
interface Role {
id: string
name: string
color: number
hoist: boolean
position: number
permissions: string
managed: boolean
mentionable: boolean
}

19
src/types/snowflake.ts Normal file
View file

@ -0,0 +1,19 @@
// 와갈, 따꾸, 동한드
export class Snowflake {
id: string;
constructor(id: string) {
this.id = id;
}
deconstruct() {
const snowflake = BigInt.asUintN(64, BigInt(this.id));
const res = {
timestamp: (snowflake << BigInt(22)) + BigInt(1420070400000),
workerId: (snowflake & BigInt(0x3E0000)) >> BigInt(17),
processId: (snowflake & BigInt(0x1F000)) >> BigInt(12),
increment: snowflake & BigInt(0xFFF),
};
return res;
}
}

View file

@ -0,0 +1,13 @@
interface Template {
code: string
name: string
description: string | undefined
usage_count: number
creator_id: string
creator: User
created_at: string
updated_at: string
source_guild_id: string
serialized_source_guild: any //guild object
is_dirty: boolean | undefined
}

15
src/types/userTypes.ts Normal file
View file

@ -0,0 +1,15 @@
interface User {
id: string
username: string
discriminator: string
avatar: string | undefined
bot?: boolean
system?: boolean
mfa_enabled?: boolean
locale?: string
verified?: boolean
email?: string | undefined
flags?: number
premium_type?: 0 | 1 | 2
public_flags?: number
}

View file

@ -11,7 +11,7 @@ enum VoiceOpcodes { // VoiceOpcodes 추가 - UnderC -
RESUME = 7,
HELLO = 8,
RESUMED = 9,
CLIENT_DISCONNECT = 13
CLIENT_DISCONNECT = 13,
}
enum VoiceCloseCodes {
@ -25,5 +25,20 @@ enum VoiceCloseCodes {
UNKNOWN_PROTOCOL = 4012,
DISCONNECTED = 4014,
VOICE_SERVER_CRASHED = 4015,
UNKNOWN_ENCRYPTION_MODE = 4016
UNKNOWN_ENCRYPTION_MODE = 4016,
}
interface VoiceState {
guild_id?: string
channel_id: string | undefined
user_id: string
member?: GuildMember
session_id: string
deaf: boolean
mute: boolean
self_deaf: boolean
self_mute: boolean
self_stream?: boolean
self_video: boolean
suppress: boolean
}

11
src/types/webhookTypes.ts Normal file
View file

@ -0,0 +1,11 @@
interface Webhook {
id: string
type: 1 | 2
guild_id?: string
channel_id: string
user?: User
name: string | undefined
avatar: string | undefined
token?: string
application_id: string | undefined
}

View file

@ -1,14 +1,15 @@
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "ESNEXT",
"target": "ESNext",
/* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
"module": "ESNext",
/* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation. */
"lib": [
"esnext",
], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
@ -25,7 +26,6 @@
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
"strict": true,
/* Enable all strict type-checking options. */
@ -36,13 +36,11 @@
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
/* Module Resolution Options */
"moduleResolution": "node",
/* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
@ -56,17 +54,14 @@
/* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
/* Advanced Options */
"skipLibCheck": true,
/* Skip type checking of declaration files. */