blob: c6d4e65c2ca201cde6204cf67e26050b5cb80992 [file] [log] [blame]
pineafan813bdf42022-07-24 10:39:10 +01001import client from '../utils/client.js';
2import convertCurlyBracketString from '../utils/convertCurlyBracketString.js'
3import singleNotify from '../utils/singleNotify.js';
4
5export async function callback(_, member) {
6 let config = await client.database.guilds.read(member.guild.id);
7
8 config.stats.forEach(async element => {
9 if (element.enabled) {
10 let string = element.text
11 if (!string) return
12 string = await convertCurlyBracketString(string, member.id, member.displayName, member.guild.name, member.guild.members)
13 let channel;
14 try {
15 channel = await member.client.channels.fetch(element.channel)
16 } catch { channel = null }
17 if (!channel) return singleNotify(
18 "statsChannelDeleted",
19 member.guild.id,
20 "One or more of your stats channels have been deleted. Please open the settings menu to change this.",
21 "Critical"
22 )
23 try {
24 await channel.edit({ name: string })
25 } catch (err) {
26 console.error(err)
27 }
28 }
29 });
30}