UNPKG

@beni69/cmd

Version:

The command handler from my discord bot

39 lines 1.55 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Logger = void 0; class Logger { constructor(client, { channel, format }) { this.client = client; if (typeof channel === "string") this.channels = [ client.channels.cache.get(channel), ]; else this.channels = channel.map(ch => client.channels.cache.get(ch)); this.format = format; } log(trigger, format = this.format) { const str = this.getFormat(trigger, format); this.channels.forEach(ch => ch.send(str)); } send(str) { this.channels.forEach(ch => ch.send(str)); } getFormat(trigger, format) { var _a, _b; format = typeof format === "object" ? format.join("") : format; return format .replace("$authorName$", trigger.author.tag) .replace("$authorTag$", trigger.author.toString()) .replace("$content$", trigger.content) .replace("$channelName$", trigger.channel.type === "DM" ? trigger.author.tag : (_a = trigger.channel) === null || _a === void 0 ? void 0 : _a.name) .replace("$channelTag$", trigger.channel.toString()) .replace("$serverName$", ((_b = trigger.guild) === null || _b === void 0 ? void 0 : _b.name) || trigger.author.toString()) .replace("$timestamp$", trigger.createdAt.toLocaleString()); } } exports.Logger = Logger; exports.default = Logger; //# sourceMappingURL=Logging.js.map