winston-discordjs 3.0.0 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -36,23 +36,21 @@ class DiscordTransport extends winston_transport_1.default {
36
36
  if (!this.silent && info) {
37
37
  const logMessage = (0, LogHandlers_1.handleInfo)(info, this.format, this.level);
38
38
  if (this.discordChannel && logMessage) {
39
- if (logMessage) {
40
- let messagePromise;
41
- if (Array.isArray(logMessage)) {
42
- const content = logMessage[0];
43
- const embed = logMessage[1];
44
- messagePromise = this.discordChannel.send({
45
- content,
46
- embeds: [embed],
47
- });
48
- }
49
- else {
50
- messagePromise = this.discordChannel.send(logMessage);
51
- }
52
- messagePromise.catch((error) => {
53
- this.emit("warn", error);
39
+ let messagePromise;
40
+ if (Array.isArray(logMessage)) {
41
+ const content = logMessage[0];
42
+ const embed = logMessage[1];
43
+ messagePromise = this.discordChannel.send({
44
+ content,
45
+ embeds: [embed],
54
46
  });
55
47
  }
48
+ else {
49
+ messagePromise = this.discordChannel.send(logMessage);
50
+ }
51
+ messagePromise.catch((error) => {
52
+ this.emit("warn", error);
53
+ });
56
54
  }
57
55
  }
58
56
  if (callback && typeof callback === "function") {
@@ -41,12 +41,11 @@ const handlePrimitive = (info) => {
41
41
  };
42
42
  exports.handlePrimitive = handlePrimitive;
43
43
  const handleLogform = (info, level) => {
44
- var _a;
45
44
  if ((level && level === info.level) || !level) {
46
45
  const messageEmbed = new discord_js_1.MessageEmbed();
47
46
  let logMessageString = "";
48
47
  const color = level
49
- ? (_a = LogLevels_1.LogLevelToColor[level]) !== null && _a !== void 0 ? _a : "DEFAULT"
48
+ ? LogLevels_1.LogLevelToColor[level] ?? "DEFAULT"
50
49
  : "DEFAULT";
51
50
  messageEmbed.setColor(color);
52
51
  const fields = sortFields(Object.keys(info));
@@ -86,7 +85,7 @@ const handleObject = (info, format, level) => {
86
85
  else if (info instanceof Error && info.stack) {
87
86
  return info.stack;
88
87
  }
89
- else if (typeof (info === null || info === void 0 ? void 0 : info.toString) === "function" &&
88
+ else if (typeof info?.toString === "function" &&
90
89
  info.toString !== Object.toString) {
91
90
  return info.toString();
92
91
  }
package/package.json CHANGED
@@ -2,48 +2,44 @@
2
2
  "author": "Robert Smieja",
3
3
  "bugs": "https://github.com/robbot-discord/winston-discordjs/issues",
4
4
  "dependencies": {
5
- "@types/ws": "^7.4.7",
6
- "discord.js": "^13.1.0",
7
- "logform": "^2.2.0",
5
+ "@types/ws": "^8.5.3",
6
+ "logform": "^2.4.2",
8
7
  "utility-types": "^3.10.0",
9
- "winston": "^3.3.3",
10
- "winston-transport": "^4.4.0"
8
+ "winston-transport": "^4.5.0"
9
+ },
10
+ "peerDependencies": {
11
+ "discord.js": "^13.8.1"
11
12
  },
12
13
  "description": "Winston Transport using Discord.js",
13
14
  "devDependencies": {
14
- "@babel/core": "^7.15.4",
15
- "@babel/preset-env": "^7.15.4",
16
- "@babel/preset-typescript": "^7.15.0",
17
- "@types/jest": "^27.0.1",
18
- "@types/node": "^16.7.10",
19
- "@typescript-eslint/eslint-plugin": "^4.30.0",
20
- "@typescript-eslint/parser": "^4.30.0",
21
- "eslint": "^7.32.0",
22
- "eslint-config-prettier": "^8.3.0",
23
- "eslint-plugin-prettier": "^4.0.0",
24
- "husky": "^7.0.2",
25
- "jest": "^27.1.0",
26
- "lint-staged": "^11.1.2",
15
+ "@babel/core": "^7.18.6",
16
+ "@babel/preset-env": "^7.18.6",
17
+ "@babel/preset-typescript": "^7.18.6",
18
+ "@tsconfig/node16": "^1.0.3",
19
+ "@types/jest": "^28.1.4",
20
+ "@types/node": "^18.0.3",
21
+ "@typescript-eslint/eslint-plugin": "^5.30.6",
22
+ "@typescript-eslint/parser": "^5.30.6",
23
+ "eslint": "^8.19.0",
24
+ "eslint-config-prettier": "^8.5.0",
25
+ "eslint-plugin-jest": "^26.5.3",
26
+ "eslint-plugin-prettier": "^4.2.1",
27
+ "husky": "^8.0.1",
28
+ "jest": "^28.1.2",
29
+ "lint-staged": "^13.0.3",
27
30
  "npm-run-all": "^4.1.5",
28
- "prettier": "^2.3.2",
31
+ "prettier": "^2.7.1",
29
32
  "rimraf": "^3.0.2",
30
- "ts-jest": "27.0.5",
31
- "typescript": "^4.4.2"
33
+ "ts-jest": "28.0.5",
34
+ "typescript": "^4.7.4"
32
35
  },
33
36
  "engines": {
34
- "node": ">=14",
35
- "npm": ">=7"
37
+ "node": ">=16.6",
38
+ "npm": ">=8"
36
39
  },
37
40
  "files": [
38
41
  "dist"
39
42
  ],
40
- "husky": {
41
- "hooks": {
42
- "pre-commit": [
43
- "lint-staged"
44
- ]
45
- }
46
- },
47
43
  "keywords": [
48
44
  "typescript",
49
45
  "nodejs",
@@ -54,14 +50,6 @@
54
50
  "transport"
55
51
  ],
56
52
  "license": "MIT",
57
- "lint-staged": {
58
- "*.{js,ts,jsx,tsx,json,md}": [
59
- "prettier --write"
60
- ],
61
- "src/*.{js,ts,jsx,tsx}": [
62
- "eslint --fix"
63
- ]
64
- },
65
53
  "main": "dist/index.js",
66
54
  "name": "winston-discordjs",
67
55
  "private": false,
@@ -70,6 +58,7 @@
70
58
  "build": "npm-run-all --parallel build:js lint",
71
59
  "build:js": "tsc",
72
60
  "clean": "rimraf dist/",
61
+ "check": "npm-run-all --parallel lint typecheck",
73
62
  "lint": "eslint ./src/**/*",
74
63
  "lint:fix": "eslint --fix ./src/**/*",
75
64
  "lint:staged": "lint-staged",
@@ -78,8 +67,10 @@
78
67
  "prepublishOnly": "npm-run-all --parallel test lint",
79
68
  "prettier": "prettier --write '*.{js,ts,jsx,tsx,json,md}'",
80
69
  "test": "jest",
81
- "version": "npm run lint:fix && git add -A src"
70
+ "typecheck": "tsc --noEmit",
71
+ "version": "npm run lint:fix && git add -A src",
72
+ "prepare": "husky install"
82
73
  },
83
74
  "types": "dist/index.d.ts",
84
- "version": "3.0.0"
75
+ "version": "4.0.0"
85
76
  }
@@ -1,17 +0,0 @@
1
- import * as Transport from "winston-transport";
2
- import { TextChannel, Client, BitFieldResolvable, IntentsString } from "discord.js";
3
- import TransportStream from "winston-transport";
4
- export interface DiscordTransportStreamOptions extends Transport.TransportStreamOptions {
5
- discordClient?: Client;
6
- discordToken?: string;
7
- discordChannel?: string | TextChannel;
8
- intents?: BitFieldResolvable<IntentsString, number>;
9
- }
10
- export declare class DiscordTransport extends TransportStream {
11
- discordChannel?: TextChannel;
12
- discordClient?: Client;
13
- constructor(opts?: DiscordTransportStreamOptions);
14
- log(info: unknown, callback?: () => void): void;
15
- close(): void;
16
- }
17
- export default DiscordTransport;
@@ -1,8 +0,0 @@
1
- import { TransformableInfo, Format } from "logform";
2
- import { Primitive } from "utility-types";
3
- import { MessageEmbed } from "discord.js";
4
- export declare const isTransformableInfo: (info: unknown) => info is TransformableInfo;
5
- export declare const handlePrimitive: (info: Primitive) => string;
6
- export declare const handleLogform: (info: TransformableInfo, level?: string | undefined) => [string, MessageEmbed] | undefined;
7
- export declare const handleObject: (info: Exclude<any, Primitive>, format?: Format | undefined, level?: string | undefined) => string | [string, MessageEmbed] | undefined;
8
- export declare const handleInfo: (info: unknown, format?: Format | undefined, level?: string | undefined) => string | [string, MessageEmbed] | undefined;
@@ -1,3 +0,0 @@
1
- import { ColorResolvable } from "discord.js";
2
- export declare type LogLevel = "emerg" | "alert" | "crit" | "error" | "warning" | "notice" | "info" | "debug";
3
- export declare const LogLevelToColor: Record<LogLevel, ColorResolvable>;
package/dist/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import DiscordTransport from "./DiscordTransport";
2
- export default DiscordTransport;