Development (#11)
We need this NOW.
---------
Co-authored-by: PineaFan <ash@pinea.dev>
Co-authored-by: pineafan <pineapplefanyt@gmail.com>
Co-authored-by: PineappleFan <PineaFan@users.noreply.github.com>
Co-authored-by: Skyler <skyler3665@gmail.com>
diff --git a/src/Unfinished/all.ts b/src/Unfinished/all.ts
index 9d9e653..eea33f5 100644
--- a/src/Unfinished/all.ts
+++ b/src/Unfinished/all.ts
@@ -5,16 +5,18 @@
ActionRowBuilder,
ButtonBuilder,
SelectMenuBuilder,
- ButtonStyle
+ ButtonStyle,
+ StringSelectMenuBuilder,
+ APIMessageComponentEmoji
} from "discord.js";
-import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
+import { SlashCommandSubcommandBuilder } from "discord.js";
import EmojiEmbed from "../utils/generateEmojiEmbed.js";
import getEmojiByName from "../utils/getEmojiByName.js";
import addPlural from "../utils/plurals.js";
import client from "../utils/client.js";
const command = (builder: SlashCommandSubcommandBuilder) =>
- builder // TODO: DON'T RELEASE THIS
+ builder
.setName("all")
.setDescription("Gives or removes a role from everyone");
@@ -171,8 +173,8 @@
const all = true;
while (true) {
let count = 0;
- const affected = [];
- const members = interaction.guild.members.cache;
+ const affected: GuildMember[] = [];
+ const members = interaction.guild!.members.cache;
if (all) {
members.forEach((member) => {
let applies = true;
@@ -224,8 +226,8 @@
.setStatus("Success")
],
components: [
- new ActionRowBuilder().addComponents([
- new SelectMenuBuilder()
+ new ActionRowBuilder<StringSelectMenuBuilder>().addComponents([
+ new StringSelectMenuBuilder()
.setOptions(
filters.map((f, index) => ({
label: (f.inverted ? "(Not) " : "") + f.name,
@@ -237,18 +239,18 @@
.setCustomId("select")
.setPlaceholder("Remove a filter")
]),
- new ActionRowBuilder().addComponents([
+ new ActionRowBuilder<ButtonBuilder>().addComponents([
new ButtonBuilder()
.setLabel("Apply")
.setStyle(ButtonStyle.Primary)
.setCustomId("apply")
- .setEmoji(client.emojis.cache.get(getEmojiByName("CONTROL.TICK", "id")))
+ .setEmoji(client.emojis.cache.get(getEmojiByName("CONTROL.TICK", "id"))! as APIMessageComponentEmoji)
.setDisabled(affected.length === 0),
new ButtonBuilder()
.setLabel("Add filter")
.setStyle(ButtonStyle.Primary)
.setCustomId("add")
- .setEmoji(client.emojis.cache.get(getEmojiByName("ICONS.FILTER", "id")))
+ .setEmoji(client.emojis.cache.get(getEmojiByName("ICONS.FILTER", "id"))! as APIMessageComponentEmoji)
.setDisabled(filters.length >= 25)
])
]
@@ -260,12 +262,12 @@
const check = async (interaction: CommandInteraction) => {
const member = interaction.member as GuildMember;
- const me = interaction.guild.me!;
- if (!me.permissions.has("MANAGE_ROLES")) throw new Error("I do not have the *Manage Roles* permission");
+ const me = interaction.guild!.members.me!;
+ if (!me.permissions.has("ManageRoles")) return "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 new Error("You do not have the *Manage Roles* permission");
+ if (!member.permissions.has("ManageRoles")) return "You do not have the *Manage Roles* permission";
// Allow role
return true;
};