Reformat using prettier
diff --git a/src/reflex/guide.ts b/src/reflex/guide.ts
index a3027e4..1901d34 100644
--- a/src/reflex/guide.ts
+++ b/src/reflex/guide.ts
@@ -1,4 +1,4 @@
-import { getCommandMentionByName } from './../utils/getCommandDataByName.js';
+import { getCommandMentionByName } from "./../utils/getCommandDataByName.js";
import { LoadingEmbed } from "../utils/defaults.js";
import Discord, {
ActionRowBuilder,
@@ -19,19 +19,19 @@
export default async (guild: Guild, interaction?: CommandInteraction) => {
let c: GuildTextBasedChannel | null = guild.publicUpdatesChannel ? guild.publicUpdatesChannel : guild.systemChannel;
c = c
- ? c
- : (guild.channels.cache.find(
- (ch) =>
- [
- ChannelType.GuildText,
- ChannelType.GuildAnnouncement,
- ChannelType.PublicThread,
- ChannelType.PrivateThread,
- ChannelType.AnnouncementThread
- ].includes(ch.type) &&
- ch.permissionsFor(guild.roles.everyone).has("SendMessages") &&
- ch.permissionsFor(guild.members.me!).has("EmbedLinks")
- ) as GuildTextBasedChannel | undefined) ?? null;
+ ? c
+ : (guild.channels.cache.find(
+ (ch) =>
+ [
+ ChannelType.GuildText,
+ ChannelType.GuildAnnouncement,
+ ChannelType.PublicThread,
+ ChannelType.PrivateThread,
+ ChannelType.AnnouncementThread
+ ].includes(ch.type) &&
+ ch.permissionsFor(guild.roles.everyone).has("SendMessages") &&
+ ch.permissionsFor(guild.members.me!).has("EmbedLinks")
+ ) as GuildTextBasedChannel | undefined) ?? null;
if (interaction) c = interaction.channel as GuildTextBasedChannel;
if (!c) {
return;
@@ -71,12 +71,22 @@
"Nucleus can log server events and keep you informed with what content is being posted to your server.\n" +
"We have 2 different types of logs, which each can be configured to send to a channel of your choice:\n" +
"**General:** These are events like kicks and channel changes etc.\n" +
- `> These are standard logs and can be set with ${getCommandMentionByName("settings/logs/general")}\n` +
+ `> These are standard logs and can be set with ${getCommandMentionByName(
+ "settings/logs/general"
+ )}\n` +
"**Warnings:** Warnings like NSFW avatars and spam etc. that may require action by a server staff member.\n" +
- `> These may require special action by a moderator. You can set the channel with ${getCommandMentionByName("settings/logs/warnings")}\n` +
+ `> These may require special action by a moderator. You can set the channel with ${getCommandMentionByName(
+ "settings/logs/warnings"
+ )}\n` +
"**Attachments:** All images sent in the server - Used to keep a record of deleted images\n" +
- `> Sent to a separate log channel to avoid spam. This can be set with ${getCommandMentionByName("settings/logs/attachments")}\n` +
- `> ${getEmojiByName("NUCLEUS.PREMIUM")} Please note this feature is only available with ${getCommandMentionByName("nucleus/premium")}`
+ `> Sent to a separate log channel to avoid spam. This can be set with ${getCommandMentionByName(
+ "settings/logs/attachments"
+ )}\n` +
+ `> ${getEmojiByName(
+ "NUCLEUS.PREMIUM"
+ )} Please note this feature is only available with ${getCommandMentionByName(
+ "nucleus/premium"
+ )}`
)
.setEmoji("ICONS.LOGGING")
.setStatus("Danger")
@@ -90,15 +100,33 @@
.setTitle("Moderation")
.setDescription(
"Nucleus has a number of commands that can be used to moderate your server.\n" +
- `These commands are all found under ${getCommandMentionByName(("mod"))}, and they include:\n` +
- `${getEmojiByName("PUNISH.WARN.YELLOW")} ${getCommandMentionByName("mod/warn")}: The user is warned (via DM) that they violated server rules. More options given if DMs are disabled.\n` +
- `${getEmojiByName("PUNISH.CLEARHISTORY")} ${getCommandMentionByName("mod/purge")}: Deletes messages in a channel, giving options to only delete messages by a certain user.\n` +
- `${getEmojiByName("PUNISH.MUTE.YELLOW")} ${getCommandMentionByName("mod/mute")}: Stops users sending messages or joining voice chats.\n` +
- `${getEmojiByName("PUNISH.MUTE.GREEN")} ${getCommandMentionByName("mod/unmute")}: Allows user to send messages and join voice chats.\n` +
- `${getEmojiByName("PUNISH.KICK.RED")} ${getCommandMentionByName("mod/kick")}: Removes a member from the server. They will be able to rejoin.\n` +
- `${getEmojiByName("PUNISH.SOFTBAN")} ${getCommandMentionByName("mod/softban")}: Kicks the user, deleting their messages from every channel in a given time frame.\n` +
- `${getEmojiByName("PUNISH.BAN.RED")} ${getCommandMentionByName("mod/ban")}: Removes the user from the server, deleting messages from every channel and stops them from rejoining.\n` +
- `${getEmojiByName("PUNISH.BAN.GREEN")} ${getCommandMentionByName("mod/unban")}: Allows a member to rejoin the server after being banned.`
+ `These commands are all found under ${getCommandMentionByName(
+ "mod"
+ )}, and they include:\n` +
+ `${getEmojiByName("PUNISH.WARN.YELLOW")} ${getCommandMentionByName(
+ "mod/warn"
+ )}: The user is warned (via DM) that they violated server rules. More options given if DMs are disabled.\n` +
+ `${getEmojiByName("PUNISH.CLEARHISTORY")} ${getCommandMentionByName(
+ "mod/purge"
+ )}: Deletes messages in a channel, giving options to only delete messages by a certain user.\n` +
+ `${getEmojiByName("PUNISH.MUTE.YELLOW")} ${getCommandMentionByName(
+ "mod/mute"
+ )}: Stops users sending messages or joining voice chats.\n` +
+ `${getEmojiByName("PUNISH.MUTE.GREEN")} ${getCommandMentionByName(
+ "mod/unmute"
+ )}: Allows user to send messages and join voice chats.\n` +
+ `${getEmojiByName("PUNISH.KICK.RED")} ${getCommandMentionByName(
+ "mod/kick"
+ )}: Removes a member from the server. They will be able to rejoin.\n` +
+ `${getEmojiByName("PUNISH.SOFTBAN")} ${getCommandMentionByName(
+ "mod/softban"
+ )}: Kicks the user, deleting their messages from every channel in a given time frame.\n` +
+ `${getEmojiByName("PUNISH.BAN.RED")} ${getCommandMentionByName(
+ "mod/ban"
+ )}: Removes the user from the server, deleting messages from every channel and stops them from rejoining.\n` +
+ `${getEmojiByName("PUNISH.BAN.GREEN")} ${getCommandMentionByName(
+ "mod/unban"
+ )}: Allows a member to rejoin the server after being banned.`
)
.setEmoji("PUNISH.BAN.RED")
.setStatus("Danger")
@@ -112,7 +140,9 @@
.setTitle("Verify")
.setDescription(
"Nucleus has a verification system that allows users to prove they aren't bots.\n" +
- `This is done by running ${getCommandMentionByName("verify")} which sends a message only the user can see, giving them a link to a website to verify.\n` +
+ `This is done by running ${getCommandMentionByName(
+ "verify"
+ )} which sends a message only the user can see, giving them a link to a website to verify.\n` +
"After the user complete's the check, they are given a role, which can be set to unlock specific channels.\n" +
`You can set the role given with ${getCommandMentionByName("settings/verify")}`
)
@@ -129,7 +159,9 @@
.setDescription(
"Nucleus has a content scanning system that automatically scans links and images sent by users.\n" +
"The staff team can be notified when an NSFW image is detected, or malicious links are sent.\n" +
- `You can check and manage what to moderate in ${getCommandMentionByName("settings/automod")}`
+ `You can check and manage what to moderate in ${getCommandMentionByName(
+ "settings/automod"
+ )}`
)
.setEmoji("MOD.IMAGES.TOOSMALL")
.setStatus("Danger")
@@ -143,10 +175,16 @@
.setTitle("Tickets")
.setDescription(
"Nucleus has a ticket system which allows users to create tickets and talk to the server staff or support team.\n" +
- `Tickets can be created by users with ${getCommandMentionByName("ticket/create")}, or by clicking a button created by moderators.\n` +
+ `Tickets can be created by users with ${getCommandMentionByName(
+ "ticket/create"
+ )}, or by clicking a button created by moderators.\n` +
`After being created, a new channel or thread is created, and the user and support team are pinged. \n` +
- `The category or channel to create threads in can be set with ${getCommandMentionByName("settings/tickets")}\n` +
- `When the ticket is resolved, anyone can run ${getCommandMentionByName("ticket/close")} (or click the button) to close it.\n` +
+ `The category or channel to create threads in can be set with ${getCommandMentionByName(
+ "settings/tickets"
+ )}\n` +
+ `When the ticket is resolved, anyone can run ${getCommandMentionByName(
+ "ticket/close"
+ )} (or click the button) to close it.\n` +
`Running ${getCommandMentionByName("ticket/close")} again will delete the ticket.`
)
.setEmoji("GUILD.TICKET.CLOSE")
@@ -161,8 +199,12 @@
.setTitle("Tags")
.setDescription(
"Nucleus allows you to create tags, which allow a message to be sent when a specific tag is typed.\n" +
- `Tags can be created with ${getCommandMentionByName("tags/create")}, and can be edited with ${getCommandMentionByName("tags/edit")}\n` +
- `Tags can be deleted with ${getCommandMentionByName("tags/delete")}, and can be listed with ${getCommandMentionByName("tags/list")}\n` +
+ `Tags can be created with ${getCommandMentionByName(
+ "tags/create"
+ )}, and can be edited with ${getCommandMentionByName("tags/edit")}\n` +
+ `Tags can be deleted with ${getCommandMentionByName(
+ "tags/delete"
+ )}, and can be listed with ${getCommandMentionByName("tags/list")}\n` +
`To use a tag, you can type ${getCommandMentionByName("tag")}, followed by the tag to send`
)
.setEmoji("PUNISH.NICKNAME.RED")
@@ -177,9 +219,9 @@
.setTitle("Premium")
.setDescription(
"Nucleus Premium allows you to use extra features in your server, which are useful but not essential.\n" +
- "**No currently free commands will become premium features.**\n" +
- "Premium features include creating ticket transcripts and attachment logs.\n\n" +
- "Premium can be purchased in [our server](https://discord.gg/bPaNnxe) in the subscriptions page" // TODO: add a table graphic
+ "**No currently free commands will become premium features.**\n" +
+ "Premium features include creating ticket transcripts and attachment logs.\n\n" +
+ "Premium can be purchased in [our server](https://discord.gg/bPaNnxe) in the subscriptions page" // TODO: add a table graphic
)
.setEmoji("NUCLEUS.PREMIUM")
.setStatus("Danger")
@@ -203,10 +245,11 @@
if (selectPaneOpen) {
const options: Discord.StringSelectMenuOptionBuilder[] = [];
pages.forEach((embed) => {
- options.push(new Discord.StringSelectMenuOptionBuilder()
- .setLabel(embed.title)
- .setValue(embed.pageId.toString())
- .setDescription(embed.description || "")
+ options.push(
+ new Discord.StringSelectMenuOptionBuilder()
+ .setLabel(embed.title)
+ .setValue(embed.pageId.toString())
+ .setDescription(embed.description || "")
);
});
selectPane = [
@@ -257,7 +300,9 @@
try {
i = await m.awaitMessageComponent({
filter: interaction
- ? (i) => { return i.user.id === interaction.user.id && i.channel!.id === interaction.channel!.id }
+ ? (i) => {
+ return i.user.id === interaction.user.id && i.channel!.id === interaction.channel!.id;
+ }
: publicFilter,
time: 300000
});
diff --git a/src/reflex/scanners.ts b/src/reflex/scanners.ts
index cf713e6..71e63b4 100644
--- a/src/reflex/scanners.ts
+++ b/src/reflex/scanners.ts
@@ -17,10 +17,10 @@
export async function testNSFW(link: string): Promise<NSFWSchema> {
const [p, hash] = await saveAttachment(link);
- const alreadyHaveCheck = await client.database.scanCache.read(hash)
- if(alreadyHaveCheck) return { nsfw: alreadyHaveCheck.data };
+ const alreadyHaveCheck = await client.database.scanCache.read(hash);
+ if (alreadyHaveCheck) return { nsfw: alreadyHaveCheck.data };
const data = new URLSearchParams();
- const r = createReadStream(p)
+ const r = createReadStream(p);
data.append("file", r.read(fs.statSync(p).size));
const result = await fetch("https://unscan.p.rapidapi.com/", {
method: "POST",
@@ -30,12 +30,14 @@
},
body: data
})
- .then((response) => response.status === 200 ? response.json() as Promise<NSFWSchema> : { nsfw: false, errored: true })
+ .then((response) =>
+ response.status === 200 ? (response.json() as Promise<NSFWSchema>) : { nsfw: false, errored: true }
+ )
.catch((err) => {
console.error(err);
return { nsfw: false, errored: true };
});
- if(!result.errored) {
+ if (!result.errored) {
client.database.scanCache.write(hash, result.nsfw);
}
return { nsfw: result.nsfw };
@@ -43,8 +45,8 @@
export async function testMalware(link: string): Promise<MalwareSchema> {
const [p, hash] = await saveAttachment(link);
- const alreadyHaveCheck = await client.database.scanCache.read(hash)
- if(alreadyHaveCheck) return { safe: alreadyHaveCheck.data };
+ const alreadyHaveCheck = await client.database.scanCache.read(hash);
+ if (alreadyHaveCheck) return { safe: alreadyHaveCheck.data };
const data = new URLSearchParams();
const f = createReadStream(p);
data.append("file", f.read(fs.statSync(p).size));
@@ -56,7 +58,9 @@
},
body: data
})
- .then((response) => response.status === 200 ? response.json() as Promise<MalwareSchema> : { safe: true, errored: true })
+ .then((response) =>
+ response.status === 200 ? (response.json() as Promise<MalwareSchema>) : { safe: true, errored: true }
+ )
.catch((err) => {
console.error(err);
return { safe: true, errored: true };
@@ -68,8 +72,8 @@
}
export async function testLink(link: string): Promise<{ safe: boolean; tags: string[] }> {
- const alreadyHaveCheck = await client.database.scanCache.read(link)
- if(alreadyHaveCheck) return { safe: alreadyHaveCheck.data, tags: [] };
+ const alreadyHaveCheck = await client.database.scanCache.read(link);
+ if (alreadyHaveCheck) return { safe: alreadyHaveCheck.data, tags: [] };
const scanned: { safe?: boolean; tags?: string[] } = await fetch("https://unscan.p.rapidapi.com/link", {
method: "POST",
headers: {
@@ -91,11 +95,11 @@
}
export async function saveAttachment(link: string): Promise<[string, string]> {
- const image = await (await fetch(link)).arrayBuffer()
+ const image = await (await fetch(link)).arrayBuffer();
const fileName = generateFileName(link.split("/").pop()!.split(".").pop()!);
const enc = new TextDecoder("utf-8");
writeFileSync(fileName, new DataView(image), "base64");
- return [fileName, createHash('sha512').update(enc.decode(image), 'base64').digest('base64')];
+ return [fileName, createHash("sha512").update(enc.decode(image), "base64").digest("base64")];
}
const linkTypes = {
diff --git a/src/reflex/statsChannelUpdate.ts b/src/reflex/statsChannelUpdate.ts
index daa82fd..6c601f7 100644
--- a/src/reflex/statsChannelUpdate.ts
+++ b/src/reflex/statsChannelUpdate.ts
@@ -1,4 +1,4 @@
-import { getCommandMentionByName } from '../utils/getCommandDataByName.js';
+import { getCommandMentionByName } from "../utils/getCommandDataByName.js";
import type { Guild, User } from "discord.js";
import type { NucleusClient } from "../utils/client.js";
import type { GuildMember } from "discord.js";
@@ -32,8 +32,9 @@
return singleNotify(
"statsChannelDeleted",
guild!.id,
- `One or more of your stats channels have been deleted. You can use ${getCommandMentionByName("settings/stats")}.\n` +
- `The channels name was: ${deleted!.name}`,
+ `One or more of your stats channels have been deleted. You can use ${getCommandMentionByName(
+ "settings/stats"
+ )}.\n` + `The channels name was: ${deleted!.name}`,
"Critical"
);
}
diff --git a/src/reflex/verify.ts b/src/reflex/verify.ts
index 290e372..a5991de 100644
--- a/src/reflex/verify.ts
+++ b/src/reflex/verify.ts
@@ -122,7 +122,7 @@
});
if (
await NSFWCheck(
- (interaction.member as GuildMember).user.displayAvatarURL({extension: "png", forceStatic: true})
+ (interaction.member as GuildMember).user.displayAvatarURL({ extension: "png", forceStatic: true })
)
) {
return await interaction.editReply({
@@ -184,14 +184,14 @@
let itt = 0;
const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
do {
- itt ++;
+ itt++;
code = "";
for (let i = 0; i < length; i++) {
code += chars.charAt(Math.floor(Math.random() * chars.length));
}
if (itt > 1000) {
itt = 0;
- length ++;
+ length++;
}
} while (code in verify);
const role: Role | null = await interaction.guild!.roles.fetch(config.verify.role);
@@ -208,7 +208,14 @@
.setEmoji("CONTROL.BLOCKCROSS")
]
});
- singleNotify("verifyRoleDeleted", interaction.guild!.id, `The role given when a member is verified has been deleted. Use ${getCommandMentionByName("settings/verify")} to set a new one`, "Critical")
+ singleNotify(
+ "verifyRoleDeleted",
+ interaction.guild!.id,
+ `The role given when a member is verified has been deleted. Use ${getCommandMentionByName(
+ "settings/verify"
+ )} to set a new one`,
+ "Critical"
+ );
return;
}
verify[code] = {
diff --git a/src/reflex/welcome.ts b/src/reflex/welcome.ts
index c2eede3..5597b81 100644
--- a/src/reflex/welcome.ts
+++ b/src/reflex/welcome.ts
@@ -1,4 +1,4 @@
-import { getCommandMentionByName } from './../utils/getCommandDataByName.js';
+import { getCommandMentionByName } from "./../utils/getCommandDataByName.js";
import type { NucleusClient } from "../utils/client.js";
import convertCurlyBracketString from "../utils/convertCurlyBracketString.js";
import client from "../utils/client.js";
@@ -26,8 +26,18 @@
embeds: [new EmojiEmbed().setDescription(string).setStatus("Success")]
});
} else {
- const channel: GuildChannel | null = await member.guild.channels.fetch(config.welcome.channel) as GuildChannel | null;
- if (!channel) return await singleNotify("welcomeChannelDeleted", member.guild.id, `The welcome channel has been deleted or is no longer accessible. Use ${getCommandMentionByName("settings/welcome")} to set a new one`, "Warning")
+ const channel: GuildChannel | null = (await member.guild.channels.fetch(
+ config.welcome.channel
+ )) as GuildChannel | null;
+ if (!channel)
+ return await singleNotify(
+ "welcomeChannelDeleted",
+ member.guild.id,
+ `The welcome channel has been deleted or is no longer accessible. Use ${getCommandMentionByName(
+ "settings/welcome"
+ )} to set a new one`,
+ "Warning"
+ );
if (!(channel instanceof BaseGuildTextChannel)) return;
if (channel.guild.id !== member.guild.id) return;
try {
@@ -39,9 +49,11 @@
singleNotify(
"welcomeChannelDeleted",
member.guild.id,
- `The welcome channel has been deleted or is no longer accessible. Use ${getCommandMentionByName("settings/welcome")} to set a new one`,
+ `The welcome channel has been deleted or is no longer accessible. Use ${getCommandMentionByName(
+ "settings/welcome"
+ )} to set a new one`,
"Warning"
- )
+ );
}
}
}