Some logging improvements

This commit is contained in:
Charlie Laabs
2021-12-23 22:01:50 -06:00
parent 0052ffff3b
commit 6874b3e98b

View File

@@ -241,7 +241,8 @@ async function generateResponse(
try { try {
const response = await markov.generate<MarkovDataCustom>(markovGenerateOptions); const response = await markov.generate<MarkovDataCustom>(markovGenerateOptions);
L.info({ response }, 'Generated response'); L.info({ string: response.string }, 'Generated response text');
L.debug({ response }, 'Generated response object');
const messageOpts: Discord.MessageOptions = { tts }; const messageOpts: Discord.MessageOptions = { tts };
const attachmentUrls = response.refs const attachmentUrls = response.refs
.filter((ref) => ref.custom && 'attachments' in ref.custom) .filter((ref) => ref.custom && 'attachments' in ref.custom)
@@ -373,13 +374,14 @@ client.on('guildCreate', async (guild) => {
await Guild.upsert(Guild.create({ id: guild.id }), ['id']); await Guild.upsert(Guild.create({ id: guild.id }), ['id']);
}); });
client.on('error', (err) => { client.on('debug', (m) => L.trace(m));
L.error(err); client.on('warn', (m) => L.warn(m));
}); client.on('error', (m) => L.error(m));
client.on('messageCreate', async (message) => { client.on('messageCreate', async (message) => {
if (!(message.guild && message.channel instanceof Discord.TextChannel)) return; if (!(message.guild && message.channel instanceof Discord.TextChannel)) return;
const command = validateMessage(message); const command = validateMessage(message);
if (command !== null) L.info({ command }, 'Recieved message command');
if (command === 'help') { if (command === 'help') {
await message.channel.send(helpMessage()); await message.channel.send(helpMessage());
} }
@@ -417,7 +419,7 @@ client.on('messageCreate', async (message) => {
client.on('messageDelete', async (message) => { client.on('messageDelete', async (message) => {
if (message.author?.bot) return; if (message.author?.bot) return;
L.info(`Deleting message ${message.id}`); L.debug(`Deleting message ${message.id}`);
if (!(message.guildId && message.content)) { if (!(message.guildId && message.content)) {
return; return;
} }
@@ -427,7 +429,7 @@ client.on('messageDelete', async (message) => {
client.on('messageUpdate', async (oldMessage, newMessage) => { client.on('messageUpdate', async (oldMessage, newMessage) => {
if (oldMessage.author?.bot) return; if (oldMessage.author?.bot) return;
L.info(`Editing message ${oldMessage.id}`); L.debug(`Editing message ${oldMessage.id}`);
if (!(oldMessage.guildId && oldMessage.content && newMessage.content)) { if (!(oldMessage.guildId && oldMessage.content && newMessage.content)) {
return; return;
} }
@@ -439,6 +441,8 @@ client.on('messageUpdate', async (oldMessage, newMessage) => {
client.on('interactionCreate', async (interaction) => { client.on('interactionCreate', async (interaction) => {
if (!interaction.isCommand()) return; if (!interaction.isCommand()) return;
L.info({ command: interaction.commandName }, 'Recieved slash command');
if (interaction.commandName === helpCommand.name) { if (interaction.commandName === helpCommand.name) {
await interaction.reply(helpMessage()); await interaction.reply(helpMessage());
} else if (interaction.commandName === inviteCommand.name) { } else if (interaction.commandName === inviteCommand.name) {