refactor(events/messages): now using the new log system
This commit is contained in:
parent
6c3a7587e8
commit
a4c08eaae5
4 changed files with 22 additions and 12 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import { Events, EmbedBuilder, Message, Channel, Collection, Snowflake, PartialMessage } from 'discord.js';
|
||||
import { log } from '@lib/log';
|
||||
import { prisma } from '@lib/prisma';
|
||||
import { Guild as GuildPrisma } from '@prisma/client';
|
||||
|
||||
|
|
@ -18,15 +19,15 @@ export default {
|
|||
try {
|
||||
fullMsg = await msg.fetch();
|
||||
}
|
||||
catch {
|
||||
console.warn('BulkDelete cannot load a message');
|
||||
catch (err) {
|
||||
log.warn(err, 'BulkDelete cannot load a message');
|
||||
}
|
||||
}
|
||||
|
||||
description += `**${fullMsg.author?.username ?? 'Unknown'}**: ${fullMsg.content || '[no content]'}\n`;
|
||||
}
|
||||
if (guildData.logMsg) {
|
||||
const log = new EmbedBuilder()
|
||||
const logEmbed = new EmbedBuilder()
|
||||
.setAuthor({
|
||||
name: `${message.author.tag} (${message.author.id})`,
|
||||
iconURL: message.author.displayAvatarURL({
|
||||
|
|
@ -47,10 +48,12 @@ export default {
|
|||
`);
|
||||
const logChannel: Promise<Channel | null> = await message.guild.client.channels
|
||||
.fetch(guildData.logMsg)
|
||||
.catch((err) => { console.error(err); });
|
||||
.catch((err) => {
|
||||
log.error(err, 'Unable to fetch the log channel');
|
||||
});
|
||||
logChannel.send({
|
||||
embeds: [
|
||||
log,
|
||||
logEmbed,
|
||||
],
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { Events, Message } from 'discord.js';
|
||||
import { prisma } from '@lib/prisma';
|
||||
import { User as UserPrisma } from '@prisma/client';
|
||||
import { GuildUser as GuildUserPrisma } from '@prisma/client';
|
||||
|
||||
const xpCooldown: Map<string, number> = new Map<string, number>();
|
||||
|
||||
|
|
@ -28,7 +29,7 @@ export default {
|
|||
},
|
||||
});
|
||||
}
|
||||
let guildUser = await prisma.guildUser.findUnique({
|
||||
let guildUser: GuildUserPrisma | null = await prisma.guildUser.findUnique({
|
||||
where: {
|
||||
userId_guildId: {
|
||||
userId: message.author.id,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { Events, EmbedBuilder, Message, Channel } from 'discord.js';
|
||||
import { prisma } from '@lib/prisma';
|
||||
import { log } from '@lib/log';
|
||||
import { Guild as GuildPrisma } from '@prisma/client';
|
||||
|
||||
export default {
|
||||
|
|
@ -11,7 +12,7 @@ export default {
|
|||
},
|
||||
});
|
||||
if (guildData.logMsg) {
|
||||
const log = new EmbedBuilder()
|
||||
const logEmbed = new EmbedBuilder()
|
||||
.setAuthor({
|
||||
name: `${message.author.tag} (${message.author.id})`,
|
||||
iconURL: message.author.displayAvatarURL({
|
||||
|
|
@ -30,10 +31,12 @@ export default {
|
|||
`);
|
||||
const logChannel: Promise<Channel | null> = await message.guild.client.channels
|
||||
.fetch(guildData.logMsg)
|
||||
.catch((err) => { console.error(err); });
|
||||
.catch((err) => {
|
||||
log.error(err, 'Unable to fetch the log channel');
|
||||
});
|
||||
logChannel.send({
|
||||
embeds: [
|
||||
log,
|
||||
logEmbed,
|
||||
],
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { Events, EmbedBuilder, Message, Channel } from 'discord.js';
|
||||
import { prisma } from '@lib/prisma';
|
||||
import { log } from '@lib/log';
|
||||
import { Guild as GuildPrisma } from '@prisma/client';
|
||||
|
||||
export default {
|
||||
|
|
@ -11,7 +12,7 @@ export default {
|
|||
},
|
||||
});
|
||||
if (guildData.logMsg) {
|
||||
const log = new EmbedBuilder()
|
||||
const logEmbed = new EmbedBuilder()
|
||||
.setAuthor({
|
||||
name: `${newMessage.author.tag} (${newMessage.author.id})`,
|
||||
iconURL: newMessage.author.displayAvatarURL({
|
||||
|
|
@ -31,10 +32,12 @@ export default {
|
|||
`);
|
||||
const logChannel: Promise<Channel | null> = await newMessage.guild.client.channels
|
||||
.fetch(guildData.logMsg)
|
||||
.catch((err) => { console.error(err); });
|
||||
.catch((err) => {
|
||||
log.error(err, 'Unable to fetch the log channel');
|
||||
});
|
||||
logChannel.send({
|
||||
embeds: [
|
||||
log,
|
||||
logEmbed,
|
||||
],
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue