2020-10-01 01:43:38 +03:00
|
|
|
import { botControlCmd } from "../types";
|
2020-07-30 03:21:07 +03:00
|
|
|
import { isOwnerPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
|
|
|
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
|
|
|
|
2020-10-01 01:43:38 +03:00
|
|
|
export const LeaveServerCmd = botControlCmd({
|
2020-07-30 03:21:07 +03:00
|
|
|
trigger: ["leave_server", "leave_guild"],
|
|
|
|
permission: null,
|
|
|
|
config: {
|
|
|
|
preFilters: [isOwnerPreFilter],
|
|
|
|
},
|
|
|
|
|
|
|
|
signature: {
|
|
|
|
guildId: ct.string(),
|
|
|
|
},
|
|
|
|
|
|
|
|
async run({ pluginData, message: msg, args }) {
|
|
|
|
if (!pluginData.client.guilds.has(args.guildId)) {
|
|
|
|
sendErrorMessage(pluginData, msg.channel, "I am not in that guild");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const guildToLeave = pluginData.client.guilds.get(args.guildId);
|
|
|
|
const guildName = guildToLeave.name;
|
|
|
|
|
|
|
|
try {
|
|
|
|
await pluginData.client.leaveGuild(args.guildId);
|
|
|
|
} catch (e) {
|
|
|
|
sendErrorMessage(pluginData, msg.channel, `Failed to leave guild: ${e.message}`);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
sendSuccessMessage(pluginData, msg.channel, `Left guild **${guildName}**`);
|
|
|
|
},
|
|
|
|
});
|