#development

1 messages · Page 612 of 1

inner jewel
#

don't build sql queries by concatenating strings

#

that's the easiest way to get an sql injection

winged mango
#

i'm using sqlite3.py, i have no error while using this command but the line i want to delete is still there

#

hum ... can you explain that a bit more ?

#

please

ruby dust
#

you are trying to concatenate a string with a date object

quartz kindle
#

google "prepared statements"

winged mango
#

it is an other part of my code

slender thistle
#

That should be good

winged mango
#

this part works

#

but i don't see how i can make this one using prepared statements

#

oh

slender thistle
#

Concatenation

winged mango
#

hum ...

#

is it because date is a string, then ?

slender thistle
#

Well, I don't know what your date is

winged mango
#

date is a string .... i guess

inner jewel
#

!kill '';DROP TABLE anniv;--/lol/dead

#

and your whole table is gone

winged mango
#

hey! i don't want to delete all my table x(

#

i just found this command funny

#

but it doesn't help me much x)

#

should have done it with xml

safe pumice
#

Hello, did someone use Heroku for hosting ?

harsh dagger
#

someone did

#

i rember

#

remember*

#

ill try to find the guy

#

@burnt zealot

#

does

#

kirino

dusky bear
#

@safe pumice yes

safe pumice
#

@dusky bear do you know the pattern of the path for file storage ? (if i can !)

dusky bear
#

You dont stroe files on Heroku you use git.

#

Any updates to the file has to be made throw the Heroku git cli or through github.

safe pumice
#

it's for a json file that i create with python 😄

dusky bear
#

You have to make a git commit the a bit push.

safe pumice
#

but it's created with the guild name where the bot is installed 😄

earnest phoenix
#

how do i get the channel a member joins in for discord.js

#

you can't

#

thats so cringe wtf

#

so i have to use a specific channel id?

#

for that you'd have to get the invite the user joined with and the api doesn't provide that, you can't get the invite in a reliable way

#

probably

dusky bear
#

@safe pumice you have to git . add to add untracked files

#

Then a git commit

sinful lotus
#

you can use Concatenation on sql

#

provided that you only use it

#

and no user input would use it

#

but if its userinputted then never ever do that

dusky bear
#

@earnest phoenix I think you can. Just search the docs

earnest phoenix
#

you can't

#

guildMemberAdd event doesn't provide the invite the user joined with (which the api doesn't provide) which holds the info about the channel the user's been invited to

dusky bear
#

He asked for the channel not the invite.

earnest phoenix
#

Codage :

var ${args[0]} = args.join(' ');
  if (!args.join(' ')) return message.channel.send ("Veuillez donner une raison pour laquelle vous voulez être AFK.");

Worries :

