#development

1 messages · Page 1058 of 1

earnest phoenix
#

this is long time bro :d

obtuse jolt
#

you're telling me

earnest phoenix
#

where are you from?

obtuse jolt
#

uk

earnest phoenix
#

tr

obtuse jolt
#

@quartz kindle im trying to move to mysql and it seems to be easier to get the information and i dont have to remake much because it allows json styles data sets is this good or bad? https://cdn.vurighosting.com/u/TFPpnl.png

#

the end scanid is a visual glitch

misty sigil
#

client.cache.channels.get() to get a channel, right?

earnest phoenix
#

no

#

client.guilds.cache.get('channelname').channels.cache.get('channelid')

misty sigil
#

yea

#

i knew the other way round

quartz kindle
#

@obtuse jolt its not json style

#

its tabular data, tables and columns, thats how SQL works

obtuse jolt
quartz kindle
#

yes, but its completely different

#

for example, you cant have nested structures

#

json can have objects inside objects, sql cant

earnest phoenix
#

2 different guilds might have same channelid

#

so yea

quartz kindle
#

i mean

obtuse jolt
#

how would that be possible

modest maple
#

i dont think they can

obtuse jolt
#

it would destroy the point of client.channels.get

quartz kindle
#

in the end its still data storage, so there are similar concepts everywhere, but you have to approach SQL with a different mind set

misty sigil
#

thats impossible

modest maple
#

Ids are 100% unique regardless of if its a diffrent guild

quartz kindle
#

2 guilds cant have the same channel id

crimson vapor
#

You can’t have objects in objects SQL?

#

in*

quartz kindle
#

not out of the box

#

although postgre does have extensive tooling for json structures

#

mysql only has it in newer versions

#

or as an extension

#

usually when interoping json with sql, one would stringify the json, and store it as text

#

thats what i do

tulip ledge
#

ReferenceError: Cannot access 'Boss' before initialization Boss is a class and is created in the SAME else statement where I'm making the new Boss object

quartz kindle
#

show code

modest maple
#

@quartz kindle Actually postgre still does the string and load method

quartz kindle
#

also why create a class on the fly like that

crimson vapor
#

Send pic of code, we cannot see the issue without seeing what you did

modest maple
#

it just has a c based codec now which usually does it automatically

tulip ledge
#

Ok but I'm gonna cut out all the code in between

#

I dont get why

#

As the bracket of else {} goes all the way down

crimson vapor
#

I’m not that good with classes but I think you need to define it before you call it

pure lion
#
                const filter1 = m => m.content === '1' || m.content === '2' || m.content === '3' || m.content === '4'
                const f = m => m.content

                tChannel.awaitMessages(filter1, {
                    max: 1
                }).then(async collected => { 
                    if (collected.first().content === '1') {
                        e1.delete()
                        let e2 = await tChannel.send(salesQ1embed)
                        tChannel.awaitMessages(f, {max:1})
                        .then(c => tickets.set(`tickets.${msg.guild.id}.user`, {
                            type: 'sale',
                            questions: [c.first().content]
                        }))
                        .then(tChannel.send(salesQ2embed))
                        tChannel.awaitMessages(f, {max:1})
                        .then(c => tickets.push(`tickets.${msg.guild.id}.user.questions`, c.first().content))
                    }
                })

it sends 2 message embeds without waiting for the messages

tulip ledge
#

But it worked before

#

I added the if() {} else {}

quartz kindle
#

techinically

#

classes work the same way as const and let

#

they are partially hoisted and depend on context and scope

#

but idk why would you wanna do that

tulip ledge
#

So I move the class up?

quartz kindle
#

classes are supposed to be defined somewhere like a blueprint, not declared on demand

crimson vapor
#

Or move It to a different file

tulip ledge
#

thats so weird

#

That it used to work

#

And now I had to move it up

misty sigil
#

Do I just use my VPS IP?

crimson vapor
misty sigil
#

wait yes oof

crimson vapor
#

LOL

obtuse jolt
#

@quartz kindle would this work?

client.queue.on('empty', function (){
    connection.connect(function(err) {
        if (err) {
          console.error('error connecting: ' + err.stack);
          client.channels.get("726960119929241631").send("DATABASE ERROR DETECTED: " + err.stack)
          return;
        }
    });

    connection.query('truncate manualScans')
    console.log("-----------------------------------")
    console.log("Queue Database Cleared")
    connection.end(function(err) {if(err) console.log(err)});
})```
quartz kindle
#

idk

marble juniper
quartz kindle
#

most of that seems to be custom code, so no way of knowing

obtuse jolt
#

will the truncate bit work?

#

also it only saves the first 10 numbers of the channel id and i cant find out why

quartz kindle
#

you need to store IDs as strings/text

#

not as numbers

#

the truncate command depends on the sql version

#

some dbs accept TRUNCATE mytable
others require TRUNCATE TABLE mytable

north hollow
#

I need help for a error

misty sigil
#

KEKW just make it async

quartz kindle
#

async execute

marble juniper
#

put async before execute

#

done

north hollow
#

Ok thx

obtuse jolt
#

epic it works

north hollow
#

@obtuse jolt can you show me

obtuse jolt
#

what

summer torrent
#

what is that

obtuse jolt
#

mysql

stark abyss
#

what is
TypeError: (intermediate value).setColor(...).setTitle(...).description is not a function

obtuse jolt
#

its setDescription

#

not description

stark abyss
#

okay thank you

north hollow
misty sigil
#

wat

obtuse jolt
#

wat

misty sigil
#

no

north hollow
#

How

misty sigil
#

async module.exports

north hollow
#

I ok thx

#

So like this

misty sigil
#

I think yes

#

or remove the async from there and put it async execute instead of just execute

obtuse jolt
#

how do i get a message in v11

#

like channels.get but for message IDs

north hollow
misty sigil
#

ok

#

so take away that async

#

and put it next to execute, so it says async execute

spiral prawn
#

If you're hosting a Discord bot on Heroku then

#

don't

north hollow
#

@misty sigil

obtuse jolt
#

omg they are

#

there are lots of other hosts

misty sigil
#

remove all the asyncs

#

then put one next to execute

#

so it says async execute

north hollow
#

Here my hole code

#

async exports = {
name: 'dogs',
description: 'Dogs!',
execute(message, args) {
const command = message.content.toLowerCase();
if(command === Prefix + 'dogs') {
let msg = await message.channel.send("Fetching");
fetch('https://dog.ceo/api/breeds/image/random')
.then(res => res.json())
.then(json => {
let embed = new Discord.MessageEmbed()
.setTitle('Woof , Woof')
.setImage(json.message)
.setTimestamp()
.setFooter(message.author.tag,message.author.displayAvatarURL());
msg.edit(embed)
})
}
},
};

pure lion
#

h o l e

#

use code blocks please

#

```js

code

```

north hollow
#

Am on phone

#

That y

tulip ledge
#

The execute function needs to be await

#

async execute(message, args)

north hollow
#

This is for a command handler that’s why

misty sigil
#
 module.exports = {
    name: 'dogs',
    description: 'Dogs!',
    async execute(message, args) {
        const command = message.content.toLowerCase();
        if(command === Prefix + 'dogs') {
          let msg = await message.channel.send("Fetching");
          fetch('https://dog.ceo/api/breeds/image/random')
              .then(res => res.json())
              .then(json => {
                  let embed = new Discord.MessageEmbed()
                      .setTitle('Woof , Woof')
                      .setImage(json.message)
                      .setTimestamp()
                      .setFooter(message.author.tag,message.author.displayAvatarURL());
                  msg.edit(embed)
      })
      } 
    },
};```
north hollow
#

