#development
1 messages · Page 1424 of 1
yeah i saw, and yeah you can do that
how can i make an element appear/disappear on click
class logic
remove class.. have that class determine visibility
MongoDB - Lacks ACID, can get expensive to host with a cloud provides, and annoying to host yourself.
DynamoDB - Schema must match access pattern, or costs will climb very quickly (which is hard to maintain)
MySQL/Postgres - Traditional SQL problems that we all know + hosting can be annoying to host yourself .. managed hosting is also expensive.
ye i have it working
Is there a 'database as a service' that I'm not thinking of?
brasillian form of "não": n, ñ, nah, nn, nhe
many
@long marsh what do you call 'traditional sql problems'?
transaction locks and stuff?
html:html <div> <div class="clicker" tabindex="1">Click me</div> <div class="hiddendiv"></div> </div>
css: ```css
.clicker {
width:100px;
height:100px;
background-color:blue;
outline:none;
cursor:pointer;
}
.hiddendiv{
display:none;
height:200px;
background-color:green;
}
.clicker:focus + .hiddendiv{
display:block;
}```
probably vertical scaling
Correct, or schema / table changes
Vertical scaling as well, yes
i guess strange placing things would happen when you make an invis div visible again
hmm, well youre not supposed to change the schema of a production system in sql
in mongo you just give it extra fields and it goes meh ok then
its like a checkbox
How can you ensure that you understand your full use case with ever growing features?
?
you cant ever understand a changing feature set
you cant, either you plan ahead or you adapt as you go
as in ever did inspect element
Facts
this is what feature freezes are for
ad looked at an invis element
it says width and height but it just meshes with all kinds of things all over the place
at least in sites i've checked
@green kestrel did you ever work with node-addon-api? for using c++ in nodejs
What was your preferred option Brian / Tim: leveraging a DaaS, hosting MySQL yourself, using a managed database service (such as AWS RDS for TraditionalSQL)?
Or maybe something else I'm not thinking of.
what is your target scale?
Ah, nice correction 😄
xD
wasnt me lmao
well that might remain unanswered for some weeks
or forever depending on if it's impossible
all my stackoverflow questions never got answered
lol..
wasnt a lot, only like 2 or 3, then i never asked in SO again
this will be my second question unanswered
only question I ever made in stackoverflow got answered with another question
lul
bruh
Stack Exchange, when getting super specific, can yield 0 responses.
mine was about normal map smoothing (interpolation between Z-level changes)
ite for history time im gonna go to my first question
@quartz kindle nope never touched node at all
ah yes putting cursor on input tab
ah rip
I'm not really great at gauging memory usage. I just know that each user is going to have the basic economic attributes: coins, inventory, wallet, bank - and perhaps more informaiton: game wins, total profit from gambling, command usage, etc.
Assuming that I, optimistically have 10,000 - 100,000 users - what exactly would that entail?
if done correctly, even sqlite can handle that
that's very few data database-wise
the thing is that.. my question wasnt the duplicate
most dbs will handle that as if it was nothing
i was such a noob i was wondering why i get undefined right after
fs.readdir(`${cat}/`).forEach(file => {
if (!file.endsWith(".js")){
return;
}
let FileJs = require(`./commands/${cat}/${file}`);
let commandname = file.split(".")[0];
Bot.commands.set(commandname, FileJs);
console.log(`✅Successfully loaded command: ${commandname}!`)
});
``` `Uncaught Exception TypeError [ERR_INVALID_CALLBACK]: Callback must be a function. Received undefined`. Not sure what I did wrong here?
I mean, I'm not looking at the scale of dank meme bot; however, it could certainly grow to that point. I just want to make sure I have the correct schema / database technology.
readdirSync
@long marsh since september, ive scaled from 2000 servers to 43000 servers
its ...interesting
Yeah.
Wow, congratulations.
but C++ has made it easier to scale
That's insane
so i can talk about what ive had to do for scalability if youre interested
as long as you stay away from json file-based DBs (more like hacks) you'll be fine
Do you host your own database?
Ah, gotcha
does sqlite/quickdb have a limit for data or smth
not at all
no
oh perfect
so the frontend bot clusters are C++, and the backend api/dashboard is php, theres a mysql database that connects the lot
im using sqlite at 6000 servers, no issues at all
php 😢
the bot makes http rest api queries to its own api for most of the functionality
sqlite is a singularity basically
sqlite is ok until you need to have multiple processes accessing the db concurrently, right?
accessing the sqlite db locks it
I was going to leverage AWS's serverless suite for handling my API. AWS API Gateway + Lambda for handling api transctions. It communicates directly with DynamoDB.
only if your app is write heavy
sqlite is fine with concurrent reads
only locks for writes
^ this
I 100% whole heartedly disagree with that statement.
even if it's write-heavy you can always create a second sqlite file xD
xD
Tim, why has your experience been poor with AWS? What happened?
Brain, I started API-first; however, to minimize complexity for now, I've just connected the bot directly with the database. That may backfire; however, for now, I'm in 4 servers 😄
i've actually never used AWS, but i've been reading a lot of benchmarks and they are one of the worst performers in cost efficiency
Is there a reason why my css files are "mixing" in Reactjs
Oh, I agree with that.
I convince sqlite users to move off onto full SQL stacks if they want to scale their bot
maybe you're importing both?
im not
Just because I know it works
SQLite doesn't seem that it was intended for production usage, unless I'm mistaken.
i'll move to an sql server if i ever need to multi process
My bot is very read and write heavy and transaction heavy too
sqlite is more than production ready
Is that its intention, though?
It was designed to turn local storage data files into ones you can access via SQL commands
As a really advanced ini file basically
I always say to use both sqlite and a full-scale DB
sqlite is way too good for caching
sqlite is intended for an embedded database, inside a phone app, a car software, IoT, etc
I prefer a key/value store for cache.
Nearly all android apps use sqlite for local storage don't they?
It's baked into the OS
ye
As a cache?
i ditched redis because my vps only has 1gb ram
I use redis only for PHP session cache
Instead of flat file
Flat file session storage can't scale horizontally
I'm using KeyV, which allows me to switch over to a hosted option when I want too in the near future. (Memcache / redis)
Redis can
Does anyone else know why my css files are conflicting with each other? (Reactjs)
So, Brain, at the ending of the day - you recommend leveraging some sort of production-grade SQL system? And, for my database size aforementioned above, that should be sufficient IF done correctly.
Brain, do you have any background as a software developer?
Tim, I also appreciate your insights as well 😄
I've designed my bot to scale out, basically I can run a shard cluster anywhere but to do that I'd need to move to a managed SQL cluster with transparent failover
My db isn't that big but it takes a battering
I'm honestly scared of scaling.
It's a great problem to have, but, man, will it hurt you if your foundation is wrong.
if you need write heavy and have the resources for it, go mysql or postgre
if you dont need it, go sqlite
if you need multi-machine go mysql or postgre in a dedicated vm over network
Or a managed database service 😄
if you have money for that and dont mind the extra latency, sure
Such as AWS RDS; however, like you alluded to earlier Tim, it's expensive.
This is awesome, thank you
my total operating costs are $2.77/mo
Maybe my worry isn't warranted.
What worries me about selecting MySQL, or any traditional SQL for that matter, is database schema development. I haven't completed an Entity Relationship diagram since college 😬
My operating costs are £70 a month but I use my server for far more than the bot, plus I'm only using 3gb of my 32gb ram, and 10% CPU on my bot atm
the sqlite website claims that their own website runs on sqlite, and that it handles 500k page views per day, with some pages running several multiple-way join queries
I can scale up much more before I have to scale out
Gotcha.
Brain, would you be willing to showcase your ERD (assuming you have one). That's a big ask, so no worries if not.
That's proprietary information 😬
For comparison, here is my bot's DynamoDB schema 😬
does anybody have a link for that meme in C# with the guy being fired and doing true = false and false = true?
Essentially, you can do things like this:
Key =
608120740100964372
Sort Key =BEGINS_WITH('USER#')
( Pulls all information for user)
All the keys are incoherent because DynamoDB charges per kb returned. So, I shorten the field names so that it can stay below that threshold for as long as I can.
g1p = global index partition key
g1s = global index sort key
So, I can additionally query (as a global leaderboard):
Key =
tw
Sort Key => 0
What about server-specific leaderboards? Forget about it. And, that's what worries me. I may want to include that later on.
How many users leverage my bot? I have no clue. Can't query for it.
Sorry for the blow up, was just curious on what you guys thought of that 😬
const name = args.slice(0).join(" ")
TypeError: args.slice(...).join is not a function
any way i can fix this
All the keys are incoherent because DynamoDB charges per kb returned
that's a dick move
oh
slice() removes the first bits
erwin
oop my bad
though you can use on string too, so theres that
erwin
thats me
this also me
Jujustu no kaisen
args.slice(n).dice(' ')
@solemn leaf https://www.youtube.com/watch?v=i1P-9IspBus
crossing fields
@opal plank Im looking for a osu map to level up more
.map(cat => `**${cat[0].toUpperCase() + cat.slice(1)}** \n${Commands(cat)}`.join("\n"))
.reduce((string, category) => string + "\n" + category); ````Unhandled rejection! TypeError: (cat[0].toUpperCase(...) + cat.slice(...))Commands(...).join is not a function`?
LOL
@livid lichen .join goes outside of .map
@high berry Yeah. I fixed that but the same error showed.
Unhandled rejection! TypeError: Bot.categories.map(...).join(...).reduce is not a function
are u sure Bot.categories is an array?
New Discord.Collection();
That's an array.
Right?
honestly im not sure i dont know much about discord objects
Bo ja tu po polsku pisze
Objects?
o
I fron Poland
I am from USA
i didnt realize
?
.reduce only applies to arrays
Oh god.
My English was not gud
how do i add a voice channel to a category without requiring admin permissions
@hollow hearth Co masz na myśli mówiąc „ja, tak o”?
Where are you from? Everyone
I used Google Translate.
with "manage channels" permission?
any error?
missing permissions error
which permission does it ask for?
hey does anyone know how to push an array into a database? (yes i know db.push im talking about how to set up an array for a db)
@livid lichen did u figure it out?
depends on the database
it doesnt ask it just says missing permissiond
quick.db
Not sure.
message.guild.channels.create((`${args[1].toUpperCase()}`), {type: 'category',}).then((cat) => {
message.guild.channels.create((`Price: ${resp.lp}`), {type: 'voice',}).then((vc) => {
})
})```
you're not even using cat variable
A ja nie moge
chill g
@livid lichen what exactly are u trying to do?
Who play MC??
we love complication
im a bit confused what ur trying to do with that map/array/string
show us the complex code
lol its not that complex it just strays from the point ok
Roblox is better.
message.guild.channels.create((`${args[1].toUpperCase()}`), {type: 'category',}).then((cat) => {
message.guild.channels.create((`Price: ${resp.lp}`), {type: 'voice',}).then((vc) => {
vc.setParent(cat.id)
channels[message.guild.id] = {
id: vc.id,
catid: cat.id,
stock: (args[1].toUpperCase())
};
fs.writeFile("./data/channels.json", JSON.stringify(channels, null, 2), (err) => {
if (err) console.log(err)
})
})
})```
My opinion
What are you trying to do?
add a voice channel to a category without requiring admin permissions
i've tried manage channels permission
Last I checked vc.setParent(cat.id) didn't exist. I don't know tell me if I am wrong.
it works with administrator privileges
What's the error?
I don't think quick.db is meant to store arrays
hmm
it does
How?
if i push one word it works fine but as soon as i push another word it doesn't work
i just need to know how to seperate the words
Any db is able to store it as string alias JSON (data type)
using the push functions ?
That is a terrible idea
@boreal iron
Please do not suggest that
They are not meant for that
Did I suggest it or just answer the question? Ask yourself.
it will be more inefficient than using a proper DB
deep
yep
I realize that but if he says that to people, they might actually do it
:l
JSON would work if i had a automatic number of words though im trying to make it so the owner can set there own words to be blacklisted
So maybe just add "but I do not suggest this"
If I would answer questions only if they make sense 75% of all the trash code snippets being posted here wouldn’t be answered
just use an array bruh
it's not that hard- db.push(message.guild.id + '.blacklisted',args[0])
since you would need to say the words in the order they where pushed to work
i use quick.db alot
If it is not just a key-value pair system why are you using ".blacklisted" to identify what it is
if you want this, it will be a little bit more complicated
dude it's just an example '-'
this pushes db.push(`bldb_${message.guild.id}`, word) and this fetches if ([words].some(b => message.content.toLowerCase().includes(b))) { message.delete() message.author.send(badlink1); } im thinking its an issue with how im fetching though
yea that's what i did q-q
What is that
Why is there a :
json
oh...
confusing
Ig I would need to know more about how this db works to fully understand what you're doing
yeah
But JSON in DBs is usually not a good idea
:o i suggest you to only see if one of the words in a bad word, i could also be texting a text without the word
like for example
having ee a bad word, i could say i saw a bee
so i would need to make the JSON file "blacklist" and push it there basicly?
u would need to set up a schema for the database
try ```js
if ([words].some(b => message.content.toLowerCase().split(' ').includes(b))) {
already did
ah .split
yes
im still thinking itd an issue with how im fetching but ill try it
qvq
What are you going to do actually?
Scan each message for blacklist words?
Multi server use or one guild only?
multiple
is there an error :o
The database doesn’t support full tables?
not yet
if i were u id make a redis db and a seperate db
im not sure
an example of how quick.db work
,_,
"ID" and "DATA" are automatic and we can't change that btw
I would actually use the guild id as primary key and add another column adding the words per guild separated by a whitespace
As string
Getting the string and split by whitespace to create an array and done
Exactly
Then check if message includes your array
yesh
bro just get a free mongodb atlas cluster and install mongoose problem solved
main problem is im not too familier with making arrays
arrays are basic js
split creates the array for you
yea you can find some mdn methods etc in the website
take a course or something
https://www.w3schools.com/jsref/jsref_obj_array.asp this has all the methods u can use on arrays
sololearn is also good if u want more content than codacademy
Finding help here how to deal with the array is easier than the inefficient and complicated way you wanna pass
codeacademy is pretty bad imo
Yeah
why D:
@main trench https://www.sololearn.com/Course/JavaScript/ good free course with plenty of content
incase u need
yeah i see how to do it now but the problem of pushing custom words still exists
which is where im stuck now
i think u should change your method of blacklisting
yeah
and do something similar to what we said earlier
ill try to push the words in a proper array format and see if that works
Custom words?
like fake said #development message
he just means the same issue as before
for simple data like this using a json schema is pretty good
yes instead of the basic words i put want the server owners to be able to add ther own words
You can push and slice and word to/from your array to expand or reduce the list and save it as string in the db again
Yo create a command which adds the arugements to the database with the guild id
And another command which can show the current words in the database, and one to remove them
and even the members that have the "MANEG_GUILD" (manage server) permission (this will include the admiins and the server owner too)
I know
when you query/fetch from your db, alter the array that contains the custom words however you want and then set the primary key (guild id) to the new array
Or based on a SQL database use ON DUPLICATE KEY UPDATE
Oh wait wrong goose
yeah
Yep all done in the same command
but its the same concept whichever way u do it
*bl add, *bl clear, *bl list
Unfortunately I can’t write an example while driving 
On this note... ON DUPLICATE KEY UPDATE can be 10x or more faster than REPLACE INTO
*bl add works and it shows the words in the list but fetching the word to detect is the issue
Reading Brains and Time convo earlier he can
there are reasons why, I forget them
INSERT INTO table (pk, field1,field2) VALUES (1,2,3) ON DUPLICATE KEY UPDATE field1 = 2, field2 = 3
Like that
Make sure to use something big enough and NOT string for a guild id pk
BIGINT(20) UNSIGNED is about as correct as can be
Unsigned is important
Also if you're using js, js sucks and you must enable the "get bigints as strings" option on connect
In c++ no such issue
I see you know what you’re doing after following your convo with Tim
Also if you don't know what an SQL injection is, learn before writing any code
You'll be glad you did
INSERT INTO table, what is so hard about that
Guessing the libs they use will suppress that anyways
@midnight blaze we are discussing the pros and cons of REPLACE INTO vs ON DUPLICATE KEY UPDATE, plus other stuff that beginners overlook at their peril
@boreal iron nope not if you're lazy or don't know about it
Brb switch to laptop so I can talk better
Unfortunately I will leave the highway in a few seconds
Guess we will continue this later
The next case somebody requires help won’t be far away 
ok so
in sql libs you usually have two ways to do a query
you can do it what looks like the simple, straightforward newbie friendly way (this is an example using a made up sql library):
dbquery("SELECT * FROM table WHERE col = '" + myval + "'");```
how do i allow people to edit and see my private repository?
and theres most likely a way called stored queries or similar, that looks like this:
dbquery("SELECT * FROM table WHERE col = ?", [ myval ]);```
difference is... the first one is a huge security vulnerability waiting to happen, the second one wont let someone hack your bot
because in the first, youre not escaping the value
which means that someone can just trick it into having a value like this in the var myval:
'; 1
Hmm we had a convo a few days ago just because somebody wondered why his string including special chars got escaped
if they do that, then every call to the query returns true, always, with the first row
That’s why I said most libs will probably do it
or they could do THIS in myval:
'; DROP TABLE table;
and then your table is gone, glhf
yeah libs will do it, if you know how to use the lib properly
if you dived in without knowing this, youd be tempted to do it the first way because the internet is full of bad tutorials that will tell you to do stuff like that
You’re trying to explain what SQL injection is to me or just generally talking about it?
generally talking about it for anyone that doesnt know
and why its important to know your libs
Alright
🙂
how on earth are you typing on discord while driving on a highway
Hm that's actually pretty interesting, thank you for that
this whole thing is also where this xkcd sketch comes from:
oh yes I do love naming my child huca'; DROP TABLE <...>;--
:(){ :|:& };:
what's the chance they would be running windows machines
uh so
let role = args[0]
await message.channel.awaitMessages(m => (m.author.id === message.author.id) && (m.content === `${role}`), {
max: 1,
time: 20000,
errors: ["time"]
}).catch((err) => {
return message.channel.send(new Discord.MessageEmbed()
.setColor('#ff3636')
.setDescription(`${no} | Setup has been canceled, didnt send a message in 20 seconds.`))
});
db.set(`muterole_${message.guild.id}`, role);
another one most people dont know about... anyone else here know about killer regexes?
how would you define role
linux killer regexes?
because on setup it says there is no value to set
in general, you can use them in any platform supporting a regex
from C# to java to linux
@young flame message.mentions.roles.first()
sadly destruction happens less often
yeah, if youve properly sandboxed your code worst that can happen is it might eventually wipe the home dir
would i put that in or outside of it
create new thread where thread creates new thread of continued loop
put it in place of args[0]
okay brb
I think it'd be cooler to rename every field in the database with "e" to show your dominance
much more fun than deleting everything
wouldnt this make it by name
i wanted it by id- because i dont think
yo, im getting an error on my code: UnhandledPromiseRejectionWarning: Error [SHARDING_READY_DIED]: Shard 0's process exited before its Client became ready. can anyone help me figure this one out?
i work daily in my day job with real 'enterprise' production dbs, for expensive pieces of off the shelf software, where they have like 300 fields on the end of each column, 30 varchars, 30 ints, 30 bigints, 30 dates called like customvarchcar1, custombigint1, customdate1...
and they use these for "user extension"
its like major WTF moment
BRUH doesnt come close
how do i allow people to edit and see my private repository?
you have to add them to your team and give them read access
anyone?
in github
bruh
im sorry mr genius. im kinda new to github
settings -> manage access
invite teams or people, big red button half way down the page
settings tab is the last one to the right of the tabs in your repository page
@main trench nope
show me your code
then put the details of the person you want to add
ok thanks
let role = message.mentions.roles.first()
await message.channel.awaitMessages(m => (m.author.id === message.author.id) && (m.content === `${role}`), {
max: 1,
time: 20000,
errors: ["time"]
}).catch((err) => {
return message.channel.send(new Discord.MessageEmbed()
.setColor('#ff3636')
.setDescription(`${no} | Setup has been canceled, didnt send a message in 20 seconds.`))
});
db.set(`muterole_${message.guild.id}`, role);
just define role as message.mentions.roles.first() set that in the db then fetch the role
when you put their name in @static trench set the access to 'read':
it cant fetch a role that isn't set.
ya i got it. thanks
and i dont think role is the issue
are your args configured correctly?
yw
where are you fetching it?
await message.channel.awaitMessages(m => (m.author.id === message.author.id) && (m.content === `${role}`)
that would work right?
so you just have to enter the role id
not ${role}
Because I’m bored and the streets are empty but I enjoy these kind of conversations, that’s why I am here
hi fake

Puhh ... alright 😅
so when I do control+c and then node . in visual studio, it sometimes does thing multiple times, how can I prevent that?
there is no need for picture
I am sure I am not the only one who had this issue
Because the process didnt fully end yet
Yh
ok ty
Or if u do it after running nodemon it does the sane
Hey guys! I would like to add this feature to my bot, but i am not sure if it is possible.
In the on_guild_join() function. Is it possible to make it so that the bot creates an invite to the server? So that way, I can join the server myself?
I have notifications to a webhook whenever he joins a server, but i'd like an invite link too.
ah
do what i did
use discord webhooks
🙂
With the on guild create event
there is a thing called ctx.channel.create_invite()
But that's with ctx
And my on_guild_join can only pass the guild parameter.
Im not good with python
Im mainly 
ah cool
why are you doing that Azure
Prob to join the servers of which the bot is in
how would i show a div when you click on something?
with js
^
onclick listener, apply display: initial styling
client.channels.cache.get(<channel>).createInvite()
.then(invite => console.log(`Created an invite: https://discord.gg/${invite.code}`))```
@pseudo wadi is this what you were looking for
Well not me
ah opps sorry wrong person
@obtuse knoll but in python
guildCreate I think
How do i get it to send a message to a random channel
Filter the guild's channel that allows the bot to send a message, get a random one then send
<Guild>.channels.cache.filter(c => c.type === "text" && ["VIEW_CHANNEL", "SEND_MESSAGE"].every(p => c.permissionsFor(<client>.user).has(p))).random().send(<content>)```
Lol
in js, how can i get the state of a checkbox and do something if the checkbox is checked and do another thing if it isnt
html//js
Website?
Idk
document.querySelectorAll("input[type=checkbox]:checked");
how do i select which checkbox in specific?
the result is an array, if there are none is null
I really suggest you to use jQuery instead of using raw JS
function showdivsb() {
document.getElementById('sidebardrop').style.display = "block";
}```
so if its shwoing
i want to not show
if it is, i want it to show
Don’t need a function, add an event listener and check the current state clicking on it
.display = <display> === "none" ? "block" : "none";
If hidden then show else hide
css?
That's JS
function showdivsb() {
document.getElementById('sidebardrop').style.display === "none" ? "block" : "none";
}```?
this didnt work
Look at the edited one
o ok
you need to set the variable again
document.getElementById('sidebardrop').style.display = <display> === "none" ? "block" : "none";
}``` still nothing...
Thxs voltrex btw for the help
wdym
function showdivsb() {
let style = document.getElementById('sidebardrop').style;
return style.display = style.display === "none" ? "block" : "none";
}```
thanks man
Don’t get me wrong but just to repeat:
I really suggest you to use jQuery instead of using raw JS
If you’re going to build in a lot more dynamic content or playing with elements and their conditions
Holy fuck, why did it take you so long to write that lmao
Just to ask? Why?
style.display = style.display === "none"
xd
lmao looks like always if youre online
Because it’s a statement to check the status
That's cursed, setting CSS properties to a boolean
Just without ()
Guess he thought you define it twice
You know like let var === lmao
Does anyone know how to get more details in simple-youtube-api searches? As the length of the video and number and views
<property> = <check if property is equal to none> ? <If none set to block> : <if block set to none>
how many <inputs> can i have per thing?
mines bugging out when i have more than 1 html <input type="button" id="checkbox" onclick="showdivsb()">
<input type="checkbox" id="checkbox">```
As many as you want
the 2nd one just doesnt work
That's not what we're really doing, that just checks if the property is equal to none @bitter jungle
Or use selects and groups
So we're doing a conditional operator check on it
If the user should have a choice instead of being able to check all
Omg it's another FakE!!!!
There's 1 imposter among us
I swear I will use it and tell Tim about
finally I’m not driving anymore
Now waiting to solve your important issues Mr. Voltrex 
can i have 2 labels inside eachother?
There were no issues, omega kek
hi can anyone help me out with fixing a error on my bot? -- if this aint against tos
Sure, you can nest 1000s inside each other but that might destroy your style (if set)
(node:8280) UnhandledPromiseRejectionWarning: ReferenceError: message is not defined
at Client.client.on (C:\Users\user\Desktop\discordbot\index.js:84:5)
at Client.emit (events.js:198:13)
at MessageCreateHandler.handle (C:\Users\user\Desktop\discordbot\node_modules\discord.js\src\client\websocket\packets\handlers\MessageCreate.js:9:34)
at WebSocketPacketManager.handle (C:\Users\user\Desktop\discordbot\node_modules\discord.js\src\client\websocket\packets\WebSocketPacketManager.js:108:65)
at WebSocketConnection.onPacket (C:\Users\user\Desktop\discordbot\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:336:35)
at WebSocketConnection.onMessage (C:\Users\user\Desktop\discordbot\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:299:17)
at WebSocket.onMessage (C:\Users\user\Desktop\discordbot\node_modules\ws\lib\event-target.js:120:16)
at WebSocket.emit (events.js:198:13)
at Receiver.receiverOnMessage (C:\Users\user\Desktop\discordbot\node_modules\ws\lib\websocket.js:789:20)
at Receiver.emit (events.js:198:13)
(node:8280) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:8280) [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.```
thats error code
Obviously your var message is not defined
But without the actual code we can’t help you solve this.
It’s like telling a car mechanic to repair your car but without touching it
why do people post their entire error messages
ReferenceError: message is not defined it's pretty clear this is the error
hastebin it
k
Does anyone know how to get more details in simple-youtube-api searches? As the length of the video and number and views
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Line 76 and below
start of the poll bot
You defined "msg" being your var name not "message"
just wanted to share how amazing JS date manipulation is for those who want to get in that field
recommendation: roughly 6 Liters of Vodka or 3L of absinthe
<link rel="stylesheet" href="index.css">
that's the entire line?
Ye
are there any other link css lines?
no
🤷
<link type="text/css" rel="stylesheet" href="index.css">
shud i change the "message" to "msg" then @boreal iron
you dont need type
you're serving your css file as a html file from your backend
Fixed
@quartz kindle next time i need time manipulation im calling you
You picked msg as name not message, thus probably yeah 
ok ty
Is there a way to get this error in console?
Going to display a message if someone pulls up the URL in a browser
wat
yes
Using rewrite rules for example to deny external access and forward back to your index
depends on the webserver
dynamic cron jobs
make a catch-all endpoint
any other mistakes? cause now it shows no error but when i do command not working
sorry to bother u
Would get a longer conversation generally speaking about your code but at least you’re trying to start somewhere
What did you enter exactly in Discord?
uh
if(msg.author.client || msg.channel.type === "dm") return;
const msgArray = msg.content.split(' ');
const cmd = msgArray[0];
const args = msgArray.slice(1);
if (cmd === '!poll'){
let pollChannel = msg.mentions.channels.first();
let pollDescription = args.slice(1).join('');
let embedPoll = new Discord.MessageEmbed()
.setTitle('New Poll!')
.setDescription(pollDescription)
.setColor('YELLOW')
let msgEmbed = await pollchannel.send(embedPoll);
await msgEmbed.react('👍')
await msgEmbed.react('👎')
}
}
})```
thats all i changed if i post whole code will send as a txt document
This would all unknown routes, printing the route to the console, & throw a error:
<var>.get("*", (req, res)=>{
console.log(req.originalUrl);
throw "Invalid Route";
});
Which command did you try to call in Discord?
!poll #poll-channel this is test
@bitter jungle Is there a way to just check in <var>.get('/api/webhookendpoint', (req, res) => { if it is a JSON response or a user in a web browser?
i did !poll #poll-channel hi @hollow sedge as well and still no poll showed up
No error?
no error
hi
didn't understand... if the request of the user is a JSON object, you mean?
Nah what is that check supposed to do?
Yeah I think you mean msg.author == client
@bitter jungle yes
there are a few checks you can do, but none are guaranteed to be safe since they all can be spoofed
you can check for user agent or referrer for example
uhh
browsers will set those headers, most direct post requests wont
nothing
Just remove this condition of your statement then
if(msg.channel.type === "dm") return;
const msgArray = msg.content.split(' ');
const cmd = msgArray[0];
const args = msgArray.slice(1);
if (cmd === '!poll'){
let pollChannel = msg.mentions.channels.first();
let pollDescription = args.slice(1).join(' ');
let embedPoll = new Discord.MessageEmbed()
.setTitle('New Poll!')
.setDescription(pollDescription)
.setColor('YELLOW')
let msgEmbed = await pollchannel.send(embedPoll);
await msgEmbed.react('👍')
await msgEmbed.react('👎')
}
}
})
so like this
Hmm
(node:6896) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'client' of undefined```
If you wanna check whole requests:
<var>.use(express.json({
verify : (req, res, obj, encoding) => {
try {
JSON.parse(obj);
} catch(e) {
//some catch stuff
}
}
}));
I forgot that there was obj
then only look for the req.originalUrl to check if it is the requested
big brain
if(msg.channel.type === "dm") return;``` that line
lmao can’t be that line causing this error
Just comment the line out
It’s not that line causing the error
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
It’s not inside what u posted a code
(node:2384) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'client' of undefined
at new MessageEmbed (C:\Users\user\Desktop\discordbot\node_modules\discord.js\src\structures\MessageEmbed.js:13:60)
at Client.client.on (C:\Users\user\Desktop\discordbot\index.js:94:25)
at Client.emit (events.js:198:13)
at MessageCreateHandler.handle (C:\Users\user\Desktop\discordbot\node_modules\discord.js\src\client\websocket\packets\handlers\MessageCreate.js:9:34)
at WebSocketPacketManager.handle (C:\Users\user\Desktop\discordbot\node_modules\discord.js\src\client\websocket\packets\WebSocketPacketManager.js:108:65)
at WebSocketConnection.onPacket (C:\Users\user\Desktop\discordbot\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:336:35)
at WebSocketConnection.onMessage (C:\Users\user\Desktop\discordbot\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:299:17)
at WebSocket.onMessage (C:\Users\user\Desktop\discordbot\node_modules\ws\lib\event-target.js:120:16)
at WebSocket.emit (events.js:198:13)
at Receiver.receiverOnMessage (C:\Users\user\Desktop\discordbot\node_modules\ws\lib\websocket.js:789:20)
(node:2384) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block,
or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:2384) [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.```
Sorry it’s impossible to see on mobile using pastebin
Looks like there’s a } too much
The error is a Djs related issue I’m not familiar with
Use hastebin to post your code with syntax highlighting
Like this?
if(msg.channel instanceof DMChannel) return;
It’s not that line
@atomic geode what version of d.js are you using
Makes my explanation obsolete
go to your package.json file and it's next to discord.js in the dependencies
"discord.js": "^11.6.4",
ooh that's way outdated
throw err;
^
Error: Cannot find module 'C:\Users\parthiv\Desktop\WhisBot'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
at Function.Module._load (internal/modules/cjs/loader.js:725:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}``` um i've coded discord bots before and never got this. i installed discord.js too... how come it doesn't work?
btw nternal is actually internal
+ discord.js@11.6.4
updated 1 package and audited 201 packages in 18.539s
found 29 vulnerabilities (6 low, 10 moderate, 13 high)
run `npm audit fix` to fix them, or `npm audit` for details```
wot
ya
V11 got's obsolete at some points
latest version of npm?
redownloading vs rq
Why
does this thing happen on new ytdl-core version lel
change the package.json
{
"dependencies": {
"discord.js": "^12.5.1"
}
}
Check your code
I don't think that came from ytdl-core
they more than likely copypasted their package.json from an older project
the recommended version (not the actual) is npm@6.14.8
i didn't do anything to my code since 4d ago and that happen when i update the ytdl-core
older project
doubt
just uninstall djs and reinstall it, it should grab v12
k
howcome i get this error?
throw err;
^
Error: Cannot find module 'C:\Users\parthiv\Desktop\WhisBot'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
at Function.Module._load (internal/modules/cjs/loader.js:725:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}```
idk, how come you got that error?
idk, if you coded that then you probably would know what you did wrong
put this in your dependencies:
"discord.js": "^12.5.1"
and then "npm install"
"discord.js": "^12.5.1"
npm install
got it
lemme refresh
"discord.js": "^12.5.1",
"discord-ytdl-core": "^5.0.0",
"discord.js": "^12.5.1",
"ffmpeg-binaries": "^4.0.0",
"index.js": "0.0.3",
either way still the same error message
here
npm WARN deprecated har-validator@5.1.5: this library is no longer supported,
nvm
this for poll bot ;-;
ok finally updated the js
the new error code when i do command is (node:11572) UnhandledPromiseRejectionWarning: TypeError: fields.flat is not a function
even doe i dont have that word in my entire code
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
:p
i feel like remaking a new poll bot script would be easier but idk other ways ;-;
can I do this to make sure that the reacted role isnt a bot
const filter = (reaction, user) => [':heavy_check_mark:', ':heavy_multiplication_x:'].includes(reaction.emoji.name) && !message.bot;
!message.author.bot;
thank
but what if it wants to be
post full error
(node:11572) UnhandledPromiseRejectionWarning: TypeError: fields.flat is not a function
at Function.normalizeFields (C:\Users\user\Desktop\discordbot\node_modules\discord.js\src\structures\MessageEmbed.js:450:8)
at MessageEmbed.setup (C:\Users\user\Desktop\discordbot\node_modules\discord.js\src\structures\MessageEmbed.js:78:91)
at new MessageEmbed (C:\Users\user\Desktop\discordbot\node_modules\discord.js\src\structures\MessageEmbed.js:18:10)
at embedLikes.map.e (C:\Users\user\Desktop\discordbot\node_modules\discord.js\src\structures\APIMessage.js:166:40)
at Array.map (<anonymous>)
at APIMessage.resolveData (C:\Users\user\Desktop\discordbot\node_modules\discord.js\src\structures\APIMessage.js:166:31)
at TextChannel.send (C:\Users\user\Desktop\discordbot\node_modules\discord.js\src\structures\interfaces\TextBasedChannel.js:166:62)
at Client.client.on (C:\Users\user\Desktop\discordbot\index.js:98:42)
at Client.emit (events.js:198:13)
at MessageCreateAction.handle (C:\Users\user\Desktop\discordbot\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
(node:11572) 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:11572) [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.
Update your node.js
i dont see that on dependencies
wait i forgot its a installed
do i just reinstall it or
dou
"discord.js": "^12.5.1"


dou x2

ya idk where to find that
and im fairly certain i told you before not to use spaces on database names
you write in the terminal/command prompt
node --version
4 days ago 
now update, delete, drop cascade, functions, relation keys, restrictions and 2006 other things
oh the password wasn't -

i just need to know if, arrays, objects in js
thats the same as what you're saying rn

every single developer : who cares ? it works
:p
Yes 
but no


Imagine learning 3 operations in pg and then ditching it
at that point why even use postgres
use SQL

I am not gonna ditch it, I am just not gonna learn everything at the moment
hello have some question, why this status offline ? thanks mod Server Status. thanks
Not true a developer will try to make it more short and less memory consumption

big brain 
javascript debbugger: who cares? -v('-')v-
ok i just downloaded the latest one@bitter jungle @pale vessel
I am also working on learning react native so my brain just tired 😔
js garbage collector should collect you too for saying that
i have v15.3.0
nice
also me: who cares about me?
ty everyone who helped me fix my bot!
good luck
ty
now write the documentation... important sounds
:p
welp
the poll worked
and the timer broke
lmao
error: Cannot access 'args' before initialization
weird windows 2000 bsod sounds
thats the response when i do !settimer sreng 10s
was working before
one error after another
if (command === "settimer") {
try {
sendmsg(`Timer: "${args[0]}" has been created for ${toTime(args[1]).humanize().toLowerCase()}.`);
setTimeout(() => {
sendmsg(`@everyone Timer: "${args[0]}" has finished after ${toTime(args[1]).humanize().toLowerCase()}.`);
}, toTime(args[1]).ms());
} catch(e) {
return sendmsg(`error: ${e.message}`);
}
}// timer bot ends```
Hey there, I have a problem with my code..
I'm using Discord.js / Node
This command should make the bot say how much people have this "Votes Role", however, it doesn't work, as it says that only one person has it when it's not true.
This error is happening since some weeks ago.. And from a day to other it started to happen even though I did never modify the bot's code!
This's how it looks like in the code:
let votes_role = "717328453757829202";
let votes_role_members = message.guild.roles.cache.get(votes_role).members;``` and ``` if (message.content === `${prefix}VotesRoleMembers`){
message.channel.send(`The current amount of members with the **Votes Role** is: **${votes_role_members.size}**`)
}```
also have a 'g' at the end?
const args = msg.content.slice(prefix.length).trim().split(/ +/g);
where
/ +/g
oh ya i have that
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
@coarse topaz enable server members intent
should be
oh so get rid of g
that shouldn't matter
What do you mean by "intent"?
shud i change one
you can't have more than one
pool.query(`INSERT INTO afkTable(id, msg)values({message.author.id}, {afkMsg});`)
I am getting syntax error, how do you use the variables in this postgres insert
pool.query(`INSERT INTO afkTable(id, msg)values(${message.author.id}, ${afkMsg});`)
^ ^```
see <#development message>
it's time to nap good sir
yeah i should sleep lmao
that query is sql injectable
what does that mean
google sql injection
ok
i changed the things and it works
its all good now from what i can see
ty for help
SQL injection is a code injection technique, used to attack data-driven applications, in which malicious SQL statements are inserted into an entry field for execution wtf kek
I mean I am still unsure what you mean @earnest phoenix
imagine the afkMsg is 'a'); DROP TABLE afkTable -- or something
the query gets sent over as
INSERT INTO afkTable(id, msg)values('123123123', 'a'); DROP TABLE afkTable --);```
boom there goes your data
pool.query("INSERT INTO afkTable(id, msg)values(`${message.author.id}`, `${afkMsg}`);")
``` how about this
Use `
Not "
but that is NOT GOOD
Use prepared statements
You can get SQL injection from that

Alright this is confusing I need docs
This is not good at all
A simple way to explain the basics of SQL injection through interpretive animation.
see that
okay ty
If you used the same concept in your other code, consider changing it asap
Okay I watched the video
Alright, I have enabled this option from the Developer Portal, but I don't know how to do the second step.. Could you please tell me how should I put it in the code so it can work?




