#development

1 messages · Page 873 of 1

turbid bough
#

huh

valid frigate
#

so i know this is completely far off but a ui change is supposedly coming for bots

#

you could wait until then and just use inline/non-inline for now

#

gui*

visual sandal
#
.addField("title", "body", false)
.addField("title", "body",true)
.addField("title", "body", false)
#

that gave every field it's own line

turbid bough
#

true, true, false, true?

valid frigate
#

how does that work

visual sandal
turbid bough
#

uuh, lemme test it myself

visual sandal
#

ight

frigid sierra
#

afaik it is not possible to delegate two fields a row

lyric mountain
#

you gotta put a empty field to break

frigid sierra
#

really? yikes

lyric mountain
#

yep

frigid sierra
#

what do you mean by empty? like literally has no content at all, or blank strings for the title + value?

lyric mountain
#

at least for JDA there's a addBlankField() method

#

it's not like a field with nothing

frigid sierra
#

i'll have to check what that does

lyric mountain
#

it literally acts like a line break

#

the only argument it has is inline

frigid sierra
#

field inlining is cursed

lyric mountain
#

so .addBlankField(true) creates a field break

#

lol

frigid sierra
#

that is not at all how that should work lol

lyric mountain
#

it's because true true put fields together, but false true and true false not

#

if one is not inline, then it'll not be in front nor behind ANY field

#

even inline ones

frigid sierra
#

which is equivalent to:

{
    "name": "\u200E",
    "value": "\u200E",
    "inline": true
}
#

that is so cursed

lyric mountain
#

lol

turbid bough
#

yeah, i just tried multiple options

#

cursed af

visual sandal
frigid sierra
#

are you just passing two normal inline fields then a blank field like the one i put above?

lyric mountain
#

you gotta do it like field field blank field field blank etc

turbid bough
#

cant add a true-inline with false-inline 😦

visual sandal
#

that is what i did

frigid sierra
#

the property inline should just get replaced with some property named like reset-row or something

#

and fields should be inline by default

lyric mountain
#

or a row index

frigid sierra
#

that would solve this issue

lyric mountain
#

like, all fields with row 0 would be together

frigid sierra
#

lol yeah while we're at it let's just enable CSS grid for embeds cool

turbid bough
#

yeah i think this was beacuse of discord changed some ui stuff again smh

#

i think i was able to do it before

lyric mountain
#

lol

#

but embeds will pretty much die or become rare given the new features ngl

turbid bough
#

and then i gotta reprogram all embeds again?

lyric mountain
#

no, I mean

#

you'll have actual menus

frigid sierra
#

well unless they add something similar to embeds for displaying data i think they'll be relevant

#

hopefully they do the former

turbid bough
#

it seems there would have to be some kind of code execution or injection for that to work

frigid sierra
#

nahhhh

turbid bough
#

or events

frigid sierra
#

i'd assume you just send some JSON metadata and perhaps websockets will be used to handle input

#

or maybe you send the entire menu payload in one go

turbid bough
#

well, you need to program it somewhat right

#

like a whole game you can make with it

#

so i dont think you would be sending everything

frigid sierra
#

yeah, i have no idea where they're going with it

frigid sierra
#

that's a convincing looking animation LOL

earnest phoenix
#

that's an official UI concept

#

it's a concept though

frigid sierra
#

has some neat concepts and i'm interested to see how they do it

earnest phoenix
#

i honestly don't have high expectations

#

discord fucks up anything they do

turbid bough
#

im expecting 5 seconds delay each action

valid frigate
#

if it does become reality there will be like infinite customization options

earnest phoenix
#

great ideas terrible execution

valid frigate
#

well maybe

frigid sierra
#

well that isn't execution

earnest phoenix
#

i know

#

the concepts there aren't

turbid bough
#

for me it looks like it just spams embeds to me just with return messages on embeds

earnest phoenix
#

i'm talking about other features over the course of the past year and a half

frigid sierra
#

oh lol

turbid bough
#

ive barely even seen useful features

earnest phoenix
#

they had really good ideas but they executed them so poorly that discord devs started being a meme within the community

frigid sierra
#

well nonetheless it's a platform we use and develop for

#

so when this UI change drops, you take what you can get

earnest phoenix
#

at least they're finally implementing it

turbid bough
#

"its time to drop discord, join <this random other discord clone>"

earnest phoenix
#

they promised contextual menus in 2016, 4 years ago

frigid sierra
#

matrix

#

what do you mean, cry? we got context menus in 2016

earnest phoenix
#

i meant what was shown in the concept, custom contextual menus* my bad

frigid sierra
#

ahh

#

yeah, that's a fair point

slow cape
#

@lyric mountain i opened it and it doesnt work

#

@ me if you have any ideas

lyric mountain
#

@slow capeupload to giphy and use an embed with the link to it

slow cape
#

How do you do that

#

Im doing a triggered command

lyric mountain
#

Create an embed

#

But set only the image field

quartz kindle
#

if they implement those contextual menus its gonna fuck me over after i spent so much time developing my reaction menu lmao

modern sable
#

does someone know why
SELECT * FROM groupparticipants WHERE groupid = comp.group.id AND comp.group.tournamentid = "1"; seems to fail with Unknown column 'comp.group.id' in 'where clause'

despite the column clearly existing https://luca.is-inside.me/ZBwDFA4p.png

lyric mountain
#

Do an inner join

#

You gotta select that table to use its columns

#

if they implement those contextual menus its gonna fuck me over after i spent so much time developing my reaction menu lmao
@quartz kindle don't think that way, it'll be fun

#

What about me that have an entire library made just for pagination? Lol

#

But I can't wait for those features

modern sable
#

oh my fucking god

#

thats why you shouldn't program at 1 am

#

ty

lyric mountain
#

Lol

prime cliff
#

Intresting thing about those interactive menus too is that people can't really userbot automate them such as game bots and bots where you have to claim stuff in chat that randomly spawn

lyric mountain
#

Yep

#

It'll fix A LOT of selfbot issues

#

Well, if developers are willing to update their code, obviously

modern sable
#

not for long probably

#

people will figure out how to selfbot the interactions since discord will have to make a API for it

lyric mountain
#

Well, yes

#

But selfbots would have to click on the buttons

quartz kindle
#

if discord introduces clickable elements, bots should never have access to it

#

who in the world would make bots be able to "click" on embeds and why lol

lyric mountain
#

Just like the context menu, which probably will be unavailable to bots

quartz kindle
#

but selfbots made with userscripts on client side will still be able to

topaz fjord
#

you could just use selenium

quartz kindle
#

theres no way to stop those

lyric mountain
#

Well, yes

topaz fjord
#

for semi automation of your account

lyric mountain
#

But it'd be a really complex code simulate user interaction

#

At least not the level that majority of people here would be able to achieve

quartz kindle
#

i played a browser game once, mobamanager, which had an event where random easter eggs would pop on the screen and move around, and you had to click them to get points

#

and i ruined the event for the whole player base

topaz fjord
#

buy automating it?

quartz kindle
#

i made a script to automate it, and released it to my guild members

#

and one of them reported me

#

lmao

topaz fjord
#

lmao

quartz kindle
#

at first, the points were hidden

#

so nobody knew who was ahead

#

when the leaderboard was released, i was in first place by like 10x more than the second place, and all the top 10 were my guild members lmao

#

we were collectively ahead of our rival guild by like 100x more points

#

it was stupidly obvious we were cheating

topaz fjord
#

amazing

#

I've been looking to see what things I can automate for fun

quartz kindle
#

i once also made a script to automate bitcoin gambling

#

didnt go so well XD

topaz fjord
#

