some API typings
diff --git a/src/api/index.ts b/src/api/index.ts
index b6f82f8..d0df639 100644
--- a/src/api/index.ts
+++ b/src/api/index.ts
@@ -1,14 +1,17 @@
-import type { Client } from 'discord.js';
+import type { NucleusClient } from '../utils/client.js';
+//@ts-expect-error
import express from "express";
+//@ts-expect-error
import bodyParser from "body-parser";
import EmojiEmbed from "../utils/generateEmojiEmbed.js";
+//@ts-expect-error
import structuredClone from "@ungap/structured-clone";
const jsonParser = bodyParser.json();
const app = express();
const port = 10000;
-const runServer = (client: Client) => {
+const runServer = (client: NucleusClient) => {
app.get("/", (req, res) => {
res.status(200).send(client.ws.ping);
});
@@ -17,20 +20,20 @@
const code = req.params.code;
const secret = req.body.secret;
if (secret === client.config.verifySecret) {
- const guild = await client.guilds.fetch(client.verify[code].gID);
+ const guild = await client.guilds.fetch(client.verify[code]!.gID);
if (!guild) {
return res.status(404);
}
- const member = await guild.members.fetch(client.verify[code].uID);
+ const member = await guild.members.fetch(client.verify[code]!.uID);
if (!member) {
return res.status(404);
}
- if (member.roles.cache.has(client.verify[code].rID)) {
+ if (member.roles.cache.has(client.verify[code]!.rID)) {
return res.status(200);
}
- await member.roles.add(client.verify[code].rID);
+ await member.roles.add(client.verify[code]!.rID);
- const interaction = client.verify[code].interaction;
+ const interaction = client.verify[code]!.interaction;
if (interaction) {
interaction.editReply({
embeds: [
@@ -57,7 +60,7 @@
},
list: {
memberId: entry(member.id, `\`${member.id}\``),
- member: entry(member.id, renderUser(member))
+ member: entry(member.id, renderUser(member.user))
},
hidden: {
guild: guild.id
@@ -77,7 +80,7 @@
const code = req.params.code;
if (client.verify[code]) {
try {
- const interaction = client.verify[code].interaction;
+ const interaction = client.verify[code]!.interaction;
if (interaction) {
interaction.editReply({
embeds: [
@@ -105,11 +108,11 @@
const code = req.params.code;
const secret = req.body.secret;
if (secret === client.config.verifySecret) {
- const guild = await client.guilds.fetch(client.roleMenu[code].guild);
+ const guild = await client.guilds.fetch(client.roleMenu[code]!.guild);
if (!guild) {
return res.status(404);
}
- const member = await guild.members.fetch(client.roleMenu[code].user);
+ const member = await guild.members.fetch(client.roleMenu[code]!.user);
if (!member) {
return res.status(404);
}
@@ -123,7 +126,7 @@
const code = req.params.code;
if (client.roleMenu[code] !== undefined) {
try {
- const interaction = client.roleMenu[code].interaction;
+ const interaction = client.roleMenu[code]!.interaction;
if (interaction) {
interaction.editReply({
embeds: [
diff --git a/src/commands/mod/viewas.ts b/src/commands/mod/viewas.ts
index 6216a37..9c163a7 100644
--- a/src/commands/mod/viewas.ts
+++ b/src/commands/mod/viewas.ts
@@ -22,13 +22,7 @@
.addUserOption((option) => option.setName("member").setDescription("The member to view as").setRequired(true));
const callback = async (interaction: CommandInteraction): Promise<void> => {
- /*
- * {
- categoryObject: channel[],
- categoryObject: channel[],
- "null": channel[]
- }
- */
+
const m = await interaction.reply({embeds: LoadingEmbed, ephemeral: true, fetchReply: true})
let channels: Record<string, GuildBasedChannel[]> = {"": []};
@@ -105,7 +99,7 @@
threads = channel.threads.cache.toJSON().map((t) => t as Discord.ThreadChannel);
}
const nsfw = ("nsfw" in channel ? channel.nsfw : false) && NSFWAvailable.includes(channelType)
- const emojiName = channelTypeEmoji[channelType] + (nsfw ? "_NSFW" : "");
+ const emojiName = channelTypeEmoji[channelType.valueOf()] + (nsfw ? "_NSFW" : "");
const emoji = getEmojiByName("ICONS.CHANNEL." + (threads.length ? "THREAD_CHANNEL" : emojiName));
let current = `${emoji} ${channel.name}`;
if (threads.length) {
diff --git a/src/commands/settings/welcome.ts b/src/commands/settings/welcome.ts
index 9892638..e7143fb 100644
--- a/src/commands/settings/welcome.ts
+++ b/src/commands/settings/welcome.ts
@@ -8,7 +8,9 @@
MessageComponentInteraction,
Role,
ButtonStyle,
- AutocompleteInteraction
+ AutocompleteInteraction,
+ GuildChannel,
+ EmbedBuilder
} from "discord.js";
import type { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
@@ -50,17 +52,17 @@
});
let m: Message;
if (
- interaction.options.getRole("role") ||
- interaction.options.getChannel("channel") ||
- interaction.options.getString("message")
+ interaction.options.get("role")?.role ||
+ interaction.options.get("channel")?.channel ||
+ interaction.options.get("message")?.value as string
) {
let role: Role | null;
let ping: Role | null;
let channel: Channel | null;
- const message: string | null = interaction.options.getString("message");
+ const message: string | null = interaction.options.get("message")?.value as string | null;
try {
- role = interaction.options.getRole("role") as Role | null;
- ping = interaction.options.getRole("ping") as Role | null;
+ role = interaction.options.get("role")?.role as Role | null;
+ ping = interaction.options.get("ping")?.role as Role | null;
} catch {
return await interaction.editReply({
embeds: [
@@ -73,7 +75,7 @@
});
}
try {
- channel = interaction.options.getChannel("channel") as Channel | null;
+ channel = interaction.options.get("channel")?.channel as Channel | null;
} catch {
return await interaction.editReply({
embeds: [
@@ -94,13 +96,14 @@
if (role) options.role = renderRole(role);
if (ping) options.ping = renderRole(ping);
- if (channel) options.channel = renderChannel(channel);
+ if (channel) options.channel = renderChannel(channel as GuildChannel);
if (message) options.message = "\n> " + message;
const confirmation = await new confirmationMessage(interaction)
- .setEmoji("GUILD.ROLES.EDIT", "GUILD.ROLES.DELETE")
+ .setEmoji("GUILD.ROLES.EDIT")
.setTitle("Welcome Events")
.setDescription(generateKeyValueList(options))
.setColor("Warning")
+ .setFailedMessage("Cancelled", "Warning", "GUILD.ROLES.DELETE") //TODO: Actual Message Needed
.setInverted(true)
.send(true);
if (confirmation.cancelled) return;
@@ -130,7 +133,7 @@
};
if (role) list.role = entry(role.id, renderRole(role));
if (ping) list.ping = entry(ping.id, renderRole(ping));
- if (channel) list.channel = entry(channel.id, renderChannel(channel.id));
+ if (channel) list.channel = entry(channel.id, renderChannel(channel as GuildChannel));
if (message) list.message = entry(message, `\`${message}\``);
const data = {
meta: {
@@ -185,19 +188,19 @@
`**Message:** ${config.welcome.message ? `\n> ${config.welcome.message}` : "*None set*"}\n` +
`**Role:** ${
config.welcome.role
- ? renderRole(await interaction.guild!.roles.fetch(config.welcome.role))
+ ? renderRole((await interaction.guild!.roles.fetch(config.welcome.role))!)
: "*None set*"
}\n` +
`**Ping:** ${
config.welcome.ping
- ? renderRole(await interaction.guild!.roles.fetch(config.welcome.ping))
+ ? renderRole((await interaction.guild!.roles.fetch(config.welcome.ping))!)
: "*None set*"
}\n` +
`**Channel:** ${
config.welcome.channel
? config.welcome.channel == "dm"
? "DM"
- : renderChannel(await interaction.guild!.channels.fetch(config.welcome.channel))
+ : renderChannel((await interaction.guild!.channels.fetch(config.welcome.channel))!)
: "*None set*"
}`
)
@@ -293,7 +296,7 @@
}
} while (!timedOut);
await interaction.editReply({
- embeds: [m.embeds[0]!.setFooter({ text: "Message timed out" })],
+ embeds: [new EmbedBuilder(m.embeds[0]!.data).setFooter({ text: "Message timed out" })],
components: []
});
};