#development
1 messages · Page 612 of 1
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
you are trying to concatenate a string with a date object
google "prepared statements"
That should be good
this part works
but i don't see how i can make this one using prepared statements
oh
Concatenation
Well, I don't know what your date is
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
Hello, did someone use Heroku for hosting ?
someone did
i rember
remember*
ill try to find the guy
@burnt zealot
does
kirino
@safe pumice yes
@dusky bear do you know the pattern of the path for file storage ? (if i can !)
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.
it's for a json file that i create with python 😄
You have to make a git commit the a bit push.
but it's created with the guild name where the bot is installed 😄
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
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
@earnest phoenix I think you can. Just search the docs
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
He asked for the channel not the invite.
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?
oh jesus fucking christ
oh boy
Eeek
@mossy vine no need to tell me to read the doc I already checked!
i've never seen someone fuck args up so badly
this is fucking cursed
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.
Well, I'll fend for myself because I have no help xD
Create file, write whole command to file, replace the command text to '' and just read the file. That's what I do
i sent you 2 links to pages that explain the var statement
^
anyone did those mistakes at first tho, don't worry!
Took me almost a day to completely separate command args in python
I thought bots were only ran once, and that discord's servers dealt with it
xd
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
xd
No but I removed the Nan but I removed the var and I replace by let..
Ima try to make a very basic coding language idk
hmmm
Can I detect if a user is using the Dark theme on dbots?
as I said, try learning js in a better way
@plucky geyser no I dont think so, and that would be best asked in #topgg-api
@earnest phoenix what is your code now?
lemme search a link!
ok
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?
okay, so the problematic code is
var ${args[0]} = args.join(' ');
what should it do? that's unvalid syntax
(also this https://javascript.info/)
@mossy vineI put let it's good, but it's the { in the args [0]
${} is used in strings, to tell javascript that whats inside it is not a string, but a variable or method
if you just want to make the first element of the args array be args.join(), you dont need the ${}
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
Might be late, but I use JSON for my database and it's worked flawlessly for the past year.
How do I do it?
It's pretty straight forward; just read on load and save occasionally.
And how do I save? I don't understand exactly what you want me to do.. [I am French]
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;
});
};
i have 2 json files about 1.5mb each
@forest needle and I put it where its?
//part of the client.on 'message'
if(GameCommands.hasOwnProperty(cmd)){
msg.channel.send(GameCommands[cmd](msg,m));
save();
return;
}
my json file has 170k lines if you beautify it lul
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
},
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.
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
whats the easiest way to turn an array of arrays into an array of all of its values
yw
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 ?
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
The bot was hosted in a server, and i have all perms
What does this play command look like?
It is a play command (music bot)
Yeah, but I'm asking for the code
That doesn't help.
I research on YouTube the song and i play it with FFMPEG
Does the vps have ffmpeg installed?
Yes
Okay... you still haven't shown the code btw
Now I’m on the phone, so I can’t show anything yet
Oh
Unless. Wait I’ll try something
So how am I supposed to handle this when the bot has all the permissions?
@inner jewel
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
it is a database
well its a language that is used to communicate with a database according to a google search
oh ok thanks
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.
any real database can handle thousands of queries per second
unless they're some extremely complex operation
There’s way too many variables to consider to make a blanket statement like that
unless you're running it on a potato it should be able to handle thousands of "normal" queries per second
and now you have to define normal
And these normal queries, are they indexed properly?
regular selects/inserts/updates
That’s so vague
if you don't have the indexes you need for your queries it's an user problem, not database problem
Well no, the database has a problem and it’s called having to look through all the records instead of utilizing the index
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
The user caused the issue, sure
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
if(!bot.hasPermission("PERM")) return ...
@earnest phoenix What's your problem?
It's not a problem
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");
}
}
}
Okey
@silver lintel what are you trying to do
using discord.js is there a way to know how to add a blacklist using json
like a tutorial to learn from...
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
Blacklisting an entire server?
oh
my*
Then you'd best check in the guildCreate event
if (blacklist.includes(guild.id))
pretty much the same
😃 ok. thankssssssssssssssssssssss
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?
pool.end(function (err) {
console.log("Closed!")
if(err) console.log(err);
});
that's not exactly guarantying anything
thats not what I was really looking for
process.on('SIGTERM', () => {
...
}
node will not shutdown until the event loop is empty
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?
just remove the process.exit() and it should be ok?
yes
you can read this as well
I was wrong about the process.exit()
good idea
k
like this `
<iframe style="width:100%;height:100%;margin:0;padding:0" src="https://gamepug.cf/hypr-lockdown/index.html" frameborder="0" allowfullscreen></iframe>
`
also add ```html
<style>content { padding:0; }</style>
before the iframe
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>
umm
How can i add a array into a sql table?
what database do you use?
usually it is recommended to have multiple rows
instead of an array type
is there a way?
just try out things and use the chrome dev tools
@spring ember I'm making an inventory system so I need to use an array. I use MySQL
when will the bot be approved
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?
Hi
@earnest phoenix I recommend reading about primary keys, which still refers to having a separate table btw
@nocturne moss Hey! Needs some help?
@earnest phoenix yea why i can't make bot in my server
Yea i want bot in my sever
This doesn't belong in #development, and there's an invite button in DBL
Where
Integrate your service with Discord — whether it's a bot or a game or your whatever you wildest imagination can come up with.
But he wanna his bot
Ohh
It's not on page I think
Tell me what you need?
"You need to verify your e-mail in order to perform this action."
I just verifi my e-mail but can't
How you "can't"?
Ty ini just dont
How would I fix a socket hang up?
What you mean with an fix? @opaque eagle
FetchError: request to <URL> failed, reason: socket hang up```
network error
(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
k
does anyone know how to store the snowflake ID of a message as its sent
to edit later
Iv'e got it sorted now, thanks
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.' }```
How do you make a discord bot mass delete
messages
c#
it's called bulk delete, and it should be somewhere in the docs
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 ?
you have too many .on("something")
@quartz kindle what ?
.on("something")
Ah ok
like .on("message")
And what does it do?
you have too many
thats why
pastebin or something
No i can't share my all code of my bot
then i cant help you
because i need to see the entire code to see how you're creating that many event listeners
no
is your code like this? js .on("message" => { //code here }) .on("message" => { //code here }) .on("message" => { //code here })
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
in the whole bot
Or all of my file ?
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?
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
how many .on do you have?
In my all files ?
yes
why so many?
then that is wrong
Why ?
you should only have 1 of each type
1 on message
1 on guildMemberAdd
1 on etc
never 2 on message
I can't but is this in other file
In all file i have one .on message
I can't make other
that is wrong
How i can ?
because if you have 2 on message, you are duplicating everything
meaning your bot will be running the same code twice
Use a command handler
Uh ok
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
Hum but i have 7 files
.on("message" => {
//code1
//code2
//code3
// if command = something -> run file 1
// if command = something else -> run file 2
// etc
})```
help yourself
I do make one file for one c ommand ?
you said you have 7 files, are they not commands?
No this a part with a lot of commands
Exmple one file for music command
One file for mod command
Etc
how do you load the files?
In my index
Yes
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 }
🤔 a function for what ?
So i do create a function with a .on message
You say this no ?
then in your index file do this js client.on("message", message -> { music(message); })
Oh ok !
so in the end you have js .on("message", message => { music(message) welcome(message) etc(message) })
Ok i understand !
Ok ok
I go make this and i have some other errors :
Warning*
Discord having issues atm
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)
}
}
Stop talking about that or else the mods will block this channel too
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
-join
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??
Yeah. How is this related to bot development?
Z
Not the right place, but sure pal
you must have missed it being linked a bit ago
if a css file loaded after another one is loaded, will the one thats loaded later overwrite all !importants?
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.
search on the site
Lazy
reeitsjustthefacts
heh I know
xd
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.
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)
You respond to the wrong event
I put her:
bot.on('guildCreate', message => {
Yes, but I have to put a dash enters the coding? (the console shows me varandaine error)
Yeah text channels can't have whitespace
Yes, but in the coding, I put the dash?
they can have whitespace
Yes
the client just doesn't allow it
instead of Guild, I put message?
Mhm
bot.on('guildCreate', message => {
or
bot.on('guildCreate', guild => {
?
it does not matter what you write there lol
you can name the returned object anything you want
ok
yes
that line is completely wrong lol
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.
Oh yes, thank you
that will create errors if your bot doesnt have create invite permission
also, creating invites for every server your bot joins is not nice
I think that's against the terms
also, that way to use .find() is deprecated
not without permission or expressly stating it
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
he just told you
you're trying to locate a channel named "nouveau-serveur" in the guild your bot joined, not your guild```
Okay I see I look at that
guild.channels.id.find
or
guild.channelsid.find
uh
the
second?
no, you use your client
and get it
if it's your server, or you have access you can get the id
I know the blow is his:
let guildCreateChannel = guild.channel.id.find("574309560995676160");
Why is js so complex xd
idk
use .get() if you wanna use id
guild.channel isn't a thing
find is a method on collections not a string
and that's not the syntax for find
i test this
~~```js
guild.channels.get("574309560995676160");
but that would work only for one server
guild.channels.find(c => c.name === "nouveau-serveur");
guildCreateChannel.send(abcEmbed);
TypeError: Cannot read property 'send' of undefined
really weird
?
read the fucking docs please
I second reading the docs, but in a much nicer tone
@mossy vine speaks better
I'd recommend a combination of reading the docs and possibly console.log to see what values you're getting
^
^^
⏫
console.log has saved me hours of bullshit tbf
GuildCreateChannel is :
let guildCreateChannel = guild.channels.get("574309560995676160");```
@mossy vine
what does console.log(guildCreateChannel) output
Channel name most likely
hmmm I'd expect a channel object
^
Hello everyone
But I want him to send in a specific salon, but odd that the send doesn't pass ^^
what does console.log(guildCreateChannel) output
@mossy vine stop
im trying to help wtf
I want him to send it in a textual salon, not in the console..
@earnest phoenix be nice
I know and thank you
He's just trying to help
im telling you to console.log it to make sure its a channel object
I know and I am grateful
thenwhyyoubeinmeaN
Okay, I can give you the coding for you to look at why the word send doesn't want to work?
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
That is the purpose of the question, to understand and to be explained..
okay cool, so what is the result of that console.log then?
this :
guildCreateChannel.send(abcEmbed);
TypeError: Cannot read property 'send' of undefined
not a console.log, but okay
no
do you know what the error means?
maybe no channel has that id
If I can't solve it, I'll use the log console
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
Yes, that he can not send? Or send is not defined
no, it's saying that guildCreateChannel is undefined
its not undefined, its just most likely not a channel
its undefined because he's looking for a channel in the wrong server
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.
oh its not even a channel id
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
So I put message?
bot.channels might work better
his client is named bot, watch him literally type "client"
ok
lmao
they may not have a good grasp of understanding that values have types
which is a pretty common issue in JS land
I assume they're trying
Yes, but when you're French and. that the site is English, we have a little trouble..
there must be some french site for learning javascript
Either its sites weird and not detailed, or it is not very well translated..
also reading about JS and actively solving problems in JS are totally different
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 ^^
which documentation are you reading?
thats not documentation for javascript, thats just for the discord.js library
you are working with 3 different things
Yes, I strongly help to encode commands. It is thanks to this site that I made the 3/4 command of my bot.
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
All right, thanks for the information. During this time I put under console log
strong disagree on learning them independently
especially considering that nodejs is a runtime + stdlib for JavaScript
and you're having problems because you lack understanding of javascript, the language, not the library
thats for learning to use node for creating programs
for javascript itself, try this
@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
It's still JavaScript. it's just about exactly the same except what you can import
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')
lmao
yes, but when you learn javascript, most of the time you're going to learn how to use it for some specific use
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
so depending on the tutorial, they'll tell you to start doing document.querySelector or require("fs")
yeah, which the script will quickly tell you "haha no"
yes lol
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 🤷
well, yeah, i was just explaining him what hes dealing with
because he thought the discord.js docs are docs for javascript itself lol
or it's a translation issue/misunderstanding
if you turn on light mode you will see difference DONT USE LIGHT MODE
what do you mean with "getting" them
set color to dark theme background
Lol
does discord look black to you?
thats your answer lmao
@lofty hamlet your code is a mess. fix it. good night
Okay but for memory leak for .on i I can not do it
i told you what to do
yes, export the function
But i can't
?
@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
general smh
what
@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
@mellow dagger excuse me what.
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
DSL doesnt have any commands
You add it to your server to put your server onto the DSL website..
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?
You can't add NSFW intended servers you can have a non main channel for that
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 ?
🤔
Ok, thanks dondish👍
@lofty hamlet you splitted by whitespace
Uh ok ?
So args[0] can't have a whitespace in it
Ah ok i understand
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 
webhook -> db -> check db
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
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
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
@idle basalt Im not spending 20s+ to fix code
also at least send the correct code
anybody here know how to install ssl certs on aws?
certbot
on aws
certbot
err, as in my shit is in an s3 bucket
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?
i get this error https://gyazo.com/d601353474749b373f53c5632b40ece3
Are you doing Bot.on("message") more than once
That's the issue
oh
https://gyazo.com/3ea028a63d4aa06fc37ff05099320b25 what happens if i remove this
Your bot will respond to any bot and any DMs it will get if possible
Lol
@earnest phoenix ouep
how to make a bot online
@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 Go search discord.py tutorials on google and you can make your bot online.
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
For a discord bot : CLOUD,SSD or RAM ?
Check pins
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.````
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
Does anyone know how to generate invite links for every server the bot is in?
i do but thats not very nice
ah ke
If consent to that was not given or the users are uninformed, that's a ToS violation
program?
vsc
i did it, but nop
are you downloaded blue vsc or purple?
blue
alright, let me get it
or glitch
with atom is the same problem
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. ```
have the hole error?
I did not understand your question
i mean, can you show the hole log error?

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
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 ?
@wraith cipher Looks like your Internet has issues
Seems to be your bot abnormally closing the connection or Discord doing weird shit
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
Send your code
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 ^
hey someone know how to make vote webhook? in js
#topgg-api check the pinned messages
and also for some reason it prints the on_ready stuff twice... I'm loosing my mind right now x_x
to change the working dir to the root files of my bot
... just so that you could use your bot files?
Even though you are already in your bot folder
yea.. what if I'm not..
return os.path.dirname(file) gives me the path of the file I run 
Or do you mean running the file from other folders
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 ?
Yes
I would suggest restarting your VPS and running the bot
d.js how to get the number of all users in the server's voice channels?
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?
Ok could someone help me. I have the eval command, how would I use it to force-leave a server.
D.py async
I just need the script for it. That's it.
async is deprecated and no support is given for it in the d.py server
switch to the main/rewrite
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.
just run a quick rewrite bot with a ready event and code to leave a server
would take 3 minutes
uh
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"?
@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
@hushed quarry I'm not asking for criticism I'm asking for help
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
just run a quick ping pong bot and add code to leave a server
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()
No need to list() a list
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
How does a list() help you leave an object out of a list
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
.guilds gets updated either way
not with list()...
list() makes a clone of a list, so deleting things does NOT affect the list() copied list of it


Are you even saving that cloned list in any var
I do not, and that is my question
Because you wanted a list that wouldn't have an object that was deleted from client.guilds?
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
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
Ah, that's right
list() prevents this by cloning the list, so you can delete things normally and the iterations won't get fucked up
Alright, got it
I remember my iterating getting fucked up on dicts, hell yes, I remember that
which lib do you work on shiv
dblpy
ah its a role for dbl libs?
yes
alright, sorry offtopic was just wondering lol
hhhhhHhHHHH
MMMMMMMMM
I swear ..
I had to make so many changes to your God damn code
And it still doesnt work
who
reeeeEEEE
make a new bot and rebuild it from scratch on the new lib
thats what im doing moving from v11 to v12
I just wanted help for ONE THING
v11 to v12 ?
if its js i can try to help
Ah, found this article finally:
https://discordjs.guide/popular-topics/permissions.html#permissions-after-overwrites
But my question is now: are all three methods listed in this codeblock just options to get the same list of permissions, or do I need to check all three?
A guide made by the community of discord.js for its users.
Okay, that's neat.
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?
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
is your cache inside your bot's memory or something like redis?
any real database will have no issues being hit with 20k queries
👌 cool, I figured it shouldn't be a large issue
@quartz kindle Bots memory, didn't need anything more complex
So what's your current code
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
What's the URL
https://discordbots.org/api/bots/514146427186839552/check?userId={message.author.id}
and i formatted
Looks fine
Depending on where you are obtaining the author from
and you didn't pass ctx in your code in #topgg-api
Is it a command
he's obtaining it from a command
yes
so message is not defined
Send your command code 
yea lol
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")```
why is it {0.name} ?
cause the code asked for it
Wrong