#development

1 messages ยท Page 906 of 1

shut inlet
earnest phoenix
#

-_-

surreal notch
#

@earnest phoenix client.on("ready", () => { console.log("Bot was logged in"); // Output a message to the logs. });

valid frigate
#

you

surreal notch
#

use this maybe

earnest phoenix
#

U miss understand me

magic jackal
#

@earnest phoenix The ready event doesnt send messages like that, you have to define the channel you're going to send it to..

surreal notch
#

@tardy estuary yes

magic jackal
#

the message.channel.send() function is only for the on.message event

shut inlet
#

message.channel.send()

magic jackal
#

you have to define channel

earnest phoenix
#

ok

tardy estuary
#

@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

earnest phoenix
#

wait can i use guild.createInvite

#

??

valid frigate
#

dont forget to use await

earnest phoenix
#

what ?

magic jackal
surreal notch
#

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

earnest phoenix
#

@magic jackal can i use guild.createInvite() ???

tardy estuary
#

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

turbid bough
#

@earnest phoenix ok, when do you want to create an invite for that guild??

#

when a user uses a command?

surreal notch
#

@tardy estuary yes it is subtracting money but these 2 messages came along and i don't need 2 one

earnest phoenix
#

yes

#

no

#

when the bot ready

turbid bough
#

why?

#

thats not allowed

earnest phoenix
#

cuz i want to join the server that my bot in

turbid bough
#

for every server?

earnest phoenix
#

Is there are any way to join server that my bot in

turbid bough
#

yes, but thats not a good idea

earnest phoenix
#

What is the another way ??

#

xD

turbid bough
#

you don't

earnest phoenix
#

?

#

i dont ?

turbid bough
#

you want someone to invite your bot to their server, then you create an invite link uninvited and join their server

tardy estuary
#

@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)?

surreal notch
#

Umm i think } else { may work

#

@tardy estuary

#

Umm i think } else { may work

earnest phoenix
#

@turbid bough No u miss understand

#

@turbid bough How i can see servers that my bot in ?

tardy estuary
#

that could work. or you could just return after sending that message

surreal notch
#

lemme try

earnest phoenix
#

?

#

oh tim

quartz kindle
#

@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

earnest phoenix
#

help mee

turbid bough
#

Client.Guilds

earnest phoenix
#

how i can see servers that my bot in

turbid bough
#

or something like that

earnest phoenix
#

client.guilds.createInvite ??

turbid bough
surreal notch
#

@tardy estuary yup return worked thanks for your guidance

turbid bough
#

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

earnest phoenix
#

what ?

#

where ?

turbid bough
#

client.guilds

earnest phoenix
#

so i just console.log(client.guild) ??

turbid bough
#

probably yeah

earnest phoenix
#

ok let me try

turbid bough
#

client.guild.cache

cinder patio
#

plural

surreal notch
#

@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

turbid bough
#

definetly not there

surreal notch
#

then

earnest phoenix
#

@turbid bough Oh it woek

turbid bough
#

i mean it will 50% work

earnest phoenix
#

work

surreal notch
#

but it is not working

#

@turbid bough

#

there

earnest phoenix
#

but how i can make a fillter

#

like display only name:"server"

turbid bough
#

Create string, for loop the guilds and add the client.guilds[i].name onto that string

tardy estuary
#

@surreal notch send the message and then return. keep it inside the if (answer === 0)

earnest phoenix
#

ok

tardy estuary
#

putting it there means you will return and now never hit the code below the return statement ever

surreal notch
#

but how can i put inside if (answer === 0)

#

if (return answer === 0)

#

i think its wrong

#

@tardy estuary

earnest phoenix
#

@turbid bough name is undefiened

#

-_-

surreal notch
#

^_^

turbid bough
#

client.guilds.cache[i].name?

earnest phoenix
#

wait u said create string ?

#

how

turbid bough
#

i think that how it works

#

var string = ""

tardy estuary
#

@surreal notch do you know what the keyword return means?

earnest phoenix
#

ok and ?

#

what it will help ?

turbid bough
#

string += clients.guilds.cache[i].name

earnest phoenix
#

oh

surreal notch
#

Umm.....maybe or not@tardy estuary

earnest phoenix
#

and then console.log(string) ??

turbid bough
#

yeah

tardy estuary
#

@surreal notch look up what a return statement means/does. It's a fundamental programming keyword.

earnest phoenix
#

nah name is undefiend

surreal notch
#

I think return statment means the code will not work

#

Below return

#

@tardy estuary

earnest phoenix
#

made to cache[i]

surreal notch
#

idk where to put it

earnest phoenix
#

and this is output Cannot read property '0' of undefined

#

@turbid bough ??

quartz kindle
#

what are you trying to do?

magic jackal
#

Can you send your code snippet?

earnest phoenix
#

Ahm i wanted to list server my biot in

#

bot*

#

@magic jackal me ??

magic jackal
#

So iterate through the array the guilds return using a forEach or something sorry I should provide examples but I don't wanna spoonfeed

earnest phoenix
#

how ? :((

#

i dont understand

quartz kindle
#

you're using discord.js, right?

earnest phoenix
#

yes

quartz kindle
#

do you know what are properties?

tardy estuary
#

@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```
earnest phoenix
#

@quartz kindle ? i didnt get it

quartz kindle
#

do you know what is a property?

surreal notch
#

@tardy estuary Okk

quartz kindle
#

what the word property means

earnest phoenix
#

no

quartz kindle
#

in javascript

#

do you know what is an object?

earnest phoenix
#

yes

quartz kindle
#

good

earnest phoenix
#

LoL

quartz kindle
#

so imagine an object like this

earnest phoenix
#

aha

quartz kindle
#

{a:10}

#

this object has a property "a"

earnest phoenix
#

ok

quartz kindle
#

with the value 10

earnest phoenix
#

oh

quartz kindle
#

a is a property of the object

#

and you can access it by using object.a

earnest phoenix
#

oh

quartz kindle
#

so ```js
let object = {a:10}
console.log(object.a) // will log 10

earnest phoenix
#

so i wanted to list value of object: name in client.guild

quartz kindle
#

so now that you know what are properties, check this

earnest phoenix
#

ok

#

check this ?

quartz kindle
surreal notch
#

@tardy estuary but they are not also working

#

:/

quartz kindle
#

here you can see all the properties of the client, in discord.js

earnest phoenix
#

ok

tardy estuary
#

@surreal notch code?

surreal notch
#
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
quartz kindle
#

you want to list guilds, right? so do you see that the client has a guilds property?

earnest phoenix
#

yes

quartz kindle
#

that means you can do client.guilds

earnest phoenix
#

so console.log(client.guilds)

quartz kindle
#

but

#

go to the docs

#

and click on guilds

#

it will show you what client.guilds actually is

earnest phoenix
#

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

quartz kindle
#

yes

#

and notice the type

#

that means client.guilds gives you a guildManager

earnest phoenix
#

yes

quartz kindle
#

go ahead and click on the guildManager to see what it can do

earnest phoenix
#

cache, cacheType, client

quartz kindle
#

yes

#

so where are the guilds?

#

here

earnest phoenix
#

yes

quartz kindle
#

you see that .cache has guilds

#

and the type is a Collection

earnest phoenix
#

yes

quartz kindle
#

a Collection is like a big object

tardy estuary
#

@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
earnest phoenix
#

aha

quartz kindle
#

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

earnest phoenix
#

yes i saw it

quartz kindle
#

now, you need to refine this object to get only the names

earnest phoenix
#

yes

quartz kindle
#

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

earnest phoenix
#

ok

surreal notch
#

@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

quartz kindle
#

so you see the example: collection.map(user => user.tag)

pale peak
#

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.

earnest phoenix
#

yes

pale peak
#

pls help

quartz kindle
#

so you can use this

#

your collection is client.guilds.cache

earnest phoenix
#

ok

quartz kindle
#

so you do client.guilds.cache.map()

pale peak
#

@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.

quartz kindle
#

and instead of user, you can put guild

#

and instead of tag, you can put name

earnest phoenix
#

client.guilds.cache.map(name)

#

?

quartz kindle
#

no, like in the example

pale peak
#

??

earnest phoenix
#

client.guilds.cache.map(name => ???)

grizzled raven
#

when a shard disconnects what is recommended for you to do

quartz kindle
#

@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

earnest phoenix
#

Or u publish it

quartz kindle
#

.map(guild => )

surreal notch
#

@tardy estuary ?

quartz kindle
#

and then instead of tag, you put name

earnest phoenix
#

oh

#

so it will log all of them or i must make a loop ?

quartz kindle
#

it will map them to an array of guild names

earnest phoenix
#

nvm

quartz kindle
#

like this

grizzled raven
#

h

#

okay then

quartz kindle
#

[name1,name2,name3]

pale peak
#

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.

earnest phoenix
#

oh ok

#

@quartz kindle YOU ARE THE BEST TEACHER

#

THX you

#

:))

#

@pale peak Maybe you posted it comewhere

#

some*

grizzled raven
#

nvm google sucks at answering discord questions

#

so yeah what should you do when a shard disconnects?

quartz kindle
#

@grizzled raven what is the reason for disconnect?

grizzled raven
#

exit the process?

pale peak
#

no discord I took my ID card because it came out

earnest phoenix
#

Bruh here is the sipport server

quartz kindle
#

in discord.js or a different lib?

grizzled raven
#

idk any reason

#

d.js

#

v12

earnest phoenix
#

@pale peak Maybe u posted it on github

pale peak
tardy estuary
#

@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

quartz kindle
#

if you mean the shardDisconnect event, it should never fire

earnest phoenix
#

@pale peak idk

quartz kindle
#

but if it does, i guess exit the process and restart

grizzled raven
#

hih

#

oh okay

#

thanks

quartz kindle
#

@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

pale peak
#

new token is created every minute

quartz kindle
#

its not

#

only the time part

#

not the key

earnest phoenix
#

@quartz kindle maybe i use v11 so it said cannot read propertire of map()

quartz kindle
#

you use v11?

pale peak
#

tim

magic jackal
#

do it XQC

earnest phoenix
#

Yes

#

all of my code are in v11

quartz kindle
#

@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

earnest phoenix
#

i dont want to update it :(( cuz there are many

#

How ?

quartz kindle
earnest phoenix
#

oh thx

quartz kindle
#

now go to client, and try again

#

?

pale peak
#

Yeah it's changing, I can't stop it already minutes

#

tim

quartz kindle
#

only the part after the dot changes

earnest phoenix
#

IT WORk

#

YEY

quartz kindle
#

good job

earnest phoenix
#

thx you verry much

pale peak
#

only the token part is changing

#

!

quartz kindle
#

@pale peak hf98hg0283hg0823j0823**.**8hr08h08h08h308h30t82h30t28h3t0
^ no change ^ ok to change

pale peak
#

I don't want to change.

quartz kindle
#

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

pale peak
#

don't you understand me, the last part changes constantly

quartz kindle
#

i understand you

#

but it doesnt stop working

pale peak
#

stops working

quartz kindle
#

it doesnt

#

it changes for me too

#

and my old token still works

pale peak
#

now it is changing every 2 parts I'm about to go crazy

quartz kindle
#

@_@

#

did you receive an email from discord?

#

wat

turbid bough
#

??

pale peak
#

no I did not receive any email

digital ibex
#

hi, i have my custom command bit set up, and now how do i send the message to the channel with eris?

quartz kindle
#

@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

digital ibex
#
    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`)
trim saddle
#

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

slender thistle
#

x.["buyprice"]

trim saddle
#

i edited that on discord

#

you know what it is

amber fractal
#

I mean my pylint is saying that json isnt even a thing so mmLol

slender thistle
#

import json ez

amber fractal
#

I did

trim saddle
#

json is imported

slender thistle
#

Your pylint is gay

queen needle
#
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 :
topaz fjord
#

shouldn't it be text = not text:

quartz kindle
#

does py pass objects/dicts as reference?

trim saddle
#

wdym

quartz kindle
#

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?

trim saddle
#

no

slender thistle
#

It's a separate object after you edit it

amber fractal
#

worked for me

trim saddle
#

owo is a static object

#

then json.dump saves it

quartz kindle
#

so the changes you make to x reflect back in owo?

slender thistle
#
>>> a = 1
>>> b = a
>>> a is b
True
>>> b = 2
>>> a
1
>>> a is b
False
trim saddle
#

yes

amber fractal
#

I mean it worked for me, are you getting an error?

trim saddle
#

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

amber fractal
quartz kindle
#

xD

trim saddle
#

even worse

#

it was in my wildcard folder

queen needle
#
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

tardy estuary
#

send the entire args after the command?

amber fractal
#

knowing google, probably paying money

#

and that

tardy estuary
#

yeh

queen needle
#

what?

amber fractal
#

you give it one argument

tardy estuary
#

you are sending args[0]

amber fractal
#

presumably one word

tardy estuary
#

i am assuming that is probably a single word

amber fractal
queen needle
#

yeah

tardy estuary
#

so send everything

#

to the translate api

queen needle
#

how

tardy estuary
#

well im not entirely sure on your usage

queen needle
#

orgianlly i was thinking of using args.join(" ") but that doesnt work

tardy estuary
#

maybe you meant to send that t variable

queen needle
#

if i send the t variable and do ^translate fish fish ja

#

it doesnt work

tardy estuary
#

then maybe let t = args.shift.join(" ")

tranquil drum
#

args.shift().join(" ")?

tardy estuary
#

yeh something like that.

#

basically remove the first word because you dont want it

tranquil drum
#

shift is gonna return the first element of the array

#

you're gonna have to ```
args.shift();
args.join(" ");

tardy estuary
#

yeah thats true

tranquil drum
#

also what is args

tacit stag
#

Are you able to put user mentions in an embed? (discord.js)

#

It didnโ€™t seem to work for me

queen needle
#
let messageArray = message.content.split(" ");
  let cmd = messageArray[0];
  let args = messageArray.slice(1);```
tranquil drum
#

nice, what happens when you translate with t

queen needle
tranquil drum
#

nothing happens?

#

or does it say fish back

tardy estuary
#

isnt message.content the string?

queen needle
#

it says fish back

#

if i say fish 2 times it says fish in ja

still merlin
#

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;
});`

queen needle
#

why are you switching?

still merlin
#

me?

tardy estuary
#

i suspect you could just do

let args = messageArray.join(" ");
knotty steeple
#

thats not how you use a switch block

tardy estuary
#

and then send args?

knotty steeple
#

its outsite the switch

still merlin
#

who are you talking to?

knotty steeple
#

who do u think

#

u obviously

#

put the message send and break in the switch instead of outside it

queen needle
#

i dont understand why you are switching on a hello command

still merlin
#

my command is just a test

knotty steeple
#

im not questioning their bullshit

#

anyway

#

do what i said

tardy estuary
#

your break is in the wrong spot

knotty steeple
#

put the message send and break in the switch instead of outside it

queen needle
#

yeah

white gyro
#

And don't split args with .split(" ")

tardy estuary
#

@queen needle any luck?

queen needle
#

honestly i just got rid of the command because i didn't know why i was even making it

tardy estuary
#

haha gotcha

queen needle
#

yeah lol

knotty steeple
#

well thats pathetic

queen needle
#

i am pathetic

frail sphinx
#

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);
  });
  
}
queen needle
#

