updated /nucleus suggest to be nice, fixed help, added needs saving to footer for automod settings.
diff --git a/src/commands/nucleus/stats.ts b/src/commands/nucleus/stats.ts
index b2658bc..c2bf9a1 100644
--- a/src/commands/nucleus/stats.ts
+++ b/src/commands/nucleus/stats.ts
@@ -21,6 +21,54 @@
const command = (builder: SlashCommandSubcommandBuilder) =>
builder.setName("stats").setDescription("Gets the bot's stats");
+
+const confirm = async (interaction: CommandInteraction) => {
+ const requiredTexts = [
+ "just do it",
+ "yes, do as i say!",
+ "clicksminuteper/nucleus",
+ "i've said it once i'll say it again",
+ "no, i've changed my mind",
+ "this incident will be reported",
+ "coded told me to",
+ "mini told me to",
+ "pinea told me to",
+ "what's a java script",
+ "it's a feature not a bug",
+ "that never happened during testing"
+ ]
+ const chosen = requiredTexts[Math.floor(Math.random() * (requiredTexts.length - 1))]!;
+
+ const modal = new ModalBuilder()
+ .addComponents(
+ new ActionRowBuilder<TextInputBuilder>().addComponents(
+ new TextInputBuilder()
+ .setStyle(TextInputStyle.Short)
+ .setLabel(`Type "${chosen}" below`)
+ .setCustomId("confirm")
+ .setPlaceholder("Guild ID")
+ .setMinLength(chosen.length)
+ .setMaxLength(chosen.length)
+ )
+ )
+ .setTitle("Admin Panel")
+ .setCustomId("adminPanel");
+ await interaction.showModal(modal);
+ let out: ModalSubmitInteraction;
+ try {
+ out = await interaction.awaitModalSubmit({
+ filter: (i) => i.customId === "adminPanel" && i.user.id === interaction.user.id,
+ time: 300000
+ });
+ } catch {
+ return;
+ }
+ await out.deferUpdate();
+ const typed = out.fields.getTextInputValue("confirm");
+ return typed.toLowerCase() === chosen.toLowerCase()
+}
+
+
const callback = async (interaction: CommandInteraction): Promise<void> => {
const description = `**Servers:** ${client.guilds.cache.size}\n` + `**Ping:** \`${client.ws.ping * 2}ms\``;
const m = await interaction.reply({
@@ -45,11 +93,7 @@
],
components: [
new ActionRowBuilder<ButtonBuilder>().addComponents(
- new ButtonBuilder().setCustomId("admin").setLabel("Admin Panel").setStyle(ButtonStyle.Primary),
- new ButtonBuilder()
- .setCustomId("mod:nickname:599498449733550102")
- .setLabel("Testing")
- .setStyle(ButtonStyle.Primary)
+ new ButtonBuilder().setCustomId("admin").setLabel("Admin Panel").setStyle(ButtonStyle.Primary)
)
]
});
@@ -77,28 +121,30 @@
return;
// console.log(interaction)
if (!("awaitMessageComponent" in channel)) return;
- try {
- i1 = await channel!.awaitMessageComponent<ComponentType.Button>({
- filter: (i) => i.customId === "admin" && i.user.id === interaction.user.id && i.message.id === m.id,
- time: 300000
- });
- } catch (e) {
- console.log(e);
- return;
- }
- await i1.showModal(modal);
- let out: ModalSubmitInteraction;
- try {
- out = await i1.awaitModalSubmit({
- filter: (i) => i.customId === "adminPanel" && i.user.id === interaction.user.id,
- time: 300000
- });
- } catch {
- return;
- }
- await out.deferUpdate();
- const GuildID = out.fields.getTextInputValue("guildID");
- if (!client.guilds.cache.has(GuildID)) {
+ let GuildID = interaction.guildId;
+ if (!GuildID) {
+ try {
+ i1 = await channel!.awaitMessageComponent<ComponentType.Button>({
+ filter: (i) => i.customId === "admin" && i.user.id === interaction.user.id && i.message.id === m.id,
+ time: 300000
+ });
+ } catch (e) {
+ console.log(e);
+ return;
+ }
+ await i1.showModal(modal);
+ let out: ModalSubmitInteraction;
+ try {
+ out = await i1.awaitModalSubmit({
+ filter: (i) => i.customId === "adminPanel" && i.user.id === interaction.user.id,
+ time: 300000
+ });
+ } catch {
+ return;
+ }
+ await out.deferUpdate();
+ GuildID = out.fields.getTextInputValue("guildID");
+ } else if (!client.guilds.cache.has(GuildID)) {
await interaction.editReply({
embeds: [new EmojiEmbed().setTitle("Admin").setDescription("Not in server").setStatus("Danger")],
components: []
@@ -110,10 +156,10 @@
components: [
new ActionRowBuilder<ButtonBuilder>().addComponents(
new ButtonBuilder().setCustomId("stats").setLabel("Stats").setStyle(ButtonStyle.Primary),
- new ButtonBuilder().setCustomId("leave").setLabel("Leave").setStyle(ButtonStyle.Danger),
new ButtonBuilder().setCustomId("data").setLabel("Guild data").setStyle(ButtonStyle.Secondary),
+ new ButtonBuilder().setCustomId("cache").setLabel("Reset cache").setStyle(ButtonStyle.Success),
+ new ButtonBuilder().setCustomId("leave").setLabel("Leave").setStyle(ButtonStyle.Danger),
new ButtonBuilder().setCustomId("purge").setLabel("Delete data").setStyle(ButtonStyle.Danger),
- new ButtonBuilder().setCustomId("cache").setLabel("Reset cache").setStyle(ButtonStyle.Success)
)
]
});
@@ -126,9 +172,9 @@
} catch {
return;
}
- await i.deferUpdate();
const guild = (await client.guilds.fetch(GuildID)) as Guild | null;
if (!guild) {
+ await i.deferUpdate();
await interaction.editReply({
embeds: [new EmojiEmbed().setTitle("Admin").setDescription("Not in server").setStatus("Danger")],
components: []
@@ -136,66 +182,91 @@
return;
}
if (i.customId === "stats") {
+ await i.deferUpdate();
await interaction.editReply({
embeds: [
new EmojiEmbed()
- .setTitle("Stats")
- .setDescription(
- `**Name:** ${guild.name}\n` +
- `**ID:** \`${guild.id}\`\n` +
- `**Owner:** ${client.users.cache.get(guild.ownerId)!.tag}\n` +
- `**Member Count:** ${guild.memberCount}\n` +
- `**Created:** <t:${guild.createdTimestamp}:F>\n` +
- `**Added Nucleus:** <t:${guild.members.me!.joinedTimestamp}:R>\n` +
- `**Nucleus' Perms:** https://discordapi.com/permissions.html#${guild.members.me!.permissions.valueOf()}\n`
+ .setTitle("Stats")
+ .setDescription(
+ `**Name:** ${guild.name}\n` +
+ `**ID:** \`${guild.id}\`\n` +
+ `**Owner:** ${client.users.cache.get(guild.ownerId)!.tag}\n` +
+ `**Member Count:** ${guild.memberCount}\n` +
+ `**Created:** <t:${guild.createdTimestamp}:F>\n` +
+ `**Added Nucleus:** <t:${guild.members.me!.joinedTimestamp}:R>\n` +
+ `**Nucleus' Perms:** https://discordapi.com/permissions.html#${guild.members.me!.permissions.valueOf()}\n`
)
.setStatus("Success")
.setEmoji("SETTINGS.STATS.GREEN")
- ]
- });
- } else if (i.customId === "leave") {
- await guild.leave();
- await interaction.editReply({
- embeds: [
- new EmojiEmbed()
+ ]
+ });
+ } else if (i.customId === "leave") {
+ if (!await confirm(interaction)) {
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("No changes were made")
+ .setStatus("Danger")
+ ],
+ components: []
+ });
+ return;
+ }
+ await guild.leave();
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
.setTitle("Left")
.setDescription(`Left ${guild.name}`)
.setStatus("Success")
.setEmoji("SETTINGS.STATS.GREEN")
- ],
- components: []
- });
- } else if (i.customId === "data") {
- // Get all the data and convert to a string
- const data = await client.database.guilds.read(guild.id);
- const stringified = JSON.stringify(data, null, 2);
- const buffer = Buffer.from(stringified);
- const attachment = new AttachmentBuilder(buffer).setName("data.json");
- await interaction.editReply({
- embeds: [
- new EmojiEmbed().setTitle("Data").setDescription(`Data for ${guild.name}`).setStatus("Success")
- ],
- components: [],
- files: [attachment]
- });
- } else if (i.customId === "purge") {
- await client.database.guilds.delete(GuildID);
- await client.database.history.delete(GuildID);
- await client.database.notes.delete(GuildID);
- await client.database.transcripts.deleteAll(GuildID);
- await interaction.editReply({
- embeds: [
- new EmojiEmbed()
+ ],
+ components: []
+ });
+ } else if (i.customId === "data") {
+ await i.deferUpdate();
+ // Get all the data and convert to a string
+ const data = await client.database.guilds.read(guild.id);
+ const stringified = JSON.stringify(data, null, 2);
+ const buffer = Buffer.from(stringified);
+ const attachment = new AttachmentBuilder(buffer).setName("data.json");
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed().setTitle("Data").setDescription(`Data for ${guild.name}`).setStatus("Success")
+ ],
+ components: [],
+ files: [attachment]
+ });
+ } else if (i.customId === "purge") {
+ if (!await confirm(interaction)) {
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("No changes were made")
+ .setStatus("Danger")
+ ],
+ components: []
+ });
+ return;
+ }
+ await client.database.guilds.delete(GuildID);
+ await client.database.history.delete(GuildID);
+ await client.database.notes.delete(GuildID);
+ await client.database.transcripts.deleteAll(GuildID);
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
.setTitle("Purge")
.setDescription(`Deleted data for ${guild.name}`)
.setStatus("Success")
.setEmoji("SETTINGS.STATS.GREEN")
- ],
- components: []
- });
- } else if (i.customId === "cache") {
- await client.memory.forceUpdate(guild.id);
- await interaction.editReply({
+ ],
+ components: []
+ });
+ } else if (i.customId === "cache") {
+ await i.deferUpdate();
+ await client.memory.forceUpdate(guild.id);
+ await interaction.editReply({
embeds: [
new EmojiEmbed()
.setTitle("Cache")
diff --git a/src/commands/nucleus/suggest.ts b/src/commands/nucleus/suggest.ts
index 79a0673..44926c7 100644
--- a/src/commands/nucleus/suggest.ts
+++ b/src/commands/nucleus/suggest.ts
@@ -1,64 +1,115 @@
import { LoadingEmbed } from "../../utils/defaults.js";
-import { ButtonStyle, CommandInteraction } from "discord.js";
-import Discord from "discord.js";
+import Discord, { ActionRowBuilder, ButtonBuilder, ButtonStyle, CommandInteraction, ModalBuilder, TextInputBuilder, TextInputStyle } from "discord.js";
import type { SlashCommandSubcommandBuilder } from "discord.js";
import confirmationMessage from "../../utils/confirmationMessage.js";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import client from "../../utils/client.js";
-import getEmojiByName from "../../utils/getEmojiByName.js";
+import config from "../../config/main.js"
+import _ from "lodash";
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
.setName("suggest")
.setDescription("Sends a suggestion to the developers")
- .addStringOption((option) =>
- option.setName("suggestion").setDescription("The suggestion to send").setRequired(true)
- );
const callback = async (interaction: CommandInteraction): Promise<void> => {
await interaction.guild?.members.fetch(interaction.member!.user.id);
- const { renderUser } = client.logger;
- const suggestion = interaction.options.get("suggestion")?.value as string;
await interaction.reply({ embeds: LoadingEmbed, ephemeral: true });
- const confirmation = await new confirmationMessage(interaction)
- .setEmoji("ICONS.OPP.ADD")
- .setTitle("Suggest")
- .setDescription(
- `**Suggestion:**\n> ${suggestion}\n` +
- "Your username and ID will also be sent with your suggestion.\n\nAre you sure you want to send this suggestion?"
- )
- .setColor("Danger")
- .setInverted(true)
- .setFailedMessage("Your suggestion was deleted", "Success", "ICONS.ADD")
- .send(true);
- if (confirmation.cancelled || !confirmation.success) return;
- await (client.channels.cache.get("955161206459600976") as Discord.TextChannel).send({
+ let closed = false;
+ let suggestionTitle: string | null = null
+ let suggestionDesc: string | null = null;
+ do {
+ const modal = new ModalBuilder()
+ .setTitle("Suggestion")
+ .setComponents(
+ new ActionRowBuilder<TextInputBuilder>()
+ .addComponents(
+ new TextInputBuilder()
+ .setLabel("Suggestion Title")
+ .setRequired(false)
+ .setStyle(TextInputStyle.Short)
+ .setCustomId("suggestionTitle")
+ .setPlaceholder("Summarize your suggestion in 1 sentence...")
+ .setMaxLength(256)
+ ),
+ new ActionRowBuilder<TextInputBuilder>()
+ .addComponents(
+ new TextInputBuilder()
+ .setLabel("Suggestion Description")
+ .setCustomId("suggestionDesc")
+ .setStyle(TextInputStyle.Paragraph)
+ .setRequired(true)
+ .setPlaceholder("Put the full details of your suggestion here...")
+ .setMinLength(50)
+ ),
+ )
+ const o: {suggestionDesc?: string, suggestionTitle?: string} = {};
+ if(suggestionTitle) {
+ o.suggestionTitle = suggestionTitle;
+ modal.components[0]!.components[0]!.setValue(suggestionTitle);
+ }
+ if(suggestionDesc) {
+ o.suggestionDesc = suggestionDesc
+ modal.components[1]!.components[0]!.setValue(suggestionDesc);
+ };
+ const confirmation = await new confirmationMessage(interaction)
+ .setEmoji("ICONS.ADD")
+ .setTitle("Suggest")
+ .setDescription(suggestionDesc ? (`Are you sure you want to send this suggestion?\n\n**Title ${suggestionTitle ? "" : "(*Placeholder*)"}:**\n> ${suggestionTitle ? suggestionTitle : `${suggestionDesc.substring(0, 70)}`}\n\n**Suggestion:**\n> ${suggestionDesc}`) : "Please enter your suggestion below.")
+ .addModal("Edit Suggestion", "ICONS.EDIT", "editSuggestion", _.cloneDeep(o), modal)
+ .setColor("Success")
+ .setInverted(true)
+ .setFailedMessage("Your suggestion was deleted", "Success", "ICONS.ADD")
+ .send(true);
+ if(confirmation.modals?.[0] && !_.isEqual(confirmation.modals[0].values, o)) {
+ suggestionTitle = confirmation.modals[0].values["suggestionTitle"] as string | null;
+ suggestionDesc = confirmation.modals[0].values["suggestionDesc"] as string | null;
+ continue;
+ }
+ if(confirmation.cancelled || confirmation.success === false) {
+ closed = true;
+ return;
+ }
+ if (confirmation.success) {
+ closed = true;
+ };
+ } while (!closed);
+ if(!suggestionDesc) return;
+ suggestionTitle = suggestionTitle ? suggestionTitle : `${suggestionDesc.substring(0, 70)}`;
+ const channel = client.channels.cache.get(config.suggestionChannel) as Discord.TextChannel;
+ const m = await channel.send({ embeds: LoadingEmbed});
+ const issue = await client.GitHub.rest.issues.create({
+ owner: "ClicksMinutePer",
+ repo: "Nucleus",
+ title: suggestionTitle,
+ body: `Linked Suggestion in Private Developer Channel: [Message](${m.url})\n\n**Suggestion:**\n> ${
+ suggestionDesc.replaceAll("@", "@<!-- -->").replaceAll("/issues", "/issues<!-- -->").replaceAll("/pull", "/pull<!-- -->")
+ }\n\n`,
+ labels: ["🤖 Auto", "📝 Suggestion"]
+ })
+ await m.edit({
embeds: [
new EmojiEmbed()
- .setTitle("Suggestion")
- .setDescription(
- `**From:** ${renderUser(
- interaction.member!.user as Discord.User
- )}\n**Suggestion:**\n> ${suggestion}\n\n` +
- `**Server:** ${interaction.guild!.name} (${interaction.guild!.id})\n`
- )
- .setStatus("Warning")
+ .setEmoji("ICONS.ADD")
+ .setTitle(`Suggestion from ${interaction.user.tag} (${interaction.user.id})`)
+ .setDescription(`**Suggestion:**\n> ${suggestionDesc}\n\n`)
+ .setStatus("Success")
+ .setFooter({text: `${issue.data.number}`})
],
components: [
- new Discord.ActionRowBuilder<Discord.ButtonBuilder>().addComponents(
- new Discord.ButtonBuilder()
- .setCustomId("suggestionAccept")
- .setLabel("Accept")
- .setStyle(ButtonStyle.Secondary)
- .setEmoji(getEmojiByName("ICONS.ADD", "id")),
- new Discord.ButtonBuilder()
- .setCustomId("suggestionDeny")
- .setLabel("Delete")
- .setStyle(ButtonStyle.Secondary)
- .setEmoji(getEmojiByName("ICONS.REMOVE", "id"))
+ new Discord.ActionRowBuilder<ButtonBuilder>().addComponents(
+ new ButtonBuilder().setCustomId("accept:Suggestion").setLabel("Accept").setStyle(ButtonStyle.Success),
+ new ButtonBuilder().setCustomId("deny:Suggestion").setLabel("Deny").setStyle(ButtonStyle.Danger),
+ new ButtonBuilder().setCustomId("close:Suggestion").setLabel("Close").setStyle(ButtonStyle.Secondary),
+ new ButtonBuilder().setCustomId("implemented:Suggestion").setLabel("Implemented").setStyle(ButtonStyle.Secondary),
+ new ButtonBuilder().setLabel(`Open Issue #${issue.data.number}`).setStyle(ButtonStyle.Link).setURL(`https://github.com/ClicksMinutePer/Nucleus/issues/${issue.data.number}`),
+ ),
+ new Discord.ActionRowBuilder<ButtonBuilder>().addComponents(
+ new ButtonBuilder().setCustomId("lock:Suggestion").setLabel("Lock").setStyle(ButtonStyle.Danger),
+ new ButtonBuilder().setCustomId("spam:Suggestion").setLabel("Mark as Spam").setStyle(ButtonStyle.Danger),
)
]
- });
+ })
await interaction.editReply({
embeds: [
new EmojiEmbed()