refactor(helpers): separate functions into files (#667)

* refactor(helpers): separate functions into files

* idk

* idk
This commit is contained in:
ayntee
2021-03-13 08:10:31 -05:00
committed by GitHub
parent 88ce4da555
commit e9cbbbff7c
143 changed files with 3362 additions and 2915 deletions
+36
View File
@@ -0,0 +1,36 @@
import { botID } from "../../bot.ts";
import { RequestManager } from "../../rest/request_manager.ts";
import { Errors } from "../../types/mod.ts";
import { endpoints } from "../../util/constants.ts";
import {
isHigherPosition,
requireBotGuildPermissions,
} from "../../util/permissions.ts";
/** Remove a role from the member */
export async function removeRole(
guildID: string,
memberID: string,
roleID: string,
reason?: string,
) {
const isHigherRolePosition = await isHigherPosition(
guildID,
botID,
roleID,
);
if (
!isHigherRolePosition
) {
throw new Error(Errors.BOTS_HIGHEST_ROLE_TOO_LOW);
}
await requireBotGuildPermissions(guildID, ["MANAGE_ROLES"]);
const result = await RequestManager.delete(
endpoints.GUILD_MEMBER_ROLE(guildID, memberID, roleID),
{ reason },
);
return result;
}