Started moving common log messages to one spot
This commit is contained in:
		
							parent
							
								
									bff208d560
								
							
						
					
					
						commit
						021f33fc38
					
				
							
								
								
									
										12
									
								
								mod.ts
								
								
								
								
							
							
						
						
									
										12
									
								
								mod.ts
								
								
								
								
							| 
						 | 
					@ -85,22 +85,16 @@ startBot({
 | 
				
			||||||
					}],
 | 
										}],
 | 
				
			||||||
					status: 'online',
 | 
										status: 'online',
 | 
				
			||||||
				});
 | 
									});
 | 
				
			||||||
				sendMessage(config.logChannel, `${config.name} has started, running version ${config.version}.`).catch((e) => {
 | 
									sendMessage(config.logChannel, `${config.name} has started, running version ${config.version}.`).catch((e: Error) => utils.commonLoggers.messageSendError('mod.ts:88', 'Startup', e));
 | 
				
			||||||
					log(LT.ERROR, `Failed to send message: ${JSON.stringify(e)}`);
 | 
					 | 
				
			||||||
				});
 | 
					 | 
				
			||||||
			}, 1000);
 | 
								}, 1000);
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		guildCreate: (guild: DiscordenoGuild) => {
 | 
							guildCreate: (guild: DiscordenoGuild) => {
 | 
				
			||||||
			log(LT.LOG, `Handling joining guild ${JSON.stringify(guild)}`);
 | 
								log(LT.LOG, `Handling joining guild ${JSON.stringify(guild)}`);
 | 
				
			||||||
			sendMessage(config.logChannel, `New guild joined: ${guild.name} (id: ${guild.id}). This guild has ${guild.memberCount} members!`).catch((e) => {
 | 
								sendMessage(config.logChannel, `New guild joined: ${guild.name} (id: ${guild.id}). This guild has ${guild.memberCount} members!`).catch((e: Error) => utils.commonLoggers.messageSendError('mod.ts:95', 'Join Guild', e));
 | 
				
			||||||
				log(LT.ERROR, `Failed to send message: ${JSON.stringify(e)}`);
 | 
					 | 
				
			||||||
			});
 | 
					 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		guildDelete: (guild: DiscordenoGuild) => {
 | 
							guildDelete: (guild: DiscordenoGuild) => {
 | 
				
			||||||
			log(LT.LOG, `Handling leaving guild ${JSON.stringify(guild)}`);
 | 
								log(LT.LOG, `Handling leaving guild ${JSON.stringify(guild)}`);
 | 
				
			||||||
			sendMessage(config.logChannel, `I have been removed from: ${guild.name} (id: ${guild.id}).`).catch((e) => {
 | 
								sendMessage(config.logChannel, `I have been removed from: ${guild.name} (id: ${guild.id}).`).catch((e: Error) => utils.commonLoggers.messageSendError('mod.ts:99', 'Leave Guild', e));
 | 
				
			||||||
				log(LT.ERROR, `Failed to send message: ${JSON.stringify(e)}`);
 | 
					 | 
				
			||||||
			});
 | 
					 | 
				
			||||||
			dbClient.execute('DELETE FROM allowed_guilds WHERE guildid = ? AND banned = 0', [guild.id]).catch((e) => {
 | 
								dbClient.execute('DELETE FROM allowed_guilds WHERE guildid = ? AND banned = 0', [guild.id]).catch((e) => {
 | 
				
			||||||
				log(LT.ERROR, `Failed to DELETE guild from DB: ${JSON.stringify(e)}`);
 | 
									log(LT.ERROR, `Failed to DELETE guild from DB: ${JSON.stringify(e)}`);
 | 
				
			||||||
			});
 | 
								});
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -9,6 +9,7 @@ import {
 | 
				
			||||||
} from '../../deps.ts';
 | 
					} from '../../deps.ts';
 | 
				
			||||||
import apiCommands from './apiCmd/_index.ts';
 | 
					import apiCommands from './apiCmd/_index.ts';
 | 
				
			||||||
import { failColor } from '../commandUtils.ts';
 | 
					import { failColor } from '../commandUtils.ts';
 | 
				
			||||||
 | 
					import utils from '../utils.ts';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const api = async (message: DiscordenoMessage, args: string[]) => {
 | 
					export const api = async (message: DiscordenoMessage, args: string[]) => {
 | 
				
			||||||
	// Light telemetry to see how many times a command is being run
 | 
						// Light telemetry to see how many times a command is being run
 | 
				
			||||||
| 
						 | 
					@ -26,9 +27,7 @@ export const api = async (message: DiscordenoMessage, args: string[]) => {
 | 
				
			||||||
				color: failColor,
 | 
									color: failColor,
 | 
				
			||||||
				title: 'API commands are only available in guilds.',
 | 
									title: 'API commands are only available in guilds.',
 | 
				
			||||||
			}],
 | 
								}],
 | 
				
			||||||
		}).catch((e) => {
 | 
							}).catch((e: Error) => utils.commonLoggers.messageSendError('apiCmd.ts:30', message, e));
 | 
				
			||||||
			log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e)}`);
 | 
					 | 
				
			||||||
		});
 | 
					 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -75,8 +74,6 @@ export const api = async (message: DiscordenoMessage, args: string[]) => {
 | 
				
			||||||
				title: 'API commands are powerful and can only be used by guild Owners and Admins.',
 | 
									title: 'API commands are powerful and can only be used by guild Owners and Admins.',
 | 
				
			||||||
				description: 'For information on how to use the API, please check the GitHub README for more information [here](https://github.com/Burn-E99/TheArtificer).',
 | 
									description: 'For information on how to use the API, please check the GitHub README for more information [here](https://github.com/Burn-E99/TheArtificer).',
 | 
				
			||||||
			}],
 | 
								}],
 | 
				
			||||||
		}).catch((e) => {
 | 
							}).catch((e: Error) => utils.commonLoggers.messageSendError('apiCmd.ts:77', message, e));
 | 
				
			||||||
			log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e)}`);
 | 
					 | 
				
			||||||
		});
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,14 +7,13 @@ import {
 | 
				
			||||||
	LT,
 | 
						LT,
 | 
				
			||||||
} from '../../../deps.ts';
 | 
					} from '../../../deps.ts';
 | 
				
			||||||
