Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Message): added string type for message nonce #4782

Merged
merged 14 commits into from
Nov 22, 2020
Merged
2 changes: 1 addition & 1 deletion src/errors/Messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const Messages = {
IMAGE_SIZE: size => `Invalid image size: ${size}`,

MESSAGE_BULK_DELETE_TYPE: 'The messages must be an Array, Collection, or number.',
MESSAGE_NONCE_TYPE: 'Message nonce must fit in an unsigned 64-bit integer.',
MESSAGE_NONCE_TYPE: 'Message nonce must be an Integer or String.',
wonderlandpark marked this conversation as resolved.
Show resolved Hide resolved

TYPING_COUNT: 'Count must be at least 1',

Expand Down
4 changes: 2 additions & 2 deletions src/structures/APIMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ class APIMessage {

let nonce;
if (typeof this.options.nonce !== 'undefined') {
nonce = parseInt(this.options.nonce);
if (isNaN(nonce) || nonce < 0) throw new RangeError('MESSAGE_NONCE_TYPE');
nonce = typeof this.options.nonce === 'string' ? this.options.nonce : parseInt(this.options.nonce);
if (!nonce) throw new RangeError('MESSAGE_NONCE_TYPE');
wonderlandpark marked this conversation as resolved.
Show resolved Hide resolved
}

const embedLikes = [];
Expand Down
2 changes: 1 addition & 1 deletion typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,7 @@ declare module 'discord.js' {
public id: Snowflake;
public readonly member: GuildMember | null;
public mentions: MessageMentions;
public nonce: string | null;
public nonce: string | number | null;
wonderlandpark marked this conversation as resolved.
Show resolved Hide resolved
public readonly partial: false;
public readonly pinnable: boolean;
public pinned: boolean;
Expand Down