pineafan | 6702cef | 2022-06-13 17:52:37 +0100 | [diff] [blame] | 1 | import client from '../utils/client.js'; |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 2 | import convertCurlyBracketString from '../utils/convertCurlyBracketString.js' |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 3 | import singleNotify from '../utils/singleNotify.js'; |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 4 | |
pineafan | 6702cef | 2022-06-13 17:52:37 +0100 | [diff] [blame] | 5 | export async function callback(_, member) { |
| 6 | let config = await client.database.read(member.guild.id); |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 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 |
pineafan | 6702cef | 2022-06-13 17:52:37 +0100 | [diff] [blame] | 16 | if (!channel) return singleNotify( |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 17 | "statsChannelDeleted", |
| 18 | member.guild.id, |
pineafan | 6702cef | 2022-06-13 17:52:37 +0100 | [diff] [blame] | 19 | "One or more of your stats channels have been deleted. Please open the settings menu to change this.", |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 20 | "Critical" |
| 21 | ) |
pineafan | 3276721 | 2022-03-14 21:27:39 +0000 | [diff] [blame] | 22 | try { |
| 23 | await channel.edit({ name: string }) |
| 24 | } catch (err) { |
| 25 | console.error(err) |
| 26 | } |
| 27 | } |
| 28 | }); |
| 29 | } |