Skip to content

Commit 02f6def

Browse files
committed
refactor: try to warn in all environments
1 parent 5374fbf commit 02f6def

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

packages/rest/src/lib/CDN.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
type ImageSize,
99
type StickerExtension,
1010
} from './utils/constants.js';
11+
import { warn } from './utils/utils.js';
1112

1213
let deprecationEmittedForEmoji = false;
1314

@@ -179,11 +180,7 @@ export class CDN {
179180

180181
if (typeof options === 'string') {
181182
if (!deprecationEmittedForEmoji) {
182-
process.emitWarning(
183-
'Passing a string for CDN#emoji() is deprecated. Use an object instead.',
184-
'DeprecationWarning',
185-
);
186-
183+
warn('DeprecationWarning: Passing a string for CDN#emoji() is deprecated. Use an object instead.');
187184
deprecationEmittedForEmoji = true;
188185
}
189186

packages/rest/src/lib/utils/utils.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,16 @@ export async function sleep(ms: number): Promise<void> {
140140
export function isBufferLike(value: unknown): value is ArrayBuffer | Buffer | Uint8Array | Uint8ClampedArray {
141141
return value instanceof ArrayBuffer || value instanceof Uint8Array || value instanceof Uint8ClampedArray;
142142
}
143+
144+
/**
145+
* Irrespective environment warning.
146+
*
147+
* @internal
148+
*/
149+
export function warn(message: string) {
150+
if (typeof globalThis.process === 'undefined') {
151+
console.warn(message);
152+
} else {
153+
process.emitWarning(message);
154+
}
155+
}

0 commit comments

Comments
 (0)