Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const Discord = require('discord.js');
- const {
- prefix,
- token,
- } = require('./config.json');
- const ytdl = require('ytdl-core');
- const client = new Discord.Client();
- const queue = new Map();
- client.once('ready', () => {
- console.log('Ready!');
- });
- client.once('reconnecting', () => {
- console.log('Reconnecting!');
- });
- client.once('disconnect', () => {
- console.log('Disconnect!');
- });
- client.on('message', async message => {
- if (message.author.bot) return;
- if (!message.content.startsWith(prefix)) return;
- const serverQueue = queue.get(message.guild.id);
- if (message.content.startsWith(`${prefix}play`)) {
- execute(message, serverQueue);
- return;
- } else if (message.content.startsWith(`${prefix}skip`)) {
- skip(message, serverQueue);
- return;
- } else if (message.content.startsWith(`${prefix}stop`)) {
- stop(message, serverQueue);
- return;
- } else if (message.content.startsWith(`${prefix}np`)) {
- message.channel.send(`Now playing: ${serverQueue.songs[0].title}`);
- return;
- } else if (message.content.startsWith(`${prefix}queue`)) {
- message.channel.send(`server queue: ${serverQueue.songs[5].title}`);
- return;
- } else if (message.content.startsWith(`${prefix}help`)) {
- message.channel.send('commands:');
- message.channel.send('+play: plays a song');
- message.channel.send('+skip: skips a song');
- message.channel.send('+stop:clears the queue and stops the current song');
- message.channel.send('+np: shows what song is playing');
- message.channel.send('+queue: shows the song queue');
- message.channel.send('+countryroads: starts the country road sequence');
- message.channel.send('+scream: plays a cowboy scream');
- return;
- } else if (message.content.startsWith(`+scream`)) {
- message.channel.send('AAAAAAAAAAA')
- message.member.voiceChannel.join()
- .then(connection => {
- const dispatcher = connection.playFile('C:\Users\isabe\OneDrive\my music bot\Kirin_J_Callinan_Big_Enough_Ringtone_(by Fringster.com).mp3');
- })
- .catch(console.error);
- return;
- } else if (message.content.startsWith(`${prefix}countryroads`)) {
- message.channel.send(`initiating country roads...`);
- message.channel.send('country roads intitiated ');
- message.channel.send('start the sequence by saying "almost heaven"')
- return;
- } else {
- message.channel.send('You need to enter a valid command!')
- }
- });
- async function execute(message, serverQueue) {
- const args = message.content.split(' ');
- const voiceChannel = message.member.voiceChannel;
- if (!voiceChannel) return message.channel.send('You need to be in a voice channel to play music!');
- const permissions = voiceChannel.permissionsFor(message.client.user);
- if (!permissions.has('CONNECT') || !permissions.has('SPEAK')) {
- return message.channel.send('I need the permissions to join and speak in your voice channel!');
- }
- const songInfo = await ytdl.getInfo(args[1]);
- const song = {
- title: songInfo.title,
- url: songInfo.video_url,
- };
- if (!serverQueue) {
- const queueContruct = {
- textChannel: message.channel,
- voiceChannel: voiceChannel,
- connection: null,
- songs: [],
- volume: 5,
- playing: true,
- };
- queue.set(message.guild.id, queueContruct);
- queueContruct.songs.push(song);
- try {
- var connection = await voiceChannel.join();
- queueContruct.connection = connection;
- play(message.guild, queueContruct.songs[0]);
- } catch (err) {
- console.log(err);
- queue.delete(message.guild.id);
- return message.channel.send(err);
- }
- } else {
- serverQueue.songs.push(song);
- console.log(serverQueue.songs);
- return message.channel.send(`${song.title} has been added to the queue!`);
- }
- }
- function skip(message, serverQueue) {
- if (!message.member.voiceChannel) return message.channel.send('You have to be in a voice channel to stop the music!');
- if (!serverQueue) return message.channel.send('There is no song that I could skip!');
- serverQueue.connection.dispatcher.end();
- }
- function stop(message, serverQueue) {
- if (!message.member.voiceChannel) return message.channel.send('You have to be in a voice channel to stop the music!');
- serverQueue.songs = [];
- serverQueue.connection.dispatcher.end();
- }
- function play(guild, song) {
- const serverQueue = queue.get(guild.id);
- if (!song) {
- serverQueue.voiceChannel.leave();
- queue.delete(guild.id);
- return;
- }
- const dispatcher = serverQueue.connection.playStream(ytdl(song.url))
- .on('end', () => {
- console.log('Music ended!');
- serverQueue.songs.shift();
- play(guild, serverQueue.songs[0]);
- })
- .on('error', error => {
- console.error(error);
- });
- dispatcher.setVolumeLogarithmic(serverQueue.volume / 5);
- }
- client.login(token);
- client.on('message', message => {
- if (message.content === 'country roads') {
- message.channel.send('take me home');
- } else if (message.content.startsWith(`to the place`)) {
- message.channel.send('I belong');
- }
- else if (message.content.startsWith(`WEST VIRGINIA`)) {
- message.channel.send('MOUNTAIN MOMMA');
- }
- else if (message.content.startsWith(`TO THE PLACE`)) {
- message.channel.send('I BELONG');
- }
- else if (message.content.startsWith(`west virginia`)) {
- message.channel.send('mountain momma');
- }
- else if (message.content === `COUNTRY ROADS`) {
- message.channel.send('TAKE ME HOME');
- }
- else if (message.content.startsWith(`i hear her voice in the morning`)) {
- message.channel.send('hour she calls me');
- }
- else if (message.content.startsWith(`I HEAR HER VOICE IN THE MORNING`)) {
- message.channel.send('HOUR SHE CALLS ME');
- }
- else if (message.content.startsWith(`RADIO REMINDS ME OF MY HOME FAR AWAY`)) {
- message.channel.send('DRIVING DOWN THE ROAD I GET A FEELING I SHOULD HAVE BEEN HOME YESTERDAY, YESTERDAY');
- }
- else if (message.content.startsWith(`radio reminds me of my home far away`)) {
- message.channel.send('drivin down the road I get a feeling I should have been home yesterday, yesterday');
- }
- else if (message.content.startsWith(`all my memories`)) {
- message.channel.send("gather 'round her");
- }
- else if (message.content.startsWith(`ALL MY MEMORIES`)) {
- message.channel.send("GATHER 'ROUND HER");
- }
- else if (message.content.startsWith(`MINER`)) {
- message.channel.send('STRANGER TO BLUE WATER');
- }
- else if (message.content.startsWith(`miner`)) {
- message.channel.send('stranger to blue water');
- }
- else if (message.content.startsWith(`dark and dusty`)) {
- message.channel.send('painted on the sky');
- }
- else if (message.content.startsWith(`DARK AND DUSTY`)) {
- message.channel.send('PAINTED ON THE SKY');
- }
- else if (message.content.startsWith(`misty taste of moonshine`)) {
- message.channel.send('teardrop in my eye');
- }
- else if (message.content.startsWith(`MISTY TASTE OF MOONSHINE`)) {
- message.channel.send('TEARDROP IN MY EYE');
- }
- else if (message.content.startsWith(`almost heaven`)) {
- message.channel.send('West Virginia');
- }
- else if (message.content.startsWith(`blue ridge mountains`)) {
- message.channel.send('Shenandoah River');
- }
- else if (message.content.startsWith(`life is old there`)) {
- message.channel.send('older than the trees');
- }
- else if (message.content.startsWith(`younger than the mountains`)) {
- message.channel.send('blowing like a breeze');
- }
- else if (message.content === `take me home,`) {
- message.channel.send('down country roads');
- }
- else if (message.content === `Take me home,`) {
- message.channel.send('down country roads');
- }
- else if (message.content === `TAKE ME HOME,`) {
- message.channel.send('DOWN COUNTRY ROADS');
- }
- else if (message.content === `radio reminds of my home far away,`) {
- message.channel.send('drivin down the road I get a feeling I should have been home yesterday, yesterday');
- }
- else if (message.content === `RADIO REMINDS OF MY HOME FAR AWAY,`) {
- message.channel.send('DRIVING DOWN THE ROAD I GET A FEELING I SHOULD HAVE BEEN HOME YESTERDAY, YESTERDAY');
- }
- else if (message.content === `${prefix}server`) {
- message.channel.send(`This server's name is: ${message.guild.name}`);
- }
- });
- client.on('message', message => {
- if (message.content === `TAKE ME HOME`) {
- message.channel.send('COUNTRY ROADS');
- }})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement