Skip to content

Commit

Permalink
fix: suggestions from space's review
Browse files Browse the repository at this point in the history
  • Loading branch information
monbrey committed Jun 9, 2021
1 parent 7cc5ae2 commit 7dea736
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
5 changes: 4 additions & 1 deletion src/structures/APIMessage.js
Expand Up @@ -4,6 +4,7 @@ const BaseMessageComponent = require('./BaseMessageComponent');
const MessageAttachment = require('./MessageAttachment');
const MessageEmbed = require('./MessageEmbed');
const { RangeError } = require('../errors');
const { MessageComponentTypes } = require('../util/Constants');
const DataResolver = require('../util/DataResolver');
const MessageFlags = require('../util/MessageFlags');
const Util = require('../util/Util');
Expand Down Expand Up @@ -154,7 +155,9 @@ class APIMessage {
const embeds = embedLikes.map(e => new MessageEmbed(e).toJSON());

const components = this.options.components?.map(c =>
BaseMessageComponent.create(Array.isArray(c) ? { type: 1, components: c } : c).toJSON(),
BaseMessageComponent.create(
Array.isArray(c) ? { type: MessageComponentTypes.ACTION_ROW, components: c } : c,
).toJSON(),
);

let username;
Expand Down
8 changes: 3 additions & 5 deletions src/util/Util.js
Expand Up @@ -270,14 +270,12 @@ class Util {
/**
* Resolves a partial emoji object from an {@link EmojiIdentifierResolvable}, without checking a Client.
* @param {EmojiIdentifierResolvable} emoji Emoji identifier to resolve
* @returns {Object} Object with possible `animated`, `name`, and `id` properties
* @returns {?RawEmoji}
* @private
*/
static resolvePartialEmoji(emoji) {
if (typeof emoji === 'undefined') return null;
if (typeof emoji === 'string') {
return emoji.length ? (/^\d{17,19}$/.test(emoji) ? { id: emoji } : Util.parseEmoji(emoji)) : null;
}
if (!emoji) return null;
if (typeof emoji === 'string') return /^\d{17,19}$/.test(emoji) ? { id: emoji } : Util.parseEmoji(emoji);
const { id, name, animated } = emoji;
if (!id && !name) return null;
return { id, name, animated };
Expand Down
2 changes: 1 addition & 1 deletion typings/index.d.ts
Expand Up @@ -1963,7 +1963,7 @@ declare module 'discord.js' {
public static moveElementInArray(array: any[], element: any, newIndex: number, offset?: boolean): number;
public static parseEmoji(text: string): { animated: boolean; name: string; id: Snowflake | null } | null;
public static resolveColor(color: ColorResolvable): number;
public static resolvePartialEmoji(emoji: EmojiIdentifierResolvable): Partial<RawEmoji>;
public static resolvePartialEmoji(emoji: EmojiIdentifierResolvable): Partial<RawEmoji> | null;
public static verifyString(data: string, error?: typeof Error, errorMessage?: string, allowEmpty?: boolean): string;
public static setPosition<T extends Channel | Role>(
item: T,
Expand Down

0 comments on commit 7dea736

Please sign in to comment.