Fix a bunch of linter errors
diff --git a/src/commands/settings/logs/_meta.ts b/src/commands/settings/logs/_meta.ts
index f46987f..fadff33 100644
--- a/src/commands/settings/logs/_meta.ts
+++ b/src/commands/settings/logs/_meta.ts
@@ -1,4 +1,4 @@
const name = "logs";
const description = "Settings for logging";
-export { name, description };
\ No newline at end of file
+export { name, description };
diff --git a/src/commands/settings/logs/attachment.ts b/src/commands/settings/logs/attachment.ts
index cb96567..f37bd1a 100644
--- a/src/commands/settings/logs/attachment.ts
+++ b/src/commands/settings/logs/attachment.ts
@@ -1,6 +1,10 @@
import { LoadingEmbed } from "./../../../utils/defaultEmbeds.js";
import { ChannelType } from "discord-api-types";
-import Discord, { CommandInteraction, MessageActionRow, MessageButton } from "discord.js";
+import Discord, {
+ CommandInteraction,
+ MessageActionRow,
+ MessageButton
+} from "discord.js";
import EmojiEmbed from "../../../utils/generateEmojiEmbed.js";
import confirmationMessage from "../../../utils/confirmationMessage.js";
import getEmojiByName from "../../../utils/getEmojiByName.js";
@@ -12,39 +16,59 @@
builder
.setName("attachments")
.setDescription("Where attachments should be logged to (Premium only)")
- .addChannelOption(option => option.setName("channel").setDescription("The channel to log attachments in").addChannelTypes([
- ChannelType.GuildNews, ChannelType.GuildText
- ]).setRequired(false));
+ .addChannelOption((option) =>
+ option
+ .setName("channel")
+ .setDescription("The channel to log attachments in")
+ .addChannelTypes([ChannelType.GuildNews, ChannelType.GuildText])
+ .setRequired(false)
+ );
-const callback = async (interaction: CommandInteraction): Promise<void | unknown> => {
- const m = await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true}) as Discord.Message;
+const callback = async (
+ interaction: CommandInteraction
+): Promise<void | unknown> => {
+ const m = (await interaction.reply({
+ embeds: LoadingEmbed,
+ ephemeral: true,
+ fetchReply: true
+ })) as Discord.Message;
if (interaction.options.getChannel("channel")) {
let channel;
try {
channel = interaction.options.getChannel("channel");
} catch {
- return await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("CHANNEL.TEXT.DELETE")
- .setTitle("Attachment Log Channel")
- .setDescription("The channel you provided is not a valid channel")
- .setStatus("Danger")
- ]});
+ return await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("CHANNEL.TEXT.DELETE")
+ .setTitle("Attachment Log Channel")
+ .setDescription(
+ "The channel you provided is not a valid channel"
+ )
+ .setStatus("Danger")
+ ]
+ });
}
channel = channel as Discord.TextChannel;
if (channel.guild.id !== interaction.guild.id) {
- return interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Attachment Log Channel")
- .setDescription("You must choose a channel in this server")
- .setStatus("Danger")
- .setEmoji("CHANNEL.TEXT.DELETE")
- ]});
+ return interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Attachment Log Channel")
+ .setDescription(
+ "You must choose a channel in this server"
+ )
+ .setStatus("Danger")
+ .setEmoji("CHANNEL.TEXT.DELETE")
+ ]
+ });
}
const confirmation = await new confirmationMessage(interaction)
.setEmoji("CHANNEL.TEXT.EDIT")
.setTitle("Attachment Log Channel")
.setDescription(
"This will be the channel all attachments will be sent to.\n\n" +
- `Are you sure you want to set the attachment log channel to <#${channel.id}>?`
+ `Are you sure you want to set the attachment log channel to <#${channel.id}>?`
)
.setColor("Warning")
.setInverted(true)
@@ -52,10 +76,13 @@
if (confirmation.cancelled) return;
if (confirmation.success) {
try {
- await client.database.guilds.write(interaction.guild.id, {"logging.attachments.channel": channel.id});
- const { log, NucleusColors, entry, renderUser, renderChannel } = client.logger;
+ await client.database.guilds.write(interaction.guild.id, {
+ "logging.attachments.channel": channel.id
+ });
+ const { log, NucleusColors, entry, renderUser, renderChannel } =
+ client.logger;
const data = {
- meta:{
+ meta: {
type: "attachmentChannelUpdate",
displayName: "Attachment Log Channel Updated",
calculateType: "nucleusSettingsUpdated",
@@ -64,8 +91,14 @@
timestamp: new Date().getTime()
},
list: {
- memberId: entry(interaction.user.id, `\`${interaction.user.id}\``),
- changedBy: entry(interaction.user.id, renderUser(interaction.user)),
+ memberId: entry(
+ interaction.user.id,
+ `\`${interaction.user.id}\``
+ ),
+ changedBy: entry(
+ interaction.user.id,
+ renderUser(interaction.user)
+ ),
channel: entry(channel.id, renderChannel(channel))
},
hidden: {
@@ -74,75 +107,124 @@
};
log(data);
} catch (e) {
- return interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Attachment Log Channel")
- .setDescription("Something went wrong and the attachment log channel could not be set")
- .setStatus("Danger")
- .setEmoji("CHANNEL.TEXT.DELETE")
- ], components: []});
+ return interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Attachment Log Channel")
+ .setDescription(
+ "Something went wrong and the attachment log channel could not be set"
+ )
+ .setStatus("Danger")
+ .setEmoji("CHANNEL.TEXT.DELETE")
+ ],
+ components: []
+ });
}
} else {
- return interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Attachment Log Channel")
- .setDescription("No changes were made")
- .setStatus("Success")
- .setEmoji("CHANNEL.TEXT.CREATE")
- ], components: []});
+ return interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Attachment Log Channel")
+ .setDescription("No changes were made")
+ .setStatus("Success")
+ .setEmoji("CHANNEL.TEXT.CREATE")
+ ],
+ components: []
+ });
}
}
let clicks = 0;
const data = await client.database.guilds.read(interaction.guild.id);
let channel = data.logging.staff.channel;
while (true) {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Attachment Log Channel")
- .setDescription(
- channel ? `Your attachment log channel is currently set to <#${channel}>` : "This server does not have an attachment log channel" +
- (client.database.premium.hasPremium(interaction.guild.id) ? "" : "\n\nThis server does not have premium, so this feature is disabled")
- )
- .setStatus("Success")
- .setEmoji("CHANNEL.TEXT.CREATE")
- ], components: [new MessageActionRow().addComponents([new MessageButton()
- .setCustomId("clear")
- .setLabel(clicks ? "Click again to confirm" : "Reset channel")
- .setEmoji(getEmojiByName(clicks ? "TICKETS.ISSUE" : "CONTROL.CROSS", "id"))
- .setStyle("DANGER")
- .setDisabled(!channel)
- ])]});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Attachment Log Channel")
+ .setDescription(
+ channel
+ ? `Your attachment log channel is currently set to <#${channel}>`
+ : "This server does not have an attachment log channel" +
+ (client.database.premium.hasPremium(
+ interaction.guild.id
+ )
+ ? ""
+ : "\n\nThis server does not have premium, so this feature is disabled")
+ )
+ .setStatus("Success")
+ .setEmoji("CHANNEL.TEXT.CREATE")
+ ],
+ components: [
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setCustomId("clear")
+ .setLabel(
+ clicks ? "Click again to confirm" : "Reset channel"
+ )
+ .setEmoji(
+ getEmojiByName(
+ clicks ? "TICKETS.ISSUE" : "CONTROL.CROSS",
+ "id"
+ )
+ )
+ .setStyle("DANGER")
+ .setDisabled(!channel)
+ ])
+ ]
+ });
let i;
try {
- i = await m.awaitMessageComponent({time: 300000});
- } catch(e) { break; }
+ i = await m.awaitMessageComponent({ time: 300000 });
+ } catch (e) {
+ break;
+ }
i.deferUpdate();
if (i.component.customId === "clear") {
clicks += 1;
if (clicks === 2) {
clicks = 0;
- await client.database.guilds.write(interaction.guild.id, null, ["logging.announcements.channel"]);
+ await client.database.guilds.write(interaction.guild.id, null, [
+ "logging.announcements.channel"
+ ]);
channel = undefined;
}
} else {
break;
}
}
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Attachment Log Channel")
- .setDescription(channel ? `Your attachment log channel is currently set to <#${channel}>` : "This server does not have an attachment log channel")
- .setStatus("Success")
- .setEmoji("CHANNEL.TEXT.CREATE")
- .setFooter({text: "Message closed"})
- ], components: [new MessageActionRow().addComponents([new MessageButton()
- .setCustomId("clear")
- .setLabel("Clear")
- .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
- .setStyle("SECONDARY")
- .setDisabled(true)
- ])]});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Attachment Log Channel")
+ .setDescription(
+ channel
+ ? `Your attachment log channel is currently set to <#${channel}>`
+ : "This server does not have an attachment log channel"
+ )
+ .setStatus("Success")
+ .setEmoji("CHANNEL.TEXT.CREATE")
+ .setFooter({ text: "Message closed" })
+ ],
+ components: [
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setCustomId("clear")
+ .setLabel("Clear")
+ .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
+ .setStyle("SECONDARY")
+ .setDisabled(true)
+ ])
+ ]
+ });
};
-const check = (interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
- const member = (interaction.member as Discord.GuildMember);
- if (!member.permissions.has("MANAGE_GUILD")) throw "You must have the *Manage Server* permission to use this command";
+const check = (
+ interaction: CommandInteraction,
+ _defaultCheck: WrappedCheck
+) => {
+ const member = interaction.member as Discord.GuildMember;
+ if (!member.permissions.has("MANAGE_GUILD"))
+ throw "You must have the *Manage Server* permission to use this command";
return true;
};
diff --git a/src/commands/settings/logs/channel.ts b/src/commands/settings/logs/channel.ts
index 4d4a392..00d2411 100644
--- a/src/commands/settings/logs/channel.ts
+++ b/src/commands/settings/logs/channel.ts
@@ -1,6 +1,10 @@
import { LoadingEmbed } from "./../../../utils/defaultEmbeds.js";
import { ChannelType } from "discord-api-types";
-import Discord, { CommandInteraction, MessageActionRow, MessageButton } from "discord.js";
+import Discord, {
+ CommandInteraction,
+ MessageActionRow,
+ MessageButton
+} from "discord.js";
import EmojiEmbed from "../../../utils/generateEmojiEmbed.js";
import confirmationMessage from "../../../utils/confirmationMessage.js";
import getEmojiByName from "../../../utils/getEmojiByName.js";
@@ -12,47 +16,71 @@
builder
.setName("channel")
.setDescription("Sets or shows the log channel")
- .addChannelOption(option => option.setName("channel").setDescription("The channel to set the log channel to").addChannelTypes([
- ChannelType.GuildNews, ChannelType.GuildText
- ]));
+ .addChannelOption((option) =>
+ option
+ .setName("channel")
+ .setDescription("The channel to set the log channel to")
+ .addChannelTypes([ChannelType.GuildNews, ChannelType.GuildText])
+ );
-const callback = async (interaction: CommandInteraction): Promise<void | unknown> => {
- const m = await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true}) as Discord.Message;
+const callback = async (
+ interaction: CommandInteraction
+): Promise<void | unknown> => {
+ const m = (await interaction.reply({
+ embeds: LoadingEmbed,
+ ephemeral: true,
+ fetchReply: true
+ })) as Discord.Message;
if (interaction.options.getChannel("channel")) {
let channel;
try {
channel = interaction.options.getChannel("channel");
} catch {
- return await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("CHANNEL.TEXT.DELETE")
- .setTitle("Log Channel")
- .setDescription("The channel you provided is not a valid channel")
- .setStatus("Danger")
- ]});
+ return await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("CHANNEL.TEXT.DELETE")
+ .setTitle("Log Channel")
+ .setDescription(
+ "The channel you provided is not a valid channel"
+ )
+ .setStatus("Danger")
+ ]
+ });
}
channel = channel as Discord.TextChannel;
if (channel.guild.id !== interaction.guild.id) {
- return interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Log Channel")
- .setDescription("You must choose a channel in this server")
- .setStatus("Danger")
- .setEmoji("CHANNEL.TEXT.DELETE")
- ]});
+ return interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Log Channel")
+ .setDescription(
+ "You must choose a channel in this server"
+ )
+ .setStatus("Danger")
+ .setEmoji("CHANNEL.TEXT.DELETE")
+ ]
+ });
}
const confirmation = await new confirmationMessage(interaction)
.setEmoji("CHANNEL.TEXT.EDIT")
.setTitle("Log Channel")
- .setDescription(`Are you sure you want to set the log channel to <#${channel.id}>?`)
+ .setDescription(
+ `Are you sure you want to set the log channel to <#${channel.id}>?`
+ )
.setColor("Warning")
.setInverted(true)
.send(true);
if (confirmation.cancelled) return;
if (confirmation.success) {
try {
- await client.database.guilds.write(interaction.guild.id, {"logging.logs.channel": channel.id});
- const { log, NucleusColors, entry, renderUser, renderChannel } = client.logger;
+ await client.database.guilds.write(interaction.guild.id, {
+ "logging.logs.channel": channel.id
+ });
+ const { log, NucleusColors, entry, renderUser, renderChannel } =
+ client.logger;
const data = {
- meta:{
+ meta: {
type: "logChannelUpdate",
displayName: "Log Channel Changed",
calculateType: "nucleusSettingsUpdated",
@@ -61,8 +89,14 @@
timestamp: new Date().getTime()
},
list: {
- memberId: entry(interaction.user.id, `\`${interaction.user.id}\``),
- changedBy: entry(interaction.user.id, renderUser(interaction.user)),
+ memberId: entry(
+ interaction.user.id,
+ `\`${interaction.user.id}\``
+ ),
+ changedBy: entry(
+ interaction.user.id,
+ renderUser(interaction.user)
+ ),
channel: entry(channel.id, renderChannel(channel))
},
hidden: {
@@ -72,72 +106,119 @@
log(data);
} catch (e) {
console.log(e);
- return interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Log Channel")
- .setDescription("Something went wrong and the log channel could not be set")
- .setStatus("Danger")
- .setEmoji("CHANNEL.TEXT.DELETE")
- ], components: []});
+ return interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Log Channel")
+ .setDescription(
+ "Something went wrong and the log channel could not be set"
+ )
+ .setStatus("Danger")
+ .setEmoji("CHANNEL.TEXT.DELETE")
+ ],
+ components: []
+ });
}
} else {
- return interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Log Channel")
- .setDescription("No changes were made")
- .setStatus("Success")
- .setEmoji("CHANNEL.TEXT.CREATE")
- ], components: []});
+ return interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Log Channel")
+ .setDescription("No changes were made")
+ .setStatus("Success")
+ .setEmoji("CHANNEL.TEXT.CREATE")
+ ],
+ components: []
+ });
}
}
let clicks = 0;
const data = await client.database.guilds.read(interaction.guild.id);
let channel = data.logging.logs.channel;
while (true) {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Log channel")
- .setDescription(channel ? `Your log channel is currently set to <#${channel}>` : "This server does not have a log channel")
- .setStatus("Success")
- .setEmoji("CHANNEL.TEXT.CREATE")
- ], components: [new MessageActionRow().addComponents([new MessageButton()
- .setCustomId("clear")
- .setLabel(clicks ? "Click again to confirm" : "Reset channel")
- .setEmoji(getEmojiByName(clicks ? "TICKETS.ISSUE" : "CONTROL.CROSS", "id"))
- .setStyle("DANGER")
- .setDisabled(!channel)
- ])]});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Log channel")
+ .setDescription(
+ channel
+ ? `Your log channel is currently set to <#${channel}>`
+ : "This server does not have a log channel"
+ )
+ .setStatus("Success")
+ .setEmoji("CHANNEL.TEXT.CREATE")
+ ],
+ components: [
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setCustomId("clear")
+ .setLabel(
+ clicks ? "Click again to confirm" : "Reset channel"
+ )
+ .setEmoji(
+ getEmojiByName(
+ clicks ? "TICKETS.ISSUE" : "CONTROL.CROSS",
+ "id"
+ )
+ )
+ .setStyle("DANGER")
+ .setDisabled(!channel)
+ ])
+ ]
+ });
let i;
try {
- i = await m.awaitMessageComponent({time: 300000});
- } catch(e) { break; }
+ i = await m.awaitMessageComponent({ time: 300000 });
+ } catch (e) {
+ break;
+ }
i.deferUpdate();
if (i.component.customId === "clear") {
clicks += 1;
if (clicks === 2) {
clicks = 0;
- await client.database.guilds.write(interaction.guild.id, null, ["logging.logs.channel"]);
+ await client.database.guilds.write(interaction.guild.id, null, [
+ "logging.logs.channel"
+ ]);
channel = undefined;
}
} else {
break;
}
}
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Log channel")
- .setDescription(channel ? `Your log channel is currently set to <#${channel}>` : "This server does not have a log channel")
- .setStatus("Success")
- .setEmoji("CHANNEL.TEXT.CREATE")
- .setFooter({text: "Message closed"})
- ], components: [new MessageActionRow().addComponents([new MessageButton()
- .setCustomId("clear")
- .setLabel("Clear")
- .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
- .setStyle("SECONDARY")
- .setDisabled(true)
- ])]});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Log channel")
+ .setDescription(
+ channel
+ ? `Your log channel is currently set to <#${channel}>`
+ : "This server does not have a log channel"
+ )
+ .setStatus("Success")
+ .setEmoji("CHANNEL.TEXT.CREATE")
+ .setFooter({ text: "Message closed" })
+ ],
+ components: [
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setCustomId("clear")
+ .setLabel("Clear")
+ .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
+ .setStyle("SECONDARY")
+ .setDisabled(true)
+ ])
+ ]
+ });
};
-const check = (interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
- const member = (interaction.member as Discord.GuildMember);
- if (!member.permissions.has("MANAGE_GUILD")) throw "You must have the *Manage Server* permission to use this command";
+const check = (
+ interaction: CommandInteraction,
+ _defaultCheck: WrappedCheck
+) => {
+ const member = interaction.member as Discord.GuildMember;
+ if (!member.permissions.has("MANAGE_GUILD"))
+ throw "You must have the *Manage Server* permission to use this command";
return true;
};
diff --git a/src/commands/settings/logs/events.ts b/src/commands/settings/logs/events.ts
index 110c70e..a1edcaf 100644
--- a/src/commands/settings/logs/events.ts
+++ b/src/commands/settings/logs/events.ts
@@ -1,33 +1,37 @@
import { LoadingEmbed } from "./../../../utils/defaultEmbeds.js";
-import Discord, { CommandInteraction, MessageActionRow, MessageButton, MessageSelectMenu } from "discord.js";
+import Discord, {
+ CommandInteraction,
+ MessageActionRow,
+ MessageButton,
+ MessageSelectMenu
+} from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
import EmojiEmbed from "../../../utils/generateEmojiEmbed.js";
import client from "../../../utils/client.js";
import { toHexArray, toHexInteger } from "../../../utils/calculate.js";
-
const logs = {
- "channelUpdate": "Channels created, deleted or modified",
- "emojiUpdate": "Server emojis modified",
- "stickerUpdate": "Server stickers modified",
- "guildUpdate": "Server settings updated",
- "guildMemberUpdate": "Member updated (i.e. nickname)",
- "guildMemberPunish": "Members punished (i.e. muted, banned, kicked)",
- "guildRoleUpdate": "Role settings changed",
- "guildInviteUpdate": "Server invite created or deleted",
- "messageUpdate": "Message edited",
- "messageDelete": "Message deleted",
- "messageDeleteBulk": "Messages purged",
- "messageReactionUpdate": "Message reactions cleared",
- "messageMassPing": "Message pings multiple members at once",
- "messageAnnounce": "Message published in announcement channel",
- "threadUpdate": "Thread created or deleted",
- "webhookUpdate": "Webhooks created or deleted",
- "guildMemberVerify": "Member runs verify",
- "autoModeratorDeleted": "Messages auto deleted by Nucleus",
- "nucleusSettingsUpdated": "Nucleus' settings updated by a moderator",
- "ticketUpdate": "Tickets created or deleted"
+ channelUpdate: "Channels created, deleted or modified",
+ emojiUpdate: "Server emojis modified",
+ stickerUpdate: "Server stickers modified",
+ guildUpdate: "Server settings updated",
+ guildMemberUpdate: "Member updated (i.e. nickname)",
+ guildMemberPunish: "Members punished (i.e. muted, banned, kicked)",
+ guildRoleUpdate: "Role settings changed",
+ guildInviteUpdate: "Server invite created or deleted",
+ messageUpdate: "Message edited",
+ messageDelete: "Message deleted",
+ messageDeleteBulk: "Messages purged",
+ messageReactionUpdate: "Message reactions cleared",
+ messageMassPing: "Message pings multiple members at once",
+ messageAnnounce: "Message published in announcement channel",
+ threadUpdate: "Thread created or deleted",
+ webhookUpdate: "Webhooks created or deleted",
+ guildMemberVerify: "Member runs verify",
+ autoModeratorDeleted: "Messages auto deleted by Nucleus",
+ nucleusSettingsUpdated: "Nucleus' settings updated by a moderator",
+ ticketUpdate: "Tickets created or deleted"
};
const command = (builder: SlashCommandSubcommandBuilder) =>
@@ -36,39 +40,52 @@
.setDescription("Sets what events should be logged");
const callback = async (interaction: CommandInteraction): Promise<void> => {
- await interaction.reply({embeds: LoadingEmbed, fetchReply: true, ephemeral: true});
+ await interaction.reply({
+ embeds: LoadingEmbed,
+ fetchReply: true,
+ ephemeral: true
+ });
let m;
while (true) {
const config = await client.database.guilds.read(interaction.guild.id);
const converted = toHexArray(config.logging.logs.toLog);
- m = await interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Logging Events")
- .setDescription("Below are the events being logged in the server. You can toggle them on and off in the dropdown")
- .setStatus("Success")
- .setEmoji("CHANNEL.TEXT.CREATE")
- ], components: [
- new MessageActionRow().addComponents([new MessageSelectMenu()
- .setPlaceholder("Set events to log")
- .setMaxValues(Object.keys(logs).length)
- .setCustomId("logs")
- .setMinValues(0)
- .setOptions(Object.keys(logs).map((e, i) => ({
- label: logs[e],
- value: i.toString(),
- default: converted.includes(e)
- })))
- ]),
- new MessageActionRow().addComponents([
- new MessageButton()
- .setLabel("Select all")
- .setStyle("PRIMARY")
- .setCustomId("all"),
- new MessageButton()
- .setLabel("Select none")
- .setStyle("DANGER")
- .setCustomId("none")
- ])
- ]});
+ m = await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Logging Events")
+ .setDescription(
+ "Below are the events being logged in the server. You can toggle them on and off in the dropdown"
+ )
+ .setStatus("Success")
+ .setEmoji("CHANNEL.TEXT.CREATE")
+ ],
+ components: [
+ new MessageActionRow().addComponents([
+ new MessageSelectMenu()
+ .setPlaceholder("Set events to log")
+ .setMaxValues(Object.keys(logs).length)
+ .setCustomId("logs")
+ .setMinValues(0)
+ .setOptions(
+ Object.keys(logs).map((e, i) => ({
+ label: logs[e],
+ value: i.toString(),
+ default: converted.includes(e)
+ }))
+ )
+ ]),
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setLabel("Select all")
+ .setStyle("PRIMARY")
+ .setCustomId("all"),
+ new MessageButton()
+ .setLabel("Select none")
+ .setStyle("DANGER")
+ .setCustomId("none")
+ ])
+ ]
+ });
let i;
try {
i = await m.awaitMessageComponent({ time: 300000 });
@@ -78,33 +95,50 @@
i.deferUpdate();
if (i.customId === "logs") {
const selected = i.values;
- const newLogs = toHexInteger(selected.map(e => Object.keys(logs)[parseInt(e)]));
- await client.database.guilds.write(interaction.guild.id, {"logging.logs.toLog": newLogs});
+ const newLogs = toHexInteger(
+ selected.map((e) => Object.keys(logs)[parseInt(e)])
+ );
+ await client.database.guilds.write(interaction.guild.id, {
+ "logging.logs.toLog": newLogs
+ });
} else if (i.customId === "all") {
- const newLogs = toHexInteger(Object.keys(logs).map(e => e));
- await client.database.guilds.write(interaction.guild.id, {"logging.logs.toLog": newLogs});
+ const newLogs = toHexInteger(Object.keys(logs).map((e) => e));
+ await client.database.guilds.write(interaction.guild.id, {
+ "logging.logs.toLog": newLogs
+ });
} else if (i.customId === "none") {
- await client.database.guilds.write(interaction.guild.id, {"logging.logs.toLog": 0});
+ await client.database.guilds.write(interaction.guild.id, {
+ "logging.logs.toLog": 0
+ });
} else {
break;
}
}
- m = await interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Logging Events")
- .setDescription("Below are the events being logged in the server. You can toggle them on and off in the dropdown")
- .setFooter({text: "Message timed out"})
- .setStatus("Success")
- .setEmoji("CHANNEL.TEXT.CREATE")
- ]});
+ m = await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Logging Events")
+ .setDescription(
+ "Below are the events being logged in the server. You can toggle them on and off in the dropdown"
+ )
+ .setFooter({ text: "Message timed out" })
+ .setStatus("Success")
+ .setEmoji("CHANNEL.TEXT.CREATE")
+ ]
+ });
return;
};
-const check = (interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
- const member = (interaction.member as Discord.GuildMember);
- if (!member.permissions.has("MANAGE_GUILD")) throw "You must have the *Manage Server* permission to use this command";
+const check = (
+ interaction: CommandInteraction,
+ _defaultCheck: WrappedCheck
+) => {
+ const member = interaction.member as Discord.GuildMember;
+ if (!member.permissions.has("MANAGE_GUILD"))
+ throw "You must have the *Manage Server* permission to use this command";
return true;
};
export { command };
export { callback };
-export { check };
\ No newline at end of file
+export { check };
diff --git a/src/commands/settings/logs/staff.ts b/src/commands/settings/logs/staff.ts
index 2f0c819..718d13b 100644
--- a/src/commands/settings/logs/staff.ts
+++ b/src/commands/settings/logs/staff.ts
@@ -1,12 +1,16 @@
import { LoadingEmbed } from "./../../../utils/defaultEmbeds.js";
import { ChannelType } from "discord-api-types";
-import Discord, { CommandInteraction, MessageActionRow, MessageButton } from "discord.js";
+import Discord, {
+ CommandInteraction,
+ MessageActionRow,
+ MessageButton
+} from "discord.js";
import EmojiEmbed from "../../../utils/generateEmojiEmbed.js";
import confirmationMessage from "../../../utils/confirmationMessage.js";
import getEmojiByName from "../../../utils/getEmojiByName.js";
import type { SlashCommandSubcommandBuilder } from "@discordjs/builders";
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
-// @ts-ignore
+// @ts-expect-error
import type { WrappedCheck } from "jshaiku";
import client from "../../../utils/client.js";
@@ -14,40 +18,62 @@
builder
.setName("staff")
.setDescription("Settings for the staff notifications channel")
- .addChannelOption(option => option.setName("channel").setDescription("The channel to set the staff notifications channel to").addChannelTypes([
- ChannelType.GuildNews, ChannelType.GuildText
- ]).setRequired(false));
+ .addChannelOption((option) =>
+ option
+ .setName("channel")
+ .setDescription(
+ "The channel to set the staff notifications channel to"
+ )
+ .addChannelTypes([ChannelType.GuildNews, ChannelType.GuildText])
+ .setRequired(false)
+ );
-const callback = async (interaction: CommandInteraction): Promise<unknown | void> => {
+const callback = async (
+ interaction: CommandInteraction
+): Promise<unknown | void> => {
if (!interaction.guild) return;
- const m = await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true}) as Discord.Message<boolean>;
+ const m = (await interaction.reply({
+ embeds: LoadingEmbed,
+ ephemeral: true,
+ fetchReply: true
+ })) as Discord.Message;
if (interaction.options.getChannel("channel")) {
let channel;
try {
channel = interaction.options.getChannel("channel");
} catch {
- return await interaction.editReply({embeds: [new EmojiEmbed()
- .setEmoji("CHANNEL.TEXT.DELETE")
- .setTitle("Staff Notifications Channel")
- .setDescription("The channel you provided is not a valid channel")
- .setStatus("Danger")
- ]});
+ return await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setEmoji("CHANNEL.TEXT.DELETE")
+ .setTitle("Staff Notifications Channel")
+ .setDescription(
+ "The channel you provided is not a valid channel"
+ )
+ .setStatus("Danger")
+ ]
+ });
}
channel = channel as Discord.TextChannel;
if (channel.guild.id !== interaction.guild.id) {
- return interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Staff Notifications Channel")
- .setDescription("You must choose a channel in this server")
- .setStatus("Danger")
- .setEmoji("CHANNEL.TEXT.DELETE")
- ]});
+ return interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Staff Notifications Channel")
+ .setDescription(
+ "You must choose a channel in this server"
+ )
+ .setStatus("Danger")
+ .setEmoji("CHANNEL.TEXT.DELETE")
+ ]
+ });
}
const confirmation = await new confirmationMessage(interaction)
.setEmoji("CHANNEL.TEXT.EDIT")
.setTitle("Staff Notifications Channel")
.setDescription(
"This will be the channel all notifications, updates, user reports etc. will be sent to.\n\n" +
- `Are you sure you want to set the staff notifications channel to <#${channel.id}>?`
+ `Are you sure you want to set the staff notifications channel to <#${channel.id}>?`
)
.setColor("Warning")
.setInverted(true)
@@ -55,10 +81,13 @@
if (confirmation.cancelled) return;
if (confirmation.success) {
try {
- await client.database.guilds.write(interaction.guild.id, {"logging.staff.channel": channel.id});
- const { log, NucleusColors, entry, renderUser, renderChannel } = client.logger;
+ await client.database.guilds.write(interaction.guild.id, {
+ "logging.staff.channel": channel.id
+ });
+ const { log, NucleusColors, entry, renderUser, renderChannel } =
+ client.logger;
const data = {
- meta:{
+ meta: {
type: "staffChannelUpdate",
displayName: "Staff Notifications Channel Updated",
calculateType: "nucleusSettingsUpdated",
@@ -67,8 +96,14 @@
timestamp: new Date().getTime()
},
list: {
- memberId: entry(interaction.user.id, `\`${interaction.user.id}\``),
- changedBy: entry(interaction.user.id, renderUser(interaction.user)),
+ memberId: entry(
+ interaction.user.id,
+ `\`${interaction.user.id}\``
+ ),
+ changedBy: entry(
+ interaction.user.id,
+ renderUser(interaction.user)
+ ),
channel: entry(channel.id, renderChannel(channel))
},
hidden: {
@@ -77,72 +112,119 @@
};
log(data);
} catch (e) {
- return interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Staff Notifications Channel")
- .setDescription("Something went wrong and the staff notifications channel could not be set")
- .setStatus("Danger")
- .setEmoji("CHANNEL.TEXT.DELETE")
- ], components: []});
+ return interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Staff Notifications Channel")
+ .setDescription(
+ "Something went wrong and the staff notifications channel could not be set"
+ )
+ .setStatus("Danger")
+ .setEmoji("CHANNEL.TEXT.DELETE")
+ ],
+ components: []
+ });
}
} else {
- return interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Staff Notifications Channel")
- .setDescription("No changes were made")
- .setStatus("Success")
- .setEmoji("CHANNEL.TEXT.CREATE")
- ], components: []});
+ return interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Staff Notifications Channel")
+ .setDescription("No changes were made")
+ .setStatus("Success")
+ .setEmoji("CHANNEL.TEXT.CREATE")
+ ],
+ components: []
+ });
}
}
let clicks = 0;
const data = await client.database.guilds.read(interaction.guild.id);
let channel = data.logging.staff.channel;
while (true) {
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Staff Notifications channel")
- .setDescription(channel ? `Your staff notifications channel is currently set to <#${channel}>` : "This server does not have a staff notifications channel")
- .setStatus("Success")
- .setEmoji("CHANNEL.TEXT.CREATE")
- ], components: [new MessageActionRow().addComponents([new MessageButton()
- .setCustomId("clear")
- .setLabel(clicks ? "Click again to confirm" : "Reset channel")
- .setEmoji(getEmojiByName(clicks ? "TICKETS.ISSUE" : "CONTROL.CROSS", "id"))
- .setStyle("DANGER")
- .setDisabled(!channel)
- ])]});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Staff Notifications channel")
+ .setDescription(
+ channel
+ ? `Your staff notifications channel is currently set to <#${channel}>`
+ : "This server does not have a staff notifications channel"
+ )
+ .setStatus("Success")
+ .setEmoji("CHANNEL.TEXT.CREATE")
+ ],
+ components: [
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setCustomId("clear")
+ .setLabel(
+ clicks ? "Click again to confirm" : "Reset channel"
+ )
+ .setEmoji(
+ getEmojiByName(
+ clicks ? "TICKETS.ISSUE" : "CONTROL.CROSS",
+ "id"
+ )
+ )
+ .setStyle("DANGER")
+ .setDisabled(!channel)
+ ])
+ ]
+ });
let i;
try {
- i = await m.awaitMessageComponent({time: 300000});
- } catch(e) { break; }
+ i = await m.awaitMessageComponent({ time: 300000 });
+ } catch (e) {
+ break;
+ }
i.deferUpdate();
if ((i.component as MessageButton).customId === "clear") {
clicks += 1;
if (clicks === 2) {
clicks = 0;
- await client.database.guilds.write(interaction.guild.id, null, ["logging.staff.channel"]);
+ await client.database.guilds.write(interaction.guild.id, null, [
+ "logging.staff.channel"
+ ]);
channel = undefined;
}
} else {
break;
}
}
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Staff Notifications channel")
- .setDescription(channel ? `Your staff notifications channel is currently set to <#${channel}>` : "This server does not have a staff notifications channel")
- .setStatus("Success")
- .setEmoji("CHANNEL.TEXT.CREATE")
- .setFooter({text: "Message closed"})
- ], components: [new MessageActionRow().addComponents([new MessageButton()
- .setCustomId("clear")
- .setLabel("Clear")
- .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
- .setStyle("SECONDARY")
- .setDisabled(true)
- ])]});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Staff Notifications channel")
+ .setDescription(
+ channel
+ ? `Your staff notifications channel is currently set to <#${channel}>`
+ : "This server does not have a staff notifications channel"
+ )
+ .setStatus("Success")
+ .setEmoji("CHANNEL.TEXT.CREATE")
+ .setFooter({ text: "Message closed" })
+ ],
+ components: [
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setCustomId("clear")
+ .setLabel("Clear")
+ .setEmoji(getEmojiByName("CONTROL.CROSS", "id"))
+ .setStyle("SECONDARY")
+ .setDisabled(true)
+ ])
+ ]
+ });
};
-const check = (interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
- const member = (interaction.member as Discord.GuildMember);
- if (!member.permissions.has("MANAGE_GUILD")) throw "You must have the *Manage Server* permission to use this command";
+const check = (
+ interaction: CommandInteraction,
+ _defaultCheck: WrappedCheck
+) => {
+ const member = interaction.member as Discord.GuildMember;
+ if (!member.permissions.has("MANAGE_GUILD"))
+ throw "You must have the *Manage Server* permission to use this command";
return true;
};