Skip to content

Commit

Permalink
feat(Message): added string type for message nonce (#4782)
Browse files Browse the repository at this point in the history
Co-authored-by: Vlad Frangu <[email protected]>
Co-authored-by: Sugden <[email protected]>
Co-authored-by: SpaceEEC <[email protected]>
  • Loading branch information
4 people authored Nov 22, 2020
1 parent 863734a commit 4b555fd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/errors/Messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,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 a string.',

TYPING_COUNT: 'Count must be at least 1',

Expand Down
7 changes: 5 additions & 2 deletions src/structures/APIMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,11 @@ 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 = this.options.nonce;
// eslint-disable-next-line max-len
if (typeof nonce === 'number' ? !Number.isInteger(nonce) : typeof nonce !== 'string') {
throw new RangeError('MESSAGE_NONCE_TYPE');
}
}

const embedLikes = [];
Expand Down
4 changes: 2 additions & 2 deletions typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,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;
public readonly partial: false;
public readonly pinnable: boolean;
public pinned: boolean;
Expand Down Expand Up @@ -2830,7 +2830,7 @@ declare module 'discord.js' {

interface MessageOptions {
tts?: boolean;
nonce?: string;
nonce?: string | number;
content?: StringResolvable;
embed?: MessageEmbed | MessageEmbedOptions;
disableMentions?: 'none' | 'all' | 'everyone';
Expand Down

0 comments on commit 4b555fd

Please sign in to comment.