Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const Endpoints = {
- User: userID => {
- if (userID.id) userID = userID.id;
- const base = `/users/${userID}`;
- return {
- toString: () => base,
- channels: `${base}/channels`,
- profile: `${base}/profile`,
- relationships: `${base}/relationships`,
- settings: `${base}/settings`,
- Relationship: uID => `${base}/relationships/${uID}`,
- Guild: guildID => ({
- toString: () => `${base}/guilds/${guildID}`,
- settings: `${base}/guilds/${guildID}/settings`,
- }),
- Note: id => `${base}/notes/${id}`,
- Mentions: (limit, roles, everyone, guildID) =>
- `${base}/mentions?limit=${limit}&roles=${roles}&everyone=${everyone}${guildID ? `&guild_id=${guildID}` : ''}`,
- Avatar: (root, hash) => {
- if (userID === '1') return hash;
- return Endpoints.CDN(root).Avatar(userID, hash);
- },
- };
- },
- guilds: '/guilds',
- Guild: guildID => {
- if (guildID.id) guildID = guildID.id;
- const base = `/guilds/${guildID}`;
- return {
- toString: () => base,
- prune: `${base}/prune`,
- embed: `${base}/embed`,
- bans: `${base}/bans`,
- integrations: `${base}/integrations`,
- members: `${base}/members`,
- channels: `${base}/channels`,
- invites: `${base}/invites`,
- roles: `${base}/roles`,
- emojis: `${base}/emojis`,
- search: `${base}/messages/search`,
- voiceRegions: `${base}/regions`,
- webhooks: `${base}/webhooks`,
- ack: `${base}/ack`,
- settings: `${base}/settings`,
- auditLogs: `${base}/audit-logs`,
- Emoji: emojiID => `${base}/emojis/${emojiID}`,
- Icon: (root, hash) => Endpoints.CDN(root).Icon(guildID, hash),
- Splash: (root, hash) => Endpoints.CDN(root).Splash(guildID, hash),
- Role: roleID => `${base}/roles/${roleID}`,
- Member: memberID => {
- if (memberID.id) memberID = memberID.id;
- const mbase = `${base}/members/${memberID}`;
- return {
- toString: () => mbase,
- Role: roleID => `${mbase}/roles/${roleID}`,
- nickname: `${base}/members/@me/nick`,
- };
- },
- };
- },
- channels: '/channels',
- Channel: channelID => {
- if (channelID.id) channelID = channelID.id;
- const base = `/channels/${channelID}`;
- return {
- toString: () => base,
- messages: {
- toString: () => `${base}/messages`,
- bulkDelete: `${base}/messages/bulk-delete`,
- },
- invites: `${base}/invites`,
- typing: `${base}/typing`,
- permissions: `${base}/permissions`,
- webhooks: `${base}/webhooks`,
- search: `${base}/messages/search`,
- pins: `${base}/pins`,
- Icon: (root, hash) => Endpoints.CDN(root).GDMIcon(channelID, hash),
- Pin: messageID => `${base}/pins/${messageID}`,
- Recipient: recipientID => `${base}/recipients/${recipientID}`,
- Message: messageID => {
- if (messageID.id) messageID = messageID.id;
- const mbase = `${base}/messages/${messageID}`;
- return {
- toString: () => mbase,
- reactions: `${mbase}/reactions`,
- ack: `${mbase}/ack`,
- Reaction: emoji => {
- const rbase = `${mbase}/reactions/${emoji}`;
- return {
- toString: () => rbase,
- User: userID => `${rbase}/${userID}`,
- };
- },
- };
- },
- };
- },
- Message: (m, c) => Endpoints.Channel(c).Message(m),
- Member: (m, g) => Endpoints.Guild(g).Member(m),
- CDN(root) {
- return {
- Emoji: (emojiID, format = 'png') => `${root}/emojis/${emojiID}.${format}`,
- Asset: name => `${root}/assets/${name}`,
- Avatar: (userID, hash) => `${root}/avatars/${userID}/${hash}.${hash.startsWith('a_') ? 'gif' : 'png?size=2048'}`,
- Icon: (guildID, hash) => `${root}/icons/${guildID}/${hash}.jpg`,
- AppIcon: (clientID, hash) => `${root}/app-icons/${clientID}/${hash}.png`,
- AppAsset: (clientID, hash) => `${root}/app-assets/${clientID}/${hash}.png`,
- GDMIcon: (channelID, hash) => `${root}/channel-icons/${channelID}/${hash}.jpg?size=2048`,
- Splash: (guildID, hash) => `${root}/splashes/${guildID}/${hash}.jpg`,
- };
- },
- OAUTH2: {
- Application: appID => {
- const base = `/oauth2/applications/${appID}`;
- return {
- toString: () => base,
- resetSecret: `${base}/reset`,
- resetToken: `${base}/bot/reset`,
- };
- },
- App: appID => `/oauth2/authorize?client_id=${appID}`,
- },
- login: '/auth/login',
- logout: '/auth/logout',
- voiceRegions: '/voice/regions',
- gateway: {
- toString: () => '/gateway',
- bot: '/gateway/bot',
- },
- Invite: (inviteID, withCounts = true) => `/invite/${inviteID}?with_counts=${withCounts}`,
- inviteLink: id => `https://discord.gg/${id}`,
- Webhook: (webhookID, token) => `/webhooks/${webhookID}${token ? `/${token}` : ''}`,
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement