From 42c56db858068cad0b9231d55495b101de39916f Mon Sep 17 00:00:00 2001 From: metal Date: Thu, 9 Dec 2021 16:20:10 +0000 Subject: [PATCH] fix typings UwU --- backend/src/plugins/Automod/actions/changePerms.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/backend/src/plugins/Automod/actions/changePerms.ts b/backend/src/plugins/Automod/actions/changePerms.ts index 53d54e04..5d8afdb6 100644 --- a/backend/src/plugins/Automod/actions/changePerms.ts +++ b/backend/src/plugins/Automod/actions/changePerms.ts @@ -1,17 +1,20 @@ import { Permissions, PermissionString } from "discord.js"; import * as t from "io-ts"; import { automodAction } from "../helpers"; -import { tNullable, isValidSnowflake } from "../../../utils"; +import { tNullable, isValidSnowflake, tPartialDictionary } from "../../../utils"; import { noop } from "knub/dist/utils"; export const ChangePermsAction = automodAction({ configType: t.type({ target: t.string, channel: tNullable(t.string), - perms: t.record(t.keyof(Permissions.FLAGS), t.union([t.boolean, t.null])), + perms: tPartialDictionary(t.keyof(Permissions.FLAGS), tNullable(t.boolean)), }), defaultConfig: { channel: "", + perms: { + SEND_MESSAGES: true, + }, }, async apply({ pluginData, contexts, actionConfig, ruleName }) { @@ -50,7 +53,7 @@ export const ChangePermsAction = automodAction({ for (const key in actionConfig.perms) { perms[key] = actionConfig.perms[key]; } - const permsArray: PermissionString[] = Object.keys(perms).filter((key) => perms[key]); + const permsArray = Object.keys(perms).filter((key) => perms[key]); await role.setPermissions(new Permissions(permsArray)).catch(noop); }, });