mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 12:25:02 +00:00
Add command to kick from VC (#124)
This commit is contained in:
parent
c1fc9744e3
commit
1c24910a20
6 changed files with 66 additions and 3 deletions
58
backend/src/plugins/Utility/commands/VcdisconnectCmd.ts
Normal file
58
backend/src/plugins/Utility/commands/VcdisconnectCmd.ts
Normal file
|
@ -0,0 +1,58 @@
|
|||
import { utilityCmd } from "../types";
|
||||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import {
|
||||
channelMentionRegex,
|
||||
errorMessage,
|
||||
isSnowflake,
|
||||
simpleClosestStringMatch,
|
||||
stripObjectToScalars,
|
||||
} from "../../../utils";
|
||||
import { canActOn, sendErrorMessage, sendSuccessMessage } from "../../../pluginUtils";
|
||||
import { VoiceChannel } from "eris";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { resolveChannel } from "knub/dist/helpers";
|
||||
|
||||
export const VcdisconnectCmd = utilityCmd({
|
||||
trigger: ["vcdisconnect", "vcdisc", "vcdc", "vckick", "vck"],
|
||||
description: "Disconnect a member from their voice channel",
|
||||
usage: "!vcdc @Dark",
|
||||
permission: "can_vckick",
|
||||
|
||||
signature: {
|
||||
member: ct.resolvedMember(),
|
||||
},
|
||||
|
||||
async run({ message: msg, args, pluginData }) {
|
||||
if (!canActOn(pluginData, msg.member, args.member)) {
|
||||
sendErrorMessage(pluginData, msg.channel, "Cannot move: insufficient permissions");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!args.member.voiceState || !args.member.voiceState.channelID) {
|
||||
sendErrorMessage(pluginData, msg.channel, "Member is not in a voice channel");
|
||||
return;
|
||||
}
|
||||
const channel = (await resolveChannel(pluginData.guild, args.member.voiceState.channelID)) as VoiceChannel;
|
||||
|
||||
try {
|
||||
await args.member.edit({
|
||||
channelID: null,
|
||||
});
|
||||
} catch (e) {
|
||||
sendErrorMessage(pluginData, msg.channel, "Failed to disconnect member");
|
||||
return;
|
||||
}
|
||||
|
||||
pluginData.state.logs.log(LogType.VOICE_CHANNEL_FORCE_DISCONNECT, {
|
||||
mod: stripObjectToScalars(msg.author),
|
||||
member: stripObjectToScalars(args.member, ["user", "roles"]),
|
||||
oldChannel: stripObjectToScalars(channel),
|
||||
});
|
||||
|
||||
sendSuccessMessage(
|
||||
pluginData,
|
||||
msg.channel,
|
||||
`**${args.member.user.username}#${args.member.user.discriminator}** disconnected from **${channel.name}**`,
|
||||
);
|
||||
},
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue