automod: change_nickname action can now also take simply a string value
This commit is contained in:
parent
212e50077a
commit
bfa9cf55a7
1 changed files with 8 additions and 4 deletions
|
@ -5,9 +5,12 @@ import { LogsPlugin } from "../../Logs/LogsPlugin";
|
||||||
import { unique } from "../../../utils";
|
import { unique } from "../../../utils";
|
||||||
|
|
||||||
export const ChangeNicknameAction = automodAction({
|
export const ChangeNicknameAction = automodAction({
|
||||||
configType: t.type({
|
configType: t.union([
|
||||||
|
t.string,
|
||||||
|
t.type({
|
||||||
name: t.string,
|
name: t.string,
|
||||||
}),
|
}),
|
||||||
|
]),
|
||||||
|
|
||||||
defaultConfig: {},
|
defaultConfig: {},
|
||||||
|
|
||||||
|
@ -16,8 +19,9 @@ export const ChangeNicknameAction = automodAction({
|
||||||
|
|
||||||
for (const member of members) {
|
for (const member of members) {
|
||||||
if (pluginData.state.recentNicknameChanges.has(member.id)) continue;
|
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, {
|
pluginData.getPlugin(LogsPlugin).log(LogType.BOT_ALERT, {
|
||||||
body: `Failed to change the nickname of \`${member.id}\``,
|
body: `Failed to change the nickname of \`${member.id}\``,
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue