Compare commits
13 Commits
1.0.0-alph
...
1.0.0-beta
Author | SHA1 | Date | |
---|---|---|---|
11845cae42 | |||
d853fa55d3
|
|||
88834703ef
|
|||
9cbb7799e9 | |||
005b9bd69c
|
|||
21812157f8
|
|||
52a349c1b9
|
|||
6242c09e4b | |||
24d39d471e
|
|||
545bda9bee
|
|||
966625bac4
|
|||
fb2e3c4f11 | |||
c8ed870fec |
20
Changelog.md
Normal file
20
Changelog.md
Normal file
@ -0,0 +1,20 @@
|
||||
# Changelog
|
||||
This file is used to list changes made to this software.
|
||||
|
||||
## V1.0.0 [`unreleased`]
|
||||
_Current development version: **1.0.0-beta.3**_
|
||||
### Features
|
||||
- /info
|
||||
- /logchannel
|
||||
- /blocklist get
|
||||
- /blocklist add
|
||||
- /blocklist remove
|
||||
- /preservesettings
|
||||
- /showblocklist
|
||||
- /showsettings
|
||||
- Data will be deleted by default when the bot leaves the server
|
||||
- Server admins can change the behaviour of the bot when it leaves the server to keep the data persistent
|
||||
- Scans for blocked words in channel names and renames channels to "CENSORED" if found
|
||||
- When settings are changed or channels are censored, notifications to a logchannel can be enabled
|
||||
- CLI to change settings and get information during runtime by attaching to the apps docker container
|
||||
- API for automated uptime checks to prevent the bot from going offline unnoticed
|
16
README.md
16
README.md
@ -2,12 +2,12 @@
|
||||
A Discord bot that checks Discord channel names for banned words and prevents renaming of them
|
||||
|
||||
## Commands
|
||||
### /logchanel [channel?]
|
||||
### /logchanel [channel?] `Permission: MANAGE_GUILD`
|
||||
Sets the channel where the bot will log if a channel meets the banned word criteria. If channel is omitted, the log channel will be disabled.
|
||||
|
||||
### /blocklist
|
||||
### /blocklist `Permission: MANAGE_GUILD`
|
||||
#### /blocklist get
|
||||
Gets the global and server specific banned word list and returns it
|
||||
Returns the global and server specific banned word list and returns it (Same behaviour as /showblocklist)
|
||||
|
||||
#### /blocklist add [word]
|
||||
Adds the word to the server specific blocklist
|
||||
@ -15,15 +15,21 @@ Adds the word to the server specific blocklist
|
||||
#### /blocklist remove [word]
|
||||
Removes the word from the server specific blocklist
|
||||
|
||||
### /info
|
||||
### /info `Permission: EVERYONE`
|
||||
Returns general information about the bot and the servers stats
|
||||
|
||||
### /preservesettings
|
||||
### /preservesettings `Permission: ADMINISTRATOR`
|
||||
Changes the behaviour when the bot leaves the server.
|
||||
Options are:
|
||||
- Keep settings persistent even if the bot leaves
|
||||
- Delete setting when the bot leaves the server [default]
|
||||
|
||||
### /showblocklist `Permission: MANAGE_CHANNELS`
|
||||
Returns the global and server specific banned word list and returns it
|
||||
|
||||
### /showsettings `Permission: MANAGE_GUILD`
|
||||
Returns the current settings for the server
|
||||
|
||||
## Environment variables
|
||||
| Name | Description | Required | Example |
|
||||
| :--------------- | :------------------------------------------------------------------------------ | :------: | :------------------ |
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "eu.astrogd.white-leopard",
|
||||
"version": "1.0.0-alpha.6",
|
||||
"version": "1.0.0-beta.3",
|
||||
"description": "A Discord bot that checks channel names for blacklisted words and reverts the changes if necessary",
|
||||
"main": "build/index.js",
|
||||
"scripts": {
|
||||
|
@ -5,6 +5,7 @@ import { getGuildSetting, isPremiumActive } from "../tools/data";
|
||||
import getDefaultEmbed, { getFailedEmbed, getSuccessEmbed } from "../tools/defaultEmbeds";
|
||||
import { getGuildChannel } from "../tools/discord";
|
||||
import { Color, Emoji } from "../tools/design";
|
||||
import { execute as showBlocklistRunner } from "./showblocklist";
|
||||
|
||||
const builder = new SlashCommandBuilder();
|
||||
builder.setName("blocklist");
|
||||
@ -51,24 +52,7 @@ async function execute(interaction: ChatInputCommandInteraction): Promise<void>
|
||||
|
||||
switch (interaction.options.getSubcommand(true)) {
|
||||
case "get": {
|
||||
const guildBadWords = await database.getRepository(Badword).find({
|
||||
select: {
|
||||
value: true
|
||||
},
|
||||
where: {
|
||||
guildID: interaction.guildId
|
||||
}
|
||||
});
|
||||
const globalBadWords = await database.getRepository(Badword).find({
|
||||
where: {
|
||||
guildID: IsNull()
|
||||
}
|
||||
});
|
||||
|
||||
interaction.reply({
|
||||
content: `\`\`\`Global bad word list\`\`\`\n||${globalBadWords.map((word) => word.value).reduce((prev, next) => prev + ", " + next, "").slice(2)} ||\n\`\`\`Local server bad word list (${guildBadWords.length}/${isPremium ? 100 : 10})\`\`\`\n||${guildBadWords.map((word) => word.value).reduce((prev, next) => prev + ", " + next, "").slice(2)} ||`,
|
||||
ephemeral: true
|
||||
}).catch();
|
||||
await showBlocklistRunner(interaction);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,19 @@
|
||||
import * as notification from "./notification";
|
||||
import * as notification from "./logchannel";
|
||||
import * as blocklist from "./blocklist";
|
||||
import * as info from "./info";
|
||||
import * as preserveSettings from "./preserveSettings";
|
||||
import * as showBlocklist from "./showblocklist";
|
||||
import * as showSettings from "./showSettings";
|
||||
|
||||
const array = [notification.builder.toJSON(), blocklist.builder.toJSON(), info.builder.toJSON(), preserveSettings.builder.toJSON()];
|
||||
const commands = [];
|
||||
commands.push(notification);
|
||||
commands.push(blocklist);
|
||||
commands.push(info);
|
||||
commands.push(preserveSettings);
|
||||
commands.push(showBlocklist);
|
||||
commands.push(showSettings);
|
||||
|
||||
const array = commands.map((command) => command.builder.toJSON());
|
||||
|
||||
export {
|
||||
array
|
||||
|
@ -1,8 +1,10 @@
|
||||
import { ChatInputCommandInteraction, Collection, Events, SlashCommandBuilder } from "discord.js";
|
||||
import * as notification from "./notification";
|
||||
import * as notification from "./logchannel";
|
||||
import * as blocklist from "./blocklist";
|
||||
import * as info from "./info";
|
||||
import * as preserveSettings from "./preserveSettings";
|
||||
import * as showBlocklist from "./showblocklist";
|
||||
import * as showSettings from "./showSettings";
|
||||
import client from "../client";
|
||||
import getDefaultEmbed from "../tools/defaultEmbeds";
|
||||
|
||||
@ -11,6 +13,8 @@ commands.set(notification.builder.name, notification);
|
||||
commands.set(blocklist.builder.name, blocklist);
|
||||
commands.set(info.builder.name, info);
|
||||
commands.set(preserveSettings.builder.name, preserveSettings);
|
||||
commands.set(showBlocklist.builder.name, showBlocklist);
|
||||
commands.set(showSettings.builder.name, showSettings);
|
||||
|
||||
client.on(Events.InteractionCreate, async (interaction) => {
|
||||
if (!interaction.isChatInputCommand()) return;
|
||||
|
@ -9,7 +9,7 @@ const builder = new SlashCommandBuilder();
|
||||
builder.setName("logchannel");
|
||||
builder.setDescription("Configures the log channel");
|
||||
builder.setDMPermission(false);
|
||||
builder.setDefaultMemberPermissions(PermissionFlagsBits.ManageChannels);
|
||||
builder.setDefaultMemberPermissions(PermissionFlagsBits.ManageGuild);
|
||||
builder.addChannelOption((option) => {
|
||||
option.addChannelTypes(ChannelType.GuildText, ChannelType.GuildAnnouncement);
|
||||
option.setName("channel");
|
61
src/commands/showSettings.ts
Normal file
61
src/commands/showSettings.ts
Normal file
@ -0,0 +1,61 @@
|
||||
import { ChatInputCommandInteraction, PermissionFlagsBits, SlashCommandBuilder } from "discord.js";
|
||||
import { Badword, database } from "../data";
|
||||
import { getGuildSetting, isPremiumActive } from "../tools/data";
|
||||
import getDefaultEmbed from "../tools/defaultEmbeds";
|
||||
import moment from "moment";
|
||||
import { Color, Emoji } from "../tools/design";
|
||||
import { getGuildChannel } from "../tools/discord";
|
||||
|
||||
const builder = new SlashCommandBuilder();
|
||||
builder.setName("showsettings");
|
||||
builder.setDescription("Show the current settings of this guild");
|
||||
builder.setDMPermission(false);
|
||||
builder.setDefaultMemberPermissions(PermissionFlagsBits.ManageGuild);
|
||||
|
||||
async function execute(interaction: ChatInputCommandInteraction): Promise<void> {
|
||||
if (!interaction.inGuild()) throw new Error("Interaction was performed outside guild context");
|
||||
|
||||
const settings = await getGuildSetting(interaction.guildId);
|
||||
const isPremium = await isPremiumActive(settings.isPremiumUntil);
|
||||
const wordCount = await database.getRepository(Badword).count({
|
||||
where: {
|
||||
guildID: interaction.guildId
|
||||
}
|
||||
});
|
||||
|
||||
const logChannel = settings.notificationChannelID ? await getGuildChannel(interaction.guildId, settings.notificationChannelID) : null;
|
||||
|
||||
const embed = getDefaultEmbed();
|
||||
embed.setTitle(`Settings from guild ${interaction.guild?.name || ""} (${interaction.guildId})`);
|
||||
embed.setDescription(isPremium ? `${Emoji.PREMIUM} your subscription ends in ${moment(settings.isPremiumUntil).fromNow(true)}` : `Consider Premium status to get an increased blocklist`);
|
||||
embed.setColor(isPremium ? Color.PREMIUM_ORANGE : Color.INFORMING_BLUE);
|
||||
embed.addFields({
|
||||
name: "Premium",
|
||||
value: isPremium ? `${Emoji.PREMIUM} active` : `${Emoji.SWITCH_OFF} inactive`,
|
||||
inline: true
|
||||
}, {
|
||||
name: "Logchannel",
|
||||
value: logChannel && logChannel.isTextBased() ? `<#${logChannel.id}>` : "Not configured",
|
||||
inline: true
|
||||
}, {
|
||||
name: "Words in Blocklist",
|
||||
value: `${wordCount}/${isPremium ? "100" : "10"}`,
|
||||
inline: true
|
||||
}, {
|
||||
name: `Preserve data on server leave is ${settings.preserveDataOnGuildLeave ? "active" : "inactive"}`,
|
||||
value: settings.preserveDataOnGuildLeave ? "Your settings will be saved even if the bot gets kicked" : "Your settings will be deleted as soon as the bot leaves this server"
|
||||
}, {
|
||||
name: `${Emoji.WAVING} Found a bug? Want to request a feature? Say hello?`,
|
||||
value: "Join the support server at https://go.astrogd.eu/discord"
|
||||
});
|
||||
|
||||
interaction.reply({
|
||||
embeds: [embed],
|
||||
ephemeral: true
|
||||
}).catch();
|
||||
}
|
||||
|
||||
export {
|
||||
builder,
|
||||
execute
|
||||
}
|
41
src/commands/showblocklist.ts
Normal file
41
src/commands/showblocklist.ts
Normal file
@ -0,0 +1,41 @@
|
||||
import { ChatInputCommandInteraction, PermissionFlagsBits, SlashCommandBuilder } from "discord.js";
|
||||
import { IsNull } from "typeorm";
|
||||
import { Badword, database } from "../data";
|
||||
import { getGuildSetting, isPremiumActive } from "../tools/data";
|
||||
|
||||
const builder = new SlashCommandBuilder();
|
||||
builder.setName("showblocklist");
|
||||
builder.setDescription("Shows the blocklist of this server");
|
||||
builder.setDMPermission(false);
|
||||
builder.setDefaultMemberPermissions(PermissionFlagsBits.ManageChannels);
|
||||
|
||||
async function execute(interaction: ChatInputCommandInteraction): Promise<void> {
|
||||
if (!interaction.inGuild()) throw new Error("Command was executed outside guild context");
|
||||
|
||||
const settings = await getGuildSetting(interaction.guildId);
|
||||
const isPremium = isPremiumActive(settings.isPremiumUntil);
|
||||
|
||||
const guildBadWords = await database.getRepository(Badword).find({
|
||||
select: {
|
||||
value: true
|
||||
},
|
||||
where: {
|
||||
guildID: interaction.guildId
|
||||
}
|
||||
});
|
||||
const globalBadWords = await database.getRepository(Badword).find({
|
||||
where: {
|
||||
guildID: IsNull()
|
||||
}
|
||||
});
|
||||
|
||||
interaction.reply({
|
||||
content: `\`\`\`Global bad word list\`\`\`\n||${globalBadWords.map((word) => word.value).reduce((prev, next) => prev + ", " + next, "").slice(2)} ||\n\`\`\`Local server bad word list (${guildBadWords.length}/${isPremium ? 100 : 10})\`\`\`\n||${guildBadWords.map((word) => word.value).reduce((prev, next) => prev + ", " + next, "").slice(2)} ||`,
|
||||
ephemeral: true
|
||||
}).catch();
|
||||
}
|
||||
|
||||
export {
|
||||
builder,
|
||||
execute
|
||||
}
|
Reference in New Issue
Block a user