pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 1 | import log from '../utils/log.js' |
| 2 | import readConfig from '../utils/readConfig.js' |
| 3 | import convertCurlyBracketString from '../utils/convertCurlyBracketString.js' |
| 4 | |
| 5 | export async function callback(_, member) { |
| 6 | let config = await readConfig(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 | |
| 14 | let channel = await member.client.channels.fetch(element.channel) |
| 15 | if (channel.guild.id !== member.guild.id) return |
| 16 | if (!channel) return // TODO: Notify mods |
| 17 | try { |
| 18 | await channel.edit({ name: string }) |
| 19 | } catch (err) { |
| 20 | console.error(err) |
| 21 | } |
| 22 | } |
| 23 | }); |
| 24 | } |