3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-21 00:35:02 +00:00
zeppelin/backend/src/plugins/CustomEvents/actions/makeRoleUnmentionableAction.ts

30 lines
824 B
TypeScript

import { GuildPluginData } from "knub";
import { CustomEventsPluginType, TCustomEvent } from "../types";
import * as t from "io-ts";
import { ActionError } from "../ActionError";
export const MakeRoleUnmentionableAction = t.type({
type: t.literal("make_role_unmentionable"),
role: t.string,
});
export type TMakeRoleUnmentionableAction = t.TypeOf<typeof MakeRoleUnmentionableAction>;
export async function makeRoleUnmentionableAction(
pluginData: GuildPluginData<CustomEventsPluginType>,
action: TMakeRoleUnmentionableAction,
values: any,
event: TCustomEvent,
eventData: any,
) {
const role = pluginData.guild.roles.get(action.role);
if (!role) {
throw new ActionError(`Unknown role: ${role}`);
}
await role.edit(
{
mentionable: false,
},
`Custom event: ${event.name}`,
);
}