mirror of
https://github.com/hazemKrimi/discord-bot.git
synced 2026-05-01 18:30:25 +00:00
added commando
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
|
||||
module.exports = class JoinCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'join',
|
||||
memberName: 'join',
|
||||
group: 'music',
|
||||
description: 'joins a voice channel',
|
||||
aliases: ['summon'],
|
||||
guildOnly: true
|
||||
});
|
||||
}
|
||||
|
||||
async run(message) {
|
||||
const voiceChannel = message.member.voice.channel;
|
||||
|
||||
if (!voiceChannel) return message.reply('you need to join a channel!');
|
||||
|
||||
const connection = await voiceChannel.join();
|
||||
|
||||
return message.say('joined!');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
|
||||
module.exports = class Leave extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'leave',
|
||||
memberName: 'leave',
|
||||
group: 'music',
|
||||
description: 'leaves a voice channel',
|
||||
guildOnly: true
|
||||
});
|
||||
}
|
||||
|
||||
async run(message) {
|
||||
if (!message.member.voice.channel) return message.reply('you need to join a channel!');
|
||||
|
||||
const voiceChannel = message.member.voice.channel;
|
||||
|
||||
voiceChannel.leave();
|
||||
|
||||
return message.say('left!');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const Youtube = require('simple-youtube-api');
|
||||
const ytdl = require('ytdl-core-discord');
|
||||
const youtube = new Youtube(process.env.YOUTUBE_API_KEY);
|
||||
|
||||
module.exports = class Play extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'play',
|
||||
memberName: 'play',
|
||||
group: 'music',
|
||||
description: 'plays audio from youtube or facebook',
|
||||
guildOnly: true,
|
||||
clientPermissions: ['SPEAK', 'CONNECT'],
|
||||
args: [
|
||||
{
|
||||
key: 'query',
|
||||
prompt: 'what do you want to listen to?',
|
||||
type: 'string',
|
||||
validate: query => query.length > 0
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(message, { query }) {
|
||||
const voiceChannel = message.member.voice.channel;
|
||||
|
||||
if (!voiceChannel) return message.reply('you need to join a channel!');
|
||||
|
||||
const connection = await voiceChannel.join();
|
||||
|
||||
if (query.match(/^(http(s)?:\/\/)?((w){3}.)?youtu(be|.be)?(\.com)?\/.+/)) {
|
||||
const dispatcher = connection.play(await ytdl(query), { type: 'opus' });
|
||||
|
||||
dispatcher.on('start', () => {
|
||||
return message.reply('youtube video is playing!');
|
||||
});
|
||||
} else {
|
||||
return message.reply('currently, i only support youtube video links!');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
|
||||
module.exports = class Play extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'stop',
|
||||
memberName: 'stop',
|
||||
group: 'music',
|
||||
description: 'stops the player and leaves the channel',
|
||||
guildOnly: true
|
||||
});
|
||||
}
|
||||
|
||||
async run(message) {
|
||||
if (!message.member.voice.channel) return message.reply('you need to join a channel!');
|
||||
|
||||
const voiceChannel = message.member.voice.channel;
|
||||
|
||||
voiceChannel.leave();
|
||||
|
||||
return message.say('stopped!');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user