import { generateApiFailed, generateApiSuccess } from '../../commandUtils.ts';
 | 
					import { generateApiFailed, generateApiSuccess } from '../../commandUtils.ts';
 | 
				
			||||||
 | 
					import utils from '../../utils.ts';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const allowBlock = async (message: DiscordenoMessage, apiArg: string) => {
 | 
					export const allowBlock = async (message: DiscordenoMessage, apiArg: string) => {
 | 
				
			||||||
	let errorOutInitial = false;
 | 
						let errorOutInitial = false;
 | 
				
			||||||
	const guildQuery = await dbClient.query(`SELECT guildid, channelid FROM allowed_guilds WHERE guildid = ? AND channelid = ?`, [message.guildId, message.channelId]).catch((e0) => {
 | 
						const guildQuery = await dbClient.query(`SELECT guildid, channelid FROM allowed_guilds WHERE guildid = ? AND channelid = ?`, [message.guildId, message.channelId]).catch((e0) => {
 | 
				
			||||||
		log(LT.ERROR, `Failed to query DB: ${JSON.stringify(e0)}`);
 | 
							log(LT.ERROR, `Failed to query DB: ${JSON.stringify(e0)}`);
 | 
				
			||||||
		message.send(generateApiFailed(apiArg)).catch((e1) => {
 | 
							message.send(generateApiFailed(apiArg)).catch((e: Error) => utils.commonLoggers.messageSendError('allowBlock.ts:16', message, e));
 | 
				
			||||||
			log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e1)}`);
 | 
					 | 
				
			||||||
		});
 | 
					 | 
				
			||||||
		errorOutInitial = true;
 | 
							errorOutInitial = true;
 | 
				
			||||||
	});
 | 
						});
 | 
				
			||||||
	if (errorOutInitial) return;
 | 
						if (errorOutInitial) return;
 | 
				
			||||||
| 
						 | 
					@ -25,9 +24,7 @@ export const allowBlock = async (message: DiscordenoMessage, apiArg: string) =>
 | 
				
			||||||
		await dbClient.execute(`INSERT INTO allowed_guilds(guildid,channelid,active) values(?,?,?)`, [message.guildId, message.channelId, (apiArg === 'allow' || apiArg === 'enable') ? 1 : 0]).catch(
 | 
							await dbClient.execute(`INSERT INTO allowed_guilds(guildid,channelid,active) values(?,?,?)`, [message.guildId, message.channelId, (apiArg === 'allow' || apiArg === 'enable') ? 1 : 0]).catch(
 | 
				
			||||||
			(e0) => {
 | 
								(e0) => {
 | 
				
			||||||
				log(LT.ERROR, `Failed to insert into DB: ${JSON.stringify(e0)}`);
 | 
									log(LT.ERROR, `Failed to insert into DB: ${JSON.stringify(e0)}`);
 | 
				
			||||||
				message.send(generateApiFailed(apiArg)).catch((e1) => {
 | 
									message.send(generateApiFailed(apiArg)).catch((e: Error) => utils.commonLoggers.messageSendError('allowBlock.ts:27', message, e));
 | 
				
			||||||
					log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e1)}`);
 | 
					 | 
				
			||||||
				});
 | 
					 | 
				
			||||||
				errorOut = true;
 | 
									errorOut = true;
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
		);
 | 
							);
 | 
				
			||||||
| 
						 | 
					@ -36,9 +33,7 @@ export const allowBlock = async (message: DiscordenoMessage, apiArg: string) =>
 | 
				
			||||||
		await dbClient.execute(`UPDATE allowed_guilds SET active = ? WHERE guildid = ? AND channelid = ?`, [(apiArg === 'allow' || apiArg === 'enable') ? 1 : 0, message.guildId, message.channelId]).catch(
 | 
							await dbClient.execute(`UPDATE allowed_guilds SET active = ? WHERE guildid = ? AND channelid = ?`, [(apiArg === 'allow' || apiArg === 'enable') ? 1 : 0, message.guildId, message.channelId]).catch(
 | 
				
			||||||
			(e0) => {
 | 
								(e0) => {
 | 
				
			||||||
				log(LT.ERROR, `Failed to update DB: ${JSON.stringify(e0)}`);
 | 
									log(LT.ERROR, `Failed to update DB: ${JSON.stringify(e0)}`);
 | 
				
			||||||
				message.send(generateApiFailed(apiArg)).catch((e1) => {
 | 
									message.send(generateApiFailed(apiArg)).catch((e: Error) => utils.commonLoggers.messageSendError('allowBlock.ts:36', message, e));
 | 
				
			||||||
					log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e1)}`);
 | 
					 | 
				
			||||||
				});
 | 
					 | 
				
			||||||
				errorOut = true;
 | 
									errorOut = true;
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
		);
 | 
							);
 | 
				
			||||||
| 
						 | 
					@ -46,7 +41,5 @@ export const allowBlock = async (message: DiscordenoMessage, apiArg: string) =>
 | 
				
			||||||
	if (errorOut) return;
 | 
						if (errorOut) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// We won't get here if there's any errors, so we know it has bee successful, so report as such
 | 
						// We won't get here if there's any errors, so we know it has bee successful, so report as such
 | 
				
			||||||
	message.send(generateApiSuccess(`${apiArg}ed`)).catch((e) => {
 | 
						message.send(generateApiSuccess(`${apiArg}ed`)).catch((e: Error) => utils.commonLoggers.messageSendError('allowBlock.ts:44', message, e));
 | 
				
			||||||
		log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e)}`);
 | 
					 | 
				
			||||||
	});
 | 
					 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,6 +7,7 @@ import {
 | 
				
			||||||
	LT,
 | 
						LT,
 | 
				
			||||||
} from '../../../deps.ts';
 | 
					} from '../../../deps.ts';
 | 
				
			||||||
import { infoColor1, infoColor2 } from '../../commandUtils.ts';
 | 
					import { infoColor1, infoColor2 } from '../../commandUtils.ts';
 | 
				
			||||||
 | 
					import utils from '../../utils.ts';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const help = (message: DiscordenoMessage) => {
 | 
					export const help = (message: DiscordenoMessage) => {
 | 
				
			||||||
	message.send({
 | 
						message.send({
 | 
				
			||||||
| 
						 | 
					@ -63,7 +64,5 @@ You may enable and disable the API rolls for your guild as needed.`,
 | 
				
			||||||
				],
 | 
									],
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
		],
 | 
							],
 | 
				
			||||||
	}).catch((e) => {
 | 
						}).catch((e: Error) => utils.commonLoggers.messageSendError('apiHelp.ts:67', message, e));
 | 
				
			||||||
		log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e)}`);
 | 
					 | 
				
			||||||
	});
 | 
					 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,6 +7,7 @@ import {
 | 
				
			||||||
	LT,
 | 
						LT,
 | 
				
			||||||
} from '../../../deps.ts';
 | 
					} from '../../../deps.ts';
 | 
				
			||||||
import { failColor, successColor } from '../../commandUtils.ts';
 | 
					import { failColor, successColor } from '../../commandUtils.ts';
 | 
				
			||||||
 | 
					import utils from '../../utils.ts';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const deleteGuild = async (message: DiscordenoMessage) => {
 | 
					export const deleteGuild = async (message: DiscordenoMessage) => {
 | 
				
			||||||
	let errorOut = false;
 | 
						let errorOut = false;
 | 
				
			||||||
| 
						 | 
					@ -18,9 +19,7 @@ export const deleteGuild = async (message: DiscordenoMessage) => {
 | 
				
			||||||
				title: 'Failed to delete this guild from the database.',
 | 
									title: 'Failed to delete this guild from the database.',
 | 
				
			||||||
				description: 'If this issue persists, please report this to the developers.',
 | 
									description: 'If this issue persists, please report this to the developers.',
 | 
				
			||||||
			}],
 | 
								}],
 | 
				
			||||||
		}).catch((e1) => {
 | 
							}).catch((e: Error) => utils.commonLoggers.messageSendError('deleteGuild.ts:22', message, e));
 | 
				
			||||||
			log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e1)}`);
 | 
					 | 
				
			||||||
		});
 | 
					 | 
				
			||||||
		errorOut = true;
 | 
							errorOut = true;
 | 
				
			||||||
	});
 | 
						});
 | 
				
			||||||
	if (errorOut) return;
 | 
						if (errorOut) return;
 | 
				
			||||||
| 
						 | 
					@ -31,7 +30,5 @@ export const deleteGuild = async (message: DiscordenoMessage) => {
 | 
				
			||||||
			color: successColor,
 | 
								color: successColor,
 | 
				
			||||||
			title: 'This guild\'s API setting has been removed from The Artifier\'s Database.',
 | 
								title: 'This guild\'s API setting has been removed from The Artifier\'s Database.',
 | 
				
			||||||
		}],
 | 
							}],
 | 
				
			||||||
	}).catch((e) => {
 | 
						}).catch((e: Error) => utils.commonLoggers.messageSendError('deleteGuild.ts:33', message, e));
 | 
				
			||||||
		log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e)}`);
 | 
					 | 
				
			||||||
	});
 | 
					 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,14 +7,13 @@ import {
 | 
				
			||||||
	LT,
 | 
						LT,
 | 
				
			||||||
} from '../../../deps.ts';
 | 
					} from '../../../deps.ts';
 | 
				
			||||||