I am so dumb

tulip ledge
#

Pretty sure your name is S O B B A tho

earnest phoenix
#

Does anyone know how to code a discord.js bot to send a dm to someone you pinged?

misty sigil
#

why does everyone here have great dad jokes

tulip ledge
#

Just get the member object and run a .send on that

misty sigil
#

Does anyone know how to code a discord.js bot to send a dm to someone you pinged?
@earnest phoenix 1. get user pinged (message.users.mentions.first())

  1. then .send().catch(e)
earnest phoenix
#

Ok

misty sigil
#

Just get the member object and run a .send on that
@tulip ledge isn't it user object?

tulip ledge
#

You should also put a catch on it for when the users have DM's disabled

#

I think both would work

#

No nvm it's user

#

It's the user object

wind kayak
#

When automating browsing with a bot, is it against a rule here or against discord TOS to have a recaptcha solver?

knotty steeple
#

good luck making it

north hollow
tulip ledge
#

show code

north hollow
#

Ok

wind kayak
#

@knotty steeple recaptcha solvers already exist, no need to make one

misty sigil
#

do same thing

tulip ledge
#

but in meme.js this time

north hollow
#

module.exports = {
name: 'meme',
description: 'Meme!',
execute(message, args) {
if(command === Prefix + 'meme') {
let msg = await message.channel.send("Fetching...");
fetch('https://meme-api.herokuapp.com/gimme')
.then(res => res.json())
.then(json => {
let embed = new Discord.MessageEmbed()
.setTitle(json.title)
.setImage(json.url)
.setFooter(Link: ${json.postLink} | Subreddit: ${json.subreddit})
msg.edit(embed)
}) //this is for ending the .then code
}
}
};

tulip ledge
#

Like we said earlier

#

async execute

autumn aspen
#

Guys how can I send the user DM when he get kicked? return message.author.send

misty sigil
#

Can't

tulip ledge
#

Get the member object of whom you're kicking then get the user obejct of that member object and run the send method on that

#

Yes you can Jeremy

misty sigil
#

not after he is kicked

earnest phoenix
#

Ok so is if(message.users.mentions.first()) correct?

tulip ledge
#

yeah just about to send it

#

Yeah then run a .send() on it

earnest phoenix
#

Ok just .send not message.channel.send?

misty sigil
#

and didn't you mean user object

knotty steeple
#

obviously u will send the message before u kick @misty sigil

misty sigil
#

mkay

obtuse jolt
misty sigil
#

bot doesn't like you

#

he is angy

obtuse jolt
#

😔

north hollow
misty sigil
#

did you mean: pensivebread

earnest phoenix
#

Ok I'm confused here is the code else if (command === 'test'){ If(!args[0]) return message.channel.send('test'); If(message.users.mentions.first()) Message.user.send('test'); anything wrong here?

misty sigil
#

yes

earnest phoenix
#

Ok where did I mess up lol

misty sigil
#

its message.users.mentions.first().send().catch() i think i dunno

earnest phoenix
#

Ok

tulip ledge
#

Yes

north hollow
#

I did not work

tulip ledge
#

message.users.mentions.first().send("message").catch(return message.channel.send("The user had DM's disabled!")

earnest phoenix
#

Ok

#

I got like 5 errors now

#

Ok so catch just gives me errors for some reason

obtuse jolt
#

Genuinely can’t find why it’s not replying

#

Maybe it really is mad

#

ohhh I think I know why

misty sigil
#

why

obtuse jolt
#

I added the ws intention things

#

In the update

earnest phoenix
#

Nope still doesn't work

cunning coral
#

hi

marble juniper
#

why Is it Message not message

obtuse jolt
#

Yeah it works now

cunning coral
#

how to do discord onilne?

#

bot'

obtuse jolt
#

@misty sigil apparently my bot doesn’t like intentions

misty sigil
#

(oh god)do you know js

marble juniper
misty sigil
#

or any language

north hollow
earnest phoenix
#

@marble juniper my autocorrect on my phone does that its fine normally

marble juniper
#

k

misty sigil
#

ok yea i got no idea

earnest phoenix
#

I got the error "Cannot read properly 'mentions' of undefined"

obtuse jolt
#

I fucking hate people that say k it has no context and you never know if they are saying ok or they are angrily trying to say idc

misty sigil
#

then put it as the message object

tulip ledge
#

Any idea why this SELECT * FROM test WHERE type = "sword" AND id = 1 OR id = 2 OR id = 3; returns all the values even the ones where type doesn't equal sword?

misty sigil
#
<message>.users.mentions.first().send("message").catch(return message.channel.send("The user had DM's disabled!")```
cunning coral
#

i have chrome book tho

misty sigil
earnest phoenix
#

Should it still be a if statement?

misty sigil
#

no there should be no if statement

earnest phoenix
#

Ok

#

I got 6 errors doing that now

#

Is this correct?

obtuse jolt
#

Remove the <>

earnest phoenix
#

Now I got 4 errors

tulip ledge
#

I fixed mine

earnest phoenix
#

Oh I fixed it lol

obtuse jolt
earnest phoenix
#

Nope still doesn't work

obtuse jolt
#

idk what to do

earnest phoenix
#

It said the same error

north hollow
misty sigil
#

what

quartz kindle
#

@obtuse jolt that happens when you try to connect/disconnect multiple times at once

#

use a connection pool and keep the connections open

#

are you using npm i mysql?

obtuse jolt
#

Yeah

#

ohh

quartz kindle
earnest phoenix
#

This correct?

obtuse jolt
#

So instead of opening the connection I just connect once then use that

#

That’s pretty cool

#

What do I put for the connection limit

#

Idk what goes there

tulip ledge
#

I fucking love levenshtein algorithm

quartz kindle
#

connection limit = max amount of connections kept alive at the same time

obtuse jolt
#

What is the account limit?

quartz kindle
#

account limit?

obtuse jolt
#

Yeah when I tried to login to my account earlier it said too many people were logged in at the same time

quartz kindle
#

that depends on your mysql configuration

obtuse jolt
#

Do I remove my connection.ends?

quartz kindle
#

yes

#

remove all ends and all connects

#

and use pool.query for everything

honest perch
#

TIM

#

Mr dev man

#

Get a channels id

#

And send args

earnest phoenix
#

Ok I need help here im trying to get the bot to dm a pinged user

#

Here is the command I get this error "cannot read properly 'mentions' of undefined"

sudden geyser
#

@earnest phoenix message.users is not a property. You should flip it with message.mentions.users instead.

earnest phoenix
#

Ok

sudden geyser
#

You should also make sure one user is mentioned by checking the collection .size.

earnest phoenix
#

Wait where does .size go?

sudden geyser
#

It goes on the collection. message.mentions.users returns a collection. So, if (<Collection>.size == 0) {...} (fallback for if no one is mentioned).

#

Then again, getting the first mentioned user is not 100% reliable, but it's good enough.

earnest phoenix
#

Got it to work thanks

tulip ledge
#

I have this else statement that will change the "itemid" to a different value and then run the code after the else statement the issue is that client.con.query takes time before it's done and therefore itemid is undefined when it reaches the code that will execute the things with itemid
This is the code:

else {
     await client.con.query(`SELECT * FROM items WHERE itemtype = "${foundType}" AND (itemid = "${weapon}" OR itemid = "${helmet}" OR itemid = "${chestplate}" OR itemid = "${leggings}" OR itemid = "${boots}" OR itemid = "${fishingrod}")`, (err, rows) => {
     if(err) throw err;
     if(rows.length < 1) return message.channel.send("You don't have this item equipped")
     let type = rows[0].itemtype;
     let id = rows[0].itemid;
     if(type === "sword" || type === "bow" || type === "weapon" && weapon !== id) return message.channel.send("You don't have this item equipped")
     else if(type === "helmet"&& helmet !== id) return message.channel.send("You don't have this item equipped")
     else if(type === "chestplate" && chestplate !== id) return message.channel.send("You don't have this item equipped")
     else if(type === "leggings" && leggings !== id) return message.channel.send("You don't have this item equipped")
     else if(type === "boots" && boots !== id) return message.channel.send("You don't have this item equipped")
     else if(type === "fishing rod" && fishingrod !== id) return message.channel.send("You don't have this item equipped")
     selected = type;
     itemid = id;
     console.log(itemid)
   })
}
// Do stuff with itemid
#

Do I make a promise from the query?

obtuse jolt
#

@quartz kindle

undefined
/home/container/node_modules/mysql/lib/protocol/Parser.js:437
throw err; // Rethrow non-MySQL errors
TypeError: Cannot read property '0' of undefined```
```js
connection.query('SELECT * FROM automatedScans WHERE scanid = ' + input, function (error, results, fields) {
        console.log(results)
        console.log(results[0])
        if(results[0].isautoscan === 1) {
            client.channels.get(results[0].channelid).fetchMessage(results[0].messageid)
            .then(message => {
                message.clearReactions()
                message.react('723475322061979669')
                connection.query('SELECT * FROM automatedScans WHERE scanid = ' + input, function (error, results, fields) {
                    if(results[0].type === "url") {
                        vtauto.urlScan(results[0].input)
                        .then(async (resp) => {
                            await new Promise(resolve => { setTimeout(resolve, 5000) })
                            let reso = resp.resource
                            vtauto.urlReport(reso)
                            .then((res) => {
                                if(!res.total) {
                                    message.react('724367489328349325')
                                }
                                if(res.positives) {
                                    if(res.positives === 0) {
                                        message.react('723481373616373818')
                                    } else {
                                        message.react('723481391786098688')
                                    }
                                } else {
                                    message.react('724367489328349325')
                                }
                            })
                        })
                    }
                })
            })
        }
    })```
quartz kindle
#

^ classic example of callback hell

obtuse jolt
#

lol shush

#

give me help

#

EEEE

quartz kindle
#

is that all the error shows?

#

results seems to be undefined

obtuse jolt
#
undefined
/home/container/node_modules/mysql/lib/protocol/Parser.js:437
throw err; // Rethrow non-MySQL errors
TypeError: Cannot read property '0' of undefined
at Query.<anonymous> (/home/container/bot.js:72:28)
at Query.<anonymous> (/home/container/node_modules/mysql/lib/Connection.js:526:10)
at Query._callback (/home/container/node_modules/mysql/lib/Connection.js:488:16)
at Query.Sequence.end (/home/container/node_modules/mysql/lib/protocol/sequences/Sequence.js:83:24)
at Query.ErrorPacket (/home/container/node_modules/mysql/lib/protocol/sequences/Query.js:92:8)
at Protocol._parsePacket (/home/container/node_modules/mysql/lib/protocol/Protocol.js:291:23)
at Parser._parsePacket (/home/container/node_modules/mysql/lib/protocol/Parser.js:433:10)
at Parser.write (/home/container/node_modules/mysql/lib/protocol/Parser.js:43:10)
at Protocol.write (/home/container/node_modules/mysql/lib/protocol/Protocol.js:38:16)
at Socket.<anonymous> (/home/container/node_modules/mysql/lib/Connection.js:88:28)```
#

yeash but why

pure lion
#

when i run this command the fillText's stay the same every time its run

const Canvas = require('canvas')
Canvas.registerFont('BebasNeue-Regular.ttf', {family: 'Sans Serif'})
const canvas = Canvas.createCanvas(750, 200)
const ctx = canvas.getContext('2d')
const { GuildMember } = require('../models/index')
const { MessageAttachment, DataResolver } = require('discord.js-light')

module.exports = {
    name: 'level',
    usage: 'aa!level',
    async execute(client, msg, args) {
        const data = await GuildMember.findOne({ID: msg.guild.id + msg.author.id})
        ctx.fillStyle = '#7289DA'
        ctx.fillRect(0, 0, 750, 200)

        let img = await Canvas.loadImage(msg.author.displayAvatarURL({format: 'png', size: 2048}))

        console.log(`${data.xp}\n${data.level}\n${data.level * 500}`)

        ctx.strokeStyle = 'white'
        ctx.lineWidth = 20
        ctx.strokeRect(100, 65, 500, 100)

        ctx.fillStyle = 'white'
        ctx.fillRect(100, 65, 20, 100)

        ctx.font = '50px Bebas Neue'
        ctx.fillText(msg.author.tag, 155, 50)
        ctx.font = '25px Bebas Neue'
        ctx.fillText(`XP: ${data.xp}`, 620, 100)

        ctx.strokeStyle = 'white'
        ctx.fillStyle = 'white'
        ctx.lineWidth = 10
        ctx.arc(100, 100, 75, 0, Math.PI * 2)
        ctx.clip()
        ctx.stroke()
        ctx.fill()

        ctx.drawImage(img, 25, 25, 150, 150)

        ctx.strokeStyle = 'white'
        ctx.shadowColor = 'black'
        ctx.shadowBlur = 10
        ctx.shadowOffsetX = 10
        ctx.shadowOffsetY = 10
        ctx.lineWidth = 10
        ctx.arc(100, 100, 75, 0, Math.PI * 2)
        ctx.stroke()

        let card = new MessageAttachment(
            canvas.toBuffer(), `${msg.author.username}'s_card.png`
        )
        msg.channel.send(card)
    }
}
#

e.g itll say my tag even if someone else runs the command

#

its loading different images too, just not changing the text

obtuse jolt
#

so thats how they make the level up cards, looks hard

pure lion
#

not even done

#

and dont steal >:c

obtuse jolt
#

lol

pure lion
#

(and also broken... etc)

obtuse jolt
#

@quartz kindle i found the error

#

Error: ER_BAD_FIELD_ERROR: Unknown column 'eRcN7y' in 'where clause'

pure lion
#

*cries in not getting help*

obtuse jolt
#

@misty sigil

pure lion
#

also bruh

tulip ledge
#

Whats the issue Dice?

obtuse jolt
#

he might be able to help

tulip ledge
#

And stop changing ur name

#

I'm always confused if ur referenceerror or not lmao

#

@pure lion

#

Whats the issue?

pure lion
#

the issue is that

#

come to my test server a sec

