mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Soundcloud command is back!
This commit is contained in:
@@ -15,7 +15,7 @@ Xiao is a Discord bot coded in JavaScript with
|
||||
Xiao is no longer available for invite. You can self-host the bot, or use her on
|
||||
the [home server](https://discord.gg/sbMe32W).
|
||||
|
||||
## Commands (325)
|
||||
## Commands (326)
|
||||
### Utility:
|
||||
|
||||
* **eval:** Executes JavaScript code.
|
||||
@@ -165,6 +165,7 @@ the [home server](https://discord.gg/sbMe32W).
|
||||
* **rotten-tomatoes:** Searches Rotten Tomatoes for your query.
|
||||
* **rule-of-the-internet:** Responds with a rule of the internet.
|
||||
* **safebooru:** Responds with an image from Safebooru, with optional query.
|
||||
* **soundcloud:** Searches SoundCloud for your query.
|
||||
* **stack-overflow:** Searches Stack Overflow for your query.
|
||||
* **steam:** Searches Steam for your query.
|
||||
* **stocks:** Responds with the current stocks for a specific symbol.
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const moment = require('moment');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const request = require('node-superfetch');
|
||||
const { SOUNDCLOUD_KEY } = process.env;
|
||||
|
||||
module.exports = class SoundcloudCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'soundcloud',
|
||||
aliases: ['soundcloud-song', 'soundcloud-music'],
|
||||
group: 'search',
|
||||
memberName: 'soundcloud',
|
||||
description: 'Searches SoundCloud for your query.',
|
||||
clientPermissions: ['EMBED_LINKS'],
|
||||
args: [
|
||||
{
|
||||
key: 'query',
|
||||
prompt: 'What song would you like to search for?',
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { query }) {
|
||||
try {
|
||||
const { body } = await request
|
||||
.get('http://api.soundcloud.com/tracks')
|
||||
.query({
|
||||
q: query,
|
||||
client_id: SOUNDCLOUD_KEY
|
||||
});
|
||||
if (!body.length) return msg.say('Could not find any results.');
|
||||
const data = body[0];
|
||||
const embed = new MessageEmbed()
|
||||
.setColor(0xFF5500)
|
||||
.setAuthor('SoundCloud', 'https://i.imgur.com/ctft3v7.png', 'https://soundcloud.com/')
|
||||
.setURL(data.permalink_url)
|
||||
.setThumbnail(data.artwork_url)
|
||||
.setTitle(data.title)
|
||||
.setDescription(data.description || 'No description available.')
|
||||
.addField('❯ Artist', `[${data.user.username}](${data.user.permalink_url})`, true)
|
||||
.addField('❯ Release Date', moment.utc(data.created_at).format('MM/DD/YYYY'), true)
|
||||
.addField('❯ Genre', data.genre, true)
|
||||
.addField('❯ Likes', data.likes_count, true);
|
||||
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",
|
||||
"version": "92.3.1",
|
||||
"version": "92.4.0",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user