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
+32
View File
@@ -0,0 +1,32 @@
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 {
highestRole,
requireBotGuildPermissions,
} from "../../util/permissions.ts";
/** Kick a member from the server */
export async function kick(guildID: string, memberID: string, reason?: string) {
const botsHighestRole = await highestRole(guildID, botID);
const membersHighestRole = await highestRole(guildID, memberID);
if (
botsHighestRole && membersHighestRole &&
botsHighestRole.position <= membersHighestRole.position
) {
throw new Error(Errors.BOTS_HIGHEST_ROLE_TOO_LOW);
}
await requireBotGuildPermissions(guildID, ["KICK_MEMBERS"]);
const result = await RequestManager.delete(
endpoints.GUILD_MEMBER(guildID, memberID),
{ reason },
);
return result;
}
// aliases
export { kick as kickMember };