mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 20:35:02 +00:00
37 lines
1 KiB
TypeScript
37 lines
1 KiB
TypeScript
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}>`,
|
|
);
|
|
},
|
|
});
|