import { generateApiFailed, generateApiSuccess } from '../../commandUtils.ts';
 | 
					import { generateApiFailed, generateApiSuccess } from '../../commandUtils.ts';
 | 
				
			||||||
 | 
					import utils from '../../utils.ts';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const showHideWarn = async (message: DiscordenoMessage, apiArg: string) => {
 | 
					export const showHideWarn = async (message: DiscordenoMessage, apiArg: string) => {
 | 
				
			||||||
	let errorOutInitial = false;
 | 
						let errorOutInitial = false;
 | 
				
			||||||
	const guildQuery = await dbClient.query(`SELECT guildid, channelid FROM allowed_guilds WHERE guildid = ? AND channelid = ?`, [message.guildId, message.channelId]).catch((e0) => {
 | 
						const guildQuery = await dbClient.query(`SELECT guildid, channelid FROM allowed_guilds WHERE guildid = ? AND channelid = ?`, [message.guildId, message.channelId]).catch((e0) => {
 | 
				
			||||||
		log(LT.ERROR, `Failed to query DB: ${JSON.stringify(e0)}`);
 | 
							log(LT.ERROR, `Failed to query DB: ${JSON.stringify(e0)}`);
 | 
				
			||||||
		message.send(generateApiFailed(`${apiArg} on`)).catch((e1) => {
 | 
							message.send(generateApiFailed(`${apiArg} on`)).catch((e: Error) => utils.commonLoggers.messageSendError('showHideWarn.ts:16', message, e));
 | 
				
			||||||
			log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e1)}`);
 | 
					 | 
				
			||||||
		});
 | 
					 | 
				
			||||||
		errorOutInitial = true;
 | 
							errorOutInitial = true;
 | 
				
			||||||
	});
 | 
						});
 | 
				
			||||||
	if (errorOutInitial) return;
 | 
						if (errorOutInitial) return;
 | 
				
			||||||
| 
						 | 
					@ -24,25 +23,19 @@ export const showHideWarn = async (message: DiscordenoMessage, apiArg: string) =
 | 
				
			||||||
		// Since guild is not in our DB, add it in
 | 
							// Since guild is not in our DB, add it in
 | 
				
			||||||
		await dbClient.execute(`INSERT INTO allowed_guilds(guildid,channelid,hidewarn) values(?,?,?)`, [message.guildId, message.channelId, (apiArg === 'hide-warn') ? 1 : 0]).catch((e0) => {
 | 
							await dbClient.execute(`INSERT INTO allowed_guilds(guildid,channelid,hidewarn) values(?,?,?)`, [message.guildId, message.channelId, (apiArg === 'hide-warn') ? 1 : 0]).catch((e0) => {
 | 
				
			||||||
			log(LT.ERROR, `Failed to insert into DB: ${JSON.stringify(e0)}`);
 | 
								log(LT.ERROR, `Failed to insert into DB: ${JSON.stringify(e0)}`);
 | 
				
			||||||
			message.send(generateApiFailed(`${apiArg} on`)).catch((e1) => {
 | 
								message.send(generateApiFailed(`${apiArg} on`)).catch((e: Error) => utils.commonLoggers.messageSendError('showHideWarn.ts:26', message, e));
 | 
				
			||||||
				log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e1)}`);
 | 
					 | 
				
			||||||
			});
 | 
					 | 
				
			||||||
			errorOut = true;
 | 
								errorOut = true;
 | 
				
			||||||
		});
 | 
							});
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		// Since guild is in our DB, update it
 | 
							// Since guild is in our DB, update it
 | 
				
			||||||
		await dbClient.execute(`UPDATE allowed_guilds SET hidewarn = ? WHERE guildid = ? AND channelid = ?`, [(apiArg === 'hide-warn') ? 1 : 0, message.guildId, message.channelId]).catch((e0) => {
 | 
							await dbClient.execute(`UPDATE allowed_guilds SET hidewarn = ? WHERE guildid = ? AND channelid = ?`, [(apiArg === 'hide-warn') ? 1 : 0, message.guildId, message.channelId]).catch((e0) => {
 | 
				
			||||||
			log(LT.ERROR, `Failed to update DB: ${JSON.stringify(e0)}`);
 | 
								log(LT.ERROR, `Failed to update DB: ${JSON.stringify(e0)}`);
 | 
				
			||||||
			message.send(generateApiFailed(`${apiArg} on`)).catch((e1) => {
 | 
								message.send(generateApiFailed(`${apiArg} on`)).catch((e: Error) => utils.commonLoggers.messageSendError('showHideWarn.ts:33', message, e));
 | 
				
			||||||
				log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e1)}`);
 | 
					 | 
				
			||||||
			});
 | 
					 | 
				
			||||||
			errorOut = true;
 | 
								errorOut = true;
 | 
				
			||||||
		});
 | 
							});
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if (errorOut) return;
 | 
						if (errorOut) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// We won't get here if there's any errors, so we know it has bee successful, so report as such
 | 
						// We won't get here if there's any errors, so we know it has bee successful, so report as such
 | 
				
			||||||
	message.send(generateApiSuccess(apiArg)).catch((e) => {
 | 
						message.send(generateApiSuccess(apiArg)).catch((e: Error) => utils.commonLoggers.messageSendError('showHideWarn.ts:40', message, e));
 | 
				
			||||||
		log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e)}`);
 | 
					 | 
				
			||||||
	});
 | 
					 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,6 +7,7 @@ import {
 | 
				
			||||||
	LT,
 | 
						LT,
 | 
				
			||||||
} from '../../../deps.ts';
 | 
					} from '../../../deps.ts';
 | 
				
			||||||
