mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-11 20:55:01 +00:00
Migrate PingableRoles to new Plugin structure
This commit is contained in:
parent
f324dfc227
commit
ed344be4b5
9 changed files with 232 additions and 0 deletions
|
@ -0,0 +1,30 @@
|
|||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { pingableRolesCmd } from "../types";
|
||||
import { sendErrorMessage, sendSuccessMessage } from "src/pluginUtils";
|
||||
|
||||
export const PingableRoleDisableCmd = pingableRolesCmd({
|
||||
trigger: ["pingable_role disable", "pingable_role d"],
|
||||
permission: "can_manage",
|
||||
|
||||
signature: {
|
||||
channelId: ct.channelId(),
|
||||
role: ct.role(),
|
||||
},
|
||||
|
||||
async run({ message: msg, args, pluginData }) {
|
||||
const pingableRole = await pluginData.state.pingableRoles.getByChannelAndRoleId(args.channelId, args.role.id);
|
||||
if (!pingableRole) {
|
||||
sendErrorMessage(pluginData, msg.channel, `**${args.role.name}** is not set as pingable in <#${args.channelId}>`);
|
||||
return;
|
||||
}
|
||||
|
||||
await pluginData.state.pingableRoles.delete(args.channelId, args.role.id);
|
||||
pluginData.state.cache.delete(args.channelId);
|
||||
|
||||
sendSuccessMessage(
|
||||
pluginData,
|
||||
msg.channel,
|
||||
`**${args.role.name}** is no longer set as pingable in <#${args.channelId}>`,
|
||||
);
|
||||
},
|
||||
});
|
|
@ -0,0 +1,37 @@
|
|||
import { commandTypeHelpers as ct } from "../../../commandTypes";
|
||||
import { pingableRolesCmd } from "../types";
|
||||
import { sendErrorMessage, sendSuccessMessage } from "src/pluginUtils";
|
||||
|
||||
export const PingableRoleEnableCmd = pingableRolesCmd({
|
||||
trigger: "pingable_role",
|
||||
permission: "can_manage",
|
||||
|
||||
signature: {
|
||||
channelId: ct.channelId(),
|
||||
role: ct.role(),
|
||||
},
|
||||
|
||||
async run({ message: msg, args, pluginData }) {
|
||||
const existingPingableRole = await pluginData.state.pingableRoles.getByChannelAndRoleId(
|
||||
args.channelId,
|
||||
args.role.id,
|
||||
);
|
||||
if (existingPingableRole) {
|
||||
sendErrorMessage(
|
||||
pluginData,
|
||||
msg.channel,
|
||||
`**${args.role.name}** is already set as pingable in <#${args.channelId}>`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
await pluginData.state.pingableRoles.add(args.channelId, args.role.id);
|
||||
pluginData.state.cache.delete(args.channelId);
|
||||
|
||||
sendSuccessMessage(
|
||||
pluginData,
|
||||
msg.channel,
|
||||
`**${args.role.name}** has been set as pingable in <#${args.channelId}>`,
|
||||
);
|
||||
},
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue