blob: 4b24768814dccb89e4f6ef07e841f76577ef742f [file] [log] [blame]
pineafan32767212022-03-14 21:27:39 +00001import log from '../utils/log.js'
2import readConfig from '../utils/readConfig.js'
3import convertCurlyBracketString from '../utils/convertCurlyBracketString.js'
pineafan377794f2022-04-18 19:01:01 +01004import singleNotify from '../utils/singleNotify.js';
pineafan32767212022-03-14 21:27:39 +00005
pineafan377794f2022-04-18 19:01:01 +01006export async function callback(interaction, member) {
pineafan32767212022-03-14 21:27:39 +00007 let config = await readConfig(member.guild.id);
8
9 config.stats.forEach(async element => {
10 if (element.enabled) {
11 let string = element.text
12 if (!string) return
13 string = await convertCurlyBracketString(string, member.id, member.displayName, member.guild.name, member.guild.members)
14
15 let channel = await member.client.channels.fetch(element.channel)
16 if (channel.guild.id !== member.guild.id) return
pineafan377794f2022-04-18 19:01:01 +010017 if (!channel) return await singleNotify(interaction.client,
18 "statsChannelDeleted",
19 member.guild.id,
20 "The stats channel has been deleted. Please set a new channel to use this feature.",
21 "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}