| const { stmts } = require('../database'); |
| const { logEmbed } = require('../utils/embeds'); |
| const { Colors } = require('../config'); |
|
|
| |
| |
| |
| async function log(client, { title, description, fields = [], color = Colors.MUTED }) { |
| try { |
| const row = await stmts.getState('channel_staff-logs'); |
| if (!row) return; |
|
|
| const channelId = row; |
| const channel = await client.channels.fetch(channelId).catch(() => null); |
| if (!channel) return; |
|
|
| const embed = logEmbed({ title, description, color, fields }); |
| await channel.send({ embeds: [embed] }); |
| } catch (err) { |
| console.error('[Logger] Failed to log:', err.message); |
| } |
| } |
|
|
| |
| async function logVerification(client, user, action) { |
| await stmts.logVerification(user.id, user.tag, action); |
| await log(client, { |
| title: 'π Verification', |
| description: `**${user.tag}** (${user.id})`, |
| fields: [{ name: 'Action', value: action, inline: true }], |
| color: action === 'verified' ? Colors.SUCCESS : Colors.WARNING, |
| }); |
| } |
|
|
| async function logTicket(client, { user, action, channelName }) { |
| await log(client, { |
| title: 'π« Ticket', |
| description: `**${user.tag}** (${user.id})`, |
| fields: [ |
| { name: 'Action', value: action, inline: true }, |
| { name: 'Channel', value: channelName || 'N/A', inline: true }, |
| ], |
| color: Colors.INFO, |
| }); |
| } |
|
|
| async function logCommand(client, command) { |
| await log(client, { |
| title: 'βοΈ Command Executed', |
| description: `\`${command}\``, |
| fields: [{ name: 'Executed by', value: 'Owner (DM)', inline: true }], |
| color: Colors.PRIMARY, |
| }); |
| } |
|
|
| async function logRoleChange(client, { user, role, action }) { |
| await log(client, { |
| title: 'π€ Role Change', |
| description: `**${user.tag}** (${user.id})`, |
| fields: [ |
| { name: 'Role', value: role, inline: true }, |
| { name: 'Action', value: action, inline: true }, |
| ], |
| color: action === 'added' ? Colors.SUCCESS : Colors.WARNING, |
| }); |
| } |
|
|
| module.exports = { log, logVerification, logTicket, logCommand, logRoleChange }; |
|
|