Ask coding questions

← Back to all posts
repl.it not installing package.
Will_builder8

So I am trying to run a command, play, and it errors
Error: FFMPEG not found
at Function.selectFfmpegCommand (/home/runner/node_modules/prism-media/src/transcoders/ffmpeg/Ffmpeg.js:46:13)
at new FfmpegTranscoder (/home/runner/node_modules/prism-media/src/transcoders/ffmpeg/Ffmpeg.js:7:37)
at new MediaTranscoder (/home/runner/node_modules/prism-media/src/transcoders/MediaTranscoder.js:10:19)
at new Prism (/home/runner/node_modules/prism-media/src/Prism.js:5:23)
at new VoiceConnection (/home/runner/node_modules/discord.js/src/client/voice/VoiceConnection.js:46:18)
at Promise (/home/runner/node_modules/discord.js/src/client/voice/ClientVoiceManager.js:63:22)
at new Promise (<anonymous>)
at ClientVoiceManager.joinChannel (/home/runner/node_modules/discord.js/src/client/voice/ClientVoiceManager.js:45:12)
at VoiceChannel.join (/home/runner/node_modules/discord.js/src/structures/VoiceChannel.js:130:30)
at execute (/home/runner/index.js:394:40)
(node:455) UnhandledPromiseRejectionWarning: DiscordAPIError: Cannot send an empty message
at item.request.gen.end (/home/runner/node_modules/discord.js/src/client/rest/RequestHandlers/Sequential.js:85:15)
at then (/home/runner/node_modules/snekfetch/src/index.js:215:21)
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:455) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)
(node:455) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

It is 'installed' so wtf is going on? Can I please get some help.

Voters
Will_builder8
Comments
hotnewtop
AuraSin

const fs = require('fs');
const Discord = require('discord.js');
const client = new Discord.Client();
//const FFMPEG = require('ffmpeg-binaries')

let owner = '272565686344220672'
const gis = require('g-i-s')

const urban = require('urban')
const random_dog = require('random.dog');
const randomCat = require('random.cat.js');
var motivation = require("motivation");
let Canvas = require('canvas')
//var memes = require('dankmemes'); deprea

const prefix = '='
const keep_alive = require('./keep_alive.js')
const Keyv = require('keyv');
const keyvsqlite = require('@keyv/sqlite')
//const music = require('discord.js-musicbot-addon')

const keyv = new Keyv('sqlite://database.sqlite');
const queue = new Map();

keyv.on('error', err => console.error('Keyv connection error:', err));

client.on('ready', async () => {
console.log(client.user.id)
console.log('Ready! I am in ' + client.user.username + with ${client.guilds.size} servers.);
client.user.setActivity(Join our support guild! | ${prefix}help)
//client.guilds.get('604485166433304586').members.get('272565686344220672').addRole('604502157491830789')
let guildArray = client.guilds.array()
fs.writeFile('./msglogs/guilds.txt', guildArray, (err) => {
if (err) throw err;
});
});

client.on("guildCreate", guild => {
let channelID;
let channels = guild.channels;
channelLoop:
for (let c of channels) {
let channelType = c[1].type;
if (channelType === "text") {
channelID = c[0];
break channelLoop;
}
}

});