Unexpected token  {

Who can help me?

mossy vine
#

oh jesus fucking christ

grim aspen
#

oh boy

west spoke
#

Eeek

mossy vine
#

im just gonna leave this here and get the fuck out of here

earnest phoenix
#

@mossy vine no need to tell me to read the doc I already checked!

grim aspen
#

i've never seen someone fuck args up so badly

mossy vine
#

this is fucking cursed

earnest phoenix
#

Codage :

let ${args[0]} = args.join(' ');
  if (!args.join(' ')) return message.channel.send ("Veuillez donner une raison pour laquelle vous voulez être AFK.");

Worries :

Unexpected token  {

Who can help me?

#

Now.

west spoke
#

Tbh for command args I just use a temporary file

#

Whobrokemyphone

earnest phoenix
#

Well, I'll fend for myself because I have no help xD

west spoke
#

Create file, write whole command to file, replace the command text to '' and just read the file. That's what I do

mossy vine
#

i sent you 2 links to pages that explain the var statement

grim aspen
#

what library are you using might i ask?

#

wanted to make sure

earnest phoenix
#

well

#

the huge tip is

#

check Javascript docs

#

and learn it

west spoke
#

^

earnest phoenix
#

anyone did those mistakes at first tho, don't worry!

west spoke
#

Took me almost a day to completely separate command args in python

earnest phoenix
#

I thought bots were only ran once, and that discord's servers dealt with it

west spoke
#

Nah

#

You keep it running

earnest phoenix
#

yeye

#

i remember when in DiscordSharpPlus' server

west spoke
#

xd

earnest phoenix
#

I made a very stupid question I got told to go learn C# properly

#

it might seem insulting at first, but in the future you just laugh thinking about it

west spoke
#

xd

earnest phoenix
#

No but I removed the Nan but I removed the var and I replace by let..

west spoke
#

Ima try to make a very basic coding language idk

earnest phoenix
#

hmmm

plucky geyser
#

Can I detect if a user is using the Dark theme on dbots?

earnest phoenix
#

as I said, try learning js in a better way

west spoke
#

@plucky geyser no I dont think so, and that would be best asked in #topgg-api

mossy vine
#

@earnest phoenix what is your code now?

earnest phoenix
#

lemme search a link!

plucky geyser
#

ok

mossy vine
#

wait actually there might be a way to check it

#

gimme a sec

earnest phoenix
#

I'll use the same link I used

#

for learning js myself

#
const Discord = require('discord.js');
const db = require('quick.db');

exports.run = async (client, message, args, tools) => {

  
  const status = new db.table('AFKs');

  let afk = await status.fetch(message.author.id);

  let ${args[0]} = args.join(' ');
  if (!args.join(' ')) return message.channel.send ("Veuillez donner une raison pour laquelle vous voulez être AFK.");
  
  const embed = new Discord.MessageEmbed()
    .setColor("RANDOM")

  if (!afk) {
    let setafkembed = new Discord.RichEmbed()
    .setDescription(`AFK défini avec succès sous : ${args[0]}`);
    message.channel.send(setafkembed)
    
    status.set(message.author.id, args.join(' ') || `Désolée, ${message.author.username} est AFK avec le statut suivant : ${args[0]}`);
    
  } else {
  	
    let changeembed = new Discord.RichEmbed()
    .setDescription('Vous n\'êtes plus sous AFK.');
     message.channel.send(changeembed)
     
    status.delete(message.author.id);
  }

  
  message.channel.send(embed);

}

module.exports.help = {
	name:"setafk"
}

@mossy vine

#

var ${args[0]} = args.join(' ');

#

what does this mean?

mossy vine
#

okay, so the problematic code is
var ${args[0]} = args.join(' ');

earnest phoenix
#

what should it do? that's unvalid syntax

#

@mossy vineI put let it's good, but it's the { in the args [0]

mossy vine
#

${} is used in strings, to tell javascript that whats inside it is not a string, but a variable or method

earnest phoenix
#

see this for that problem!

#

or also

mossy vine
#

if you just want to make the first element of the args array be args.join(), you dont need the ${}

earnest phoenix
#

this

#

and yeah, cyber (c but longer) is right!

#

thx

#
Error: Cannot find module '../build/better_sqlite3.node'

better SQLite 3 is installed

So what do I do? Xd

forest needle
#

Might be late, but I use JSON for my database and it's worked flawlessly for the past year.

earnest phoenix
#

How do I do it?

forest needle
#

It's pretty straight forward; just read on load and save occasionally.

earnest phoenix
#

And how do I save? I don't understand exactly what you want me to do.. [I am French]

mossy vine
#

read

#

the

#

fucking

#

docs

forest needle
#

My users file is over 100,000 lines; 1.8 MB lol

#
function save(){
    let data = JSON.stringify(users,null,2);
    
    fs.writeFile('./users.json', data, (err) => {  
        if (err) throw err;
    });
};
quartz kindle
#

i have 2 json files about 1.5mb each

earnest phoenix
#

@forest needle and I put it where its?

forest needle
#
    //part of the client.on 'message'
    if(GameCommands.hasOwnProperty(cmd)){
        msg.channel.send(GameCommands[cmd](msg,m));
        save();
        return;
    }
quartz kindle
#

my json file has 170k lines if you beautify it lul

forest needle
#

sample of my JSON

  "134800705230733312": {
    "nick": "EFHIII",
    "played": 44,
    "won": 43,
    "lost": 11,
    "tied": 5,
    "quit": 1,
    "netwin": -43,
    "bank": 286,
    "banned": false,
    "can": [
      "computer-science",
      "html",
      "javascript",
      "node.js",
      "other"
    ],
    "rated": 0,
    "rating": 0,
    "current": {
      "261225881647841280": "134800705230733312"
    },
    "lastVote": 1556764613837
  },
fiery stream
#

Nice

#

What does can mean

forest needle
#

It was supposed to be for a mentor program (Some people say what they can help with, others ask for help) but it doesn't seem to be used.

#

It's kinda too bad, I put a decent amount of work into this part of my bot, but it's gone unnoticed.

viral spade
#

Hey there i could really need some help!
after running though for a week, my bot just went offline. Now, without changing anything, when i try to start it again, i get ETIMEDOUT "Shard 0 took too long to become ready". What could that be? Maybe due to a bug, the discord rate limit got exceeded and now i have to wait?

#

Even my development botuser (other user and computer, but same ip) cannot log in

fiery stream
#

I think discord ip banned u for boy

#

Bot*

slim heart
#

whats the easiest way to turn an array of arrays into an array of all of its values

opaque eagle
#

Array.prototype.flat() @slim heart

#

JavaScript, right?

slim heart
#

ty

#

ye

opaque eagle
#

yw

earnest phoenix
#

I have a problem: (node:26652) UnhandledPromiseRejectionWarning: Error: send EPERM *redacted (secret IP)* at SendWrap.afterSend [as oncomplete] (dgram.js:526:11) (node:26652) 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: 22) (node:26652) [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.

#

What is this ?

opaque eagle
#

Do u happen to have written dgram.js?

#

Or is it from a module from npm/yarn

earnest phoenix
#

I thing it is from a module

#

But idk

opaque eagle
#

Ok

#

I'd just make sure that whenever ur accessing that module, ur passing in the proper info into any methods from the module that ur calling

earnest phoenix
#

The bot was hosted in a server, and i have all perms

opaque eagle
#

Does it happen to be a Windows server?

#

@earnest phoenix

earnest phoenix
#

Nop

#

Inux

#

@opaque eagle

opaque eagle
#

Ok just curious

#

What were u trying to do when the error was thrown?

earnest phoenix
#

Play command

#

It's work localy

#

But in the Linux server, no

opaque eagle
#

What does this play command look like?

earnest phoenix
#

It is a play command (music bot)

opaque eagle
#

Yeah, but I'm asking for the code

earnest phoenix
opaque eagle
#

That doesn't help.

earnest phoenix
#

I research on YouTube the song and i play it with FFMPEG

opaque eagle
#

Does the vps have ffmpeg installed?

earnest phoenix
#

Yes

opaque eagle
#

Okay... you still haven't shown the code btw

earnest phoenix
#

Now I’m on the phone, so I can’t show anything yet

opaque eagle
#

Oh

earnest phoenix
#

Unless. Wait I’ll try something

inner jewel
#

dgram is udp

#

so your OS is returning a perm error when sending udp packets

earnest phoenix
#

So how am I supposed to handle this when the bot has all the permissions?

#

@inner jewel

inner jewel
#

what kind of permissions

#

discord permissions or linux permissions

earnest phoenix
#

On Discord, on my side the bot has all the permissions, on the server side, it has the permissions to read files/ folders, to write files/ folders and I it’s more what (permissions code: 777)

#

I'm confuse

#

@inner jewel

earnest phoenix
#

Is SQL capable of being a database?

#

and can it handle 10-20 requests at a time?

bright spear
#

it is a database

#

well its a language that is used to communicate with a database according to a google search

earnest phoenix
#

oh ok thanks

hybrid oasis
#

SQL is how you query data in a database

#

Depending on the database, it can handle way more than 10-20 requests a second

#

Postresql is great, MySQL is okay, SQLite is good for tiny projects.

inner jewel
#

any real database can handle thousands of queries per second

#

unless they're some extremely complex operation

hybrid oasis
#

There’s way too many variables to consider to make a blanket statement like that

inner jewel
#

unless you're running it on a potato it should be able to handle thousands of "normal" queries per second

hybrid oasis
#

and now you have to define normal

#

And these normal queries, are they indexed properly?

inner jewel
#

regular selects/inserts/updates

hybrid oasis
#

That’s so vague

inner jewel
#

if you don't have the indexes you need for your queries it's an user problem, not database problem

hybrid oasis
#

Well no, the database has a problem and it’s called having to look through all the records instead of utilizing the index

inner jewel
#

that's an user problem

#

if you need to index on X and dont have an index for it

#

you're the one at fault

hybrid oasis
#

The user caused the issue, sure

soft eagle
#

how do i check if the bot has a permision if not to return a msg

#

my brain hurts from trying to do this

#

nvm got it

earnest phoenix
#

if(!bot.hasPermission("PERM")) return ...

#

@earnest phoenix What's your problem?

#

It's not a problem

silver lintel
#

i am using discord.js 11.4.2 and can someone please anylyze this bit of code?
so i have already got an array of the letters like var letterText = ["a", "b"...] so is the code below correct?

function checkIfLetterSame(letter) {
  if (!letter) {
    return;
  }
  for (var j = 0; j < 25; j++) {
    if (letter.toLowerCase() === letterText[j]) {
      return true;
    } else {
      return;
    }
  }
}

function checkWord(word) {
  let lengthOfWord = word.length;
  var currentLetter;
  for (var i = 0; i < lengthOfWord - 1; i++) {
    currentLetter = lengthOfWord.splice(i, i + 1);
    if (checkIfLetterSame(currentLetter)) {
      console.log("yes");
    }
  }
}
earnest phoenix
#

OK

#

I told @soft eagle how to fix ig

#

It

#

It should work @silver lintel

soft eagle
#

no i fixed on my own 😃

#

and it was if (!message.guild.me.hasPermison());

earnest phoenix
#

Okey

late hill
#

@silver lintel what are you trying to do

earnest phoenix
#

using discord.js is there a way to know how to add a blacklist using json

#

like a tutorial to learn from...

late hill
#

Your for loop in checkIfLetterSame() will never loop @silver lintel because it'll either return true or nothing on the first iteration

#

@earnest phoenix you can simply add a blacklist.json file looking like this

["BLACKLISTED_USER_ID", "BLACKLISTED_USER_ID"]```
and in your message event require that file and  check `if (blacklist.includes(msg.author.id))`
#

If you want to be able to edit the blacklist using commands however, you shouldn't use a json file

#

But a database instead

earnest phoenix
#

ooh ok

#

is it the same for a server

late hill
#

Blacklisting an entire server?

earnest phoenix
#

yep

#

so thats a bot can not join it

late hill
#

oh

earnest phoenix
#

my*

late hill
#

Then you'd best check in the guildCreate event

#

pretty much the same

earnest phoenix
#

OOh ok

#

thanks alot

#

😃 that helps alot

late hill
#

yes

#

and then just return guild.leave();

earnest phoenix
#

😃 ok. thankssssssssssssssssssssss

sinful lotus
#

I just want so seek for advice in closing mysql pool in node.js. How do you guys do it to make sure the pool gets closed?

earnest phoenix
#
pool.end(function (err) {
console.log("Closed!")
if(err) console.log(err);
});
spring ember
#

that's not exactly guarantying anything

sinful lotus
#

thats not what I was really looking for

earnest phoenix
#

Hmmm

#

Oh in node?

spring ember
#
process.on('SIGTERM', () => {
 ...
}
#

node will not shutdown until the event loop is empty

sinful lotus
#

but what I did is

const Watched_Events = ['beforeExit', 'SIGINT', 'SIGINT']
for (const event of Watched_Events) process.on(event, this._close_db.bind(this))
_close_db() {
    this.pool.close()
        .then(() => {
            console.log('Database Connections have ended gracefully, Shutting down.')
            process.exit()
        })
        .catch((error) => {
            console.error(error)
            console.log('Database Connections have encountered an error on trying to shut it down gracefully. Shutting down.')
            process.exit()
        })
}
#

do you think thats enough?

spring ember
#

don't do process.exit()

#

node will exit for you

#

this can cause recursion

sinful lotus
#

just remove the process.exit() and it should be ok?

spring ember
#

yes

#

you can read this as well

sinful lotus
#

ok thanks

#

mysql is a lot diff from using sqlite

spring ember
#

I was wrong about the process.exit()

sinful lotus
#

wait what it automatically closed the pool thonk

spring ember
#

umm

#

maybe it has it's own handlers

sinful lotus
#

probably, eitherways Imma keep it

#

just inase

#

case*

spring ember
#

good idea

karmic gulch
spring ember
#

add padding:0

#

to the style

karmic gulch
#

k

spring ember
#

also add ```html
<style>content { padding:0; }</style>

 before the iframe
karmic gulch
#

is this it? because still same result

<style>
  content { padding:0; }
</style>
<iframe style="width:100%;height:100%;margin:0;padding:0" src="https://example.com" frameborder="0" allowfullscreen></iframe>
spring ember
#

umm

earnest phoenix
#

How can i add a array into a sql table?

spring ember
#

what database do you use?

#

usually it is recommended to have multiple rows

#

instead of an array type

karmic gulch
#

is there a way?

spring ember
#

just try out things and use the chrome dev tools

earnest phoenix
#

@spring ember I'm making an inventory system so I need to use an array. I use MySQL

static matrix
#

when will the bot be approved

earnest phoenix
#

never

static matrix
#

Ok

#

:d

earnest phoenix
#

What can I use to replace Array in SQL that I can push things into it rather than a table because im making an inventory system?

nocturne moss
#

Hi

ruby dust
#

@earnest phoenix I recommend reading about primary keys, which still refers to having a separate table btw

earnest phoenix
#

@nocturne moss Hey! Needs some help?

nocturne moss
#

@earnest phoenix yea why i can't make bot in my server

earnest phoenix
#

How Long are you waiting? @nocturne moss

#

Or you want your bot to your server?

nocturne moss
#

Yea i want bot in my sever

earnest phoenix
#

So invite him

#

Give me his id

nocturne moss
#

How

#

I invite

earnest phoenix
#

Go discord applications

#

For developers

opaque eagle
#

This doesn't belong in #development, and there's an invite button in DBL

nocturne moss
#

Where

earnest phoenix
opaque eagle
#

Look at that invite btn

earnest phoenix
#

But he wanna his bot

opaque eagle
#

Ohh

earnest phoenix
#

It's not on page I think

nocturne moss
#

I cant

earnest phoenix
#

Tell me what you need?

amber fractal
#

bro

#

it tells you what to do

earnest phoenix
#

He XD

#

Ye*

#

Verifi your mail

amber fractal
#

"You need to verify your e-mail in order to perform this action."

nocturne moss
#

I just verifi my e-mail but can't

earnest phoenix
#

How you "can't"?

opaque eagle
#

Did u actually verify ur email?

#

I'd log onto settings and check

earnest phoenix
#

He prob won't

#

Discord is okey with that

#

It's operational

nocturne moss
#

Ty ini just dont

opaque eagle
#

How would I fix a socket hang up?

earnest phoenix
#

What you mean with an fix? @opaque eagle

opaque eagle
#
FetchError: request to <URL> failed, reason: socket hang up```
inner jewel
#

network error

opaque eagle
#

oh

#

Now it's giving me an ECONNRESET

#

:(

#

Public wifi sucks

earnest phoenix
#

Send the error

#

I think it's every 2-3 days?

opaque eagle
#
(node:7198) UnhandledPromiseRejectionWarning: FetchError: request to <URL> failed, reason: read ECONNRESET
    at ClientRequest.<anonymous> (/Users/sinistercyborg/Workspace/test/node_modules/node-fetch/lib/index.js:1453:11)
    at ClientRequest.emit (events.js:193:13)
    at TLSSocket.socketErrorListener (_http_client.js:397:9)
    at TLSSocket.emit (events.js:193:13)
    at emitErrorNT (internal/streams/destroy.js:91:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)
    at processTicksAndRejections (internal/process/task_queues.js:81:17)```
#

I'm just tryna send to a ShareX custom uploader with a POST request but this happens

earnest phoenix
#

Just every day destroy the client

#

@opaque eagle

opaque eagle
#

k

young jungle
#

does anyone know how to store the snowflake ID of a message as its sent

#

to edit later

opaque eagle
#

What language

#

And store as in store long-term or just within the program?

young jungle
#

Iv'e got it sorted now, thanks

opaque eagle
#
const fetch = require("node-fetch");
(async function() {

    const result = await fetch("an_endpoint_here", {
        method: "POST", body: [{
            "__Content-Type": "image",
            "filename": "a.jpg",
            "name": "file",
            "body": fs.readFileSync("./image.jpg").toString()
        }],
        headers: { "key": "a_key_here" }
    }).then(res => res.json());

    console.log(result);

})();``````sh
{ error: 'File is needed.' }```
modest monolith
#

How do you make a discord bot mass delete
messages
c#

ruby dust
#

it's called bulk delete, and it should be somewhere in the docs

lofty hamlet
#

I have error in my console : Maxlistenerswaring ... Possible EventEmitter memery leak detected. 11 error listeners added, use emmiter.setMaxlisteners() to increase limit

#

What is it ?

quartz kindle
#

you have too many .on("something")

lofty hamlet
#

@quartz kindle what ?

quartz kindle
#

.on("something")

lofty hamlet
#

Ah ok

quartz kindle
#

like .on("message")

lofty hamlet
#

And what does it do?

quartz kindle
#

you have too many

lofty hamlet
#

I have to divide into several files?

#

How i can patch this ?

quartz kindle
#

no, you have to stop using or accidentally creating them

#

show you full code

lofty hamlet
#

What ?

#

My have 5K Line dude 😂

#

I can't

wicked spade
#

thats why

quartz kindle
#

pastebin or something

lofty hamlet
#

No i can't share my all code of my bot

quartz kindle
#

then i cant help you

lofty hamlet
#

Why ?

#

I do just remove .on ?

#

But I need it

quartz kindle
#

because i need to see the entire code to see how you're creating that many event listeners

lofty hamlet
#

I don't understand why this write this

#

You can go to screenshare ?

quartz kindle
#

no

lofty hamlet
#

Hum 5K line dude

#

Just say me why he write this plz

#

And how i can patch this

quartz kindle
#

is your code like this? js .on("message" => { //code here }) .on("message" => { //code here }) .on("message" => { //code here })

lofty hamlet
#

No

#

This error takes only one file or all?

quartz kindle
#

the error means you have too many listeners

#

do you know what is a listener?

lofty hamlet
#

Hum ...

#

.on you say ?

#

No ?

quartz kindle
#

yes, .on() creates an event listener. that means that the code inside .on() will run forever, always waiting for an event to execute

#

if you have 2 .on() you have 2 functions running forever

#

the error says you have 11

lofty hamlet
#

Ahhh ok

#

I have 11 in same file ?

quartz kindle
#

in the whole bot

lofty hamlet
#

Or all of my file ?

quartz kindle
#

doesnt say whch file

#

your bot program has 11 codes running forever somewhere

lofty hamlet
#

It's not possible because in my index i have 9 and another file another 3-4

#

I have 7 files

#

My bot lights etc but what is this error?

quartz kindle
#

this is not an error, its a warning

#

because having too many event listeners will make the bot slow and your CPU high

#

because there are many things running forever

lofty hamlet
#

Ahhh ok !

#

And i need it of my .ons

quartz kindle
#

how many .on do you have?

lofty hamlet
#

In my all files ?

quartz kindle
#

yes

lofty hamlet
#

22

#

In my all files

quartz kindle
#

why so many?

lofty hamlet
#

My all warning

#

I need it

#

In each file i have one .on or 2

#

And in my index 9

quartz kindle
#

are they all different?

#

or do you have the same ones?

lofty hamlet
#

Yes or bot.on message in all many files

#

Exmple :

quartz kindle
#

then that is wrong

lofty hamlet
#

Why ?

quartz kindle
#

you should only have 1 of each type

#

1 on message
1 on guildMemberAdd
1 on etc

#

never 2 on message

lofty hamlet
#

I can't but is this in other file

#

In all file i have one .on message

#

I can't make other

quartz kindle
#

that is wrong

lofty hamlet
#

How i can ?

quartz kindle
#

because if you have 2 on message, you are duplicating everything

#

meaning your bot will be running the same code twice

strange trout
#

Use a command handler

lofty hamlet
#

Uh ok

quartz kindle
#

so your bot uses 2 times more cpu for nothing

#

if you have 5 on message, each message you receive, you bot will run 5 times

#

if you get 100 messages per second, you bot runs 500 functions

#

per second

lofty hamlet
#

Ah ok !

#

And how i can make ?

quartz kindle
#

use only 1 on message

#

and put everything inside it

lofty hamlet
#

Hum but i have 7 files

quartz kindle
#
.on("message" => {
    //code1
    //code2
    //code3
    // if command = something -> run file 1
    // if command = something else -> run file 2
    // etc
})```
lofty hamlet
#

Hum what

#

🤔

earnest phoenix
lofty hamlet
#

I do make one file for one c ommand ?

quartz kindle
#

you said you have 7 files, are they not commands?

lofty hamlet
#

No this a part with a lot of commands

#

Exmple one file for music command

#

One file for mod command

#

Etc

quartz kindle
#

how do you load the files?

lofty hamlet
#

In my index

quartz kindle
#

show the code that loads the files

#

and inside the files you have .on("message") ?

lofty hamlet
#

Yes

quartz kindle
#

make something like this

#

instead of .on("message"), make a function

#

instead of js client.on("message", message => { // your music code }) do this js function music(message) { //your music code }

lofty hamlet
#

🤔 a function for what ?

#

So i do create a function with a .on message

#

You say this no ?

quartz kindle
#

then in your index file do this js client.on("message", message -> { music(message); })

lofty hamlet
#

Oh ok !

#

Good idea

quartz kindle
#

.on("message") should be only in your index

#

not in the files

lofty hamlet
#

Oh ok !

quartz kindle
#

so in the end you have js .on("message", message => { music(message) welcome(message) etc(message) })

lofty hamlet
#

Ok i understand !

#

Ok ok

#

I go make this and i have some other errors :

#

Warning*

late hill
#

Discord having issues atm

quartz kindle
#

you should start catching promises

#

if you're using async/await, put promises inside try/catch blocks

#

if you're using .then() use .catch() as well

#

example ```js
channel.send("message").catch(console.log)

//or

... async message => {
try {
channel.send("message")
} catch(e) {
console.log(e)
}
}

lofty hamlet
#

Crash of discord '-'

#

@quartz kindle if i use async in .on 🤔

opaque eagle
#

Stop talking about that or else the mods will block this channel too

earnest phoenix
#

f for off topic and general

#

xd

opaque eagle
#

They already got rid of perms for us in #general cuz we were talking about the connection issues

#

Let's save this channel for serious discussions only

fresh dune
#

-join

opaque eagle
mellow dagger
#

I read on the website that the servers shouldn't be NSFW-related and we shouldn't write in the description that the server contains "nsfw" things, am I right??

west spoke
#

Yeah. How is this related to bot development?

earnest phoenix
#

Z

hybrid oasis
#

stopbeingabad.dev is the most obnoxious domain I've ever witnessed

#

irony, anyone?

amber fractal
#

Not the right place, but sure pal

hybrid oasis
#

you must have missed it being linked a bit ago

mossy vine
#

if a css file loaded after another one is loaded, will the one thats loaded later overwrite all !importants?

robust jackal
#

I'm looking for a discord bot that creates a message for users to react to. When the user reacts, they receive a role. When the reaction window is over, the list of users who have reacted can/will be listed (via user command or automatically). If anyone knows of a bot that can do said function, please mention me when answering.

mossy vine
#

search on the site

west spoke
#

@robust jackal this channel is for developing bots

#

Damn does anyone read?!

unique nimbus
#

Lazy

west spoke
#

reeitsjustthefacts

robust jackal
#

Well you see...uhh...I was developing a description of the bots function

#

yea

west spoke
#

...

#

developing bot code

#

Lemme rephrase that

robust jackal
#

heh I know

west spoke
#

xd

robust jackal
#

Told a reddit user I would help him find a bot for something he wanted, and the bot that I thought could do that function didn't.

#

So I have been a bit hasty finding possible bots to meet his need.

earnest phoenix
#

I coded a system that allows that, when a bot joins a server, it sends a message regarding the information the server joins in a salon where the bot has access, but it does not work:/

code :

bot.on ('guildCreate', guild => {
	module.exports  = async (client, guild) => {
    const invite = await guild.channels.find(c => c.type !== "category" && c.position === 0).createInvite({
        maxAge: 0
    });
    let guildCreateChannel = guild.channels.find(`name`, "nouveau serveur");
    let abcEmbed = new Discord.RichEmbed()
    .setTitle("J'ai rejoind un serveur !")
    .setThumbnail(guild.iconURL)
    .addField(`Nom du serveur :`, `${guild.name}`)
    .addField(`Identifiant du serveur :`, `${guild.id}`)
    .addField(`Propriétaire du serveur :`, `${guild.owner}`)
    .addField(`Invitation au serveur :`, `${invite.url}`)
    .setColor("RANDOM")
    .setFooter(`TheKıng`)
    .setTimestamp();
    guildCreateChannel.send(abcEmbed);
}
});```
#

Who could possibly help me? (I read the doc to be able to make this system)

spring ember
#

You respond to the wrong event

earnest phoenix
#

I put her:

bot.on('guildCreate', message => {
spring ember
#

Oh wait nvm

#

Does the server has a channel with that name?

earnest phoenix
#

Yes, but I have to put a dash enters the coding? (the console shows me varandaine error)

spring ember
#

Yeah text channels can't have whitespace

earnest phoenix
#

Yes, but in the coding, I put the dash?

inner jewel
#

they can have whitespace

spring ember
#

Yes

inner jewel
#

the client just doesn't allow it

spring ember
#

Really?

#

That's dumb tbh

earnest phoenix
#

instead of Guild, I put message?

inner jewel
quartz kindle
spring ember
#

Mhm

earnest phoenix
#
bot.on('guildCreate', message => {

or

bot.on('guildCreate', guild => {

?

spring ember
#

I think it's the guild

#

Yeah it is

quartz kindle
#

it does not matter what you write there lol

#

you can name the returned object anything you want

earnest phoenix
#

ok

spring ember
#

Module.exports corrupts the file a little bit

#

That one

earnest phoenix
#

yes

quartz kindle
#

that line is completely wrong lol

earnest phoenix
#

now, I have is :

bot.on ('guildCreate', guild => {
	
    const invite = guild.channels.find(c => c.type !== "category" && c.position === 0).createInvite({
        maxAge: 0
    });
    let guildCreateChannel = guild.channels.find(`name`, "nouveau-serveur");
    let abcEmbed = new Discord.RichEmbed()
    .setTitle("J'ai rejoind un serveur !")
    .setThumbnail(guild.iconURL)
    .addField(`Nom du serveur :`, `${guild.name}`)
    .addField(`Identifiant du serveur :`, `${guild.id}`)
    .addField(`Propriétaire du serveur :`, `${guild.owner}`)
    .addField(`Invitation au serveur :`, `${invite.url}`)
    .setColor("RANDOM")
    .setFooter(`TheKıng`)
    .setTimestamp();
    guildCreateChannel.send(abcEmbed);
}
});```
#

I think it's good, I'll try.

spring ember
#

You didn't remove that bracelet

#

In the end

earnest phoenix
#

Oh yes, thank you

quartz kindle
#

that will create errors if your bot doesnt have create invite permission

#

also, creating invites for every server your bot joins is not nice

amber fractal
#

I think that's against the terms

quartz kindle
#

also, that way to use .find() is deprecated

amber fractal
#

not without permission or expressly stating it

quartz kindle
#

and you will not even find the channel to send in

#

you're trying to locate a channel named "nouveau-serveur" in the guild your bot joined, not your guild

earnest phoenix
#
TypeError: Cannot read property 'send' of null```
#

uh..

amber fractal
#

he just told you

#
you're trying to locate a channel named "nouveau-serveur" in the guild your bot joined, not your guild```
earnest phoenix
#

Okay I see I look at that

#

guild.channels.id.find

#

or

#

guild.channelsid.find

#

uh

#

the

#

second?

amber fractal
#

no, you use your client

#

and get it

#

if it's your server, or you have access you can get the id

earnest phoenix
#

I know the blow is his:

amber fractal
earnest phoenix
#
let guildCreateChannel = guild.channel.id.find("574309560995676160");
west spoke
#

Why is js so complex xd

earnest phoenix
#

idk

smoky spire
#

Tf is that

#

everything about that is wrong

buoyant wagon
#

use .get() if you wanna use id

earnest phoenix
#

thx

#

and now :

guild.channels.id.get("574309560995676160");```
smoky spire
#

guild.channel isn't a thing
find is a method on collections not a string
and that's not the syntax for find

earnest phoenix
#

i test this

buoyant wagon
#

~~```js
guild.channels.get("574309560995676160");

#

but that would work only for one server

guild.channels.find(c => c.name === "nouveau-serveur");
earnest phoenix
#
guildCreateChannel.send(abcEmbed);
                       

TypeError: Cannot read property 'send' of undefined

really weird

mossy vine
#

the fuck

#

guildCreateChannel makes no sense

#

what

buoyant wagon
#

?

mossy vine
#

read the fucking docs please

hybrid oasis
#

I second reading the docs, but in a much nicer tone

earnest phoenix
#

@mossy vine speaks better

hybrid oasis
#

I'd recommend a combination of reading the docs and possibly console.log to see what values you're getting

mossy vine
#

^

west spoke
#

^^

buoyant wagon
#

mossy vine
#

console.log has saved me hours of bullshit tbf

earnest phoenix
#

GuildCreateChannel is :

let guildCreateChannel = guild.channels.get("574309560995676160");```

 @mossy vine
mossy vine
#

what does console.log(guildCreateChannel) output

west spoke
#

Channel name most likely

hybrid oasis
#

hmmm I'd expect a channel object

buoyant wagon
#

^

earnest phoenix
#

Hello everyone

#

But I want him to send in a specific salon, but odd that the send doesn't pass ^^

mossy vine
#

what does console.log(guildCreateChannel) output

earnest phoenix
#

@mossy vine stop

mossy vine
#

im trying to help wtf

earnest phoenix
#

I want him to send it in a textual salon, not in the console..

west spoke
#

@earnest phoenix be nice

earnest phoenix
#

I know and thank you

west spoke
#

He's just trying to help

mossy vine
#

im telling you to console.log it to make sure its a channel object

earnest phoenix
#

I know and I am grateful

west spoke
#

thenwhyyoubeinmeaN

earnest phoenix
#

Okay, I can give you the coding for you to look at why the word send doesn't want to work?

hybrid oasis
#

we're trying to help you learn how to figure it out instead of giving you the answer

#

you should do what the c longer person said and console.log the result

earnest phoenix
#

That is the purpose of the question, to understand and to be explained..

hybrid oasis
#

okay cool, so what is the result of that console.log then?

earnest phoenix
#

this :

#
guildCreateChannel.send(abcEmbed);
                       

TypeError: Cannot read property 'send' of undefined
hybrid oasis
#

not a console.log, but okay

earnest phoenix
#

no

hybrid oasis
#

do you know what the error means?

buoyant wagon
#

maybe no channel has that id

earnest phoenix
#

If I can't solve it, I'll use the log console

mossy vine
#

just fucking console.log it so we can make sure its a channel object

#

because if its not a channel, chances are you cant send anything to it

earnest phoenix
#

Yes, that he can not send? Or send is not defined

hybrid oasis
#

no, it's saying that guildCreateChannel is undefined

mossy vine
#

its not undefined, its just most likely not a channel

quartz kindle
#

its undefined because he's looking for a channel in the wrong server

mossy vine
#

oh yeah

#

client.channels.get would work tho, no?

earnest phoenix
#
	
    const invite = guild.channels.find(c => c.type !== "category" && c.position === 0).createInvite({
        maxAge: 0
    });
    let guildCreateChannel = guild.channels.get("574309560995676160");
    let abcEmbed = new Discord.RichEmbed()
    .setTitle("J'ai rejoind un serveur !")
    .setThumbnail(guild.iconURL)
    .addField(`Nom du serveur :`, `${guild.name}`)
    .addField(`Identifiant du serveur :`, `${guild.id}`)
    .addField(`Propriétaire du serveur :`, `${guild.owner}`)
    .addField(`Invitation au serveur :`, `${invite.url}`)
    .setColor("RANDOM")
    .setFooter(`TheKıng`)
    .setTimestamp();
   guildCreateChannel.send(abcEmbed);
});

The ID of the Salon is in the server support of my bot.. and my bot has access to it.

mossy vine
#

oh its not even a channel id

quartz kindle
#

yes, but if you use guild. you're looking for it in the guild you just added

#

to find that channel you must look for it in the client, not in the guild object

earnest phoenix
#

So I put message?

buoyant wagon
#

bot.channels might work better

quartz kindle
#

his client is named bot, watch him literally type "client"

earnest phoenix
#

ok

quartz kindle
#

lmao

hybrid oasis
#

they may not have a good grasp of understanding that values have types

#

which is a pretty common issue in JS land

quartz kindle
#

yes, he should learn some javascript

#

hes been told millions of times

hybrid oasis
#

I assume they're trying

earnest phoenix
#

Yes, but when you're French and. that the site is English, we have a little trouble..

quartz kindle
#

there must be some french site for learning javascript

earnest phoenix
#

Either its sites weird and not detailed, or it is not very well translated..

hybrid oasis
#

also reading about JS and actively solving problems in JS are totally different

earnest phoenix
#

I prefer to go on the official documentation, although it is in English I still have the translation of Google, but I am obliged to go to the site Google translation, select the sentence, understand etc.. and it takes time.. Despite also that my English is not so strong that its ^^

quartz kindle
#

which documentation are you reading?

earnest phoenix
quartz kindle
#

thats not documentation for javascript, thats just for the discord.js library

#

you are working with 3 different things

earnest phoenix
#

Yes, I strongly help to encode commands. It is thanks to this site that I made the 3/4 command of my bot.

quartz kindle
#

javascript is the language itself
node.js is the program that runs javascript code
discord.js is a javascript program that connects to discord

#

all three of them are separate things, which have to be studied and learned independently

#

and each have their own documentations

#

the website for discord.js is only about functions in discord.js, nothing about javascript itself

earnest phoenix
#

All right, thanks for the information. During this time I put under console log

hybrid oasis
#

strong disagree on learning them independently

#

especially considering that nodejs is a runtime + stdlib for JavaScript

quartz kindle
#

and you're having problems because you lack understanding of javascript, the language, not the library

earnest phoenix
#

This site

quartz kindle
#

thats for learning to use node for creating programs

#

for javascript itself, try this

#
earnest phoenix
#

It's pretty interesting, I'd see to

#

tomorrow

quartz kindle
#

@hybrid oasis you have to learn them independently because node is a different environment from a web browser for example

#

so if you learn browser javascript, you will have some troubles writing node javascript and vice versa

#

assuming you're writing code that interacts with the environment, not just simple js logic

hybrid oasis
#

It's still JavaScript. it's just about exactly the same except what you can import

quartz kindle
#

not if you interact with the invironment

#

ie: document/window vs fs

hybrid oasis
#

okay, window is replaced with global and you don't have document

#

but one is very specifically working with the dom

#

and nobody is going to be like bot.querySelectorAll('channel')

quartz kindle
#

lmao

#

yes, but when you learn javascript, most of the time you're going to learn how to use it for some specific use

hybrid oasis
#

well you know the API's for those specific things which don't apply to writing a bot. I don't understand how that would confuse anyone

quartz kindle
#

so depending on the tutorial, they'll tell you to start doing document.querySelector or require("fs")

hybrid oasis
#

yeah, which the script will quickly tell you "haha no"

quartz kindle
#

yes lol

hybrid oasis
#

they've already got most of a bot, I don't think telling them to go back and learn node API's or JS itself is going to do much help. the best way to learn imo is by doing

#

if anything they probably need to spend more time flailing around trying to solve it but 🤷

quartz kindle
#

well, yeah, i was just explaining him what hes dealing with

#

because he thought the discord.js docs are docs for javascript itself lol

hybrid oasis
#

or it's a translation issue/misunderstanding

buoyant wagon
#

if you turn on light mode you will see difference DONT USE LIGHT MODE

quartz kindle
#

what do you mean with "getting" them

inner jewel
#

set color to dark theme background

earnest phoenix
#

Lol

lofty hamlet
#

I'm back

#

So @quartz kindle i have another warning

#

Look all warning ^^

quartz kindle
#

does discord look black to you?

#

thats your answer lmao

#

@lofty hamlet your code is a mess. fix it. good night

lofty hamlet
#

Okay but for memory leak for .on i I can not do it

quartz kindle
#

i told you what to do

lofty hamlet
#

Yes but :

#

I can not make this

#

I do make a module.export ?

#

Yes ?

quartz kindle
#

yes, export the function

lofty hamlet
#

But i can't

idle basalt
#

?

mellow dagger
#

@west spoke sorry for the ping and also sorry because I didn't know that this channel is only for bot developing, someone in general told me to ask here for questions about DSL

idle basalt
#

general smh

bright spear
#

what

lofty hamlet
#

Put all his commands in a switch

#

Is Not recommended ?

hybrid oasis
#

@lofty hamlet you need to explain what you're talking about in much more detail. we have no idea what you mean

#

code always helps

west spoke
#

@mellow dagger excuse me what.

mellow dagger
#

I asked in #general where I can put my questions about @pliant gorge , like a support channel, and someone told me to write them here

west spoke
#

DSL doesnt have any commands

#

You add it to your server to put your server onto the DSL website..

mellow dagger
#

I know, I have a doubt in listing my server
I read that we can't list NSFW-related in any kind servers, does this also mean that we cannot list a server that has for example only one nsfw channel which can be disabled through reaction roles?

spring ember
#

You can't add NSFW intended servers you can have a non main channel for that

lofty hamlet
#

I have in my code : switch (args[0].toLowerCase()) { //command } var args = message.content.substring(prefix.length).split(" "); why i can't make a command test 1 and test 2 ?

#

🤔

mellow dagger
#

Ok, thanks dondish👍

spring ember
#

@lofty hamlet you splitted by whitespace

lofty hamlet
#

Uh ok ?

spring ember
#

So args[0] can't have a whitespace in it

lofty hamlet
#

Ah ok i understand

spring ember
#

Otherwise it would have been splitted

#

?

lofty hamlet
#

Fail

#

@spring ember i don't understand why i can split by space

prime cliff
#

What is wrong with it and does it produce any errors?

#

Also you dosen't have a permission check if the bot does not have kick member perms dboatsYeetus

amber fractal
#

webhook -> db -> check db

earnest phoenix
#
my bot has all the permissions and my bot can not kick```

hierarchy issue or you're trying to kick the owner of the guild
#

bot cannot kick anyone who has roles equal to or above bot's highest role

earnest phoenix
#

and .kick is a promise

#

also members can be uncached

#
client.on('message', async message =>{
    if (!message.guild) return
    let args = message.content.trim().split(/ +/g)

    if (args[0].toLocaleLowerCase() === prefix + 'kick'){
        if (!message.member.hasPermission('KICK_MEMBERS')) return message.channel.send("You are not allowed to use this command ;(")
        const user = message.mentions.users.first();
        if (!user) return message.channel.send("please mention a user ❌");
    const member = await message.guild.members.fetchMember(user);
        if (member.highestRole.calculatedPosition >= message.member.highestRole.calculatedPosition && message.author.owner.id) return message.channel.send("you can not kick this user")
        if (!member.kickable) return mesasge.channel.send("I can not exclude this user")
        await member.kick()
        return member.channel.send(member.user.username + 'was excluded ✅')
    }
})
``` assuming ur using d.js stable
idle basalt
#
client.on('message', async (message) => {
  if (!message.guild) return;
  const args = message.content.trim().split(/ +/g);

  if (args[0].toLowerCase() === 'kick') {
    if (!message.member.hasPermission('KICK_MEMBERS')) return message.channel.send('You are not allowed to use this command.');

    const member = message.mentions.members.first();
    if (!member) return message.channel.send('Please mention a user.');

    if (member.highestRole.calculatedPosition >= message.member.highestRole.calculatedPosition) return message.channel.send('You cannot kick this user.');

    if (!member.kickable) return message.channel.send('I cannot kick this user.');

    await member.kick();
    return message.channel.send(`${member.displayName} was kicked.`);
  }
});
```at least spoonfeed some readable code
#

with correct syntax and properties

earnest phoenix
#

@idle basalt Im not spending 20s+ to fix code

#

also at least send the correct code

worldly rain
#

anybody here know how to install ssl certs on aws?

quartz kindle
#

certbot

worldly rain
#

on aws

mossy vine
#

certbot

worldly rain
#

err, as in my shit is in an s3 bucket

earnest phoenix
#

certbot

#

Is using MongoDB and SQL together ok?

#

Yes, itd okey, I think

harsh dagger
#

ok so im having a problem with my code

#
  if(message.isMentioned(Bot.users.get("561968604334260244"))){
    message.channel.send("Yes, what do you want?");
  }
})

problem is that when i mention it it spams yes what do you want?

slender thistle
#

Are you doing Bot.on("message") more than once

harsh dagger
#

no

#

wait

#

lemme see

#

i do

#

am*

#

@slender thistle

slender thistle
#

That's the issue

harsh dagger
#

oh

slender thistle
#

Your bot will respond to any bot and any DMs it will get if possible

harsh dagger
#

so i have to keep that

#

yet it still spams

#

oh wait

#

made it work now

earnest phoenix
#

Lol

earnest phoenix
#

@earnest phoenix ouep

robust anvil
#

how to make a bot online

mossy vine
#

@robust anvil you write code for it

#

do you know any programming languages?

vestal swallow
#

@earnest phoenix yep pk ? Parles en anglais par contre. C'est anglais seulement -> #rules-and-info

  • Translation -
    Yep why ? You have to speak english here. That's an english-only server -> #rules-and-info
robust anvil
#

i know pydroid

#

python

earnest phoenix
#

@robust anvil Go search discord.py tutorials on google and you can make your bot online.

earnest phoenix
#

what is the code for the bot to show on the website how many shards it is in and how many servers; i did this and idk why it is no appearing

bot.on("ready", () => {
const request = require("request");

request.post({
url: https://discordbots.org/api/stats/bot/${bot.user.id},
form: {
serverCount: bot.guilds.size,
shardCount: bot.guilds.shard,
authorization: ""
}
});
});

#

authorization is supposed to go in the headers

lofty hamlet
#

For a discord bot : CLOUD,SSD or RAM ?

opaque eagle
#

Check pins

coarse cove
#

i have a error, can you help me ?

(node:5188) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 message listeners added. Use emitter.setMaxListeners() to increase limit
warning.js:18
(node:5188) UnhandledPromiseRejectionWarning: Error: getaddrinfo ENOTFOUND discordapp.com discordapp.com:443
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:56:26)
warning.js:18
(node:5188) 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: 2)
warning.js:18
(node:5188) [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.````
broken elm
#

so im using a giphy api

#

and i can't figure out how to use the response it gives me

#
{ data:
   [ { type: 'gif',
       id: 'uLnPIWsqIz2aA',
       slug: 'pokemon-look-pikachu-uLnPIWsqIz2aA',
       url: 'https://giphy.com/gifs/pokemon-look-pikachu-uLnPIWsqIz2aA',
       bitly_gif_url: 'https://gph.is/1dAWL60',
       bitly_url: 'https://gph.is/1dAWL60',
       embed_url: 'https://giphy.com/embed/uLnPIWsqIz2aA',
       username: '',
       source: 'https://gif-database.tumblr.com/post/18010720856',
       rating: 'g',
       content_url: '',
       source_tld: 'gif-database.tumblr.com',
       source_post_url: 'https://gif-database.tumblr.com/post/18010720856',
       is_sticker: 0,
       import_datetime: '2013-07-15 20:26:08',
       trending_datetime: '1970-01-01 00:00:00',
       images: [Object],
       title: 'searching look around GIF',
       analytics: [Object] },
     { type: 'gif',
       id: '7T200DTPdx31e',
       slug: 'pokemon-videogame-7T200DTPdx31e',
       url: 'https://giphy.com/gifs/pokemon-videogame-7T200DTPdx31e',
       bitly_gif_url: 'https://gph.is/XHDQDN',
       bitly_url: 'https://gph.is/XHDQDN',
       embed_url: 'https://giphy.com/embed/7T200DTPdx31e',
       username: '',
       source: 'https://gifloop.tumblr.com/post/2748179648',
       rating: 'g',
       content_url: '',
       source_tld: 'gifloop.tumblr.com',
       source_post_url: 'https://gifloop.tumblr.com/post/2748179648',
       is_sticker: 0,
       import_datetime: '2013-03-25 07:50:00',
       trending_datetime: '1970-01-01 00:00:00',
       images: [Object],
       title: 'pokemon videogame GIF',
       analytics: [Object] },
#

so how would i get the lets say second response

#

i've tried

#

res.data.url

#

and sending it as a message

#

this is discord js btw

tribal turtle
#

Does anyone know how to generate invite links for every server the bot is in?

buoyant wagon
#

i do but thats not very nice

tribal turtle
#

ah ke

slender thistle
#

If consent to that was not given or the users are uninformed, that's a ToS violation

limber swan
#

I have this error and i try installing ffmpeg but never works

earnest phoenix
#

npm i ffmpeg --save

#

you need with lowercase

limber swan
#

yeah, i know

#

i already did it, but it doesnt work

earnest phoenix
#

program?

limber swan
#

vsc

earnest phoenix
#

try to re-install vsc

#

i have friend

#

who has

#

same problem

limber swan
#

i did it, but nop

earnest phoenix
#

are you downloaded blue vsc or purple?

limber swan
#

blue

earnest phoenix
#

try purple

#

or basiclly

#

try to use atom editor

limber swan
#

alright, let me get it

earnest phoenix
#

or glitch

limber swan
#

with atom is the same problem

coarse cove
#

Always the this error... can you help me ?

    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:56:26)
warning.js:18
(node:6372) 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: 2)
warning.js:18
(node:6372) [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. ```
limber swan
#

have the hole error?

coarse cove
#

I did not understand your question

limber swan
#

i mean, can you show the hole log error?

hybrid river
coarse cove
#

i have just that on the debug console

    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:56:26)
(node:6200) UnhandledPromiseRejectionWarning: Error: getaddrinfo ENOTFOUND discordapp.com discordapp.com:443
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:56:26)
(node:6200) 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: 2)
(node:6200) [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.
ping.js commande chargée !
say.js commande chargée !
support.js commande chargée !
2 events chargés ```
#

30 minutes ago it still works. and it's all of a sudden, without anything having changed it down

wraith cipher
#
websockets.exceptions.ConnectionClosed: WebSocket connection is closed: code = 1006 (connection closed abnormally [internal]), no reason
#

When I try to run my bot this error pops up and it stop

#

any idea what it means ?

slender thistle
#

@wraith cipher Looks like your Internet has issues

wraith cipher
#

The bot was running in a VPS

#

I mean I executed it over there

slender thistle
#

Seems to be your bot abnormally closing the connection or Discord doing weird shit

wraith cipher
#

probably discord >.<

#

just made a basic bot file and used my old bot's token

#

no commands seem to be working

#

it just prints the on_ready stuff

#

but my other bots are working fine...

#

its just this bot app which is causing the issue

slender thistle
#

Send your code

wraith cipher
#
import os, asyncio
import discord, datetime
from discord.ext import commands

abspath = os.path.abspath(__file__)
dname = os.path.dirname(abspath)
os.chdir(dname)

bot = commands.Bot(command_prefix=',')

TOKEN = ""


@bot.event
async def on_ready():
    print("--------")
    print("Logged in as:")
    print(bot.user)
    print(bot.user.id)
    print('--------')
    

@bot.check
async def globally_block_dms(ctx):
    ''' Dissable DM commands'''
    return ctx.guild is not None


@bot.event
async def on_command_error(ctx, error):
    
    if isinstance(error, commands.CommandNotFound):
        return

    elif isinstance(error, commands.BotMissingPermissions):
        await ctx.send(f"I need the following permission(s) to make to make this command work {error.missing_perms}")

    elif isinstance(error, commands.CommandOnCooldown):
        wait = datetime.timedelta(seconds=int(error.retry_after))
        await ctx.send(f"This command is on cooldown, please retry in {wait}.")

    else:
        raise error


for cog in os.listdir('cogs/'):
    if cog.endswith('.py'):
        try:
            cog = f"cogs.{cog.replace('.py', '')}"
            bot.load_extension(cog)
        except Exception as e:
            print(f"Error with {cog} reason:\n")
            raise e

async def playing():
    await bot.wait_until_ready()

    while not bot.is_closed():
        total_users = len(set(bot.get_all_members()))
        await bot.change_presence(activity=discord.Game(name='asd with {:,d} users'.format(int(total_users)), type=1))
        await asyncio.sleep(300)


bot.loop.create_task(playing())

bot.run(TOKEN)
#

that's my main file ^

earnest phoenix
#

hey someone know how to make vote webhook? in js

wraith cipher
#

and also for some reason it prints the on_ready stuff twice... I'm loosing my mind right now x_x

slender thistle
#

Why are you doing os.chdir

#

Also, do you import your main file from your cogs

wraith cipher
#

to change the working dir to the root files of my bot

slender thistle
#

... just so that you could use your bot files?

#

Even though you are already in your bot folder

wraith cipher
#

yea.. what if I'm not..

slender thistle
#

return os.path.dirname(file) gives me the path of the file I run RenShrugGif

#

Or do you mean running the file from other folders

wraith cipher
#

I also need to list the cogs folder

#

and load all the cogs there

#

does that matter ?

#

my commands aren't working

#

and now the on_message stuff prints 3 times gg

#

the on_message func should just run once right ?

slender thistle
#

Yes

wraith cipher
#

I think its connecting to the application multiple times

#

ahgg

wraith cipher
#

ohh sorry didn't see that

#

no I don't import my main file from my cogs

slender thistle
#

I would suggest restarting your VPS and running the bot

wraith cipher
#

okay... I'll give it a try

#

thanks

thorn nexus
#

d.js how to get the number of all users in the server's voice channels?

buoyant wagon
#

ik

#
voiceChannel.members.size
#

it gets the number of users in a voice channel

grim aspen
warm epoch
#

Hey, so I've noticed I was getting "Missing Permissions" errors in my console, which turned out to be because my bot is on this server and it tried to interpret commands prefixed with "!", the poor thing, so it got muted for mentioning it doesn't know such commands.

I can just add some special exception for this "guild" so it doesn't do that, but my question is: it does check for permissions beforehand, so it technically shouldn't even get to this point. Anyone knows why it might work like that?

west spoke
#

Ok could someone help me. I have the eval command, how would I use it to force-leave a server.

#

I just need the script for it. That's it.

hushed quarry
#

async is deprecated and no support is given for it in the d.py server

#

switch to the main/rewrite

west spoke
#

Ik i won't get help from there. I've written stuff for async and I am switching over. I just need to be able to have my bot leave a certain server.

hushed quarry
#

just run a quick rewrite bot with a ready event and code to leave a server

#

would take 3 minutes

pliant needle
#

If on connect server == this:
Server disconnect

#

So it will auto leave on join

west spoke
#

uh

pliant needle
#

Ik that isn't code

#

Just in case you had a specific server in mind

warm epoch
#

Hmmm. I'm guessing I need to check for rolePermissions as well, but I am not sure how exactly they work to begin with. Like, if, say, a GuildMember has two roles, one of which disallows sending messages and the other allows that, which one "wins"?

hushed quarry
#

@west spoke also you kinda shot yourself in the foot by taking so long to move over to the rewrite... wasn't the rewrite in development since like 2017

#

so you will deal with issues like this if you're just moving over

west spoke
#

@hushed quarry I'm not asking for criticism I'm asking for help

hushed quarry
#

and, as i said, you will deal with issues like this since async is deprecated and the fact you had 2 years to move over

#

you could've had it finished already

#
async def on_ready(self):
    for guild in list(client.guilds):
        if guild.id == 1234:
            await guild.leave()
slender thistle
#

No need to list() a list

hushed quarry
#

you do if you're leaving it

#

since it'll be removed from the list

#

and the indicies will be fucked up

#

i guess not for that example

#

since it's just leaving one

#

but it's still good python practice nonetheless if you're removing things from lists and iterating over it

slender thistle
#

How does a list() help you leave an object out of a list

hushed quarry
#

because it's a clone of a list

#

if you leave/delete things with d.py, the original list will be modified and the indicies will be messed up

#

so you can iterate over it like normal

slender thistle
#

.guilds gets updated either way

hushed quarry
#

not with list()...

#

list() makes a clone of a list, so deleting things does NOT affect the list() copied list of it

slender thistle
wraith cipher
slender thistle
#

Are you even saving that cloned list in any var

hushed quarry
#

???

slender thistle
#

I do not, and that is my question

hushed quarry
#

why would I have it in a variable

#

for a stupid ping pong example!?!

slender thistle
#

Because you wanted a list that wouldn't have an object that was deleted from client.guilds?

hushed quarry
#

??????

#

write the code to demonstrate it

slender thistle
#

My initial question was why list was casted on client.guilds if it was already a list which would get updated after you leaving a guild

hushed quarry
#

because with the way python works, the iteration gets fucked up if you're deleting things from a list that you're also iterating over, leaving things to skipping elements, etc

slender thistle
#

Ah, that's right

hushed quarry
#

list() prevents this by cloning the list, so you can delete things normally and the iterations won't get fucked up

slender thistle
#

Alright, got it

#

I remember my iterating getting fucked up on dicts, hell yes, I remember that

idle basalt
#

which lib do you work on shiv

slender thistle
#

dblpy

idle basalt
#

ah its a role for dbl libs?

mossy vine
#

yes

idle basalt
#

alright, sorry offtopic was just wondering lol

west spoke
#

hhhhhHhHHHH

#

MMMMMMMMM

#

I swear ..

#

I had to make so many changes to your God damn code

#

And it still doesnt work

idle basalt
#

who

wraith cipher
#

so you've shifted to rw

#

well atleast now you can get help

west spoke
#

reeeeEEEE

quartz kindle
#

make a new bot and rebuild it from scratch on the new lib

#

thats what im doing moving from v11 to v12

west spoke
#

I just wanted help for ONE THING

wraith cipher
#

v11 to v12 ?

idle basalt
#

if its js i can try to help

warm epoch
idle basalt
#

no theyre options

#

just various methods to get various permissions

warm epoch
#

Okay, that's neat.

topaz moth
#

in the readme for DBLPY's github there is a voting listener (on_dbl_vote), i cant seem to find any information on it though, even when looking through the code. has anyone got any info on it?

wanton walrus
#

Howdy - so in the rewrite of my bot, I am building most things into the cache- as in, all player, and guild data is loaded in on startup, so I don't have to ping the database constantly.

Now, I update everything in the cache when interactions occur, etc, and every 45 minutes I want to upload those changes to the database in the background. I would be updating about ~20000 user accounts in the database from the cache, and I have made a function to limit the loop speed of the updates to the database. About how long should I wait between each transaction to keep it from 1) hitting the database too hard, and 2) keep it from waiting a very long time to upload changes

I'm not 100% positive on a good time, so I figured I would ask here

quartz kindle
#

is your cache inside your bot's memory or something like redis?

inner jewel
#

any real database will have no issues being hit with 20k queries

wanton walrus
#

👌 cool, I figured it shouldn't be a large issue

#

@quartz kindle Bots memory, didn't need anything more complex

slender thistle
#

So what's your current code

robust acorn
#
  File "/home/runner/.local/lib/python3.6/site-packages/discord/ext/commands/bot.py", line 846, in process_commands
    yield from command.invoke(ctx)
  File "/home/runner/.local/lib/python3.6/site-packages/discord/ext/commands/core.py", line 374, in invoke
    yield from injected(*ctx.args, **ctx.kwargs)
  File "/home/runner/.local/lib/python3.6/site-packages/discord/ext/commands/core.py", line 54, in wrapped
    raise CommandInvokeError(e) from e
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: KeyError: 'voted'```
#

It keeps giving me this error

#

It probably never made it to the site

#

and never obtained the response

slender thistle
#

It did

#

Try to print the entire dict/json and see what's up

robust acorn
#

I think the url is wrong

#

I am using python 3.6.1

slender thistle
#

What's the URL

robust acorn
#

https://discordbots.org/api/bots/514146427186839552/check?userId={message.author.id}

#

and i formatted

slender thistle
#

Looks fine

wraith cipher
#

wait

#

isn't it supposed to be ctx.author.id in a command ?

robust acorn
#

what are different ways of obtaining the user.id

slender thistle
#

Depending on where you are obtaining the author from

robust acorn
wraith cipher
robust acorn
#

I did

#

now

slender thistle
#

Is it a command

wraith cipher
#

he's obtaining it from a command

robust acorn
#

yes

slender thistle
robust acorn
#

so message is not defined

slender thistle
#

Send your command code Thonk

wraith cipher
#

yea lol

robust acorn
#
Traceback (most recent call last):
  File "/home/runner/.local/lib/python3.6/site-packages/discord/ext/commands/bot.py", line 846, in process_commands
    yield from command.invoke(ctx)
  File "/home/runner/.local/lib/python3.6/site-packages/discord/ext/commands/core.py", line 367, in invoke
    yield from self.prepare(ctx)
  File "/home/runner/.local/lib/python3.6/site-packages/discord/ext/commands/core.py", line 345, in prepare
    yield from self._parse_arguments(ctx)
  File "/home/runner/.local/lib/python3.6/site-packages/discord/ext/commands/core.py", line 304, in _parse_arguments
    transformed = yield from self.transform(ctx, param)
  File "/home/runner/.local/lib/python3.6/site-packages/discord/ext/commands/core.py", line 212, in transform
    raise MissingRequiredArgument('{0.name} is a required argument that is missing.'.format(param))
discord.ext.commands.errors.MissingRequiredArgument: ctx is a required argument that is missing.```
#

command code```@client.command(name='votecheck')
async def votecheck(ctx):
url = 'https://discordbots.org/api/bots/514146427186839552/check?userId={0.name}'.format(ctx.author.id)
async with aiohttp.ClientSession() as session:
raw_response = await session.get(url)
response = await raw_response.text()
response = json.loads(response)

if response['voted'] == 1:
await client.say("You voted")
else:
await client.say("You did not vote")```

wraith cipher
#

why is it {0.name} ?

robust acorn
#

cause the code asked for it

slender thistle
#

Wrong