Fix some more eslint & ts errors
diff --git a/src/commands/mod/info.ts b/src/commands/mod/info.ts
index 86a4c4a..9837273 100644
--- a/src/commands/mod/info.ts
+++ b/src/commands/mod/info.ts
@@ -1,4 +1,4 @@
-import { HistorySchema } from "../../utils/database";
+import { HistorySchema } from "../../utils/database.js";
import Discord, {
CommandInteraction,
GuildMember,
diff --git a/src/commands/mod/mute.ts b/src/commands/mod/mute.ts
index 5be6f43..b430191 100644
--- a/src/commands/mod/mute.ts
+++ b/src/commands/mod/mute.ts
@@ -71,17 +71,15 @@
.setRequired(false)
);
-const callback = async (
- interaction: CommandInteraction
-): Promise<void | unknown> => {
+const callback = async (interaction: CommandInteraction): Promise<unknown> => {
const { log, NucleusColors, renderUser, entry, renderDelta } =
client.logger;
const user = interaction.options.getMember("user") as GuildMember;
const time = {
- days: interaction.options.getInteger("days") || 0,
- hours: interaction.options.getInteger("hours") || 0,
- minutes: interaction.options.getInteger("minutes") || 0,
- seconds: interaction.options.getInteger("seconds") || 0
+ days: interaction.options.getInteger("days") ?? 0,
+ hours: interaction.options.getInteger("hours") ?? 0,
+ minutes: interaction.options.getInteger("minutes") ?? 0,
+ seconds: interaction.options.getInteger("seconds") ?? 0
};
const config = await client.database.guilds.read(interaction.guild.id);
let serverSettingsDescription = config.moderation.mute.timeout
diff --git a/src/commands/settings/logs/attachment.ts b/src/commands/settings/logs/attachment.ts
index f37bd1a..ea8aa51 100644
--- a/src/commands/settings/logs/attachment.ts
+++ b/src/commands/settings/logs/attachment.ts
@@ -1,5 +1,5 @@
import { LoadingEmbed } from "./../../../utils/defaultEmbeds.js";
-import { ChannelType } from "discord-api-types";
+import { ChannelType } from "discord-api-types/v9";
import Discord, {
CommandInteraction,
MessageActionRow,
diff --git a/src/commands/settings/logs/channel.ts b/src/commands/settings/logs/channel.ts
index 00d2411..fd64424 100644
--- a/src/commands/settings/logs/channel.ts
+++ b/src/commands/settings/logs/channel.ts
@@ -1,5 +1,5 @@
import { LoadingEmbed } from "./../../../utils/defaultEmbeds.js";
-import { ChannelType } from "discord-api-types";
+import { ChannelType } from "discord-api-types/v9";
import Discord, {
CommandInteraction,
MessageActionRow,
diff --git a/src/commands/settings/logs/staff.ts b/src/commands/settings/logs/staff.ts
index 718d13b..a0df97c 100644
--- a/src/commands/settings/logs/staff.ts
+++ b/src/commands/settings/logs/staff.ts
@@ -1,5 +1,5 @@
import { LoadingEmbed } from "./../../../utils/defaultEmbeds.js";
-import { ChannelType } from "discord-api-types";
+import { ChannelType } from "discord-api-types/v9";
import Discord, {
CommandInteraction,
MessageActionRow,
@@ -9,7 +9,6 @@
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-expect-error
import type { WrappedCheck } from "jshaiku";
import client from "../../../utils/client.js";
diff --git a/src/commands/settings/tickets.ts b/src/commands/settings/tickets.ts
index 5e5cbe7..206e157 100644
--- a/src/commands/settings/tickets.ts
+++ b/src/commands/settings/tickets.ts
@@ -19,7 +19,7 @@
SelectMenuOption,
SlashCommandSubcommandBuilder
} from "@discordjs/builders";
-import { ChannelType } from "discord-api-types";
+import { ChannelType } from "discord-api-types/v9";
import client from "../../utils/client.js";
import {
toHexInteger,
diff --git a/src/commands/settings/welcome.ts b/src/commands/settings/welcome.ts
index 3eb0ec5..00b1826 100644
--- a/src/commands/settings/welcome.ts
+++ b/src/commands/settings/welcome.ts
@@ -8,12 +8,12 @@
MessageComponentInteraction,
Role
} from "discord.js";
-import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
+import type { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import client from "../../utils/client.js";
import confirmationMessage from "../../utils/confirmationMessage.js";
import generateKeyValueList from "../../utils/generateKeyValueList.js";
-import { ChannelType } from "discord-api-types";
+import { ChannelType } from "discord-api-types/v9";
import getEmojiByName from "../../utils/getEmojiByName.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
@@ -49,9 +49,7 @@
.addChannelTypes([ChannelType.GuildText, ChannelType.GuildNews])
);
-const callback = async (
- interaction: CommandInteraction
-): Promise<void | unknown> => {
+const callback = async (interaction: CommandInteraction): Promise<unknown> => {
const { renderRole, renderChannel, log, NucleusColors, entry, renderUser } =
client.logger;
await interaction.reply({
@@ -340,7 +338,9 @@
const check = (interaction: CommandInteraction) => {
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";
+ throw new Error(
+ "You must have the *Manage Server* permission to use this command"
+ );
return true;
};
diff --git a/src/commands/tags/edit.ts b/src/commands/tags/edit.ts
index 192a2d4..5aaec40 100644
--- a/src/commands/tags/edit.ts
+++ b/src/commands/tags/edit.ts
@@ -1,5 +1,5 @@
-import Discord, { CommandInteraction } from "discord.js";
-import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
+import type { CommandInteraction, GuildMember } from "discord.js";
+import type { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import confirmationMessage from "../../utils/confirmationMessage.js";
import keyValueList from "../../utils/generateKeyValueList.js";
@@ -28,10 +28,11 @@
.setDescription("The new name of the tag / Edit")
);
-const callback = async (interaction: CommandInteraction): Promise<void> => {
+const callback = async (interaction: CommandInteraction): Promise<unknown> => {
+ if (!interaction.guild) return;
const name = interaction.options.getString("name");
- const value = interaction.options.getString("value") || "";
- const newname = interaction.options.getString("newname") || "";
+ const value = interaction.options.getString("value") ?? "";
+ const newname = interaction.options.getString("newname") ?? "";
if (!newname && !value)
return await interaction.reply({
embeds: [
@@ -155,9 +156,11 @@
};
const check = (interaction: CommandInteraction) => {
- const member = interaction.member as Discord.GuildMember;
+ const member = interaction.member as GuildMember;
if (!member.permissions.has("MANAGE_MESSAGES"))
- throw "You must have the *Manage Messages* permission to use this command";
+ throw new Error(
+ "You must have the *Manage Messages* permission to use this command"
+ );
return true;
};
diff --git a/src/commands/user/about.ts b/src/commands/user/about.ts
index 5f096ae..129359f 100644
--- a/src/commands/user/about.ts
+++ b/src/commands/user/about.ts
@@ -55,8 +55,9 @@
}
const callback = async (interaction: CommandInteraction): Promise<void> => {
+ if (!interaction.guild) return;
const { renderUser, renderDelta } = client.logger;
- const member = (interaction.options.getMember("user") ||
+ const member = (interaction.options.getMember("user") ??
interaction.member) as Discord.GuildMember;
const flags: string[] = [];
if (
@@ -107,26 +108,29 @@
};
const members = await interaction.guild.members.fetch();
const membersArray = [...members.values()];
- membersArray.sort((a, b) => a.joinedTimestamp - b.joinedTimestamp);
+ membersArray.sort((a, b) => {
+ if (a.joinedTimestamp === null) return 1;
+ if (b.joinedTimestamp === null) return -1;
+ return a.joinedTimestamp - b.joinedTimestamp;
+ });
const joinPos = membersArray.findIndex((m) => m.id === member.user.id);
const roles = member.roles.cache
- .filter((r) => r.id !== interaction.guild.id)
+ .filter((r) => r.id !== interaction.guild!.id)
.sort();
let s = "";
let count = 0;
let ended = false;
- roles.map((item) => {
- if (ended) return;
- const string = `<@&${item.id}>, `;
+ for (const roleId in roles) {
+ const string = `<@&${roleId}>, `;
if (s.length + string.length > 1000) {
ended = true;
s += `and ${roles.size - count} more`;
- return;
+ break;
}
count++;
s += string;
- });
+ }
if (s.length > 0 && !ended) s = s.slice(0, -2);
let perms = "";
diff --git a/src/commands/user/avatar.ts b/src/commands/user/avatar.ts
index 35c475f..502e9c8 100644
--- a/src/commands/user/avatar.ts
+++ b/src/commands/user/avatar.ts
@@ -19,7 +19,7 @@
const callback = async (interaction: CommandInteraction): Promise<void> => {
const { renderUser } = client.logger;
- const member = (interaction.options.getMember("user") ||
+ const member = (interaction.options.getMember("user") ??
interaction.member) as Discord.GuildMember;
await interaction.reply({
embeds: [
@@ -33,7 +33,7 @@
url: member.user.displayAvatarURL({ dynamic: true })
})
)
- .setImage(await member.user.displayAvatarURL({ dynamic: true }))
+ .setImage(member.user.displayAvatarURL({ dynamic: true }))
],
ephemeral: true,
fetchReply: true
diff --git a/src/commands/user/track.ts b/src/commands/user/track.ts
index e0e41e0..1a4c308 100644
--- a/src/commands/user/track.ts
+++ b/src/commands/user/track.ts
@@ -10,7 +10,6 @@
SelectMenuOption,
SlashCommandSubcommandBuilder
} from "@discordjs/builders";
-// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
import { WrappedCheck } from "jshaiku";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
@@ -45,9 +44,7 @@
return "TRACKS.VERTICAL.MIDDLE." + disabled + active;
};
-const callback = async (
- interaction: CommandInteraction
-): Promise<void | unknown> => {
+const callback = async (interaction: CommandInteraction): Promise<unknown> => {
const { renderUser } = client.logger;
const member = interaction.options.getMember("user") as GuildMember;
const guild = interaction.guild;
@@ -57,7 +54,7 @@
let track = 0;
let generated;
const roles = await guild.roles.fetch();
- const memberRoles = await member.roles;
+ const memberRoles = member.roles;
let managed: boolean;
while (true) {
const data = config.tracks[track];
@@ -137,9 +134,8 @@
})
.join("\n");
const selected = [];
- for (let i = 0; i < data.track.length; i++) {
- if (memberRoles.cache.has(data.track[i]))
- selected.push(data.track[i]);
+ for (const position of data.track) {
+ if (memberRoles.cache.has(position)) selected.push(position);
}
const conflict = data.retainPrevious ? false : selected.length > 1;
let conflictDropdown;
@@ -278,7 +274,8 @@
) => {
const tracks = (await client.database.guilds.read(interaction.guild.id))
.tracks;
- if (tracks.length === 0) throw "This server does not have any tracks";
+ if (tracks.length === 0)
+ throw new Error("This server does not have any tracks");
const member = interaction.member as GuildMember;
// Allow the owner to promote anyone
if (member.id === interaction.guild.ownerId) return true;
@@ -297,7 +294,7 @@
}
// Check if the user has manage_roles permission
if (!managed && !member.permissions.has("MANAGE_ROLES"))
- throw "You do not have the *Manage Roles* permission";
+ throw new Error("You do not have the *Manage Roles* permission");
// Allow track
return true;
};
diff --git a/src/commands/verify.ts b/src/commands/verify.ts
index d1a0659..2319284 100644
--- a/src/commands/verify.ts
+++ b/src/commands/verify.ts
@@ -1,6 +1,5 @@
import type { CommandInteraction } from "discord.js";
import { SlashCommandBuilder } from "@discordjs/builders";
-// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
import { WrappedCheck } from "jshaiku";
import verify from "../reflex/verify.js";