Add more logging!
This commit is contained in:
		
							parent
							
								
									0521de87ab
								
							
						
					
					
						commit
						90727e4988
					
				
							
								
								
									
										11
									
								
								index.js
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								index.js
									
									
									
									
									
								
							| 
						 | 
					@ -79,7 +79,10 @@ var channel;
 | 
				
			||||||
discord.on('ready', async () => {
 | 
					discord.on('ready', async () => {
 | 
				
			||||||
	console.log(`${colors.cyan("[DISCORD]")} Logged in as ${discord.user.displayName}`);
 | 
						console.log(`${colors.cyan("[DISCORD]")} Logged in as ${discord.user.displayName}`);
 | 
				
			||||||
	channel = await discord.channels.cache.get(process.env.SUMMARY_CHANNEL_ID);
 | 
						channel = await discord.channels.cache.get(process.env.SUMMARY_CHANNEL_ID);
 | 
				
			||||||
 | 
						if (!channel) {
 | 
				
			||||||
 | 
							console.log(`${colors.red("[DISCORD]")} Channel not found, Make sure the channel ID is correct in the .env file`);
 | 
				
			||||||
 | 
							process.exit(1);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	noblox.setCookie(process.env.ROBLOSECURITY).then(async (current) => {
 | 
						noblox.setCookie(process.env.ROBLOSECURITY).then(async (current) => {
 | 
				
			||||||
		console.log(`${colors.cyan("[ROBLOX]")} Logged in as ${current.displayName}`);
 | 
							console.log(`${colors.cyan("[ROBLOX]")} Logged in as ${current.displayName}`);
 | 
				
			||||||
		console.log(`${colors.cyan("[ROBLOX]")} Fetching group data...`);
 | 
							console.log(`${colors.cyan("[ROBLOX]")} Fetching group data...`);
 | 
				
			||||||
| 
						 | 
					@ -98,20 +101,26 @@ discord.on('ready', async () => {
 | 
				
			||||||
		const webhooks = await channel.fetchWebhooks();
 | 
							const webhooks = await channel.fetchWebhooks();
 | 
				
			||||||
		webhook = webhooks.find(w => w.owner.id === discord.user.id && w.channelId == process.env.SUMMARY_CHANNEL_ID)
 | 
							webhook = webhooks.find(w => w.owner.id === discord.user.id && w.channelId == process.env.SUMMARY_CHANNEL_ID)
 | 
				
			||||||
		if (!webhook) {
 | 
							if (!webhook) {
 | 
				
			||||||
 | 
								console.log(`${colors.yellow("[DISCORD]")} No existing webhook found, creating a new one...`);
 | 
				
			||||||
			webhook = await channel.createWebhook({
 | 
								webhook = await channel.createWebhook({
 | 
				
			||||||
				name: `${groupData.name} Funds Summary`,
 | 
									name: `${groupData.name} Funds Summary`,
 | 
				
			||||||
				avatar: groupLogoUrl,
 | 
									avatar: groupLogoUrl,
 | 
				
			||||||
				reason: "Funds Summary Webhook"
 | 
									reason: "Funds Summary Webhook"
 | 
				
			||||||
			});
 | 
								});
 | 
				
			||||||
 | 
							} else {
 | 
				
			||||||
 | 
								console.log(`${colors.green("[DISCORD]")} Found existing webhook`);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		// Try to find the latest message from our webhook, if it doesnt exist send a new one
 | 
							// Try to find the latest message from our webhook, if it doesnt exist send a new one
 | 
				
			||||||
		message = await channel.messages.fetch().then(messages => messages.find(m => m.author.id === webhook.id));
 | 
							message = await channel.messages.fetch().then(messages => messages.find(m => m.author.id === webhook.id));
 | 
				
			||||||
		if (!message) {
 | 
							if (!message) {
 | 
				
			||||||
 | 
								console.log(`${colors.yellow("[DISCORD]")} No existing message found, sending a new one...`);
 | 
				
			||||||
			message = await webhook.send({
 | 
								message = await webhook.send({
 | 
				
			||||||
				embeds: [{
 | 
									embeds: [{
 | 
				
			||||||
					title: "Please wait..."
 | 
										title: "Please wait..."
 | 
				
			||||||
				}]
 | 
									}]
 | 
				
			||||||
			})
 | 
								})
 | 
				
			||||||
 | 
							} else {
 | 
				
			||||||
 | 
								console.log(`${colors.green("[DISCORD]")} Found existing message`);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		updateWebhook();
 | 
							updateWebhook();
 | 
				
			||||||
		setInterval(updateWebhook, 1 * 60 * 60 * 1000); // Update every hour
 | 
							setInterval(updateWebhook, 1 * 60 * 60 * 1000); // Update every hour
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue