for coded
diff --git a/src/commands/mod/ban.ts b/src/commands/mod/ban.ts
index 2d7d036..92ed3a7 100644
--- a/src/commands/mod/ban.ts
+++ b/src/commands/mod/ban.ts
@@ -41,7 +41,7 @@
.setEmoji("PUNISH.BAN.RED")
.setTitle("Banned")
.setDescription(`You have been banned in ${interaction.guild.name}` +
- (interaction.options.getString("reason") ? ` for:\n> ${interaction.options.getString("reason")}` : " with no reason provided."))
+ (interaction.options.getString("reason") ? ` for:\n> ${interaction.options.getString("reason")}` : "."))
.setStatus("Danger")
]
})
diff --git a/src/commands/mod/kick.ts b/src/commands/mod/kick.ts
index 56e00e2..08beaa5 100644
--- a/src/commands/mod/kick.ts
+++ b/src/commands/mod/kick.ts
@@ -39,7 +39,7 @@
.setEmoji("PUNISH.KICK.RED")
.setTitle("Kicked")
.setDescription(`You have been kicked in ${interaction.guild.name}` +
- (interaction.options.getString("reason") ? ` for:\n> ${interaction.options.getString("reason")}` : " with no reason provided."))
+ (interaction.options.getString("reason") ? ` for:\n> ${interaction.options.getString("reason")}` : "."))
.setStatus("Danger")
]
})
diff --git a/src/commands/mod/mute.ts b/src/commands/mod/mute.ts
index 7c8cdd9..02d2531 100644
--- a/src/commands/mod/mute.ts
+++ b/src/commands/mod/mute.ts
@@ -137,7 +137,7 @@
.setEmoji("PUNISH.MUTE.RED")
.setTitle("Muted")
.setDescription(`You have been muted in ${interaction.guild.name}` +
- (interaction.options.getString("reason") ? ` for:\n> ${interaction.options.getString("reason")}` : " with no reason provided.\n\n" +
+ (interaction.options.getString("reason") ? ` for:\n> ${interaction.options.getString("reason")}` : ".\n\n" +
`You will be unmuted at: <t:${Math.round((new Date).getTime() / 1000) + muteTime}:D> at <t:${Math.round((new Date).getTime() / 1000) + muteTime}:T> (<t:${Math.round((new Date).getTime() / 1000) + muteTime}:R>)`))
.setStatus("Danger")
]
diff --git a/src/commands/mod/purge.ts b/src/commands/mod/purge.ts
index 1dc75eb..aa2f405 100644
--- a/src/commands/mod/purge.ts
+++ b/src/commands/mod/purge.ts
@@ -15,7 +15,7 @@
.setDescription("The amount of messages to delete")
.setRequired(false)
.setMinValue(1)
- .setMaxValue(50))
+ .setMaxValue(100))
.addChannelOption(option => option.setName("channel").setDescription("The channel to purge messages from").setRequired(false))
.addUserOption(option => option.setName("user").setDescription("The user to purge messages from").setRequired(false))
.addStringOption(option => option.setName("reason").setDescription("The reason for the purge").setRequired(false))
diff --git a/src/commands/mod/softban.ts b/src/commands/mod/softban.ts
index bcebbd5..233b7f2 100644
--- a/src/commands/mod/softban.ts
+++ b/src/commands/mod/softban.ts
@@ -40,7 +40,7 @@
.setEmoji("PUNISH.BAN.RED")
.setTitle("Softbanned")
.setDescription(`You have been softbanned from ${interaction.guild.name}` +
- (interaction.options.getString("reason") ? ` for:\n> ${interaction.options.getString("reason")}` : " with no reason provided."))
+ (interaction.options.getString("reason") ? ` for:\n> ${interaction.options.getString("reason")}` : "."))
.setStatus("Danger")
]
})
diff --git a/src/commands/mod/warn.ts b/src/commands/mod/warn.ts
index 442f290..3662896 100644
--- a/src/commands/mod/warn.ts
+++ b/src/commands/mod/warn.ts
@@ -16,6 +16,8 @@
)
const callback = async (interaction: CommandInteraction) => {
+ // @ts-ignore
+ const { log, NucleusColors, entry, renderUser, renderChannel, renderDelta } = interaction.client.logger
// TODO:[Modals] Replace this with a modal
if (await new confirmationMessage(interaction)
.setEmoji("PUNISH.WARN.RED")
@@ -24,7 +26,8 @@
"user": `<@!${(interaction.options.getMember("user") as GuildMember).id}> (${(interaction.options.getMember("user") as GuildMember).user.username})`,
"reason": `\n> ${interaction.options.getString("reason") ? interaction.options.getString("reason") : "*No reason provided*"}`
})
- + `The user **will${interaction.options.getString("notify") === "no" ? ' not' : ''}** be notified\n\n`)
+ + `The user **will${interaction.options.getString("notify") === "no" ? ' not' : ''}** be notified\n\n`
+ + `Are you sure you want to warn <@!${(interaction.options.getMember("user") as GuildMember).id}>?`)
.setColor("Danger")
// pluralize("day", interaction.options.getInteger("delete"))
// const pluralize = (word: string, count: number) => { return count === 1 ? word : word + "s" }
@@ -37,7 +40,7 @@
.setEmoji("PUNISH.WARN.RED")
.setTitle("Warned")
.setDescription(`You have been warned in ${interaction.guild.name}` +
- (interaction.options.getString("reason") ? ` for:\n> ${interaction.options.getString("reason")}` : " with no reason provided."))
+ (interaction.options.getString("reason") ? ` for:\n> ${interaction.options.getString("reason")}` : "."))
.setStatus("Danger")
]
})
@@ -51,6 +54,25 @@
.setStatus("Danger")
], components: []})
}
+ let data = {
+ meta:{
+ type: 'memberWarn',
+ displayName: 'Member warned',
+ calculateType: 'guildMemberPunish',
+ color: NucleusColors.yellow,
+ emoji: 'PUNISH.WARN.YELLOW',
+ timestamp: new Date().getTime()
+ },
+ list: {
+ user: renderUser((interaction.options.getMember("user") as GuildMember).user.id, (interaction.options.getMember("user") as GuildMember).user),
+ warnedBy: renderUser(interaction.member.user.id, interaction.member.user),
+ reason: (interaction.options.getString("reason") ? `\n> ${interaction.options.getString("reason")}` : "No reason provided")
+ },
+ hidden: {
+ guild: interaction.guild.id
+ }
+ }
+ log(data, interaction.client);
let failed = (dmd == false && interaction.options.getString("notify") != "no")
if (!failed) {
await interaction.editReply({embeds: [new EmojiEmbed()
@@ -97,7 +119,7 @@
.setEmoji(`PUNISH.WARN.RED`)
.setTitle(`Warn`)
.setDescription(`You have been warned` +
- (interaction.options.getString("reason") ? ` for:\n> ${interaction.options.getString("reason")}` : " with no reason provided."))
+ (interaction.options.getString("reason") ? ` for:\n> ${interaction.options.getString("reason")}` : "."))
.setStatus("Danger")
],
content: `<@!${(interaction.options.getMember("user") as GuildMember).id}>`,
@@ -129,7 +151,6 @@
}
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
- return true
let member = (interaction.member as GuildMember)
let me = (interaction.guild.me as GuildMember)
let apply = (interaction.options.getMember("user") as GuildMember)
diff --git a/src/commands/privacy.ts b/src/commands/privacy.ts
index dc97370..063f195 100644
--- a/src/commands/privacy.ts
+++ b/src/commands/privacy.ts
@@ -1,13 +1,15 @@
import { CommandInteraction } from "discord.js";
import { SlashCommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
+import { testLink, testMalware, testNSFW } from '../utils/scanners.js';
const command = new SlashCommandBuilder()
.setName("privacy")
- .setDescription("Shows info about Nucleus' privacy options")
+ .setDescription("we changed the fucking charger again!")
+ .addStringOption(option => option.setName("link").setDescription("fuck you").setRequired(false))
-const callback = (interaction: CommandInteraction) => {
- interaction.reply("Command incomplete [privacy]");
+const callback = async (interaction: CommandInteraction) => {
+ console.log(await testLink(interaction.options.getString("link")))
}
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
diff --git a/src/commands/settings/all.ts b/src/commands/settings/all.ts
deleted file mode 100644
index 0f17545..0000000
--- a/src/commands/settings/all.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import { CommandInteraction } from "discord.js";
-import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
-import { WrappedCheck } from "jshaiku";
-
-const command = (builder: SlashCommandSubcommandBuilder) =>
- builder
- .setName("all")
- .setDescription("Shows a full UI of all settings")
-
-const callback = (interaction: CommandInteraction) => {
- interaction.reply("Command incomplete [settings/all]");
-}
-
-const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
- return true;
-}
-
-export { command };
-export { callback };
-export { check };
\ No newline at end of file
diff --git a/src/commands/settings/tickets.ts b/src/commands/settings/tickets.ts
index 33e1586..2c2b806 100644
--- a/src/commands/settings/tickets.ts
+++ b/src/commands/settings/tickets.ts
@@ -1,18 +1,24 @@
import { CommandInteraction } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
+import { ChannelType } from 'discord-api-types';
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
.setName("tickets")
.setDescription("Shows settings for tickets")
+ .addStringOption(option => option.setName("enabled").setDescription("If users should be able to create tickets | Default yes").setRequired(false)
+ .addChoices([["Yes", "yes"], ["No", "no"]]))
+ .addChannelOption(option => option.setName("category").setDescription("The category where tickets are created").addChannelType(ChannelType.GuildCategory).setRequired(false))
+ .addNumberOption(option => option.setName("maxtickets").setDescription("The maximum amount of tickets a user can create | Default 5").setRequired(false).setMinValue(1))
+ .addRoleOption(option => option.setName("supportping").setDescription("The role pinged when a ticket is created").setRequired(false))
const callback = (interaction: CommandInteraction) => {
interaction.reply("Command incomplete [settings/tickets]");
}
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
- return true;
+ return interaction.memberPermissions.has("MANAGE_GUILD");
}
export { command };
diff --git a/src/commands/ticket/close.ts b/src/commands/ticket/close.ts
index 1e0856d..7b9d1c2 100644
--- a/src/commands/ticket/close.ts
+++ b/src/commands/ticket/close.ts
@@ -1,14 +1,99 @@
-import { CommandInteraction } from "discord.js";
+import Discord, { CommandInteraction } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
+import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
+import readConfig from "../../utils/readConfig.js";
+import getEmojiByName from "../../utils/getEmojiByName.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
.setName("close")
.setDescription("Closes a ticket")
-const callback = (interaction: CommandInteraction) => {
- interaction.reply("Command incomplete [ticket/close]");
+const callback = async (interaction: CommandInteraction) => {
+ // @ts-ignore
+ const { log, NucleusColors, entry, renderUser, renderChannel, renderDelta } = interaction.client.logger
+
+ let config = await readConfig(interaction.guild.id);
+ let channel = (interaction.channel as Discord.TextChannel)
+ if (config.tickets.category != channel.parent.id) {
+ return interaction.reply({embeds: [new EmojiEmbed()
+ .setTitle("Close Ticket")
+ .setDescription("This ticket is not in your tickets category, so cannot be deleted.")
+ .setStatus("Danger")
+ .setEmoji("CONTROL.BLOCKCROSS")
+ ], ephemeral: true});
+ }
+ let status = channel.topic.split(" ")[1];
+ if (status == "Archived") {
+ interaction.reply({embeds: [new EmojiEmbed()
+ .setTitle("Close Ticket")
+ .setDescription("This ticket will be deleted in 3 seconds.")
+ .setStatus("Danger")
+ .setEmoji("GUILD.TICKET.CLOSE")
+ ]});
+ setTimeout(async () => {
+ let data = {
+ meta:{
+ type: 'ticketClosed',
+ displayName: 'Ticket Closed',
+ calculateType: true,
+ color: NucleusColors.red,
+ emoji: 'GUILD.TICKET.CLOSE',
+ timestamp: new Date().getTime()
+ },
+ list: {
+ ticketFor: entry(channel.topic.split(" ")[0], renderUser((await interaction.guild.members.fetch(channel.topic.split(" ")[0])).user)),
+ closedBy: entry(interaction.member.user.id, renderUser(interaction.member.user)),
+ closedAt: entry(new Date().getTime(), renderDelta(new Date().getTime()))
+ },
+ hidden: {
+ guild: interaction.guild.id
+ }
+ }
+ log(data, interaction.client);
+ interaction.channel.delete();
+ }, 3000);
+ return;
+ } else if (status == "Active") {
+ interaction.reply({embeds: [new EmojiEmbed()
+ .setTitle("Close Ticket")
+ .setDescription("This ticket will be archived in 3 seconds.")
+ .setStatus("Warning")
+ .setEmoji("GUILD.TICKET.ARCHIVED")
+ ]});
+ setTimeout(async () =>{
+ channel.permissionsFor(await interaction.guild.members.fetch(channel.topic.split(" ")[0])).remove("VIEW_CHANNEL");
+ channel.setTopic(`${channel.topic.split(" ")[0]} Archived`);
+ let data = {
+ meta:{
+ type: 'ticketArchive',
+ displayName: 'Ticket Archived',
+ calculateType: true,
+ color: NucleusColors.yellow,
+ emoji: 'GUILD.TICKET.ARCHIVED',
+ timestamp: new Date().getTime()
+ },
+ list: {
+ ticketFor: entry(channel.topic.split(" ")[0], renderUser((await interaction.guild.members.fetch(channel.topic.split(" ")[0])).user)),
+ archivedBy: entry(interaction.member.user.id, renderUser(interaction.member.user)),
+ archivedAt: entry(new Date().getTime(), renderDelta(new Date().getTime())),
+ ticketChannel: entry(channel.id, renderChannel(channel)),
+ },
+ hidden: {
+ guild: interaction.guild.id
+ }
+ }
+ log(data, interaction.client);
+ await interaction.editReply({embeds: [new EmojiEmbed()
+ .setTitle("Close Ticket")
+ .setDescription("This ticket has been archived.\nType `/ticket close` to delete it.")
+ .setStatus("Warning")
+ .setEmoji("GUILD.TICKET.ARCHIVED") // TODO:[Premium] Add a transcript option ||\----/|| <- the bridge we will cross when we come to it
+ ]});
+ }, 3000);
+ return;
+ }
}
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
diff --git a/src/commands/ticket/create.ts b/src/commands/ticket/create.ts
index 6f45cc2..4f58aa0 100644
--- a/src/commands/ticket/create.ts
+++ b/src/commands/ticket/create.ts
@@ -1,14 +1,172 @@
-import { CommandInteraction } from "discord.js";
+import Discord, { CommandInteraction, MessageActionRow, MessageButton } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
+import { tickets, toHexArray, toHexInteger } from "../../utils/calculate.js";
+import readConfig from "../../utils/readConfig.js";
+import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
+import getEmojiByName from "../../utils/getEmojiByName.js";
+
+function capitalize(s: string) {
+ s = s.replace(/([A-Z])/g, ' $1');
+ return s.length < 3 ? s.toUpperCase() : s[0].toUpperCase() + s.slice(1).toLowerCase();
+}
const command = (builder: SlashCommandSubcommandBuilder) =>
builder
.setName("create")
.setDescription("Creates a new modmail ticket")
+ .addStringOption(option => option.setName("message").setDescription("The content of the ticket").setRequired(false))
-const callback = (interaction: CommandInteraction) => {
- interaction.reply("Command incomplete [ticket/create]");
+const callback = async (interaction: CommandInteraction) => {
+ // @ts-ignore
+ const { log, NucleusColors, entry, renderUser, renderChannel, renderDelta } = interaction.client.logger
+
+ let config = await readConfig(interaction.guild.id);
+ if (!config.tickets.enabled || !config.tickets.category) {
+ return await interaction.reply({embeds: [new EmojiEmbed()
+ .setTitle("Tickets are disabled")
+ .setDescription("Please enable tickets in the configuration to use this command.")
+ .setStatus("Danger")
+ .setEmoji("CONTROL.BLOCKCROSS")
+ ], ephemeral: true});
+ }
+ let category = interaction.guild.channels.cache.get(config.tickets.category) as Discord.CategoryChannel;
+ let count = 0;
+ category.children.forEach(element => {
+ if (!(element.type == "GUILD_TEXT")) return;
+ if ((element as Discord.TextChannel).topic.includes(`${interaction.member.user.id}`)) {
+ if ((element as Discord.TextChannel).topic.endsWith("Active")) {
+ count++;
+ }
+ }
+ });
+ if (count >= config.tickets.maxTickets) {
+ return await interaction.reply({embeds: [new EmojiEmbed()
+ .setTitle("Create Ticket")
+ .setDescription(`You have reached the maximum amount of tickets (${config.tickets.maxTickets}). Please close one of your active tickets before creating a new one.`)
+ .setStatus("Danger")
+ .setEmoji("CONTROL.BLOCKCROSS")
+ ], ephemeral: true});
+ }
+ let ticketTypes
+ if (config.tickets.customTypes) ticketTypes = config.tickets.customTypes;
+ else if (config.tickets.types) ticketTypes = toHexArray(config.tickets.types, tickets);
+ else ticketTypes = [];
+ let chosenType;
+ if (ticketTypes.length > 0) {
+ let splitFormattedTicketTypes = [];
+ let formattedTicketTypes = [];
+ formattedTicketTypes = ticketTypes.map(type => {
+ return new MessageButton()
+ .setLabel(capitalize(type))
+ .setStyle("PRIMARY")
+ .setCustomId(type)
+ .setEmoji(getEmojiByName(("TICKETS." + type.toString().toUpperCase()), "id"));
+ });
+ for (let i = 0; i < formattedTicketTypes.length; i += 4) {
+ splitFormattedTicketTypes.push(new MessageActionRow().addComponents(formattedTicketTypes.slice(i, i + 4)));
+ }
+ let m = await interaction.reply({embeds: [new EmojiEmbed()
+ .setTitle("Create Ticket")
+ .setDescription("Please select a ticket type")
+ .setStatus("Success")
+ .setEmoji("GUILD.TICKET.OPEN")
+ ], ephemeral: true, fetchReply: true, components: splitFormattedTicketTypes});
+ let component;
+ try {
+ component = await (m as Discord.Message).awaitMessageComponent({time: 2.5 * 60 * 1000});
+ } catch (e) {
+ return;
+ }
+ component.deferUpdate();
+ chosenType = component.customId;
+ } else {
+ chosenType = null
+ await interaction.reply({embeds: [new EmojiEmbed()
+ .setTitle("Create Ticket")
+ .setEmoji("GUILD.TICKET.OPEN")
+ ], ephemeral: true})
+ }
+ let overwrites = [{
+ id: interaction.member,
+ allow: ["VIEW_CHANNEL", "SEND_MESSAGES", "ATTACH_FILES", "ADD_REACTIONS", "READ_MESSAGE_HISTORY"],
+ type: "member"
+ }] as Discord.OverwriteResolvable[];
+ if (config.tickets.supportRole != null) {
+ overwrites.push({
+ id: interaction.guild.roles.cache.get(config.tickets.supportRole),
+ allow: ["VIEW_CHANNEL", "SEND_MESSAGES", "ATTACH_FILES", "ADD_REACTIONS", "READ_MESSAGE_HISTORY"],
+ type: "role"
+ })
+ }
+
+ let c;
+ try {
+ c = await interaction.guild.channels.create(interaction.member.user.username, {
+ type: "GUILD_TEXT",
+ topic: `${interaction.member.user.id} Active`,
+ parent: config.tickets.category,
+ nsfw: false,
+ permissionOverwrites: (overwrites as Discord.OverwriteResolvable[]),
+ reason: "Creating ticket"
+ })
+ } catch (e) {
+ return await interaction.editReply({embeds: [new EmojiEmbed()
+ .setTitle("Create Ticket")
+ .setDescription("Failed to create ticket")
+ .setStatus("Danger")
+ .setEmoji("CONTROL.BLOCKCROSS")
+ ]});
+ }
+ try {
+ await c.send(
+ {
+ content: (`<@${interaction.member.user.id}>` + (config.tickets.supportRole != null ? ` • <@&${config.tickets.supportRole}>` : "")),
+ allowedMentions: {
+ users: [(interaction.member as Discord.GuildMember).id],
+ roles: (config.tickets.supportRole != null ? [config.tickets.supportRole] : [])
+ }
+ }
+ )
+ let content = interaction.options.getString("message") || "";
+ if (content) content = `**Message:**\n> ${content}\n`;
+ await c.send({ embeds: [new EmojiEmbed()
+ .setTitle("New Ticket")
+ .setDescription(
+ `Ticket created by <@${interaction.member.user.id}>\n` +
+ `**Support type:** ${chosenType != null ? (getEmojiByName("TICKETS." + chosenType.toUpperCase()) + " " + capitalize(chosenType)) : "General"}\n` +
+ `**Ticket ID:** \`${c.id}\`\n${content}\n` +
+ `Type \`/ticket close\` to archive this ticket.`,
+ )
+ .setStatus("Success")
+ .setEmoji("GUILD.TICKET.OPEN")
+ ]})
+ let data = {
+ meta:{
+ type: 'ticketCreate',
+ displayName: 'Ticket Created',
+ calculateType: true,
+ color: NucleusColors.green,
+ emoji: 'GUILD.TICKET.OPEN',
+ timestamp: new Date().getTime()
+ },
+ list: {
+ ticketFor: entry(interaction.member.user.id, renderUser(interaction.member.user)),
+ createdAt: entry(new Date().getTime(), renderDelta(new Date().getTime())),
+ ticketChannel: entry(c.id, renderChannel(c)),
+ },
+ hidden: {
+ guild: interaction.guild.id
+ }
+ }
+ log(data, interaction.client);
+ } catch (e) { console.log(e)}
+ await interaction.editReply({embeds: [new EmojiEmbed()
+ .setTitle("Create Ticket")
+ .setDescription(`Ticket created. You can view it here: <#${c.id}>`)
+ .setStatus("Success")
+ .setEmoji("GUILD.TICKET.OPEN")
+ ], components: []});
}
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
diff --git a/src/commands/ticket/delete.ts b/src/commands/ticket/delete.ts
deleted file mode 100644
index 587ecf4..0000000
--- a/src/commands/ticket/delete.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import { CommandInteraction } from "discord.js";
-import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
-import { WrappedCheck } from "jshaiku";
-
-const command = (builder: SlashCommandSubcommandBuilder) =>
- builder
- .setName("delete")
- .setDescription("Deletes a ticket")
-
-const callback = (interaction: CommandInteraction) => {
- interaction.reply("Command incomplete [ticket/delete]");
-}
-
-const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
- return true;
-}
-
-export { command };
-export { callback };
-export { check };
\ No newline at end of file
diff --git a/src/commands/verify.ts b/src/commands/verify.ts
index bb93dde..489a109 100644
--- a/src/commands/verify.ts
+++ b/src/commands/verify.ts
@@ -1,13 +1,144 @@
-import { CommandInteraction } from "discord.js";
+import Discord, { CommandInteraction, GuildMember } from "discord.js";
import { SlashCommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
+import generateEmojiEmbed from "../utils/generateEmojiEmbed.js";
+import readConfig from "../utils/readConfig.js";
+import fetch from "node-fetch";
+import { TestString, NSFWCheck } from "../automations/unscan.js";
const command = new SlashCommandBuilder()
.setName("verify")
.setDescription("Get verified in the server")
-const callback = (interaction: CommandInteraction) => {
- interaction.reply("Command incomplete [verify]");
+const callback = async (interaction: CommandInteraction) => {
+ // @ts-ignore
+ let verify = interaction.client.verify
+ await interaction.reply({embeds: [new generateEmojiEmbed()
+ .setTitle("Loading")
+ .setStatus("Danger")
+ .setEmoji("NUCLEUS.LOADING")
+ ], ephemeral: true, fetchReply: true});
+ let config = await readConfig(interaction.guild.id);
+ if ((interaction.member as GuildMember).roles.cache.has(config.verify.role)) {
+ return await interaction.editReply({embeds: [new generateEmojiEmbed()
+ .setTitle("Verify")
+ .setDescription(`You already have the <@&${config.verify.role}> role`)
+ .setStatus("Danger")
+ .setEmoji("CONTROL.BLOCKCROSS")
+ ]});
+ } else if (interaction.channel.id != config.verify.channel) {
+ return await interaction.editReply({embeds: [new generateEmojiEmbed()
+ .setTitle("Verify")
+ .setDescription(`You can only use this command in <#${config.verify.channel}>`)
+ .setStatus("Danger")
+ .setEmoji("CONTROL.BLOCKCROSS")
+ ]});
+ }
+ await interaction.editReply({embeds: [new generateEmojiEmbed()
+ .setTitle("Verify")
+ .setDescription(`Checking our servers are up`)
+ .setStatus("Warning")
+ .setEmoji("NUCLEUS.LOADING")
+ ]});
+ try {
+ let status = await fetch(`https://clicksminuteper.net`).then(res => res.status);
+ if (status != 200) {
+ return await interaction.editReply({embeds: [new generateEmojiEmbed()
+ .setTitle("Verify")
+ .setDescription(`Our servers appear to be down, please try again later`)
+ .setStatus("Danger")
+ .setEmoji("CONTROL.BLOCKCROSS")
+ ]});
+ }
+ } catch {
+ return await interaction.editReply({embeds: [new generateEmojiEmbed()
+ .setTitle("Verify")
+ .setDescription(`Our servers appear to be down, please try again later`)
+ .setStatus("Danger")
+ .setEmoji("CONTROL.BLOCKCROSS")
+ ], components: [new Discord.MessageActionRow().addComponents([
+ new Discord.MessageButton()
+ .setLabel("Open webpage")
+ .setStyle("LINK")
+ .setURL("https://clicksminuteper.net/"),
+ new Discord.MessageButton()
+ .setLabel("Support")
+ .setStyle("LINK")
+ .setURL("https://discord.gg/bPaNnxe")
+ ])]});
+ }
+ if (config.filters.images.NSFW) {
+ await interaction.editReply({embeds: [new generateEmojiEmbed()
+ .setTitle("Verify")
+ .setDescription(`Checking your avatar is safe for work`)
+ .setStatus("Warning")
+ .setEmoji("NUCLEUS.LOADING")
+ ]});
+ if (await NSFWCheck((interaction.member as GuildMember).user.avatarURL({format: "png"}))) {
+ return await interaction.editReply({embeds: [new generateEmojiEmbed()
+ .setTitle("Verify")
+ .setDescription(`Your avatar was detected as NSFW, which we do not allow in this server.\nPlease contact one of our staff members if you believe this is a mistake`)
+ .setStatus("Danger")
+ .setEmoji("CONTROL.BLOCKCROSS")
+ ]});
+ }
+ }
+ if (config.filters.wordFilter) {
+ await interaction.editReply({embeds: [new generateEmojiEmbed()
+ .setTitle("Verify")
+ .setDescription(`Checking your name is allowed`)
+ .setStatus("Warning")
+ .setEmoji("NUCLEUS.LOADING")
+ ]});
+ if (TestString((interaction.member as Discord.GuildMember).displayName, config.filters.wordFilter.words.loose, config.filters.wordFilter.words.strict) != "none") {
+ return await interaction.editReply({embeds: [new generateEmojiEmbed()
+ .setTitle("Verify")
+ .setDescription(`Your name contained a word we do not allow in this server.\nPlease contact one of our staff members if you believe this is a mistake`)
+ .setStatus("Danger")
+ .setEmoji("CONTROL.BLOCKCROSS")
+ ]});
+ }
+ }
+ await interaction.editReply({embeds: [new generateEmojiEmbed()
+ .setTitle("Verify")
+ .setDescription(`One moment...`)
+ .setStatus("Warning")
+ .setEmoji("NUCLEUS.LOADING")
+ ]});
+ let code = ""
+ let length = 5
+ let itt = 0
+ const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
+ while (true) {
+ itt += 1
+ code = ""
+ for (let i = 0; i < length; i++) { code += chars.charAt(Math.floor(Math.random() * chars.length)); }
+ if (code in verify) continue;
+ if (itt > 1000) {
+ itt = 0
+ length += 1
+ continue
+ }
+ break;
+ }
+ verify[code] = {
+ uID: interaction.member.user.id,
+ gID: interaction.guild.id,
+ rName: (await interaction.guild.roles.fetch(config.verify.role)).name,
+ mCount: interaction.guild.memberCount,
+ gName: interaction.guild.name,
+ guildIcon: interaction.guild.iconURL({format: "png"})
+ }
+ await interaction.editReply({embeds: [new generateEmojiEmbed()
+ .setTitle("Verify")
+ .setDescription(`Looking good!\nClick the button below to get verified`)
+ .setStatus("Success")
+ .setEmoji("MEMBER.JOIN")
+ ], components: [new Discord.MessageActionRow().addComponents([new Discord.MessageButton()
+ .setLabel("Verify")
+ .setStyle("LINK")
+ .setURL(`https://clicksminuteper.net/nucleus/verify?code=${code}`)
+ ])]});
}
const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
@@ -16,4 +147,4 @@
export { command };
export { callback };
-export { check };
\ No newline at end of file
+export { check };
diff --git a/src/config/emojis.json b/src/config/emojis.json
index 1764932..b759b8a 100644
--- a/src/config/emojis.json
+++ b/src/config/emojis.json
@@ -1,5 +1,7 @@
{
"NUCLEUS": {
+ "LOGO": "953040840945721385",
+ "LOADING": "a946346549271732234",
"INFO": {
"HELP": "751751467014029322",
"ABOUT": "751762088346517504",
@@ -30,6 +32,7 @@
"CONTROL": {
"TICK": "947441964234702849",
"CROSS": "947441948543815720",
+ "BLOCKCROSS": "952261738349330493",
"LEFT": "947441951148486728",
"RIGHT": "947441957473488916",
"DOWNLOAD": "947959513032585236",
@@ -48,10 +51,12 @@
"CHANNEL": {
"TEXT": {
"CREATE": "729066924943737033",
+ "EDIT": "951957316117360640",
"DELETE": "729064529211686922"
},
"VOICE": {
"CREATE": "729064530830950530",
+ "EDIT": "951957316071223336",
"DELETE": "729064530981683200"
},
"STORE": {
@@ -180,15 +185,19 @@
}
},
"GUILD": {
- "EMOJIS": "729066518549233795",
+ "EMOJI": {
+ "CREATE": "953035168115982437",
+ "EDIT": "729066518549233795",
+ "DELETE": "953035210121953320"
+ },
"GRAPHS": "752214059159650396",
"SETTINGS": "752570111063228507",
"ICONCHANGE": "729763053612302356",
"MODERATIONUPDATE": "729763053352124529",
- "MODMAIL": {
+ "TICKET": {
"OPEN": "853245836331188264",
"CLOSE": "853580122506133505",
- "ARCHIVE": "853580122636025856"
+ "ARCHIVED": "853580122636025856"
},
"ROLES": {
"CREATE": "729064530763579413",
@@ -272,5 +281,13 @@
"CFSERVICE": {
"VERIFIED": "881984571242053642",
"UNVERIFIED": "881984571258847232"
+ },
+ "TICKETS": {
+ "SUPPORT": "952295894370369587",
+ "REPORT": "952295894437482537",
+ "QUESTION": "952295894403907645",
+ "ISSUE": "952295894412316672",
+ "SUGGESTION": "952295894399725588",
+ "OTHER": "952295894445883502"
}
}
\ No newline at end of file
diff --git a/src/index.ts b/src/index.ts
index 9a361f6..9e2770c 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -1,11 +1,15 @@
import { HaikuClient } from 'jshaiku';
import { Intents } from 'discord.js';
import config from './config/main.json' assert {type: 'json'};
-
+import { Logger } from './utils/log.js';
const client = new HaikuClient({
intents: new Intents(32767).bitfield, // This is a way of specifying all intents w/o having to type them out
}, config);
await client.registerCommandsIn("./commands");
+await client.registerEventsIn("./events");
+
+client.logger = new Logger()
+client.verify = {}
await client.login();
\ No newline at end of file
diff --git a/src/utils/generateKeyValueList.ts b/src/utils/generateKeyValueList.ts
index 7f77bef..b3e276f 100644
--- a/src/utils/generateKeyValueList.ts
+++ b/src/utils/generateKeyValueList.ts
@@ -1,6 +1,11 @@
-function capitalize(s)
-{
- return s[0].toUpperCase() + s.slice(1);
+const forceCaps = [
+ "ID",
+ "NSFW"
+]
+
+export function capitalize(s: string) {
+ s = s.replace(/([A-Z])/g, ' $1');
+ return forceCaps.includes(s.toUpperCase()) ? s.toUpperCase() : s[0].toUpperCase() + s.slice(1).toLowerCase();
}
function keyValueList(data) {
diff --git a/src/utils/getEmojiByName.ts b/src/utils/getEmojiByName.ts
index 0ec7cd6..bbc8f24 100644
--- a/src/utils/getEmojiByName.ts
+++ b/src/utils/getEmojiByName.ts
@@ -13,7 +13,7 @@
if (id === undefined) {
return `<a:a:946346549271732234>`
} else if (id.toString().startsWith("a")) {
- return `<a:a:${id.toString().slice(0, -1)}>`
+ return `<a:a:${id.toString().slice(1, id.toString().length)}>`
}
return `<:a:${id}>`;
}