whats the error?

knotty steeple
#

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

frail sphinx
knotty steeple
#

i dont know cuz i dont use ytdl

#

but seems as tho ur not searching properly

queen needle
#

yeah

knotty steeple
#

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

frail sphinx
#

ok

copper cradle
#

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

digital ibex
#

its not null

copper cradle
#

I just wasn't reading the error properly

tight forum
#

hello there

digital ibex
copper cradle
#

now I feel like a white name

#

๐Ÿ˜”

tight forum
#

i upgraded from v11 to v12, im still trying to learn new cmds

#

and got an error

digital ibex
#

there r no new commands

#

what

tight forum
#

i know

#

what is fn.bind

copper cradle
#

function.bind

digital ibex
#

function.b

knotty steeple
#

ur not using a function

tight forum
#

mmm

#
TypeError: fn.bind is not a function
knotty steeple
#
thing(meme => meme.dank === "yes")
mossy vine
#

sam what

tight forum
#
message.mentions.channels.first() || message.guild.channels.cache.get(args[0]) || message.guild.channels.cache.find('name', args[0]);
knotty steeple
#

cyber go away

tight forum
#

where is wrong

knotty steeple
#

yea there is the problem

#

the 3rd

tight forum
#
message.guild.channels.cache.find('name', args[0]);
``` this one?
knotty steeple
#

yes

#

ur not using a function

#

which is shown in my example

tight forum
#

im still trying to get used to the "cache" word

#

ok tyvm

turbid bough
#

i dont understand why the cache keyword was even added

tight forum
knotty steeple
#

cuz its ur cache

mossy vine
#

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

knotty steeple
turbid bough
#

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

tight forum
turbid bough
#

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

viral spade
#

@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]

hollow prawn
#

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

tight forum
#

hello again

#

there is a new problem with my damn bot

tardy estuary
#

rip

tight forum
#

when i restart my bot, the prefix is โ€‹โ€‹reset

queen needle
#

oh?

tight forum
split hazel
#

Obviously that's going to happen if you're storing it in memory

tight forum
#

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

turbid bough
#

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

hollow prawn
#

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?

sudden geyser
#

@hollow prawn if it's in the same scope and there's no other variable or parameter with that name, yes.

hollow prawn
#

thank

tight forum
#

ok now i'm dead cuz of my bot

#

still waiting for your help guys

sudden geyser
#

@tight forum what is bot.prefixes

tight forum
#

dude wait

#

there is no prefixes.db

#

forgot to create it

hollow prawn
tight forum
#

holy

sudden geyser
hollow prawn
#

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

tight forum
#

hey im crying

hollow prawn
#

i am too

queen needle
#

wow

tight forum
#

ive been working on the bot for one day

#

i cant feel my head

#

anyway

magic jackal
#

Idk what i should program now

#

im out of ideas

clear wraith
#

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?

turbid bough
slim heart
#

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

tight forum
#

there is no prefixes.db
@tight forum created it

#

still not working

#

ok know

#

i really need help

sudden geyser
#

@clear wraith what version of Discord.js are you using? or, are you using a different library?

tight forum
#

not due to the lack of prefixes.db file

clear wraith
#

v12 @sudden geyser

tight forum
#

use cache

clear wraith
#

use it where

#

wait

sudden geyser
#

guild.members is a manger in v12.

clear wraith
#

message.guild.members.cache.get()??

sudden geyser
#

There's a property called .cache which has the cache of the guild members

#

try it out and see

tight forum
#

^

clear wraith
#

or... replace cache with guild?

sudden geyser
#

it's in the docs

queen needle
#
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
clear wraith
#

Ive been looking in the docs, but no luck

tight forum
#

ups

#

wait

#

check it

sudden geyser
#

you sure args[0][0] is a thing.

tight forum
#

i need someone who knows endb...

clear wraith
#

Then what did i do wrong

#

or is it...

#

message.guild.members.cache.get()

sudden geyser
#

Yes

#

It says so in the docs.

queen needle
#

if i dont have args[0][0] then when i do 5m or whatever it says its not a number

sudden geyser
#

oh so you're accessing the first character in a string.

queen needle
#

yes

#

im using 11.5.3 also discord.js

clear wraith
#

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

queen needle
#

what verison

clear wraith
#

v12

queen needle
#

you need to add cache i believe

tardy estuary
#
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

tight forum
#

hey hey

#

me too need help ๐Ÿ˜ฆ

queen needle
#
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
clear wraith
#

message.guild.roles.find

#

so i need to add .cache to this?

tight forum
tardy estuary
#

What's the error there @queen needle ? Maybe print out the error in the catch to see what it is

queen needle
#

checking right now

tardy estuary
#

Might be bounding issue with questions.length

tight forum
#
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

clear wraith
#

Ok, so

tight forum
#

but its not saving prefix

#

when i set the prefix everything ok but

#

when i restart the bot prefix is reset.

queen needle
#

the command works on my test bot

#

but not on my real bot

clear wraith
#

hmm

queen needle
#

my real bot is in a different verison though

earnest phoenix
#

I need game code x o

#

game code? Elaborate please

#

Means a game

#

@earnest phoenix

oak cliff
#

@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

earnest phoenix
#

ok

tight forum
sudden geyser
#

@tight forum like I said, what is bot.prefixes?

wise quartz
#

How do i send the guild avatar on an author in embed?

tight forum
#

oh

#

w8

wise quartz
#

I tried ctx.guild.avatar_url

#

Didn't work

#

(Python)

tight forum
#
bot.prefixes = new Endb('prefixes.db', { adapter: 'sqlite' });
sudden geyser
#

is it not icon_url (unicode)?

wise quartz
#

Idk

#

I know the member one is avatar_url

#

But imma try icon_url

#

Ty

sick cloud
#
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`
delicate zephyr
sick cloud
#

