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

Add barcode information command #1255

Closed
wants to merge 2 commits into from

Conversation

michizhou
Copy link

Added code for fetching barcode information from the UPC database API about products with specified codes.

Closes #1182

@michizhou michizhou requested a review from a team as a code owner November 1, 2020 00:09
@almeidx almeidx added scope: commands New command(s) suggestion/addition type: feature New feature labels Nov 3, 2020
)
if (data.description !== '') embed.setDescription(`/${data.description}/`)
if (data.images) embed.setThumbnail(data.images[0])
if (data.stores) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (data.stores.length) {

'https://upcdatabase.org/images/logo.png'
)
if (data.description !== '') embed.setDescription(`/${data.description}/`)
if (data.images) embed.setThumbnail(data.images[0])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (data.images.length) embed.setThumbnail(data.images[0])

t('commands:barcode.footer'),
'https://upcdatabase.org/images/logo.png'
)
if (data.description !== '') embed.setDescription(`/${data.description}/`)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the /?

},
parameters: [{
type: 'string',
full: true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

barcode has spaces?
image
image

data.stores.map(d =>
({
name: d.store,
price: `${d.price ? `$${d.price}` : ''}`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

value: `${d.price ? `$${d.price}` : ''}`

} catch (err) {
channel.stopTyping()
if (err.response && err.response.status === 404) {
throw new CommandError(t('commands:barcode.notFound'))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It isn't throwing this when no information is found
image
data result:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: commands New command(s) suggestion/addition type: feature New feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Barcode Information Command
4 participants