went broke

quartz kindle
#

a couple times

#

i mostly used it with shitcoins so no real loss

#

if you're using v12, delete requires an options object

queen needle
#
client.on("message", message => {
    let args = message.content.substring(PREFIX.length).split(" ");
  
    switch (args[0]) {
      case "give":
       if(!coins[message.author.id]){
        return message.reply("You do not have any coins")
      }
        
        let puser = message.guild.member(message.mentions.users.first()) || message.guild.members.get(args[1])
        
        if(!coins[puser.id]){
          coins[puser.id] = {
            coins: 0
          };
          
          
       let pcoins = coins[puser.id].coins;
          let scoins = coins[message.author.id].coins;
          
          if(scoins < args[1]) return message.reply("You do not have enough coins")
          
          
          coins[message.author.id] = {
            coins: scoins - parseInt(args[2])
          }
          
          coins[puser.id] = {
            coins: pcoins + parseInt(args[2])
          }
          
          message.channel.send(`${message.author} has given ${puser} ${args[2]} coins`)
          
          
          fs.writeFile("./coins.json", JSON.stringify(coins), (err) => {
            if(err) console.log(err)
          })
        }
        
        break;
    }
  });```
heavy anchor
#

I have one its 3000

queen needle
#

if i do the give command it only works once so if i do ^give @ a user 5

#

for some reason the command wont work again

sudden geyser
#

You're not doing anything for users who have a coin balance. Look around your coins[puser.id] {...} code.

#

if(scoins < args[1])
You're comparing against the user instead of how much you want the user to give.

quartz kindle
#

@heavy anchor it requires an object, you gave it a number

#

an object is like this: {}

#

for example {timeout:3000}

queen needle
#

@sudden geyser how could i do thta

sudden geyser
#

Do what

queen needle
#

i changed the args[1] to args[2] but now the command doesnt work at all

sudden geyser
#

Where did you change it. Do you know what args[1] and args[2] are supposed to be?

queen needle
#

if(scoins < args[2]) return message.reply("You do not have enough coins")

#

args[1] is a person

lyric mountain
#

Bump to kinolite's question

queen needle
#

args[2] is coins

sudden geyser
#

If nothing's happening, did you check your statement?

You're not doing anything for users who have a coin balance. Look around your if(!coins[puser.id]) {...} code.

queen needle
#

oh forget to fo that

#

i dont see anything wrong there if they are not in the file already add them too it

sudden geyser
#

The issue is you're doing that for users if they don't have a balance. If they do, you don't do anything. In short:

if (!coins[puser.id]) {
  // all your code
}

// Nothing's happening to users with a balance.```
queen needle
#

bu then how would it work the first time?

#

and it didnt work

earnest phoenix
#

Well console.log it

#

Or try catch the command

sudden geyser
#

Cinnamon roll, all you need to do is make that if only add a property to the coins object.

#

You should move the rest of the code under it outside that if statement.

queen needle
#

isnt that where it is

