mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-03 17:30:07 +00:00
fix: add perm checking for timeouts. Closes #1972
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { BotWithCache, PermissionStrings } from "../../deps.ts";
|
||||
import { requireBotGuildPermissions } from "../permissions.ts";
|
||||
import { hasGuildPermissions, requireBotGuildPermissions, requireGuildPermissions } from "../permissions.ts";
|
||||
|
||||
export default function editMember(bot: BotWithCache) {
|
||||
const editMemberOld = bot.helpers.editMember;
|
||||
@@ -13,6 +13,17 @@ export default function editMember(bot: BotWithCache) {
|
||||
if (options.mute !== undefined) requiredPerms.push("MUTE_MEMBERS");
|
||||
if (options.deaf !== undefined) requiredPerms.push("DEAFEN_MEMBERS");
|
||||
|
||||
if (options.communicationDisabledUntil) {
|
||||
const guild = bot.guilds.get(guildId);
|
||||
if (guild) {
|
||||
if (guild.ownerId === memberId) throw new Error("You can not timeout the servers owner.");
|
||||
}
|
||||
|
||||
if (!hasGuildPermissions(bot, guildId, memberId, ["ADMINISTRATOR"])) {
|
||||
throw new Error("You can not timeout a server administrator.");
|
||||
}
|
||||
}
|
||||
|
||||
if (requiredPerms.length) {
|
||||
requireBotGuildPermissions(bot, guildId, requiredPerms);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user