import { failColor, generateApiStatus } from '../../commandUtils.ts';
 | 
					import { failColor, generateApiStatus } from '../../commandUtils.ts';
 | 
				
			||||||
 | 
					import utils from '../../utils.ts';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const status = async (message: DiscordenoMessage) => {
 | 
					export const status = async (message: DiscordenoMessage) => {
 | 
				
			||||||
	// Get status of guild from the db
 | 
						// Get status of guild from the db
 | 
				
			||||||
| 
						 | 
					@ -19,9 +20,7 @@ export const status = async (message: DiscordenoMessage) => {
 | 
				
			||||||
				title: 'Failed to check API rolls status for this guild.',
 | 
									title: 'Failed to check API rolls status for this guild.',
 | 
				
			||||||
				description: 'If this issue persists, please report this to the developers.',
 | 
									description: 'If this issue persists, please report this to the developers.',
 | 
				
			||||||
			}],
 | 
								}],
 | 
				
			||||||
		}).catch((e1) => {
 | 
							}).catch((e: Error) => utils.commonLoggers.messageSendError('status.ts:23', message, e));
 | 
				
			||||||
			log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e1)}`);
 | 
					 | 
				
			||||||
		});
 | 
					 | 
				
			||||||
		errorOut = true;
 | 
							errorOut = true;
 | 
				
			||||||
	});
 | 
						});
 | 
				
			||||||
	if (errorOut) return;
 | 
						if (errorOut) return;
 | 
				
			||||||
| 
						 | 
					@ -30,18 +29,12 @@ export const status = async (message: DiscordenoMessage) => {
 | 
				
			||||||
	if (guildQuery.length > 0) {
 | 
						if (guildQuery.length > 0) {
 | 
				
			||||||
		// Check if guild is banned from using API and return appropriate message
 | 
							// Check if guild is banned from using API and return appropriate message
 | 
				
			||||||
		if (guildQuery[0].banned) {
 | 
							if (guildQuery[0].banned) {
 | 
				
			||||||
			message.send(generateApiStatus(true, false)).catch((e) => {
 | 
								message.send(generateApiStatus(true, false)).catch((e: Error) => utils.commonLoggers.messageSendError('status.ts:32', message, e));
 | 
				
			||||||
				log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e)}`);
 | 
					 | 
				
			||||||
			});
 | 
					 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			message.send(generateApiStatus(false, guildQuery[0].active)).catch((e) => {
 | 
								message.send(generateApiStatus(false, guildQuery[0].active)).catch((e: Error) => utils.commonLoggers.messageSendError('status.ts:34', message, e));
 | 
				
			||||||
				log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e)}`);
 | 
					 | 
				
			||||||
			});
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		// Guild is not in DB, therefore they are blocked
 | 
							// Guild is not in DB, therefore they are blocked
 | 
				
			||||||
		message.send(generateApiStatus(false, false)).catch((e) => {
 | 
							message.send(generateApiStatus(false, false)).catch((e: Error) => utils.commonLoggers.messageSendError('status.ts:38', message, e));
 | 
				
			||||||
			log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e)}`);
 | 
					 | 
				
			||||||
		});
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -9,6 +9,7 @@ import {
 | 
				
			||||||
} from '../../deps.ts';
 | 
					} from '../../deps.ts';
 | 
				
			||||||
import auditCommands from './auditCmd/_index.ts';
 | 
					import auditCommands from './auditCmd/_index.ts';
 | 
				
			||||||
import { failColor } from '../commandUtils.ts';
 | 
					import { failColor } from '../commandUtils.ts';
 | 
				
			||||||
 | 
					import utils from '../utils.ts';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const audit = async (message: DiscordenoMessage, args: string[]) => {
 | 
					export const audit = async (message: DiscordenoMessage, args: string[]) => {
 | 
				
			||||||
	// Light telemetry to see how many times a command is being run
 | 
						// Light telemetry to see how many times a command is being run
 | 
				
			||||||
| 
						 | 
					@ -47,8 +48,6 @@ export const audit = async (message: DiscordenoMessage, args: string[]) => {
 | 
				
			||||||
				color: failColor,
 | 
									color: failColor,
 | 
				
			||||||
				title: `Audit commands are powerful and can only be used by ${config.name}'s owner.`,
 | 
									title: `Audit commands are powerful and can only be used by ${config.name}'s owner.`,
 | 
				
			||||||
			}],
 | 
								}],
 | 
				
			||||||
		}).catch((e) => {
 | 
							}).catch((e: Error) => utils.commonLoggers.messageSendError('audit.ts:51', message, e));
 | 
				
			||||||
			log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e)}`);
 | 
					 | 
				
			||||||
		});
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -9,6 +9,7 @@ import {
 | 
				
			||||||
} from '../../../deps.ts';
 | 
					} from '../../../deps.ts';
 | 
				
			||||||
import { infoColor2 } from '../../commandUtils.ts';
 | 
					import { infoColor2 } from '../../commandUtils.ts';
 | 
				
			||||||
import { compilingStats } from '../../commonEmbeds.ts';
 | 
					import { compilingStats } from '../../commonEmbeds.ts';
 | 
				
			||||||
 | 
					import utils from '../../utils.ts';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const auditDB = async (message: DiscordenoMessage) => {
 | 
					export const auditDB = async (message: DiscordenoMessage) => {
 | 
				
			||||||
	try {
 | 
						try {
 | 
				
			||||||
| 
						 | 
					@ -39,10 +40,8 @@ export const auditDB = async (message: DiscordenoMessage) => {
 | 
				
			||||||
				timestamp: new Date().toISOString(),
 | 
									timestamp: new Date().toISOString(),
 | 
				
			||||||
				fields: embedFields,
 | 
									fields: embedFields,
 | 
				
			||||||
			}],
 | 
								}],
 | 
				
			||||||
		}).catch((e) => {
 | 
							}).catch((e: Error) => utils.commonLoggers.messageSendError('auditDB.ts:43', message, e));
 | 
				
			||||||
			log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e)}`);
 | 
					 | 
				
			||||||
		});
 | 
					 | 
				
			||||||
	} catch (e) {
 | 
						} catch (e) {
 | 
				
			||||||
		log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e)}`);
 | 
							utils.commonLoggers.messageSendError('auditDB.ts:45', message, e)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -6,6 +6,7 @@ import {
 | 
				
			||||||
	LT,
 | 
						LT,
 | 
				
			||||||
} from '../../../deps.ts';
 | 
					} from '../../../deps.ts';
 | 
				
			||||||
import { infoColor2 } from '../../commandUtils.ts';
 | 
					import { infoColor2 } from '../../commandUtils.ts';
 | 
				
			||||||
 | 
					import utils from '../../utils.ts';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const auditGuilds = (message: DiscordenoMessage) => {
 | 
					export const auditGuilds = (message: DiscordenoMessage) => {
 | 
				
			||||||
	message.send({
 | 
						message.send({
 | 
				
			||||||
| 
						 | 
					@ -15,7 +16,5 @@ export const auditGuilds = (message: DiscordenoMessage) => {
 | 
				
			||||||
			description: 'WIP',
 | 
								description: 'WIP',
 | 
				
			||||||
			timestamp: new Date().toISOString(),
 | 
								timestamp: new Date().toISOString(),
 | 
				
			||||||
		}],
 | 
							}],
 | 
				
			||||||
	}).catch((e) => {
 | 
						}).catch((e: Error) => utils.commonLoggers.messageSendError('auditGuild.ts:19', message, e));
 | 
				
			||||||
		log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e)}`);
 | 
					 | 
				
			||||||
	});
 | 
					 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,6 +7,7 @@ import {
 | 
				
			||||||
	LT,
 | 
						LT,
 | 
				
			||||||
} from '../../../deps.ts';
 | 
					} from '../../../deps.ts';
 | 
				
			||||||
import { infoColor1 } from '../../commandUtils.ts';
 | 
					import { infoColor1 } from '../../commandUtils.ts';
 | 
				
			||||||
 | 
					import utils from '../../utils.ts';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const auditHelp = (message: DiscordenoMessage) => {
 | 
					export const auditHelp = (message: DiscordenoMessage) => {
 | 
				
			||||||
	message.send({
 | 
						message.send({
 | 
				
			||||||
| 
						 | 
					@ -31,7 +32,5 @@ export const auditHelp = (message: DiscordenoMessage) => {
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
			],
 | 
								],
 | 
				
			||||||
		}],
 | 
							}],
 | 
				
			||||||
	}).catch((e) => {
 | 
						}).catch((e: Error) => utils.commonLoggers.messageSendError('auditHelp.ts:35', message, e));
 | 
				
			||||||
		log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e)}`);
 | 
					 | 
				
			||||||
	});
 | 
					 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8,6 +8,7 @@ import {
 | 
				
			||||||
	LT,
 | 
						LT,
 | 
				
			||||||
} from '../../deps.ts';
 | 
					} from '../../deps.ts';
 | 
				
			||||||
import { EmojiConf } from '../mod.d.ts';
 | 
					import { EmojiConf } from '../mod.d.ts';
 | 
				
			||||||
 | 
					import utils from '../utils.ts';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const allEmojiAliases: string[] = [];
 | 
					const allEmojiAliases: string[] = [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -29,14 +30,10 @@ export const emoji = (message: DiscordenoMessage, command: string) => {
 | 
				
			||||||
				});
 | 
									});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				// Send the needed emoji
 | 
									// Send the needed emoji
 | 
				
			||||||
				message.send(`<${emji.animated ? 'a' : ''}:${emji.name}:${emji.id}>`).catch((e) => {
 | 
									message.send(`<${emji.animated ? 'a' : ''}:${emji.name}:${emji.id}>`).catch((e: Error) => utils.commonLoggers.messageSendError('emoji.ts:33', message, e));
 | 
				
			||||||
					log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e)}`);
 | 
					 | 
				
			||||||
				});
 | 
					 | 
				
			||||||
				// And attempt to delete if needed
 | 
									// And attempt to delete if needed
 | 
				
			||||||
				if (emji.deleteSender) {
 | 
									if (emji.deleteSender) {
 | 
				
			||||||
					message.delete().catch((e) => {
 | 
										message.delete().catch((e: Error) => utils.commonLoggers.messageDeleteError('emoji.ts:36', message, e));
 | 
				
			||||||
						log(LT.WARN, `Failed to delete message: ${JSON.stringify(message)} | ${JSON.stringify(e)}`);
 | 
					 | 
				
			||||||
					});
 | 
					 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				return true;
 | 
									return true;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8,6 +8,7 @@ import {
 | 
				
			||||||
	LT,
 | 
						LT,
 | 
				
			||||||
} from '../../deps.ts';
 | 
					} from '../../deps.ts';
 | 
				
			||||||
import { infoColor1 } from '../commandUtils.ts';
 | 
					import { infoColor1 } from '../commandUtils.ts';
 | 
				
			||||||
 | 
					import utils from '../utils.ts';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const handleMentions = (message: DiscordenoMessage) => {
 | 
					export const handleMentions = (message: DiscordenoMessage) => {
 | 
				
			||||||
	log(LT.LOG, `Handling @mention message: ${JSON.stringify(message)}`);
 | 
						log(LT.LOG, `Handling @mention message: ${JSON.stringify(message)}`);
 | 
				
			||||||
| 
						 | 
					@ -26,7 +27,5 @@ export const handleMentions = (message: DiscordenoMessage) => {
 | 
				
			||||||
				value: `To learn about my available commands, please run \`${config.prefix}help\``,
 | 
									value: `To learn about my available commands, please run \`${config.prefix}help\``,
 | 
				
			||||||
			}],
 | 
								}],
 | 
				
			||||||
		}],
 | 
							}],
 | 
				
			||||||
	}).catch((e) => {
 | 
						}).catch((e: Error) => utils.commonLoggers.messageSendError('handleMentions.ts:30', message, e));
 | 
				
			||||||
		log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e)}`);
 | 
					 | 
				
			||||||
	});
 | 
					 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8,6 +8,7 @@ import {
 | 
				
			||||||
	LT,
 | 
						LT,
 | 
				
			||||||
} from '../../deps.ts';
 | 
					} from '../../deps.ts';
 | 
				
			||||||
import { infoColor2 } from '../commandUtils.ts';
 | 
					import { infoColor2 } from '../commandUtils.ts';
 | 
				
			||||||
 | 
					import utils from '../utils.ts';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const help = (message: DiscordenoMessage) => {
 | 
					export const help = (message: DiscordenoMessage) => {
 | 
				
			||||||
	// Light telemetry to see how many times a command is being run
 | 
						// Light telemetry to see how many times a command is being run
 | 
				
			||||||
| 
						 | 
					@ -78,7 +79,5 @@ export const help = (message: DiscordenoMessage) => {
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
			],
 | 
								],
 | 
				
			||||||
		}],
 | 
							}],
 | 
				
			||||||
	}).catch((e) => {
 | 
						}).catch((e: Error) => utils.commonLoggers.messageSendError('help.ts:82', message, e));
 | 
				
			||||||
		log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e)}`);
 | 
					 | 
				
			||||||
	});
 | 
					 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,6 +7,7 @@ import {
 | 
				
			||||||
	LT,
 | 
						LT,
 | 
				
			||||||
} from '../../deps.ts';
 | 
					} from '../../deps.ts';
 | 
				
			||||||
