mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-04 09:50:07 +00:00
feat(handlers): add editChannelOverwrite() & deleteChannelOverwrite() (#403)
* add editChannelOverwrite function * remove body constant Co-authored-by: Ayyan <ayyantee@gmail.com> * format * Update src/api/handlers/guild.ts Co-authored-by: Ayyan <ayyantee@gmail.com> * Update src/api/handlers/guild.ts Co-authored-by: Ayyan <ayyantee@gmail.com> * add deleteChannelOverwrite function * Mark permission in jsdoc Co-authored-by: Ayyan <ayyantee@gmail.com> Co-authored-by: Ayyan <ayyantee@gmail.com>
This commit is contained in:
@@ -25,6 +25,7 @@ import {
|
||||
ImageSize,
|
||||
Intents,
|
||||
MemberCreatePayload,
|
||||
Overwrite,
|
||||
PositionSwap,
|
||||
PruneOptions,
|
||||
PrunePayload,
|
||||
@@ -206,6 +207,50 @@ export function swapChannels(
|
||||
);
|
||||
}
|
||||
|
||||
/** Edit the channel permission overwrites for a user or role in this channel. Requires `MANAGE_ROLES` permission. */
|
||||
export async function editChannelOverwrite(
|
||||
guildID: string,
|
||||
channelID: string,
|
||||
overwriteID: string,
|
||||
options: Omit<Overwrite, "id">,
|
||||
) {
|
||||
const hasPerm = await botHasPermission(
|
||||
guildID,
|
||||
["MANAGE_ROLES"],
|
||||
);
|
||||
if (!hasPerm) {
|
||||
throw new Error(Errors.MISSING_MANAGE_ROLES);
|
||||
}
|
||||
|
||||
return RequestManager.put(
|
||||
endpoints.CHANNEL_OVERWRITE(channelID, overwriteID),
|
||||
{
|
||||
allow: calculateBits(options.allow),
|
||||
deny: calculateBits(options.deny),
|
||||
type: options.type,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/** Delete the channel permission overwrites for a user or role in this channel. Requires `MANAGE_ROLES` permission. */
|
||||
export async function deleteChannelOverwrite(
|
||||
guildID: string,
|
||||
channelID: string,
|
||||
overwriteID: string,
|
||||
) {
|
||||
const hasPerm = await botHasPermission(
|
||||
guildID,
|
||||
["MANAGE_ROLES"],
|
||||
);
|
||||
if (!hasPerm) {
|
||||
throw new Error(Errors.MISSING_MANAGE_ROLES);
|
||||
}
|
||||
|
||||
return RequestManager.delete(
|
||||
endpoints.CHANNEL_OVERWRITE(channelID, overwriteID),
|
||||
);
|
||||
}
|
||||
|
||||
/** Returns a guild member object for the specified user.
|
||||
*
|
||||
* ⚠️ **ADVANCED USE ONLY: Your members will be cached in your guild most likely. Only use this when you are absolutely sure the member is not cached.**
|
||||
|
||||
Reference in New Issue
Block a user