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