import { infoColor2 } from '../commandUtils.ts';
 | 
					import { infoColor2 } from '../commandUtils.ts';
 | 
				
			||||||
 | 
					import utils from '../utils.ts';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const info = (message: DiscordenoMessage) => {
 | 
					export const info = (message: DiscordenoMessage) => {
 | 
				
			||||||
	// Light telemetry to see how many times a command is being run
 | 
						// Light telemetry to see how many times a command is being run
 | 
				
			||||||
| 
						 | 
					@ -23,7 +24,5 @@ Additional information can be found on my website [here](https://discord.burne99
 | 
				
			||||||
Want to check out my source code?  Check it out [here](https://github.com/Burn-E99/TheArtificer).
 | 
					Want to check out my source code?  Check it out [here](https://github.com/Burn-E99/TheArtificer).
 | 
				
			||||||
Need help with this bot?  Join my support server [here](https://discord.gg/peHASXMZYv).`,
 | 
					Need help with this bot?  Join my support server [here](https://discord.gg/peHASXMZYv).`,
 | 
				
			||||||
		}],
 | 
							}],
 | 
				
			||||||
	}).catch((e) => {
 | 
						}).catch((e: Error) => utils.commonLoggers.messageSendError('info.ts:27', message, e));
 | 
				
			||||||
		log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e)}`);
 | 
					 | 
				
			||||||
	});
 | 
					 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,6 +7,7 @@ import {
 | 
				
			||||||
	LT,
 | 
						LT,
 | 
				
			||||||
} from '../../deps.ts';
 | 
					} from '../../deps.ts';
 | 
				
			||||||
import { generatePing } from '../commandUtils.ts';
 | 
					import { generatePing } from '../commandUtils.ts';
 | 
				
			||||||
 | 
					import utils from '../utils.ts';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const ping = async (message: DiscordenoMessage) => {
 | 
					export const ping = async (message: DiscordenoMessage) => {
 | 
				
			||||||
	// Light telemetry to see how many times a command is being run
 | 
						// Light telemetry to see how many times a command is being run
 | 
				
			||||||
| 
						 | 
					@ -19,6 +20,6 @@ export const ping = async (message: DiscordenoMessage) => {
 | 
				
			||||||
		const m = await message.send(generatePing(-1));
 | 
							const m = await message.send(generatePing(-1));
 | 
				
			||||||
		m.edit(generatePing(m.timestamp - message.timestamp));
 | 
							m.edit(generatePing(m.timestamp - message.timestamp));
 | 
				
			||||||
	} catch (e) {
 | 
						} catch (e) {
 | 
				
			||||||
		log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e)}`);
 | 
							utils.commonLoggers.messageSendError('ping.ts:23', message, e);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8,6 +8,7 @@ import {
 | 
				
			||||||
	LT,
 | 
						LT,
 | 
				
			||||||
} from '../../deps.ts';
 | 
					} from '../../deps.ts';
 | 
				
			||||||
import { infoColor1 } from '../commandUtils.ts';
 | 
					import { infoColor1 } from '../commandUtils.ts';
 | 
				
			||||||
 | 
					import utils from '../utils.ts';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const privacy = (message: DiscordenoMessage) => {
 | 
					export const privacy = (message: DiscordenoMessage) => {
 | 
				
			||||||
	// Light telemetry to see how many times a command is being run
 | 
						// Light telemetry to see how many times a command is being run
 | 
				
			||||||
| 
						 | 
					@ -29,7 +30,5 @@ For more details, please check out the Privacy Policy on the GitHub [here](https
 | 
				
			||||||
Terms of Service can also be found on GitHub [here](https://github.com/Burn-E99/TheArtificer/blob/master/TERMS.md).`,
 | 
					Terms of Service can also be found on GitHub [here](https://github.com/Burn-E99/TheArtificer/blob/master/TERMS.md).`,
 | 
				
			||||||
			}],
 | 
								}],
 | 
				
			||||||
		}],
 | 
							}],
 | 
				
			||||||
	}).catch((e) => {
 | 
						}).catch((e: Error) => utils.commonLoggers.messageSendError('privacy.ts:33', message, e));
 | 
				
			||||||
		log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e)}`);
 | 
					 | 
				
			||||||
	});
 | 
					 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -10,6 +10,7 @@ import {
 | 
				
			||||||
	sendMessage,
 | 
						sendMessage,
 | 
				
			||||||
} from '../../deps.ts';
 | 
					} from '../../deps.ts';
 | 
				
			||||||
import { failColor, generateReport, successColor } from '../commandUtils.ts';
 | 
					import { failColor, generateReport, successColor } from '../commandUtils.ts';
 | 
				
			||||||
 | 
					import utils from '../utils.ts';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const report = (message: DiscordenoMessage, args: string[]) => {
 | 
					export const report = (message: DiscordenoMessage, args: string[]) => {
 | 
				
			||||||
	// Light telemetry to see how many times a command is being run
 | 
						// Light telemetry to see how many times a command is being run
 | 
				
			||||||
| 
						 | 
					@ -18,18 +19,14 @@ export const report = (message: DiscordenoMessage, args: string[]) => {
 | 
				
			||||||
	});
 | 
						});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (args.join(' ')) {
 | 
						if (args.join(' ')) {
 | 
				
			||||||
		sendMessage(config.reportChannel, generateReport(args.join(' '))).catch((e) => {
 | 
							sendMessage(config.reportChannel, generateReport(args.join(' '))).catch((e: Error) => utils.commonLoggers.messageSendError('report.ts:22', message, e));
 | 
				
			||||||
			log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e)}`);
 | 
					 | 
				
			||||||
		});
 | 
					 | 
				
			||||||
		message.send({
 | 
							message.send({
 | 
				
			||||||
			embeds: [{
 | 
								embeds: [{
 | 
				
			||||||
				color: successColor,
 | 
									color: successColor,
 | 
				
			||||||
				title: 'Failed command has been reported to my developer.',
 | 
									title: 'Failed command has been reported to my developer.',
 | 
				
			||||||
				description: `For more in depth support, and information about planned maintenance, please join the support server [here](https://discord.gg/peHASXMZYv).`,
 | 
									description: `For more in depth support, and information about planned maintenance, please join the support server [here](https://discord.gg/peHASXMZYv).`,
 | 
				
			||||||
			}],
 | 
								}],
 | 
				
			||||||
		}).catch((e) => {
 | 
							}).catch((e: Error) => utils.commonLoggers.messageSendError('report.ts:29', message, e));
 | 
				
			||||||
			log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e)}`);
 | 
					 | 
				
			||||||
		});
 | 
					 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		message.send({
 | 
							message.send({
 | 
				
			||||||
			embeds: [{
 | 
								embeds: [{
 | 
				
			||||||
| 
						 | 
					@ -37,8 +34,6 @@ export const report = (message: DiscordenoMessage, args: string[]) => {
 | 
				
			||||||
				title: 'Please provide a short description of what failed',
 | 
									title: 'Please provide a short description of what failed',
 | 
				
			||||||
				description: 'Providing a short description helps my developer quickly diagnose what went wrong.',
 | 
									description: 'Providing a short description helps my developer quickly diagnose what went wrong.',
 | 
				
			||||||
			}],
 | 
								}],
 | 
				
			||||||
		}).catch((e) => {
 | 
							}).catch((e: Error) => utils.commonLoggers.messageSendError('report.ts:37', message, e));
 | 
				
			||||||
			log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e)}`);
 | 
					 | 
				
			||||||
		});
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,6 +7,7 @@ import {
 | 
				
			||||||
	LT,
 | 
						LT,
 | 
				
			||||||
} from '../../deps.ts';
 | 
					} from '../../deps.ts';
 | 
				
			||||||
