Much more typing
diff --git a/src/reflex/statsChannelUpdate.ts b/src/reflex/statsChannelUpdate.ts
index 644a75f..657e90d 100644
--- a/src/reflex/statsChannelUpdate.ts
+++ b/src/reflex/statsChannelUpdate.ts
@@ -1,3 +1,4 @@
+import type { Guild, User } from 'discord.js';
// @ts-expect-error
import type { HaikuClient } from "jshaiku";
import type { GuildMember } from "discord.js";
@@ -9,28 +10,29 @@
name: string;
}
-export async function callback(client: HaikuClient, member: GuildMember) {
- const guild = await client.guilds.fetch(member.guild.id);
+export async function callback(client: HaikuClient, member?: GuildMember, guild?: Guild, user?: User) {
+ if (!member && !guild) return;
+ guild = await client.guilds.fetch(member ? member.guild.id : guild!.id);
+ if (!guild) return;
+ user = user ?? member!.user
const config = await client.database.guilds.read(guild.id);
Object.entries(config.getKey("stats")).forEach(async ([channel, props]) => {
if ((props as PropSchema).enabled) {
let string = (props as PropSchema).name;
if (!string) return;
- string = await convertCurlyBracketString(string, member.id, member.displayName, guild.name, guild.members);
+ string = await convertCurlyBracketString(string, user!.id, user!.username, guild!.name, guild!.members);
let fetchedChannel;
try {
- fetchedChannel = await guild.channels.fetch(channel);
+ fetchedChannel = await guild!.channels.fetch(channel);
} catch (e) {
fetchedChannel = null;
}
if (!fetchedChannel) {
const deleted = config.getKey("stats")[channel];
- console.log(`stats.${channel}`);
- console.log(guild.id);
- await client.database.guilds.write(guild.id, null, `stats.${channel}`);
+ await client.database.guilds.write(guild!.id, null, `stats.${channel}`);
return singleNotify(
"statsChannelDeleted",
- guild.id,
+ guild!.id,
"One or more of your stats channels have been deleted. Please use `/settings stats` if you wish to add the channel again.\n" +
`The channels name was: ${deleted.name}`,
"Critical"
diff --git a/src/reflex/verify.ts b/src/reflex/verify.ts
index 37f8d6c..f28b291 100644
--- a/src/reflex/verify.ts
+++ b/src/reflex/verify.ts
@@ -1,5 +1,5 @@
import { LoadingEmbed } from "./../utils/defaultEmbeds.js";
-import Discord, { CommandInteraction, GuildMember, Interaction, Permissions, Role } from "discord.js";
+import Discord, { CommandInteraction, GuildMember, Interaction, MessageComponentInteraction, Permissions, Role } from "discord.js";
import EmojiEmbed from "../utils/generateEmojiEmbed.js";
import fetch from "node-fetch";
import { TestString, NSFWCheck } from "./scanners.js";
@@ -21,7 +21,7 @@
return "\n\n" + createPageIndicator(5, i);
}
-export default async function (interaction: CommandInteraction) {
+export default async function (interaction: CommandInteraction | MessageComponentInteraction) {
const verify = client.verify;
await interaction.reply({
embeds: LoadingEmbed,