asunyan-logs
v1.0.0
Published
Module for logging system on a Discord bot using discord.js
Maintainers
Readme
asunyan-logs
Module to create a logging system in your Discord bot using discord.js.
Install
$ npm install asunyan-logsUsage
Properties
guildId is the server where the log will be enabled.
log is the log type to enable. 4 available types (!!! They are case sensitive !!!) : memberEvents, messageLogs, joinLeave, voiceLogs
channelId is the channel where the logs will be sent for the selected type.
Enable a log
const { enableLog } = require('asunyan-logs');
enableLog(guildId, log, channelId);Disable a log
const { disableLog } = require('asunyan-logs');
disableLog(guildId, log);Edit the channel for a log type
const { editLog } = require('asunyan-logs');
editLog(guildId, log, channelId);Get the data for a type of log
const { getLog } = require('asunyan-logs');
const log = await getLog(guildId, log);This will return two properties:
{
enabled: boolean,
channelId: string | null
}Get all logs
const { getAllLogs } = require('asunyan-logs');
const logs = await getAllLogs(guildId);This will return the same properties as before but for each type of logs. So for example:
{
memberEvents: { enabled: true, channelId: "73166938611738" }
}How to use this then after?
Imagine you want to log when a member joins the server:
const { Events, EmbedBuilder } = require('discord.js');
const { getLog } = require('asunyan-logs');
module.exports = {
name: Events.GuildMemberAdd,
async execute(member) {
const guildId = member.guild.id;
const status = await getLog(guildId, "joinLeave");
if(!status.enabled) return;
// rest of your code here
}
}If you have any questions, feel free to reach me out on Discord: @mimi.mrow or join my server
