3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-10 12:25:02 +00:00

Migrate Slowmode to new Plugin structure

This commit is contained in:
Dark 2020-07-23 00:25:40 +02:00
parent ebcb28261b
commit b4b8680431
14 changed files with 538 additions and 0 deletions

View file

@ -0,0 +1,40 @@
import { commandTypeHelpers as ct } from "../../../commandTypes";
import { sendErrorMessage, sendSuccessMessage } from "src/pluginUtils";
import { slowmodeCmd } from "../types";
import { clearBotSlowmodeFromUserId } from "../util/clearBotSlowmodeFromUserId";
export const SlowmodeClearCmd = slowmodeCmd({
trigger: ["slowmode clear", "slowmode c"],
permission: "can_manage",
signature: {
channel: ct.textChannel(),
user: ct.resolvedUserLoose(),
force: ct.bool({ option: true, isSwitch: true }),
},
async run({ message: msg, args, pluginData }) {
const channelSlowmode = await pluginData.state.slowmodes.getChannelSlowmode(args.channel.id);
if (!channelSlowmode) {
sendErrorMessage(pluginData, msg.channel, "Channel doesn't have slowmode!");
return;
}
try {
await clearBotSlowmodeFromUserId(pluginData, args.channel, args.user.id, args.force);
} catch (e) {
return sendErrorMessage(
pluginData,
msg.channel,
`Failed to clear slowmode from **${args.user.username}#${args.user.discriminator}** in <#${args.channel.id}>`,
);
}
sendSuccessMessage(
pluginData,
msg.channel,
`Slowmode cleared from **${args.user.username}#${args.user.discriminator}** in <#${args.channel.id}>`,
);
},
});