doesn't really say much other than to use --unsafe-perm?

delicate zephyr
#

I mean

#

try it

#

seemed to work for them

sudden geyser
#

@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.

quartz kindle
#

adapter is listed as a client option

sick cloud
#

ok issue was i had to install libtool

sudden geyser
#

yeah but the first argument was the db path

weak parrot
#

Well that was kinda of what it was saying

tight forum
sick cloud
#

ยฏ_(ใƒ„)_/ยฏ

weak parrot
#

On one hand I felt like asking but I sorta thought you'd have probably tried that already

sick cloud
#

i thought it was gonna install by itself

quartz kindle
weak parrot
#

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

sick cloud
#

making music bots is fun

tight forum
#

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

quartz kindle
#

@sudden geyser you're right, its string or options

#

@tight forum new Endb(URL OR OPTIONS) not both

sudden geyser
tight forum
#

i reviewed the endb doc, but I couldn't see anything to change

quartz kindle
tight forum
#

oh let me change it

sick cloud
#

okay now i'm running into more opus issues

quartz kindle
#

want there a few issues about this in the discordjs/opus repo?

sick cloud
#

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```
quartz kindle
#

wanna add another one? xD

sick cloud
#

considering they've all been closed, what's the point

#

i can just install node-opus and get past the depreciated warning

quartz kindle
#

is there an option to build from source?

tight forum
#
const Endb = require('endb');
const bot.prefixes = new Endb('sqlite://Lemniscate V2/prefixes.sqlite');
quartz kindle
#

it seems like its trying to use a prebuilt version

tight forum
#

did i get it right?

#

i guess, didnt :/

quartz kindle
#

it should accept relative paths, so just sqlite://prefixes.sqlite

sick cloud
#

but i don't think there's any build from source option

quartz kindle
#

what happens if you do npm rebuild?

sick cloud
#

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
$```
quartz kindle
#

really lmao

#

thats the point of --fallback-to-build if you're gonna throw if node-pre-gyp is not found

sick cloud
#

that's their error or mine? ยฏ_(ใƒ„)_/ยฏ

tight forum
#

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?
quartz kindle
#

theirs i guess

sick cloud
#

no const

quartz kindle
#

i mean idk, try installing node-pre-gyp

sick cloud
#

through npm or apt-get?

quartz kindle
#

npm

tight forum
quartz kindle
#

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?

sick cloud
#

v12

#

12.16.3 to be specific

quartz kindle
#

its not v14 so there should be a prebuilt binary for it

#

btw this should have been fixed 9 hours ago?

#

Lol

sick cloud
#

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

quartz kindle
#

nice

sick cloud
#

do you have any experience with making music bots?

quartz kindle
#

nope

queen needle
#

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);  
   }  ```
sick cloud
#

pretty obvious why it can't

#

it only sends the content

quartz kindle
#

attachments and embeds are not in the content

queen needle
#

what are they in?

#

and how could i change it so it does read and sends those?

quartz kindle
#

message.embeds and message.attachments

sick cloud
#

well no

#

it'd be quotedMessage?

queen needle
#
if(message.embeds === true){

}```
#

would i have to use something along the liens of that

sick cloud
#