#
client.on("message", message => {
    let args = message.content.substring(PREFIX.length).split(" ");
  
    switch (args[0]) {
      case "give":
       if(!coins[message.author.id]){
        return message.reply("You do not have any coins")
      }
        
        let puser = message.guild.member(message.mentions.users.first()) || message.guild.members.get(args[1])
        
        if(!coins[puser.id]){
          coins[puser.id] = {
            coins: 0
          };
          it ends right here then the code starts
          
       let pcoins = coins[puser.id].coins;
          let scoins = coins[message.author.id].coins;
          
          if(scoins < args[1]) return message.reply("You do not have enough coins")
          
          
          coins[message.author.id] = {
            coins: scoins - parseInt(args[2])
          }
          
          coins[puser.id] = {
            coins: pcoins + parseInt(args[2])
          }
          
          message.channel.send(`${message.author} has given ${puser} ${args[2]} coins`)
          
          
          fs.writeFile("./coins.json", JSON.stringify(coins), (err) => {
            if(err) console.log(err)
          })
        }
        
        break;
    }
  });```
sudden geyser
#

Unless I'm not seeing something, I think you're missing a } where you said it should end.

#

"No closing } here" as in you're missing another }

earnest phoenix
#

I always had a question on my mind and it's tumbling around in my head...
It's that how can make the bot find users/members with their usernames aside of mention or ID...?

lyric mountain
#

@earnest phoenix get user array and filter by name

earnest phoenix
#

Hmm...

quartz kindle
#

you can find members by username in members.fetch() as well

lyric mountain
#

Or use getUsersByName

earnest phoenix
#

@lyric mountain in which function?

lyric mountain
#

Idk, probably Tim's solution works better

#

He ninja'd me

earnest phoenix
#

Lol

queen needle
#

the one that says no closing isnt that a closing

quartz kindle
#

getUsersByName is not discord.js, maybe another lib

lyric mountain
#

Ik

earnest phoenix
#

Hmm true that

quartz kindle
#

not the IF

earnest phoenix
#

So like
await message.guild.members.fetch(f => f.user.username.toLowerCase().includes(args[0])) or something? @quartz kindle

quartz kindle
#

no

#

thats for .find()

earnest phoenix
#

Oh...

quartz kindle
#

will work fine for cached members

queen needle
#

so i need another braket

lyric mountain
#

The best way to find bracket errors is to format the code

#

If everything is not aligned, then you missed one somewhere

queen needle
#

well if im missing one then why when i add one do i get a error

quartz kindle
#

@earnest phoenix if the member is cached, use .find()

#

if the members you want are not cached, then this

queen needle
#

if i add a bracket i get a error

earnest phoenix
#

All will be cached but I'm still wondering like find them with this?:
await message.guild.members.cache.find()
?

quartz kindle
#

@queen needle you need to remove whatever bracket you added before

#

basically your brackets are in the wrong place, you need to remove the wrong one to add that one

lyric mountain
#

@queen needle you can't simply add one anywhere

#

You gotta find the right place to add it

quartz kindle
#

@earnest phoenix cache functions are not async, not need to await them

earnest phoenix
#

Oh ok

queen needle
#

well if i try to add it after the ```if(!coins[puser.id]){
coins[puser.id] = {
coins: 0

      };``` i  get a error or after the break or before the break
earnest phoenix
#

But I'm confused about what to put inside the find() function lol (to find them by their username) @quartz kindle

#

Wait a second... Brb

quartz kindle
#

what you posted was fine

#

f => f.user.username.toLowerCase().includes(args[0])

queen needle
#

fixed it

lyric mountain
#

Dude

#

Plz

queen needle
#

sorry

#

but i fixed it

quartz kindle
#

gj

earnest phoenix
#

@quartz kindle wait that function i wrote was good?

quartz kindle
#

yeah looks fine

earnest phoenix
#

K lemme try it...

#

@quartz kindle wait...
Will the ones like this that includes 3 things like:
let user = message.guild.members.cache.find(m => m.user.username.toLowerCase().includes(args[0]) || bot.users.cache.get(args[0]) || message.author;
Work or only the ones that include 2 of them works?

lyric mountain
earnest phoenix
#

OK

quartz kindle
#

cant use .get because its not an id

#

and you didnt properly close the .find

#

but yes, you can do guild.members.cache.find(m => m.user.username.includes()) || bot.users.cache.find(u => u.username.includes())

#

although its kinda redundant, because if the member exists, the user will also exist

#

so it should be safe to find only from users

queen needle
#
    if(args[1] === message.author.id) return message.reply("You can not give coins to yourself")```
#

i can still give coins to myself?

sudden geyser
#

what did you pass as args[1]

queen needle
#

a person

sudden geyser
#

as in the text

queen needle
#

wdym

#

like in the message i sent what was in the place of args[1]

sudden geyser
#

what did you pass when you ran the command (e.g. !annoy 264811613708746752)

queen needle
#

oh

#

^give @queen needle 10

sudden geyser
#

yeah see

#

that's a mention

queen needle
#

i checked for the i

#

did

sudden geyser
#

mentions look like <@userid> with a ! if the member has a nickname

queen needle
#

id

#

<@message.author>

sudden geyser
#

What you're really comparing is <@userid> === userid

queen needle
#

i thought it would be $@{message.author}

quartz kindle
#

wat

queen needle
#

what would i use to make it so i cant mention myself

quartz kindle
#

if your command only accepts mentions, then use something like message.mentions.users.first()

#

if your commands accept both mentions and ids, you can use a replace function with a regex for numbers only like .replace(/\D/g,"")

queen needle
#

well like args 1 is the first user that was mentioned

#

so

#

if(args[1] === what would go here to make it so i cant mention myself

quartz kindle
#

but args[1] is not a mention, its just the mention in text form

#

if you use message.mentions.users.first() you use the mention object which gets the id for you

queen needle
#
   let puser =
        message.guild.member(message.mentions.users.first()) ||
        message.guild.members.get(args[1]);```
#

so

earnest phoenix
#

Just do

if (CoinM.id === message.author.id){
return message.channel.send("blah blah blah");
}```
queen needle
quartz kindle
earnest phoenix
#

Yup

queen needle
#

thank you it worke

earnest phoenix
#

@queen needle
Also that one on the bottom should use the cache function before the get(args[0])

#

Np

queen needle
#

time to try to do a xp system

earnest phoenix
#

Good luck

queen needle
#

cries

#

and then a custom prefix system

lyric mountain
#

Waitaminute

#

Custom prefix is something almost initial nowadays

#

Just make a simple table in sqlite

#

Even json db would do it

slate oyster
#

It told me I had a free quota
The site said nothing about having to enable billing

#

Looks like I can't use that API then

#

Would have been nice had the site told me before I put it in my code

grizzled raven
#

for anyone who used rethinkdb before, which is better rethinkdbdash or rethinkdb-ts?

autumn quarry
#

The type thing you just need to call the typing method
@lyric mountain How do I do that?
I already know how to delay it, so we don't need to go over that

lyric mountain
#

@autumn quarry in jda I just call sendTyping() method

#

There must be something similar in js

slate oyster
#

So because it won't let me use the API, I can't have my bot filter data
Would have been nice if the site had told me that I had to enable billing before
Rather than telling me I had an already-available quota

autumn quarry
#

oh

queen needle
#

@lyric mountain im using json

lyric mountain
#

You're not connecting to it anywhere in that code

rare mist
#

true

sick cloud
#

@grizzled raven rethinkdbdash

#

over everything else

grizzled raven
#

yeah at first i thought it was slightly outdated but then i looked at it's docs and realised it makes way more sense that rethinkdb-ts

#

or rethinkdb lol

sick cloud
#

it also has promises

#

await thing over thing.run()

grizzled raven
#

rethinkdb has promises too, if you dont specify a callback

#

but one key thing is that you dont have to have conn as a param when using query.run()

sick cloud
#

yep

#

it also does cursor to array by default

grizzled raven
#

and that

lyric mountain
#

Why are you writing in alternating caps?

spring dagger
#

The bot does not join the vOicE ChANnEl hElP
how did u define voiceChannel?

earnest phoenix
#
const db = require("megadb");
const warns = new db.crearDB("warns");

module.exports = {
  nombre: "check",
  alias: [],
  categoria: 'Moderación',
    run: async (client, message, args) =>{
 
       
      
  const user = message.mentions.users.first() || message.author; 
  if (!user) return message.channel.send("Mencione a un usuario porfavor");
      
  if(!warns.tiene(`${user.id}`)) {
  warns.establecer(`${user.id}`, 0);}     
    
  let cantidad = await warns.obtener(`${user.id}`);   
      
  const embed = new Discord.RichEmbed()
    .setTitle("Strikes de: **" + user.username + "**")
    .addField("Cantidad de advertencias:", cantidad)
    .setColor("#13ec12")
    .setTimestamp();
  message.channel.send(embed);
    }
}

I have this command, but it doesn't show how many strikes the person has

#

Any ideas why it doesn't work?

spring dagger
#

show me the full code, since i can't help you with that screenshot u took earlier

#

@vivid cargo try voiceChannel.join()

#

no?

#

just add voiceChannel.join() after that permission check

earnest phoenix
#

are you in v12

spring dagger
#

he is

earnest phoenix
#

ok

pallid marsh
#

um hey so its about my time to prepare for sharding cuz i have like 1.3k server now...
the lib i use is discord.js. i saw alot of people that is using external libs and not the default one off discord.js.
is that worth a look? and if it is, what lib?

earnest phoenix
#

@vivid cargo you didn't make the bot join the channel

#

run what tuan said

#

he gave you the function

#

jesus

lyric mountain
#

Stop alternating caps dude

spring dagger
queen needle
#

can someone help me it doesnt change the prefix it still uses the normal prefix

spring dagger
#

what

earnest phoenix
#

What did i just see

#

[Eyes glow red]

spring dagger
#

jeez

earnest phoenix
#

i need

queen needle
earnest phoenix
#

to

#

Put
voiceChannel.join()
Under that permission check in the bottom @vivid cargo

#

kill mysel

#

@vivid cargo this has nothing to do with permissions

#

Sorry i don't speak enchantment table

lyric mountain
#

N WORD

earnest phoenix
#

Saying the n word i see

#

@lyric mountain Should we go easy on him?

lyric mountain
#

WE HAVE 23-19 HERE

earnest phoenix
#

Uhh

#

Whay

#

*what

lyric mountain
#

Lol who doesn't know what 2319 means

#

Anyway

earnest phoenix
#

[Visible CONFUSION]

lyric mountain
#

@vivid cargo don't use the n-word

earnest phoenix
#

Bruh

#

.....

lyric mountain
#

<@&364144633451773953>

queen needle
earnest phoenix
#

I feel a ban coming

#

[EYES GLOW RED]

#

😂😂

lyric mountain
#

N word case

earnest phoenix
#

Got banned... Nice

lyric mountain
#

I warned him

ember atlas
#

Handled. No need to ping the whole role for it tho. One person is enough.

lyric mountain
#

Ok boss

spring dagger
#

lmao he got banned

earnest phoenix
#

I think we should mute them for at least 3 days and make them understand to not use it again instead of banning them in the first time lmao

#

I mean

#

He was warned

#

But if it happens again just ban

lyric mountain
#

Yeah i guess

earnest phoenix
#

Warned by banning?

#

No he was tagged and told not to use it

ember atlas
#

We moderate at our discretion and using the n-word is strictly prohibited here. If you don’t need any development help, please leave this channel.

queen needle
#

cough cough

earnest phoenix
#

Uh... Ok...

crimson vapor
#

N-word very against tos therefore ping all mods is ok

queen needle
ember atlas
#

Ya I realized that. Again please stick to the channel topic.

crimson vapor
#

Sir yes sir

lucid pasture
#

yo, so i got all of the code to use the api, but i cant find any good apis to use for memes, does anyone have suggestions?

sudden geyser
#

reddit

remote yacht
#

random-puppy

lucid pasture
#

how would i get it from reddit?

earnest phoenix
#

@lucid pasture best module to use to fetch memes from Reddit is snek-fetch

sudden geyser
#

snekfetch is deprecated.

#

use node-fetch instead.

spring dagger
#

^

sudden geyser
#

any http library works but that's not the point

lucid pasture
#

ok thanks! but how should i get a link to do so

earnest phoenix
#

@sudden geyser how can i use the snekfetch then lol?

sudden geyser
#

because it's deprecated

#

it doesn't mean you can't use it

earnest phoenix
#

Hmm

sudden geyser
#

it just means it won't receive updates/disbanded

#

like request was recently marked as deprecated on npm

earnest phoenix
#

Hmm

#

Anyway

pallid marsh
#

hey um if i looped through all the shards and found the guild, do i need to loop through all the shards to find a member from this guild? or the member is in the cache already?

lucid pasture
#

so how do i get a link to the api?

earnest phoenix
#

To the module you mean? Or what? @lucid pasture

lucid pasture
#

uhh just to pull random images or however that works

earnest phoenix
#

npm install node-fetch

#

Then

#

Just store in some random subreddits and Math.random() it so it would choose a random subreddit then pull the image...
However... Idk how node-fetch works...

lucid pasture
#

so i got all of the fetch stuff but how should i store the subreddits

earnest phoenix
#

in an array

#

then when pulling a meme

#
"meme",
"dankmemes",
"other",
"Other"
];```
 @lucid pasture
#

take a random subreddit out of the array

lucid pasture
#

ok so if i put that code into a math.random, it would choose between those and then post an image from a random link?

lyric mountain
#

you gotta put math.random in that

#

actually it'd be math.random() * array.length

earnest phoenix
#

your array should be a const variable somewhere and not inside of a function otherwise you'll be creating the variable every time the function is ran which is a nono for your memory

lucid pasture
#

tbh thanks for you guys help but im just gonna watch a video on it

earnest phoenix
#

micro optimization™️

#

lol

#

@lucid pasture lmao...
Good luck

slow cape
#
if(message.content.startsWith(`${p}mute`)) {
  
    if(!message.member.hasPermission("MANAGE_MESSAGES")) return message.channel.send("You do not have manage messages.")

    let toMute = message.guild.member(message.mentions.users.first()) || message.guild.member(args[0]);
    if(!toMute) return message.channel.send("You didn't specify a user!");
    if(toMute.id === message.author.id) return message.channel.send("You can't mute yourself.");
    if(toMute.roles.highest.position >= message.member.roles.highest.position) return message.channel.send("You cannot mute a member that has a higher or same role as you.")
    let role = message.guild.roles.cache.find(r => r.name === "FrontierMuted");
    if(!role) {
     try {
      role = await message.guild.roles.create({
       data: {
        name: "FrontierMuted",
        color: "#000000",
        permissions: []
      }
    });
    message.guild.channels.cache.forEach((channel) => {
      if (channel.type == 'text') {
        channel.updateOverwrite(FrontierMuted, {
          deny: ['SEND_MESSAGES', `ADD_REACTIONS`],
        })
    } else if (channel.type == 'voice') {
        channel.updateOverwrite(FrontierMuted, {
          deny: [`SPEAK`],
        })
        
    }

   })

      

      
   }catch(e) {
     console.log(e.stack);
   }
  }
   console.log(role);
   if(toMute.roles.cache.has(role.id)) return message.channel.send("This member is already muted!")

   await toMute.roles.add(role);
   message.channel.send("I have muted them.")
   return;
  
 }
#

for my mute command

#

it creates the role

#

but doesnt add any perms

#

anyone knows why

#

@ me if you have any ideas

turbid bough
#

so, console.log(role) outputs right?

#

in documentations i read, it says it does not need an await for the addRole

#

if you have .catch(console.error) with

slow cape
#

@turbid bough theres no error and it add the role

#

its jsut that the role does not mute the person

turbid bough
#

oh, then thats what you have to check with your server settings

slow cape
#

@turbid bough i did

#

the role is just a role that does nothing

turbid bough
#

or channel settings to be precise

slow cape
#

ye

turbid bough
#

hmm

slow cape
#

it doesnt have it there

turbid bough
#

does the bot have manage channels?

#

and manage roles?

#

cause you wouldnt be able to change role settings on a channel without those permissions (iirc)

slow cape
#

it has admin

turbid bough
#

so, the channel overrides are not getting applied right?

#

can you do a console.log on the if statements within the foreach?

slow cape
#

yes

#

@turbid bough how do i console log the if statements

turbid bough
#

just add one under the overrides

#

btw, where is FrontierMuted from?

#

in js channel.updateOverwrite(FrontierMuted, { deny: ['SEND_MESSAGES', `ADD_REACTIONS`], })

#

should it not be role?

abstract spruce
#

@daring sun How Do You Put A Discord Bot Online With Node.js

earnest phoenix
#

ask it nicely

placid vault
#

i tryed that but it's not working

ember atlas
#

what lib

amber fractal
placid vault
#

yea

amber fractal
#

Look at the code.

#

Lemme see the docs havent looked in a while

placid vault
#

i checked them

amber fractal
#

Is that latest?

placid vault
#

yea i think

#

i don't get errors in editor

#

but i get that

amber fractal
#

set_permissions is a function, not a property, but that isn't what you're looking for anyways

placid vault
#

i tryed has_permissions

amber fractal
#

D.py docs take forever to load on phone because it's one page

placid vault
#

rip

amber fractal
#

Try looking at channel.permissions_for(self) my phone literally cant load these docs because of how poorly it's made lmao

placid vault
#

if channel.permissions_for(self, send_messages = None):

#

?

amber fractal
#

Would be like channel.permissions_for(member).send_messages I think

#

Returns true or false

#

Wait

#

Are you trying to set perms or check them

placid vault
#

i need to return for None or True

warm marsh
#

It will return False or True

amber fractal
#

A permission is either given or not. I don't think it can ever be None

placid vault
#

ah ok

#

wait

#

False None True

#

None is when

#

u choose that

warm marsh
#

Never

placid vault
amber fractal
#

That's inherit

placid vault
#

and why this command is working

#

await ctx.channel.set_permissions(ctx.guild.default_role, send_messages=None)

#

It's none and it's working

amber fractal
#

Because you can set it to inherit

placid vault
#

i am speaking about channel perms

#

ok

warm marsh
#

Setting it to none sets it role defaults.

#

Either true or false

placid vault
#

okey

pallid marsh
#

um i get this error when im starting my bot with a selected amount of shards, cuz currently its spawnning me only one shard if i use the recommended amount.
any idea of how can i fix it?
erorr: Error [SHARDING_READY_DIED]: Shard 1's process exited before its Client became ready.
code:```js
const { ShardingManager } = require('discord.js');
const manager = new ShardingManager('./bot.js', { token: token});

manager.spawn(2);
manager.on('shardCreate', shard => console.log(Launched shard ${shard.id}));

high bough
#

How do I shard? Any help? The infos ive read are outdated

pallid marsh
#

lib?

high bough
#

um i get this error when im starting my bot with a selected amount of shards, cuz currently its spawnning me only one shard if i use the recommended amount.
any idea of how can i fix it?
erorr: Error [SHARDING_READY_DIED]: Shard 1's process exited before its Client became ready.
code:```js
const { ShardingManager } = require('discord.js');
const manager = new ShardingManager('./bot.js', { token: token});

manager.spawn(2);
manager.on('shardCreate', shard => console.log(Launched shard ${shard.id}));

@pallid marsh Same issue here

#

Discord.js

pallid marsh
#

oh

#

lol

#

discordjs.guide

high bough
#

Outdated

#

Not helping

pallid marsh
#

idk

high bough
#
(node:15833) UnhandledPromiseRejectionWarning: Error [TOKEN_MISSING]: Request to use token, but token was unavailable to the client.
    at Function.fetchRecommendedShards (/home/inspiralgt/node_modules/discord.js/src/util/Util.js:241:23)
    at ShardingManager.spawn (/home/inspiralgt/node_modules/discord.js/src/sharding/ShardingManager.js:175:27)
    at Object.<anonymous> (/home/inspiralgt/index.js:4:9)
    at Module._compile (internal/modules/cjs/loader.js:1147:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
    at Module.load (internal/modules/cjs/loader.js:996:32)
    at Function.Module._load (internal/modules/cjs/loader.js:896:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47
(node:15833) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:15833) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
```And this issue along with it
slow cape
#

@turbid bough u might be right

pallid marsh
#

if i use the recommended amount its working but what if ill need more than one shard?

high bough
#

Now, my cmd is flooded with shard death logs

#

Halpp

#
SyntaxError: Unexpected end of input
    at wrapSafe (internal/modules/cjs/loader.js:1063:16)
    at Module._compile (internal/modules/cjs/loader.js:1111:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
    at Module.load (internal/modules/cjs/loader.js:996:32)
    at Function.Module._load (internal/modules/cjs/loader.js:896:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47
(node:15896) UnhandledPromiseRejectionWarning: Error [SHARDING_READY_DIED]: Shard 0's process exited before its Client became ready.
    at Shard.onDeath (/home/inspiralgt/node_modules/discord.js/src/sharding/Shard.js:155:16)
    at Object.onceWrapper (events.js:422:26)
    at Shard.emit (events.js:315:20)
    at Shard._handleExit (/home/inspiralgt/node_modules/discord.js/src/sharding/Shard.js:371:10)
    at ChildProcess.emit (events.js:315:20)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
(node:15896) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 359)
#

@coral trellis Help

coral trellis
#

Check if your token is correct

high bough
#

It is

#

the second one is the bigger issue

#
const Discord = require('discord.js');
const config = require('./config.json')
const manager = new Discord.ShardingManager('./bot.js', {token: config.token});

manager.spawn();
manager.on('shardCreate', shard => console.log(`Shard ${shard.id} connected!`));
#

couldn't even spawn one

#

And it's flooding my console

amber fractal
#

What d.js version

high bough
#

12

amber fractal
#

It does say unexpected end of input at wrapSafe

#

Is that a file you require

#

At some point?

high bough
#

Yes

#

Wait

#

Id

#

Isk

#

Idk

#

Its discord.js's sharding

pallid marsh
#

can i pass a db connection to all the shards instead of creating a mysql connection for each shard?

amber fractal
#

@high bough can you tell me the output of node -v?

high bough
#

K a sec

#

I thinknits 13.x or 14.x tho

#

Wait

amber fractal
high bough
#

My internet is at 200kbps rn so its slow patience is needed

amber fractal
#

Seems like it was an issue with a node version at one point

#

Perhaps it resurfaced

high bough
#

I downgraded it to 12.x maybe

#

Nope its v13.12.0

pallid marsh
#

do u know how can i pass a connection to all the shards? @amber fractal

#

like a db connection

valid frigate
#

every process can have its own db connection

amber fractal
#

Run one db and form a new connection to the same db each shard

#

Idk of any other way

valid frigate
#

it shouldnt be any different from if you didnt shard your bot

pallid marsh
#

ok

high bough
#

@amber fractal 13.12.0

valid frigate
#

opening multiple connections shouldnt be an issue too much

pallid marsh
#

um as i see the ready event executed to each shard im creating, but i change my status on ready and i dont wanna change it everytime a shard is created cuz it can be an api abuse if i use alot of shards, then how can i make so it happens just when the bot starts?

#

and not like for each the amount of shards?

amber fractal
#

Each shard has seperate rate limits I'm pretty sure

#

Also

#

I believe each shard can have its own status as well

#

Don't quote me on that though

pallid marsh
#

rlly?

#

ok

#

ill see idk

high bough
#

Help

#

Ive been ignored T.T

amber fractal
#

Yes mb

icy crane
#

I don't want to be spoonfed, but could someone help me with setting a bots status to mobile? I don't really know where to start...

ember atlas
#

What lib

high bough
#

You cant

icy crane
#

djs

high bough
#

Set to mobile

ember atlas
#

Oh I see what you mean

#

Ya, you cannot set to mobile

#

Thought you meant the set the status in general

icy crane
#

wut, why are some bots on mobile then

#

lol

ember atlas
#

They arent

icy crane
#

...

high bough
#

Your cache has issues prob

icy crane
#

@quasi cloak what about that bot

#

its presence is mobile

amber fractal
#

Try to downgrade to node 12. @high bough (I really don't know if it will do anything, but it is the LTS)

icy crane
#

@ember atlas what about this @quasi cloak thats what I meant

stray wasp
#
INSERT INTO votes (`user`, `created_at`, `updated_at`, `vote_count`) VALUES ("33", current_timestamp, current_timestamp, 1) ON DUPLICATE KEY UPDATE votes SET `updated_at`= current_timestamp , `vote_count`= vote_count + 1 WHERE USER = "33";

Anyone know why this errors, both statements work without the ON DUPLICATE KEY UPDATE

pallid marsh
#

um wen i try to shard all of my shards are responding...

#

like i get a response 3 times

#

how can i fix it?

royal laurel
#

Do any of you guys have any suggestions of what i should add into my discord bot? It's based around moderation

stray wasp
#

nvm, I reread the channel title

#

sorry for the ping

slender thistle
#

-ideas

gilded plankBOT
#

Find something that you would like in a bot, and has also not been done before. Try and come up with a list of things you are interested in, and think up ways you could make the task easier with a discord bot. Eg. I like fishing -> I'm in a fishing discord group -> I'll make a bot that has fishing data and gives fishing advice. or I like a certain cartoon/anime/tv show. -> Why not make a bot that reminds me when new episodes are released and their watch dates? Once you have a fair amount of concepts down, try and look for those bots on bot listing sites like this one. If you cant find a bot that does what you laid out before as a bot concept, then feel free to write it! Who knows? Maybe a lot of people would like what you create...

royal laurel
#

kk

#

but see

#

i like coding

#

so do i make a bot that codes

#

YES
FUCK YES

#

ILL BE A SEC

stray wasp
#

machine learning?

royal laurel
#

yes

#

what i had in mind

stray wasp
#

a bot which learns to code

royal laurel
#

yes

stray wasp
#

thats, something I haven't seen yet

royal laurel
#

thatd be cool

#

but first gotta learn what machine learning is

#

lol

stray wasp
#

haha goodbye next 6 months.

amber fractal
#

More than

#

Machine learning takes forever on most machines

stray wasp
#

Oh I'm talking about learning it

amber fractal
#

Good ones train for a long long time

slender thistle
#

teaching

stray wasp
#

some guy on 2bt2 created a minecraft bot which trains on Mircosoft Azure with really highend graphic cards. (3k each)

earnest phoenix
#

(node:5856) UnhandledPromiseRejectionWarning: TypeError: client.guilds.forEach is not a function

#

why

stray wasp
#

guilds is a collection

#

map it

#

plus in the new version it's client.guilds.cache

pallid marsh
#

does some1 knows why all my shards respond at the same time when i execute a command?

stray wasp
#

@earnest phoenix

clear island
#

How could I get it if I mention my bot and the command name run it in discord.js v12?

earnest phoenix
#

okey i understand

pallid marsh
#

no one?

earnest phoenix
#

i download need 15.1.1

stray wasp
#

@clear island I'm confused, what are you referencing to?

#

are you trying to have your bot's mention as a prefix?

clear island
#

yes

stray wasp
#

check if your bot is mentioned within the message.

amber fractal
stray wasp
#

you can also use each()

#

a method which does the same thing but returns the collection instead of undefined.

clear island
golden condor
#

MySQL keeps disconnecting every minute causing my bot to restart all the time

#

Not sure how to fix it

pallid marsh
#

does some1 knows why all my shards respond at the same time when i execute a command?

amber fractal
#

It's <@id> (such as <@353782817777385472> but this wont account for nick names)

pallid marsh
#

like i got 3 shards so i get 3 responds

stray wasp
#

@golden condor is your MySql local?

pallid marsh
#

i watched this tutorial

golden condor
#

No

stray wasp
#

it's text @pallid marsh

golden condor
#

It's remote

stray wasp
#

You may be losing connection to the remote server

#

try it locally

pallid marsh
#

i followed every step

#

and its still responding 3 times

stray wasp
#

It's mostly best to have your database local anyway to keep latency down.

#

@pallid marsh show your sharding file

pallid marsh
#
const manager = new ShardingManager('./bot.js', { token: secrets.token});

manager.spawn();
manager.on('shardCreate', shard => console.log(`Launched shard ${shard.id}`));
earnest phoenix
#
 const db = require("megadb");
 const warns = new db.crearDB("warns");
 
 module.exports = {
  nombre: "check",
   alias: [],
   categoria: 'Moderación',
     run: async (client, message, args) =>{
 
 
      
   const user = message.mentions.users.first() || message.author; 
   if (!user) return message.channel.send("Mencione a un usuario porfavor");
       
   if(!warns.tiene(`${user.id}`)) {
   warns.establecer(`${user.id}`, 0);}     
     
   let cantidad = await warns.obtener(`${user.id}`);   
       
   const embed = new Discord.RichEmbed()
     .setTitle("Strikes de: **" + user.username + "**")
     .addField("Cantidad de advertencias:", cantidad)
     .setColor("#13ec12")
     .setTimestamp();
   message.channel.send(embed);
     }
 }

I have this command, but it doesn't show how many strikes the person has

stray wasp
#

@pallid marsh your starting that file only once correct?

pallid marsh
#

yes

copper cradle
#

@earnest phoenix what does the command show

earnest phoenix
#

In the console?

copper cradle
#

...

earnest phoenix
#

.___.

copper cradle
#

I never mentioned the console

#

When you run the command

#

what does it show

earnest phoenix
#

I need learn english.

stray wasp
#

@pallid marsh

earnest phoenix
#

Wait

stray wasp
#

give that a go

copper cradle
#

@earnest phoenix say it in spanish

earnest phoenix
#

sends the embed, but if a person has 5 strikes for example, it shows that he has 0

stray wasp
#

problem is I can't read spanish

#

so I don't really understand whats happening

pallid marsh
#

nop

copper cradle
#

lol

pallid marsh
#

still the same

copper cradle
#

what does warns.tiene return

stray wasp
#

@pallid marsh are you using latest?

pallid marsh
#

latest what

stray wasp
#

discordjs

pallid marsh
#

ill try

earnest phoenix
#

what does warns.tiene return
@copper cradle como?

copper cradle
#

what's the return value of it

#

console.log(warns.tiene()) and tell me what the console shows

earnest phoenix
#

The amount of strikes

#

Ok

#

Wait

copper cradle
#

I'm pretty sure values.tiene() doesn't return the amount of strikes, I guess it returns a bool

#

on wether or not the """""""""database""""""""" has the value in it

#

@earnest phoenix so

#

what did it show

obsidian sky
#

Can someone help me with making a ticket system in my bot, i want to find a channel by name in my server and if it is not found then create one with the name as the userid of the message author in dm of the bot and all further messages from the author should come in the text channel with his userid and if anyone types a message in the text channel of the user it sends a message to the userid in the channel name..... I am bad at explaining this and i am really dumb at programming.... Help me plzz or the bots will come to kill me...

ember atlas
#

Did you try to do it yourself?

obsidian sky
#

ummm yes for 2 days then i just gave up

#

i made a basic bot that does dm and stuff but i can't figure out the more complex stuff...

stray wasp
#

@obsidian sky

#

map/each through this collection. It returns a GuildChannel class for each channel which contains the name property

#

you can find mostly all you need within the docs.

#

If you're really not up for the task, you can probably find someone on fiverr or even get a job posted within #434058442764714002

obsidian sky
#

Thanks😅 @stray wasp

stray wasp
#

np

hidden canopy
#

Hi! I'm having some trouble with making a request to a REST Api

#

i was following along with the Discord.js guide on this

#

What i'm confused about is that.. fetch() is a promise? so why wouldn't await work on it?

stray wasp
#

you need to make the function async

#

async execute

hidden canopy
#

ohh

#

let me give that a shot

#

thanks

stray wasp
#

lul I tried

#

don't at me if I'm wrong weirdsip I never said a thing

hidden canopy
#

@stray wasp well imma @ you cause it worked

#

thanks man

stray wasp
#

HELLL YEAHHHH BROTHER

#

thank you. I feel better about myself now

hidden canopy
#

you're welcome weirdsip

wheat jolt
#

so I have an array with some chunks
[{pos: 0, size: 4, url: 'someurl'}, {pos: 4, size: 7, url: 'someurl'}, {pos: 11, size: 5, url: 'someurl'}, {pos: 16, size: 10, url: 'someurl'}, {pos: 26, size: 9, url: 'someurl'}, {pos: 35, size: 15, url: 'someurl'}]
What function can I use for .filter to get the chunks needed to get the bytes from pos 15 to pos 30?

earnest phoenix
#

just do object.pos >= 15 && object.pos <= 30?

wheat jolt
#

nah

earnest phoenix
#

uh... yes?

wheat jolt
#

from pos 15

#

not from 16

earnest phoenix
#

are you blind

wheat jolt
#

Probably

earnest phoenix
#

you don't have a pos 15 in your array

mossy vine
#

there is no object with pos 15 in there lmao

earnest phoenix
#

you have pos.16

wheat jolt
#

.-.

#

so I have an array with some chunks
[{pos: 0, size: 4, url: 'someurl'}, {pos: 4, size: 7, url: 'someurl'}, {pos: 11, size: 5, url: 'someurl'}, {pos: 16, size: 10, url: 'someurl'}, {pos: 26, size: 9, url: 'someurl'}, {pos: 35, size: 15, url: 'someurl'}]
What function can I use for .filter to get the chunks needed to get the bytes from pos 15 to pos 30?
read again

#

i know there is no obj with pos 15

earnest phoenix
#

????

wheat jolt
#

I want to get the elements to get the 15 byte too

#

so the element before the element with pos 16 too

slender thistle
#

But there's no element with pos 15 that you can get when filtering the array nekothinking

earnest phoenix
#

exactly lol

wheat jolt
#

again

earnest phoenix
wheat jolt
#

i don't want to get the element with pos 15. I want to get the elements needed to get the chunks with POSes between 15 and 30

mossy vine
#

but thats what the code is doing, you just dont have any more objects that fit the condition in the array

wheat jolt
#

I

#

don't

#

want

#

to use all elements

#

for my actual code

#

that array is much bigger

mossy vine
#

okay can you just tell us what the actual problem is that you are trying to solve?

earnest phoenix
#

yes and

wheat jolt
#

argh

earnest phoenix
#

just reduce the number from 15 to 7...?

wheat jolt
#

Let me explain from the start to the end.
I have an big array with elements as objects that have a pos, size and a download url property.
By fetching each element's download url then writing the data to a file will result to a bigfile.extension
I also get automatically a pos and a size of the only data I need from that bigfile. So, to not download all the chunks, I try to get only the needed elements from the big array needed for the data from pos to pos+size

#

It's hard to explain but I know what I want and what I'm doing

earnest phoenix
#

and this is ladies and gents xyproblem in it's true form

wheat jolt
#

thanks

#

I wanted to explain what the heck I want to do

earnest phoenix
#

you have to fetch the element before too, take the last byte the response (which is at pos 15) and then you can continue what you were doing, if the last element is not at pos 30 you'll also have to fetch the next element from the last one and grab the amount of bytes needed to get to 30

wheat jolt
#

I said I don't want to fetch the element

#

the max size for Buffers is 2gb

#

around 2gb

earnest phoenix
#

too bad you have to

wheat jolt
#

I don't

earnest phoenix
#

there's no other way going around it, you need to fetch those two extra elements to get missing bytes

earnest phoenix
#

help me

#
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL('', client);
  dbl.hasVoted(`message.author.id`).then(voted => { 
    `Please vote for the bot to use this command` 
  })```
#

this command can be used by non-voters also

#

please help

#

please me if you can help

wheat jolt
#

@earnest phoenix show your code

earnest phoenix
#

please help me also

#

@earnest phoenix you're passing straight up a string

#

so what should i do ?

#

take a guess

#

idk

slender thistle
#

Does an ID message.author.id exist

#

Literally that

earnest phoenix
#

we love it when help vampires don't want to use their brain 🙈

valid frigate
#

i'm trying to figure out what to send in ws in eris' client options to get a mobile status on my bot

#

there's no information on what to send and i've looked around, how do i do this?

#

tried sending this already as well

              ws: {
                properties: {
                    $browser: "Discord iOS",
                    $os: "darwin"
                }
            }
earnest phoenix
#

he tell me

slender thistle
earnest phoenix
#

but it shows error if i remove it

slender thistle
#

because you don't have a message object

hidden canopy
#

could someone help me implement a bearer authentication scheme in my header

#

i've been trying to use fetch

earnest phoenix
#

@valid frigate i dont think that is what the ws property is for

valid frigate
#

yeah i didnt think so either

earnest phoenix
valid frigate
#

i went off of a youtube video around how to do it in djs

slender thistle
#

Where are you going to get a message from

valid frigate
#

supposedly it also has a ws option you can pass to the client

#

i thought it would have worked the same

earnest phoenix
#

i need author id @slender thistle

slender thistle
#

And if there's no message, there's no author

#

And where do you think you can get a message object

#

I need you to think here for a sec

earnest phoenix
#

then who will use command ?

slender thistle
#

on which event do you execute commands?

earnest phoenix
#

??

slender thistle
#

hint: you receive messages

earnest phoenix
#

i giveup

#

tell me answer

hidden canopy
slender thistle
#

You aren't even trying, are you...

#

message event

earnest phoenix
#

help vampire lol

slender thistle
#

You're trying to access a message object where it doesn't exist

#

Think of trying to find an apple in a store that sells only soup. nekothinking

earnest phoenix
#

so what should ido ?

slender thistle
#

applying logic...

#

Put your code snippet inside the message event?

earnest phoenix
#

ok

#

ohh i got it

#

you mean i forget to add ${}

slender thistle
#

What's the point

#

Considering IDs are string anyway

earnest phoenix
#

to give error if non voter is using the command

#

you need to be able to logically resolve problems yourself, the whole point of programming is being able to do it yourself, to use your own brain to resolve a logical problem however you want - this is a simple structural issue which can be resolved in about a thousand ways, if you can't think of a correct one yourself, well,

#

train yourself to use common sense and logic to resolve problems

slender thistle
earnest phoenix
#

what did you want to say

copper cradle
#

not everyone should code

valid frigate
#

bruh

earnest phoenix
#

slonk so i should stop codding

copper cradle
#

you decide ¯\_(ツ)_/¯

earnest phoenix
#

ok i decided

#

to stop listening to idiots

copper cradle
#

coding requires logic and mostly common sense

#

and calling us idiots won't help

#

nor give you those I mentioned

finite bough
#

@earnest phoenix what do u need help with

#

I will try to help if I can

earnest phoenix
#

@finite bough const Discord = require("discord.js"); const client = new Discord.Client(); const DBL = require("dblapi.js"); const dbl = new DBL('', client); dbl.hasVoted(`message.author.id`).then(voted => { `Please vote for the bot to use this command` }) command can be used by non voters also what should i do ?

summer torrent
#

if (!voted) ...

finite bough
#

^

#

!voted means not voted

#

and !== is not equals to

earnest phoenix
#
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL('', client);
  if(voted(`message.author.id`)).then(voted => { 
    `Please vote for the bot to use this command` 
  })``` @finite bough like this ?
finite bough
#

nah

earnest phoenix
#

then ?

finite bough
#

can u tell me what exactly u r trying to do if possible

summer torrent
#
dbl.hasVoted(message.author.id).then(voted => { 
   if (!voted) return message.channel.send(`Please vote for the bot to use this command`)
})```
earnest phoenix
#

don't spoonfeed

finite bough
#

@earnest phoenix if(!voted) means if not voted

#

please understand the code before using it

#

it will help u in future

earnest phoenix
copper cradle
#

learn about scopes and functions

finite bough
#

define message

copper cradle
#

that'll help you

earnest phoenix
#

How can i get a bot's guild names that the bot is in them?
discord.js 12.1.1

copper cradle
#

and to use a message object you must define it some way, aka put the thing inside a message event

earnest phoenix
copper cradle
#

as I said

earnest phoenix
#

@finite bough what should i define message ?

copper cradle
#

I don't really care what you call me

slender thistle
#

It's not idiocy

#

They're giving you an advice how to prevent situations like this in the future

golden condor
#

mysql db keeps disconnecting in node.js

finite bough
#

@earnest phoenix map

golden condor
#

I don't know how to fix

finite bough
#

client.guilds.map(..)

earnest phoenix
#

@finite bough k thx... I got it

finite bough
#

@golden condor any errors

golden condor
#

Yes

earnest phoenix
#

@finite bough also cache is needed

finite bough
#

show me senpai

#

@earnest phoenix oh 12v yea bloblul

earnest phoenix
#

@finite bough please tell what should i define message as

#

Lol

slender thistle
#

You don't define message

earnest phoenix
#

then ?

slender thistle
#

You get it from an event that sends message

earnest phoenix
#

@earnest phoenix maybe put that event inside a message event?

slender thistle
#

and I remember telling you which event it is

golden condor
#
error when connecting to db: Error: Cannot enqueue Handshake after already enqueuing a Handshake.
    at Protocol._validateEnqueue (/home/cxllm/Bots/Corynth/node_modules/mysql/lib/protocol/Protocol.js:221:16)
    at Protocol._enqueue (/home/cxllm/Bots/Corynth/node_modules/mysql/lib/protocol/Protocol.js:138:13)
    at Protocol.handshake (/home/cxllm/Bots/Corynth/node_modules/mysql/lib/protocol/Protocol.js:51:23)
    at Connection.connect (/home/cxllm/Bots/Corynth/node_modules/mysql/lib/Connection.js:116:18)
    at Timeout.handleDisconnect [as _onTimeout] (/home/cxllm/Bots/Corynth/db/con.js:20:14)
    at listOnTimeout (internal/timers.js:549:17)
    at processTimers (internal/timers.js:492:7) {
  code: 'PROTOCOL_ENQUEUE_HANDSHAKE_TWICE',
  fatal: false
}```
@finite bough
earnest phoenix
#

@earnest phoenix can you see my full code ?

#

Hmm... Up there? @earnest phoenix

slender thistle
#

They don't have to see your full code if all you need to do is paste your code snippet into an event

earnest phoenix
#

@earnest phoenix thats my whole code

golden condor
#
var mysql = require('mysql');
var con = mysql.createConnection({
  host: '',
  user: '',
  password: '',
  database: ''
});
con.connect(function (err) {
  if (err) {
      console.log(`Db failed to connect Ouput:${err.message}`);
      setTimeout(con.connect, 2000);
  }
});
con.on('connect', () => {
  console.log(`Connected!`)
})```
#

this is my code for connecting to mysql

#

it connects then disconnects after a certain time

earnest phoenix
#

you arent meant to stay connected

golden condor
#
Error: Connection lost: The server closed the connection.
    at Protocol.end (/home/cxllm/Bots/Corynth/node_modules/mysql/lib/protocol/Protocol.js:112:13)
    at Socket.<anonymous> (/home/cxllm/Bots/Corynth/node_modules/mysql/lib/Connection.js:94:28)
    at Socket.<anonymous> (/home/cxllm/Bots/Corynth/node_modules/mysql/lib/Connection.js:526:10)
    at Socket.emit (events.js:323:22)
    at endReadableNT (_stream_readable.js:1204:12)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)
Emitted 'error' event on Connection instance at:
    at Connection._handleProtocolError (/home/cxllm/Bots/Corynth/node_modules/mysql/lib/Connection.js:423:8)
    at Protocol.emit (events.js:311:20)
    at Protocol._delegateError (/home/cxllm/Bots/Corynth/node_modules/mysql/lib/protocol/Protocol.js:398:10)
    at Protocol.end (/home/cxllm/Bots/Corynth/node_modules/mysql/lib/protocol/Protocol.js:116:8)
    at Socket.<anonymous> (/home/cxllm/Bots/Corynth/node_modules/mysql/lib/Connection.js:94:28)
    [... lines matching original stack trace ...]
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  fatal: true,
  code: 'PROTOCOL_CONNECTION_LOST'
}```
earnest phoenix
#

connect, execute query, disconnect

golden condor
#

Yeah but it exits the code

earnest phoenix
#

like i saof

#

said*

#

you aren't meant to stay connected

finite bough
#

^

golden condor
#

yeah i understand that

earnest phoenix
#

@earnest phoenix i think you should put that event under a message event... That should define the message automatically

#

your code is built expecting to stay connected

golden condor
#

But it then exits the code

finite bough
#

u should disconnect after the end of a code

#

people dont do it

#

but

#

its a good practice

#

says the docs bloblul

earnest phoenix
#

@earnest phoenix hmm now it dont show error

golden condor
#

Yeah but I need the code to stay on

#

For me

#

bot

earnest phoenix
#

lemme test now

#

@earnest phoenix but it works?

finite bough
#

u can connect when u need to connect

earnest phoenix
#

why are you depending on a database connection to block your app from exiting lol

golden condor
#

What I wanna do

#

Is on a message

finite bough
#

use mongodb then lmao

golden condor
#

How do I use mongo

#

lmfao

finite bough
#

go to their website

golden condor
#

I never used dbs other than sql

#

I mean I've tried mongo

finite bough
#

mongo is easier than SQL

golden condor
#

Cos I wanna connect to a remote db

finite bough
#

yea

earnest phoenix
#

they don't need to migrate

finite bough
#

mongo atlas is a remote dh

#

db

golden condor
#

Ya but it isn't gonna be hosted on the same machine

finite bough
#

if u use local host

#

like

golden condor
#

Ya that's what I am saying

finite bough
#

mongoose.connect(local host)

#

or something like that

golden condor
#

Should I install mongodb compass on linux?

earnest phoenix
summer torrent
#

no

#

that is GUI

golden condor
#

Or should I connect to a remote db

earnest phoenix
finite bough
#

mongodb compass helps u to see ur data

golden condor
#

with atlas

earnest phoenix
#

Hmm... Can i see your code now? @earnest phoenix

finite bough
#

I would recomend downloading it

earnest phoenix
#

can i dm you ?

finite bough
#

u can also manipulate with the data manually using compass

earnest phoenix
#

@earnest phoenix sure

golden condor
#

I have compass

#

On my main pc

finite bough
#

ok make acc

golden condor
#

Not where my bot is hosted

finite bough
#

just download it then

golden condor
#

I have it

finite bough
#

wrll

#

well

#

tbh

golden condor
#

On my pc

finite bough
#

it doesnt matter

golden condor
#

I wanna use mongo

finite bough
#

u can see ur data from ur pc as well

golden condor
#

k

finite bough
#

ok do u have an acc?

golden condor
#

I have made one with my google acc

finite bough
#

yea fair enough

golden condor
#

You wanna take this to dms or something?

finite bough
#

make a cluster

#

no I need mah message count high

golden condor
#

Already have

finite bough
#

:3

golden condor
finite bough
#

connect to it then

#

brb

golden condor
flat pelican
#

@earnest phoenix Don’t attack beginners. Suggesting to « use their brain » or to « stop coding » doesn’t helps here. If you don’t have enough patience to explain things to people starting to learn programming, please mute this channel or don’t reply to people asking very basic questions. Thanks.

earnest phoenix
#

you're putting words in my mouth

golden condor
#

To be fair, he didn't say that (to me at least)

earnest phoenix
#

they're a help vampire and there's no other way to help other than either spoonfeeding or encourage them to think for themselves

finite bough
#

@golden condor connect app

#

wait

earnest phoenix
#

encouraging help vampirism is the worst thing you can do in development, and that was 40 minutes ago damn you are fishing

finite bough
#

uhhhhhh

#

brb @golden condor

golden condor
#

Shouldn't I connect compass?

finite bough
#

gotta get on my pc

#

so I can show it to u easily

golden condor
#

Should I get mongoose or mongodb in npm

#

@finite bough where do I find the password for the cluster

flat pelican
#

We neither encourage spoonfeeding, and people doing that will be warned aswell. However, please try, instead of attacking them, to redirect to correct ressources. I can understand that they can leave it with a « I don’t understand », « It’s hard » or « Can you show me first how you do it? ». In this kind of situations, you can simply try to explain that they need to learn themselves and understand their mistakes. People begging for codes or looking for spoonfeeding even after warnings will be muted 👍

golden condor
#

We neither encourage spoonfeeding, and people doing that will be warned aswell. However, please try, instead of attacking them, to redirect to correct ressources. I can understand that they can leave it with a « I don’t understand », « It’s hard » or « Can you show me first how you do it? ». In this kind of situations, you can simply try to explain that they need to learn themselves and understand their mistakes. People begging for codes or looking for spoonfeeding even after warnings will be muted 👍
@flat pelican ❤️

#

Mongo won't let me connect to the cluster aa

flat pelican
#

❤️

finite bough
#

@golden condor ok back

#

sorry i was taking a shower

golden condor
#

that's fine

#

I am in no rush

#

ok

#

I used the sample code to connect

#

and it worked

flat pelican
#

@summer torrent This channel is intended to help people, please don’t spoonfeed (giving the code directly instead of explaining the error is called spoonfeeding).

finite bough
#

@golden condor add these { useNewUrlParser: true,
useUnifiedTopology: true}

golden condor
#
const MongoClient = require('mongodb').MongoClient;
const uri = "My login stuff";
const client = new MongoClient(uri, { useNewUrlParser: true });
client.connect(err => {
  const collection = client.db("test").collection("devices");
  console.log(collection)
});``` i did this
summer torrent
#

I tried to show him an example, but okay

finite bough
#

also add
useUnifiedTopology: true