Skip to content
This repository has been archived by the owner on Jan 19, 2025. It is now read-only.

Add TasteDive Command #1346

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
5a026a2
Add a Itunes command
puddingpy Oct 16, 2021
275d354
Add TasteDiv Command
puddingpy Oct 16, 2021
a367922
Merge branch 'dev' into tastediv
Doges Oct 16, 2021
27dd24f
Remove itunes.js
puddingpy Oct 16, 2021
5ee8cbe
Make requested changes
puddingpy Oct 18, 2021
79b23d1
Update src/locales/en-US/commands.json
puddingpy Oct 19, 2021
0f1dc6f
Update src/commands/misc/tastedive.js
puddingpy Oct 19, 2021
1455697
Make requested changes
puddingpy Oct 22, 2021
4ea475d
Formatting
puddingpy Oct 22, 2021
ddb8047
Remove unnecessary lines
puddingpy Oct 23, 2021
1a58986
Update src/apis/TasteDive.js
puddingpy Oct 23, 2021
ecb5cbd
Make requested changes
puddingpy Oct 25, 2021
8bbfa7f
Make requested changes
puddingpy Oct 25, 2021
33e978c
Update
puddingpy Oct 25, 2021
f50e05d
Make requested changes
puddingpy Oct 25, 2021
c6cf6e2
Make requested changes
puddingpy Oct 25, 2021
8167d27
Merge branch 'dev' into tastediv
Doges Oct 25, 2021
43dfe58
Make requested changes
puddingpy Oct 27, 2021
7fd126e
Revert unwanted changes
almeidx Oct 31, 2021
c9dba54
Update tastedive.js
almeidx Oct 31, 2021
b9d631e
Make requested changes
puddingpy Oct 31, 2021
04585c7
Make requested changes
puddingpy Oct 31, 2021
3d5c9fc
Make requested changes
puddingpy Oct 31, 2021
d7fcfae
Make requested changes
puddingpy Oct 31, 2021
f1bed8f
Make requested changes
puddingpy Oct 31, 2021
8b20ec6
Make requested changes
puddingpy Oct 31, 2021
b6855b6
Fix errors
puddingpy Oct 31, 2021
ef1a656
Fix errors
puddingpy Oct 31, 2021
7b852af
Update
puddingpy Oct 31, 2021
f333441
standard
almeidx Oct 31, 2021
20877b5
Merge branch 'dev' into tastediv
puddingpy Nov 13, 2021
61d84aa
Make requested changes
puddingpy Nov 14, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/apis/TasteDive.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const { APIWrapper } = require('..')
const axios = require('axios')

module.exports = class TasteDive extends APIWrapper {
constructor () {
super({ name: 'tastedive' })
}

async search (type, q) {
try {
const { data } = await axios.get('https://tastedive.com/api/similar', {
params: {
type,
q,
limit: 10
}
})

if (!data.results) throw new Error()

return data.Similar.Results
} catch {
return []
}
}
}
41 changes: 41 additions & 0 deletions src/commands/misc/tastedive.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
const { SwitchbladeEmbed, Command} = require('../../')

const MEDIA_WHITE_LIST = ['music', 'movies', 'shows', 'podcasts', 'books', 'authors', 'games']

module.exports = class TasteDive extends Command {
constructor (client) {
super({
name: 'tastedive',
requirements: { apis: ['tastedive'] },
parameters: [
{
type: 'string',
full: false,
whitelist: MEDIA_WHITE_LIST,
missingError: 'commands:tastedive.noText'
}, {
type: 'string',
full: true,
almeidx marked this conversation as resolved.
Show resolved Hide resolved
required: true,
missingError: 'commands:tastedive.noText'
}
]
}, client)
}

async run ({ channel, t, message }, media, term) {
const data = await this.client.apis.tastedive.search(media, term)
almeidx marked this conversation as resolved.
Show resolved Hide resolved

channel.send(this.parseResponse(t, message.content, data))
}

parseResponse (t, title, data) {
const description = data.map((item, index) => `\`${String(index).padStart(2, '0')}\`: *${item.Name}*`).join('\n')

const embed = new SwitchbladeEmbed()
.setTitle(t('commands:tastedive.title', { title }))
.setDescription(description)

return embed
This conversation was marked as resolved.
Show resolved Hide resolved
}
}
6 changes: 6 additions & 0 deletions src/locales/en-US/commands.json
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,12 @@
"commandUsage": "<text>",
"noText": "You have to give me some text to asciify!"
},
"tastedive": {
"commandDescription": "Provides similar types of media according to user's liking",
"commandUsage": "<media> <liking>",
"title": "Showing Results for {{title}}.",
"noText": "You have to give me media and search terms!"
},
"hentai": {
"commandDescription": "Sends hentai in an NSFW channel.",
"hereIsYourHentai": "Here's your hentai!"
Expand Down