mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-26 06:42:50 +02:00
Join/Leave Voice Commands
This commit is contained in:
@@ -132,7 +132,7 @@ in the appropriate channel's topic to use it.
|
|||||||
|
|
||||||
## Commands
|
## Commands
|
||||||
|
|
||||||
Total: 411
|
Total: 413
|
||||||
|
|
||||||
### Utility:
|
### Utility:
|
||||||
|
|
||||||
@@ -513,7 +513,6 @@ Total: 411
|
|||||||
* **clap:** Sends 👏 text 👏 like 👏 this.
|
* **clap:** Sends 👏 text 👏 like 👏 this.
|
||||||
* **cow-say:** Makes a cow say your text.
|
* **cow-say:** Makes a cow say your text.
|
||||||
* **cursive:** Converts text to cursive.
|
* **cursive:** Converts text to cursive.
|
||||||
* **dec-talk:** The world's best Text-to-Speech.
|
|
||||||
* **dvorak:** Converts text to Dvorak encoding.
|
* **dvorak:** Converts text to Dvorak encoding.
|
||||||
* **embed:** Sends text in an embed.
|
* **embed:** Sends text in an embed.
|
||||||
* **emojify:** Converts text to emoji form.
|
* **emojify:** Converts text to emoji form.
|
||||||
@@ -565,9 +564,15 @@ Total: 411
|
|||||||
* **tax:** Determines the total cost of something plus tax.
|
* **tax:** Determines the total cost of something plus tax.
|
||||||
* **units:** Converts units to/from other units.
|
* **units:** Converts units to/from other units.
|
||||||
|
|
||||||
### Other:
|
### Voice-Based:
|
||||||
|
|
||||||
* **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.
|
||||||
|
* **join:** Joins your voice channel.
|
||||||
|
* **leave:** Leaves the current voice channel.
|
||||||
|
|
||||||
|
### Other:
|
||||||
|
|
||||||
* **cleverbot:** Talk to Cleverbot. (Owner-Only)
|
* **cleverbot:** Talk to Cleverbot. (Owner-Only)
|
||||||
* **phone-book:** Looks up phone-enabled servers.
|
* **phone-book:** Looks up phone-enabled servers.
|
||||||
* **phone:** Starts a phone call with a random server.
|
* **phone:** Starts a phone call with a random server.
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ client.registry
|
|||||||
['edit-meme', 'Meme Generators'],
|
['edit-meme', 'Meme Generators'],
|
||||||
['edit-text', 'Text Manipulation'],
|
['edit-text', 'Text Manipulation'],
|
||||||
['edit-number', 'Number Manipulation'],
|
['edit-number', 'Number Manipulation'],
|
||||||
|
['voice', 'Voice-Based'],
|
||||||
['other', 'Other'],
|
['other', 'Other'],
|
||||||
['roleplay', 'Roleplay'],
|
['roleplay', 'Roleplay'],
|
||||||
['readme', 'README Generators']
|
['readme', 'README Generators']
|
||||||
|
|||||||
@@ -1,49 +0,0 @@
|
|||||||
const Command = require('../../structures/Command');
|
|
||||||
const path = require('path');
|
|
||||||
const sounds = require('../../assets/json/airhorn');
|
|
||||||
|
|
||||||
module.exports = class AirhornCommand extends Command {
|
|
||||||
constructor(client) {
|
|
||||||
super(client, {
|
|
||||||
name: 'airhorn',
|
|
||||||
group: 'other',
|
|
||||||
memberName: 'airhorn',
|
|
||||||
description: 'Plays an airhorn sound in a voice channel.',
|
|
||||||
guildOnly: true,
|
|
||||||
throttling: {
|
|
||||||
usages: 1,
|
|
||||||
duration: 10
|
|
||||||
},
|
|
||||||
credit: [
|
|
||||||
{
|
|
||||||
name: 'Discord',
|
|
||||||
url: 'https://discord.com/',
|
|
||||||
reason: 'Airhorn Sounds',
|
|
||||||
reasonURL: 'https://github.com/discord/airhornbot/tree/master/audio'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async run(msg) {
|
|
||||||
const voiceChannel = msg.member.voice.channel;
|
|
||||||
if (!voiceChannel) return msg.say('Please enter a voice channel first.');
|
|
||||||
if (!voiceChannel.permissionsFor(this.client.user).has(['CONNECT', 'SPEAK'])) {
|
|
||||||
return msg.say('Missing the "Connect" or "Speak" permission for the voice channel.');
|
|
||||||
}
|
|
||||||
if (!voiceChannel.joinable) return msg.say('Your voice channel is not joinable.');
|
|
||||||
if (this.client.voice.connections.has(voiceChannel.guild.id)) return msg.say('I am already playing a sound.');
|
|
||||||
try {
|
|
||||||
const connection = await voiceChannel.join();
|
|
||||||
const airhorn = sounds[Math.floor(Math.random() * sounds.length)];
|
|
||||||
const dispatcher = connection.play(path.join(__dirname, '..', '..', 'assets', 'sounds', 'airhorn', airhorn));
|
|
||||||
await msg.react('🔉');
|
|
||||||
dispatcher.once('finish', () => voiceChannel.leave());
|
|
||||||
dispatcher.once('error', () => voiceChannel.leave());
|
|
||||||
return null;
|
|
||||||
} catch (err) {
|
|
||||||
voiceChannel.leave();
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -6,7 +6,6 @@ module.exports = class InviteCommand extends Command {
|
|||||||
constructor(client) {
|
constructor(client) {
|
||||||
super(client, {
|
super(client, {
|
||||||
name: 'invite',
|
name: 'invite',
|
||||||
aliases: ['join'],
|
|
||||||
group: 'util',
|
group: 'util',
|
||||||
memberName: 'invite',
|
memberName: 'invite',
|
||||||
description: 'Responds with the bot\'s invite links.',
|
description: 'Responds with the bot\'s invite links.',
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
const Command = require('../../structures/Command');
|
||||||
|
const path = require('path');
|
||||||
|
const sounds = require('../../assets/json/airhorn');
|
||||||
|
|
||||||
|
module.exports = class AirhornCommand extends Command {
|
||||||
|
constructor(client) {
|
||||||
|
super(client, {
|
||||||
|
name: 'airhorn',
|
||||||
|
group: 'voice',
|
||||||
|
memberName: 'airhorn',
|
||||||
|
description: 'Plays an airhorn sound in a voice channel.',
|
||||||
|
guildOnly: true,
|
||||||
|
throttling: {
|
||||||
|
usages: 1,
|
||||||
|
duration: 10
|
||||||
|
},
|
||||||
|
userPermissions: ['CONNECT', 'SPEAK'],
|
||||||
|
clientPermissions: ['ADD_REACTIONS', 'READ_MESSAGE_HISTORY'],
|
||||||
|
credit: [
|
||||||
|
{
|
||||||
|
name: 'Discord',
|
||||||
|
url: 'https://discord.com/',
|
||||||
|
reason: 'Airhorn Sounds',
|
||||||
|
reasonURL: 'https://github.com/discord/airhornbot/tree/master/audio'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async run(msg) {
|
||||||
|
const inGuild = msg.guild ? undefined : null;
|
||||||
|
const connection = this.client.voice.connections.get(msg.guild.id);
|
||||||
|
if (!connection) {
|
||||||
|
return msg.say(`I am not in a voice channel. Use ${msg.anyUsage('join', inGuild, inGuild)} to fix that!.`);
|
||||||
|
}
|
||||||
|
const airhorn = sounds[Math.floor(Math.random() * sounds.length)];
|
||||||
|
connection.play(path.join(__dirname, '..', '..', 'assets', 'sounds', 'airhorn', airhorn));
|
||||||
|
await msg.react('🔉');
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -6,7 +6,7 @@ module.exports = class DECTalkCommand extends Command {
|
|||||||
super(client, {
|
super(client, {
|
||||||
name: 'dec-talk',
|
name: 'dec-talk',
|
||||||
aliases: ['text-to-speech', 'tts'],
|
aliases: ['text-to-speech', 'tts'],
|
||||||
group: 'edit-text',
|
group: 'voice',
|
||||||
memberName: 'dec-talk',
|
memberName: 'dec-talk',
|
||||||
description: 'The world\'s best Text-to-Speech.',
|
description: 'The world\'s best Text-to-Speech.',
|
||||||
guildOnly: true,
|
guildOnly: true,
|
||||||
@@ -47,25 +47,19 @@ module.exports = class DECTalkCommand extends Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async run(msg, { text }) {
|
async run(msg, { text }) {
|
||||||
const voiceChannel = msg.member.voice.channel;
|
const inGuild = msg.guild ? undefined : null;
|
||||||
if (!voiceChannel) return msg.say('Please enter a voice channel first.');
|
const connection = this.client.voice.connections.get(msg.guild.id);
|
||||||
if (!voiceChannel.permissionsFor(this.client.user).has(['CONNECT', 'SPEAK'])) {
|
if (!connection) {
|
||||||
return msg.say('Missing the "Connect" or "Speak" permission for the voice channel.');
|
return msg.say(`I am not in a voice channel. Use ${msg.anyUsage('join', inGuild, inGuild)} to fix that!.`);
|
||||||
}
|
}
|
||||||
if (!voiceChannel.joinable) return msg.say('Your voice channel is not joinable.');
|
|
||||||
if (this.client.voice.connections.has(voiceChannel.guild.id)) return msg.say('I am already playing a sound.');
|
|
||||||
try {
|
try {
|
||||||
const connection = await voiceChannel.join();
|
|
||||||
const { url } = await request
|
const { url } = await request
|
||||||
.get('http://tts.cyzon.us/tts')
|
.get('http://tts.cyzon.us/tts')
|
||||||
.query({ text });
|
.query({ text });
|
||||||
const dispatcher = connection.play(url);
|
connection.play(url);
|
||||||
await msg.react('🔉');
|
await msg.react('🔉');
|
||||||
dispatcher.once('finish', () => voiceChannel.leave());
|
|
||||||
dispatcher.once('error', () => voiceChannel.leave());
|
|
||||||
return null;
|
return null;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
voiceChannel.leave();
|
|
||||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
const Command = require('../../structures/Command');
|
||||||
|
|
||||||
|
module.exports = class JoinCommand extends Command {
|
||||||
|
constructor(client) {
|
||||||
|
super(client, {
|
||||||
|
name: 'join',
|
||||||
|
aliases: ['join-voice-channel', 'join-vc', 'join-voice', 'join-channel'],
|
||||||
|
group: 'voice',
|
||||||
|
memberName: 'join',
|
||||||
|
description: 'Joins your voice channel.',
|
||||||
|
guarded: true,
|
||||||
|
userPermissions: ['CONNECT']
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async run(msg) {
|
||||||
|
const voiceChannel = msg.member.voice.channel;
|
||||||
|
if (!voiceChannel) return msg.say('Please enter a voice channel first.');
|
||||||
|
if (!voiceChannel.permissionsFor(this.client.user).has(['CONNECT', 'SPEAK', 'VIEW_CHANNEL'])) {
|
||||||
|
return msg.say('I am missing the "Connect", "Speak", or "View Channel" permission for this voice channel.');
|
||||||
|
}
|
||||||
|
if (!voiceChannel.joinable) return msg.say('Your voice channel is not joinable.');
|
||||||
|
if (this.client.voice.connections.has(voiceChannel.guild.id)) return msg.say('I am already in a voice channel.');
|
||||||
|
await voiceChannel.join();
|
||||||
|
return msg.reply(`Joined **${voiceChannel.name}**!`);
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
const Command = require('../../structures/Command');
|
||||||
|
|
||||||
|
module.exports = class LeaveCommand extends Command {
|
||||||
|
constructor(client) {
|
||||||
|
super(client, {
|
||||||
|
name: 'leave',
|
||||||
|
aliases: ['leave-voice-channel', 'leave-vc', 'leave-voice', 'leave-channel'],
|
||||||
|
group: 'voice',
|
||||||
|
memberName: 'leave',
|
||||||
|
description: 'Leaves the current voice channel.',
|
||||||
|
guarded: true,
|
||||||
|
userPermissions: ['MOVE_MEMBERS']
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
run(msg) {
|
||||||
|
const connection = this.client.voice.connections.get(msg.guild.id);
|
||||||
|
if (!connection) return msg.say('I am not in a voice channel.');
|
||||||
|
connection.channel.leave();
|
||||||
|
return msg.reply(`Left **${connection.channel.name}**...`);
|
||||||
|
}
|
||||||
|
};
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiao",
|
"name": "xiao",
|
||||||
"version": "114.4.0",
|
"version": "114.5.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