This commit is contained in:
2022-11-24 16:25:20 +01:00
parent a26fb2df12
commit def44d2774
8 changed files with 113 additions and 13 deletions

View File

@ -4,6 +4,7 @@ import { IsNull } from "typeorm";
import { getGuildSetting, isPremiumActive } from "../tools/data";
import getDefaultEmbed, { getFailedEmbed, getSuccessEmbed } from "../tools/defaultEmbeds";
import { getGuildChannel } from "../tools/discord";
import { Color, Emoji } from "../tools/design";
const builder = new SlashCommandBuilder();
builder.setName("blocklist");
@ -81,7 +82,7 @@ async function execute(interaction: ChatInputCommandInteraction): Promise<void>
const limit = isPremium ? 100 : 10;
if (count >= limit) {
const embed = getFailedEmbed();
embed.setDescription("You reached the word limit for your guild. Please delete a word before adding a new one");
embed.setDescription(`You reached the word limit for your guild. Please delete a word before adding a new one`);
interaction.reply({
embeds: [embed],
ephemeral: true
@ -122,7 +123,8 @@ async function execute(interaction: ChatInputCommandInteraction): Promise<void>
});
const logMessage = getDefaultEmbed();
logMessage.setTitle("Word added");
logMessage.setTitle(`${Emoji.SETTINGS} Word added`);
logMessage.setColor(Color.INFORMING_BLUE);
logMessage.setDescription(`"||${word}||" has been added to the blocklist`);
logMessage.addFields({
name: "This action was performed by",
@ -168,7 +170,8 @@ async function execute(interaction: ChatInputCommandInteraction): Promise<void>
}).catch();
const logMessage = getDefaultEmbed();
logMessage.setTitle("Word removed");
logMessage.setTitle(`${Emoji.SETTINGS} Word removed`);
logMessage.setColor(Color.INFORMING_BLUE);
logMessage.setDescription(`"||${word}||" has been removed from the blocklist`);
logMessage.addFields({
name: "This action was performed by",

View File

@ -1,7 +1,8 @@
import * as notification from "./notification";
import * as blocklist from "./blocklist";
import * as info from "./info";
const array = [notification.builder.toJSON(), blocklist.builder.toJSON()];
const array = [notification.builder.toJSON(), blocklist.builder.toJSON(), info.builder.toJSON()];
export {
array

View File

@ -1,12 +1,14 @@
import { ChatInputCommandInteraction, Collection, Events, SlashCommandBuilder } from "discord.js";
import * as notification from "./notification";
import * as blocklist from "./blocklist";
import * as info from "./info";
import client from "../client";
import getDefaultEmbed from "../tools/defaultEmbeds";
const commands = new Collection<string, { builder: SlashCommandBuilder, execute: (interaction: ChatInputCommandInteraction) => Promise<void> }>();
commands.set(notification.builder.name, notification);
commands.set(blocklist.builder.name, blocklist);
commands.set(info.builder.name, info);
client.on(Events.InteractionCreate, async (interaction) => {
if (!interaction.isChatInputCommand()) return;

66
src/commands/info.ts Normal file
View File

@ -0,0 +1,66 @@
import { ChatInputCommandInteraction, SlashCommandBuilder } from "discord.js";
import { IsNull } from "typeorm";
import { Badword, database } from "../data";
import { getGuildSetting, isPremiumActive } from "../tools/data";
import getDefaultEmbed from "../tools/defaultEmbeds";
import pack from "../../package.json";
import { Color, Emoji } from "../tools/design";
const builder = new SlashCommandBuilder();
builder.setName("info");
builder.setDescription("Shows information about this bot and the server settings");
builder.setDMPermission(false);
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 globalBlockedWordsCount = await database.getRepository(Badword).count({
where: {
guildID: IsNull()
}
});
const localBlockedWordsCount = await database.getRepository(Badword).count({
where: {
guildID: interaction.guildId
}
});
const embed = getDefaultEmbed();
embed.setTitle(`${Emoji.SECURITY_CHALLENGE} Channel filter V${pack.version} by AstroGD®`);
embed.setDescription(`Codename eu.astrogd.white-leopard`);
embed.setColor(isPremium ? Color.PREMIUM_ORANGE : Color.INFORMING_BLUE);
embed.addFields({
name: "What does this bot do?",
value: "This bot checks for blocked words contained in channel names and reverts the changes if found."
},{
name: "Author",
value: `This bot was created by AstroGD#0001 ${Emoji.ASTROGD} mainly for the official r/Overwatch2 Subreddit Discord server`
},{
name: "Server status",
value: `${isPremium ? Emoji.PREMIUM : Emoji.SWITCH_OFF} Premium features are ${isPremium ? "enabled" : "disabled"} on this server`,
inline: true
},{
name: "Global word count",
value: globalBlockedWordsCount.toString(),
inline: true
},{
name: "Local word count",
value: localBlockedWordsCount.toString(),
inline: true
},{
name: `${Emoji.WAVING} Have a question or want to say hello?`,
value: "Join the support Discord server at https://go.astrogd.eu/discord"
});
interaction.reply({
embeds: [embed],
ephemeral: true
}).catch();
}
export {
builder,
execute
}