Merge pull request #15 from r-Overwatch2/main #18
							
								
								
									
										18
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								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
 | 
			
		||||
@@ -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`);
 | 
			
		||||
 
 | 
			
		||||
@@ -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`);
 | 
			
		||||
 
 | 
			
		||||
@@ -30,3 +30,15 @@ export function getFailedEmbed(): EmbedBuilder {
 | 
			
		||||
    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}
 | 
			
		||||
You just modified a channel on the ${guildName} server. \
 | 
			
		||||
However, your channel name (#${channelName}) contained a word that is not allowed so your channel got deleted.
 | 
			
		||||
Please make sure to keep channel names friendly for everyone!`);
 | 
			
		||||
 | 
			
		||||
    return embed;
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user