import { infoColor2 } from '../commandUtils.ts';
 | 
					import { infoColor2 } from '../commandUtils.ts';
 | 
				
			||||||
 | 
					import utils from '../utils.ts';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const rip = (message: DiscordenoMessage) => {
 | 
					export const rip = (message: DiscordenoMessage) => {
 | 
				
			||||||
	// Light telemetry to see how many times a command is being run
 | 
						// Light telemetry to see how many times a command is being run
 | 
				
			||||||
| 
						 | 
					@ -22,7 +23,5 @@ export const rip = (message: DiscordenoMessage) => {
 | 
				
			||||||
			
 | 
								
 | 
				
			||||||
			December 21, 2020`,
 | 
								December 21, 2020`,
 | 
				
			||||||
		}],
 | 
							}],
 | 
				
			||||||
	}).catch((e) => {
 | 
						}).catch((e: Error) => utils.commonLoggers.messageSendError('rip.ts:26', message, e));
 | 
				
			||||||
		log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e)}`);
 | 
					 | 
				
			||||||
	});
 | 
					 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -12,6 +12,7 @@ import { rollingEmbed, warnColor } from '../commandUtils.ts';
 | 
				
			||||||
import rollFuncs from './roll/_index.ts';
 | 
					import rollFuncs from './roll/_index.ts';
 | 
				
			||||||
import { queueRoll } from '../solver/rollQueue.ts';
 | 
					import { queueRoll } from '../solver/rollQueue.ts';
 | 
				
			||||||
import { QueuedRoll } from '../mod.d.ts';
 | 
					import { QueuedRoll } from '../mod.d.ts';
 | 
				
			||||||
 | 
					import utils from '../utils.ts';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const roll = async (message: DiscordenoMessage, args: string[], command: string) => {
 | 
					export const roll = async (message: DiscordenoMessage, args: string[], command: string) => {
 | 
				
			||||||
	// Light telemetry to see how many times a command is being run
 | 
						// Light telemetry to see how many times a command is being run
 | 
				
			||||||
| 
						 | 
					@ -26,9 +27,7 @@ export const roll = async (message: DiscordenoMessage, args: string[], command:
 | 
				
			||||||
				color: warnColor,
 | 
									color: warnColor,
 | 
				
			||||||
				title: 'Command is in development, please try again later.',
 | 
									title: 'Command is in development, please try again later.',
 | 
				
			||||||
			}],
 | 
								}],
 | 
				
			||||||
		}).catch((e) => {
 | 
							}).catch((e: Error) => utils.commonLoggers.messageSendError('roll.ts:30', message, e));
 | 
				
			||||||
			log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e)}`);
 | 
					 | 
				
			||||||
		});
 | 
					 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8,6 +8,7 @@ import {
 | 
				
			||||||
	LT,
 | 
						LT,
 | 
				
			||||||
} from '../../deps.ts';
 | 
					} from '../../deps.ts';
 | 
				
			||||||
import { infoColor1, infoColor2, successColor } from '../commandUtils.ts';
 | 
					import { infoColor1, infoColor2, successColor } from '../commandUtils.ts';
 | 
				
			||||||
 | 
					import utils from '../utils.ts';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const rollHelp = (message: DiscordenoMessage) => {
 | 
					export const rollHelp = (message: DiscordenoMessage) => {
 | 
				
			||||||
	// Light telemetry to see how many times a command is being run
 | 
						// Light telemetry to see how many times a command is being run
 | 
				
			||||||
| 
						 | 
					@ -243,7 +244,5 @@ Available directions:
 | 
				
			||||||
				],
 | 
									],
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
		],
 | 
							],
 | 
				
			||||||
	}).catch((e) => {
 | 
						}).catch((e: Error) => utils.commonLoggers.messageSendError('rollHelp.ts:247', message, e));
 | 
				
			||||||
		log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e)}`);
 | 
					 | 
				
			||||||
	});
 | 
					 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -10,6 +10,7 @@ import {
 | 
				
			||||||
} from '../../deps.ts';
 | 
					} from '../../deps.ts';
 | 
				
			||||||
import { generateStats } from '../commandUtils.ts';
 | 
					import { generateStats } from '../commandUtils.ts';
 | 
				
			||||||
import { compilingStats } from '../commonEmbeds.ts';
 | 
					import { compilingStats } from '../commonEmbeds.ts';
 | 
				
			||||||
 | 
					import utils from '../utils.ts';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const stats = async (message: DiscordenoMessage) => {
 | 
					export const stats = async (message: DiscordenoMessage) => {
 | 
				
			||||||
	// Light telemetry to see how many times a command is being run
 | 
						// Light telemetry to see how many times a command is being run
 | 
				
			||||||
| 
						 | 
					@ -33,10 +34,8 @@ export const stats = async (message: DiscordenoMessage) => {
 | 
				
			||||||
		const cachedGuilds = await cacheHandlers.size('guilds');
 | 
							const cachedGuilds = await cacheHandlers.size('guilds');
 | 
				
			||||||
		const cachedChannels = await cacheHandlers.size('channels');
 | 
							const cachedChannels = await cacheHandlers.size('channels');
 | 
				
			||||||
		const cachedMembers = await cacheHandlers.size('members');
 | 
							const cachedMembers = await cacheHandlers.size('members');
 | 
				
			||||||
		m.edit(generateStats(cachedGuilds + cache.dispatchedGuildIds.size, cachedChannels + cache.dispatchedChannelIds.size, cachedMembers, rolls, total - rolls)).catch((e) => {
 | 
							m.edit(generateStats(cachedGuilds + cache.dispatchedGuildIds.size, cachedChannels + cache.dispatchedChannelIds.size, cachedMembers, rolls, total - rolls)).catch((e: Error) => utils.commonLoggers.messageSendError('stats.ts:37', message, e));
 | 
				
			||||||
			log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e)}`);
 | 
					 | 
				
			||||||
		});
 | 
					 | 
				
			||||||
	} catch (e) {
 | 
						} catch (e) {
 | 
				
			||||||
		log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e)}`);
 | 
							utils.commonLoggers.messageSendError('stats.ts:39', message, e);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8,6 +8,7 @@ import {
 | 
				
			||||||
	LT,
 | 
						LT,
 | 
				
			||||||
} from '../../deps.ts';
 | 
					} from '../../deps.ts';
 | 
				
			||||||
import { infoColor1 } from '../commandUtils.ts';
 | 
					import { infoColor1 } from '../commandUtils.ts';
 | 
				
			||||||
 | 
					import utils from '../utils.ts';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const version = (message: DiscordenoMessage) => {
 | 
					export const version = (message: DiscordenoMessage) => {
 | 
				
			||||||
	// Light telemetry to see how many times a command is being run
 | 
						// Light telemetry to see how many times a command is being run
 | 
				
			||||||
| 
						 | 
					@ -20,7 +21,5 @@ export const version = (message: DiscordenoMessage) => {
 | 
				
			||||||
			color: infoColor1,
 | 
								color: infoColor1,
 | 
				
			||||||
			title: `My current version is ${config.version}`,
 | 
								title: `My current version is ${config.version}`,
 | 
				
			||||||
		}],
 | 
							}],
 | 
				
			||||||
	}).catch((e) => {
 | 
						}).catch((e: Error) => utils.commonLoggers.messageSendError('version.ts:24', message, e));
 | 
				
			||||||
		log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e)}`);
 | 
					 | 
				
			||||||
	});
 | 
					 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -15,6 +15,7 @@ import { SolvedRoll } from '../solver/solver.d.ts';
 | 
				
			||||||
