mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-12 15:57:43 +02:00
Stock Photo Command
This commit is contained in:
@@ -54,6 +54,7 @@ TMDB_KEY=
|
|||||||
TUMBLR_KEY=
|
TUMBLR_KEY=
|
||||||
TWITTER_KEY=
|
TWITTER_KEY=
|
||||||
TWITTER_SECRET=
|
TWITTER_SECRET=
|
||||||
|
UNSPLASH_KEY=
|
||||||
USPS_USERID=
|
USPS_USERID=
|
||||||
WATTPAD_KEY=
|
WATTPAD_KEY=
|
||||||
WEBSTER_KEY=
|
WEBSTER_KEY=
|
||||||
|
|||||||
@@ -194,6 +194,7 @@ API. All are free unless otherwise stated.
|
|||||||
* `TMDB_KEY` can be obtained by [following these instructions at the TMDB website](https://www.themoviedb.org/documentation/api). Read the "How do I apply for an API key?" section.
|
* `TMDB_KEY` can be obtained by [following these instructions at the TMDB website](https://www.themoviedb.org/documentation/api). Read the "How do I apply for an API key?" section.
|
||||||
* `TUMBLR_KEY` can be obtained at the [Tumblr developer portal](https://www.tumblr.com/oauth/apps).
|
* `TUMBLR_KEY` can be obtained at the [Tumblr developer portal](https://www.tumblr.com/oauth/apps).
|
||||||
* `TWITTER_KEY` and `TWITTER_SECRET` can be obtained at the [Twitter developer portal](https://developer.twitter.com/en/apps).
|
* `TWITTER_KEY` and `TWITTER_SECRET` can be obtained at the [Twitter developer portal](https://developer.twitter.com/en/apps).
|
||||||
|
* `UNSPLASH_KEY` can be obtained at the [Unsplash developer portal](https://unsplash.com/developers).
|
||||||
* `USPS_USERID` can be obtained at the [Web Tools API Portal](https://www.usps.com/business/web-tools-apis/).
|
* `USPS_USERID` can be obtained at the [Web Tools API Portal](https://www.usps.com/business/web-tools-apis/).
|
||||||
* `WATTPAD_KEY` can be obtained at the [Wattpad developer portal](https://www.wattpad.com/developer/docs/api).
|
* `WATTPAD_KEY` can be obtained at the [Wattpad developer portal](https://www.wattpad.com/developer/docs/api).
|
||||||
* `WEBSTER_KEY` can be obtained by [going to the Dictionary API website](https://dictionaryapi.com/). Find the "GET STARTED USING OUR API" section.
|
* `WEBSTER_KEY` can be obtained by [going to the Dictionary API website](https://dictionaryapi.com/). Find the "GET STARTED USING OUR API" section.
|
||||||
@@ -226,7 +227,7 @@ in the appropriate channel's topic to use it.
|
|||||||
|
|
||||||
## Commands
|
## Commands
|
||||||
|
|
||||||
Total: 471
|
Total: 472
|
||||||
|
|
||||||
### Utility:
|
### Utility:
|
||||||
|
|
||||||
@@ -457,6 +458,7 @@ Total: 471
|
|||||||
* **safebooru:** Responds with an image from Safebooru, with optional query.
|
* **safebooru:** Responds with an image from Safebooru, with optional query.
|
||||||
* **stack-overflow:** Searches Stack Overflow for your query.
|
* **stack-overflow:** Searches Stack Overflow for your query.
|
||||||
* **steam:** Searches Steam for your query.
|
* **steam:** Searches Steam for your query.
|
||||||
|
* **stock-photo:** Searches for stock photos based on your query.
|
||||||
* **stocks:** Responds with the current stocks for a company.
|
* **stocks:** Responds with the current stocks for a company.
|
||||||
* **tenor:** Searches Tenor for your query.
|
* **tenor:** Searches Tenor for your query.
|
||||||
* **tumblr:** Responds with information on a Tumblr blog.
|
* **tumblr:** Responds with information on a Tumblr blog.
|
||||||
@@ -1447,6 +1449,8 @@ here.
|
|||||||
* genie-rules ([Image](https://www.reddit.com/r/MemeTemplatesOfficial/comments/bht9o6/i_made_an_hd_high_quality_version_of_the_4_rules/))
|
* genie-rules ([Image](https://www.reddit.com/r/MemeTemplatesOfficial/comments/bht9o6/i_made_an_hd_high_quality_version_of_the_4_rules/))
|
||||||
- [UNDERTALE](https://undertale.com/)
|
- [UNDERTALE](https://undertale.com/)
|
||||||
* temmie (Original Game)
|
* temmie (Original Game)
|
||||||
|
- [Unsplash](https://unsplash.com/)
|
||||||
|
* stock-photo ([API](https://unsplash.com/developers))
|
||||||
- [Urban Dictionary](https://www.urbandictionary.com/)
|
- [Urban Dictionary](https://www.urbandictionary.com/)
|
||||||
* urban ([API](https://github.com/zdict/zdict/wiki/Urban-dictionary-API-documentation))
|
* urban ([API](https://github.com/zdict/zdict/wiki/Urban-dictionary-API-documentation))
|
||||||
- [USPS](https://www.usps.com/)
|
- [USPS](https://www.usps.com/)
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
const Command = require('../../structures/Command');
|
||||||
|
const request = require('node-superfetch');
|
||||||
|
const { MessageEmbed } = require('discord.js');
|
||||||
|
const { shorten } = require('../../util/Util');
|
||||||
|
const { UNSPLASH_KEY } = process.env;
|
||||||
|
|
||||||
|
module.exports = class StockPhotoCommand extends Command {
|
||||||
|
constructor(client) {
|
||||||
|
super(client, {
|
||||||
|
name: 'stock-photo',
|
||||||
|
aliases: ['unsplash', 'stock-image', 'stock-img'],
|
||||||
|
group: 'search',
|
||||||
|
memberName: 'stock-photo',
|
||||||
|
description: 'Searches for stock photos based on your query.',
|
||||||
|
clientPermissions: ['EMBED_LINKS'],
|
||||||
|
credit: [
|
||||||
|
{
|
||||||
|
name: 'Unsplash',
|
||||||
|
url: 'https://unsplash.com/',
|
||||||
|
reason: 'API',
|
||||||
|
reasonURL: 'https://unsplash.com/developers'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
key: 'query',
|
||||||
|
prompt: 'What image would you like to search for?',
|
||||||
|
type: 'string'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async run(msg, { query }) {
|
||||||
|
try {
|
||||||
|
const { body } = await request
|
||||||
|
.get('https://api.unsplash.com/photos/random')
|
||||||
|
.set({ Authorization: `Client-ID ${UNSPLASH_KEY}` })
|
||||||
|
.query({
|
||||||
|
query,
|
||||||
|
content_filter: msg.channel.nsfw ? 'low' : 'high'
|
||||||
|
});
|
||||||
|
if (!body) return msg.say('Could not find any results.');
|
||||||
|
const embed = new MessageEmbed()
|
||||||
|
.setTitle(body.description ? shorten(body.description, 256) : 'Unnamed Image')
|
||||||
|
.setURL(body.links.download)
|
||||||
|
.setColor(body.color)
|
||||||
|
.setAuthor(body.user.name || body.user.username, undefined, body.user.links.html)
|
||||||
|
.setImage(body.urls.raw)
|
||||||
|
.setFooter(`Photo by ${body.user.name || body.user.username} on Unsplash`)
|
||||||
|
.setTimestamp(new Date(body.updated_at));
|
||||||
|
return msg.embed(embed);
|
||||||
|
} catch (err) {
|
||||||
|
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiao",
|
"name": "xiao",
|
||||||
"version": "116.14.0",
|
"version": "116.15.0",
|
||||||
"description": "Your personal server companion.",
|
"description": "Your personal server companion.",
|
||||||
"main": "Xiao.js",
|
"main": "Xiao.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user