mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 12:25:02 +00:00
Port BotControl
This commit is contained in:
parent
b66e601cef
commit
f500034729
10 changed files with 237 additions and 2 deletions
35
backend/src/plugins/BotControl/commands/LeaveServerCmd.ts
Normal file
35
backend/src/plugins/BotControl/commands/LeaveServerCmd.ts
Normal file
|
@ -0,0 +1,35 @@
|
|||
import { command } from "knub";
|
||||
import { BotControlPluginType } from "../types";
|
||||
import { isOwnerPreFilter, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
|
||||
export const LeaveServerCmd = command<BotControlPluginType>()({
|
||||
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}**`);
|
||||
},
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue