Download src/systems/logger.js from APRKDEV/wsb-bot: direct link, hf CLI and curl.
- Browser
- Download file 2.27 kB
-
https://huggingface.co/spaces/APRKDEV/wsb-bot/resolve/c8f3880098432483b23491dd763585274d00f8c8/src/systems/logger.js
- Command line
-
hf download hf://spaces/APRKDEV/wsb-bot@c8f3880098432483b23491dd763585274d00f8c8/src/systems/logger.js
-
curl -L -o logger.js https://huggingface.co/spaces/APRKDEV/wsb-bot/resolve/c8f3880098432483b23491dd763585274d00f8c8/src/systems/logger.js
2.27 kB
| const { stmts } = require('../database'); | |
| const { logEmbed } = require('../utils/embeds'); | |
| const { Colors } = require('../config'); | |
| /** | |
| * Log an action to the staff-logs channel. | |
| */ | |
| async function log(client, { title, description, fields = [], color = Colors.MUTED }) { | |
| try { | |
| const row = stmts.getState.get('channel_staff-logs'); | |
| if (!row) return; | |
| const channelId = row.value; | |
| 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); | |
| } | |
| } | |
| // Convenience wrappers | |
| async function logVerification(client, user, action) { | |
| stmts.logVerification.run(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 }; | |