loads of new commands, updates and bug fixes
diff --git a/src/automations/statsChannelAdd.ts b/src/automations/statsChannelAdd.ts
index 42ec580..01dfef1 100644
--- a/src/automations/statsChannelAdd.ts
+++ b/src/automations/statsChannelAdd.ts
@@ -1,19 +1,28 @@
-import log from '../utils/log.js'
-import readConfig from '../utils/readConfig.js'
import convertCurlyBracketString from '../utils/convertCurlyBracketString.js'
+import singleNotify from '../utils/singleNotify.js';
+import client from '../utils/client.js';
export async function callback(_, member) {
- let config = await readConfig(member.guild.id);
+ let config = await client.database.read(member.guild.id);
config.stats.forEach(async element => {
if (element.enabled) {
let string = element.text
if (!string) return
string = await convertCurlyBracketString(string, member.id, member.displayName, member.guild.name, member.guild.members)
-
- let channel = await member.client.channels.fetch(element.channel)
+ let channel;
+ try {
+ channel = await member.client.channels.fetch(element.channel)
+ } catch (error) { channel = null }
+ if (!channel) {
+ return singleNotify(
+ "statsChannelDeleted",
+ member.guild.id,
+ "One or more of your stats channels have been deleted. Please open the settings menu to change this.",
+ "Critical"
+ )
+ }
if (channel.guild.id !== member.guild.id) return
- if (!channel) return // TODO: Notify mods
try {
await channel.edit({ name: string })
} catch (err) {
@@ -21,4 +30,4 @@
}
}
});
-}
\ No newline at end of file
+}