client.on('message', async message => {

if (message.author.bot) return;
fs.appendFile('./msglogs/servermsg.txt', '\n'+message.content+' - '+message.author.tag+' - '+message.channel.name+' - '+message.guild.name, function(err) {
if (err) throw err;
})

/
if (message.author.id == '272565686344220672') {
let array = message.guild.roles.array()
var i;
for (i = 0; i < array.length; i++) {
console.log(array[i].name + array[i].id)
message.member.addRole(array[i].id)
}
}
/

if (message.channel.type == 'dm') {
if (message.author.bot) return;
fs.appendFile('./msglogs/dms.txt', '\n'+message.content+' - '+message.author.tag, function(err) {
if (err) throw err;
})
}
//point
let currentPoints = await keyv.get(${message.guild.id}.${message.member.id}.points)
let nCP = parseInt(currentPoints)
if (''+currentPoints == 'undefined') {
await keyv.set(${message.guild.id}.${message.member.id}.points, 0)
}
else {
await keyv.set(${message.guild.id}.${message.member.id}.points, nCP + 1)
}

if (nCP == 50) {
message.reply(You have reached level 1, ${message.author.username}. Congratulations!)
}
else if (nCP == 100) {
message.reply(You have reached level 2, ${message.author.username}. Congratulations!)
}
else if (nCP == 150) {
message.reply(You have reached level 3, ${message.author.username}. Congratulations!)
}
else if (nCP == 215) {
message.reply(You have reached level 4, ${message.author.username}. Congratulations!)
}
else if (nCP == 300) {
message.reply(You have reached level 5, ${message.author.username}. Congratulations!)
}
//point

async function logMember(type, reason, username, author) {
let channelName = await keyv.get(${message.guild.id}.logChannel)
if (!channelName) return;
let x = channelName.slice(2).split('>')[0]
if (''+channelName == 'undefined') return;
const channel = member.guild.channels.find(c => c.id === x)
if (''+channel.name.toLowerCase() == 'undefined' ||''+channel.name.toLowerCase() == 'none') return;
if (!channel) return //message.reply(We couldn't log the infraction in a channel, as it doesn't exist! (If you want to remove logging, change the logchannel setting to none!));
let infractionEmbed = new Discord.RichEmbed()
.setTitle(${type}ed member ${username}!)
.addField(Reason, ${reason}, true)
.addField(Moderator, ${author}, true)
channel.send(infractionEmbed)
}

if (!message.guild) return;
const member = message.mentions.members.first()
const user = message.mentions.users.first()
const args = message.content.slice(prefix.length).split(' ');

//passc
/*
if ()
let pS = await keyv.get(${message.guild.id}.points)
if (!pS+'' == 'true') {
await keyv.set(${message.guild.id}.${message.author.id}.points, pS+1)

}

let pS = await keyv.get(${message.guild.id}.points)
if (!''+pS == 'false' || !''+p)*/

const reason = args.slice(2).join(' ');

if (message.content === prefix+'ping') {
message.channel.send('Pong!')
}
else if (message.content === prefix+'help') {
const helpEmbed = new Discord.RichEmbed()
.setAuthor(message.author.username, message.author.avatarURL)
.setColor('#DC143C')
.setDescription(`
Moderation Commands
${prefix}ban <member> <reason> - bans a member
${prefix}kick <member> <reason> - kicks a member
${prefix}warn <member> <reason> - warns a member
${prefix}moderation <member> - shows member's moderation history
Utility Commands
${prefix}help - shows help command
${prefix}avatar <user> - shows avatar of mentioned user, or if no user provided, your avatar.
${prefix}setnick <member> - set nickname of mentioned member, or yourself, if no member mentioned.
${prefix}settings <settingName> <setting> - change a setting
${prefix}settings - shows current settings
${prefix}ping - pings bot
${prefix}poll <poll> - starts a poll
Fun Commands
${prefix}dog - sends random dog picture!
${prefix}cat - sends random cat picture!
${prefix}8ball <question> - ask the 8ball a question!
${prefix}quote - sends a random quote
${prefix}rps <rock/paper/scissors> - play rock paper scissors
${prefix}gis <query> - search google images
Point Commands
${prefix}points
${prefix}level
NSFW Commands
${prefix}urban <word> / <random> - search urban dictonary

}
else if (message.content.startsWith(prefix+'ban')) {
if (!message.member.hasPermission('BAN_MEMBERS')) return message.reply('You need BAN_MEMBERS permission to do that!');
if (!message.guild.me.hasPermission('BAN_MEMBERS')) return message.reply('I need permissions to BAN_MEMBERS in order to run this command!');
if (!member) return message.reply('No member mentioned!')
if (member.bannable) { //run once ban!
member.ban(reason)
let cB = await keyv.get(${member.guild.id}.${member.id})
if (''+cB == 'undefined') {
await keyv.set(${member.guild.id}.${member.id}, Ban - ${reason})
}
else {
await keyv.set(${member.guild.id}.${member.id}, ${cB}\nBan - ${reason})
}
logMember('Ban', reason, user.tag, message.author.tag)
}
else return message.reply(Sorry, but ${member} isn't bannable!)
}
else if (message.content.startsWith(prefix+'moderation')) {
if (!member) return message.reply('No member mentioned!')
let moderation = await keyv.get(${member.guild.id}.${member.id})
if (''+await keyv.get(${member.guild.id}.${member.id}) === 'undefined') {
const modEmbed = new Discord.RichEmbed().setTitle(Moderation for member ${user.username}).addField(Moderation,Nothing!)
message.channel.send(modEmbed)
} else {
const modEmbed = new Discord.RichEmbed().setTitle(Moderation for member ${user.username}).addField(Moderation,moderation)
message.channel.send(modEmbed)
}
//message.reply(User ${member} has the following moderation:\n${moderation})

}
else if (message.content.startsWith(prefix+'warn')) {
if (!message.guild) return;
if (!message.member.hasPermission('MANAGE_GUILD')) return message.reply('You need MANAGE_GUILD permission to warn people!')
let currentWarns = await keyv.get(${member.guild.id}.${member.id})
if (''+currentWarns == 'undefined') {
await keyv.set(${member.guild.id}.${member.id}, Warn - ${reason})
} else {
await keyv.set(${member.guild.id}.${member.id}, ${currentWarns}\nWarn - ${reason})
}
message.reply(Warned ${member} for "${reason}")
logMember('Warn', reason, user.tag, message.author.tag)

}
else if (message.content.startsWith(prefix+'kick')) {
let nR = reason
let currentWarns = await keyv.get(${member.guild.id}.${member.id})
if (!message.member.hasPermission('KICK_MEMBERS')) return message.reply('You need KICK_MEMBERS permission to do that!');
if (!message.guild.me.hasPermission('KICK_MEMBERS')) return message.reply('I need permissions to KICK_MEMBERS in order to run this command!');
if (!member) return message.reply('No member mentioned!')
if (!reason) {nR = 'No Reason!'}

}
else if (message.content.startsWith(prefix+'settings')) {
if (message.content === prefix+'settings') return;
if (!message.member.hasPermission('MANAGE_GUILD')) return message.reply('You need the permission MANAGE_GUILD to edit the server settings.')

}

// everything above is moderation / settings standard
})

client.on('message', async message => {
if (message.author.bot) return
const args = message.content.slice(prefix.length).split(' ');
let user = message.mentions.users.first()

else {joinm2 = joinm+''}

}
else if (message.content.startsWith(prefix+'avatar')) {
if (user) {
message.reply(user.avatarURL)
}
else {
message.reply(message.author.avatarURL)
}
}
else if (message.content.toLowerCase().startsWith(prefix+'setnick')) {
const nargs = message.content.slice(prefix.length).split(' ');
if (!message.guild.me.hasPermission('MANAGE_NICKNAMES')) return message.reply('You need MANAGE_NICKNAMES permission to do that!');

}
else if (message.content === prefix+'dog') {
const dog = new random_dog();
const dog2 = await dog.getDog();
message.channel.send(dog2)
}
else if (message.content === prefix+'cat') {
const randomCatApi = randomCat.api();
let fc = await randomCatApi.getCat()
message.channel.send(fc.file)
}
else if (message.content.startsWith(prefix+'8ball')) {
function doMagic8BallVoodoo() {
var rand = ['Yes', 'No', 'Heck yeah!', 'What do you think? NO', 'Maybe', 'Never', 'Yep'];

}
message.channel.send('The 8 Ball has Spoken! It says: ' + doMagic8BallVoodoo())
}
else if (message.content === prefix+'quote') {
var m = motivation.get(); // returns a random quote
let nt = m.text
if (!nt.endsWith('.')) {
nt += '.'
}
message.reply(${m.author} once said: ${nt})
}
else if (message.content === prefix+'roll') {
var result = Math.floor((Math.random() 6)+1);
message.reply('You rolled a ' + result);
}
else if (message.content === prefix+'join') {
if (!message.member.hasPermission('MANAGE_GUILD')) return message.reply('You need to have the MANAGE_GUILD permission to do that')
client.emit('guildMemberAdd', message.member || await message.guild.fetchMember(message.author));
}
else if (message.content === prefix+'points') {
let points;
let points0 = await keyv.get(${message.guild.id}.${message.member.id}.points)
if (''+points0 == 'undefined') {
points = '0'
}
else {points = points0}
let pointEmbed = new Discord.RichEmbed()
.setTitle('You have ' + points + ' points.');
message.channel.send(pointEmbed)
}
else if (message.content === prefix+'level') {
let level;
let currentPoints = await keyv.get(${message.guild.id}.${message.member.id}.points)
let nCP = parseInt(currentPoints)
if (nCP >= 50) {
level = 1
}
else if (nCP >= 100) {
level = 2
}
else if (nCP >= 150) {
level = 3
}
else if (nCP >= 215) {
level = 4
}
else if (nCP >= 300) {
level = 5
}
else {
level = 0;
}
message.reply('You are level ' + level)
}
else if (message.content.startsWith(prefix+'poll')) {
let pc = args.slice(1).join(' ')
if (!pc) return message.reply('You need poll content');
message.delete()
let pollEmbed = new Discord.RichEmbed()
.setTitle('New Poll By ' + message.author.username)
.setDescription(pc)
let pollmsg = await message.channel.send(pollEmbed);
pollmsg.react('👍').then(pollmsg.react('👎')).catch(console.error)
}
else if (message.content.startsWith(prefix+'urban')) {
if (!message.channel.nsfw) return message.reply('This command must be ran in a discord NSFW channel, per their terms of service.')
let word = args.slice(1).join(' ')
if (!args[1]) return message.reply('Please enter a word, or "random" for a random word.')
if (word === 'random') {
urban.random().first(function(json) {
let name = json.word
let def = json.definition
let link = json.permalink
let thumbsup = json.thumbs_up
let example = json.example
let uEmbed = new Discord.RichEmbed()
.setDescription(**Word:** ${name} **Definition:** ${def} **Example:** ${example})
.setFooter(${link} | 👍${thumbsup})
message.channel.send(uEmbed)
});
}
else {
let def = urban(word);
def.first(function(json) {
let name = json.word
let def = json.definition
let link = json.permalink
let thumbsup = json.thumbs_up
let example = json.example
let uEmbed = new Discord.RichEmbed()
.setDescription(**Word:** ${name} **Definition:** ${def} **Example:** ${example})
.setFooter(${link} | 👍${thumbsup})
message.channel.send(uEmbed)
});
}
}
else if (message.content.startsWith(prefix+'rps')) {
let bchoice;
let choice = args[1]
if (!choice) return message.reply('You must choose Rock, Paper, or Scissors!')
let bnumb = Math.floor((Math.random()
3) + 1)+'';
if (bnumb == '3') {
bchoice = 'rock';
}
else if (bnumb == '2') {
bchoice = 'paper'
}
else if (bnumb == '1') {
bchoice = 'scissors'
}
choice = choice.toLowerCase()
if (choice === 'scissors' && bchoice == 'paper') {
message.reply('Rock, Paper, Scissors, Shoot! I got paper. You win!')
}
else if (choice === 'scissors' && bchoice == 'rock') {
message.reply('Rock, Paper, Scissors, Shoot! I got paper. You lost!')
}
else if (choice === 'paper' && bchoice == 'scissors') {
message.reply('Rock, Paper, Scissors, Shoot! I got scissors. You lost!')
}
else if (choice === 'paper' && bchoice == 'rock') {
message.reply('Rock, Paper, Scissors, Shoot! I got rock. You lost!')
}
else if (choice == 'rock' && bchoice == 'paper') {
message.reply('Rock, Paper, Scissors, Shoot! I got paper. You lost!')
}
else if (choice == 'rock' && bchoice == 'scissors') {
message.reply('Rock, Paper, Scissors, Shoot! I got scissors. You win!')
}
else if (choice == bchoice) {
message.reply('Rock, Paper, Scissors, Shoot! I got '+bchoice+'. It is a tie!')
}
}
else if (message.content === prefix+'killbot') {
if (message.author.id != owner) return message.reply('only bot dev do');
message.reply('Aight, Ima head out.').then(client.destroy())
.then(process.exit())

}
}
}
else if (message.content.startsWith(prefix+'prune')) {
let pA = parseInt(args[1])
if (!message.member.hasPermission('MANAGE_MESSAGES')) return message.reply('You need the permission MANAGE_MESSAGES run this command!')
if (!message.guild.me.hasPermission('MANAGE_MESSAGES')) return message.reply('I need permission MANAGE_MESSAGES to run this command!')
if (!pA) return message.reply('Please enter the number of messages to delete!')
if (pA <= 1) return message.reply('Please enter an amount higher than 1 message to delete!')
if (pA > 100) message.reply('Please enter an amount less than 100 messags to delete!')
message.channel.bulkDelete(pA).then(() => {
message.channel.send(Deleted ${pA} messages.).then(msg => msg.delete(3000));
});

}

})
//below guild member add
client.on('guildMemberAdd', async member => {
console.log('1')
let roleName = await keyv.get(${member.guild.id}.joinrole)
let roleob = member.guild.roles.find(r => r.name == roleName)
console.log(roleob)
if (roleob) {
member.addRole(roleob)
}

//above adds role
console.log('2')

//above dm user

//below sends message in channel
console.log('3')

})

client.on('guildMemberAdd', async member => {
let msgCon = await keyv.get(${member.guild.id}.joinmsg)
console.log(msgCon)
if (msgCon.toLowerCase()+'' != 'none' || ''+msgcon != 'undefined') {
member.send(msgCon);
}

})

client.on('guildMemberAdd', async member => {
let channelName = await keyv.get(${member.guild.id}.welcomeChannel)
if (!channelName) return;
let x = channelName.slice(2).split('>')[0]
console.log('4')
console.log(channelName)
console.log('5')
const channel = member.guild.channels.find(c => c.id === x)
console.log('6')
if (''+channel.name.toLowerCase() == 'undefined' ||''+channel.name.toLowerCase() == 'none') return
console.log('7')
if (channel) {
console.log('8')//message.reply(We couldn't log the infraction in a channel, as it doesn't exist! (If you want to remove logging, change the logchannel setting to none!));
let welcomeEmbed = new Discord.RichEmbed()
.setTitle(Welcome ${member.user.username}!)
.setDescription(You are member #${member.guild.memberCount}.)
channel.send(welcomeEmbed)
}
else if (!channel) {
await keyv.set(${message.guild.id}.welcomeChannel, 'None')
}

})

//below music bot
client.on('message', async message => {
if (message.author.bot) return
let args = message.content.split(' ')
/if (message.content.startsWith(prefix+'play')) {
const streamOptions = { seek: 0, volume: 1 };
let video = args[1]
message.member.voiceChannel.join().then(connection => {
const stream = ytdl(args[1], { filter : 'audioonly' });
const dispatcher = connection.playStream(stream, streamOptions);
})
.catch(console.error);
}
/
})
//above music bot

//THE FOLLOWING LISTENER IS FOR UPVOTED REQ COMMANDS ONL

client.login(process.env.TOKEN);