stark abyss
#
const data = [];
  const { commands } = message.client;
  if (!args.length) {

    data.push('Here\'s a list of all my commands:');
    data.push(commands.map(command => command.name).join(', '));
    data.push(`\nYou can send \`${prefix}help [command name]\` to get info on a specific command!`);

return message.author.send(data, { split: true })```
#

um this get's all the commands in this folder

#

but i wanna seperate it by folder

tulip ledge
#

@stark abyss I'll break down for you how to do it ok?

stark abyss
#

yeah please

pure lion
#

@earnest phoenix hello there, lord of canvas. i apologise for the ping but i appear to be suffering from an issue that neither i nor ChickenDev can solve. your assistance would be greatly appreciated :). the issue is that the text isnt updating per use of the command, and stays the same as the first user who ran the command
(https://hasteb.in/hifikoji) <= code

tulip ledge
#

First you create a function like this:

function loadCommands = module.exports.loadCommands = (dir ="./commands/") {

}

Inside the function you first run an fs.readdir to get all the files & folders inside commands
The you wanna .forEach these files and use fs's function .isDirectory() on them, if this returns true you can call loadCommands again and add this directory into it like this: loadCommands(dir + file + "/") if .isDirectory() returns false you can just add the command to your set like usual

pure lion
#

dire times :sad:

stark abyss
#

okay that's gonna be bit rough on me but ill try my best

astral yoke
#

i have a screenshot command right, how would i filter out nsfw content?

#

do i just have todo if(ss).includes(...)?

misty sigil
#

just restrict it to nsfw

astral yoke
#

yeah thats what i have right now

misty sigil
#

it'll be bypassed

pale vessel
#

it's impossible

astral yoke
#

but for yours i thought you have it bypassed flazepe

pale vessel
#

nope

astral yoke
#

you have nsfw bypassed or did you lock your command to nsfw?

pale vessel
#

not anymore

misty sigil
#

nope

#

its nsfw only

pale vessel
#

we were all told to lock, even for owners

wicked pivot
#

hello, I am trying to export some of my features which are often repeated in my code, example:

const discord = require('discord.js')

var config = {
    check: async(msg) => {
        if(msg.channel.id !== "534739150214135818"){
            if(!msg.member.hasPermission('MUTE_MEMBERS')) {
                msg.delete()
                return msg.channel.send("Les commandes sont autorisés uniquement dans [#534739150214135818](/guild/264445053596991498/channel/534739150214135818/)").then(msg => msg.delete(10000))
            }
        }
    }
}

module.exports = config```it works the message and send but the continuation of the code is executed as I can stop the continuation? if the action does
knotty steeple
#

https://modeus.is-inside.me/r3Irc5i4.png

constructor(options) {
  this.options = options || {}
  if (typeof this.options !== "object" && this.options !== null) throw new TypeError("'options' has to be an object.")
}```
#

js is a troll

#

using typeof on an array returns object

tulip ledge
#

@knotty steeple an array is an object

#

You can use Array.isArray(array) to see if it's an array or not

#

An array is basically an object with different methods

knotty steeple
#

ya i forgot how to check if its in array

#

thank

gritty bolt
#

I have a json element that I've parsed using js, how do I get the first json object in the array?

opal plank
#

index [0] @gritty bolt

wicked pivot
#

I think it's not very understandable what I said

stark abyss
#

@tulip ledge ||sorry for ping just ignore me if you don't wanna deal with me||
so I sort off did what you aimed for in different way

    fs.readdirSync(`./commands/`).forEach(folder => {
      var loadFolder = `${folder}`
      console.log("Loadded " + loadFolder)   

      fs.readdirSync(`./commands/${loadFolder}`).forEach(file => {
        var loadFile = `${folder}/${file}`
        console.log("Loadded " + loadFile)

        })
    })```
and it's console.logging the folder and file right but the thing is that i called
```css
  const data = [];
  const { commands } = message.client;

   data.push(commands.map(command => command.name).join(', '));```
So I want to seperate the commands by file for help embed but i am not sure how to
#

so how can i do data.push by folder in this folder then taking all files in this folder

obtuse jolt
#

theres spaces in that

#

currently using

console.log(results[0])```
stark abyss
#

what is results?

obtuse jolt
#

that is the result

stark abyss
#

where is it defined though

obtuse jolt
#
connection.query(`SELECT EXISTS(SELECT * FROM votes WHERE userid = '${vote.user}')`, function (error, results, fields) {
        console.log(results[0])
})```
stark abyss
#

i am not expert but what happens when you just do results instead of results[0]

#

error?

obtuse jolt
#

the same thing i think

stark abyss
#

maybe it's worth trying? idk man

obtuse jolt
#

yeah its literally the same thing

sonic lodge
#

when the command is run, check that the person running has your id

obtuse jolt
#
if(message.author.id !== "YOUR ID") return;```
stark abyss
#

no

obtuse jolt
#

use what

stark abyss
#

only you

#

as long as put in up top your code

obtuse jolt
#

@quartz kindle i need help

stark abyss
#

me too

#

😳

sonic lodge
#

@obtuse jolt is the key to your entry an entire sql query?

quartz kindle
#

hmm?

wicked pivot
#

without export:

if (!message.member.hasPermission("BAN_MEMBERS"))return msg.channel.send("You don't have permissions to do this!");
member.ban()```I do not have the perm it sends the message and stop the code before ban
with export:


```js
ExportConfig.permcheck(message, "BAN_MEMBERS")
member.ban()```

I do not have the perm it sends the message, its not stop before ban

how to remedy this?

code :
```js
const discord = require('discord.js')


var config = {
    check: async(msg) => {
        if(msg.channel.id !== "534739150214135818"){
            if(!msg.member.hasPermission('MUTE_MEMBERS')) {
                msg.delete()
                return msg.channel.send("Les commandes sont autorisés uniquement dans [#534739150214135818](/guild/264445053596991498/channel/534739150214135818/)").then(msg => msg.delete(10000))
            }
        }
    },
    permcheck: async(msg, perm) => {
        if (!msg.member.hasPermission(perm))return msg.channel.send("Vous n'avez pas les permissions pour faire cela !");
    }
}

module.exports = config```
misty sigil
#

god tim is being pinged smh

obtuse jolt
#

i need tim

#

he has big brain

#

@wicked pivot if they bot says it doesnt have permission to send the message the bot is most likely muted in that channel

quartz kindle
#

you probably want to use AS

obtuse jolt
#

as?

wicked pivot
#

nothing to do with bot perm?

quartz kindle
#

SELECT EXISTS(bla) AS hue = results[0].hue

#

otherwise

#

SELECT EXISTS(bla) = results[0]["bla"]

obtuse jolt
#

big brain tim

quartz kindle
#

in your case

#

results is returning everything right after SELECT

#

so you'd need to results[0]["EXISTS(SELECT * FROM votes WHERE userid = '${vote.user}'"] lmao

obtuse jolt
#

bruh

quartz kindle
#

thats why you use AS

obtuse jolt
#

AS vibecheck

#

yes

#

beautiful

#

this man has no vibe we must vibe check him

#

bruh

#

why

misty sigil
#

no ads

obtuse jolt
#

@scenic kelp is there an anti ad bot here or something

misty sigil
#

luca

scenic kelp
#

luca deletes any messages from whitenames with links to certain places afaik

obtuse jolt
#

luca anti ad auto ban

warm copper
#

Oh sorry

obtuse jolt
#

yes

warm copper
#

I didn’t know

obtuse jolt
#

they should add that

scenic kelp
#

@warm copper Maybe you should read the rules then

obtuse jolt
#

vibecheck

scenic kelp
#

isn't that prone to sql injection

obtuse jolt
#

only i can access it

#

its hard coded

scenic kelp
#

still

misty sigil
#

sql injection has entered chat
sql injection has left chat

scenic kelp
#

there's ?

obtuse jolt
#

i mean if dbl wanted to sql inject me i suppose they could

#

but i would hope they wouldn't

scenic kelp
#

use the ? thing in sql

misty sigil
#

ok why not 3000 priority tokens for me mmulu

scenic kelp
#

a parameterized query

misty sigil
#

seriously, i'd advise securing that

obtuse jolt
#

i mean theres no sensitive data its all scan config files and server configs so

scenic kelp
#

doesn't matter

#

use it

quartz kindle
#

the mysql lib doesnt have actual prepared statements, they just do string escaping

scenic kelp
#

oh

obtuse jolt
#

HOW

quartz kindle
#

still, better than nothing

obtuse jolt
#

im not good with sql

#

i ping big brain tim when i cant figure something out

quartz kindle
scenic kelp
#

that's kinda dumb

quartz kindle
obtuse jolt
#

how would i add it tho

quartz kindle
#

god knows how long thats been there

obtuse jolt
#

doesnt it just query the database?

scenic kelp
#

it looks like you just pass an array of args

obtuse jolt
#

so couldnt you just manually add it

scenic kelp
obtuse jolt
#

im not big brain with sql

#

im not changing again

quartz kindle
obtuse jolt
#

ive been working on this for over 4 hours

scenic kelp
#

so it'd be like connection.query(`sql statement with ?`, [arg(s) to replace with], callback)

#

yeah

obtuse jolt
#

wow thats easy

#

ok ill do the escape thing if it makes you happy

scenic kelp
#

not a huge change but one that is the difference between giving users access to your db and not

#

it's not for me

#

it's for you

quartz kindle
#

sql injection is stupid

obtuse jolt
#

which one would be better tho ? or escape

#

and what does escape even do

quartz kindle
#

both are the same, as explained in the docs

#

it escapes dangerous characters

obtuse jolt
#

how does the ? do that i never got that

quartz kindle
#

for example, if your query is SELECT * FROM table WHERE id = "USER ID FROM COMMAND HERE"

#

and a person does command bla" DROP TABLE

#

your query becomes SELECT * FROM table WHERE id = "bla" DROP TABLE"

obtuse jolt
#

oop

#

so how does it get by that?

quartz kindle
#

escaping characters prevents dangeours chracters like quotes from being parsed by SQL as commands

#

so that your dbl will understand DROP TABLE as text, and not as a command

obtuse jolt
#

its so easy to add tho i wouldve though they would just add it by default

quartz kindle
#

they cant do it by default, because the entire interface is text based

#

you are basically sending one huge text command to SQL

#

they have no way of validating the command for you, you need to do it yourself

obtuse jolt
#

i see

#

im gonna add the ? one because i know most people use it

#

lol

quartz kindle
#

the ? just makes it easier to add multiple values to the query

stark abyss
#
    fs.readdirSync(`./commands/`).forEach(folder => {
      var loadFolder = `${folder}`
      console.log("Loadded " + loadFolder)   

      fs.readdirSync(`./commands/${loadFolder}`).forEach(file => {
        var loadFile = `${folder}/${file}`
        console.log("Loadded " + loadFile)

        })
    })```
and it's console.logging the folder and file right but the thing is that i called
```css
  const data = [];
  const { commands } = message.client;

   data.push(commands.map(command => command.name).join(', '));```

so how can i do data.push seperately to files in folder then just all files in this folder with multiple folder

obtuse jolt
stark abyss
#

I need to seperate it bc i am using this for help embed and it would give me all commands. I want to categorize them

quartz kindle
#

yes

opaque hawk
#

can I define a constant as a block of code instead of a single line

obtuse jolt
#

seems easy enough

opaque hawk
#

And how would I do that

quartz kindle
#

not sure if you need the quotes around the ?

#

i think you dont

#

@opaque hawk what kind of block

opaque hawk
#

Like a function, say

#

Im trying to make a rank command and I'm defining xp

stark abyss
#

if anyone can help me please ping me

obtuse jolt
#

well i guess im now sql injection protected now

#

good to know

opaque hawk
#

I think that I could do ```ts
const xp = ({

});```

quartz kindle
#

i dont understand what your code is trying to do p025

obtuse jolt
#

it loads all the commands

quartz kindle
#

@opaque hawk you can define a const as anything, an array, an object, a function, etc...

obtuse jolt
#

the top bit does at least

opaque hawk
#

ok

quartz kindle
#

but it needs to be a specific thing

obtuse jolt
#

yeah idk what hes trying to do either

quartz kindle
#

for example ```js
const a = function() {
return 10
}

or

const a = {
a:10,
b:20
}

obtuse jolt
quartz kindle
#

yes

stark abyss
#

i dont understand what your code is trying to do p025
@quartz kindle So right now I have

    data.push('Here\'s a list of all my commands:');
    data.push(commands.map(command => command.name).join(', '));
    data.push(`\nYou can send \`${prefix}help [command name]\` to get info on a specific command!`);

    return message.author.send(data, { split: true })

This is triggered when I do prefix + help. the data.push(commands.map) line will give me all the commands that exist in this folder called commands. But just giving all commands is kinda weird so I wanna categorize them. I already have folders in folder named with their category name and I want to separate the commands by folder

obtuse jolt
stark abyss
#

can I ask why you are hosting pictures to send rather then just sharing/sending?

obtuse jolt
#

my internet is shit

#

really

#

really bad

sonic lodge
#

yes it's good

stark abyss
obtuse jolt
#

im talking 1MB/s down and less then that up

#

its just easier to upload it like that

stark abyss
#

nice

quartz kindle
#

you could just... you know... copy and paste? the actual code?

#

upload a few bytes instead of an image?

stark abyss
#

well tim any hints / tips / suggestion for me?

quartz kindle
#

@stark abyss do you have some kind of category field defined in your commands?

stark abyss
#

no

quartz kindle
#

then you need to add one

#

you can even do it during command loading

stark abyss
#

oh

quartz kindle
#

for example

#
cmd = require(folder/file)
cmd.category = folder
client.commands.set(cmd.name,cmd)
stark abyss
#

I see

#

wait what is category in cmd.category or what does it do

quartz kindle
#

the folder name?

#

idk, give it whatever you want

stark abyss
#

oh ok

quartz kindle
#

you're basically using the command loader to attach the folder it came from to itself

#

so it remembers which folder it came from

stark abyss
#

okay Thanks

obtuse jolt
#
connection.query(`SELECT EXISTS(SELECT * FROM votes WHERE userid = '?') AS vibecheck`, [vote.user], function (error, results, fields) {
        if(results[0].vibecheck === 0) {
            connection.query(`INSERT INTO votes (priorityleft, totalvotes, userid) VALUES (?, ?, ?)`, [0, 0, vote.user], function (error, results, fields) {
                connection.query(`SELECT EXISTS(SELECT * FROM votes WHERE userid = '?') AS vibecheck2`, [vote.user], function (error, results, fields) {
                    connection.query(`UPDATE votes SET priorityleft = ?, totalvotes = ? WHERE userid = ?`, [vibecheck2.priorityleft++, vibecheck2.totalvotes++, vote.user], function (error, results, fields) {
                    })
                })
            })
        }

        if(results[0].vibecheck === 1) {
            connection.query(`SELECT EXISTS(SELECT * FROM votes WHERE userid = '?') AS vibecheck`, [vote.user], function (error, results, fields) {
                connection.query(`UPDATE votes SET priorityleft = ?, totalvotes = ? WHERE userid = ?`, [vibecheck.priorityleft++, vibecheck.totalvotes++, vote.user], function (error, results, fields) {
                })
            })
        }
    })```
#

is that all valid

quartz kindle
#

idk, looks like it

#

horrendous callback hell tho :^)

obtuse jolt
#

i hope it works

#

i dont understand sql errors that well

#

nope didnt work

#

frick

sonic lodge
#

i think mysql will add the quotes around the placeholders automatically, so '?' is wrong

obtuse jolt
#

code: 'ER_PARSE_ERROR',
errno: 1064,
sqlMessage: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '551854789990940699'') AS vibecheck' at line 1",
sqlState: '42000',
index: 0,
sql: "SELECT EXISTS(SELECT * FROM votes WHERE userid = ''551854789990940699'') AS vibecheck"

#

dont even need the help

#

i know that one

#

ReferenceError: vibecheck2 is not defined

#

seriously

sonic lodge
#

''551854789990940699''

#

there's two pairs of quotes

obtuse jolt
#

ok ok

#

no errors

#

now to check the database

#

hmm

#

im on there but it wont add votes to me

#

i cant get it to work wtf

#

@quartz kindle help

cunning gorge
#

I got this error

WARNING: The script chardetect is installed in '/Users/
Library/Python/3.8/bin' which is not on PATH.

So it ran

nano .bash_profile

then

export PATH="/Users/Library/Python/3.8/bin:${PATH}"

Was this correct?

#

And is that and okay thing to do

#

like will it mess up something else

sick cloud
#

is async enabled in for loops?

stark abyss
#
cmd = require(folder/file)
cmd.category = folder
client.commands.set(cmd.name,cmd)```
#

does anyone know what category or folder is in 2nd line

gray zealot
#

Hi 😄 how do I make it so it can only be used in a nsfw channel?

make sense? 🙂

earnest phoenix
#

check if the channel is nsfw

gray zealot
#

ik but how? 😄

earnest phoenix
#

in which lib

gray zealot
#

? 😄

ember lodge
#

how do i change the color of my web?

earnest phoenix
#

what do you mean

ember lodge
#

i tried adding background-color style to my body but nothing

earnest phoenix
#

what

#

? 😄
@gray zealot im asking you which library you are using

gray zealot
#

discord js

gray zealot
#

ok 🙂

#

||ughhhh idk how to read that 😂||

ember lodge
#

How do i change the color of the website?

earnest phoenix
#

style it with css

gray zealot
#

lol yeah

earnest phoenix
#

help me pls

#

embed.set_thumbnail(url=message.guild.User.avatar_url)

gray zealot
#

!

earnest phoenix
#

avatar not found

ember lodge
#

@earnest phoenix i tried it but nothing

earnest phoenix
#

yikes making a dashboard in raw html

ember lodge
#

i know @earnest phoenix

#

then i will pass it to my VPS

#

Right now its just the model _XD

earnest phoenix
#

try removing bulma

#

bulma might be overwriting default rules

gray zealot
#

embed.set.thumbnail(message.author.displayAvatarURL)
@earnest phoenix will this work?

ember lodge
#

Bulma is my css framework XD

gray zealot
#

or something like it

earnest phoenix
#

you can also mark background-color with !important

#

error

#

read your damn error

gray zealot
#

do .thumbnail

#

not _

#

@earnest phoenix

earnest phoenix
#

that is not the issue

#

please stop trying to help if you cannot diagnose the issue correctly

#

not using ext

zenith terrace
#

@ember lodge pretty sure background-color has to go between <body> </body

earnest phoenix
#

what

#

no

#

that's not how css works

#

and oh i just noticed your issue

#

your style tag is outside of the head

zenith terrace
#

I havent used html in a while

earnest phoenix
#

then don't help? lol

ember lodge
#

@zenith terrace I figured out by myself so don't worry

#

I added background color to html tag

zenith terrace
#

cool

#

prob gonna head to bed to rest my head since its 3am

regal raven
#

error
@earnest phoenix can you try using message.author.avatar_url instead of message.guild.user.avatar_url May work 🤔

#

do .thumbnail
not _
@gray zealot He is using discord.py so "_" is right

ember lodge
#

Why is not appearing?

gray zealot
#

@gray zealot He is using discord.py so "_" is right
@regal raven oh nvm then 🙂

regal raven
#

🙂

gray zealot
#

🙂

regal raven
#

😂

fervent flume
#

why would this let welcome = db.get(welcome_${message.guild.id});
give me this error
(node:57) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'id' of undefined

torn ravine
#

@fervent flume you don’t have it in your message event

fervent flume
#

oh i see thank you

#

I have changed it and it still says the same thing

cunning gorge
#
Consider using the `--user` option or check the permissions.

I flagged my command with the --user too, if anyone can help please DM me!

torn ravine
#

is it in your <Client>.on message event

#

I think its fixed seeing that you deleted your message?

fervent flume
#

what?

#

no it isnt its still saying thgat error, and yeah it is in my on message event

#

@torn ravine

hazy sparrow
#

its not even telling me where that code is -_-

solemn latch
#

Mybot.js line 16 char 21

#

Lol

hazy sparrow
#

thats line 16

torn ravine
#

@fervent flume v11 or v12

fervent flume
#

v12

lavish anchor
#

can anyone help me

#

i want to make a bot

sudden geyser
#

Press New Application

lavish anchor
#

i did

torn ravine
#

@lavish anchor also learn a language

sudden geyser
#

Enter a name for your application -> Click the "Bot" tab on the left side bar -> Build the bot

lavish anchor
#

oh! i see

#

thanks

#

i will proceed further

#

if i need any help

#

will let you know

hazy sparrow
#

are you using a guide?

#

@lavish anchor

lavish anchor
#

yeah

hazy sparrow
#

which guide?

lavish anchor
#

click this

#

@hazy sparrow

hazy sparrow
#

okay

#

ah

#

that

cunning gorge
#
ClientConnectorCertificateError(
aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host discordapp.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123)')]

Can someone help me with this issue that I get when running python3 main.py on a mac? Please ping me if you have a solution 🙂

slim heart
#

how am i meant to handle
(node:11571) UnhandledPromiseRejectionWarning: Error: WebSocket was closed before the connection was established
even tho its thrown does it still close it?

torn ravine
#

d.js version?

viral spade
#

how do i best clear guild cache for a specific guild in discord.js?

hazy sparrow
slim heart
#

@torn ravine me?

torn ravine
#

ya you

slim heart
#

its not a djs error nor do i use djs its just ws package

torn ravine
#

ah

delicate shore
#

Is this kind of language bad

#

And will it make my bot rejected ?

#

Wrong link

earnest phoenix
#

making a bot there seems to be something wrong with the code but i dont see it

#

What's the issue though

#

no commands run

#

const Discord = require("discord.js");
const bot = new Discord.Client();
const token = 'token';
const PREFIX= '*';

bot.on('ready' , () =>{
console.log('This bot is online!')

}

)

bot.on('message' , message=>{
let args = message.content.substring(PREFIX.length).split(" ");

switch(args[0]){
    case 'ping':
        message.channel.send('pong!');
        break;
        case 'info':
            console.log('message received');
            if(args[1] === 'version'){
                message.channel.send('Version 1.0.0');
            }else{
                message.channel.send('Invalid Args');
            }
            break;

        }
        
    })    
    

        
    bot.on('ready', () => {console.log('ready')});

bot.login(token);

#

heres all of the code

cunning gorge
#
ClientConnectorCertificateError(
aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host discordapp.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123)')]

Can someone help me with this issue that I get when running python3 main.py on a mac? Please ping me if you have a solution 🙂

earnest phoenix
#

ping me with response

#

imma sleep

meager jasper
#

for node.js what did I have to download msi oder zip

pure lion
#

Because it is

#

Do the .msi, you'll get an installer

#

Do the .zip, it's an archive file

meager jasper
#

what is better

#

I think I will install the msi

#

@pure lion

pure lion
#

It's usually down to preference but msi is generally more straightforward

meager jasper
#

so the msi is easy then zip? @pure lion

pure lion
#

Omg stop pinging me

#

Yes go do it byebye

clever vector
#

Hey guys how can we use bot catch censor??

restive pebble
#

use some image apis

earnest phoenix
#

well uhh the command (work command) it works but when the user runs again it doesnt store the number like the cmd works but the number doesnt get stored into the database

valid frigate
#

make sure that you're writing the value to your database

earnest phoenix
#

i am

#

Which database do you use is the question

valid frigate
#

what db type

earnest phoenix
#

mongoDB

valid frigate
#

mongoose?

earnest phoenix
#

no

#

mongoDB

#

as i said

valid frigate
#

ok ok

#

what language for the mongodb driver are you using

earnest phoenix
#

Javascript

valid frigate
#

ok well

#

are you using updateOne

earnest phoenix
#

yes

valid frigate
#

well actually

#

can you send the snippet of code

earnest phoenix
#

sure

#

ill just give full code then

#
const Discord = require("discord.js")

module.exports = {
    name: "work",
    aliases: ["w"],
    category: "Currency",
    run: async (bot, message, args) => {
    let random = Math.floor(Math.random() * 100);
    console.log("blah")
    let prevmoney = await bot.db.collection("Money").findOne({"User_ID": message.author.id})
    
    if(!prevmoney) {
      await bot.db.collection("Money").updateOne({"User_ID": message.author.id}, {$set:{Money: prevmoney ? prevmoney.Money + random : random}},{upsert:true})
      prevmoney = 0;
    }

    let embed = new Discord.MessageEmbed()
        .setColor("RANDOM")
        .setTitle(`You worked!`)
        .setDescription(`You worked and got \`\`${random}\`\` money!💰`)
        .setFooter("By the way this command is in beta!")
      

      message.channel.send(embed);

        
    }
}
valid frigate
#

well

#

i think it's your code's logic

earnest phoenix
#

wdym

valid frigate
#

it will only update if it cannot find the user's id in the money collection

earnest phoenix
#

uhh?

valid frigate
#

basically

#

say i used the command for te first time

earnest phoenix
#

k

valid frigate
#

the bot should set my data as expected

earnest phoenix
#

mhm

valid frigate
#

but if i tried to run the command again

earnest phoenix
#

it wont

#

set data

valid frigate
#

prevmoney is now defined and the block that updates the database will never run

earnest phoenix
#

wait

#

i can do an else

#

couldnt i?

valid frigate
#

because when you say (!prevmoney) you're telling it "if this user doesnt exist update their currency"

#

yes you can

earnest phoenix
#

ok will that work?

valid frigate
#

but you can also do findOneAndUpdate

clever vector
#

@earnest phoenix Yo bro

earnest phoenix
#

Hmm

#

but you can also do findOneAndUpdate
@valid frigate how would i do that?

clever vector
#

can you come to my base i need talk xD

earnest phoenix
#

K

valid frigate
#

essentially you can just use the code that you currently hve

#

but lift it out of the if block

#

nd replace findOne with findOneAndUpdate

#

because you also specified upsert it will create a new document if it cant find the user

earnest phoenix
#

?

#

uh im a bit confused

restive pebble
#

i started using mongodb

earnest phoenix
#

could you give an example? @valid frigate

valid frigate
#

okay

#
await db.collection("test").findOneAndUpdate({ user_id: "0" }, {
$set: {
  money: 100
}
}, upsert: true)
#

wait fuck

restive pebble
#

close it

#

yes

earnest phoenix
#

so where would that go?

restive pebble
#

bruh

valid frigate
#

bruh

restive pebble
#

u dont know anything about db?

#

atleast read the code vysion sent

pale vessel
#

everyone starts somewhere

earnest phoenix
#

uuhhhhhhhhhhhhhhhhhhhhhhhhhhhhh

#

wait does it go in the else statement? @valid frigate

valid frigate
#

no

earnest phoenix
#

oh

valid frigate
#

you dont need a conditional at all

#

because think about it this way

#

the code above will create and set a document if it cant find the user, and if it can, just update it like normal

earnest phoenix
#

hmm let me try without if statement then

#

OMG IT WORKED

#

I HOPE

cunning gorge
#
ClientConnectorCertificateError(
aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host discordapp.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123)')]

Can someone help me with this issue that I get when running python3 main.py on a mac? Please ping me if you have a solution 🙂

earnest phoenix
#

now how do i make a bal cmd? @valid frigate

valid frigate
#

you uh

#

use .findOne()

earnest phoenix
#

use .findOne()
@valid frigate how?

valid frigate
#

........similar to findoneandupdate

earnest phoenix
#

uhh god

#

welp

#

wait

#

cant i do

let prevmoney = await bot.db.collection("Money").findOne({"User_ID": message.author.id})

message.channel.send(prevmoney.Money)
```?
#

let me try

#

that

#
const Discord = require("discord.js")

module.exports = {
    name: "balance",
    aliases: ["bal"],
    category: "Currency",
    cooldown: 5,
    run: async (bot, message, args) => {
    let prevmoney = await bot.db.collection("Money").findOne({"User_ID": message.author.id})

    let embed = new Discord.MessageEmbed()
        .setColor("RANDOM")
        .setTitle(`${message.author.username} here's your balance!`)
        .setDescription(`Balance: \`\`${prevmoney.Money}\`\``)
        .setFooter("By the way this command is in beta!")
      

      message.channel.send(embed);

        
    }
}
``` @valid frigate well when someone has no money it says cannot find Money of null or smth how can i stop that?
valid frigate
#

if (!prevmoney) {}

earnest phoenix
#

ok in ?

valid frigate
#

guess

earnest phoenix
#

uhh embed?

#

im not sure

#

@valid frigate ^^

valid frigate
#

right above it

earnest phoenix
#

just that?

#

@valid frigate what else do i put?

pure lion
#

When I do <channel>.awaitMessages(...{max:1}).then(), if doesn't wait for the collector to end

valid frigate
#

b to the r to the u to the h

valid frigate
#

something like

#

"u havent worked yet"

#

then return statement

earnest phoenix
#

k

pure lion
#

:/

sick cloud
#

so i need help planning my api
each space has pages, but pages can belong to a group (like channels and categories in discord)

how should i lay out the api routes?

#

i was thinking this:
/pages
/pages/id

then pages includes the groups as well to make it simpler
but i'm not too sure if that's good

dire abyss
#

Yeah I think pages/id would be a good api route amon avis

sick cloud
#

👍

#

also what sort of regex can i use to only match two words

#

so the regex only outputs true if the value it gets is public or private - case insensitivie

hasty sparrow
#

Use |: (private|public)

earnest phoenix
#

you do not need regex for that

#

regex is much slower compared to just directly comparing the string

rigid maple
#

v11 pls help

hazy sparrow
#

how do i get all the roles of a member?

honest perch
#

Read the docs

hazy sparrow
#

which docs

honest perch
#

Your libs

earnest phoenix
#

.

honest perch
#

Don't dotpost

hazy sparrow
#

Your libs
@honest perch discord.js

honest perch
#

Google

#

Discordjs docs

hazy sparrow
#

ty

summer torrent
#

yes

#

use map()

earnest phoenix
#

It's a map

#

message.guild.roles.cache.map(x => x.name)

hazy sparrow
#

oh ty

earnest phoenix
#
/home/runner/work/import/import/commands/softban.js:31
  let logchannel = message.guild.channels.cache.find(x => x.name = 'logs');
      ^

SyntaxError: Identifier 'logchannel' has already been declared
    at wrapSafe (internal/modules/cjs/loader.js:1054:16)
    at Module._compile (internal/modules/cjs/loader.js:1102:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
    at Module.load (internal/modules/cjs/loader.js:986:32)
    at Function.Module._load (internal/modules/cjs/loader.js:879:14)
    at Module.require (internal/modules/cjs/loader.js:1026:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at /home/runner/work/import/import/index.js:21:17
    at Array.forEach (<anonymous>)
    at /home/runner/work/import/import/index.js:20:9
    at FSReqCallback.oncomplete (fs.js:155:23)
##[error]Process completed with exit code 1.```
#

