mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-17 03:38:17 +00:00
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:
@@ -417,7 +417,7 @@ export async function editChannel(
|
||||
};
|
||||
|
||||
return RequestManager.patch(
|
||||
endpoints.GUILD_CHANNEL(channelID),
|
||||
endpoints.CHANNEL_BASE(channelID),
|
||||
{
|
||||
...payload,
|
||||
reason,
|
||||
|
||||
@@ -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>;
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ export async function sendDirectMessage(
|
||||
if (!dmChannel) {
|
||||
// If not available in cache create a new one.
|
||||
const dmChannelData = await RequestManager.post(
|
||||
endpoints.USER_CREATE_DM,
|
||||
endpoints.USER_DM,
|
||||
{ recipient_id: memberID },
|
||||
) as DMChannelCreatePayload;
|
||||
// Channel create event will have added this channel to the cache
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { botID } from "../../bot.ts";
|
||||
import { RequestManager } from "../../rest/request_manager.ts";
|
||||
import {
|
||||
CreateSlashCommandOptions,
|
||||
EditSlashCommandOptions,
|
||||
@@ -17,7 +18,6 @@ import { endpoints } from "../../util/constants.ts";
|
||||
import { botHasChannelPermissions } from "../../util/permissions.ts";
|
||||
import { urlToBase64 } from "../../util/utils.ts";
|
||||
import { structures } from "../structures/mod.ts";
|
||||
import { RequestManager } from "../../rest/request_manager.ts";
|
||||
|
||||
/** Create a new webhook. Requires the MANAGE_WEBHOOKS permission. Returns a webhook object on success. Webhook names follow our naming restrictions that can be found in our Usernames and Nicknames documentation, with the following additional stipulations:
|
||||
*
|
||||
@@ -166,7 +166,7 @@ export function editWebhookMessage(
|
||||
}
|
||||
|
||||
return RequestManager.patch(
|
||||
endpoints.WEBHOOK_EDIT(webhookID, webhookToken, messageID),
|
||||
endpoints.WEBHOOK_MESSAGE(webhookID, webhookToken, messageID),
|
||||
{ ...options, allowed_mentions: options.allowed_mentions },
|
||||
);
|
||||
}
|
||||
@@ -177,7 +177,7 @@ export function deleteWebhookMessage(
|
||||
messageID: string,
|
||||
) {
|
||||
return RequestManager.delete(
|
||||
endpoints.WEBHOOK_DELETE(webhookID, webhookToken, messageID),
|
||||
endpoints.WEBHOOK_MESSAGE(webhookID, webhookToken, messageID),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user