Bug fixes and ~~performance~~ typing improvements
diff --git a/src/Unfinished/all.ts b/src/Unfinished/all.ts
index 453a467..1c6ce20 100644
--- a/src/Unfinished/all.ts
+++ b/src/Unfinished/all.ts
@@ -23,11 +23,7 @@
data: object;
checkFunction: (member) => boolean;
inverted = false;
- constructor(
- name: (data) => string | string,
- data: object,
- check: (member) => boolean
- ) {
+ constructor(name: (data) => string | string, data: object, check: (member) => boolean) {
if (typeof name === "function") {
this.name = name(data);
} else {
@@ -64,10 +60,7 @@
render: "joined",
before: (date) =>
new Filter(
- (_data) =>
- `Joined server before <t:${Math.round(
- date.getTime() / 1000
- )}:D>`,
+ (_data) => `Joined server before <t:${Math.round(date.getTime() / 1000)}:D>`,
{ date: date, type: Date, render: "before" },
(member) => {
return member.joinedTimestamp < date.getTime();
@@ -116,10 +109,7 @@
render: "created",
before: (date) =>
new Filter(
- (_data) =>
- `Account created before <t:${Math.round(
- date.getTime() / 1000
- )}:D>`,
+ (_data) => `Account created before <t:${Math.round(date.getTime() / 1000)}:D>`,
{ date: date, type: Date, render: "before" },
(member) => {
return member.user.createdTimestamp < date.getTime();
@@ -167,9 +157,7 @@
}
};
-const callback = async (
- interaction: CommandInteraction
-): Promise<void | unknown> => {
+const callback = async (interaction: CommandInteraction): Promise<void | unknown> => {
await interaction.reply({
embeds: LoadingEmbed,
ephemeral: true,
@@ -215,29 +203,20 @@
new EmojiEmbed()
.setTitle("Role all")
.setDescription(
- (all
- ? "All of the following must be true:"
- : "Any of the following must be true") +
+ (all ? "All of the following must be true:" : "Any of the following must be true") +
"\n" +
filters
.map((f) => {
count++;
return (
- (count === 1
- ? getEmojiByName("ICONS.FILTER")
- : all
- ? "**and** "
- : "**or** ") +
+ (count === 1 ? getEmojiByName("ICONS.FILTER") : all ? "**and** " : "**or** ") +
(f.inverted ? "**not** " : "") +
`${f.name}`
);
})
.join("\n") +
"\n\n" +
- `This will affect ${addPlural(
- affected.length,
- "member"
- )}`
+ `This will affect ${addPlural(affected.length, "member")}`
)
.setEmoji("GUILD.ROLES.CREATE")
.setStatus("Success")
@@ -261,21 +240,13 @@
.setLabel("Apply")
.setStyle("PRIMARY")
.setCustomId("apply")
- .setEmoji(
- client.emojis.cache.get(
- getEmojiByName("CONTROL.TICK", "id")
- )
- )
+ .setEmoji(client.emojis.cache.get(getEmojiByName("CONTROL.TICK", "id")))
.setDisabled(affected.length === 0),
new MessageButton()
.setLabel("Add filter")
.setStyle("PRIMARY")
.setCustomId("add")
- .setEmoji(
- client.emojis.cache.get(
- getEmojiByName("ICONS.FILTER", "id")
- )
- )
+ .setEmoji(client.emojis.cache.get(getEmojiByName("ICONS.FILTER", "id")))
.setDisabled(filters.length >= 25)
])
]
@@ -285,19 +256,14 @@
return;
};
-const check = async (
- interaction: CommandInteraction,
- _defaultCheck: WrappedCheck
-) => {
+const check = async (interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
const member = interaction.member as GuildMember;
const me = interaction.guild.me!;
- if (!me.permissions.has("MANAGE_ROLES"))
- throw "I do not have the *Manage Roles* permission";
+ if (!me.permissions.has("MANAGE_ROLES")) throw "I do not have the *Manage Roles* permission";
// Allow the owner to role anyone
if (member.id === interaction.guild.ownerId) return true;
// Check if the user has manage_roles permission
- if (!member.permissions.has("MANAGE_ROLES"))
- throw "You do not have the *Manage Roles* permission";
+ if (!member.permissions.has("MANAGE_ROLES")) throw "You do not have the *Manage Roles* permission";
// Allow role
return true;
};
diff --git a/src/Unfinished/categorisationTest.ts b/src/Unfinished/categorisationTest.ts
index 8c25eb2..2da2be3 100644
--- a/src/Unfinished/categorisationTest.ts
+++ b/src/Unfinished/categorisationTest.ts
@@ -1,11 +1,5 @@
import { LoadingEmbed } from "../utils/defaultEmbeds.js";
-import {
- CommandInteraction,
- GuildChannel,
- MessageActionRow,
- MessageButton,
- MessageSelectMenu
-} from "discord.js";
+import { CommandInteraction, GuildChannel, MessageActionRow, MessageButton, MessageSelectMenu } from "discord.js";
import { SlashCommandBuilder } from "@discordjs/builders";
// @ts-expect-error
import type { WrappedCheck } from "jshaiku";
@@ -14,14 +8,10 @@
import addPlural from "../utils/plurals.js";
import getEmojiByName from "../utils/getEmojiByName.js";
-const command = new SlashCommandBuilder()
- .setName("categorise")
- .setDescription("Categorises your servers channels");
+const command = new SlashCommandBuilder().setName("categorise").setDescription("Categorises your servers channels");
const callback = async (interaction: CommandInteraction): Promise<unknown> => {
- const channels = interaction.guild.channels.cache.filter(
- (c) => c.type !== "GUILD_CATEGORY"
- );
+ const channels = interaction.guild.channels.cache.filter((c) => c.type !== "GUILD_CATEGORY");
const categorised = {};
await interaction.reply({ embeds: LoadingEmbed, ephemeral: true });
const predicted = {};
@@ -50,10 +40,7 @@
for (const c of channels) {
// convert channel to a channel if its a string
let channel: string | GuildChannel;
- if (typeof c === "string")
- channel = interaction.guild.channels.cache.get(
- channel as string
- ).id;
+ if (typeof c === "string") channel = interaction.guild.channels.cache.get(channel as string).id;
else channel = (c[0] as unknown as GuildChannel).id;
console.log(channel);
if (!predicted[channel]) predicted[channel] = [];
@@ -63,10 +50,7 @@
.setTitle("Categorise")
.setDescription(
`Select all types that apply to <#${channel}>.\n\n` +
- `${addPlural(
- predicted[channel].length,
- "Suggestion"
- )}: ${predicted[channel].join(", ")}`
+ `${addPlural(predicted[channel].length, "Suggestion")}: ${predicted[channel].join(", ")}`
)
.setEmoji("CHANNEL.CATEGORY.CREATE")
.setStatus("Success")
@@ -77,9 +61,7 @@
.setCustomId("selected")
.setMaxValues(Object.keys(types).length)
.setMinValues(1)
- .setPlaceholder(
- "Select all types that apply to this channel"
- )
+ .setPlaceholder("Select all types that apply to this channel")
.setOptions(
Object.keys(types).map((type) => ({
label: type,
@@ -93,20 +75,12 @@
.setCustomId("accept")
.setStyle("SUCCESS")
.setDisabled(predicted[channel].length === 0)
- .setEmoji(
- client.emojis.cache.get(
- getEmojiByName("ICONS.TICK", "id")
- )
- ),
+ .setEmoji(client.emojis.cache.get(getEmojiByName("ICONS.TICK", "id"))),
new MessageButton()
.setLabel('Use "Other"')
.setCustomId("reject")
.setStyle("SECONDARY")
- .setEmoji(
- client.emojis.cache.get(
- getEmojiByName("ICONS.CROSS", "id")
- )
- )
+ .setEmoji(client.emojis.cache.get(getEmojiByName("ICONS.CROSS", "id")))
])
]
});
@@ -122,10 +96,9 @@
.setStatus("Danger")
.setDescription(
`Select all types that apply to <#${channel}>.\n\n` +
- `${addPlural(
- predicted[channel].length,
- "Suggestion"
- )}: ${predicted[channel].join(", ")}`
+ `${addPlural(predicted[channel].length, "Suggestion")}: ${predicted[channel].join(
+ ", "
+ )}`
)
.setFooter({ text: "Message timed out" })
]
@@ -147,10 +120,7 @@
console.log(categorised);
};
-const check = (
- _interaction: CommandInteraction,
- _defaultCheck: WrappedCheck
-) => {
+const check = (_interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
return true;
};