Merge pull request #18 from r-Overwatch2/release/1.1.0

This commit is contained in:
Lukas | AstroGD 2022-11-29 21:37:08 +01:00 committed by GitHub
commit f528d107da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 59 additions and 10 deletions

View File

@ -1,9 +1,19 @@
# Changelog
This file is used to list changes made to this software.
## V1.0.0 [2022-11-29]
_Current development version: **1.0.0**_
_Current development release: 1.1.0_
## V1.1.0 [2022-11-29]
### Features
- If a channel gets deleted and the responsible user has been detected, a message will be sent to that user informing him of the deletion
## V1.0.0 [2022-11-29]
### Features
- /info
- /logchannel
- /blocklist get

View File

@ -1,40 +1,53 @@
# eu.astrogd.white-leopard
A Discord bot that checks Discord channel names for banned words and prevents renaming of them
## Commands
### /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 `Permission: MANAGE_GUILD`
#### /blocklist get
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
#### /blocklist remove [word]
Removes the word from the server specific blocklist
### /info `Permission: EVERYONE`
Returns general information about the bot and the servers stats
### /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 |
| :--------------- | :------------------------------------------------------------------------------ | :------: | :------------------ |
| TOKEN | Discord bot token to log into the API with | ▶️/🚀 | NzYzMDP3MzE1Mzky... |
| DB_HOST | Hostname of the database | ▶️ | 127.0.0.1:3546 |
| DB_HOST | Hostname of the database | ▶️ | 127.0.0.1 |
| DB_USERNAME | Username of the database | ▶️ | root |
| DB_PASSWORD | Password of the database | ▶️ | abc123 |
| DB_DATABASE | Database name | ▶️ | white-leopard |
@ -42,6 +55,7 @@ Returns the current settings for the server
| DEPLOY_TOKEN | Production Discord bot token to log into the API with | 🚀 | NzYzMDP3MzE1Mzky... |
| DEPLOY_CLIENT_ID | Production Client ID of the Discord appication associated with the deploy token | 🚀 | 763035392692274 |
### Icon explanation:
### Icon explanation
- ▶️ = Required in runtime
- 🚀 = Required during CI/CD
- 🚀 = Required during CI/CD

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "eu.astrogd.white-leopard",
"version": "1.0.0",
"version": "1.1.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "eu.astrogd.white-leopard",
"version": "1.0.0",
"version": "1.1.0",
"license": "CC-BY-NC-ND-4.0",
"dependencies": {
"discord.js": "^14.6.0",

View File

@ -1,6 +1,6 @@
{
"name": "eu.astrogd.white-leopard",
"version": "1.0.0",
"version": "1.1.0",
"description": "A Discord bot that checks channel names for blacklisted words and reverts the changes if necessary",
"main": "build/index.js",
"scripts": {

View File

@ -3,7 +3,7 @@ import { AuditLogEvent, Events, GuildAuditLogsEntry, PermissionFlagsBits, User }
import { getGuildSetting } from "../tools/data";
import { Badword, database } from "../data";
import { IsNull } from "typeorm";
import getDefaultEmbed, { getFailedEmbed } from "../tools/defaultEmbeds";
import getDefaultEmbed, { getFailedEmbed, getUserReportEmbed } from "../tools/defaultEmbeds";
import { getGuildChannel } from "../tools/discord";
import { Color, Emoji } from "../tools/design";
@ -89,6 +89,13 @@ client.on(Events.ChannelCreate, async (newChannel) => {
return;
}
if (responsibleUser) {
const embed = getUserReportEmbed(guild.name, newChannel.name);
responsibleUser.send({
embeds: [embed]
}).catch(() => {});
}
if (!logChannel || !logChannel.isTextBased()) return;
const embed = getDefaultEmbed();
embed.setTitle(`${Emoji.SECURITY_CHALLENGE_FAILED} Blocked word detected`);

View File

@ -3,7 +3,7 @@ import { AuditLogEvent, Events, GuildAuditLogsEntry, PermissionFlagsBits, User }
import { getGuildSetting } from "../tools/data";
import { Badword, database } from "../data";
import { IsNull } from "typeorm";
import getDefaultEmbed, { getFailedEmbed } from "../tools/defaultEmbeds";
import getDefaultEmbed, { getFailedEmbed, getUserReportEmbed } from "../tools/defaultEmbeds";
import { getGuildChannel } from "../tools/discord";
import { Color, Emoji } from "../tools/design";
@ -89,6 +89,13 @@ client.on(Events.ChannelUpdate, async (oldChannel, newChannel) => {
return;
}
if (responsibleUser) {
const embed = getUserReportEmbed(guild.name, newChannel.name);
responsibleUser.send({
embeds: [embed]
}).catch(() => {});
}
if (!logChannel || !logChannel.isTextBased()) return;
const embed = getDefaultEmbed();
embed.setTitle(`${Emoji.SECURITY_CHALLENGE_FAILED} Blocked word detected`);

View File

@ -28,5 +28,16 @@ export function getFailedEmbed(): EmbedBuilder {
const embed = getDefaultEmbed();
embed.setTitle(`${Emoji.CHAT_DENY} Failed`);
embed.setColor(Color.STOPSIGN_RED);
return embed;
}
export function getUserReportEmbed(guildName: string, channelName: string): EmbedBuilder {
const embed = getDefaultEmbed();
embed.setColor(Color.STOPSIGN_RED);
embed.setTitle(`${Emoji.SECURITY_CHALLENGE_FAILED} A channel you modified has been deleted`);
embed.setDescription(`Hey there ${Emoji.WAVING}
Your channel (#${channelName}) on the "${guildName}" server contained a blacklisted word and was deleted automatically.
Please make sure to keep channel names friendly for everyone!`);
return embed;
}