Release/1.0.0 beta.3 #10
@ -7,7 +7,7 @@ Sets the channel where the bot will log if a channel meets the banned word crite
|
||||
|
||||
### /blocklist `Permission: MANAGE_GUILD`
|
||||
#### /blocklist get
|
||||
Gets the global and server specific banned word list and returns it
|
||||
Gets 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
|
||||
@ -24,6 +24,9 @@ Options are:
|
||||
- Keep settings persistent even if the bot leaves
|
||||
- Delete setting when the bot leaves the server [default]
|
||||
|
||||
### /showblocklist `Permission: MANAGE_CHANNELS`
|
||||
Gets the global and server specific banned word list and returns it
|
||||
|
||||
## Environment variables
|
||||
| Name | Description | Required | Example |
|
||||
| :--------------- | :------------------------------------------------------------------------------ | :------: | :------------------ |
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -2,8 +2,9 @@ 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";
|
||||
|
||||
const array = [notification.builder.toJSON(), blocklist.builder.toJSON(), info.builder.toJSON(), preserveSettings.builder.toJSON()];
|
||||
const array = [notification.builder.toJSON(), blocklist.builder.toJSON(), info.builder.toJSON(), preserveSettings.builder.toJSON(), showBlocklist.builder.toJSON()];
|
||||
|
||||
export {
|
||||
array
|
||||
|
@ -3,6 +3,7 @@ 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 client from "../client";
|
||||
import getDefaultEmbed from "../tools/defaultEmbeds";
|
||||
|
||||
@ -11,6 +12,7 @@ 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);
|
||||
|
||||
client.on(Events.InteractionCreate, async (interaction) => {
|
||||
if (!interaction.isChatInputCommand()) return;
|
||||
|
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
|
||||
}
|
Loading…
Reference in New Issue
Block a user