blob: c6d4e65c2ca201cde6204cf67e26050b5cb80992 [file] [log] [blame]
pineafan6702cef2022-06-13 17:52:37 +01001import client from '../utils/client.js';
pineafan32767212022-03-14 21:27:39 +00002import convertCurlyBracketString from '../utils/convertCurlyBracketString.js'
pineafan377794f2022-04-18 19:01:01 +01003import singleNotify from '../utils/singleNotify.js';
pineafan32767212022-03-14 21:27:39 +00004
pineafan6702cef2022-06-13 17:52:37 +01005export async function callback(_, member) {
pineafan4edb7762022-06-26 19:21:04 +01006 let config = await client.database.guilds.read(member.guild.id);
pineafan32767212022-03-14 21:27:39 +00007
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)
pineafan52906cd2022-06-29 22:02:36 +010013 let channel;
14 try {
15 channel = await member.client.channels.fetch(element.channel)
16 } catch { channel = null }
pineafan6702cef2022-06-13 17:52:37 +010017 if (!channel) return singleNotify(
pineafan377794f2022-04-18 19:01:01 +010018 "statsChannelDeleted",
19 member.guild.id,
pineafan6702cef2022-06-13 17:52:37 +010020 "One or more of your stats channels have been deleted. Please open the settings menu to change this.",
pineafan377794f2022-04-18 19:01:01 +010021 "Critical"
22 )
pineafan32767212022-03-14 21:27:39 +000023 try {
24 await channel.edit({ name: string })
25 } catch (err) {
26 console.error(err)
27 }
28 }
29 });
30}