#development
1 messages ยท Page 906 of 1
-_-
@earnest phoenix client.on("ready", () => { console.log("Bot was logged in"); // Output a message to the logs. });
you
use this maybe
U miss understand me
@earnest phoenix The ready event doesnt send messages like that, you have to define the channel you're going to send it to..
@tardy estuary yes
the message.channel.send() function is only for the on.message event
message.channel.send()
you have to define channel
ok
@tardy estuary yes
@surreal notch then yes. I believe your issue lies in that if statement. you are returning and any code after that will not execute
dont forget to use await
what ?
@shut inlet repl.it/languages/nodejs
return message.channel.send(`You caught robbing a bank and paid a fine of 30 coins`) db.subtract(`cdata_${message.author.id}`, 30) }
So i have to remove return from here ?@tardy estuary
@magic jackal can i use guild.createInvite() ???
Try it out and see if it does what you want it to do. What do you think that return message.channel.send is actually doing? @surreal notch
@earnest phoenix ok, when do you want to create an invite for that guild??
when a user uses a command?
@tardy estuary yes it is subtracting money but these 2 messages came along and i don't need 2 one
cuz i want to join the server that my bot in
for every server?
Is there are any way to join server that my bot in
yes, but thats not a good idea
you don't
you want someone to invite your bot to their server, then you create an invite link uninvited and join their server
@surreal notch you are close. think about it logically. what should happen? you get caught robbing a bank, need to pay a fine, and then what should happen next (in the code)?
@turbid bough No u miss understand
@turbid bough How i can see servers that my bot in ?
that could work. or you could just return after sending that message
lemme try
@viral spade this sounds similar to your issue https://dba.stackexchange.com/questions/185968/mysql-simple-update-is-very-slow
also, is your database indexed? what indexes do you have?
im also reading a few posts saying that InnoDB needs some tweaks for good write performance
help mee
Client.Guilds
how i can see servers that my bot in
or something like that
client.guilds.createInvite ??
@tardy estuary yup return worked thanks for your guidance
you do not need to create an invite to see which server your bots are in
you already have a list of bots right there
client.guilds
so i just console.log(client.guild) ??
probably yeah
ok let me try
client.guild.cache
plural
@tardy estuary I think i messed up
That return is not working
or where I supposed to put return
@tardy estuary
I have putted there
definetly not there
@turbid bough Oh it woek
i mean it will 50% work
work
Create string, for loop the guilds and add the client.guilds[i].name onto that string
@surreal notch send the message and then return. keep it inside the if (answer === 0)
ok
putting it there means you will return and now never hit the code below the return statement ever
but how can i put inside if (answer === 0)
if (return answer === 0)
i think its wrong

@tardy estuary
^_^
client.guilds.cache[i].name?
@surreal notch do you know what the keyword return means?
string += clients.guilds.cache[i].name
oh
Umm.....maybe or not@tardy estuary
and then console.log(string) ??
yeah
@surreal notch look up what a return statement means/does. It's a fundamental programming keyword.
nah name is undefiend
I think return statment means the code will not work
Below return
@tardy estuary
made to cache[i]
idk where to put it
what are you trying to do?
Can you send your code snippet?
So iterate through the array the guilds return using a forEach or something sorry I should provide examples but I don't wanna spoonfeed
you're using discord.js, right?
yes
do you know what are properties?
@surreal notch return terminates execution. Basically code after the return statement wouldn't execute. You want that return statement to be the last thing to hit after doing your logic.
if (answer === 0) {
subtract 30 coins
send message
return
}
//more code here if you had the correct answer```
@quartz kindle ? i didnt get it
do you know what is a property?
@tardy estuary Okk
what the word property means
no
yes
good
LoL
so imagine an object like this
aha
ok
with the value 10
oh
oh
so ```js
let object = {a:10}
console.log(object.a) // will log 10
so i wanted to list value of object: name in client.guild
so now that you know what are properties, check this
here you can see all the properties of the client, in discord.js
ok
@surreal notch code?
if(cdata === 0) db.subtract(`cdata_${message.author.id}`, 30)
return
}
//more code here if you had the correct answer
message.channel.send(`You caught robbing a bank and paid a fine of 30 coins`)
db.subtract(`cdata_${message.author.id}`, 30)
}
var embed = new Discord.MessageEmbed().setColor("#FF4500").setTitle("**Redeem Coins**")
.setDescription(`You have found **${answer}** coins`)
db.add(`cdata_${message.author.id}`, answer)
message.channel.send(embed)
}
)```
I think i have done correct
you want to list guilds, right? so do you see that the client has a guilds property?
yes
that means you can do client.guilds
so console.log(client.guilds)
but
go to the docs
and click on guilds
it will show you what client.guilds actually is
All of the guilds the client is currently handling, mapped by their IDs - as long as sharding isn't being used, this will be every guild the bot is a member of
yes
go ahead and click on the guildManager to see what it can do
cache, cacheType, client
yes
yes
a Collection is like a big object
@surreal notch
if(answer === 0) {
db.subtract(`cdata_${message.author.id}`, 30)
return message.channel.send(`You caught robbing a bank and paid a fine of 30 coins`)
}```
this should do what you want it to do
aha
so now you know that you can do client.guilds.cache to get a big object of guilds
if you console.log this you will see
yes i saw it
now, you need to refine this object to get only the names
yes
so go ahead and click on collection, to see what you can do with it
you can do a lot of things with a collection
but the best one for you is this one
ok
@tardy estuary ```if(answer === 0) {
db.subtract(cdata_${message.author.id}, 30)
return message.channel.send(You caught robbing a bank and paid a fine of 30 coins)
}
//more code here if you had the correct answer
message.channel.send(You caught robbing a bank and paid a fine of 30 coins)
db.subtract(cdata_${message.author.id}, 30)
}
var embed = new Discord.MessageEmbed().setColor("#FF4500").setTitle("**Redeem Coins**")
.setDescription(`You have found **${answer}** coins`)
db.add(`cdata_${message.author.id}`, answer)
message.channel.send(embed)
}
)```
But if correct ans is not working
so you see the example: collection.map(user => user.tag)
I applied to get my discord bot approved, but since then I cannot activate the bot because the token has changed since I have to know how to stop the token changing every minute.
yes
pls help
ok
so you do client.guilds.cache.map()
@quartz kindle pls help bro I applied to get my discord bot approved, but since then I cannot activate the bot because the token has changed since I have to know how to stop the token changing every minute.
no, like in the example
??
client.guilds.cache.map(name => ???)
when a shard disconnects what is recommended for you to do
@pale peak it doesnt matter if the token changes, the important part of it doesnt change if you dont explicitly regenerate it, you can keep using it
@earnest phoenix no, instead of user, you put guild
Or u publish it
.map(guild => )
@tardy estuary ?
it will map them to an array of guild names
nvm
like this
[name1,name2,name3]
Tim I had created 2 times before but now I am changing the token without stopping + I sent a message to verify this bot. Waiting for a return.
oh ok
@quartz kindle YOU ARE THE BEST TEACHER
THX you
:))
@pale peak Maybe you posted it comewhere
some*
nvm google sucks at answering discord questions
so yeah what should you do when a shard disconnects?
@grizzled raven what is the reason for disconnect?
exit the process?
no discord I took my ID card because it came out
Bruh here is the sipport server
in discord.js or a different lib?
@pale peak Maybe u posted it on github
@surreal notch go back to the original code you first posted and swap the return statement to be the last line of code in the conditional if(answer === 0) and you should have it working as expected
if you mean the shardDisconnect event, it should never fire
@pale peak idk
but if it does, i guess exit the process and restart
@pale peak the token is made of two parts, a key and a time
only the time changes, the key doesnt change
so your token will still work because they key part is still the same, only the time part changed
unless you regenerate it
new token is created every minute
@quartz kindle maybe i use v11 so it said cannot read propertire of map()
you use v11?
do it 
@pale peak yes, notice that only the part after the dot changes, not the part before the dot
@earnest phoenix then you need to chose v11 in the docs
oh thx
only the part after the dot changes
good job
thx you verry much
@pale peak hf98hg0283hg0823j0823**.**8hr08h08h08h308h30t82h30t28h3t0
^ no change ^ ok to change
I don't want to change.
its ok to change
it doesnt stop working
even if it changes, the old token is still working
it will not stop working just because that part changed
don't you understand me, the last part changes constantly
stops working
now it is changing every 2 parts I'm about to go crazy
??
no I did not receive any email
hi, i have my custom command bit set up, and now how do i send the message to the channel with eris?
@pale peak then it should not stop working. if your token is reset and stops working, they send you an email
your token has to work. it changes for me too and mine works
let a = guild.commands.find((e) => message.content === e.name);
if (a) {
message.channel.createMessage(a.response);
console.log('aa');
}
``` i am currently using that to send the message but nothing gets sent + gets logged (`aa`)
with open("tools.json", 'r') as a:
owo = json.load(a)
for x in owo.keys():
x = owo[x]
try:
buy = x.["buyprice"]
sell = x["sellprice"]
x["prices"] = {"buy": buy, "sell": sell}
del x["buyprice"]
except Exception as e:
print(e)
pass
json.dump(owo, open("fish.json", 'w'), indent=2)
this isn't editing the json
x.["buyprice"]
I mean my pylint is saying that json isnt even a thing so 
import json ez
I did
json is imported
Your pylint is gay
const translate = require("@vitalets/google-translate-api")
if(message.content.startsWith(prefix + 'translate')){
let translated = translate(text:`${args[0]}`, opts:{to: "es", raw: true})
message.channel.send(translated)
}``` unexpected token :
shouldn't it be text = not text:
does py pass objects/dicts as reference?
wdym
you give owo[x] to x then edit it, and save owo. does the edited x reflect in owo, or is owo copied to x?
no
It's a separate object after you edit it
worked for me
so the changes you make to x reflect back in owo?
>>> a = 1
>>> b = a
>>> a is b
True
>>> b = 2
>>> a
1
>>> a is b
False
yes
I mean it worked for me, are you getting an error?
uhh
lemme give it one last try
w a i t w t f
vsc had it in my ssh folder when i was trying to edit locally

xD
const translate = require("google-translate-api")
if(message.content.startsWith(prefix + 'translate')){
let t = args.join(" ")
translate(args[0], {to: args[1]}).then(res => {
message.channel.send(res.text);
});
}```
how could i make it so i can translate more then one word
send the entire args after the command?
yeh
what?
you give it one argument
you are sending args[0]
presumably one word
i am assuming that is probably a single word
yeah
how
well im not entirely sure on your usage
orgianlly i was thinking of using args.join(" ") but that doesnt work
maybe you meant to send that t variable
then maybe let t = args.shift.join(" ")
args.shift().join(" ")?
shift is gonna return the first element of the array
you're gonna have to ```
args.shift();
args.join(" ");
yeah thats true
also what is args
Are you able to put user mentions in an embed? (discord.js)
It didnโt seem to work for me
let messageArray = message.content.split(" ");
let cmd = messageArray[0];
let args = messageArray.slice(1);```
nice, what happens when you translate with t
isnt message.content the string?
can someone help?
`break;
^^^^^
SyntaxError: Illegal break statement
at wrapSafe (internal/modules/cjs/loader.js:1050:16)
at Module._compile (internal/modules/cjs/loader.js:1098:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
at Module.load (internal/modules/cjs/loader.js:983:32)
at Function.Module._load (internal/modules/cjs/loader.js:891:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.jim getting a iLEGAL brAke SyStEM and my code is client.on("message", (message) => {
let args = message.content.substring(prefix.length).split(" ");
switch (args[0]) {
case "hello":
}
message.channel.send("hi");
break;
});`
why are you switching?
me?
i suspect you could just do
let args = messageArray.join(" ");
thats not how you use a switch block
and then send args?
its outsite the switch
who are you talking to?
who do u think
u obviously
put the message send and break in the switch instead of outside it
i dont understand why you are switching on a hello command
my command is just a test
your break is in the wrong spot
put the message send and break in the switch instead of outside it
yeah
And don't split args with .split(" ")
@queen needle any luck?
honestly i just got rid of the command because i didn't know why i was even making it
haha gotcha
yeah lol
well thats pathetic
i am pathetic
Who knows why the code gives me this error?
exports.run = async (client, message, args, ops) => {
if (!message.member.voice.channel) return message.reply("You need to be in a voice channel, first!");
if (!args[0]) return message.reply("Please search or input an url following the command!");
let validate = await ytdl.validateURL(args[0]);
if (!validate) {
let commandFile = require("./search.js");
commandFile.run(client, message, args, ops);
};
let info = await ytdl.getInfo(args[0]);
let data = ops.active.get(message.guild.id) || {};
if(!data.connection) data.connection = await message.member.voice.channel.join();
if(!data.queue) data.queue = [];
data.guildID = message.guild.id;
data.queue.push({
songTitle: info.title,
requester: message.author.tag,
url: args[0],
announceChannel: message.channel.id
});
if(!data.dispatcher) play(client, ops, data);
else {
message.channel.send(`Added to queue: **${info.title}** | Requested by **<@${message.author.id}>**`);
}
ops.active.set(message.guild.id, data);
}
async function play(client, ops, data) {
client.channels.cache.get(data.queue[0].announceChannel).send(`Now Playing **${data.queue[0].songTitle}** | Requested by ${data.queue[0].requester}`);
data.dispatcher = await data.connection.play(ytdl(data.queue[0].url, { type: 'opus' }));
data.dispatcher.setVolume(40/100);
data.dispatcher.guildID = data.guildID;
data.dispatcher.once('finish', function() {
finish(client, ops, this);
});
}
whats the error?
do you know what a youtube video id is
ur not getting the actual proper id of a video
thats what it means
learn to read and u would know that
Doesn't this do other thing if it isn't validated?
yeah
and trying to use args as the video id which doesnt work
u have to search up properly
maybe assume the first result is what u want then get the id from that
read ytdl docs to see how u can search for top x of whatever someone puts
ok
does anyone know why new Date().toLocaleTimeString().slice(0, 5); would be null? the error log says it's null and I just can't figure out why,
this is what I'm trying to do
document.getElementById('start_time').value = new Date().toLocaleTimeString().slice(0, 4); // the date looks like this when sliced 14:56
wait
nvm
its not null
I just wasn't reading the error properly
hello there

function.bind
function.b
ur not using a function
thing(meme => meme.dank === "yes")
sam what

message.mentions.channels.first() || message.guild.channels.cache.get(args[0]) || message.guild.channels.cache.find('name', args[0]);
cyber go away
where is wrong
message.guild.channels.cache.find('name', args[0]);
``` this one?
i dont understand why the cache keyword was even added

cuz its ur cache
@turbid bough to make it more obvious that its a cache

for me it just looks like it just adds more useless words to write

also, why is it very important to make sure that they know it is cached or not?
like, you could have specified it in the documentations lol
@quartz kindle your database will never bottleneck you if you use it correctly, considering its designed to handle millions of operations per second
So i shouldnt need any database sharding for any purposes of my statistics bot, kinda forever? But then i am doing something wrong with my remote database..
When f.e. i have to reset the stats of all guildmembers of a guild, i set all the ([channel,user,values]) records to their defaults for the 4 statistics tables. This takes about half a minute for my remote mysql server. During that time it is at max capacity and wont answer other requests.
This works now, with only a few resets from time to time, but this cannot work anymore with 10x the servers..
there is a primary key on [guildid,userid,channelid]
d.js library v11.6.4
I can await inside a promise to return another promise correct? without the first one being fully executed until the 2nd one has had it's await completed
rip
when i restart my bot, the prefix is โโreset
oh?

Obviously that's going to happen if you're storing it in memory
using endb
normally there was no such problem
this problem arose when i upgraded to v12.
i guess there is no problem in command handler

oh, im gonna die
is there a way in C# to see which operation (in ms) takes the most time to process?
like, function to function
or i mean, see a part of the function which takes the most time
ah i think i might have found it out
would the role that's in the line of code underlined with green be accessed properly from the one with blue underline as it will be a nested promise?
@hollow prawn if it's in the same scope and there's no other variable or parameter with that name, yes.
thank
@tight forum what is bot.prefixes


i just choked really hard on that large brain of yours @tight forum
your profile picture literally describes you rn

ok ok, imma stop b4 i push it too far
hey im crying
wow
How is this wrong? ```(node:11041) UnhandledPromiseRejectionWarning: TypeError: message.guild.members.get is not a function
code:
``` message.guild.members.get(message.author.id).addRole(message.guild.roles.find("name", 'Moderator'))```
did i do that wrong?
Hey, so im still having a bit of trouble with EF Core, but im trying to do with Owned types, but i seem to only get this error:
42703: column d0.server_statistics_commands_used does not exist
the example im trying to follow is: https://docs.microsoft.com/en-us/ef/core/modeling/owned-entities
I cant for the life of my figure out where my SQL error is.
Im getting a ER_PARSE_ERROR
sql:
UPDATE settings WHERE `id` = '569907007465848842' SET `music` = true, `welcome` = false, `moderation` = true, `fun` = true, `custom` = false, `golive` = false, `help` = true, `welcome_message` = ':wave: | Welcome. ${member} to the server', `welcome_channel` = '', `prefix` = '%'`
error message if it helps: near 'WHERE `id` = '569907007465848842' SET `music` = true, `welcome` = false, `modera' at line 1"
nvrm i switched set and where
there is no prefixes.db
@tight forum created it
still not working

ok know
i really need help
@clear wraith what version of Discord.js are you using? or, are you using a different library?
not due to the lack of prefixes.db file
v12 @sudden geyser
use cache
guild.members is a manger in v12.
message.guild.members.cache.get()??
There's a property called .cache which has the cache of the guild members
try it out and see
^
or... replace cache with guild?
it's in the docs
const mss = require('ms');
if(message.content.startsWith(prefix + 'ga')){
if(!args[0]) return message.channel.send(`You did not specify your time!`)
if(!args[0].endsWith("d")&&!args[0].endsWith("h")&&!args[0].endsWith("m")) return message.channel.send(`You did not use the correct formatting for the time!`)
if(isNaN(args[0][0])) return message.channel.send(`That is not a number!`)
let channel = message.mentions.channels.first()
if(!channel) return message.channel.send(`I could not find that channel in the guild!`)
let prize = args.slice(2).join(" ")
if(!prize) return message.channel.send(`No prize specified!`)
message.channel.send(`*Giveaway created in ${channel}*`)
.then( message.channel.send(
new Discord.RichEmbed()
.setTitle("New giveaway!")
.setColor("#FF0000")
.setDescription(`The user ${message.author} is hosting a giveaway for **${prize}**`)
.setTimestamp(Date.now()+mss(args[0]))
)
).then(msg =>{
msg.react("๐")
setTimeout(() => {
if(msg.reactions.get("๐").count<=1){
message.channel.send(`Reactions: ${msg.reactions.get("๐").count}`)
return message.channel.send(`Not enough people reacted for me to start draw a winner!`)
}
let winner = msg.reactions.get("๐").usersFilter(u=>!u.bot).random()
channel.send(`The winner of the giveaway for **${prize}** is... ${winner}`)
}, mss(args[0]));
})
}
``` it reacts to the message saying where the giveaway is being held not what the giveaway is
Ive been looking in the docs, but no luck
you sure args[0][0] is a thing.
@clear wraith you were correct the first time: https://discord.js.org/#/docs/main/stable/class/GuildMemberManager?scrollTo=cache
i need someone who knows endb...
if i dont have args[0][0] then when i do 5m or whatever it says its not a number
oh so you're accessing the first character in a string.
It didn't work
because now it says there is something wrong with this:
TypeError: message.guild.roles.find is not a function
Ill get the code too
.addRole(message.guild.roles.find("name", 'Moderator'))
I can't find a fix for that in the docs
what verison
v12
you need to add cache i believe
collection.find('property', value) has been removed entirely, and collection.find() only accepts a function in v12.
- client.users.find('username', 'Bob');
+ client.users.cache.find(user => user.username === 'Bob');
#Collection#findAll
collection.findAll() was removed entirely as it just duplicated collection.filterArray()'s results.```
If this helps
let questions = [
{
title: "Best programming language",
options: ["JavaScript/TypeScript", "Python", "Ruby", "Rust"],
correct: 1
},
{
title: "Best NPM package",
options: ["int.engine", "ms", "ws", "discord.js"],
correct: 3
}
];
if (message.content.startsWith(prefix + "trivia")) {
let q = questions[Math.floor(Math.random() * questions.length)];
let i = 0;
message.channel.send(
new Discord.RichEmbed()
.setTitle(q.title)
.setDescription(
q.options.map(opt => {
i++;
return `${i} - ${opt}\n`;
})
)
.setColor("#FF0000")
.setFooter(
`Reply to this message with the correct question number! You have 15 seconds.`
)
);
try {
let msgs = await message.channel.awaitMessages(
u2 => u2.author.id === message.author.id,
{ time: 15000, max: 1, errors: ["time"] }
);
if (parseInt(msgs.first().content) == q.correct) {
return message.channel.send(`You got it correct!`);
} else {
return message.channel.send(`You got it incorrect.`);
}
} catch (e) {
return message.channel.send(`You did not answer!`);
}
}``` it instantly says that i did not answer

What's the error there @queen needle ? Maybe print out the error in the catch to see what it is
checking right now
Might be bounding issue with questions.length
bot.on("message", async message => {
let botprefix = require("./botprefix.json");
const prefix = await bot.prefixes.get(message.guild.id) || botprefix.prefix;
if (message.author.bot || message.channel.type === 'dm') return;
const args = message.content.slice(prefix.length).split(' ');
if (!message.content.startsWith(prefix)) return;
const command = args.shift().toLowerCase();
const commandfile = bot.commands.get(command);
if (commandfile) commandfile.run(bot, message, args);
});
This is my command handler guyz
and this is setprefix.js
module.exports.run = async (bot, message, args, func) => {
if (!message.member.hasPermission('ADMINISTRATOR')) return message.channel.send('Yรถnetici yetkisine sahip deฤilsin.');
if (!args[0]) return message.channel.send("โ | รnce istediฤin prefix'i belirtmelisin.\n" + "โ
| Doฤru kullanฤฑm: `prefix <prefix>`");
let prefix = bot.prefixes.get(message.guild.id);
if (args[0] === "sฤฑfฤฑrla") {
if (!prefix) {
return message.channel.send(`โ | Sunucunuzda herhangi bir ayarlฤฑ prefix bulunmamakta.`);
} else if (prefix) {
bot.prefixes.delete(message.guild.id);
return message.channel.send("โ
| Prefix baลarฤฑyla sฤฑfฤฑrlandฤฑ. Mevcut prefix `l!`");
}
}
await bot.prefixes.set(message.guild.id, args[0]);
return message.channel.send(`โ
| Prefix baลarฤฑyla \`${args[0]}\` olarak ayarlandฤฑ, sฤฑfฤฑrlamak istersen \`${args[0]}prefix sฤฑfฤฑrla\` komutunu kullanabilirsin.`);
};
i have a file prefixes.db
Ok, so
but its not saving prefix
when i set the prefix everything ok but
when i restart the bot prefix is reset.
hmm
my real bot is in a different verison though
I need game code x o
game code? Elaborate please
Means a game
I have a saliva bot and I need this game
@earnest phoenix
@earnest phoenix i said you can ask for help with your code in this channel, but nobody is going to give you code to make it
you'll have to write it yourself
ok

