Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const express = require("express");
- const app = express();
- app.listen(() => console.log("Server started"));
- app.use('/ping', (req, res) => {
- res.send(new Date());
- });
- const Discord = require('discord.js');
- const client = new Discord.Client();
- let prefix = '-'//بريفكس البوت مهم
- const db = require('quick.db')
- const DisTube = require('distube');
- const { SoundCloudPlugin } = require("@distube/soundcloud");
- const distube = new DisTube.DisTube(client, {
- youtubeDL: true,
- emitNewSongOnly: false,
- savePreviousSongs: true,
- leaveOnFinish: false,
- leaveOnStop: false,
- leaveOnEmpty :false,
- plugins: [new SoundCloudPlugin()]});
- const DisTubeVoice = require('distube')
- client.on('ready', async() => {
- console.log('im online')
- client.user.setActivity(`${prefix}help`, { type : 'PLAYING', status: "dnd"})
- var fs = require('fs');
- setInterval(() => {
- fs.readFile('json.sqlite', 'utf8', function(err, contents) {
- });
- }, 10000)
- })
- client.on("message", async (message) => {
- if (message.author.bot) return;
- if(message.channel.type === 'dm') return;
- if (!message.content.startsWith(prefix)) return;
- const args = message.content.slice(prefix.length).trim().split(/ +/g);
- const command = args.shift();
- if(command === 'help') {
- message.channel.send(new Discord.MessageEmbed()
- .setColor('#056608')
- .setAuthor(message.member.user.tag,message.member.user.displayAvatarURL())
- .setDescription(`**${prefix}play \| ${prefix}p :** to play a song. \n **${prefix}pause \| ${prefix}pa:** to pause the song. \n **${prefix}resume \| ${prefix}re :** to resume the song.\n **${prefix}stop \| ${prefix}st :** to stop the songs. \n **${prefix}volume \| ${prefix}vol:** to see and set volume.\n **${prefix}jump :** to jump to a song in the queue using the number. \n **${prefix}nowplaying \| ${prefix}np :** see the current song name.\n **${prefix}skip \| ${prefix}s :** to skip the current song.`)
- .setTimestamp())
- }
- if (["play", "p"].includes(command)) {
- const cc = distube.getQueue(message)
- let player = args.join(" ")
- if(!message.member.voice.channel) return
- if(message.guild.me.voice.channel && !cc) {distube.voices.leave(message.guild.id)}
- try {
- distube.play(message, player);
- } catch (e) {
- message.channel.send(` Error: \`${e}\``)
- }
- }
- if (["skip", "s"].includes(command)) {
- if(!message.member.voice.channel) return
- let queue = distube.getQueue(message);
- if(!queue) return message.channel.send('no more songs in queue to skip.')
- if(queue.songs.length === 1) return message.channel.send('no more songs in queue to skip.')
- try{
- const queueskip = distube.getQueue(message);
- distube.skip(message)
- message.channel.send('skipping....')
- } catch(err) { message.channel.send('no songs to skip') }
- }
- if (["nowplaying", "np"].includes(command)) {
- if(!message.member.voice.channel) return
- let queue = distube.getQueue(message);
- if(!queue) return message.channel.send('no song playing.')
- if(queue.songs.length === 0) return message.channel.send('no songs are playing.')
- message.channel.send(new Discord.MessageEmbed()
- .setColor('#056608')
- .setDescription('Current song :\n' + queue.songs.map((song, id) =>
- `⭐- [${song.name}](${song.url}) - \`${song.formattedDuration}\` added by : \`${song.user.tag}\``
- ).slice(0, 1).join("\n")));
- }
- if (["pause", "pa"].includes(command)) {
- let queue = distube.getQueue(message);
- if(!queue) return message.channel.send('no song playing to pause.')
- if(queue.songs.length === 0) return message.channel.send('no songs to pause.')
- const pausable = distube.getQueue(message);
- if(!message.member.voice.channel) return;
- try{
- distube.pause(message);
- message.channel.send('paused!')
- } catch(err) {message.channel.send('already paused or the bot not playing.')}
- }
- if (["resume", "re"].includes(command)) {
- if(!message.member.voice.channel) return;
- let queue = distube.getQueue(message);
- if(!queue) return message.channel.send('no song paused to resume')
- if(queue.songs.length === 0) return message.channel.send('no songs to resume.')
- try{
- distube.resume(message);
- message.channel.send('resuming!!')
- } catch(err) {message.channel.send('the queue not paused or the bot not playing.')}
- }
- if (["volume", "vol"].includes(command)) {
- if(!message.member.voice.channel) return;
- let vol = args.join(" ")
- const volume = db.fetch(`${message.guild.id}_volume`)||75
- if(!vol) return message.channel.send(`current volume is: ${volume}%`)
- if (isNaN(vol)) return message.channel.send('only numbers!')
- if (vol > 100 || vol <= 0) return message.channel.send('allowed volume => 0 to 100')
- message.channel.send(`new volume: **${vol}%**`)
- db.set(`${message.guild.id}_volume`, vol)
- distube.setVolume(message, parseInt(vol))
- }
- if (["repeat", "loop"].includes(command)) {
- if(!message.member.voice.channel) return;
- let queue = distube.getQueue(message);
- if(!queue) return message.channel.send('no songs to repeat.')
- if(queue.songs.length === 0) return message.channel.send('no songs to repeat.')
- let repeat = db.fetch('repeat')
- if(!args[0]) return message.channel.send(`${prefix}repeat (0/1/2)\n 1 = repeat current song. \n 2 = repeat queue. \n 0 = off.\n current repeat mode \`${repeat}\``)
- let mode = distube.setRepeatMode(message, parseInt(args[0]));
- mode = mode ? mode == 2 ? "Repeat queue" : "Repeat song" : "Off";
- db.set("repeat", args[0])
- message.channel.send("Set repeat mode to `" + mode + "`");
- }
- if (["stop", "st"].includes(command)) {
- if(!message.member.voice.channel) return;
- if(!distube.getQueue(message)) return message.channel.send('no songs playing to stop!')
- if(queue.songs.length === 0) return message.channel.send('no songs playing to stop.')
- distube.stop(message);
- message.channel.send(new Discord.MessageEmbed()
- .setColor('#056608')
- .setAuthor(message.author.tag,message.author.displayAvatarURL())
- .setDescription("Stopped the music!"))
- }
- if(command === "previous") {
- if(!message.member.voice.channel) return;
- try {
- distube.previous(message)
- message.channel.send('playing previous song!.')
- }catch(err) { message.channel.send('no song is playing!!')}
- }
- if (command == "queue") {
- if(!message.member.voice.channel) return;
- let queue = distube.getQueue(message);
- if(!queue) return message.channel.send('you didnt add songs to queue in this server!')
- message.channel.send(new Discord.MessageEmbed()
- .setColor('#056608')
- .setDescription('Current queue:\n' + queue.songs.map((song, id) =>
- `⭐-**${id + 0}**. ${song.name} - \`${song.formattedDuration}\``
- ).slice(0, 11).join("\n"))
- .addField('songs:', queue.songs.length));
- }
- if(command === "jump") {
- if(!message.member.voice.channel) return;
- let queue = distube.getQueue(message);
- if (!queue) return message.channel.send(new Discord.MessageEmbed()
- .setColor('#850101')
- .setDescription(`❌ | There is nothing in the queue right now!`))
- if(queue.songs.length === 1) return message.channel.send('no more songs to jump.')
- let queuenumber = args.join(" ")
- if(queuenumber === "0") return message.channel.send('this song already playing!')
- if(queuenumber > 10) return message.channel.send('max number is 10')
- distube.jump(message, parseInt(args[0]))
- }
- });
- distube.on("addSong", (queue, song) =>{
- queue.textChannel.send(new Discord.MessageEmbed()
- .setColor('#056608')
- .setAuthor(song.user.tag,song.user.displayAvatarURL())
- .setDescription(`Added ${song.name} - \`${song.formattedDuration}\` to the queue by ${song.user.tag}`)
- )
- }).on("playList", (queue, playlist, song) => queue.textChannel.send(new Discord.MessageEmbed()
- .setColor('#056608')
- .setAuthor(playlist.user.tag,playlist.user.displayAvatarURL())
- .setDescription(`Play \`${playlist.name}\` playlist (${playlist.songs.length} songs).\nRequested by: ${song.user.tag}\nNow playing \`${song.name}\` - \`${song.formattedDuration}\``)
- ))
- .on("addList", (queue, playlist) => queue.textChannel.send(new Discord.MessageEmbed()
- .setColor('#056608')
- .setAuthor(playlist.user.tag,playlist.user.displayAvatarURL())
- .setDescription(`Added \`${playlist.name}\` playlist (${playlist.songs.length} songs) to queue`)
- ))
- distube.on("error", (channel, error) => { console.log(error)
- });
- distube.on("playSong", (queue, song) => { queue.textChannel.send(new Discord.MessageEmbed()
- .setColor('#056608')
- .setDescription(`Playing- ${song.name}`)
- .addField('likes:', song.likes)
- .addField(`duration:`, song.formattedDuration)
- .addField('views:', song.views)
- )
- let repeat = db.fetch('repeat') || 0
- let mode = distube.setRepeatMode(queue.textChannel.guild.id, parseInt(repeat));
- mode = mode ? mode == 2 ? "Repeat queue" : "Repeat song" : "Off";
- let vols = db.get(`${queue.textChannel.guild.id}_volume`) || 75
- distube.setVolume(queue.textChannel.guild.id, parseInt(vols))
- })
- distube.on("finish", (queue) => { queue.textChannel.send("No more songs in queue")});
- distube.on("noRelated", (queue) => queue.textChannel.send("Can't find related video to play. Stop playing music."));
- client.on("message", async message => {
- if (message.content.startsWith(prefix + "setname")) {
- let args = message.content.split(" ");
- let botnameee = args.slice(1).join(" ");
- if (!message.member.hasPermission('MANAGE_GUILD'))
- return message.channel.send(
- `** :x: Only Owners Can Use this Command **`
- );
- if (!botnameee)
- return message.channel.send(
- `** :x: Please Provide me a name for the bot !**`
- );
- client.user.setUsername(`${botnameee}`);
- message.channel.send(`Changing The bot's Name ...`).then(me => {
- me.edit(` Done !`);
- });
- }
- if (message.content.startsWith(prefix + "setavatar")) {
- let args = message.content.split(" ");
- let botnameee = args.slice(1).join(" ");
- if (!message.member.hasPermission('MANAGE_GUILD'))
- return message.channel.send(
- `** :x: Only Owners Can Use this Command **`
- );
- if (!botnameee)
- return message.channel.send(
- `** :x: Please Provide me an avatar for the bot !**`
- );
- client.user.setAvatar(`${botnameee}`);
- message.channel.send(`Changing The bot's Avatar ...`).then(me => {
- me.edit(` Done !`);
- });
- }
- });
- client.login(process.env.token);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement