#development

1 messages · Page 790 of 1

violet nimbus
#

@earnest phoenix can you give a big explanation?

round ridge
#

Hello i need a little help with my bot witch its in JavaScript i am using discord.js
so i wanted to use fetchUser to get user tag and when user cant be find i want to show his id

violet nimbus
#

@round ridge hello,
If you don't know lemme tell you that fetchUser if for user account.
https://discord.js.org/#/docs/main/stable/class/Client?scrollTo=fetchUser

round ridge
#

i am using it for bot i use normally fetchUser but i want when he will not find it just reply with id

quartz kindle
#

check if a result was found

#

show your fetchuser code

round ridge
#

i used it like that

const user = await bot.fetchUser(userr).catch(error => { userr })
quartz kindle
#

ok so then check if user exists

#

if(!user) { user = userr }

#

if user does not exist, replace it with id

round ridge
#

ye i know

#

@quartz kindle i did what you told me and still reply with error:

(node:26760) UnhandledPromiseRejectionWarning: DiscordAPIError: Unknown User

#

:p

quartz kindle
#

@round ridge change it to await bot.fetchUser(userr).catch(() => {})

round ridge
#

still errored:

(node:26928) UnhandledPromiseRejectionWarning: TypeError: Assignment to constant variable.

quartz kindle
#

do you have const user anywhere else?

round ridge
#
                let MUser = message.author.id;
                if(!userr) return message.reply("ID?");
                let breason = args.join(" ").slice(19);
                if (!breason) return message.channel.send('Specify a reason!')
                const user = await bot.fetchUser(userr).catch(() => {})
                if(!user) { 
                  user = userr 
                }
                const mod = await bot.fetchUser(MUser)
#

This is full varibles

quartz kindle
#

change const to let

#

the value of a const cannot be changed

round ridge
#

oh ye i forgot

#

now is working thx

#

by fetchUser do i am able to get only that user tag

quartz kindle
#

yes

#

you can do fetchUser(userr).then(u => u.tag).catch(...)

round ridge
#

oh thx 🙂

quartz kindle
#

@earnest phoenix show code

ocean frigate
#

you should show the code of the help command you use i think

quartz kindle
#

^

restive furnace
#

@ocean frigate 200 iq

round ridge
#

can someone help again
Code:

bot.guilds.members.forEach(member => { if (userr != client.user.id) member.kick(`ModBot Secruiti This User Got Banned For: ${breason}`); });

Error:


(node:27549) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'forEach' of undefined
winter shell
#

how to use lavalink?

restive furnace
#

@round ridgeyou need to first do loop for each guild and then for each the guild members (and i recommend for, not forEach.

ocean frigate
#

FreestyleToday at 2:55 PM
@ocean frigate 200 iq
What do you mean?

round ridge
#

@restive furnace can you help me out how to do loop i never done a loop in any of my projects

restive furnace
#
   Code here
}```
#

object can be bot guilds example

round ridge
#

and in code i just put what?

#

desame what i used?

restive furnace
#

you need to use loop-in-loop

#

like loop(guilds) { loop(members) { code here what u want to do } }

quartz kindle
#

you can use forEach, its just that for has higher performance, although the difference will only be a couple milliseconds

round ridge
#

i still dont understand how to use this

#

its look dificule

quartz kindle
#

a for loop is a pure/manual loop

#

while forEach is a helper method on an array that does it for you

#

the syntax of a for loop is as follows:

slender thistle
#

performance matters
readability matters too
nekopeek

quartz kindle
#
for(initial value; condition; next iteration) {
  // code
}```
round ridge
quartz kindle
#

nonono dont copy paste

round ridge
#

okay but how i am able to to that all?

quartz kindle
#

you know what, just use forEach

#

because anyway you need to convert guilds to an array if you want to use for

#

but you can use for in

#
for(let guild in bot.guilds) {
  bot.guilds[guild].members
}```
round ridge
#

rn i am thinking what is that i rly never used any of loops stuff

slender thistle
#

Is there a performance difference between a casual for and for in loops nekohmm

quartz kindle
#

for is still faster yes

#

@round ridge the concept of a loop is simply a block of code that repeats until a condition is met

#

there are many uses for loops, for instance, go over a list and repeat a block of code on each item of a list until the list ends

round ridge
#
for(let guild in bot.guilds) {
  bot.guilds[guild].members
}```

@quartz kindle so if i would do some like that do i add forEach ?

#

to like check users

slender thistle
#

Technically infinite loops are considered loops too, right? nekopeek

quartz kindle
#

yup

#

you can do it two ways

restive furnace
#

while(true){}

#

one way

quartz kindle
#
bot.guilds.forEach(guild => {
  guild.members.forEach(member => {
    // member
  })
})

or

for(let guild in bot.guilds) {
  for(let member in bot.guilds[guild].members) {
    // bot.guilds[guild].members[member]
  }
}``` or any combination of them
#

forEach is more readable and easier to use, but for is faster

#

for can be used for many other things, while forEach can only be used for arrays and collections, or other custom list-like things

#

for in can be used in objects, forEach cant

#

for is a loop that you create and manipulate however you want, forEach is a loop that is only available if the data you want to use it on provides it

marble juniper
#

you can use for to get for example the length of the text (which you don't need since the length property does that)

#

and other things

#
for (statement 1; statement 2; statement 3) {
  // code block to be executed
}
#

or well if you want every element in an array

for (let index = 0; index < array.length; index++) {
             const element = array[index];  
         }
#

also you should not forget this

dense drift
#

Anyone know how to use a message collector in PMs?

restive furnace
#

same way as in server?

dense drift
#

Yeah

#

I just need to send something like, reply with accept or deny, then it will watch what they say, and do something depending on what they said.

#

This is my code right now.. I'm a little lost.

        else if(args[0] == "invite"){
            let chnv = server.channels.find(c => c.name === `voice_${uid}` && c.type == "voice")
            let chn = server.channels.find(c => c.name === `chat_${uid}` && c.type == "text")
            let cate = server.channels.find(c => c.name == `party_${uid}` && c.type == "category")
            let role = msg.guild.roles.find(role => role.name === `${uid}`)
            let invm = msg.guild.member(msg.mentions.users.first() || msg.guild.members.get(args[0]));

            //console.log(invm.user)

            

            invm.send(`${u} has invited you to their party!\n\nPlease respond with \`accept\` or \`deny\`.`)
            const waiting = await new Discord.MessageCollector(invm, m => msg.author.id === `${invm.user.id}`, { time: 15000 })
            await waiting.on('collect', async m => {
                if(m.content.toLowerCase() === "accept"){
                    await invm.addRole(role)

                    invm.send(`You have joined the party!\n\nClick on <#${chn.id}> to get started!`)
                    u.send(`${invm.nickname} has accepted your invite!`)
                } else if(m.content.toLowerCase() === "deny"){


                    invm.send(`You have declined this invite.`)
                    u.send(`${invm.nickname} has declined your invite!`)
                }
                else {
                    invm.send(`Invalid response! Please ask for a new invite!`)
                    u.send(`${invm.nickname} has declined your invite!`)
                }
            
        })```
restive furnace
#

you could do ur custom msg collector like

#

on message -> if message channel type is dm and author is the wanted -> if message deny (-> function) or message accerpt (-> function) or no message (-> function)

violet nimbus
#

@restive furnace

const dbl = new DBL(DBLAPITOKEN, bot);

// Optional events
dbl.on("posted", () => {
  console.log("Server count posted!");
});

dbl.on("error", e => {
  console.log(`Oops! ${e}`);
});``` is that enough?
#

Or how to do it?

dense drift
#

Would I have to do that in a top level file, or can I do that in the command?

#

The accept or deny only applies in this command, it wouldn't apply at any other point.

#

HMMMMMMMMMM

#

I'll try something, I'll let you know. 🙂

violet nimbus
#

For server count

#

@restive furnace??

earnest phoenix
#
UnhandledPromiseRejectionWarning: TypeError [ERR_INVALID_ARG_TYPE]: The "url" argument must be of type string. Received undefined
#

Im getting this error but i cant seem to fix it

quartz kindle
#

@violet nimbus yes that is enough

dense drift
#

Hey, Tim's here lol

#

I'm still lost, if you want to take a look, you tend to be super helpful.

quartz kindle
#

what are you trying to do?

dense drift
#

My code has moved to,

        else if(args[0] == "invite"){
            let chnv = server.channels.find(c => c.name === `voice_${uid}` && c.type == "voice")
            let chn = server.channels.find(c => c.name === `chat_${uid}` && c.type == "text")
            let cate = server.channels.find(c => c.name == `party_${uid}` && c.type == "category")
            let role = msg.guild.roles.find(role => role.name === `${uid}`)
            let invm = msg.guild.member(msg.mentions.users.first() || msg.guild.members.get(args[0]));

            //console.log(invm.user)

            let filter = msg.channel.type.toLowerCase() == 'dm' && m.author.id === `${invm.user.id}`

            invm.send(`${u} has invited you to their party!\n\nPlease respond with \`accept\` or \`deny\`.`)
            const waiting = await new Discord.MessageCollector(filter, { time: 15000 })
            await waiting.on('collect', async m => {
                //if(m.author.id !== `${invm.user.id}`){ return }
                if(m.content.toLowerCase() === "accept"){
                    
                    await invm.addRole(role)

                    invm.send(`You have joined the party!\n\nClick on <#${chn.id}> to get started!`)
                    u.send(`${invm.nickname} has accepted your invite!`)
                } else if(m.content.toLowerCase() === "deny"){


                    invm.send(`You have declined this invite.`)
                    u.send(`${invm.nickname} has declined your invite!`)
                }
                else {
                    invm.send(`Invalid response! Please ask for a new invite!`)
                    u.send(`${invm.nickname} has declined your invite!`)
                }
            
        })```

The new error is ```js
TypeError: Cannot read property 'setMaxListeners' of undefined```

I'm trying to use a messagecollector in pms.
quartz kindle
#

can this command be initiated in dms? or is it a guild command that sends a dm then awaits for it?

dense drift
#

Guild command that sends to dm and awaits for it

quartz kindle
#

then await it and get the channel from it

#

let dmMessage = await invm.send(); let reply = await dmMessage.channel.awaitMessages(filter)

dense drift
#

dude

quartz kindle
#

check the docs for how to use awaitMessages

dense drift
#

I didn't think to set invm.send()

#

You're a life saver

forest sundial
quartz kindle
#

that code doesnt make any sense

modest maple
#

that is possibly

#

the most impressive piece of lack of basics knowledge ive ever seen

dense drift
#

I have a new bug, it's odd.

#
DiscordAPIError: Cannot send an empty message```

That's the error,

```js
else if(args[0] == "invite"){
            let chnv = server.channels.find(c => c.name === `voice_${uid}` && c.type == "voice")
            let chn = server.channels.find(c => c.name === `chat_${uid}` && c.type == "text")
            let cate = server.channels.find(c => c.name == `party_${uid}` && c.type == "category")
            let role = msg.guild.roles.find(role => role.name === `${uid}`)
            let invm = msg.guild.member(msg.mentions.users.first() || msg.guild.members.get(args[0]));

            

            //console.log(invm.user)


            invm.send(`${u} has invited you to their party!\n\nPlease respond with \`accept\` or \`deny\`.`);

            let dmMessage = await invm.send();
            const waiting = dmMessage.channel.createMessageCollector(dmMessage.channel, m => m.author.id === invm.user.id, { time: 500000 });
            waiting.on('collect', async m => {
                //if(m.author.id !== `${invm.user.id}`){ return }
                if(m.content.toLowerCase() === "accept"){
                    
                    await invm.addRole(role)

                    invm.send(`You have joined the party!\n\nClick on <#${chn.id}> to get started!`)
                    u.send(`${invm.nickname} has accepted your invite!`)
                } else if(m.content.toLowerCase() === "deny"){


                    invm.send(`You have declined this invite.`)
                    u.send(`${invm.nickname} has declined your invite!`)
                }
                else {
                    invm.send(`Invalid response! Please ask for a new invite!`)
                    u.send(`${invm.nickname} has declined your invite!`)
                }
            
        })```

That's the code
#

It is sending the DM to the user in question, it just seems to not be waiting for a response.

quartz kindle
dense drift
#

Which part is confusing?

quartz kindle
#

send the message, why are you sending the message then sending nothing right after?

dense drift
#

Oh

#

OHHH

#

Call me dumb

#

lol

#

Okay, now that that is working LOL,

New issue

TypeError: Function.prototype.apply was called on [object Object], which is a object and not a function```
quartz kindle
#

@earnest phoenix your code is not valid in any programming language i know, learn the basics of how programming works

#

@dense drift i told you to use channel.awaitMessages()

dense drift
#
        else if(args[0] == "invite"){
            let chnv = server.channels.find(c => c.name === `voice_${uid}` && c.type == "voice")
            let chn = server.channels.find(c => c.name === `chat_${uid}` && c.type == "text")
            let cate = server.channels.find(c => c.name == `party_${uid}` && c.type == "category")
            let role = msg.guild.roles.find(role => role.name === `${uid}`)
            let invm = msg.guild.member(msg.mentions.users.first() || msg.guild.members.get(args[0]));

            

            //console.log(invm.user)


            let dmMessage = await invm.send(`${u} has invited you to their party!\n\nPlease respond with \`accept\` or \`deny\`.`);
            const waiting = dmMessage.channel.createMessageCollector(dmMessage.channel, m => m.author.id === invm.user.id, { time: 500000 });
            waiting.on('collect', async m => {
                //if(m.author.id !== `${invm.user.id}`){ return }
                if(m.content.toLowerCase() === "accept"){
                    
                    await invm.addRole(role)

                    await invm.send(`You have joined the party!\n\nClick on <#${chn.id}> to get started!`)
                    await u.send(`${invm.nickname} has accepted your invite!`)
                } else if(m.content.toLowerCase() === "deny"){


                    await invm.send(`You have declined this invite.`)
                    await u.send(`${invm.nickname} has declined your invite!`)
                }
                else {
                    await invm.send(`Invalid response! Please ask for a new invite!`)
                    await u.send(`${invm.nickname} has declined your invite!`)
                }
            
        })```

Code if you need to see it again
quartz kindle
#

you cant use a collector like that

dense drift
#

Ah

#

Okay, I just didn't want to have to change it all again. Thanks, let me try.

quartz kindle
#

you dont need to use a collector here, you can remove your entire collector code

#

and look at the docs for how to use awaitMessages

#

show your "normal" code

#

this is not normal code

#

show the full code

#

show the embed part, and the message send part

dense drift
#

Okay, I've done a bit of code changing, and now I'm even more confused lol.

#

Also, don't @ tim every time.

#
TypeError: Function.prototype.apply was called on #<Object>, which is a object and not a function```

Error,

```js
            let dmMessage = await invm.send(`${u} has invited you to their party!\n\nPlease respond with \`accept\` or \`deny\`.`);
            let filter = dmMessage.channel
            dmMessage.channel.awaitMessages({
                max: 1,
                time: 500000 })
            
            .then(async(collected) => {
                console.log(collected)
                if (collected.content.toLowerCase() == 'accept') {
                    await invm.addRole(role)

                    await invm.send(`You have joined the party!\n\nClick on <#${chn.id}> to get started!`)
                    await u.send(`${invm.nickname} has accepted your invite!`)

                } else if (collected.content.toLowerCase() == "deny") {


                    await invm.send(`You have declined this invite.`)
                    await u.send(`${invm.nickname} has declined your invite!`)
                } else {
                    await invm.send(`Invalid response! Please ask for a new invite!`)
                    await u.send(`${invm.nickname} has declined your invite!`)
                }

            })```

Code
quartz kindle
#

@earnest phoenix delete this const client = new Discord.Client();
then you need to separate the message into arguments, for example let args = message.content.split(" ") then you need to make a different description depending on the argument, for example: ```js
...
.setFooter();

if(args[1] === "utilita") {
avatarEmbed.setDescription(Ciao ${message.author}. Ecco i miei comandi: __**Utilità**__ t!avatar o t!avatar @user: manda l'avatar di chi ha taggato o di sè stesso t!ping: dice i ping del bot t!aiuto: manda in privato i comandi del bot t!help: manda in chat i comandi del bot)
} else if(args[1] === "fun") {
avatarEmbed.setDescription(Ciao ${message.author}. Ecco i miei comandi: __**FUN**__ t!random: manda un numero random t!doge: manda l'emoji del doge t!buonasera: Risponde Buonasera t!ciao o t!ciao @user: il bot ti saluta t!RIP: il bot ti risponde scrivendo RIP)
} else {
avatarEmbed.setDescription(Ciao ${message.author}. Ecco i miei comandi: __**Utilità**__ t!avatar o t!avatar @user: manda l'avatar di chi ha taggato o di sè stesso t!ping: dice i ping del bot t!aiuto: manda in privato i comandi del bot t!help: manda in chat i comandi del bot __**FUN**__ t!random: manda un numero random t!doge: manda l'emoji del doge t!buonasera: Risponde Buonasera t!ciao o t!ciao @user: il bot ti saluta t!RIP: il bot ti risponde scrivendo RIP __**Photoshop**__ t!triggered: Triggera l'immagine profilo di sè stessi o propria t!inversione: Inverte i colori della propria immagine profilo di sè stessi o propria **ULTERIORI INFO USARE t!photoshop help** __**In Costruzione / Riparazione**__ t!nick @user: per cambiare il ick di un utente t!userinfo: manda le info di un utente (non funziona ancora, ma quasi) t!serverinfo: manda le info di un server (non funziona ancora, ma quasi)
);
}

#

@dense drift this is the example for awaitMessages in the docs: js // Await !vote messages const filter = m => m.content.startsWith('!vote'); // Errors: ['time'] treats ending because of the time limit as an error channel.awaitMessages(filter, { max: 4, time: 60000, errors: ['time'] }) .then(collected => console.log(collected.size)) .catch(collected => console.log(`After a minute, only ${collected.size} out of 4 voted.`));

#

the filter must be a function that checks what the messages should be to pass it

dense drift
#

Okayyy

#

I think I understand

#

Let me give it a shot

#

Okay, you're a life saver, it's now listening, but it just jumps to the last else every time...

let ug = msg.guild.member(invm.user.id)
            let dmMessage = await invm.send(`${u} has invited you to their party!\n\nPlease respond with \`accept\` or \`deny\`.`);
            let filter = m => m.content.startsWith('accept')

            dmMessage.channel.awaitMessages(filter, {
                max: 1,
                time: 500000 })
            
            .then(async collected => {
                console.log(collected.content)
                if (collected.content.toLowerCase() == 'accept') {
                    ug.addRole(role)

                    invm.send(`You have joined the party!\n\nClick on <#${chn.id}> to get started!`)
                    u.send(`${invm.nickname} has accepted your invite!`)

                } else if (collected.content.toLowerCase() == "deny") {


                    invm.send(`You have declined this invite.`)
                    u.send(`${invm.nickname} has declined your invite!`)
                } else {
                    invm.send(`Invalid response! Please ask for a new invite!`)
                    u.send(`${invm.nickname} has declined your invite!`)
                }

            }).catch(() => {

                invm.send(`Timed out, please ask for a new invite from ${u}.`)

            })
#

It always just says timed out.

quartz kindle
#

what does console.log(collected.content) show?

dense drift
#

undefined

quartz kindle
#

also, your filter should contain all possible answers, not only one

dense drift
#

Ohhhh

#

Interesting

quartz kindle
#

collected is probably a collection, just in case you want to await for more than 1 message

#

so collected.first().content

dense drift
#

I tweaked it to

let ug = msg.guild.member(invm.user.id)
            let dmMessage = await invm.send(`${u} has invited you to their party!\n\nPlease respond with \`accept\` or \`deny\`.`);
            let filter = m => m.content.startsWith(['accept', 'deny'])

            dmMessage.channel.awaitMessages(filter, {
                max: 1,
                time: 500000 })
            
            .then(async collected => {
                console.log(collected)
                if (collected.content.toLowerCase() == 'accept') {
                    ug.addRole(role)

                    invm.send(`You have joined the party!\n\nClick on <#${chn.id}> to get started!`)
                    u.send(`${invm.nickname} has accepted your invite!`)

                } else if (collected.content.toLowerCase() == "deny") {


                    invm.send(`You have declined this invite.`)
                    u.send(`${invm.nickname} has declined your invite!`)
                } else {
                    invm.send(`Invalid response! Please ask for a new invite!`)
                    u.send(`${invm.nickname} has declined your invite!`)
                }

            }).catch(() => {

                invm.send(`Timed out, please ask for a new invite from ${u}.`)

            })```
quartz kindle
#

startsWith doesnt work like that

dense drift
#

Okay

#

How would you go about it?

quartz kindle
#

filter = m => m.content.toLowerCase() === "accept" || m.content.toLowerCase() === "deny"

dense drift
#

Oh yeah lol

quartz kindle
#

that way only accept or deny will be valid answers, everything else will be ignored

dense drift
#

I'm half asleep

quartz kindle
#

so you can also remove this else { invm.send(`Invalid response! Please ask for a new invite!`) u.send(`${invm.nickname} has declined your invite!`) }

dense drift
#
            let ug = msg.guild.member(invm.user.id)
            let dmMessage = await invm.send(`${u} has invited you to their party!\n\nPlease respond with \`accept\` or \`deny\`.`);
            let filter = m => m.content.toLowerCase() === "accept" || m.content.toLowerCase() === "deny"

            dmMessage.channel.awaitMessages(filter, {
                max: 1,
                time: 500000 })
            
            .then(async collected => {
                console.log(collected)
                if (collected.content.toLowerCase() == 'accept') {
                    ug.addRole(role)

                    invm.send(`You have joined the party!\n\nClick on <#${chn.id}> to get started!`)
                    u.send(`${invm} has accepted your invite!`)

                } if (collected.content.toLowerCase() == "deny") {


                    invm.send(`You have declined this invite.`)
                    u.send(`${invm} has declined your invite!`)


            .catch(() => {

                invm.send(`Timed out, please ask for a new invite from ${u}.`)

            })

        }```
#

Now it's posting the same thing

#

Undefined, and timed out

quartz kindle
#

collected is still undefined?

dense drift
#

yeah

#
            let ug = msg.guild.member(invm.user.id)
            let dmMessage = await invm.send(`${u} has invited you to their party!\n\nPlease respond with \`accept\` or \`deny\`.`);
            let filter = m => m.content.toLowerCase() === "accept" || m.content.toLowerCase() === "deny"

            dmMessage.channel.awaitMessages(filter, {
                max: 1,
                time: 500000 })
            
            .then(collected => {
                console.log(collected)
                if (collected.content.toLowerCase() == 'accept') {
                    ug.addRole(role)

                    invm.send(`You have joined the party!\n\nClick on <#${chn.id}> to get started!`)
                    u.send(`${invm} has accepted your invite!`)

                } if (collected.content.toLowerCase() == "deny") {


                    invm.send(`You have declined this invite.`)
                    u.send(`${invm} has declined your invite!`)


            .catch(() => {

                invm.send(`Timed out, please ask for a new invite from ${u}.`)

            })}})

        }```
#

Now it's not undefined

#

It's a collection as expected

#
 Collection [Map] {
1|boomer |   '678564268295323660' => Message {
1|boomer |     channel: DMChannel {
1|boomer |       type: 'dm',
1|boomer |       deleted: false,
1|boomer |       id: '678533789839786003',
1|boomer |       recipient: [User],
1|boomer |       lastMessageID: '678564268295323660',
1|boomer |       lastPinTimestamp: null,
1|boomer |       messages: [Collection [Map]],
1|boomer |       _typing: Map {}
1|boomer |     },
1|boomer |     deleted: false,
1|boomer |     id: '678564268295323660',
1|boomer |     type: 'DEFAULT',
1|boomer |     content: 'accept',
1|boomer |     author: User {
1|boomer |       id: '375073714833981441',
1|boomer |       username: 'Lootgamer77',
1|boomer |       discriminator: '7758',
1|boomer |       avatar: 'c948087af467626a0b5b44df3a1bf030',
1|boomer |       bot: false,
1|boomer |       lastMessageID: '678564268295323660',
1|boomer |       lastMessage: [Circular]
1|boomer |     },
1|boomer |     member: null,
1|boomer |     pinned: false,
1|boomer |     tts: false,
1|boomer |     nonce: '678564256207077376',
1|boomer |     system: false,
1|boomer |     embeds: [],
1|boomer |     attachments: Collection [Map] {},
1|boomer |     createdTimestamp: 1581852728676,
1|boomer |     editedTimestamp: null,
1|boomer |     reactions: Collection [Map] {},
1|boomer |     mentions: MessageMentions {
1|boomer |       everyone: false,
1|boomer |       users: Collection [Map] {},
1|boomer |       roles: Collection [Map] {},
1|boomer |       _content: 'accept',
1|boomer |       _client: [Client],
1|boomer |       _guild: undefined,
1|boomer |       _members: null,
1|boomer |       _channels: null
1|boomer |     },
1|boomer |     webhookID: null,
1|boomer |     hit: null,
1|boomer |     _edits: []
1|boomer |   }
1|boomer | }```
#
TypeError: Cannot read property 'toLowerCase' of undefined
1|boomer |     at E:\Discord bots\Boomer\commands\default\party.js:147:39
1|boomer |     at processTicksAndRejections (internal/process/task_queues.js:94:5)```
quartz kindle
#

yes

#

now you have to use collected.first()

dense drift
#

Ayyyyyyyyy

#

It works!!!!!

#

❤️ <#

#

Holy moly, that's 3 hours of coding now working lolol

#

Thanks soooo sooo much for your help as always

quartz kindle
#

👍

finite bough
#
client.on('message', message => {
  if (message.author.id === '430964083160776705'){
    if(message.content.toLowerCase().startsWith('y!addmod')){
      let User = message.mentions.users.first()
  if (!User) return message.channel.send('doge ping someone!')

  let student = { 
    name: 'Mike'
    
};
 
let data = JSON.stringify(student, null, 2);

fs.writeFile('database.json', data, (err) => {
    if (err) throw err;
    console.log('Data written to file');
});

console.log('This is after the write call');
  }
  }
});
#

is there something I did wrong

quartz kindle
#

depends what you're trying to do

finite bough
#

I made a json file

#

named database.json

#

I want to send the userid of who I ping in the json file

#

it was not working so I just replayed User. Id with mike

#

its stil not working

quartz kindle
#

the way your code is right now, it will replace the entire database with one user every time

#

and writeFile writes buffers by default afaik, so you need to set it to write utf8

#

, data, "utf8", err =>

finite bough
#

oh

#

I will try it

#

still

#

didnt work

#
client.on('message', message => {
  if (message.author.id === '430964083160776705'){
    if(message.content.toLowerCase().startsWith('y!addmod')){
      let User = message.mentions.users.first()
  if (!User) return message.channel.send('doge ping someone!')

  let student = { 
    name: 'Mike'
    
};
 
let data = JSON.stringify(student, null, 2);

fs.writeFile('database.json', data, "utf8", (err) => {
    if (err) throw err;
    console.log('Data written to file');
});

console.log('This is after the write call');
}
}
});
quartz kindle
#

what didnt work?

#

did any of the console.log's work?

finite bough
#

it didnt send mike to the database

#

and yes it sent the message to the console

#

if you want you can send me a code which serves my purpose

quartz kindle
#

which message?

finite bough
#

it can be totally different

#

mike

#

in the database

quartz kindle
#

which message was sent to the console

finite bough
#

both

#

data written to file

#

and

#

this is after the write call

quartz kindle
#

and you opened the database.json file?

finite bough
#

ye

quartz kindle
#

and it has nothing inside it?

finite bough
#

nope

quartz kindle
#

delete it and try again

finite bough
quartz kindle
#

do you have any other code that writes to that file?

#

also, console.log(data) before fs.writeFile

finite bough
#

nope

tight plinth
#

Try not using glitch

#

@earnest phoenix make it online

finite bough
#

is there any other website I can use

tight plinth
#

@finite bough free no

warm marsh
#

Free yes, without a con, no.

tight plinth
#

@warm marsh wdym

finite bough
#

what's the con

warm marsh
#

E.g. heroku but its limited.

finite bough
#

nah

tight plinth
#

Heroku + databases = no

#

Just no

warm marsh
#

Heroku has postgres?

tight plinth
#

But it sucks

warm marsh
#

Fair. You're just better of paying a couple dollars/pounds/euros per month to get a vps.

tight plinth
#

If u have money vps are the best solution

#

But u need a good vps

warm marsh
#

For a bot? Nah.

tight plinth
#

If course u need one

#

Check pins

warm marsh
#

Wait, Google Cloud or Azure do trials/free credits.

toxic mauve
#

Hello how do u fix the music to search and hear the music

warm marsh
#

Langauge, show code (pastebin pref).

finite bough
#

@tight plinth can i use a module called fs extra

warm marsh
#

That won't change being able to write and read files consistently on glitch.

tight plinth
#

How heroku works :
-Clone the girhub repo of your bot
-npm install
-npm start

toxic mauve
#

I am so confused

quartz kindle
#

@finite bough try this: console.log(require("./database.json")) right after your console.log("data written to file"), still inside the fs scope

tight plinth
#

It clones the repo, it don't edit it

finite bough
#

oki

toxic mauve
#

Can someone join my server and help me

tight plinth
#

So databases with heroku are a bad idea coz they reset every time u restart ur bot

quartz kindle
#

json sorry, not js

toxic mauve
#

Pls anyone

quartz kindle
#

@toxic mauve are you trying to fix a bot you made?

toxic mauve
#

Yes

quartz kindle
#

how did you make it?

toxic mauve
#

I added the music rythim

quartz kindle
#

did you code it?

toxic mauve
#

How u code it

quartz kindle
#

so its not a bot you made?

toxic mauve
#

N

#

O

quartz kindle
#

then we cant help you

#

this channel is to help people who code bots

toxic mauve
#

Damn

#

Is there any channel for help

warm marsh
#

Go to the bots support server.

quartz kindle
#

ask the people who coded the bot

toxic mauve
#

Can I get code

twilit rapids
#

-wrongserver

gilded plankBOT
#

Hey! We think you have our server mistaken. We do not provide support, help, or advice for any bot. You need to click on the "Support Server" button on the bot's page, not the "Join Discord" button at the top of our website. If there isn't a button that says Join Support Server, then we can't help you. Sorry :(

toxic mauve
#

Ok

#

Thx

finite bough
#

@quartz kindle in the console there was this line {name: mike}

surreal sage
#

how to fetch guildmember property from msg author property

quartz kindle
#

@finite bough so the file is being written correctly, and then something is deleting it

#

so the problem is glitch, not your code

surreal sage
#

in visual studio code @earnest phoenix

quartz kindle
#

unless some other part of your code is doing that

surreal sage
#

y

#

but u need to understand it first

#

i rather watch a tutorial for beginners

quartz kindle
#

@surreal sage messages have a .member getter for that

surreal sage
#

lol forgot

#

thx

finite bough
#

I believe its not

surreal sage
#

wait

#

@quartz kindle message.author.member or message.member

#

msg.member

slender thistle
#

I don't think message.author.member will work

prime cliff
#

??? message.author is the member

slender thistle
#

d.py user vanishes into the void

prime cliff
#

C# all the way thinksmart

slender thistle
modest maple
#

i cant believe its actually harder to scrape sfw anime images than it is hentai

#

wtf is this world

twilit rapids
prime cliff
#

Technically harder for sfw since some sfw images could be seen as nsfw

modest maple
#

its just

#

you know how hard it is to scrape that shit

earnest phoenix
#

Can anyone help me how can i change authorized link.
Like open my own web page after authorize complete(when anyone adding my bot)

brisk meadow
#

can any mod help me

heavy marsh
#

I need a small help on Discord.js

What I am trying to do is ...
I dont want to make the bot leave the voice channel when I am in a different voice channel.

What I have soo far

if(message.member.voiceChannel !== message.client.user.voiceChannel) return```
#

It doesnt quite work

blissful scaffold
#

It might be better to compare the id of the channel

heavy marsh
#
if(message.member.voiceChannel.id !== message.client.user.voiceChannel.id) return
#

Like this?

earnest phoenix
#

Where's the code?

heavy marsh
#

What code?

blissful scaffold
#

Try it and see if it works

heavy marsh
#

oks

earnest phoenix
#

Is there a code bot?

#

Is it in

blissful scaffold
#

What do you mean with code bot? You need to code your own bot

earnest phoenix
#

I don't mean like that I mean in bot orders I mean pots but and so on because I put it in the bot my right

#

what

#

is that even english

#

please help me

console error

(node:3972) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'send' of undefined

CODE


      let leave = member.guild.channels.get(leavechannel);

    leave.send(`${leavemessage2}, ${member}!`, attachment);```
heavy marsh
#

On what do you need help on?

earnest phoenix
#

for some reason the event is not running

#

but I have given everything well the hits are good too

#

@heavy marsh

heavy marsh
#

Error means you cant send it

#

so there is an error in ```js
let leave = member.guild.channels.get(leavechannel);

earnest phoenix
#

but it shouldn't be a mistake

#
con.query(`SELECT * FROM prefix WHERE id = ('${member.guild.id}')`, async (err, rows) => {
        if(err) throw err;
        
        if (rows[0].welcome === 1) {
            console.log(`Goodbye event kivan kapcsolva a ${member.guild.name} Szerveren`)
        } else {


                  const leavemessage = rows[0].leavemessage
                  const leavemessage2 = rows[0].leavemessage2
                  let leavechannel = rows[0].leavechannel



let leave = member.guild.channels.get(leavechannel);```
heavy marsh
#

is member defined?

earnest phoenix
#
module.exports = async (bot, member, message) => { ```
#

EVENTS

heavy marsh
#

ahhh your trying to do the member leave event

earnest phoenix
#

YES

#

CAVAS ON

#

learn to debug

#

inspect the values of your variables

#

see what went wrong and where

heavy marsh
#

^

earnest phoenix
#

try removing and adding bits of code

#

@earnest phoenix error code got it just don't know why you do it js (node:3972) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'send' of undefined at Query.<anonymous> (C:\Users\Headsoht\Desktop\henota\events\guildMemberRemove.js:71:8)

heavy marsh
#

what dont you simple do js client.channels.get(`Channel ID`).send(`BLa BLa Bla`)

earnest phoenix
#

have you tried reading the error

#

yes

#

do you understand what it means

heavy marsh
#

Cannot read property 'send' of undefined

#

So send is not defined

earnest phoenix
#

no

slender thistle
earnest phoenix
#

it isn't

slender thistle
#

You are trying to do x.send where x is not defined

earnest phoenix
#

^

#

which is why i told you to inspect your variables to see what went wrong

heavy marsh
#

so some thing wrong with the variable right

#
if(message.member.voiceChannel.id !== message.client.user.voiceChannel.id) return

Is this wrong

#

ok nvm i get it lol

earnest phoenix
#

error code js (node:6828) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'send' of undefined at Query.<anonymous> (C:\Users\Headsoht\Desktop\henota\events\guildMemberAdd.js:68:39)

#

stop being a help vampire and read what we told you

#

codejs bot.channels.get(`${welcomechannel}`).send(`${welcomemessage2}, ${member}!`, attachment);

heavy marsh
#

(${welcomechannel}) might be an id that is invaild

#
message.client.user.voiceChannel.id

Is this wrong to get the voice channel id for which the bot is connected to?

earnest phoenix
#

a bot can be connected to multiple channels at once

#

so, yes

#

don't make up your own properties and read the docs

heavy marsh
#

Yey I am going through it now ... my bad

summer torrent
#

for message guild

#

@heavy marsh

heavy marsh
#

OMEGALUL Ohh thanks

upbeat wing
#

how to setup give role with use sticker only

summer torrent
#

sticker?

upbeat wing
#

reaction

#

sorry

#

how

#

help me @summer torrent

earnest phoenix
#

which lib are you using

upbeat wing
#

what???

earnest phoenix
#

which library are you using

#

i'm assuming discord.js

summer torrent
#

which library do you use

upbeat wing
#

bot

earnest phoenix
#

that's not a library

#

Hi

summer torrent
#

@upbeat wing which language do you use

upbeat wing
#

how

#

toturial

summer torrent
#

are you using javascript? @upbeat wing

upbeat wing
#

no

summer torrent
#

what do you do use

upbeat wing
#

i don know to use can you help me

earnest phoenix
#

see the image above

summer torrent
#

@upbeat wing do you know any programming language?

#

javascript, python etc

upbeat wing
#

no

summer torrent
#

first learn an any programming language

earnest phoenix
#

hello

upbeat wing
#

@summer torrent noooooo

summer torrent
#

?

upbeat wing
#

no

summer torrent
#

do you have a bot?

#

@upbeat wing

upbeat wing
#

i have bot mee6

quartz kindle
#

lmao

earnest phoenix
#

lol

summer torrent
#

🤦‍♂️

earnest phoenix
#

read the channel topic

upbeat wing
#

sorry

summer torrent
#

@upbeat wing go to mee6 support server

upbeat wing
#

i newbie

#

ouh

summer torrent
earnest phoenix
#

if it wasn't obvious enough by the channel name

upbeat wing
quartz kindle
#

nobody reads channel topics

summer torrent
#

@upbeat wing #verify channel

upbeat wing
summer torrent
#

???

#

@upbeat wing this server isn't a support server of MEE6.

upbeat wing
#

i don know

summer torrent
#

ask on mee6 support server

split hazel
#

Is it possible to create a database file & use it inside a node module installed via npm

quartz kindle
#

depends on what exactly you want to do, but most likely yes

split hazel
#

I only need it to store some data that needs to be persistent

#

that the module would require

quartz kindle
#

then yes

upbeat wing
summer torrent
#

ask on mee6 support server

#

@weak parrot -wrongserver pls

weak parrot
#

-wrongserver

gilded plankBOT
#

Hey! We think you have our server mistaken. We do not provide support, help, or advice for any bot. You need to click on the "Support Server" button on the bot's page, not the "Join Discord" button at the top of our website. If there isn't a button that says Join Support Server, then we can't help you. Sorry :(

restive furnace
#

picture changed from pokemon bot to luca

round ridge
#

i need help how can i make webhook to get who vote on my bot

modest maple
summer torrent
round ridge
#

i did

peak venture
#

ahm.. my bot seems to be offline and cant login. I get this error:

    at timeout.client.setTimeout (/rbd/pnpm-volume/7280dbe1-5cd8-4dd7-8365-79abebaab974/node_modules/.registry.npmjs.org/discord.js/11.5.1/node_modules/discord.js/src/client/ClientManager.js:40:57)
    at Timeout.setTimeout [as _onTimeout] (/rbd/pnpm-volume/7280dbe1-5cd8-4dd7-8365-79abebaab974/node_modules/.registry.npmjs.org/discord.js/11.5.1/node_modules/discord.js/src/client/Client.js:436:7)
    at ontimeout (timers.js:498:11)
    at tryOnTimeout (timers.js:323:5)
    at Timer.listOnTimeout (timers.js:290:5)```
#

nvm

#

apparently Discord created a new token O_o"

blissful scaffold
#

I think Discord sometimes automatically creates a new token if it sees that your token is leaked somewhere, or maybe if you break the rate limit a lot. But I am not sure

peak venture
#

it's odd though. Atm i just got another new token. And atm it's trying to login again but it's taking relative long.. once again.

So.. i assume there's going to be a similar error again

quartz kindle
#

you might have an infinite loop

#

or something wrong when loading something

peak venture
#

It used to work untill today though

#

Like nothing has changed at all since like 3 weeks

modest maple
#

i prefer to reclusively make my bot class and if one instance dies who cares i just have another 9999 left

peak venture
#

Web says Discord is banning IPs

scenic kelp
#

@modest maple smart way of doing it

#

rent 10000 different servers

quartz kindle
#

@peak venture did your bot cross 2500 servers by any chance?

peak venture
#

Nope

#

That's 1 seperate bot for 1 server

quartz kindle
#

are you loading files?

peak venture
#

Yws

#

so @quartz kindle the thing is that it loaded all the files and only to actually "login" it fails.

cinder patio
#

Can you guys tell me how much ram your bot uses? (and guild count to compare)

peak venture
#

So i posted my project there in awaitance

quartz kindle
#

i guess discord banned several of glitch's ip addresses

peak venture
#

so it seems

quartz kindle
#

since its a free service, many people use it for selfbots, spam, raids, etc

peak venture
#

btw; how did i store this session info or is that done automaticly?

quartz kindle
#

@cinder patio tell me how much yours uses and which language library, and i'll tell you if its normal

marble juniper
#

since glitch auto updates if you ever write any single line of code
it will always login and login

#

and thats the problem

cinder patio
#

48MB with discord.js, but I also have an express server running on the same proccess

modest maple
#

low as fuck

cinder patio
#

bot is in 2 guilds with 4 users total

quartz kindle
#

in glitch/heroku?

marble juniper
#

not even a gb ram

slender thistle
#

Is there any difference between blob and text data types in mysql special_think

cinder patio
#

when I just run it on my pc

marble juniper
#

not even 100mb

cinder patio
#

but like

#

2 guilds

quartz kindle
#

typically, discord.js will use an average of 100mb per 200-400 guilds, depending on how many members the guilds have

#

with default configuration

marble juniper
#

if there are many guilds with many members your kinda screwed

#

If you use heroku or glitch I suggest buying a vps

#

with a decent amount of ram

cinder patio
#

yea I'll definitely buy a VPS, I already have 1 but it only has 1GB ram

marble juniper
#

Performance is what you nedd

#

*need

cinder patio
#

I mean memory not RAM

quartz kindle
#

i asked about glitch/heroku because i dont think they count node's own process as part of its ram usage, so while node itself uses 40-50mb ram, glitch/heroku sometimes report 10/15mb ram

#

memory = ram

summer torrent
quartz kindle
#

discord.js has a lot of room for tweaking though, so you can make it use 10x less ram if you disable and/or clear caching

cinder patio
#

I run the process using pm2, don't know if that can add some bytes

marble juniper
#

you can use client.sweepMessages

quartz kindle
#

yes pm2 runs on its own process, which will add another 10-20mb total, but it doesnt matter much

marble juniper
#

client.sweepMessages removes some messages depending how long ago they got sent from the cache

#

which you can specify

quartz kindle
#

you can disable message caching, sweep members, users, channels, etc

marble juniper
#

you can remove the caching of most things and fetch them only if needed

quartz kindle
#

i made a library which disables all caches on a class level

cinder patio
#

I'm planning on deleting / making some properties of guilds / roles / users but I doubt that would save much RAM

marble juniper
#

better than nothing

cinder patio
#

I am not sure if I want to do the caching myself

quartz kindle
#

what will your bot do?

#

depending on your needs, you can also disable events, and use discord's new intents system, which will massively reduce cpu and bandwidth usage

cinder patio
#

not much, only needs to see perms and posts messages

quartz kindle
#

for perms you need to cache guilds, channels, members and roles

#

do you need welcome messages?

#

do you need to access people's online/idle status or their nicknames?

cinder patio
#

nope

quartz kindle
#

then you can probably use intents

summer torrent
quartz kindle
#

uh... context please?

summer torrent
#

context?

tight plinth
#

show entire code

scenic kelp
#

tim isn't magic

summer torrent
scenic kelp
#

well he is but not that magic

tight plinth
#

what the hell is this

quartz kindle
#

@summer torrent key names cannot start with numbers when using dot notation

#

you need to use bracket notation

#

response["3vs3Victories"]

summer torrent
#

ty

earnest phoenix
#

Hi

violet nimbus
#

Mean custom colors

modest maple
#

css in long desc

violet nimbus
#

@modest maple ooh

#

Thanx

#

But what

#

Are classes?

#

Or ids*

modest maple
#

use this thing called

#

'inspect element'

violet nimbus
#

Ooh

#

K

quartz kindle
#

who the hell uses query parameters like this: param/value/param/value/param/value

#

in any order

slender thistle
#

Wait what

modest maple
#

crunchyroll's api works using hash codes

slender thistle
#

It's literally like param1/value1?

modest maple
#

you have to send a request to get the hash to then use that hash to get the thing u want

slender thistle
quartz kindle
#

@slender thistle /basicspacedata/query/class/tle/distinct/true/predicates/NORAD_CAT_ID,TLE_LINE1,TLE_LINE2/EPOCH/>now-2/

slender thistle
#

Good God save the humanity

quartz kindle
#

plus they use cookies for auth instead of api keys

#

you have to send a get request with a cookie in the header

amber fractal
#

That's gonna be a fat api

quartz kindle
#

and look at these rate limits

#

are they running on windows xp?

modest maple
#

my webscraper api has a higher limit than that bloblul

earnest phoenix
#

why do they even bother exposing the api if they don't want people to utilise it.. almost at all

quartz kindle
#

they also say "please contact us and we will help you configure your use case for best efficiency"

#

sent them an email a week ago, no answer

#

they also ask you to use cURL with --limit-rate=100k (max 100kb per second download speed)

finite bough
#

@quartz kindle thanks now its somehow working

#

but can u tell me how can I add more ids in a single json file

#

if u want to see the code again

#
client.on("message", message => {
  if (message.author.id === "430964083160776705" || message.author.id === "469076843430150154") {
    if (message.content.toLowerCase().startsWith("y!addmod")) {
      let User = message.mentions.users.first();
      if (!User) return message.channel.send("doge ping someone!");
      
      let student = {
        name: `${User.id}`
      };

      let data = JSON.stringify(student, null, 2);
      
      console.log(data)

      fs.writeFile("./mod.json", data, "utf8", err => {
        if (err) console.log(err);
        console.log("Data written to file");
        console.log(require("./mod.json"))
      });
      message.channel.send('Hello! This is the reply message.')
      console.log("This is after the write call");
      
    }
  }
})
sudden geyser
#

@modest maple link to Crunchyroll's API?

#

@modest maple link to Crunchyroll's API?

modest maple
#

Theyre private endpoints

#

Theyre private endpoints

quartz kindle
#

@finite bough a json file cannot be parsed partially, so you make operations to the whole file at once

#

if you save to it, the whole file will be replaced

#

so you need to load the whole file, make the change and then save the whole file again

#

for this reason, json files are not a good storage solution and databases are preferred

finite bough
#

cant u just push it?

quartz kindle
#

nope because it breaks the json structure

finite bough
#

my friend does it

#

he sent me how he does it

#

but I didnt understand

blissful scaffold
#

theoretically you could insert data into a list, but I don't know any parser that does that when it updates a file

quartz kindle
#

show his code and i'll explain what he did

#

see? he does exactly what i said

#

he reads the entire file, makes the change then saves the entire file again

finite bough
#

hm?

blissful scaffold
#

he reads the entire file, edits the data and then saves the entire file

finite bough
#

how can I do that

quartz kindle
#

you can read a json file using require() or by using fs.readFile() or fs.readFileSync()

finite bough
#

yes

quartz kindle
#

using require will keep a copy of the file in memory

#

using fs will not

#

fs.readFile is an async function, fs.readFileSync is not

finite bough
#

hmm

#

so I should use require()?

quartz kindle
#

that would be the easiest way yes

finite bough
#

can u show me an easy way on how I can so it

#

it's ok if it troubles u

quartz kindle
finite bough
#

I will try searching on some example bots

#

ye

quartz kindle
#

thats reading the file

finite bough
#

ye

quartz kindle
#

so you read it, then you edit it, then you save it again

finite bough
#

hmm I will try thanks

quartz kindle
#

check this

finite bough
#

o

tidal parrot
#

use json as db

dusky marsh
#

json = fastest and safest database solution

quartz kindle
#

™️

hybrid sequoia
#

how do i make a code that runs multiple scripts?

sudden geyser
#

what do you mean?

heavy marsh
#

in discord.js how to get the number of voice channel the bot is connected to?

quartz kindle
#

client.voiceConnections

heavy marsh
#

Thank you

hybrid sequoia
#

i was trying to make a avatar command but it says the else is the problem

#
i was trying to make a avatar command but it says the else is the problem
// AVATAR COMMAND //
else if (command === 'avatar') {
    if (!message.mentions.users.size) {
        return message.channel.send(`Your avatar: <${message.author.displayAvatarURL}>`);
    }

    const avatarList = message.mentions.users.map(user => {
        return `${user.username}'s avatar: <${user.displayAvatarURL}>`;
    });

    // send the entire array of strings as a message
    // by default, discord.js will `.join()` the array with `\n`
    message.channel.send(avatarList);
}
valid holly
#

Thats a really dumb way to map a collection for someone’s avatar

hybrid sequoia
#

Really?

wintry jungle
#

How do you add a channel to a category?

channel.setParent("categoryID") isn't working

Please ping

mystic violet
#

Why does lavalink deafen my bot? random question

warm marsh
#

Language?

#

Most languages have that as an option.
E.g javascript (d.js)

const player = client.player.join({ guild, channel, host }, { selfdeaf: true });
valid holly
#

@wintry jungle why won’t you resolve the promise and log

#

Or at least send more info

ocean frigate
#

Maybe spam

modest maple
#

@coral trellis sizzle for ping

#

Spam in many channels

ocean frigate
#

deleted

#

auto matically?

modest maple
#

Ban yh

ocean frigate
#

oh

fallen arch
#

im still getting this error(2 months btw)
MongooseTimeoutError: Server selection timed out after 30000 ms

#
const mongoose = require("mongoose");
mongoose.connect('mongodb+srv://arcle:<pass>@xeroc-z467s.mongodb.net/test?retryWrites=true&w=majority',{
  useNewUrlParser: true,
  useUnifiedTopology: true
});```
#

useUnifiedTopology: true someone told me to change this to false
but i still get the error

earnest phoenix
#

How can I send a fake vote event to test my bot ?

copper cradle
#

There's a test button in the same place where you put your webhook thingy

earnest phoenix
#

Thanks

quartz kindle
#

@fallen arch you're using atlas? did you whitelist your ip address?

fallen arch
#

yes

earnest phoenix
#

I do not understand how to set up a webhook with the js api :/

quartz kindle
#

@fallen arch try adding .catch(console.log) to it

#

see if it logs anything

fallen arch
#

okay

quartz kindle
#

@earnest phoenix where is your bot hosted?

earnest phoenix
#

My bot is hosted on a vps, why ?

analog walrus
#

👀

quartz kindle
#

dbl sends webhooks to YOU, not to discord

#

your URL field should be your vps's ip address + webhook port + webhook url

earnest phoenix
#

And what is the webhook port and webhook url ?

quartz kindle
#

the port you define in the js api options

#

for example: YOUR.VPS.IP.ADDRESS:5000/dblwebhook

#

if the port you set up is 5000

earnest phoenix
#

I see, thanks

quartz kindle
#

also make sure the authorization field in the website is the same as the webhookAuth in the api options

fallen arch
#

why paused?

quartz kindle
#

idk

#

i dont use atlas

fallen arch
#

i did connect to my cluster

earnest phoenix
quartz kindle
#

do you have an existing server?

#

like express or something

earnest phoenix
#

no

quartz kindle
#

then remove the webhookServer option

earnest phoenix
#

Ok, thanks x)

#

Is it normal that when I launch the link, I have a 404 ?

fallen arch
#

mongoose
whats wrong with this connection string:
'mongodb+srv://arcle:<password>@xeroc-z467s.mongodb.net/test?retryWrites=true&w=majority'

analog walrus
#

I can't help much XC

summer torrent
#

@fallen arch replace <password> with password of db user

fallen arch
#

i did that ofc

neat ingot
#

lulz

quartz kindle
#

@earnest phoenix not normal, where is that 404 coming from?

earnest phoenix
#

nvm I fixed it

#

It works, thank you !

quartz kindle
#

👍

neat ingot
#

mongodb://user:pass@localhost:27017/rootcollection?authSource=admin

#

thats my mongodb string (with creds removed ofc)

quartz kindle
#

hes using Atlas, not a local installation

neat ingot
#

ahhhh poop, my bad 😄

#

sry

surreal sage
#

any ideas for a discord bot?

violet nimbus
#
const dbl = new DBL(DBLAPITOKEN, bot);

dbl.postStats(serverCount);
dbl.on("posted", () => {
  console.log("Server count posted!");
});

dbl.on("error", e => {
  console.log(`Oops! ${e}`);
});```
Is it enough?
sinful belfry
#

At the area labelled 'main' (near the bottom), cprefix should equal udata.personalPrefix when udata.voted == true however this is not the case and it instead outputs data.prefix. I am quite unsure of how to solve this. Any suggestions?

    function message(client, message) {
        guildData.findOne(
            {
              guildId: message.channel.guild.id
            },
            async (err, data) => {
              if (!data) {
                return;
              } else {
                var cprefix = data.prefix;
            
            userData.findOne(
            {
              userId: message.author.id,
              guildId: message.channel.guild.id
            },
            async (err, udata) => {
              if (!udata) {
                return;
              } else {
                 if (udata.voted == true) { /* this condition returns true */
                   var cprefix = udata.personalPrefix;
                    message.channel.send(cprefix); /* outputs udata.personalPrefix */
                    //cprefix == udata.personalPrefix here
                 } 
              }
            })
            /* main */
            message.channel.send(cprefix); /* outputs data.prefix */
            //cprefix == data.prefix here
        })
    }
quartz kindle
#

@sinful belfry the .send() part is outside of the second callback

mystic violet
#

would it be okay if I called const dbl = new DBL(Bot.config.topGGToken) every time my bot gets a voteLocked command?

#

Doesn't that not call the api

#

isnt that only client-side?

sinful belfry
#

@quartz kindle wdym i dont really understand.

quartz kindle
#

@mystic violet it should be ok, but its not really good practice to repeatedly create new instances for no reason

#

just create one dbl instance and attach it somewhere where you can access, like client for example

#

@sinful belfry the second .findOne part only applies to things that are inside it

sinful belfry
#

ah ok

quartz kindle
#

the final message.channel.send is inside the first callback, but outside the second, so it only has access to the things inside the first one

sinful belfry
#

oh so if i enclose the last message.channel.send() in the second one too then the variable should be defined correctly?

quartz kindle
#

yes

#

you can simply place it instead of the return line

sinful belfry
#

ok ty i will try it out

hoary elm
#

Looking for some assistance in resolving this ```[FATAL] Possibly Unhandled Rejection at: Promise Promise {

<rejected> { [Error: SQLITE_CANTOPEN: unable to open database file] errno: 14, code: 'SQLITE_CANTOPEN' } } reason: SQLITE_CANTOPEN: unable to open database file

[FATAL] Possibly Unhandled Rejection at: Promise Promise {

<rejected> { [Error: SQLITE_CANTOPEN: unable to open database file] errno: 14, code: 'SQLITE_CANTOPEN' } } reason: SQLITE_CANTOPEN: unable to open database file``` using Discord.JS and SQLite

#

I don't even know where to begin with this error and the odd part is the bot still uses the Database as it should it still functions properly regardless

I am also not looking to be spoon fed this is just my first time working with SQL and my first time getting this error and have been unable to find anything in guides, Reddit ect

quartz kindle
#

which sqlite driver/library are you using?

hoary elm
#

I am using both

#

I don't have an actual client side set up yet to manage/login to the database right now it's all done through the bot as I just set it up about a day or two ago

#

Like I said the bot still reads and writes to the database regardless of the error so I honestly am stumped on what the issue is. For example the bot has economy commands (Work, Bank ect) linked to the database I can work and earn money and it will still add it to my balance in the database.

quartz kindle
#

why are you using both?

#

the problem is likely that one of them is being blocked because the other one is using the file

#

you're not supposed to have multiple libraries doing the same thing lol

scenic kelp
#

but double the libraries is double the performance

hoary elm
#

Ahh okay sorry like I said I'm new to SQL the guide I was referncing listed both

#

So that's why I did that

scenic kelp
#

that's a whacky guide

hoary elm
#

I honestly assumed I didn't need SQLite3 cause my bot only ever calls SQLite just didn't want to delete it and break something

#

@scenic kelp it was a very whack very poorly designed guide

#

90% of what they listed was old or outdated functions

#

But like I said my bot only ever calls SQLite const sql = require("sqlite"); so I'll just delete the other one

#

Thanks for advising me that the double is likely the issue 😁

restive night
#

I updated discord.js to v12 and when i run my bot that have 200+ guilds, i get this debug log and my bot doesn't listening to any message

[WS => Shard 0] [HeartbeatTimer] Didn't receive a heartbeat ack last time, assuming zombie connection. Destroying and reconnecting.```
but when i change the bot token to another bot with only have 2 guilds and with the same code, i get this log and my bot is working properly
```[WS => Shard 0] Shard received all its guilds. Marking as fully ready.```
can someone help me with this?
if you ask my code, i already try with simple code like this but only bots that have 2 guilds work
```const Discord = require('discord.js');
const client = new Discord.Client();

client.on("debug", (e) => console.info(e));

client.on("ready", () => {
  
console.log("Logged in!");

});


client.on('message', message => {
	console.log(message.content);

if (message.content === 'ping') {
	message.channel.send('Pong.');
}

});

client.login("mytoken");```
hoary elm
#

If you are using v12 even I have heard a few people say they have better luck with v12.0.0-dev

quartz kindle
#

v12 is v12.0.0-dev lol

hoary elm
#

Other then that I'm useless lol I have no experience in shards yet

quartz kindle
#

@restive night try client.on("raw",console.log)

hoary elm
#

Oh 🤔 what are the changes exactly cause I have heard a few people saying that updating breaks certain functions

restive night
#

the bot is not sharded

#

let me try first, tim

quartz kindle
#

you installed via npm install discordjs/discord.js right?

restive night
#

right

#

client.on raw give me a lot of log

quartz kindle
#

on the 200 guilds or on the 2 guilds?

restive night
#

200

quartz kindle
#

a lot of GUILD_CREATE right?

restive night
#

yeah

#

so what is the causing this?

quartz kindle
#

that is normal

#

does it ever stop logging?

#

or does it keep logging a bunch o stuff forever?

restive night
#

its always logging

#

forever yeah

quartz kindle
#

lots of PRESENCE_UPDATE right?

restive night
#

but my bot only appear online,

#

and doesn't listen to any message

quartz kindle
#

does any MESSAGE_CREATE appear in the logs?

restive night
#

no, i thinks its only PRESENCE_UPDATE and GUILD_CREATE

#

why its not happening on bot that only have 2 guilds?

quartz kindle
#

very strange

#

you're not receiving some packets idk why

#

try reinstalling discord.js and maybe try resetting your token

restive night
#

already try that both reinstaling discord.js and reset token but still stuck with this

quartz kindle
#

and this only happens in v12, not in v11 right?

#

maybe try an earlier commit

#

i g2g now

restive night
#

yeah only happen on v12

#

ok thank for ur time

restive furnace
#

try v11

#

or v11-dev

sinful belfry
#

URIError: URI malformed

the hell does that mean?

restive furnace
#

that its invalid/became invalid while parsing

sinful belfry
#

invalid in what way?

restive furnace
#

idk

blissful scaffold
#

We don't know what your URI looks like, but it is not how it should be

analog roost
#
                ^

RangeError [EMBED_FIELD_VALUE]: MessageEmbed field values may not be empty.```
#

:/

amber fractal
#

Let me tell you the error MessageEmbed field values may not be empty.

copper cradle
#

People should learn to read error logs tbh

hoary elm
#

Lol yup

#

@analog roost that error is simple literally tells you what's wrong

#

Either one of your Embed fields are empty or it can't read what you have in it

analog roost
#

Well nvm found out what I had to do 😆

hoary elm
#

😁

marble juniper
#

it appears like errors are written in an alien language for others or they just are too lazy to actually understand it

blissful scaffold
#

I think the last, usually the error message is pretty clear

copper cradle
#

Yeah

sudden geyser
#

it appears like errors are written in an alien language for others
@marble juniper check out C++ error messages.

surreal sage
#

bruhhhh

#

how to get bot owner properties discord.js

#

ping me if u know

hoary elm
#

Bot owner properties like what? @surreal sage

#

Like Owner ID ect?

quartz kindle
#

there are no bot owner properties

#

discord doesnt know and doesnt care who the owner is

hoary elm
#

Yeah I was gonna say usually for that stuff I just use something like const Owner = client.users.get('OwnerID')

amber fractal
#

you can set one like <Client>.owner = await client.users.fetch("your-id") if you want

#

but I don't see why you would

earnest phoenix
#

TimToday at 9:37 PM
there are no bot owner properties
discord doesnt know and doesnt care who the owner is
the client is able to fetch information about itself which includes the owner

#

as for other bots, you can't know who the owner is from the API

summer torrent
#

client.fetchApplication()

amber fractal
#

That's true

#

Well other bots cant get that

#

I dont think

quartz kindle
#

ah yeah theres fetchapplication

hoary elm
#

Oh I didn't even know that was a thing 🤔

#

Interesting

wet iron
#

im new to developing

#

hi

hoary elm
#

👋

wet iron
#

I use python

#

and I made my first bot

#

soo

#

Now im waiting

#

for it to get approved...

#

how long it will take for it to be?

quartz kindle
#

about a week

wet iron
#

thanks

#

because im new

#

how do i add this

#

like orange

#

think

#

?

quartz kindle
#

an embed?

hoary elm
#

an embed?
i think he means the embed color I can't help with that idk much about python

modest maple
#

Usefull Link^^

blissful scaffold
#

Approval is around 2 weeks

twilit rapids
#

Oh hey that's my botum

wet iron
#

yes

#

an embed

#

how do i write it

#

so i can put it on the bot

blissful scaffold
#

Timo, did you call your bot Chip because Chips are made from Potatoes?

twilit rapids
#

No, and this is not related to Development

earnest phoenix
#

lmao

modest maple
#

D.py embeds:


# To start / create an initial embed we use discord.Embed()
embed = discord.Embed()

# Embed() has Kwargs title, description, color
embed = discord.Embed(title="This is a title",
                      description="This is a description",
                      color=<Some hex code>)```
#

basic embed

hoary elm
#

Interesting I kinda like the python layout.

modest maple
wet iron
#

thanks!

slender thistle
#

@modest maple Real men do embed.title = "This is a title" nekopeek

modest maple
#

fuck off

#

xD

#

only monsters do that

slender thistle
#

Are you calling me a monster nekoannoyed

earnest phoenix
#

so, tupperbox is offline, how do we bring him back to life?

modest maple
#

no cuz u a cuti

#

@earnest phoenix not a support server

earnest phoenix
#

damn

#

how can i find a support server?

hoary elm
#

On the bot page

slender thistle
#

If you're talking about a bot that's on top.gg, find its bot page and click on "Join Support Server" button nekopeek

hoary elm
#

If they have a support server listed that is

earnest phoenix
#

ah

#

thank u

slender thistle
zealous veldt
#

I need a surefire way to convert anything into a string that I can log to the console. I'm creating a custom logger and getting errors trying to convert things to primitives. Is there a surefire way in JS to convert anything into a string? I'm ok with something become something like [Object: null prototype] {}, it just needs to convert to a string. I've tried using String(<thing>) , str = thing + '', thing.toString(), etc. All have thrown errors. The function that I need this in a logging function, similar to console.log.

log (...args) {
 ...
  args.join(' ') <- this is where I get errors
 ...
  console.log(prefix + chalk.bgRed()) // ~
}```

Please ping me with a response
quartz kindle
#

there is no surefire way, but i think the closest you can get is util.inspect

zealous veldt
#

hm, I'll try that

#

would it be best to inspect all args or just the ones that aren't strings?

quartz kindle
#

all of it

#

util.inspect is designed to debug stuff like objects

zealous veldt
#

aight

quartz kindle
#

its output is similar to that of JSON.stringify

zealous veldt
#

yeah

#

alright that worked

#

thanks!

quartz kindle
#

👍

mystic violet
#

Is there any db's like rethinkdb? cause I cant install rethink, the windows link isnt working

zealous veldt
#

Mongo is probably the closest you can get

#

But it's still quite different

copper shoal
#

where is the bot list ;;;—-

zealous veldt
mystic violet
#

@zealous veldt press download on the zip

zealous veldt
mystic violet
#

Thank you

#

\⏯️ \⏩ \🔁

neat ingot
#

@zealous veldt javascript has the .toString() function on all objects

#
log (...args) {
  args.map(a => a.toString())
  console.log(...args) 
}
empty owl
#

WHoa

#

another moose

neat ingot
#

lmao

empty owl
#

now theres 3

#

wait

#

no thats Moose

neat ingot
#

however, you should be able to log objects to the console without any issues

#

for example

function log(...args) {
  console.log('some new thing', ...args)
}```
true oasis
#

I have a t4 bot in my discord and it stopped working all of a sudden. Anyone has any ideas what I can do to fix it?

dense drift
#

Anyone have any idea how I would go about printing a loop in 1 message?

                for (let i = 1; i < +a; i++) {
                    
                    msg.channel.send(`**${i}** - ${client.games.get(i)}`)
                }```

My code is that, and instead of it printing 1 message at a time, I would like to map it, and send it in a single message. I'm confused. Thanks in advance!
hybrid sequoia
#

let messageArray = message.content.split(" "); is right for command handler? Hope everyone understand this

#

error:```let messageArray = message.content.split(' ');
^

ReferenceError: message is not defined```

dense drift
#
module.exports = {
    name: 'name of command here',
    description: 'description here',
    execute(client, message, args) {```
#

What's yours look like?

analog walrus
#

Btw, regarding webhooks

#

I have this issue of invalid webhook token

primal dove
#

i got some error but i do not found them / how to fix it

earnest phoenix
#

Hey

#

If anyone can give me some tips to making a bot at all please please message me <3

lament meteor
#

@primal dove what is the error?

marble juniper
#

imma guess its because you try to delete the message twice

#

remove the message.delete after if (message.deletable) @IDBLOCK#9999

#

bruh

torn nebula
#

Lol he left

pulsar lantern
#

@dense drift in case nobody answered your question from an hour ago, you'd create a string and concatenate each line to it and then send the message after the loop

dense drift
#

How do I add each line?

pulsar lantern
#

Is that PHP?

dense drift
#

javascript

pulsar lantern
#

Oh then it'd just be like
var fullString = "";
for(...){
fullString += (your message);
}
channel.send(fullString);

late hill
#

You can probably do it without the loop

dense drift
#
                var fullString = "";
                for (let i = 1; i < +a; i++) {
                    
                    fullString += `**${i}** - ${client.games.get(i)}`
                }
                msg.channel.send(fullString)
                return```

Something like this?
late hill
#

is client.games a Map

dense drift
#

It's pulling from my database, that's why I use the loop.

pulsar lantern
#

Yeah it should be a loop for sure

dense drift
#

Yes, however the map would have stuff I don't want.

pulsar lantern
#

That's close however u interpret the entire statement as a string when u add it to the fullString

#

So it will print out the line of code, not the data from the code

#

I think anyway, you can try that

#

I'm not very experienced with jQuery

dense drift
#

Okay, I'll try.

#

Holy

earnest phoenix
#

Im just trying to develop my first bot and cant get off the part where i have to start up my bot im sorry to both you people but can anyone help me xd

dense drift
#

You did it!

#

Thanks man!!!!

late hill
#

Yes, however the map would have stuff I don't want.
You could still apply filters without a loop

pulsar lantern
#

Yeah np

late hill
#

Depending on what exactly your filtering is like, it may actually be very simple

dense drift
#

That's alright, this worked perfectly! Thanks for the help.

pulsar lantern
#

Glad to hear

#

Gl developing

dense drift
#

🙂

earnest phoenix
#

can anyone help me start my bot please? its on the part where i start the bot so its online and every time i do node index.js it just says module not found

neat ingot
#

rauxs, have you ever written a node js application before?

earnest phoenix
#

no

neat ingot
#

i'd recommend you follow these steps:
1 - run 'npm install' from command line

#

2 - run node index.js

#

3 - profit

earnest phoenix
#

profit?

neat ingot
#

idk, isnt that the intent?

earnest phoenix
#

okay 1st. i did npm install its up to date

#

node index.js doesnt work

neat ingot
#

but either way, it sounds like node modules werent available

pulsar lantern
#

It's missing discord.js probably

neat ingot
#

what does the error say

pulsar lantern
#

If you're making a node bot

neat ingot
#

could be missing the entire package.json lol

earnest phoenix
#

Error: Cannot find module 'C:\Users(my name)\index.js'
 at Function.Module._resolveFilename (internal/modules/cjs/loader.js:981:15)
 at Function.Module._load (internal/modules/cjs/loader.js:863:27)
 at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
 at internal/main/run_main_module.js:18:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}

C:\Users(my name)>

neat ingot
#

is the file 'index.js' within your user directory?

earnest phoenix
#

yes

late hill
#

show your directory

earnest phoenix
#

wait

#

what is my directory

late hill
#

also

pulsar lantern
#

Does it have discord.js code in there and no discord.js?

late hill
#

straight up having the main file in your user folder

ruby warren
#

Hi

late hill
#

kinda weird

#

and probably not what you did

pulsar lantern
#

^

neat ingot
#

^

#

certainly not recommended if you did

pulsar lantern
#

If your file is elsewhere you'll have to navigate ur command line to it first

neat ingot
#

personally, i would create a brand new folder somewhere called 'app' or w.e

earnest phoenix
neat ingot
#

then i'd move my index.js, and package.json file into that folder

earnest phoenix
#

i will get new token

neat ingot
#

and follow the 3 steps from above

earnest phoenix
#

idc about my name anymore

#

i just want the bot to get off that

neat ingot
#

show your package.json contents plz?

#

ahh seer

earnest phoenix
neat ingot
#

your in a directory already

#

'discordbot'

earnest phoenix
#

erm

#

is that good or bad

late hill
#

Did you install node

earnest phoenix
#

yes

neat ingot
#

oooohhh

earnest phoenix
#

i did

neat ingot
#

its not finding it

late hill
#

Have you restarted your pc since

neat ingot
#

type node --v

earnest phoenix
#

no....

neat ingot
#

in the command line

late hill
#

It's probably not added to the path

#

If you reboot it should work

earnest phoenix
#

oka

#

will do

#

thx

neat ingot
#

node --version sorryu

#

should get something spit out like that

earnest phoenix
#

yeah

#

12.16.0

#

ima restart pc

#

be back in a min or 2

neat ingot
#

how can node --version work though when it cant find 'node' ...

#

strange, but mmk 🙂

#

also, idk if case matters on requires, but you have a capitalized D

#

is what i use

#

it might require case sensitivity more if your running a linux machine

earnest phoenix
#

okay

#

just restarted

#

took a few mins

#

leme open everything up again

neat ingot
#

np, tyt 🙂