mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 11:33:30 +01:00
Internal API Request Rewrite (#1490)
* start rewrite * converted guilds * more changes * convert GuildMember * convert User and remove friend methods which kill people * convert more stuff * even more stuff * make things nicer * speed and fixes and stuff * almost finished * fix * Update Client.js * uwu * Update RESTMethods.js * message editing * fix router * fix issue with references * message delete reason * move message sending * fix dm * message splitting * NO MORE REST METHODS * Update Client.js * Update WebhookClient.js * remove all those endpoints from the constants * Update ClientUser.js * Update ClientUser.js * fixes * Update ClientUser.js * complaiancy * all sort of fixes * merge master (#1) * Fix Permissions now that member is deprecated (#1491) * removing more deprecation leftovers (#1492) * Fix MessageCollectors * Fix awaitMessages (#1493) * Fix MessageCollector#cleanup * Fix MessageCollector#postCheck * Add max option back for safety * Update Invite.js (#1496) * guild setPosition missing docs (#1498) * missing docs * update return docs * indent * switched .invites for the apirouter and invite.js * make multiple options an object * Update ClientUser.js * fix nicks * Update WebhookClient.js
This commit is contained in:
@@ -106,101 +106,7 @@ const AllowedImageSizes = [
|
||||
2048,
|
||||
];
|
||||
|
||||
const Endpoints = exports.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 => `${base}/guilds/${guildID}`,
|
||||
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, format, size) => {
|
||||
if (userID === '1') return hash;
|
||||
return Endpoints.CDN(root).Avatar(userID, hash, format, size);
|
||||
},
|
||||
};
|
||||
},
|
||||
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, format, size) => Endpoints.CDN(root).Icon(guildID, hash, format, size),
|
||||
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`,
|
||||
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, limit) => {
|
||||
const rbase = `${mbase}/reactions/${emoji}${limit ? `?limit=${limit}` : ''}`;
|
||||
return {
|
||||
toString: () => rbase,
|
||||
User: userID => `${rbase}/${userID}`,
|
||||
};
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
},
|
||||
Message: m => exports.Endpoints.Channel(m.channel).Message(m),
|
||||
Member: m => exports.Endpoints.Guild(m.guild).Member(m),
|
||||
exports.Endpoints = {
|
||||
CDN(root) {
|
||||
return {
|
||||
Emoji: emojiID => `${root}/emojis/${emojiID}.png`,
|
||||
@@ -227,26 +133,7 @@ const Endpoints = exports.Endpoints = {
|
||||
Splash: (guildID, hash) => `${root}/splashes/${guildID}/${hash}.jpg`,
|
||||
};
|
||||
},
|
||||
OAUTH2: {
|
||||
Application: appID => {
|
||||
const base = `/oauth2/applications/${appID}`;
|
||||
return {
|
||||
toString: () => base,
|
||||
reset: `${base}/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 => `/invite/${inviteID}?with_counts=true`,
|
||||
inviteLink: id => `https://discord.gg/${id}`,
|
||||
Webhook: (webhookID, token) => `/webhooks/${webhookID}${token ? `/${token}` : ''}`,
|
||||
invite: code => `https://discord.gg/${code}`,
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ class Util {
|
||||
}
|
||||
messages[msg] += (messages[msg].length > 0 && messages[msg] !== prepend ? char : '') + splitText[i];
|
||||
}
|
||||
return messages;
|
||||
return messages.filter(m => m);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user