Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,7 @@ blapi.setLogging({
logger: yourCustomLogger
})
```
### Turn on extended logging
![](https://img.shields.io/badge/deprecated-Do%20not%20use%20this%20anymore-orange)

```js
// Following method to activate extended logging still works, but is deprecated.
// Switch to using above syntax, as this will be removed at some point.
blapi.setLogging(true);
```

### Turn off the use of the BotBlock API

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "blapi",
"version": "2.2.4",
"version": "3.0.0",
"license": "MIT",
"repository": "botblock/BLAPI",
"bugs": {
Expand Down
13 changes: 3 additions & 10 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ type DiscordJSClientFallback = {
[k: string]: any;
};

type LogOptions = boolean | { extended?: boolean; logger?: UserLogger };
type LogOptions = { extended?: boolean; logger?: UserLogger };

let listData = fallbackData as listDataType;
let legacyIds = legacyIdsFallbackData as legacyIdDataType;
Expand Down Expand Up @@ -432,14 +432,8 @@ export async function manualPost(
}

export function setLogging(logOptions: LogOptions): void {
// we are setting extendedLogging to the passed in logOptions
// so users can disable extended logging later on
if (typeof logOptions === 'boolean') {
extendedLogging = logOptions;
}
if (
typeof logOptions === 'object'
&& Object.prototype.hasOwnProperty.call(logOptions, 'extended')
Object.prototype.hasOwnProperty.call(logOptions, 'extended')
&& typeof logOptions.extended === 'boolean'
) {
extendedLogging = logOptions.extended;
Expand All @@ -448,7 +442,7 @@ export function setLogging(logOptions: LogOptions): void {
if (!Object.prototype.hasOwnProperty.call(logOptions, 'logger')) {
return;
}
const { logger } = logOptions as any; // we checked that it exists beforehand
const logger = logOptions.logger!; // we checked that it exists beforehand
// making sure the logger supplied by the user has our required log levels (info, warn, error)
if (
typeof logger.info !== 'function'
Expand All @@ -459,7 +453,6 @@ export function setLogging(logOptions: LogOptions): void {
'Your supplied logger does not seem to expose the log levels BLAPI needs to work. Make sure your logger offers the following methods: info() warn() error()',
);
}
// @ts-ignore
userLogger = logOptions.logger;
}

Expand Down