Feature/6 add a way to view current settings #9
@ -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 `Permission: MANAGE_GUILD`
|
||||||
#### /blocklist get
|
#### /blocklist get
|
||||||
Gets the global and server specific banned word list and returns it (Same behaviour as /showblocklist)
|
Returns the global and server specific banned word list and returns it (Same behaviour as /showblocklist)
|
||||||
|
|
||||||
#### /blocklist add [word]
|
#### /blocklist add [word]
|
||||||
Adds the word to the server specific blocklist
|
Adds the word to the server specific blocklist
|
||||||
@ -25,7 +25,10 @@ Options are:
|
|||||||
- Delete setting when the bot leaves the server [default]
|
- Delete setting when the bot leaves the server [default]
|
||||||
|
|
||||||
### /showblocklist `Permission: MANAGE_CHANNELS`
|
### /showblocklist `Permission: MANAGE_CHANNELS`
|
||||||
Gets the global and server specific banned word list and returns it
|
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
|
## Environment variables
|
||||||
| Name | Description | Required | Example |
|
| Name | Description | Required | Example |
|
||||||
|
@ -3,8 +3,17 @@ import * as blocklist from "./blocklist";
|
|||||||
import * as info from "./info";
|
import * as info from "./info";
|
||||||
import * as preserveSettings from "./preserveSettings";
|
import * as preserveSettings from "./preserveSettings";
|
||||||
import * as showBlocklist from "./showblocklist";
|
import * as showBlocklist from "./showblocklist";
|
||||||
|
import * as showSettings from "./showSettings";
|
||||||
|
|
||||||
const array = [notification.builder.toJSON(), blocklist.builder.toJSON(), info.builder.toJSON(), preserveSettings.builder.toJSON(), showBlocklist.builder.toJSON()];
|
const commands = [];
|
||||||
|
commands.push(notification);
|
||||||
|
commands.push(blocklist);
|
||||||
|
commands.push(info);
|
||||||
|
commands.push(preserveSettings);
|
||||||
|
commands.push(showBlocklist);
|
||||||
|
commands.push(showSettings);
|
||||||
|
|
||||||
|
const array = commands.map((command) => command.builder.toJSON());
|
||||||
|
|
||||||
export {
|
export {
|
||||||
array
|
array
|
||||||
|
@ -4,6 +4,7 @@ import * as blocklist from "./blocklist";
|
|||||||
import * as info from "./info";
|
import * as info from "./info";
|
||||||
import * as preserveSettings from "./preserveSettings";
|
import * as preserveSettings from "./preserveSettings";
|
||||||
import * as showBlocklist from "./showblocklist";
|
import * as showBlocklist from "./showblocklist";
|
||||||
|
import * as showSettings from "./showSettings";
|
||||||
import client from "../client";
|
import client from "../client";
|
||||||
import getDefaultEmbed from "../tools/defaultEmbeds";
|
import getDefaultEmbed from "../tools/defaultEmbeds";
|
||||||
|
|
||||||
@ -13,6 +14,7 @@ commands.set(blocklist.builder.name, blocklist);
|
|||||||
commands.set(info.builder.name, info);
|
commands.set(info.builder.name, info);
|
||||||
commands.set(preserveSettings.builder.name, preserveSettings);
|
commands.set(preserveSettings.builder.name, preserveSettings);
|
||||||
commands.set(showBlocklist.builder.name, showBlocklist);
|
commands.set(showBlocklist.builder.name, showBlocklist);
|
||||||
|
commands.set(showSettings.builder.name, showSettings);
|
||||||
|
|
||||||
client.on(Events.InteractionCreate, async (interaction) => {
|
client.on(Events.InteractionCreate, async (interaction) => {
|
||||||
if (!interaction.isChatInputCommand()) return;
|
if (!interaction.isChatInputCommand()) return;
|
||||||
|
61
src/commands/showSettings.ts
Normal file
61
src/commands/showSettings.ts
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
import { ChatInputCommandInteraction, PermissionFlagsBits, SlashCommandBuilder } from "discord.js";
|
||||||
|
import { Badword, database } from "../data";
|
||||||
|
import { getGuildSetting, isPremiumActive } from "../tools/data";
|
||||||
|
import getDefaultEmbed from "../tools/defaultEmbeds";
|
||||||
|
import moment from "moment";
|
||||||
|
import { Color, Emoji } from "../tools/design";
|
||||||
|
import { getGuildChannel } from "../tools/discord";
|
||||||
|
|
||||||
|
const builder = new SlashCommandBuilder();
|
||||||
|
builder.setName("showsettings");
|
||||||
|
builder.setDescription("Show the current settings of this guild");
|
||||||
|
builder.setDMPermission(false);
|
||||||
|
builder.setDefaultMemberPermissions(PermissionFlagsBits.ManageGuild);
|
||||||
|
|
||||||
|
async function execute(interaction: ChatInputCommandInteraction): Promise<void> {
|
||||||
|
if (!interaction.inGuild()) throw new Error("Interaction was performed outside guild context");
|
||||||
|
|
||||||
|
const settings = await getGuildSetting(interaction.guildId);
|
||||||
|
const isPremium = await isPremiumActive(settings.isPremiumUntil);
|
||||||
|
const wordCount = await database.getRepository(Badword).count({
|
||||||
|
where: {
|
||||||
|
guildID: interaction.guildId
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const logChannel = settings.notificationChannelID ? await getGuildChannel(interaction.guildId, settings.notificationChannelID) : null;
|
||||||
|
|
||||||
|
const embed = getDefaultEmbed();
|
||||||
|
embed.setTitle(`Settings from guild ${interaction.guild?.name || ""} (${interaction.guildId})`);
|
||||||
|
embed.setDescription(isPremium ? `${Emoji.PREMIUM} your subscription ends in ${moment(settings.isPremiumUntil).fromNow(true)}` : `Consider Premium status to get an increased blocklist`);
|
||||||
|
embed.setColor(Color.INFORMING_BLUE);
|
||||||
|
embed.addFields({
|
||||||
|
name: "Premium",
|
||||||
|
value: isPremium ? `${Emoji.PREMIUM} active` : `${Emoji.SWITCH_OFF} inactive`,
|
||||||
|
inline: true
|
||||||
|
}, {
|
||||||
|
name: "Logchannel",
|
||||||
|
value: logChannel && logChannel.isTextBased() ? `<#${logChannel.id}>` : "Not configured",
|
||||||
|
inline: true
|
||||||
|
}, {
|
||||||
|
name: "Words in Blocklist",
|
||||||
|
value: `${wordCount}/${isPremium ? "100" : "10"}`,
|
||||||
|
inline: true
|
||||||
|
}, {
|
||||||
|
name: `Preserve data on server leave is ${settings.preserveDataOnGuildLeave ? "active" : "inactive"}`,
|
||||||
|
value: settings.preserveDataOnGuildLeave ? "Your settings will be saved even if the bot gets kicked" : "Your settings will be deleted as soon as the bot leaves this server"
|
||||||
|
}, {
|
||||||
|
name: `${Emoji.WAVING} Found a bug? Want to request a feature? Say hello?`,
|
||||||
|
value: "Join the support server at https://go.astrogd.eu/discord"
|
||||||
|
});
|
||||||
|
|
||||||
|
interaction.reply({
|
||||||
|
embeds: [embed],
|
||||||
|
ephemeral: true
|
||||||
|
}).catch();
|
||||||
|
}
|
||||||
|
|
||||||
|
export {
|
||||||
|
builder,
|
||||||
|
execute
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user