automod: change_nickname action can now also take simply a string value

This commit is contained in:
Dragory 2020-08-10 01:37:20 +03:00
parent 212e50077a
commit bfa9cf55a7
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1

View file

@ -5,9 +5,12 @@ import { LogsPlugin } from "../../Logs/LogsPlugin";
import { unique } from "../../../utils";
export const ChangeNicknameAction = automodAction({
configType: t.type({
name: t.string,
}),
configType: t.union([
t.string,
t.type({
name: t.string,
}),
]),
defaultConfig: {},
@ -16,8 +19,9 @@ export const ChangeNicknameAction = automodAction({
for (const member of members) {
if (pluginData.state.recentNicknameChanges.has(member.id)) continue;
const newName = typeof actionConfig === "string" ? actionConfig : actionConfig.name;
member.edit({ nick: actionConfig.name }).catch(err => {
member.edit({ nick: newName }).catch(err => {
pluginData.getPlugin(LogsPlugin).log(LogType.BOT_ALERT, {
body: `Failed to change the nickname of \`${member.id}\``,
});