Remove some now unused blacklist functionality
This commit is contained in:
parent
3111c35b98
commit
adcf1b73cf
2 changed files with 262 additions and 328 deletions
|
@ -9,351 +9,285 @@ import { checkMessageForFilteredWords } from "../../modules/antispam";
|
||||||
import { DEFAULT_PREFIX } from "../../modules/command_handler";
|
import { DEFAULT_PREFIX } from "../../modules/command_handler";
|
||||||
import { embed, EmbedColor, getDmChannel, isBotManager, NO_MANAGER_MSG, sanitizeMessageContent } from "../../util";
|
import { embed, EmbedColor, getDmChannel, isBotManager, NO_MANAGER_MSG, sanitizeMessageContent } from "../../util";
|
||||||
|
|
||||||
const WORDLIST_DEFAULT_MESSAGE = '<@{{user_id}}>, the message you sent contained a blocked word.';
|
const WORDLIST_DEFAULT_MESSAGE = "<@{{user_id}}>, the message you sent contained a blocked word.";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'botctl',
|
name: "botctl",
|
||||||
aliases: null,
|
aliases: null,
|
||||||
description: 'Perform administrative actions',
|
description: "Perform administrative actions",
|
||||||
category: CommandCategory.Config,
|
category: CommandCategory.Config,
|
||||||
run: async (message: MessageCommandContext, args: string[]) => {
|
run: async (message: MessageCommandContext, args: string[]) => {
|
||||||
if (!await isBotManager(message)) return message.reply(NO_MANAGER_MSG);
|
if (!(await isBotManager(message))) return message.reply(NO_MANAGER_MSG);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let action = args.shift();
|
let action = args.shift();
|
||||||
switch(action) {
|
switch (action) {
|
||||||
case 'ignore_blacklist': {
|
case "spam_detection": {
|
||||||
if (args[0] == 'yes') {
|
if (args[0] == "on") {
|
||||||
if (message.serverContext.discoverable) {
|
await dbs.SERVERS.update({ id: message.serverContext.id }, { $set: { antispamEnabled: true } });
|
||||||
return message.reply('Your server is currently listed in server discovery. As part of Revolt\'s [Discover Guidelines](<https://support.revolt.chat/kb/safety/discover-guidelines>), all servers on Discover are enrolled to AutoMod\'s antispam features.');
|
await message.reply("Spam detection is now enabled in this server.\n" + "Please make sure AutoMod has permission to Manage Messages");
|
||||||
}
|
} else if (args[0] == "off") {
|
||||||
|
if (message.serverContext.discoverable) {
|
||||||
|
return message.reply(
|
||||||
|
"Your server is currently listed in server discovery. As part of Revolt's [Discover Guidelines](<https://support.revolt.chat/kb/safety/discover-guidelines>), all servers on Discover are enrolled to AutoMod's antispam features.",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
await dbs.SERVERS.update({ id: message.serverContext.id }, { $set: { allowBlacklistedUsers: true } });
|
await dbs.SERVERS.update({ id: message.serverContext.id }, { $set: { antispamEnabled: false } });
|
||||||
await message.reply('Globally blacklisted users will no longer get banned in this server. Previously banned users will need to be unbanned manually.');
|
await message.reply("Spam detection is now disabled in this server.");
|
||||||
} else if (args[0] == 'no') {
|
} else {
|
||||||
await dbs.SERVERS.update({ id: message.serverContext.id }, { $set: { allowBlacklistedUsers: false } });
|
const cfg = await dbs.SERVERS.findOne({ id: message.serverContext.id });
|
||||||
await message.reply('Globally blacklisted users will now get banned in this server.');
|
await message.reply(`Spam detection is currently **${cfg?.antispamEnabled ? "enabled" : "disabled"}**. ` + `Please specify either 'on' or 'off' to toggle this setting.`);
|
||||||
} else {
|
}
|
||||||
await message.reply(`Please specify either 'yes' or 'no' to toggle this setting.`);
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'spam_detection': {
|
|
||||||
if (args[0] == 'on') {
|
|
||||||
await dbs.SERVERS.update({ id: message.serverContext.id }, { $set: { antispamEnabled: true } });
|
|
||||||
await message.reply('Spam detection is now enabled in this server.\nIf a user is wrongfully kicked '
|
|
||||||
+ 'or banned, please report it here: https://rvlt.gg/jan\n\n'
|
|
||||||
+ 'Please make sure to grant AutoMod permission to **Kick**, **Ban** and **Manage Messages**!');
|
|
||||||
} else if (args[0] == 'off') {
|
|
||||||
if (message.serverContext.discoverable) {
|
|
||||||
return message.reply('Your server is currently listed in server discovery. As part of Revolt\'s [Discover Guidelines](<https://support.revolt.chat/kb/safety/discover-guidelines>), all servers on Discover are enrolled to AutoMod\'s antispam features.');
|
|
||||||
}
|
|
||||||
|
|
||||||
await dbs.SERVERS.update({ id: message.serverContext.id }, { $set: { antispamEnabled: false } });
|
case "logs": {
|
||||||
await message.reply('Spam detection is now disabled in this server.');
|
if (!args[0]) {
|
||||||
|
return await message.reply(`No category specified. Syntax: ${DEFAULT_PREFIX}botctl logs [category] [#channel]\n` + `Categories: \`messageupdate\`, \`modaction\``);
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
if (!args[1]) {
|
||||||
const cfg = await dbs.SERVERS.findOne({ id: message.serverContext.id });
|
return await message.reply("No target channel specified.");
|
||||||
await message.reply(`Spam detection is currently **${cfg?.antispamEnabled ? 'enabled' : 'disabled'}**. `
|
}
|
||||||
+ `Please specify either 'on' or 'off' to toggle this setting.`);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'logs': {
|
let channelInput = args[1];
|
||||||
if (!args[0]) {
|
if (channelInput.startsWith("<#") && channelInput.endsWith(">")) {
|
||||||
return await message.reply(
|
channelInput = channelInput.substring(2, channelInput.length - 1);
|
||||||
`No category specified. Syntax: ${DEFAULT_PREFIX}botctl logs [category] [#channel]\n` +
|
}
|
||||||
`Categories: \`messageupdate\`, \`modaction\``,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!args[1]) {
|
const channel = client.channels.get(channelInput);
|
||||||
return await message.reply('No target channel specified.');
|
if (!channel) return message.reply("I can't find that channel.");
|
||||||
}
|
if (channel.serverId != message.channel?.serverId) return message.reply("That channel is not part of this server!");
|
||||||
|
if (!channel.havePermission("SendMessage")) return message.reply("I don't have permission to **send messages** in that channel.");
|
||||||
|
if (!channel.havePermission("SendEmbeds")) return message.reply("I don't have permission to **send embeds** in that channel.");
|
||||||
|
|
||||||
let channelInput = args[1];
|
switch (args[0]?.toLowerCase()) {
|
||||||
if (channelInput.startsWith('<#') && channelInput.endsWith('>')) {
|
case "messageupdate": {
|
||||||
channelInput = channelInput.substring(2, channelInput.length - 1);
|
await dbs.SERVERS.update(
|
||||||
}
|
{ id: message.channel!.serverId! },
|
||||||
|
{
|
||||||
|
$set: {
|
||||||
|
"logs.messageUpdate.revolt": {
|
||||||
|
channel: channel.id,
|
||||||
|
type: "EMBED",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
$setOnInsert: {
|
||||||
|
id: message.channel!.serverId!,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ upsert: true },
|
||||||
|
);
|
||||||
|
await message.reply(`Bound message update logs to <#${channel.id}>!`);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
const channel = client.channels.get(channelInput);
|
case "modaction": {
|
||||||
if (!channel) return message.reply('I can\'t find that channel.');
|
await dbs.SERVERS.update(
|
||||||
if (channel.serverId != message.channel?.serverId) return message.reply('That channel is not part of this server!');
|
{ id: message.channel!.serverId! },
|
||||||
if (!channel.havePermission('SendMessage')) return message.reply('I don\'t have permission to **send messages** in that channel.');
|
{
|
||||||
if (!channel.havePermission('SendEmbeds')) return message.reply('I don\'t have permission to **send embeds** in that channel.');
|
$set: {
|
||||||
|
"logs.modAction.revolt": {
|
||||||
|
channel: channel.id,
|
||||||
|
type: "EMBED",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
$setOnInsert: {
|
||||||
|
id: message.channel!.serverId!,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ upsert: true },
|
||||||
|
);
|
||||||
|
await message.reply(`Bound moderation logs to <#${channel.id}>!`);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
switch(args[0]?.toLowerCase()) {
|
default: {
|
||||||
case 'messageupdate': {
|
return await message.reply("Unknown log category");
|
||||||
await dbs.SERVERS.update(
|
}
|
||||||
{ id: message.channel!.serverId! },
|
}
|
||||||
{
|
break;
|
||||||
$set: {
|
}
|
||||||
'logs.messageUpdate.revolt': {
|
|
||||||
channel: channel.id,
|
|
||||||
type: 'EMBED',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
$setOnInsert: {
|
|
||||||
id: message.channel!.serverId!,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{ upsert: true },
|
|
||||||
);
|
|
||||||
await message.reply(`Bound message update logs to <#${channel.id}>!`);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'modaction': {
|
case "filter": {
|
||||||
await dbs.SERVERS.update(
|
const config = await dbs.SERVERS.findOne({ id: message.channel!.serverId! });
|
||||||
{ id: message.channel!.serverId! },
|
switch (args.shift()?.toLowerCase()) {
|
||||||
{
|
case "enable": {
|
||||||
$set: {
|
await dbs.SERVERS.update({ id: message.channel!.serverId! }, { $set: { wordlistEnabled: true } }, { upsert: true });
|
||||||
'logs.modAction.revolt': {
|
await message.reply({ embeds: [embed(`### Word filter enabled!\nThere are currently ${config?.wordlist?.length ?? 0} words on your list.`, null, EmbedColor.Success)] });
|
||||||
channel: channel.id,
|
break;
|
||||||
type: 'EMBED',
|
}
|
||||||
},
|
case "disable": {
|
||||||
},
|
await dbs.SERVERS.update({ id: message.channel!.serverId! }, { $set: { wordlistEnabled: false } }, { upsert: true });
|
||||||
$setOnInsert: {
|
await message.reply({ embeds: [embed("Word filter disabled.", null, EmbedColor.SoftError)] });
|
||||||
id: message.channel!.serverId!,
|
break;
|
||||||
}
|
}
|
||||||
},
|
case "add": {
|
||||||
{ upsert: true },
|
let strictness: any = "HARD";
|
||||||
);
|
if (["soft", "hard", "strict"].includes(args[0].toLowerCase())) {
|
||||||
await message.reply(`Bound moderation logs to <#${channel.id}>!`);
|
strictness = args.shift()!.toUpperCase() as any;
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
default: {
|
const word = args.join(" ").toLowerCase();
|
||||||
return await message.reply('Unknown log category');
|
if (!word) return message.reply("You didn't provide a word to add to the list!");
|
||||||
}
|
if (config?.wordlist?.find((w) => w.word == word)) return await message.reply("That word is already on the list!");
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'filter': {
|
await dbs.SERVERS.update({ id: message.channel!.serverId! }, { $push: { wordlist: { strictness, word } } }, { upsert: true });
|
||||||
const config = await dbs.SERVERS.findOne({ id: message.channel!.serverId! });
|
await message.reply({ embeds: [embed(`Word added with strictness **${strictness}**.`, null, EmbedColor.Success)] });
|
||||||
switch(args.shift()?.toLowerCase()) {
|
break;
|
||||||
case 'enable': {
|
}
|
||||||
await dbs.SERVERS.update(
|
case "remove": {
|
||||||
{ id: message.channel!.serverId! },
|
const word = args.join(" ").toLowerCase();
|
||||||
{ $set: { wordlistEnabled: true } },
|
if (!word) return message.reply("You need to provide the word to remove from the list.");
|
||||||
{ upsert: true },
|
|
||||||
);
|
|
||||||
await message.reply({ embeds: [
|
|
||||||
embed(
|
|
||||||
`### Word filter enabled!\nThere are currently ${config?.wordlist?.length ?? 0} words on your list.`,
|
|
||||||
null,
|
|
||||||
EmbedColor.Success
|
|
||||||
),
|
|
||||||
] });
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'disable': {
|
|
||||||
await dbs.SERVERS.update(
|
|
||||||
{ id: message.channel!.serverId! },
|
|
||||||
{ $set: { wordlistEnabled: false } },
|
|
||||||
{ upsert: true },
|
|
||||||
);
|
|
||||||
await message.reply({ embeds: [
|
|
||||||
embed('Word filter disabled.', null, EmbedColor.SoftError),
|
|
||||||
] });
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'add': {
|
|
||||||
let strictness: any = 'HARD';
|
|
||||||
if (['soft', 'hard', 'strict'].includes(args[0].toLowerCase())) {
|
|
||||||
strictness = args.shift()!.toUpperCase() as any;
|
|
||||||
}
|
|
||||||
|
|
||||||
const word = args.join(' ').toLowerCase();
|
if (!config?.wordlist?.find((w) => w.word == word)) return await message.reply("That word is not on the list.");
|
||||||
if (!word) return message.reply('You didn\'t provide a word to add to the list!');
|
await dbs.SERVERS.update({ id: message.channel!.serverId! }, { $pull: { wordlist: { word } } }, { upsert: true });
|
||||||
if (config?.wordlist?.find(w => w.word == word)) return await message.reply('That word is already on the list!');
|
await message.reply({ embeds: [embed(`Word removed.`, null, EmbedColor.Success)] });
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "show": {
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append(`wordlist_${message.channel?.serverId}`, config?.wordlist?.map((w) => `${w.strictness}\t${w.word}`).join("\n") ?? "", `wordlist_${message.channel?.serverId}.txt`);
|
||||||
|
|
||||||
await dbs.SERVERS.update(
|
try {
|
||||||
{ id: message.channel!.serverId! },
|
const channel = await getDmChannel(message.authorId!);
|
||||||
{ $push: { wordlist: { strictness, word } } },
|
const res = await axios.post(`${client.configuration?.features.autumn.url}/attachments`, formData, { headers: formData.getHeaders(), responseType: "json" });
|
||||||
{ upsert: true },
|
await channel.sendMessage({
|
||||||
);
|
attachments: [(res.data as any).id],
|
||||||
await message.reply({ embeds: [
|
embeds: [embed(`Here's the current word list for **${message.channel?.server?.name}**.`, "Word List", EmbedColor.Success)],
|
||||||
embed(`Word added with strictness **${strictness}**.`, null, EmbedColor.Success),
|
});
|
||||||
] });
|
await message.reply({ embeds: [embed(`I have sent the current word list to your direct messages!`, null, EmbedColor.Success)] });
|
||||||
break;
|
} catch (e) {
|
||||||
}
|
console.error(e);
|
||||||
case 'remove': {
|
}
|
||||||
const word = args.join(' ').toLowerCase();
|
break;
|
||||||
if (!word) return message.reply('You need to provide the word to remove from the list.');
|
}
|
||||||
|
case "message": {
|
||||||
|
const msg = args.join(" ");
|
||||||
|
if (!msg) {
|
||||||
|
return await message.reply({
|
||||||
|
embeds: [
|
||||||
|
embed(
|
||||||
|
"This command lets you change the message the bot will send if a message is filtered.\n" +
|
||||||
|
"Note that this message will not be sent if the configured action is to log events only.\n" +
|
||||||
|
"The current message is:\n" +
|
||||||
|
`>${sanitizeMessageContent(config?.wordlistAction?.message ?? WORDLIST_DEFAULT_MESSAGE)
|
||||||
|
.trim()
|
||||||
|
.replace(/\n/g, "\n>")}\n` +
|
||||||
|
"`{{user_id}}` will be substituted for the target user's ID.",
|
||||||
|
"Warning message",
|
||||||
|
EmbedColor.Success,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (!config?.wordlist?.find(w => w.word == word)) return await message.reply('That word is not on the list.');
|
await dbs.SERVERS.update({ id: message.channel!.serverId! }, { $set: { wordlistAction: { action: config?.wordlistAction?.action ?? "LOG", message: msg } } }, { upsert: true });
|
||||||
await dbs.SERVERS.update(
|
await message.reply({ embeds: [embed("Filter message set!", null, EmbedColor.Success)] });
|
||||||
{ id: message.channel!.serverId! },
|
break;
|
||||||
{ $pull: { wordlist: { word } } },
|
}
|
||||||
{ upsert: true },
|
case "action": {
|
||||||
);
|
let action: string;
|
||||||
await message.reply({ embeds: [
|
switch (args[0]?.toLowerCase()) {
|
||||||
embed(`Word removed.`, null, EmbedColor.Success),
|
case "log":
|
||||||
] });
|
case "delete":
|
||||||
break;
|
case "warn":
|
||||||
}
|
action = args[0].toUpperCase();
|
||||||
case 'show': {
|
break;
|
||||||
const formData = new FormData();
|
default:
|
||||||
formData.append(
|
await message.reply({
|
||||||
`wordlist_${message.channel?.serverId}`,
|
embeds: [
|
||||||
config?.wordlist?.map(w => `${w.strictness}\t${w.word}`).join('\n') ?? '',
|
embed(
|
||||||
`wordlist_${message.channel?.serverId}.txt`
|
"Please provide one of the following arguments:\n" +
|
||||||
);
|
"- **log** (Log the message in mod action log channel)\n" +
|
||||||
|
"- **delete** (Log and delete the message)\n" +
|
||||||
|
"- **warn** (Log and delete message, warn user)\n\n" +
|
||||||
|
`The currently configured action is **${config?.wordlistAction?.action ?? "LOG"}**.`,
|
||||||
|
null,
|
||||||
|
EmbedColor.SoftError,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
await dbs.SERVERS.update(
|
||||||
const channel = await getDmChannel(message.authorId!);
|
{ id: message.channel!.serverId! },
|
||||||
const res = await axios.post(
|
{
|
||||||
`${client.configuration?.features.autumn.url}/attachments`,
|
$set: {
|
||||||
formData,
|
wordlistAction: {
|
||||||
{ headers: formData.getHeaders(), responseType: 'json' }
|
action: action as any,
|
||||||
);
|
message: config?.wordlistAction?.message ?? WORDLIST_DEFAULT_MESSAGE,
|
||||||
await channel.sendMessage({
|
},
|
||||||
attachments: [ (res.data as any).id ],
|
},
|
||||||
embeds: [ embed(
|
},
|
||||||
`Here's the current word list for **${message.channel?.server?.name}**.`,
|
{ upsert: true },
|
||||||
'Word List',
|
);
|
||||||
EmbedColor.Success
|
await message.reply({
|
||||||
) ],
|
embeds: [embed(`Filter action set to **${action}**. ` + `Please make sure you configured a logging channel using **${DEFAULT_PREFIX}botctl logs**.`, null, EmbedColor.Success)],
|
||||||
});
|
});
|
||||||
await message.reply({ embeds: [
|
break;
|
||||||
embed(`I have sent the current word list to your direct messages!`, null, EmbedColor.Success),
|
}
|
||||||
] });
|
case "test": {
|
||||||
} catch(e) {
|
const match = checkMessageForFilteredWords(args.join(" "), config as ServerConfig);
|
||||||
console.error(e);
|
await message.reply({
|
||||||
}
|
embeds: [
|
||||||
break;
|
match
|
||||||
}
|
? embed("Your word list matches this test phrase!", "Filter Test", EmbedColor.SoftError)
|
||||||
case 'message': {
|
: embed("Your word list does not match this test phrase!", "Filter Test", EmbedColor.Success),
|
||||||
const msg = args.join(' ');
|
],
|
||||||
if (!msg) {
|
});
|
||||||
return await message.reply({ embeds: [
|
break;
|
||||||
embed(
|
}
|
||||||
'This command lets you change the message the bot will send if a message is filtered.\n' +
|
default: {
|
||||||
'Note that this message will not be sent if the configured action is to log events only.\n' +
|
await message.reply({
|
||||||
'The current message is:\n' +
|
embeds: [
|
||||||
`>${sanitizeMessageContent(config?.wordlistAction?.message ?? WORDLIST_DEFAULT_MESSAGE).trim().replace(/\n/g, '\n>')}\n` +
|
embed(
|
||||||
'`{{user_id}}` will be substituted for the target user\'s ID.',
|
`### This command allows you to configure a manual word filter.\n` +
|
||||||
'Warning message',
|
`- **${DEFAULT_PREFIX}botctl filter enable** - Enable the word filter.\n` +
|
||||||
EmbedColor.Success
|
`- **${DEFAULT_PREFIX}botctl filter disable** - Disable the word filter.\n` +
|
||||||
),
|
`- **${DEFAULT_PREFIX}botctl filter add [soft|hard|strict] [word]** - Add a word to the list. If omitted, defaults to 'hard'.\n` +
|
||||||
] });
|
`- **${DEFAULT_PREFIX}botctl filter remove** - Remove a word from the list.\n` +
|
||||||
}
|
`- **${DEFAULT_PREFIX}botctl filter show** - Send the current filter list.\n` +
|
||||||
|
`- **${DEFAULT_PREFIX}botctl filter message [message]** - Set the message sent when a message is matched.\n` +
|
||||||
|
`- **${DEFAULT_PREFIX}botctl filter action [log|delete|warn]** - Configure the action taken on filtered messages.\n` +
|
||||||
|
`- **${DEFAULT_PREFIX}botctl filter test [phrase]** - Test whether a phrase matches your word list.\n` +
|
||||||
|
`More documentation can be found [here](https://github.com/sussycatgirl/automod/wiki/Word-Filter).`,
|
||||||
|
"Word filter",
|
||||||
|
),
|
||||||
|
embed(
|
||||||
|
`**Enabled:** ${!!config?.wordlistEnabled}` +
|
||||||
|
(!config?.wordlistEnabled
|
||||||
|
? ""
|
||||||
|
: `\n**Action:** ${config?.wordlistAction?.action ?? "LOG"}\n` +
|
||||||
|
`**Warning message:** ${config?.wordlistAction?.message}\n` +
|
||||||
|
`**Wordlist length:** ${config?.wordlist?.length ?? 0}`),
|
||||||
|
"Current configuration",
|
||||||
|
config?.wordlistEnabled ? EmbedColor.Success : EmbedColor.SoftError,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
await dbs.SERVERS.update(
|
case undefined:
|
||||||
{ id: message.channel!.serverId! },
|
case "":
|
||||||
{ $set: { wordlistAction: { action: config?.wordlistAction?.action ?? 'LOG', message: msg } } },
|
message.reply(
|
||||||
{ upsert: true },
|
`### Available subcommands\n` + `- \`spam_detection\` - Toggle automatic spam detection.\n` + `- \`logs\` - Configure log channels.\n` + `- \`filter\` - Configure word filter.\n`,
|
||||||
);
|
);
|
||||||
await message.reply({ embeds: [
|
break;
|
||||||
embed(
|
default:
|
||||||
'Filter message set!',
|
message.reply(`Unknown option`);
|
||||||
null,
|
}
|
||||||
EmbedColor.Success
|
} catch (e) {
|
||||||
),
|
console.error("" + e);
|
||||||
] });
|
message.reply("Something went wrong: " + e);
|
||||||
break;
|
}
|
||||||
}
|
},
|
||||||
case 'action': {
|
|
||||||
let action: string;
|
|
||||||
switch(args[0]?.toLowerCase()) {
|
|
||||||
case 'log':
|
|
||||||
case 'delete':
|
|
||||||
case 'warn':
|
|
||||||
action = args[0].toUpperCase();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
await message.reply({ embeds: [
|
|
||||||
embed(
|
|
||||||
'Please provide one of the following arguments:\n' +
|
|
||||||
'- **log** (Log the message in mod action log channel)\n' +
|
|
||||||
'- **delete** (Log and delete the message)\n' +
|
|
||||||
'- **warn** (Log and delete message, warn user)\n\n' +
|
|
||||||
`The currently configured action is **${config?.wordlistAction?.action ?? 'LOG'}**.`,
|
|
||||||
null,
|
|
||||||
EmbedColor.SoftError
|
|
||||||
),
|
|
||||||
] });
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await dbs.SERVERS.update(
|
|
||||||
{ id: message.channel!.serverId! },
|
|
||||||
{ $set: { wordlistAction: {
|
|
||||||
action: action as any,
|
|
||||||
message: config?.wordlistAction?.message ?? WORDLIST_DEFAULT_MESSAGE
|
|
||||||
} } },
|
|
||||||
{ upsert: true },
|
|
||||||
);
|
|
||||||
await message.reply({ embeds: [
|
|
||||||
embed(
|
|
||||||
`Filter action set to **${action}**. ` +
|
|
||||||
`Please make sure you configured a logging channel using **${DEFAULT_PREFIX}botctl logs**.`,
|
|
||||||
null,
|
|
||||||
EmbedColor.Success
|
|
||||||
),
|
|
||||||
] });
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'test': {
|
|
||||||
const match = checkMessageForFilteredWords(args.join(' '), config as ServerConfig);
|
|
||||||
await message.reply({ embeds: [
|
|
||||||
match
|
|
||||||
? embed('Your word list matches this test phrase!', 'Filter Test', EmbedColor.SoftError)
|
|
||||||
: embed('Your word list does not match this test phrase!', 'Filter Test', EmbedColor.Success)
|
|
||||||
] });
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
await message.reply({ embeds: [
|
|
||||||
embed(
|
|
||||||
`### This command allows you to configure a manual word filter.\n` +
|
|
||||||
`- **${DEFAULT_PREFIX}botctl filter enable** - Enable the word filter.\n` +
|
|
||||||
`- **${DEFAULT_PREFIX}botctl filter disable** - Disable the word filter.\n` +
|
|
||||||
`- **${DEFAULT_PREFIX}botctl filter add [soft|hard|strict] [word]** - Add a word to the list. If omitted, defaults to 'hard'.\n` +
|
|
||||||
`- **${DEFAULT_PREFIX}botctl filter remove** - Remove a word from the list.\n` +
|
|
||||||
`- **${DEFAULT_PREFIX}botctl filter show** - Send the current filter list.\n` +
|
|
||||||
`- **${DEFAULT_PREFIX}botctl filter message [message]** - Set the message sent when a message is matched.\n` +
|
|
||||||
`- **${DEFAULT_PREFIX}botctl filter action [log|delete|warn]** - Configure the action taken on filtered messages.\n` +
|
|
||||||
`- **${DEFAULT_PREFIX}botctl filter test [phrase]** - Test whether a phrase matches your word list.\n` +
|
|
||||||
`More documentation can be found [here](https://github.com/sussycatgirl/automod/wiki/Word-Filter).`,
|
|
||||||
'Word filter',
|
|
||||||
),
|
|
||||||
embed(
|
|
||||||
`**Enabled:** ${!!config?.wordlistEnabled}` + (!config?.wordlistEnabled
|
|
||||||
? ''
|
|
||||||
: `\n**Action:** ${config?.wordlistAction?.action ?? 'LOG'}\n` +
|
|
||||||
`**Warning message:** ${config?.wordlistAction?.message}\n` +
|
|
||||||
`**Wordlist length:** ${config?.wordlist?.length ?? 0}`),
|
|
||||||
'Current configuration',
|
|
||||||
config?.wordlistEnabled ? EmbedColor.Success : EmbedColor.SoftError,
|
|
||||||
),
|
|
||||||
] });
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case undefined:
|
|
||||||
case '':
|
|
||||||
message.reply(`### Available subcommands\n`
|
|
||||||
+ `- \`ignore_blacklist\` - Ignore the bot's global blacklist.\n`
|
|
||||||
+ `- \`spam_detection\` - Toggle automatic spam detection.\n`
|
|
||||||
+ `- \`logs\` - Configure log channels.\n`
|
|
||||||
+ `- \`filter\` - Configure word filter.\n`);
|
|
||||||
break
|
|
||||||
default:
|
|
||||||
message.reply(`Unknown option`);
|
|
||||||
}
|
|
||||||
} catch(e) {
|
|
||||||
console.error(''+e);
|
|
||||||
message.reply('Something went wrong: ' + e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} as SimpleCommand;
|
} as SimpleCommand;
|
||||||
|
|
||||||
export { WORDLIST_DEFAULT_MESSAGE }
|
export { WORDLIST_DEFAULT_MESSAGE };
|
||||||
|
|
|
@ -23,7 +23,7 @@ const categories: {
|
||||||
[CommandCategory.Owner]: {
|
[CommandCategory.Owner]: {
|
||||||
friendlyName: "Owner",
|
friendlyName: "Owner",
|
||||||
description: "Owner-only commands for managing AutoMod",
|
description: "Owner-only commands for managing AutoMod",
|
||||||
aliases: [ "owner" ],
|
aliases: ["owner"],
|
||||||
},
|
},
|
||||||
[CommandCategory.Miscellaneous]: {
|
[CommandCategory.Miscellaneous]: {
|
||||||
friendlyName: "Miscellaneous",
|
friendlyName: "Miscellaneous",
|
||||||
|
|
Loading…
Reference in a new issue