import { QueuedRoll, RollModifiers } from '../mod.d.ts';
 | 
					import { QueuedRoll, RollModifiers } from '../mod.d.ts';
 | 
				
			||||||
import { generateCountDetailsEmbed, generateDMFailed, generateRollEmbed, infoColor2, rollingEmbed } from '../commandUtils.ts';
 | 
					import { generateCountDetailsEmbed, generateDMFailed, generateRollEmbed, infoColor2, rollingEmbed } from '../commandUtils.ts';
 | 
				
			||||||
import stdResp from '../endpoints/stdResponses.ts';
 | 
					import stdResp from '../endpoints/stdResponses.ts';
 | 
				
			||||||
 | 
					import utils from '../utils.ts';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
let currentWorkers = 0;
 | 
					let currentWorkers = 0;
 | 
				
			||||||
const rollQueue: Array<QueuedRoll> = [];
 | 
					const rollQueue: Array<QueuedRoll> = [];
 | 
				
			||||||
| 
						 | 
					@ -193,9 +194,7 @@ export const queueRoll = async (rq: QueuedRoll) => {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
The results for this roll will replace this message when it is done.`,
 | 
					The results for this roll will replace this message when it is done.`,
 | 
				
			||||||
			}],
 | 
								}],
 | 
				
			||||||
		}).catch((e) => {
 | 
							}).catch((e: Error) => utils.commonLoggers.messageSendError('rollQueue.ts:197', rq.dd.m, e));
 | 
				
			||||||
			log(LT.ERROR, `Failed to send message: ${JSON.stringify(rq.dd.m)} | ${JSON.stringify(e)}`);
 | 
					 | 
				
			||||||
		});
 | 
					 | 
				
			||||||
		rollQueue.push(rq);
 | 
							rollQueue.push(rq);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					@ -206,9 +205,7 @@ setInterval(async () => {
 | 
				
			||||||
	if (rollQueue.length && currentWorkers < config.limits.maxWorkers) {
 | 
						if (rollQueue.length && currentWorkers < config.limits.maxWorkers) {
 | 
				
			||||||
		const temp = rollQueue.shift();
 | 
							const temp = rollQueue.shift();
 | 
				
			||||||
		if (temp) {
 | 
							if (temp) {
 | 
				
			||||||
			temp.dd.m.edit(rollingEmbed).catch((e) => {
 | 
								temp.dd.m.edit(rollingEmbed).catch((e: Error) => utils.commonLoggers.messageSendError('rollQueue.ts:208', temp.dd.m, e));
 | 
				
			||||||
				log(LT.ERROR, `Failed to send message: ${JSON.stringify(temp.dd.m)} | ${JSON.stringify(e)}`);
 | 
					 | 
				
			||||||
			});
 | 
					 | 
				
			||||||
			handleRollWorker(temp);
 | 
								handleRollWorker(temp);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										28
									
								
								src/utils.ts
								
								
								
								
							
							
						
						
									
										28
									
								
								src/utils.ts
								
								
								
								
							| 
						 | 
					@ -5,6 +5,11 @@
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import {
 | 
					import {
 | 
				
			||||||
 | 
						// Discordeno deps
 | 
				
			||||||
 | 
						DiscordenoMessage,
 | 
				
			||||||
 | 
						// Log4Deno deps
 | 
				
			||||||
 | 
						log,
 | 
				
			||||||
 | 
						LT,
 | 
				
			||||||
	// Discordeno deps
 | 
						// Discordeno deps
 | 
				
			||||||
	sendMessage,
 | 
						sendMessage,
 | 
				
			||||||
} from '../deps.ts';
 | 
					} from '../deps.ts';
 | 
				
			||||||
| 
						 | 
					@ -74,9 +79,14 @@ const cmdPrompt = async (logChannel: bigint, botName: string): Promise<void> =>
 | 
				
			||||||
		} // help or h
 | 
							} // help or h
 | 
				
			||||||
		// Shows a basic help menu
 | 
							// Shows a basic help menu
 | 
				
			||||||
		else if (command === 'help' || command === 'h') {
 | 
							else if (command === 'help' || command === 'h') {
 | 
				
			||||||
			console.log(
 | 
								console.log(`${botName} CLI Help:
 | 
				
			||||||
				`${botName} CLI Help:\n\nAvailable Commands:\n  exit - closes bot\n  stop - closes the CLI\n  m [ChannelID] [messgae] - sends message to specific ChannelID as the bot\n  ml [message] sends a message to the specified botlog\n  help - this message`,
 | 
					
 | 
				
			||||||
			);
 | 
					Available Commands:
 | 
				
			||||||
 | 
					  exit - closes bot
 | 
				
			||||||
 | 
					  stop - closes the CLI
 | 
				
			||||||
 | 
					  m [ChannelID] [messgae] - sends message to specific ChannelID as the bot
 | 
				
			||||||
 | 
					  ml [message] sends a message to the specified botlog
 | 
				
			||||||
 | 
					  help - this message`);
 | 
				
			||||||
		} // Unhandled commands die here
 | 
							} // Unhandled commands die here
 | 
				
			||||||
		else {
 | 
							else {
 | 
				
			||||||
			console.log('undefined command');
 | 
								console.log('undefined command');
 | 
				
			||||||
| 
						 | 
					@ -84,4 +94,14 @@ const cmdPrompt = async (logChannel: bigint, botName: string): Promise<void> =>
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export default { cmdPrompt };
 | 
					const genericLogger = (level: LT, message: string) => log(level, message);
 | 
				
			||||||
 | 
					const messageSendError = (location: string, message: DiscordenoMessage | string, err: Error) => genericLogger(LT.ERROR, `${location} | Failed to send message: ${JSON.stringify(message)} | Error: ${err.name} - ${err.message} `)
 | 
				
			||||||
 | 
					const messageDeleteError = (location: string, message: DiscordenoMessage | string, err: Error) => genericLogger(LT.ERROR, `${location} | Failed to delete message: ${JSON.stringify(message)} | Error: ${err.name} - ${err.message} `)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export default {
 | 
				
			||||||
 | 
						commonLoggers: {
 | 
				
			||||||
 | 
							messageSendError,
 | 
				
			||||||
 | 
							messageDeleteError,
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						cmdPrompt,
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue