diff --git a/Changelog.md b/Changelog.md index 7b98e9b..41cff22 100644 --- a/Changelog.md +++ b/Changelog.md @@ -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 diff --git a/README.md b/README.md index ff0c8a5..a5020d2 100644 --- a/README.md +++ b/README.md @@ -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 \ No newline at end of file +- 🚀 = Required during CI/CD diff --git a/package-lock.json b/package-lock.json index d1f9097..b13cafd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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", diff --git a/package.json b/package.json index a22723b..377f149 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/src/events/channelCreate.ts b/src/events/channelCreate.ts index 0549c36..15a4d5a 100644 --- a/src/events/channelCreate.ts +++ b/src/events/channelCreate.ts @@ -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`); diff --git a/src/events/channelUpdate.ts b/src/events/channelUpdate.ts index 9e297b2..99edb57 100644 --- a/src/events/channelUpdate.ts +++ b/src/events/channelUpdate.ts @@ -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`); diff --git a/src/tools/defaultEmbeds.ts b/src/tools/defaultEmbeds.ts index 0b8c1b2..b213bb5 100644 --- a/src/tools/defaultEmbeds.ts +++ b/src/tools/defaultEmbeds.ts @@ -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; } \ No newline at end of file