mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Mindfulness Command
This commit is contained in:
@@ -270,7 +270,7 @@ in the appropriate channel's topic to use it.
|
|||||||
|
|
||||||
## Commands
|
## Commands
|
||||||
|
|
||||||
Total: 608
|
Total: 609
|
||||||
|
|
||||||
### Utility:
|
### Utility:
|
||||||
|
|
||||||
@@ -897,6 +897,7 @@ Total: 608
|
|||||||
|
|
||||||
* **airhorn:** Plays an airhorn sound in a voice channel.
|
* **airhorn:** Plays an airhorn sound in a voice channel.
|
||||||
* **dec-talk:** The world's best Text-to-Speech.
|
* **dec-talk:** The world's best Text-to-Speech.
|
||||||
|
* **mindfulness:** Immerse yourself in some mindful quotes.
|
||||||
* **soundboard:** Plays a sound in a voice channel.
|
* **soundboard:** Plays a sound in a voice channel.
|
||||||
* **vocodes:** Speak text like a variety of famous figures.
|
* **vocodes:** Speak text like a variety of famous figures.
|
||||||
|
|
||||||
@@ -1393,6 +1394,7 @@ here.
|
|||||||
* chi-idea ([Wild Words Font](https://www.insidescanlation.com/etc/the-idiots-guide-to-editing-manga/guide/type/fonts.html))
|
* chi-idea ([Wild Words Font](https://www.insidescanlation.com/etc/the-idiots-guide-to-editing-manga/guide/type/fonts.html))
|
||||||
- [InspiroBot](https://inspirobot.me/)
|
- [InspiroBot](https://inspirobot.me/)
|
||||||
* inspiration (API)
|
* inspiration (API)
|
||||||
|
* mindfulness (API)
|
||||||
- [ipify API](https://www.ipify.org/)
|
- [ipify API](https://www.ipify.org/)
|
||||||
* ip (API)
|
* ip (API)
|
||||||
- [iStock](https://www.istockphoto.com/)
|
- [iStock](https://www.istockphoto.com/)
|
||||||
|
|||||||
@@ -0,0 +1,64 @@
|
|||||||
|
const Command = require('../../structures/Command');
|
||||||
|
const request = require('node-superfetch');
|
||||||
|
const { Readable } = require('stream');
|
||||||
|
const { reactIfAble } = require('../../util/Util');
|
||||||
|
const { LOADING_EMOJI_ID } = process.env;
|
||||||
|
|
||||||
|
module.exports = class MindfulnessCommand extends Command {
|
||||||
|
constructor(client) {
|
||||||
|
super(client, {
|
||||||
|
name: 'mindfulness',
|
||||||
|
aliases: ['mindful'],
|
||||||
|
group: 'voice',
|
||||||
|
memberName: 'mindful',
|
||||||
|
description: 'Immerse yourself in some mindful quotes.',
|
||||||
|
guildOnly: true,
|
||||||
|
throttling: {
|
||||||
|
usages: 1,
|
||||||
|
duration: 10
|
||||||
|
},
|
||||||
|
userPermissions: ['CONNECT', 'SPEAK'],
|
||||||
|
credit: [
|
||||||
|
{
|
||||||
|
name: 'InspiroBot',
|
||||||
|
url: 'https://inspirobot.me/',
|
||||||
|
reason: 'API'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async run(msg) {
|
||||||
|
const connection = this.client.voice.connections.get(msg.guild.id);
|
||||||
|
if (!connection) {
|
||||||
|
const usage = this.client.registry.commands.get('join').usage();
|
||||||
|
return msg.reply(`I am not in a voice channel. Use ${usage} to fix that!`);
|
||||||
|
}
|
||||||
|
if (this.client.dispatchers.has(msg.guild.id)) return msg.reply('I am already playing audio in this server.');
|
||||||
|
try {
|
||||||
|
await reactIfAble(msg, this.client.user, LOADING_EMOJI_ID, '💬');
|
||||||
|
const flow = await this.fetchFlow();
|
||||||
|
const { body } = await request.get(flow.mp3);
|
||||||
|
const dispatcher = connection.play(Readable.from([body]));
|
||||||
|
this.client.dispatchers.set(msg.guild.id, dispatcher);
|
||||||
|
dispatcher.once('finish', () => this.client.dispatchers.delete(msg.guild.id));
|
||||||
|
dispatcher.once('error', () => this.client.dispatchers.delete(msg.guild.id));
|
||||||
|
await reactIfAble(msg, this.client.user, '🔉');
|
||||||
|
for (const item of body.data) {
|
||||||
|
if (item.type !== 'text') continue;
|
||||||
|
setTimeout(() => msg.say(item.text).catch(() => null), item.time * 1000);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
} catch (err) {
|
||||||
|
await reactIfAble(msg, this.client.user, '⚠️');
|
||||||
|
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fetchFlow() {
|
||||||
|
const { body } = await request
|
||||||
|
.get('https://inspirobot.me/api')
|
||||||
|
.query({ generateFlow: 1 });
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
};
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiao",
|
"name": "xiao",
|
||||||
"version": "131.2.0",
|
"version": "131.3.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