help me plz

#

Please go review js basics

#

That's a real simple error

summer torrent
#

read the error plz

#

@hazy sparrow what is your node.js version

earnest phoenix
#

@summer torrent plz bro

summer torrent
#

no, read error

earnest phoenix
hazy sparrow
#

wait hold on

#

12.13.0

#

@summer torrent

earnest phoenix
#

Anyone what this error means?

(node:1818) UnhandledPromiseRejectionWarning: #<Response>
5:46 PM
(node:1818) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
5:46 PM
(node:1818) [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.

hazy sparrow
#

@earnest phoenix show code

earnest phoenix
#

I want to but every time I reboot the error come from a different place

restive pebble
#

yes try catching and logging the error

earnest phoenix
#

@restive pebble help bro

hasty sparrow
#

Read the error message

earnest phoenix
#

@earnest phoenix That error message is pretty much useless...

restive pebble
#

ok i told him what to do

earnest phoenix
#
/home/runner/work/import/import/commands/softban.js:31
  let logchannel = message.guild.channels.cache.find(x => x.name = 'logs');
      ^

SyntaxError: Identifier 'logchannel' has already been declared
    at wrapSafe (internal/modules/cjs/loader.js:1054:16)
    at Module._compile (internal/modules/cjs/loader.js:1102:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
    at Module.load (internal/modules/cjs/loader.js:986:32)
    at Function.Module._load (internal/modules/cjs/loader.js:879:14)
    at Module.require (internal/modules/cjs/loader.js:1026:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at /home/runner/work/import/import/index.js:21:17
    at Array.forEach (<anonymous>)
    at /home/runner/work/import/import/index.js:20:9
    at FSReqCallback.oncomplete (fs.js:155:23)
##[error]Process completed with exit code 1.```
#

@earnest phoenix Please stop

pure lion
#
[c.forEach(e => e.content)]

i want to put the content of the collected messages (c) into an array while using awaitmessages, ive logged it and it returns undefined

restive pebble
#

u are assigning

earnest phoenix
#

@earnest phoenix If you can't work with simple js you shouldnt be working on a bot.

restive pebble
#

@earnest phoenix u are assigning the value of channels to logs

earnest phoenix
#

@earnest phoenix plz help me sir

#

@earnest phoenix That error message is pretty much useless...
@earnest phoenix what should I do?

restive pebble
hazy sparrow
#

send the code @earnest phoenix

hasty sparrow
#

Identifier 'logchannel' has already been declared
Self explanatory

restive pebble
#

@earnest phoenix u know the line where the error occured

earnest phoenix
#

Nope

restive pebble
#

now place a .catch

earnest phoenix
#

I place .catch already on every command

restive pebble
#

Luca oment

pure lion
#

luca o m e n t

restive pebble
#

u have to place in correct line

earnest phoenix
#

Try a try and catch block @earnest phoenix

restive pebble
#

do try

#

and cover all and full comands

pure lion
#

try { peepee } catch (err) { poopoo }

earnest phoenix
#

try {
// code
}
catch(e) {
console.log(e)
}

#

any buddy know github workflow???

restive pebble
#

yes why

earnest phoenix
#

as in github actions?

#

this option work 24/7

#

??

pure lion
#

👁️

restive pebble
#

wot

earnest phoenix
#

workflow work 24/7

pure lion
#

github not for host

restive pebble
#

student edition

pure lion
#

:o

restive pebble
#

not edition tho

hasty sparrow
#

No, you have to call GitHub and ask them to run it for you /s

earnest phoenix
#

@restive pebble yus i am student

pure lion
#

/s/s/s/s

earnest phoenix
restive pebble
#

oh i see

pure lion
#
[c.forEach(e => e.content)]

hhhhhhhhhhhhhhhhhhhhhhhhhh

restive pebble
#

whats the error here

earnest phoenix
#

What's the issue

pure lion
#

it logs undefined

restive pebble
#

and why u putting in []

earnest phoenix
#

^

pure lion
#

because its meant to be an array

hasty sparrow
#

You want map, not forEach

restive pebble
#

no content is there

hasty sparrow
#

forEach doesn't return anything

pure lion
#

o h f u c k w h y a m i a r e t ar d

#

ok the more you know

#

thanks :D

restive pebble
#

either map them

#

or make an array

#

and push the content using a for loop

earnest phoenix
#

or foreach and add push to array

hasty sparrow
sick cloud
#

lots of fun

earnest phoenix
#

nice

restive pebble
#

mongo

sick cloud
#

it works

restive pebble
#

mongoDB?

hasty sparrow
#

Well done

sick cloud
#

i can easily switch to any db i want in the future as i made a custom wrapper

#

yes mongodb

restive pebble
#

nice

earnest phoenix
#

custom wrapper 👀

#

is it on gh?

sick cloud
#

no, it's not

#

i only use it in private projects

earnest phoenix
#

ah ok

sick cloud
#

if you're interested i can send it though tomorrow

earnest phoenix
#

I already have my small handler

sick cloud
#

mine works more basically, ie
await db.coll('users').add(...)

jaunty junco
#

how to set the color of that line thingy on the embeds in discordia?

earnest phoenix
#

<embed>.setColor('COLOR')

restive pebble
#

discordia

jaunty junco
#

discordia

slender thistle
#

Do the docs mention anything?

jaunty junco
#

nope

restive pebble
#

ok nice

jaunty junco
#

at least i dont think so

restive pebble
#

dont use that thing if they dont have proper docs

jaunty junco
#

i saw somewhere something like embed color.fromrgb or something like that

earnest phoenix
#

isnt even documented lmao

#

why use discordia though

restive pebble
#

why use discord.js

slender thistle
jaunty junco
#

because its based on lua and i like lua

slender thistle
#

line 38

jaunty junco
#

ok

earnest phoenix
#

Oh that's lua didnt even realize

jaunty junco
#

@slender thistle thanks will try it

#

@slender thistle ok, thank you so so much, it works!

slender thistle
earnest phoenix
#

dek-help

restive pebble
#

epic

earnest phoenix
#

dek-help

#

hmm

#

what

restive pebble
#

muted

earnest phoenix
#

how

restive pebble
earnest phoenix
#

oop

#

my bad lmfao

honest perch
#

how would i make my bot leave all guilds with eval

modest maple
#

just delete your bot on discord

#

easy

honest perch
#

i want the logs doe

#

i just want to see it leave 90 guilds

stiff stream
#

i made my bot 5 days ago

#

and only 22 servers added him

#

is it good?

#

in 5 days

marble juniper
#

thats not development related

#

but well

#

my bot was added on 45 servers in 5 days

#

so uh

#

idk

#

if you consider it good

strong fractal
#

I clear using bulk

earnest phoenix
#

rainbow role bot ip banned why??

misty sigil
#

uhh

earnest phoenix
misty sigil
#

api abuse?

restive pebble
#

k

sinful belfry
#

@strong fractal that only deletes up to 2 weeks worth of messages or 100 messages tho

#

@earnest phoenix it is api abuse

earnest phoenix
#

If you are using a speed that's lower than 60000ms (1 minute) Your bot might get IP-banned!

sinful belfry
#

...

earnest phoenix
#

true /false

strong fractal
#

?

sinful belfry
#

is that a question?

strong fractal
#

Ohhh

#

Then I have not bulk...

#

I must delete the command XD

earnest phoenix
#

If you are using a speed that's lower than 60000ms (1 minute) Your bot might get IP-banned!

true/false

spare mirage
#

false

digital ibex
#

wot

earnest phoenix
#

how to know what device user is using

#

in js

#

like Desktop or Mobile

stiff stream
#

pc or mobile

#

not desktop

earnest phoenix
#

yes

#

how

#

(await message.channel.messages.fetch('732892960403882044')).reactions.cache.get(':white_check_mark:').users.cache.map(x => x.id)

#

that's just to get users who reacted from a message