that's not gonna work even if you had message

#

check quotedMessage.embeds length

queen needle
#

oh

sick cloud
#

if its > 0

#

you have an embed

queen needle
#

so

#
if(quotedMessage.embeds.length > 0){
}
sick cloud
#

should work

queen needle
#

and i would just send it

#
if(quotedMessage.embeds.length > 0){
message.channel.send(quotedMessage)

}```
#

but then how would i send the embed

quartz kindle
#

quotedMessage.embeds[0]

queen needle
#
  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*

tardy estuary
#

im anal but I woulda written if(quotedMessage.embeds.length)

queen needle
#

lol

#

do you know how i could fix this so it works

tardy estuary
#

not sure I haven't messed with that yet

tight forum
#

Hey @quartz kindle thank you very much btw

jade shadow
#

r!help

pale vessel
split hazel
#

-botcommands @jade shadow

gilded plankBOT
#

@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.

jade shadow
#

sorry

copper cradle
#

I hate it when people call functions 'commands' this isn't minecraft smh

neat tinsel
#

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

amber fractal
#

how are you sharding

neat tinsel
#

ShardingManager from discord.js

amber fractal
#

v12?

neat tinsel
#

yep

amber fractal
#

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

neat tinsel
#

hmm

#

Seems a bit dumb them not having that imo

split hazel
#

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, my client shard has the ID property of the shard, and I'm on v12

amber fractal
#

this is what is returned with client.shard

smoky spire
#

Shard id in v12 is a property of each guild

#

It got changed because of internal sharding

neat tinsel
#
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

hallow heath
#

-sock @neat tinsel

#

H

neat tinsel
#

๐Ÿ˜•

#

confusion

clear wraith
#

Why is my bot saying this?

#

and what should i do to fix it

earnest phoenix
#

you tell me

#

debug your code

#

go through each closure

#

try catch for errors

#

inspect your variables

#

debug your own code

copper cradle
#

lmao

#

why is bot not work shows picture of bot not working how I fix bot not working

clear wraith
#

LOL

#

Im stupid

#

ik

gilded plankBOT
tardy estuary
#

lol some of the things I see here are hilarious

light wigeon
#

@gilded plank

tight forum
#

guys

#

how can i find a role

#

in v12

#
message.guild.roles.cache.find(rol => rol.name === args[0])

i think its not true

sudden geyser
#

depends on what args[0] is.

#

what you showed is how you find a role by its name.

#

which is correct for v12.

tight forum
#

typepeyay

queen needle
#
https://pastebin.com/JgZrgmP4
#

im trying to make a remind command but it is not working

#

no errors

edgy heron
#

help me someone

queen needle
#

whats your problem?

earnest phoenix
#

@slender thistle

#

Sir

slender thistle
#

-botcommands @gleaming glacier

gilded plankBOT
#

@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.

earnest phoenix
#

@slender thistle

#

See that ss

#

Sir

slender thistle
#

I can see it

earnest phoenix
#

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

slender thistle
#

What do you mean by "send request in this format"

earnest phoenix
#

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.

amber fractal
#

did you try

setTimeout(() => {
  setTimeout(() => {

  }, ms)
}, ms)
#

this will execute the 2nd timeout after the first is waited for

earnest phoenix
#

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

tardy estuary
#

It's a array of json objects

#

I suspect you would loop through answers

earnest phoenix
#

Can u help @tardy estuary

#

@slender thistle sir reply

#

Look on Stackoverflow on how to loop through an array

sudden geyser
#

@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.

earnest phoenix
#

does anyone know why message.member.voice, message.member.voiceChannel and message.member.voice.channel come back undefined

#

here's code

sudden geyser
#

are you in a voice channel

earnest phoenix
#

uhhhh no?

amber fractal
#

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

sudden geyser
#

were you in a voice channel when you tested it?

earnest phoenix
#

yea

sudden geyser
#

Have you tried joining the voice channel then testing it?

#

ah

earnest phoenix
#

I would expect it to say something

sudden geyser
#

.voice itself is not undefined/null.

#

It's .voice.channel that may be null/undefined.

earnest phoenix
#

I use message.member.voice

sudden geyser
#

try voice.channel

earnest phoenix
#

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?

amber fractal
#

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

earnest phoenix
#

gonna try using my old play code

sudden geyser
#

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).

earnest phoenix
#

its most likely message.member

tardy estuary
#

@earnest phoenix I don't really know what you want to do. I am assuming you want to loop through that array

earnest phoenix
loud salmon
#

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.

tight forum
#

hello again

loud salmon
#

am I overcomplicating things? I'm a tad sleep deprived so my brain could be described as the smooth variety

amber fractal
#

I would normally just go with guildid-memberid when I do stuff like that

prime cliff
#

If you do it as 102845358677176320-264445053596991498 then that would take less time than computing a hash of it

amber fractal
#

but I never tested performance

tight forum
#

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

loud salmon
#

yea idk i might just do plaintext idk

surreal notch
#

How to make a cmd that only I can use

#

No other can use that

tardy estuary
#

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

astral yoke
#

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

tardy estuary
#

You can try the emojis id

astral yoke
#

like :23578id : ?

white gyro
#

it's <:emoji:id> or <a:emoji:id>

astral yoke
#

yeah i got it

#

How can I get the discord.js version

prime cliff
#

a: for gif emotes

astral yoke
#

how would I get the discord.js version so that I can put it as like in my stats command

vernal jungle
#

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

cinder patio
#

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

vernal jungle
#

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

cinder patio
#

you also have to JSON.parse it

vernal jungle
#

yes

#

you have to do that

#

either way

cinder patio
#

no, with require it's parsed once afaik

vernal jungle
#
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

earnest phoenix
#

you can also just... read it once and store the response in memory

vernal jungle
#

that's also only reading the file once

#

unless you do an interval

cinder patio
#

I don't think that a package.json will be updated frequently... not at all actually why would it get updated in runtime?

vernal jungle
#

i was just saying what i personally do

#

because i do update it during runtime

cinder patio
#

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

vernal jungle
#

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

lofty grove
#

Are there any commands I want the music bot to play when I throw a link in the spotify?

small prairie
#

Whats the fetchMembers alternative from d.js v11,5 to d.js v 12

summer torrent
#

members.fetch

lofty grove
#

Are you telling me?

restive furnace
#

@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)

mossy vine
#

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
#

@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.

summer torrent
#

@restive furnace groovy using youtube for playing spotify songs

tight plinth
#

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

pale vessel
#

by using lavalink

tight plinth
#

Without lavalink

pale vessel
#

ah

tight plinth
#

I don't want to use it

pale vessel
#

try optimising the settings

tight plinth
#

They are

#

I can't optimize more

wise quartz
#
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

slender thistle
#

raise SomeExceptionHere
you are trying to raise an exception that doesn't exist

wise quartz
#

it has 2 embeds rn

#

do i do like

slender thistle
#

What do you want to do

wise quartz
#
except Exception as e:
    print(e)
#

?

#

that will print any errors right?

slender thistle
#

Yeah

wise quartz
#

alr

#

imma try

slender thistle
#

Though there's another way and you will get a full traceback

wise quartz
#

i am listening

#

whats the way?

slender thistle
#

traceback.print_exception exists

wise quartz
#

so i change Exception with traceback...?

slender thistle
#

traceback is a module

#

type(error), error, and error.__traceback__ being the function's arguments where error is the exception

wise quartz
#

back

#

i know traceback is a module i've used it before

#

but not for this exact thing

cinder patio
#

Opinions on using puppeteer as an alternative for node-canvas?

quartz kindle
#

never tried

#

i use node-canvas quite extensively

surreal notch
#

how to make leaderboard i am using quick.db and making economy cmd

#

discord.js v12

quartz kindle
#

wait which puppeteer? i can only find stuff about a headless chrome module

cinder patio
#

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

quartz kindle
#

how exactly is it an alternative to canvas? or is there something im not understanding

cinder patio
#

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'); ...")

quartz kindle
#

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?

cinder patio
#

yeah, I'm not saying it's more performant lol, but you can have multiple canvases inside 1 page

pale vessel
#

i thought you use puppeteer for something like web screenshot

quartz kindle
#

i dont think its a viable alternative to node-canvas

#

its a completely different lib with a completely different purpose

pale vessel
#

what about jimp?

quartz kindle
#

jimp is more like a replacement for graphicsmagick/imagemagick

pale vessel
#

ah ok

quartz kindle
#

its not a drawing library, its an image compositing library

nocturne grove
#

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()

delicate zephyr
#

just set an interval to update the status every 60 minutes

#

sometimes discord will just forget the presences

#

happens to me too

quartz kindle
#

i think it disappears if discord disconnects and reconnects

delicate zephyr
#

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

quartz kindle
#

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

nocturne grove
#

oh okay thanks

#

where can I find options to use when doing new Discord.Client()?

#

not in the docs afaik

quartz kindle
#

it is in the docs

nocturne grove
#

ohh yes I see it now

#

thx

earnest phoenix
#

How can I do that when someone on twitter posts a new tweet, that the bot sends a message in a channel.

quartz kindle
#

twitter webhooks

#

i think twitter webhooks are compatible with discord, so you dont even need a bot

nocturne grove
#

can you help me with the presence when the bot starts, those objects are confusing me

quartz kindle
#

what do you have now?

nocturne grove
#

like this:

const client = new Discord.Client({ presence: `help`, { type: 'WATCHING' } });```
#

but my eslint already says it's not correct

high bough
#

Isn't "presence" deprecated?

nocturne grove