https://discordapp.com/channels/264445053596991498/272764566411149314/706649838091108383 w8ing for your help...
@tight forum like I said, what is bot.prefixes?
How do i send the guild avatar on an author in embed?
bot.prefixes = new Endb('prefixes.db', { adapter: 'sqlite' });
is it not icon_url (unicode)?
libtool is required, but wasn't found on this system
Makefile:61: recipe for target 'libsodium' failed
make: *** [libsodium] Error 1
/home/tony/testboat/node_modules/sodium/install.js:293
throw new Error(cmdLine + ' exited with code ' + code);
^
Error: make libsodium exited with code 2
at ChildProcess.<anonymous> (/home/tony/testboat/node_modules/sodium/install.js:293:19)
at ChildProcess.emit (events.js:310:20)
at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)```
running into this when trying to `npm install sodium`
doesn't really say much other than to use --unsafe-perm?
@tight forum are you sure a second argument for new Endb is accepted? It seems to only be the first argument (https://endb.js.org/?api=endb). I don't know anything on that library so I'm just going off its documentation.
ok issue was i had to install libtool
yeah but the first argument was the db path
Well that was kinda of what it was saying

ยฏ_(ใ)_/ยฏ
On one hand I felt like asking but I sorta thought you'd have probably tried that already
i thought it was gonna install by itself
@tight forum also
Also had an issue on Deeping where it told me a package wasn't installed that was installed got into some dependency hell and finally fixed it by just grabbing newer versions ยฏ_(ใ)_/ยฏ
Sometimes certain packages need manual installation at least from my experience
making music bots is fun
if i add await to the places you specified, will the problem be corrected?
normally had no such problem. I encountered such a problem when I updated all my packages
@sudden geyser you're right, its string or options
@tight forum new Endb(URL OR OPTIONS) not both

i reviewed the endb doc, but I couldn't see anything to change
oh let me change it
okay now i'm running into more opus issues
https://hasteb.in/ahohubah.js if anyone wants to take a look
want there a few issues about this in the discordjs/opus repo?
not that i know of
can't see any
this is the error specific to it though
Require stack:
- /home/tony/testboat/node_modules/@discordjs/opus/lib/index.js
- /home/tony/testboat/node_modules/prism-media/src/util/loader.js
- /home/tony/testboat/node_modules/prism-media/src/opus/Opus.js
- /home/tony/testboat/node_modules/prism-media/src/opus/index.js
- /home/tony/testboat/node_modules/prism-media/src/index.js
- /home/tony/testboat/node_modules/discord.js/src/client/voice/player/BasePlayer.js
- /home/tony/testboat/node_modules/discord.js/src/client/voice/player/BroadcastAudioPlayer.js
- /home/tony/testboat/node_modules/discord.js/src/client/voice/VoiceBroadcast.js
- /home/tony/testboat/node_modules/discord.js/src/client/voice/ClientVoiceManager.js
- /home/tony/testboat/node_modules/discord.js/src/client/Client.js
- /home/tony/testboat/node_modules/discord.js/src/index.js
- /home/tony/testboat/index.js```
considering they've all been closed, what's the point
i can just install node-opus and get past the depreciated warning
is there an option to build from source?
const Endb = require('endb');
const bot.prefixes = new Endb('sqlite://Lemniscate V2/prefixes.sqlite');
it seems like its trying to use a prebuilt version
it should accept relative paths, so just sqlite://prefixes.sqlite
node-opus works for now anyways
but i don't think there's any build from source option
what happens if you do npm rebuild?
lemme try
it errors
> @discordjs/opus@0.3.1 install /home/tony/testboat/node_modules/@discordjs/opus
> node-pre-gyp install --fallback-to-build
sh: 1: node-pre-gyp: not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! @discordjs/opus@0.3.1 install: `node-pre-gyp install --fallback-to-build`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the @discordjs/opus@0.3.1 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/tony/.npm/_logs/2020-05-04T00_20_16_989Z-debug.log
$```
really lmao
thats the point of --fallback-to-build if you're gonna throw if node-pre-gyp is not found
that's their error or mine? ยฏ_(ใ)_/ยฏ
it says Identifier 'bot' has already been declared with ```js
const bot.prefixes = new Endb('sqlite://Lemniscate V2/prefixes.sqlite');
if I change the part that says bot.prefixes, I need to change the bot.prefixes section in this command handler, right?
theirs i guess
no const
i mean idk, try installing node-pre-gyp
through npm or apt-get?
npm
https://discordapp.com/channels/264445053596991498/272764566411149314/706649838091108383 right there my command handler
node-pre-gyp is like a downloader for prebuilt binaries, but it should be a dev dependency, not a user devenpency, idk
btw what version of node.js are you on?
its not v14 so there should be a prebuilt binary for it
btw this should have been fixed 9 hours ago?
Lol
sigh
anyways that didn't fix the lib installing that
looks like rebuild is working now
@quartz kindle seems like a proper rebuild worked
appreciate the help there
nice
do you have any experience with making music bots?
nope
discord.js i have a quote command but it can't quote attachments or embeds?
async function quote(msg) {
// Split the message into arguments
let content = msg.content.split(' ');
// Check if message id is supplied
if (content[1] == undefined) {
msg.reply('You need to suplly a message id');
return;
}
// Retrieve the message
let quotedMessage = await msg.channel.fetchMessage(content[1]);
// Parse the timestamp
let date = new Date(quotedMessage.createdTimestamp);
// Send the quote
msg.channel.send(`"${quotedMessage.content}" - ${quotedMessage.author}, ${date.getFullYear()}`);
}
if (message.content.startsWith(prefix + 'quote')) {
quote(message);
} ```
attachments and embeds are not in the content
message.embeds and message.attachments
if(message.embeds === true){
}```
would i have to use something along the liens of that
oh
should work
and i would just send it
if(quotedMessage.embeds.length > 0){
message.channel.send(quotedMessage)
}```
but then how would i send the embed
quotedMessage.embeds[0]
async function quote(msg) {
// Split the message into arguments
let content = msg.content.split(' ');
// Check if message id is supplied
if (content[1] == undefined) {
msg.reply('You need to suplly a message id');
return;
}
// Retrieve the message
let quotedMessage = await msg.channel.fetchMessage(content[1]);
// Parse the timestamp
let date = new Date(quotedMessage.createdTimestamp);
// Send the quote
msg.channel.send(`"${quotedMessage.content}" - ${quotedMessage.author}, ${date.getFullYear()}`);
if(quotedMessage.embeds.length > 0){
message.channel.send(quotedMessage.embeds[0])
}
}
if (message.content.startsWith(prefix + 'quote')) {
quote(message);
} ```
diesnt work
doesnt*
im anal but I woulda written if(quotedMessage.embeds.length)
not sure I haven't messed with that yet
Hey @quartz kindle thank you very much btw
r!help
-botcommands @jade shadow
@jade shadow
Hey! Bots aren't given permissions to send responses in this channel. Please use #commands or #265156322012561408 to run commands. In addition, bots with commonly used prefixes cannot read or send messages in any channel. This is done to prevent spam and bot abuse.
sorry
I hate it when people call functions 'commands' this isn't minecraft smh
Anyone know why my bot's not getting the shard ID correctly? I am using this
this.client.shard.broadcastEval(`this.user.setActivity('nHelp | https://noelbot.com | Shard ' + this.shard.id, { type: 'PLAYING' });`);
It sets the status but says shard is undefined
Also doing this.shard.ids makes it constantly change in the game from 0 and 1
how are you sharding
ShardingManager from discord.js
v12?
yep
not sure if there is a way to get shard id on v12 because <Client>.shard returns a ShardClientUtil, but that has no id property
don't take that as fact though, just what I see straight away
not sure if there is a way to get shard id on v12 because <Client>.shard returns a ShardClientUtil, but that has no id property
@amber fractal Strange, myclient shardhas the ID property of the shard, and I'm on v12
Shard id in v12 is a property of each guild
It got changed because of internal sharding
this.client.shard.broadcastEval(`this.user.setActivity('nHelp | https://noelbot.com | Shard ' + this.shard.client.guilds.cache.values().next().value.shardID, { type: 'PLAYING' });`);
Changed it to that,
^ which works.
Also, it's normal for the shard to continuously change for guilds even without restarting?
never mind, I am dumb
Thanks for the help tho
you tell me
debug your code
go through each closure
try catch for errors
inspect your variables
debug your own code
lmao
why is bot not work shows picture of bot not working how I fix bot not working
lol some of the things I see here are hilarious
@gilded plank
guys
how can i find a role
in v12
message.guild.roles.cache.find(rol => rol.name === args[0])
i think its not true
depends on what args[0] is.
what you showed is how you find a role by its name.
which is correct for v12.
ty
https://pastebin.com/JgZrgmP4
im trying to make a remind command but it is not working
no errors
help me someone
whats your problem?
-botcommands @gleaming glacier
@gleaming glacier
Hey! Bots aren't given permissions to send responses in this channel. Please use #commands or #265156322012561408 to run commands. In addition, bots with commonly used prefixes cannot read or send messages in any channel. This is done to prevent spam and bot abuse.
I can see it
From that json format
I want question I'd and correct option id
{"answers":[{"option_id":12986,"question_id":4331},{"option_id":16448,"question_id":5486},{"option_id":13535,"question_id":4514},{"option_id":14077,"question_id":4695},{"option_id":16518,"question_id":5509},{"option_id":14321,"question_id":4776}],"signature":"53A362A3090CEF9E6BA6EF6A1CB35DA3516DF351","timestamp":1588394634}
And send request in this format
@slender thistle
@slender thistle
Reply
You just have to wait @earnest phoenix, not ping mods for asking for help
Ok
What do you mean by "send request in this format"
I want a bit of help with javascript...
I am trying to set two timers with one starting at first and the second starting only if the first ended. I tried setting two timeouts but that didn't work, they just run at once.
Any help would be appreciated.
did you try
setTimeout(() => {
setTimeout(() => {
}, ms)
}, ms)
this will execute the 2nd timeout after the first is waited for
Sir @slender thistle
Can u check first json format
How it is
There are 10 question in order with 3 options with correct option
I want question I'd and correct option I'd of 10 question how can I get
{"answers":[{"option_id":12986,"question_id":4331},{"option_id":16448,"question_id":5486},{"option_id":13535,"question_id":4514},{"option_id":14077,"question_id":4695},{"option_id":16518,"question_id":5509},{"option_id":14321,"question_id":4776}]
I want in this format
Can u help @tardy estuary
@slender thistle sir reply
Look on Stackoverflow on how to loop through an array
@queen needle what about the file doesn't work? Did you try debugging it and finding out what doesn't work? The command file is kind of littered with flaws.
does anyone know why message.member.voice, message.member.voiceChannel and message.member.voice.channel come back undefined
here's code
are you in a voice channel
uhhhh no?
GuildMember doesn't have a voiceChannel property anyways, it'd be <GuildMember>.voice.channel (on v12)
also if you aren't in a voice channel it's empty as well
I would expect null over undefined though
were you in a voice channel when you tested it?
yea
I would expect it to say something
.voice itself is not undefined/null.
It's .voice.channel that may be null/undefined.
I use message.member.voice
try voice.channel
I tried voice.channel already
but I'll try it again
(node:11216) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'voice' of undefined
im on v12 should I try GuildMember.voice,channel?
member is undefined then, not voice
when it says it cannot read something of undefined that means the value before it is undefined
most likely a cache issue then
gonna try using my old play code
Was message.member undefined for you, because it can be undefined if not used in a guild (not sure about if the member is cached).
its most likely message.member
@earnest phoenix I don't really know what you want to do. I am assuming you want to loop through that array
should I use this execute command, it sure does seem to cause alot of problems
So I'm fucking around with a private mod bot and I want to make user notes. they would basically be an implementation of the client-side notes on discord, except they would be accessible by all moderators of the server. I'm using mongodb. The problem is, I'm not sure if I should just let mongo autogenerate an object id to index and ignore performance? or should I make the object ID literally the user id and the guild id eg, 102845358677176320-264445053596991498 and/or throw it in a sha-1 hash.
hello again
am I overcomplicating things? I'm a tad sleep deprived so my brain could be described as the smooth variety
I would normally just go with guildid-memberid when I do stuff like that
If you do it as 102845358677176320-264445053596991498 then that would take less time than computing a hash of it
but I never tested performance
how can i remove the reaction of the person who clicked on the reaction?
reaction.remove(reaction.users.last())
i wrote something like this but it didn't work
yea idk i might just do plaintext idk
When the command is triggered, check the ID of the user and if it doesn't match your ID then just don't do anything
hi guys, so how would I have the bot use my discord servers emojis like :Dogbot : because if I do :Dogbot : (remove space) or <:dogbot : id> it dosent work
i saw a few stuff where you define
the server
then get the emoji
then use it
but the one i saw didnt work
You can try the emojis id
like :23578id : ?
it's <:emoji:id> or <a:emoji:id>
a: for gif emotes
how would I get the discord.js version so that I can put it as like in my stats command
personally
just parse package.json
parse fs.readfilesync on your package.json
then you can just access it from there
only thing
it will appear like
^12.2.0
or whatever your version is
so just replace ^ with v
some people would say require, but using fs is dynamic, so any changes made to package.json won't require a client restart
I doubt any changes would be made while the process is running
reading a file every time someone runs a stats command doesn't sound good to me
it takes like no time at all
i personally use it when i make changes to the codebase and update the version inside package.json
you also have to JSON.parse it
no, with require it's parsed once afaik
You wanna use require? Think again!
You can sometimes use require:
var obj = require('path/to/file.json');
But, I do not recommend this for several reasons:
require is synchronous. If you have a very big JSON file, it will choke your event loop. You really need to use JSON.parse with fs.readFile.
require will read the file only once. Subsequent calls to require for the same file will return a cached copy. Not a good idea if you want to read a .json file that is continuously updated. You could use a hack. But at this point, it's easier to simply use fs.
If your file does not have a .json extension, require will not treat the contents of the file as JSON.
stackoverflow
you can also just... read it once and store the response in memory
I don't think that a package.json will be updated frequently... not at all actually why would it get updated in runtime?
Also, you'd require the package.json before the client has logged in and then the contents of it will always stay cached so it won't choke the event loop. And package.json files aren't usually big
either way
imo fs is better practice
it does depend on the situation though
but for me, i update package.json during runtime whenever i modify anything and i want that to reflect inside my code
Are there any commands I want the music bot to play when I throw a link in the spotify?
Whats the fetchMembers alternative from d.js v11,5 to d.js v 12
members.fetch
Are you telling me?
@lofty grove the only way is probably by "reverse engineering" spotify client, and its illegal, so dont do it. (idk how groovy does it, someone said it fakes someway that its running on spotify client)
i dont think groovy does that
a simpler way is to just grab the metadata and look it up on yt or souncloud or whatever allows streaming
@lofty grove the only way is probably by "reverse engineering" spotify client, and its illegal, so dont do it. (idk how groovy does it, someone said it fakes someway that its running on spotify client)
@restive furnace I understood thank you.
@restive furnace groovy using youtube for playing spotify songs
With my bot music streams starts very glitchy and then become stable. How can I prevent the stream from starting in glitchy ways?
I'm using ytdl + discordjs v12
by using lavalink
Without lavalink
ah
I don't want to use it
try optimising the settings
embed_dict = {"1": original_embed, "2": page1}
flag = True
pn = 1
def check(reaction, user):
return user == ctx.author and (str(reaction) == "\U000027A1" or str(reaction) == "\U00002B05")
while flag:
try:
reaction, user = await client.wait_for("reaction_add", check=check)
except:
raise error
else:
if str(reaction) == "\U000027A1":
original_embed = embed_dict.get(pn + 1)
if original_embed:
await s.clear_reactions()
await s.edit(embed=original_embed)
await s.add_reaction('\U00002B05')
await s.add_reaction('\U000027A1')
pn += 1
elif str(reaction) == "\U00002B05":
original_embed = embed_dict.get(pn - 1)
if original_embed:
await s.clear_reactions()
await s.edit(embed=original_embed)
await s.add_reaction('\U00002B05')
await s.add_reaction('\U000027A1')
pn -= 1
else:
await s.delete()
flag = False
hey so i have this command
but its giving me an error saying name "error" is not defined
why?
the command is ment to send embeds with reactions that lead u to different pages
raise SomeExceptionHere
you are trying to raise an exception that doesn't exist
What do you want to do
Yeah
Though there's another way and you will get a full traceback
traceback.print_exception exists
so i change Exception with traceback...?
traceback is a module
type(error), error, and error.__traceback__ being the function's arguments where error is the exception
back
i know traceback is a module i've used it before
but not for this exact thing
Opinions on using puppeteer as an alternative for node-canvas?
wait which puppeteer? i can only find stuff about a headless chrome module
yeah, that
I'm testing it rn and well it can be used as an alternative but I am not sure if it'll be faster
how exactly is it an alternative to canvas? or is there something im not understanding
you can evaluate scripts inside the pages + set the page's HTML content, so you can do:
page = await browser.newPage();
await page.setContent('<html><body> <canvas id="can" height="500px" width="500px"> </canvas> </body></html>')
and then to make changes: page.evaluate("const context = window.can.getContext('2d'); ...")
so basically instead of drawing a line on a canvas, you're gonna load an entire browser, simulate an html dom, inject a canvas element, and draw a line on it?
yeah, I'm not saying it's more performant lol, but you can have multiple canvases inside 1 page
i thought you use puppeteer for something like web screenshot
i dont think its a viable alternative to node-canvas
its a completely different lib with a completely different purpose
what about jimp?
jimp is more like a replacement for graphicsmagick/imagemagick
ah ok
its not a drawing library, its an image compositing library
The status of the bot of someone I helped, is disappearing randomly sometimes. Using d.js v12
the status is only set after the client is ready, using client.user.setActivity()
just set an interval to update the status every 60 minutes
sometimes discord will just forget the presences
happens to me too
i think it disappears if discord disconnects and reconnects
that also causes it
but I also have it set to redo the presence on reconnect and that happens every now and then
so I just set an interval to make sure
on discord.js you can add the initial presence to your client options
so then that presence will always be used when connecting
thats what i do, and my status never disappears
oh okay thanks
where can I find options to use when doing new Discord.Client()?
not in the docs afaik
it is in the docs
How can I do that when someone on twitter posts a new tweet, that the bot sends a message in a channel.
twitter webhooks
i think twitter webhooks are compatible with discord, so you dont even need a bot
can you help me with the presence when the bot starts, those objects are confusing me
what do you have now?
like this:
const client = new Discord.Client({ presence: `help`, { type: 'WATCHING' } });```
but my eslint already says it's not correct
Isn't "presence" deprecated?
https://discord.js.org/#/docs/main/stable/typedef/ClientOptions it says presence here

