mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Remove play, resume, pause, stop
This commit is contained in:
@@ -34,7 +34,6 @@ ANILIST_USERNAME=
|
|||||||
BITLY_KEY=
|
BITLY_KEY=
|
||||||
CLEVERBOT_KEY=
|
CLEVERBOT_KEY=
|
||||||
GITHUB_ACCESS_TOKEN=
|
GITHUB_ACCESS_TOKEN=
|
||||||
GOOGLE_KEY=
|
|
||||||
GOV_KEY=
|
GOV_KEY=
|
||||||
IDIOT_URL=
|
IDIOT_URL=
|
||||||
REMOVEBG_KEY=
|
REMOVEBG_KEY=
|
||||||
|
|||||||
@@ -73,7 +73,6 @@ Only if you want to use the DECTalk command.
|
|||||||
* `BITLY_KEY` is your API key for Bit.ly. You can get one [here](https://dev.bitly.com/docs/getting-started/authentication/).
|
* `BITLY_KEY` is your API key for Bit.ly. You can get one [here](https://dev.bitly.com/docs/getting-started/authentication/).
|
||||||
* `CLEVERBOT_KEY` is your API key for Cleverbot. You can get one [here](https://www.cleverbot.com/api/).
|
* `CLEVERBOT_KEY` is your API key for Cleverbot. You can get one [here](https://www.cleverbot.com/api/).
|
||||||
* `GITHUB_ACCESS_TOKEN` is your access token for GitHub. [Follow these steps](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-personal-access-token-classic) to make one.
|
* `GITHUB_ACCESS_TOKEN` is your access token for GitHub. [Follow these steps](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-personal-access-token-classic) to make one.
|
||||||
* `GOOGLE_KEY` is your API key for Google, used for the YouTube Data API. You can get one [here](https://console.cloud.google.com/apis/dashboard). You must also [activate the YouTube Data API](https://console.cloud.google.com/marketplace/product/google/youtube.googleapis.com?q=search).
|
|
||||||
* `GOV_KEY` is your API key for NASA. You get get one [here](https://api.nasa.gov/).
|
* `GOV_KEY` is your API key for NASA. You get get one [here](https://api.nasa.gov/).
|
||||||
* `IDIOT_URL` is a URL, ideally to the [Wikipedia page of an idiot](https://en.wikipedia.org/wiki/Donald_Trump). By default, it will reply with "_Stares at you._"
|
* `IDIOT_URL` is a URL, ideally to the [Wikipedia page of an idiot](https://en.wikipedia.org/wiki/Donald_Trump). By default, it will reply with "_Stares at you._"
|
||||||
* `REMOVEBG_KEY` is your API key for remove.bg. You can get one [here](https://www.remove.bg/api).
|
* `REMOVEBG_KEY` is your API key for remove.bg. You can get one [here](https://www.remove.bg/api).
|
||||||
@@ -114,7 +113,7 @@ Only if you want to use the DECTalk command.
|
|||||||
18. Start Xiao up!
|
18. Start Xiao up!
|
||||||
|
|
||||||
## Commands
|
## Commands
|
||||||
Total: 518
|
Total: 515
|
||||||
|
|
||||||
### Utility:
|
### Utility:
|
||||||
|
|
||||||
@@ -127,8 +126,10 @@ Total: 518
|
|||||||
* **help:** Displays a list of available commands, or detailed information for a specific command.
|
* **help:** Displays a list of available commands, or detailed information for a specific command.
|
||||||
* **high-scores:** Responds with the high scores the bot has saved.
|
* **high-scores:** Responds with the high scores the bot has saved.
|
||||||
* **info:** Responds with detailed bot information.
|
* **info:** Responds with detailed bot information.
|
||||||
|
* **join:** Joins your voice channel.
|
||||||
* **last-run:** Responds with a command's most recent run date.
|
* **last-run:** Responds with a command's most recent run date.
|
||||||
* **last-run-leaderboard:** Responds with the bot's most recently run commands.
|
* **last-run-leaderboard:** Responds with the bot's most recently run commands.
|
||||||
|
* **leave:** Leaves the current voice channel.
|
||||||
* **options:** Responds with a list of server options.
|
* **options:** Responds with a list of server options.
|
||||||
* **ping:** Checks the bot's ping to the Discord server.
|
* **ping:** Checks the bot's ping to the Discord server.
|
||||||
* **report:** Reports something to the bot owner(s).
|
* **report:** Reports something to the bot owner(s).
|
||||||
@@ -138,14 +139,6 @@ Total: 518
|
|||||||
* **unknown-command:** Displays help information for when an unknown command is used.
|
* **unknown-command:** Displays help information for when an unknown command is used.
|
||||||
* **uses:** Responds with a command's usage stats.
|
* **uses:** Responds with a command's usage stats.
|
||||||
|
|
||||||
### Utility (Voice):
|
|
||||||
|
|
||||||
* **join:** Joins your voice channel.
|
|
||||||
* **leave:** Leaves the current voice channel.
|
|
||||||
* **pause:** Pauses the current audio playing.
|
|
||||||
* **resume:** Resume the current audio playing.
|
|
||||||
* **stop:** Stops the current audio playing.
|
|
||||||
|
|
||||||
### Discord Information:
|
### Discord Information:
|
||||||
|
|
||||||
* **avatar:** Responds with a user's avatar.
|
* **avatar:** Responds with a user's avatar.
|
||||||
@@ -665,7 +658,6 @@ Total: 518
|
|||||||
* **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.
|
* **mindfulness:** Immerse yourself in some mindful quotes.
|
||||||
* **morse:** Converts text to morse code.
|
* **morse:** Converts text to morse code.
|
||||||
* **play:** Plays a YouTube video in your voice channel.
|
|
||||||
* **tts:** Say the text you provide in the accent you choose.
|
* **tts:** Say the text you provide in the accent you choose.
|
||||||
|
|
||||||
### Reminders:
|
### Reminders:
|
||||||
@@ -695,7 +687,6 @@ Total: 518
|
|||||||
### NPM Packages
|
### NPM Packages
|
||||||
* [@discordjs/opus](https://www.npmjs.com/package/@discordjs/opus)
|
* [@discordjs/opus](https://www.npmjs.com/package/@discordjs/opus)
|
||||||
* [@discordjs/voice](https://www.npmjs.com/package/@discordjs/voice)
|
* [@discordjs/voice](https://www.npmjs.com/package/@discordjs/voice)
|
||||||
* [@distube/ytdl-core](https://www.npmjs.com/package/@distube/ytdl-core)
|
|
||||||
* [@mediapipe/face_detection](https://www.npmjs.com/package/@mediapipe/face_detection)
|
* [@mediapipe/face_detection](https://www.npmjs.com/package/@mediapipe/face_detection)
|
||||||
* [@napi-rs/canvas](https://www.npmjs.com/package/@napi-rs/canvas)
|
* [@napi-rs/canvas](https://www.npmjs.com/package/@napi-rs/canvas)
|
||||||
* [@skyra/gifenc](https://www.npmjs.com/package/@skyra/gifenc)
|
* [@skyra/gifenc](https://www.npmjs.com/package/@skyra/gifenc)
|
||||||
@@ -1451,8 +1442,6 @@ Total: 518
|
|||||||
- [Digital Equipment Corporation](http://gordonbell.azurewebsites.net/digital/timeline/tmlnhome.htm) (Original DECTalk Software)
|
- [Digital Equipment Corporation](http://gordonbell.azurewebsites.net/digital/timeline/tmlnhome.htm) (Original DECTalk Software)
|
||||||
* **mindfulness:**
|
* **mindfulness:**
|
||||||
- [InspiroBot](https://inspirobot.me/) (API)
|
- [InspiroBot](https://inspirobot.me/) (API)
|
||||||
* **play:**
|
|
||||||
- [Google](https://www.google.com/) ([YouTube Data API](https://developers.google.com/youtube/v3/))
|
|
||||||
* **tts:**
|
* **tts:**
|
||||||
- [Google](https://www.google.com/) (Translate TTS API)
|
- [Google](https://www.google.com/) (Translate TTS API)
|
||||||
* **cleverbot:**
|
* **cleverbot:**
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ client.registry
|
|||||||
.registerGroups([
|
.registerGroups([
|
||||||
['util', 'Utility (Owner)'],
|
['util', 'Utility (Owner)'],
|
||||||
['util-public', 'Utility'],
|
['util-public', 'Utility'],
|
||||||
['util-voice', 'Utility (Voice)'],
|
|
||||||
['info', 'Discord Information'],
|
['info', 'Discord Information'],
|
||||||
['random-res', 'Random Response'],
|
['random-res', 'Random Response'],
|
||||||
['random-img', 'Random Image'],
|
['random-img', 'Random Image'],
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
"urban": "https://i.imgur.com/Fo0nRTe.png",
|
"urban": "https://i.imgur.com/Fo0nRTe.png",
|
||||||
"wikipedia": "https://i.imgur.com/Z7NJBK2.png",
|
"wikipedia": "https://i.imgur.com/Z7NJBK2.png",
|
||||||
"yugioh": "https://i.imgur.com/AJNBflD.png",
|
"yugioh": "https://i.imgur.com/AJNBflD.png",
|
||||||
"youtube": "https://i.imgur.com/kKHJg9Q.png",
|
|
||||||
"scryfall": "https://i.imgur.com/DyuauFS.png",
|
"scryfall": "https://i.imgur.com/DyuauFS.png",
|
||||||
"lorcana": "https://i.imgur.com/rqatpU3.png"
|
"lorcana": "https://i.imgur.com/rqatpU3.png"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ module.exports = class JoinCommand extends Command {
|
|||||||
super(client, {
|
super(client, {
|
||||||
name: 'join',
|
name: 'join',
|
||||||
aliases: ['join-voice-channel', 'join-vc', 'join-voice', 'join-channel', 'connect'],
|
aliases: ['join-voice-channel', 'join-vc', 'join-voice', 'join-channel', 'connect'],
|
||||||
group: 'util-voice',
|
group: 'util',
|
||||||
description: 'Joins your voice channel.',
|
description: 'Joins your voice channel.',
|
||||||
guildOnly: true,
|
guildOnly: true,
|
||||||
guarded: true,
|
guarded: true,
|
||||||
@@ -6,7 +6,7 @@ module.exports = class LeaveCommand extends Command {
|
|||||||
super(client, {
|
super(client, {
|
||||||
name: 'leave',
|
name: 'leave',
|
||||||
aliases: ['leave-voice-channel', 'leave-vc', 'leave-voice', 'leave-channel', 'disconnect'],
|
aliases: ['leave-voice-channel', 'leave-vc', 'leave-voice', 'leave-channel', 'disconnect'],
|
||||||
group: 'util-voice',
|
group: 'util',
|
||||||
description: 'Leaves the current voice channel.',
|
description: 'Leaves the current voice channel.',
|
||||||
guildOnly: true,
|
guildOnly: true,
|
||||||
guarded: true
|
guarded: true
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
const Command = require('../../framework/Command');
|
|
||||||
const { PermissionFlagsBits } = require('discord.js');
|
|
||||||
|
|
||||||
module.exports = class PauseCommand extends Command {
|
|
||||||
constructor(client) {
|
|
||||||
super(client, {
|
|
||||||
name: 'pause',
|
|
||||||
aliases: ['pause-voice-channel', 'pause-vc', 'pause-voice', 'pause-music', 'pause-playing'],
|
|
||||||
group: 'util-voice',
|
|
||||||
description: 'Pauses the current audio playing.',
|
|
||||||
guildOnly: true,
|
|
||||||
guarded: true
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
run(msg) {
|
|
||||||
const connection = this.client.dispatchers.get(msg.guild.id);
|
|
||||||
if (!connection) return msg.reply('I am not in a voice channel.');
|
|
||||||
if (connection.canPlay) {
|
|
||||||
return msg.reply('I am not currently playing audio in this server.');
|
|
||||||
}
|
|
||||||
if (!connection.channel.permissionsFor(msg.author).has(PermissionFlagsBits.MoveMembers)) {
|
|
||||||
return msg.reply(`You need the "MOVE_MEMBERS" permission to use the \`${this.name}\` command.`);
|
|
||||||
}
|
|
||||||
connection.pause();
|
|
||||||
return msg.reply('Paused playing.');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
const Command = require('../../framework/Command');
|
|
||||||
const { PermissionFlagsBits } = require('discord.js');
|
|
||||||
|
|
||||||
module.exports = class ResumeCommand extends Command {
|
|
||||||
constructor(client) {
|
|
||||||
super(client, {
|
|
||||||
name: 'resume',
|
|
||||||
aliases: ['resume-voice-channel', 'resume-vc', 'resume-voice', 'resume-music', 'resume-playing'],
|
|
||||||
group: 'util-voice',
|
|
||||||
description: 'Resume the current audio playing.',
|
|
||||||
guildOnly: true,
|
|
||||||
guarded: true
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
run(msg) {
|
|
||||||
const connection = this.client.dispatchers.get(msg.guild.id);
|
|
||||||
if (!connection) return msg.reply('I am not in a voice channel.');
|
|
||||||
if (connection.canPlay) {
|
|
||||||
return msg.reply('I am not currently playing audio in this server.');
|
|
||||||
}
|
|
||||||
if (!connection.channel.permissionsFor(msg.author).has(PermissionFlagsBits.MoveMembers)) {
|
|
||||||
return msg.reply(`You need the "MOVE_MEMBERS" permission to use the \`${this.name}\` command.`);
|
|
||||||
}
|
|
||||||
connection.unpause();
|
|
||||||
return msg.reply('Resumed playing.');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
const Command = require('../../framework/Command');
|
|
||||||
const { PermissionFlagsBits } = require('discord.js');
|
|
||||||
|
|
||||||
module.exports = class StopCommand extends Command {
|
|
||||||
constructor(client) {
|
|
||||||
super(client, {
|
|
||||||
name: 'stop',
|
|
||||||
aliases: ['stop-voice-channel', 'stop-vc', 'stop-voice', 'stop-music', 'stop-playing'],
|
|
||||||
group: 'util-voice',
|
|
||||||
description: 'Stops the current audio playing.',
|
|
||||||
guildOnly: true,
|
|
||||||
guarded: true
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
run(msg) {
|
|
||||||
const connection = this.client.dispatchers.get(msg.guild.id);
|
|
||||||
if (!connection) return msg.reply('I am not in a voice channel.');
|
|
||||||
if (connection.canPlay) {
|
|
||||||
return msg.reply('I am not currently playing audio in this server.');
|
|
||||||
}
|
|
||||||
if (!connection.channel.permissionsFor(msg.author).has(PermissionFlagsBits.MoveMembers)) {
|
|
||||||
return msg.reply(`You need the "MOVE_MEMBERS" permission to use the \`${this.name}\` command.`);
|
|
||||||
}
|
|
||||||
connection.stop();
|
|
||||||
return msg.reply('Stopped playing.');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,98 +0,0 @@
|
|||||||
const Command = require('../../framework/Command');
|
|
||||||
const { EmbedBuilder, PermissionFlagsBits } = require('discord.js');
|
|
||||||
const request = require('node-superfetch');
|
|
||||||
const ytdl = require('@distube/ytdl-core');
|
|
||||||
const { shorten, verify } = require('../../util/Util');
|
|
||||||
const logos = require('../../assets/json/logos');
|
|
||||||
const { GOOGLE_KEY } = process.env;
|
|
||||||
|
|
||||||
module.exports = class PlayCommand extends Command {
|
|
||||||
constructor(client) {
|
|
||||||
super(client, {
|
|
||||||
name: 'play',
|
|
||||||
aliases: ['play-music', 'music'],
|
|
||||||
group: 'voice',
|
|
||||||
description: 'Plays a YouTube video in your voice channel.',
|
|
||||||
guildOnly: true,
|
|
||||||
throttling: {
|
|
||||||
usages: 2,
|
|
||||||
duration: 60
|
|
||||||
},
|
|
||||||
userPermissions: [PermissionFlagsBits.Connect, PermissionFlagsBits.Speak],
|
|
||||||
credit: [
|
|
||||||
{
|
|
||||||
name: 'Google',
|
|
||||||
url: 'https://www.google.com/',
|
|
||||||
reason: 'YouTube Data API',
|
|
||||||
reasonURL: 'https://developers.google.com/youtube/v3/'
|
|
||||||
}
|
|
||||||
],
|
|
||||||
args: [
|
|
||||||
{
|
|
||||||
key: 'query',
|
|
||||||
type: 'string'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async run(msg, { query }) {
|
|
||||||
const connection = this.client.dispatchers.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 (!connection.canPlay) return msg.reply('I am already playing audio in this server.');
|
|
||||||
const result = await this.searchForVideo(query, msg.channel.nsfw || false);
|
|
||||||
if (!result) return msg.reply('Could not find any results for your query.');
|
|
||||||
const data = await ytdl.getInfo(result);
|
|
||||||
const canPlay = this.canUseVideo(data, msg.channel.nsfw || false);
|
|
||||||
if (!canPlay) return msg.reply('I cannot play this video.');
|
|
||||||
if (canPlay === 'length') return msg.reply('This video is longer than 15 minutes, so I can\'t play it.');
|
|
||||||
await msg.reply('Is this the video you want to play? Reply with **[y]es** or **[n]o**.', {
|
|
||||||
embeds: [this.generateEmbed(data)]
|
|
||||||
});
|
|
||||||
const verification = await verify(msg.channel, msg.author);
|
|
||||||
if (!verification) return msg.reply('Aborting playback.');
|
|
||||||
connection.play(ytdl(result, { filter: 'audioonly' }));
|
|
||||||
return msg.reply(`🔉 Now playing **${shorten(data.videoDetails.title, 70)}**!`);
|
|
||||||
}
|
|
||||||
|
|
||||||
async searchForVideo(query, nsfw) {
|
|
||||||
if (ytdl.validateURL(query)) return ytdl.getURLVideoID(query);
|
|
||||||
if (ytdl.validateID(query)) return query;
|
|
||||||
if (!GOOGLE_KEY) return null;
|
|
||||||
const { body } = await request
|
|
||||||
.get('https://www.googleapis.com/youtube/v3/search')
|
|
||||||
.query({
|
|
||||||
part: 'snippet',
|
|
||||||
type: 'video',
|
|
||||||
maxResults: 1,
|
|
||||||
q: query,
|
|
||||||
safeSearch: nsfw ? 'none' : 'strict',
|
|
||||||
key: GOOGLE_KEY
|
|
||||||
});
|
|
||||||
if (!body.items.length) return null;
|
|
||||||
const data = body.items[0];
|
|
||||||
return data.id.videoId;
|
|
||||||
}
|
|
||||||
|
|
||||||
canUseVideo(data, nsfw) {
|
|
||||||
if (data.videoDetails.isPrivate || data.videoDetails.isLiveContent) return false;
|
|
||||||
if (data.videoDetails.age_restricted && nsfw) return false;
|
|
||||||
if (Number.parseInt(data.videoDetails.lengthSeconds, 10) > 900) return 'length';
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
generateEmbed(data) {
|
|
||||||
return new EmbedBuilder()
|
|
||||||
.setColor(0xDD2825)
|
|
||||||
.setTitle(shorten(data.videoDetails.title, 70))
|
|
||||||
.setDescription(shorten(data.videoDetails.description, 100))
|
|
||||||
.setAuthor({ name: 'YouTube', iconURL: logos.youtube, url: 'https://www.youtube.com/' })
|
|
||||||
.setURL(data.videoDetails.video_url)
|
|
||||||
.setThumbnail(data.videoDetails.thumbnails.length ? data.videoDetails.thumbnails[0].url : null)
|
|
||||||
.addField('❯ ID', data.videoDetails.videoId, true)
|
|
||||||
.addField('❯ Publish Date', data.videoDetails.publishDate, true);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
+1
-2
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiao",
|
"name": "xiao",
|
||||||
"version": "158.0.1",
|
"version": "159.0.0",
|
||||||
"description": "Your personal server companion.",
|
"description": "Your personal server companion.",
|
||||||
"main": "Xiao.js",
|
"main": "Xiao.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -31,7 +31,6 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@discordjs/opus": "^0.10.0",
|
"@discordjs/opus": "^0.10.0",
|
||||||
"@discordjs/voice": "^0.19.0",
|
"@discordjs/voice": "^0.19.0",
|
||||||
"@distube/ytdl-core": "^4.16.12",
|
|
||||||
"@dotenvx/dotenvx": "^1.49.0",
|
"@dotenvx/dotenvx": "^1.49.0",
|
||||||
"@mediapipe/face_detection": "^0.4.1646425229",
|
"@mediapipe/face_detection": "^0.4.1646425229",
|
||||||
"@napi-rs/canvas": "^0.1.80",
|
"@napi-rs/canvas": "^0.1.80",
|
||||||
|
|||||||
Reference in New Issue
Block a user