diff --git a/lib/Discord/Commands/GitlabIssue.js b/lib/Discord/Commands/GitlabIssue.js index d8090ab..cd60aa4 100644 --- a/lib/Discord/Commands/GitlabIssue.js +++ b/lib/Discord/Commands/GitlabIssue.js @@ -26,7 +26,7 @@ class GitlabIssue extends Command { run(msg, args) { if (!args[0]) return this.errorUsage(msg); - if (args[0] === 'search') return this._search(msg, args); + if (args[0] === 'search' && args.length > 1) return this._search(msg, args); if (args.length === 1) return this._issue(msg, args); return this.errorUsage(msg); @@ -40,12 +40,14 @@ class GitlabIssue extends Command { return Gitlab.getProjectIssue(repository, null, issueNumber) .then(res => { - let issue = res.body; + const issue = res.body; + const description = issue.description; + const [, imageUrl] = /!\[(?:.*?)\]\((.*?)\)/.exec(description) || []; const embed = new this.embed() .setTitle(`Issue \`#${issue.iid}\` - ${issue.title}`) .setURL(issue.web_url) - .setDescription(`\u200B\n${issue.description}\n\u200B`) + .setDescription(`\u200B\n${description.slice(0, 2040)}\n\u200B`) .setColor('#84F139') .addField('Status', issue.state === 'opened' ? 'Open' : 'Closed', true) .addField('Labels', issue.labels.length ? issue.labels.map(e => `\`${e}\``).join(', ') : 'None', true) @@ -54,6 +56,7 @@ class GitlabIssue extends Command { .addField('Assignee', issue.assignee ? `[${issue.assignee.name}](${issue.assignee.web_url})` : 'None', true) .addField('Comments', issue.user_notes_count, true) .setFooter(repository, this.bot.user.avatarURL); + if (imageUrl) embed.setImage(imageUrl.startsWith('/') ? `https://gitlab.com/${repository}/${imageUrl}` : imageUrl); return msg.channel.send({ embed }); }).catch(err => {