Fix a bunch of linter errors
diff --git a/src/Unfinished/all.ts b/src/Unfinished/all.ts
index 51be5cb..453a467 100644
--- a/src/Unfinished/all.ts
+++ b/src/Unfinished/all.ts
@@ -1,5 +1,11 @@
import { LoadingEmbed } from "./../utils/defaultEmbeds.js";
-import Discord, { CommandInteraction, GuildMember, MessageActionRow, MessageButton, MessageSelectMenu } from "discord.js";
+import Discord, {
+ CommandInteraction,
+ GuildMember,
+ MessageActionRow,
+ MessageButton,
+ MessageSelectMenu
+} from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
import EmojiEmbed from "../utils/generateEmojiEmbed.js";
@@ -17,13 +23,23 @@
data: object;
checkFunction: (member) => boolean;
inverted = false;
- constructor(name: (data) => string | string, data: object, check: (member) => boolean) {
- if (typeof name === "function") { this.name = name(data);
- } else { this.name = name; }
+ constructor(
+ name: (data) => string | string,
+ data: object,
+ check: (member) => boolean
+ ) {
+ if (typeof name === "function") {
+ this.name = name(data);
+ } else {
+ this.name = name;
+ }
this.data = data;
this.checkFunction = check;
}
- flip() { this.inverted = true; return this; }
+ flip() {
+ this.inverted = true;
+ return this;
+ }
check(member) {
if (this.inverted) return !this.checkFunction(member);
else return this.checkFunction(member);
@@ -35,51 +51,130 @@
render: "Member",
has: {
render: "has",
- role: (role) => ( new Filter((data) => `Member has role <@&${data.role}>`, {role: role, type: Discord.Role, render: "role"}, (member) => { return member.roles.cache.has(role);}))
+ role: (role) =>
+ new Filter(
+ (data) => `Member has role <@&${data.role}>`,
+ { role: role, type: Discord.Role, render: "role" },
+ (member) => {
+ return member.roles.cache.has(role);
+ }
+ )
},
joined: {
render: "joined",
- before: (date) => ( new Filter((_data) => `Joined server before <t:${Math.round(date.getTime() / 1000)}:D>`, {date: date, type: Date, render: "before"}, (member) => {
- return member.joinedTimestamp < date.getTime();
- }))
+ before: (date) =>
+ new Filter(
+ (_data) =>
+ `Joined server before <t:${Math.round(
+ date.getTime() / 1000
+ )}:D>`,
+ { date: date, type: Date, render: "before" },
+ (member) => {
+ return member.joinedTimestamp < date.getTime();
+ }
+ )
},
nickname: {
render: "Nickname",
- set: () => ( new Filter((_data) => "Member has a nickname set\"", {render: "set"}, (member) => { return member.nickname !== null;})),
- includes: (name) => ( new Filter((_data) => `Nickname includes "${name}"`, {nickname: name, type: String, render: "includes"}, (member) => {
- return member.displayName.includes(name);})),
- startsWith: (name) => ( new Filter((_data) => `Nickname starts with "${name}"`, {nickname: name, type: String, render: "starts with"}, (member) => {
- return member.displayName.startsWith(name);})),
- endsWith: (name) => ( new Filter((_data) => `Nickname ends with "${name}"`, {nickname: name, type: String, render: "ends with"}, (member) => {
- return member.displayName.endsWith(name);}))
+ set: () =>
+ new Filter(
+ (_data) => 'Member has a nickname set"',
+ { render: "set" },
+ (member) => {
+ return member.nickname !== null;
+ }
+ ),
+ includes: (name) =>
+ new Filter(
+ (_data) => `Nickname includes "${name}"`,
+ { nickname: name, type: String, render: "includes" },
+ (member) => {
+ return member.displayName.includes(name);
+ }
+ ),
+ startsWith: (name) =>
+ new Filter(
+ (_data) => `Nickname starts with "${name}"`,
+ { nickname: name, type: String, render: "starts with" },
+ (member) => {
+ return member.displayName.startsWith(name);
+ }
+ ),
+ endsWith: (name) =>
+ new Filter(
+ (_data) => `Nickname ends with "${name}"`,
+ { nickname: name, type: String, render: "ends with" },
+ (member) => {
+ return member.displayName.endsWith(name);
+ }
+ )
}
},
account: {
render: "Account",
created: {
render: "created",
- before: (date) => ( new Filter((_data) => `Account created before <t:${Math.round(date.getTime() / 1000)}:D>`, {date: date, type: Date, render: "before"}, (member) => {
- return member.user.createdTimestamp < date.getTime();
- }))
+ before: (date) =>
+ new Filter(
+ (_data) =>
+ `Account created before <t:${Math.round(
+ date.getTime() / 1000
+ )}:D>`,
+ { date: date, type: Date, render: "before" },
+ (member) => {
+ return member.user.createdTimestamp < date.getTime();
+ }
+ )
},
is: {
render: "is",
- human: () => ( new Filter((_data) => "Member is a human", {human: true, render: "human"}, (member) => { return !member.bot; }))
+ human: () =>
+ new Filter(
+ (_data) => "Member is a human",
+ { human: true, render: "human" },
+ (member) => {
+ return !member.bot;
+ }
+ )
},
username: {
render: "Username",
- includes: (name) => ( new Filter((_data) => `Nickname includes "${name}"`, {nickname: name, type: String, render: "includes"}, (member) => {
- return member.user.name.includes(name);})),
- startsWith: (name) => ( new Filter((_data) => `Nickname starts with "${name}"`, {nickname: name, type: String, render: "starts with"}, (member) => {
- return member.user.name.startsWith(name);})),
- endsWith: (name) => ( new Filter((_data) => `Nickname ends with "${name}"`, {nickname: name, type: String, render: "ends with"}, (member) => {
- return member.user.name.endsWith(name);}))
+ includes: (name) =>
+ new Filter(
+ (_data) => `Nickname includes "${name}"`,
+ { nickname: name, type: String, render: "includes" },
+ (member) => {
+ return member.user.name.includes(name);
+ }
+ ),
+ startsWith: (name) =>
+ new Filter(
+ (_data) => `Nickname starts with "${name}"`,
+ { nickname: name, type: String, render: "starts with" },
+ (member) => {
+ return member.user.name.startsWith(name);
+ }
+ ),
+ endsWith: (name) =>
+ new Filter(
+ (_data) => `Nickname ends with "${name}"`,
+ { nickname: name, type: String, render: "ends with" },
+ (member) => {
+ return member.user.name.endsWith(name);
+ }
+ )
}
}
};
-const callback = async (interaction: CommandInteraction): Promise<void | unknown> => {
- await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true});
+const callback = async (
+ interaction: CommandInteraction
+): Promise<void | unknown> => {
+ await interaction.reply({
+ embeds: LoadingEmbed,
+ ephemeral: true,
+ fetchReply: true
+ });
const filters: Filter[] = [
filterList.member.has.role("959901346000154674"),
filterList.member.nickname.startsWith("Pinea"),
@@ -91,65 +186,122 @@
const affected = [];
const members = interaction.guild.members.cache;
if (all) {
- members.forEach(member => {
+ members.forEach((member) => {
let applies = true;
- filters.forEach(filter => { if (!filter.check(member)) { applies = false; } });
- if (applies) { affected.push(member); }
+ filters.forEach((filter) => {
+ if (!filter.check(member)) {
+ applies = false;
+ }
+ });
+ if (applies) {
+ affected.push(member);
+ }
});
} else {
- members.forEach(member => {
+ members.forEach((member) => {
let applies = false;
- filters.forEach(filter => { if (filter.check(member)) { applies = true; } });
- if (applies) { affected.push(member); }
+ filters.forEach((filter) => {
+ if (filter.check(member)) {
+ applies = true;
+ }
+ });
+ if (applies) {
+ affected.push(member);
+ }
});
}
- await interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Role all")
- .setDescription((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** ")) +
- (f.inverted ? "**not** " : "") + `${f.name}`;
- }).join("\n") + "\n\n" + `This will affect ${addPlural(affected.length, "member")}`)
- .setEmoji("GUILD.ROLES.CREATE")
- .setStatus("Success")
- ], components: [
- new MessageActionRow().addComponents([new MessageSelectMenu().setOptions(filters.map((f, index) => ({
- label: (f.inverted ? "(Not) " : "") + f.name,
- value: index.toString()
- }))).setMinValues(1).setMaxValues(filters.length).setCustomId("select").setPlaceholder("Remove a filter")]),
- new MessageActionRow().addComponents([
- new MessageButton()
- .setLabel("Apply")
- .setStyle("PRIMARY")
- .setCustomId("apply")
- .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")))
- .setDisabled(filters.length >= 25)
- ])
- ]});
+ await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Role all")
+ .setDescription(
+ (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** ") +
+ (f.inverted ? "**not** " : "") +
+ `${f.name}`
+ );
+ })
+ .join("\n") +
+ "\n\n" +
+ `This will affect ${addPlural(
+ affected.length,
+ "member"
+ )}`
+ )
+ .setEmoji("GUILD.ROLES.CREATE")
+ .setStatus("Success")
+ ],
+ components: [
+ new MessageActionRow().addComponents([
+ new MessageSelectMenu()
+ .setOptions(
+ filters.map((f, index) => ({
+ label: (f.inverted ? "(Not) " : "") + f.name,
+ value: index.toString()
+ }))
+ )
+ .setMinValues(1)
+ .setMaxValues(filters.length)
+ .setCustomId("select")
+ .setPlaceholder("Remove a filter")
+ ]),
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setLabel("Apply")
+ .setStyle("PRIMARY")
+ .setCustomId("apply")
+ .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")
+ )
+ )
+ .setDisabled(filters.length >= 25)
+ ])
+ ]
+ });
break;
}
return;
};
-const check = async (interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
- const member = (interaction.member as GuildMember);
- const me = (interaction.guild.me as GuildMember);
- if (!me.permissions.has("MANAGE_ROLES")) throw "I do not have the *Manage Roles* permission";
+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";
// 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;
};
export { command };
export { callback };
-export { check };
\ No newline at end of file
+export { check };
diff --git a/src/Unfinished/categorisationTest.ts b/src/Unfinished/categorisationTest.ts
index 4ba582d..e4346d6 100644
--- a/src/Unfinished/categorisationTest.ts
+++ b/src/Unfinished/categorisationTest.ts
@@ -1,5 +1,11 @@
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";
import { WrappedCheck } from "jshaiku";
import EmojiEmbed from "../utils/generateEmojiEmbed.js";
@@ -11,10 +17,14 @@
.setName("categorise")
.setDescription("Categorises your servers channels");
-const callback = async (interaction: CommandInteraction): Promise<void | unknown> => {
- const channels = interaction.guild.channels.cache.filter(c => c.type !== "GUILD_CATEGORY");
+const callback = async (
+ interaction: CommandInteraction
+): Promise<void | unknown> => {
+ const channels = interaction.guild.channels.cache.filter(
+ (c) => c.type !== "GUILD_CATEGORY"
+ );
const categorised = {};
- await interaction.reply({embeds: LoadingEmbed, ephemeral: true});
+ await interaction.reply({ embeds: LoadingEmbed, ephemeral: true });
const predicted = {};
const types = {
general: ["general", "muted", "main", "topic", "discuss"],
@@ -41,58 +51,110 @@
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] = [];
- m = await interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Categorise")
- .setDescription(`Select all types that apply to <#${channel}>.\n\n` +
- `${addPlural(predicted[channel].length, "Suggestion")}: ${predicted[channel].join(", ")}`)
- .setEmoji("CHANNEL.CATEGORY.CREATE")
- .setStatus("Success")
- ], components: [
- new MessageActionRow().addComponents([new MessageSelectMenu()
- .setCustomId("selected")
- .setMaxValues(Object.keys(types).length)
- .setMinValues(1)
- .setPlaceholder("Select all types that apply to this channel")
- .setOptions(Object.keys(types).map(type => ({label: type, value: type})))
- ]),
- new MessageActionRow().addComponents([
- new MessageButton().setLabel("Accept Suggestion").setCustomId("accept").setStyle("SUCCESS").setDisabled(predicted[channel].length === 0)
- .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")))
- ])
- ]});
+ m = await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Categorise")
+ .setDescription(
+ `Select all types that apply to <#${channel}>.\n\n` +
+ `${addPlural(
+ predicted[channel].length,
+ "Suggestion"
+ )}: ${predicted[channel].join(", ")}`
+ )
+ .setEmoji("CHANNEL.CATEGORY.CREATE")
+ .setStatus("Success")
+ ],
+ components: [
+ new MessageActionRow().addComponents([
+ new MessageSelectMenu()
+ .setCustomId("selected")
+ .setMaxValues(Object.keys(types).length)
+ .setMinValues(1)
+ .setPlaceholder(
+ "Select all types that apply to this channel"
+ )
+ .setOptions(
+ Object.keys(types).map((type) => ({
+ label: type,
+ value: type
+ }))
+ )
+ ]),
+ new MessageActionRow().addComponents([
+ new MessageButton()
+ .setLabel("Accept Suggestion")
+ .setCustomId("accept")
+ .setStyle("SUCCESS")
+ .setDisabled(predicted[channel].length === 0)
+ .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")
+ )
+ )
+ ])
+ ]
+ });
let i;
try {
i = await m.awaitMessageComponent({ time: 300000 });
} catch (e) {
- return await interaction.editReply({embeds: [new EmojiEmbed()
- .setTitle("Categorise")
- .setEmoji("CHANNEL.CATEGORY.DELETE")
- .setStatus("Danger")
- .setDescription(`Select all types that apply to <#${channel}>.\n\n` +
- `${addPlural(predicted[channel].length, "Suggestion")}: ${predicted[channel].join(", ")}`)
- .setFooter({text: "Message timed out"})
- ]});
+ return await interaction.editReply({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle("Categorise")
+ .setEmoji("CHANNEL.CATEGORY.DELETE")
+ .setStatus("Danger")
+ .setDescription(
+ `Select all types that apply to <#${channel}>.\n\n` +
+ `${addPlural(
+ predicted[channel].length,
+ "Suggestion"
+ )}: ${predicted[channel].join(", ")}`
+ )
+ .setFooter({ text: "Message timed out" })
+ ]
+ });
}
i.deferUpdate();
let selected;
- if (i.customId === "select") { selected = i.values; }
- if (i.customId === "accept") { selected = predicted[channel]; }
- if (i.customId === "reject") { selected = ["other"]; }
+ if (i.customId === "select") {
+ selected = i.values;
+ }
+ if (i.customId === "accept") {
+ selected = predicted[channel];
+ }
+ if (i.customId === "reject") {
+ selected = ["other"];
+ }
categorised[channel] = selected;
}
console.log(categorised);
};
-const check = (_interaction: CommandInteraction, _defaultCheck: WrappedCheck) => {
+const check = (
+ _interaction: CommandInteraction,
+ _defaultCheck: WrappedCheck
+) => {
return true;
};
export { command };
export { callback };
-export { check };
\ No newline at end of file
+export { check };