Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const Discord = require('discord.js');
- const client = new Discord.Client();
- const config = require("./config.json");
- const YTDL = require("ytdl-core")
- const fs = require("fs")
- var servers = {};
- function play(connection,message){
- var server = servers[message.gulid];
- server.dispatcher = connection.playStream(YTDL(server.queue[0], {filter: "audioonly"}));
- server.queue.shift();
- server.dispatcher.on("end",function(){
- if (server.queue[0])play(connection, message);
- else
- connection.disconnect();
- });
- }
- client.on('ready', () => {
- console.log(`Logged in as ${client.user.tag}!`);
- });
- client.on("error", (e) => console.error(e));
- client.on("warn", (e) => console.warn(e));
- client.on("debug", (e) => console.info(e));
- // client.on("raw",(e) => console.raw(e));
- client.on("message", message => {
- if (message.author.bot) return;
- // This is where we'll put our code.
- if (message.content.indexOf(config.prefix) !== 0) return;
- const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
- const command = args.shift().toLowerCase();
- if(command === 'ping') {
- message.channel.send('Pong!');
- } else
- if (command === 'blah') {message.channel.send('Meh.');}
- else
- if (command === 'music') {
- if (args[0] === "play"){if(message.member.voiceChannel){message.member.voiceChannel.join().then(connect => {message.reply("I have connect to the voiceChannel");}).then(function (connection){play(connection,message);});}else{message.reply("You need to join a first !!!");}}
- else
- if (args[0] === "join"){if(message.member.voiceChannel){message.member.voiceChannel.join().then(connect => {message.reply("I have connect to the voiceChannel");}).catch(console.log);}else{message.reply("You need to join a first !!!");}}
- else
- if (args[0] === "leave"){if(message.member.VoiceChannel){client.voiceChannel.leave();}else{message.reply("I need to be in the voice channel first");}}
- else
- if (args[0] === "stop"){message.channel.send("stop function comming soon");}
- else
- if (args[0] === "pause"){message.channel.send("pause function comming soon");}
- else
- message.channel.send("command: play pause stop join leave");
- }
- if (message.content.includes('changeNick')) {
- client.setNickname({nick: message.content.replace('changeNick ', '')});
- }
- if (command === "asl") {
- let [age, sex, location] = args;
- message.reply(`Hello ${message.author.username}, I see you're a ${age} year old ${sex} from ${location}. Wanna date ?`);
- }
- // Kick a single user in the mention
- if (command === "kick") {
- let member = message.mentions.members.first();
- member.kick();
- }
- //Ensures bot doesn't reply to itself or non-commands
- if (message.author.bot) return;
- // if (!message.content.startsWith(config.prefix)) return;
- //Simplifies command making
- // let command = message.content.toLowerCase().split(" ")[0];
- // command = command.slice(config.prefix.length);
- //Simplifies arguments in a command
- // let args = message.content.split(" ").slice(1);
- if (command === "changeNick") {
- let [name] = args;
- client.user.setUsername(args).then(user => message.reply(`My new nickname is ${user.username}!`)).catch(console.error);
- }
- if(command === "say"){
- let text = args.join(" ");
- message.delete();
- message.channel.send(text);
- }
- if(command === "bot"){
- if(args[0] === "shutdown"){message.channel.send('shutting down').then(msg => client.destroy())};
- if(args[0] === "restart"){message.channel.send('Restartting...').then(msg => client.destroy()).then(()=> client.login(config.token));}}
- //if(command === "quote") {
- // const [channelid, messageid, quotename, ...note] = args.splice(1);
- // I also support "here" as a channelID using this:
- // const channel = channelid == "here" ? message.channel : client.channels.get(channelid);
- // I do the same with message ID, which can be "last":
- // const message = messageid === "last" ? msg.channel.messages.last(2)[0] : await channel.messages.get(messageid);
- // pretend for a second this is the rest of the function:
- // insertInDB(quotename, channel.id, message.id, note.join(" "));
- //}
- });
- client.login(config.token);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement