mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-16 22:55:03 +00:00
35 lines
1,018 B
TypeScript
35 lines
1,018 B
TypeScript
import { Snowflake } from "discord.js";
|
|
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
|
import { isStaffPreFilter } from "../../../pluginUtils";
|
|
import { botControlCmd } from "../types";
|
|
|
|
export const LeaveServerCmd = botControlCmd({
|
|
trigger: ["leave_server", "leave_guild"],
|
|
permission: null,
|
|
config: {
|
|
preFilters: [isStaffPreFilter],
|
|
},
|
|
|
|
signature: {
|
|
guildId: ct.string(),
|
|
},
|
|
|
|
async run({ pluginData, message: msg, args }) {
|
|
if (!pluginData.client.guilds.cache.has(args.guildId as Snowflake)) {
|
|
void msg.channel.send("I am not in that guild");
|
|
return;
|
|
}
|
|
|
|
const guildToLeave = await pluginData.client.guilds.fetch(args.guildId as Snowflake)!;
|
|
const guildName = guildToLeave.name;
|
|
|
|
try {
|
|
await pluginData.client.guilds.cache.get(args.guildId as Snowflake)?.leave();
|
|
} catch (e) {
|
|
void msg.channel.send(`Failed to leave guild: ${e.message}`);
|
|
return;
|
|
}
|
|
|
|
void msg.channel.send(`Left guild **${guildName}**`);
|
|
},
|
|
});
|