refactor(util): update endpoints (#383)

* Update constants.ts

* fiiiixxxx

* dupe

* Update src/util/constants.ts

Co-authored-by: Ayyan <ayyantee@gmail.com>

* USER_DM

* fix this and remove that

* Update src/util/constants.ts

Co-authored-by: Ayyan <ayyantee@gmail.com>

* Update constants.ts

* Update src/util/constants.ts

Co-authored-by: Ayyan <ayyantee@gmail.com>

* Update src/util/constants.ts

Co-authored-by: Ayyan <ayyantee@gmail.com>

* need these

* hmm

* rename GUILD_EMBED to GUILD_WIDGET

* idk

* Update src/util/constants.ts

Co-authored-by: Ayyan <ayyantee@gmail.com>

* Update constants.ts

* Update constants.ts

Co-authored-by: Ayyan <ayyantee@gmail.com>
This commit is contained in:
ITOH
2021-01-17 17:34:34 +01:00
committed by GitHub
parent b4cfeb7fbd
commit 8b663ca4de
5 changed files with 122 additions and 99 deletions
+7 -7
View File
@@ -52,7 +52,7 @@ export async function createServer(options: CreateServerOptions) {
/** Delete a guild permanently. User must be owner. Returns 204 No Content on success. Fires a Guild Delete Gateway event.
*/
export function deleteServer(guildID: string) {
return RequestManager.delete(endpoints.GUILD(guildID));
return RequestManager.delete(endpoints.GUILDS_BASE(guildID));
}
/** Gets an array of all the channels ids that are the children of this category. */
@@ -148,7 +148,7 @@ export async function deleteChannel(
throw new Error(Errors.MISSING_MANAGE_CHANNELS);
}
return RequestManager.delete(endpoints.CHANNEL(channelID), { reason });
return RequestManager.delete(endpoints.CHANNEL_BASE(channelID), { reason });
}
/** Returns a list of guild channel objects.
@@ -174,7 +174,7 @@ export async function getChannels(guildID: string, addToCache = true) {
*/
export async function getChannel(channelID: string, addToCache = true) {
const result = await RequestManager.get(
endpoints.GUILD_CHANNEL(channelID),
endpoints.CHANNEL_BASE(channelID),
) as ChannelCreatePayload;
const channel = await structures.createChannel(result, result.guild_id);
if (addToCache) await cacheHandlers.set("channels", channel.id, channel);
@@ -462,7 +462,7 @@ export async function getEmbed(guildID: string) {
throw new Error(Errors.MISSING_MANAGE_GUILD);
}
return RequestManager.get(endpoints.GUILD_EMBED(guildID));
return RequestManager.get(endpoints.GUILD_WIDGET(guildID));
}
/** Modify a guild embed object for the guild. Requires the MANAGE_GUILD permission. */
@@ -477,7 +477,7 @@ export async function editEmbed(
}
return RequestManager.patch(
endpoints.GUILD_EMBED(guildID),
endpoints.GUILD_WIDGET(guildID),
{ enabled, channel_id: channelID },
);
}
@@ -603,7 +603,7 @@ export async function editGuild(guildID: string, options: GuildEditOptions) {
options.splash = await urlToBase64(options.splash);
}
return RequestManager.patch(endpoints.GUILD(guildID), options);
return RequestManager.patch(endpoints.GUILDS_BASE(guildID), options);
}
/** Get all the invites for this guild. Requires MANAGE_GUILD permission */
@@ -653,7 +653,7 @@ export function getUser(userID: string) {
* */
export function getGuild(guildID: string, counts = true) {
return RequestManager.get(
endpoints.GUILD(guildID),
endpoints.GUILDS_BASE(guildID),
{ with_counts: counts },
) as Promise<UpdateGuildPayload>;
}