Skip to content
This repository has been archived by the owner on Dec 14, 2024. It is now read-only.

Commit

Permalink
fix(ImageEmbedCommand): only require maxNumber or images to be set if…
Browse files Browse the repository at this point in the history
… applicable (#82)
  • Loading branch information
SpaceEEC authored Dec 21, 2019
1 parent c809850 commit 8c852c7
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/structures/ImageEmbedCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,24 @@ export abstract class ImageEmbedCommand extends Command
*/
protected imageEmbed(message: GuildMessage, userModel: UserModel): MessageEmbed
{
if (!this.maxNumber) throw new Error('No maxNumber set!');
if (!this.images) throw new Error('No images set!');

const image: string = this.baseURL
? `${this.baseURL}${Math.floor(Math.random() * this.maxNumber) + 1}.gif`
: this.images[Math.floor(Math.random() * this.images.length)];
let image: string;
if (this.baseURL)
{
if (!this.maxNumber) throw new Error('No maxNumber set!');
image = `${this.baseURL}${Math.floor(Math.random() * this.maxNumber) + 1}.gif`;
}
else
{
if (!this.images) throw new Error('No images set!');
image = this.images[Math.floor(Math.random() * this.images.length)];
}

return MessageEmbed.image(message, userModel, image);
}
}

export interface IImageEmbedCommandInfo extends ICommandInfo {
export interface IImageEmbedCommandInfo extends ICommandInfo
{
baseURL?: string;
images?: string[];
maxNumber?: number;
Expand Down

0 comments on commit 8c852c7

Please sign in to comment.