Still got errors and warnings, mostly the same and easy to fix
diff --git a/src/Unfinished/all.ts b/src/Unfinished/all.ts
index d49633c..db43527 100644
--- a/src/Unfinished/all.ts
+++ b/src/Unfinished/all.ts
@@ -1,4 +1,4 @@
-import { LoadingEmbed } from './../utils/defaultEmbeds.js';
+import { LoadingEmbed } from "./../utils/defaultEmbeds.js";
import Discord, { CommandInteraction, GuildMember, MessageActionRow, MessageButton, MessageSelectMenu } from "discord.js";
import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import { WrappedCheck } from "jshaiku";
@@ -9,14 +9,14 @@
const command = (builder: SlashCommandSubcommandBuilder) =>
builder // TODO: DON'T RELEASE THIS
- .setName("all")
- .setDescription("Gives or removes a role from everyone")
+ .setName("all")
+ .setDescription("Gives or removes a role from everyone");
class Filter {
name: string;
data: object;
checkFunction: (member) => boolean;
- inverted: boolean = false;
+ inverted = false;
constructor(name: (data) => string | string, data: object, check: (member) => boolean) {
if (typeof name === "function") { this.name = name(data);
} else { this.name = name; }
@@ -25,8 +25,8 @@
}
flip() { this.inverted = true; return this; }
check(member) {
- if (this.inverted) return !this.checkFunction(member)
- else return this.checkFunction(member)
+ if (this.inverted) return !this.checkFunction(member);
+ else return this.checkFunction(member);
}
}
@@ -35,23 +35,23 @@
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()
+ return member.joinedTimestamp < date.getTime();
}))
},
nickname: {
render: "Nickname",
- set: () => ( new Filter((data) => `Member has a nickname set"`, {render: "set"}, (member) => { return member.nickname !== null})),
+ 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)})),
+ 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)})),
+ 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)}))
+ return member.displayName.endsWith(name);}))
}
},
account: {
@@ -59,49 +59,49 @@
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()
+ 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)})),
+ 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)})),
+ 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)}))
+ return member.user.name.endsWith(name);}))
}
}
-}
+};
const callback = async (interaction: CommandInteraction): Promise<any> => {
- await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true})
- let filters: Filter[] = [
+ await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true});
+ const filters: Filter[] = [
filterList.member.has.role("959901346000154674"),
filterList.member.nickname.startsWith("Pinea"),
filterList.member.joined.before(new Date(2022, 1)).flip()
- ]
- let all = true;
+ ];
+ const all = true;
while (true) {
let count = 0;
- let affected = []
- let members = interaction.guild.members.cache
+ const affected = [];
+ const members = interaction.guild.members.cache;
if (all) {
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 => {
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")
@@ -109,7 +109,7 @@
filters.map((f) => {
count ++;
return (count === 1 ? getEmojiByName("ICONS.FILTER") : (all ? "**and** " : "**or** ")) +
- (f.inverted ? "**not** " : "") + `${f.name}`
+ (f.inverted ? "**not** " : "") + `${f.name}`;
}).join("\n") + "\n\n" + `This will affect ${addPlural(affected.length, "member")}`)
.setEmoji("GUILD.ROLES.CREATE")
.setStatus("Success")
@@ -132,22 +132,22 @@
.setEmoji(client.emojis.cache.get(getEmojiByName("ICONS.FILTER", "id")))
.setDisabled(filters.length >= 25)
])
- ]})
- break
+ ]});
+ break;
}
-}
+};
const check = async (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
- let member = (interaction.member as GuildMember)
- let me = (interaction.guild.me as GuildMember)
+ 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";
// Allow the owner to role anyone
- if (member.id === interaction.guild.ownerId) return true
+ 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";
// Allow role
return true;
-}
+};
export { command };
export { callback };