#development
1 messages · Page 1742 of 1
yes i use it too
because with synchronous-off, the blocking is extremely short
writes are simply handed to the OS
it doesnt wait for the write to actually happen before it unblocks
@zenith terrace
Would you mind addressing my query above? You're not authenticating to mongo
you're not providing a URL or connection string or anything
Mongoose can't magically guess where to connect and what credentials to use
I'm connected
I have It in my main
Right, but not HERE
but why shoul I connect again, my .beg and every command works withoht connecting in every command
You're using const collection = new Collection(); in every single command that connects to the database?
no
Ok so why here then
because I need It for my leaderbord
Ok no but my question is, why are you requiring mongoose here and doing new Collection();, empty, no name, as a brand new connection
should you not be exporting/importing that existing mongoose connection as a module or something
to me?
Only in main
ugh mongoose is so damn weird
Languafe of truth
return message.reply(Devi aspettare ancora ${(time_left.toFixed(0)/60)} secondi prima di usare ${command.name} 😢);
the output of this cooldown is too long
@stiff lynx, Devi aspettare ancora 59.86666666666667 secondi prima di usare beg 😢
like this
how can I have less output numbers?
use toFixed after you divide by 60
(time_left / 60).toFixed(2)
if you dont want decimals at all, better to use Math.floor or Math.round
Math.round(time_left / 60)
Hello, i have a question,
How can i get count of value in a array.
example:
array = ["10", "20", "10"]
the console return me :
10 = 2
20 = 1
loop through the array and keep a map with all values and their respective count
array.reduce((a,b) => { if(!a[b]) { a[b] = 0; }; a[b]++; return a; }, {})
only works for strings tho, because object keys are stringified
https://srcb.in/KPK02AJDwT
Like this?
what do you think about this code?
doesn't look like you're doing that anywhere? or am I blind
oh I see, I think
there's really no point in using map
just a regular for loop
And also I'd use an object instead of a collection
hey at how many users is sharding a good thing to do?
you mean guilds?
no shards

oowh yeah
users don't matter
how many guilds is a good amount to start sharding your bot?
alright, thanks.
pls, help, with this words it seems harder lol
You have to first sort the users in the database, then get the first 10, then turn it into an array, this is all built-in in mongodb:
const users = await <Collection>.sort({bank: 1}).limit(10).toArray();
Afterwards just loop over users
lol this convo is still going
Not sure why you'd want to count all duplicates though
yes he is here
Where i make my own bot
Read this: #502193464054644737 message
and After that for(int i = 0; i<array.lenght);i++){
message.channel.send(${position++} ) Array[i]);
It'd be better to use map and join here - so you send a single message
<Array>.map((user, index) => `${index++} ${user.name}`).join("\n")
for example
it's member.user.id right?
user with the declaration that I've already did?
I don't know your user structure - but replace user.name with what makes sense to you
"<@${member.id}>"
but how I get the userID in the First Array?
in that const users= etc I get Also the userID?
user.userId, according to your schema
you don't have to do any of that
just
<Array>.map((user, index) => `${index++} <@${user.userID}>`).join("\n")
guys i need help in something
I'll give a try After the coffee, wait I'll be Beck to destroy ur mental health lol
y?
it only increments the value and return the original value (not the incremented one)
which is useless as the value is regenerated at the next iteration and it will still start with index 0 instead of 1
because the output Is at the beggining
so my bot needs to access the channel.members, cause i need to know what members are currently in a voice channel. Do i need the Privileged Intent?
ops, nope
I usually don't spoon-feed people but I feel like you won't leave me alone until your code works so here u go
I really need to know
love u 💘
HAHAHA
Does anyone know?
I cant find it anywhere
discord.js docs
https://srcb.in/VrhWvaBAXV
I'm at this point, and now?
That requires member intent as well as voice states one. Without the member intent, you can still get the voice states through <Guild>._voice_states
So, I don't think the privilege intent is really necessary
UnhandledPromiseRejectionWarning: TypeError: profileModel.sort is not a function
because I get this
Maybe mongoose has a different way of sorting, I only use mongodb
you need to get all first before sorting
so find({}).sort(...
I use mongodb too
I did mention it above somewhere...
find({}).sort...
It didnt worked 🥺
but it dont work
now you gotta feed the whole meal 
I feel like a shit this way
I love programming because my parents hates me for no reason
and for them I m a failure
for that I'm so insistent
I'm always trying my best
like, you should try to troubleshoot the errors you come across instead of depending on other people writing code for you
programming is 80% googling
I dont want the code done
I never asked
but I would like to know what I'm doing
trust me are kinda 2 weeks that I'm trying to do this leaderboard
but never worked
Maybe that says that you should take a step back and take your time getting hang of the basics
You particularly don't want to try to cram everything together and pray it works, case in point being me with my projects that failed because I try to learn on the go
js basics?
hello !
JS, MongoDB drivers, you know it
Both
#development message read this for a more detailed answer
There's no universal best when it comes to libraries
js basics I already know, I'm not the best but I know how to do some things
I've watched a video of 8 hours
Is this damned mongodb
I never come to a conclusion
It is always a problem for me
What's the issue again
I think the issue is my life
As in the issue at hand
wanting to sort leaderboards by X value
UnhandledPromiseRejectionWarning: TypeError: profileData.sort is not a function
like, a leaderboard, people with higher score stay on top
yes
I literally just now thought of filtering for whatever reason, then got to something like lb.values().sort()
higher the money, higher on the leaderboard
What's profileData?
the variable that I created for my schema that is called profileModels
Could you show your code?
see also the problem you had with what I showed is that you had other code inside of it
lemme send a srcbin to show you what I wanted you to try
@stiff lynxwhats in the const profileModel = require ('../models/profileSchema'); file
models/profileSchema
does anyone here knows Canvas and d.js?
Just ask your question
I am making a image manipulation, and I want to know how to declare the new image, so I add it on .setImage of the Embed
const context = canvas.getContext('2d');
const background = await Canvas.loadImage('https://cdn2.bulbagarden.net/upload/thumb/f/f4/Safari_RTDX.png/1200px-Safari_RTDX.png')
const gif = await Canvas.loadImage('https://play.pokemonshowdown.com/sprites/xyani/' + rand.toLowerCase() + '.gif')
context.drawImage(background, 0, 0, canvas.width, canvas.height);
context.drawImage(gif, 0, 0, canvas.width, canvas.height);```
you need to upload the image
how? ;-;
ok
hi does anyone know why my bot is going offline and online back to back
for the setImage() you use atachment://filename.extension
cuz ive never seen that happen before
ok
and I put the .attachFiles inside the new Discord.MessageEmbed?
your embed.attachFiles() should look like attachFiles([{ attachment: canvas.toBuffer(), name: "image.png" }])
const context = canvas.getContext('2d');
const background = await Canvas.loadImage('https://cdn2.bulbagarden.net/upload/thumb/f/f4/Safari_RTDX.png/1200px-Safari_RTDX.png')
const gif = await Canvas.loadImage('https://play.pokemonshowdown.com/sprites/xyani/' + rand.toLowerCase() + '.gif')
context.drawImage(background, 0, 0, canvas.width, canvas.height);
context.drawImage(gif, 0, 0, canvas.width, canvas.height);
let avatar = message.author.displayAvatarURL({format: 'png'});
const embed = new Discord.MessageEmbed()
.attachFiles([{ attachment: canvas.toBuffer(), name: "hunt.gif" }])
.setTitle('Pokémon')
.setColor('#1eb346')
.setDescription(`${message.author} congratulations, you caught a ` + rand + `!`)
.setImage('attachment://hunt.gif')
.setTimestamp()
.setFooter('Gotta catch em all')
.setAuthor(message.author.tag, avatar);
await message.channel.send(embed);```
is this correct?
try it and see I guess
ok
note that it's not going to be a gif since canvas will turn it into a static image based on the first frame of the gif
you need to use an encoder like gifencoder to work with gifs
oof
it is giving this error:
UnhandledPromiseRejectionWarning: TypeError: Canvas.getContext is not a function
at Object.exports.run (/home/runner/Bulba-Bot-Recover/commands/hunt.js:79:24)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:1085) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:1085) [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.
You have to create a canvas to get its context
oh, perhaps because I put before the images
- <canvas>.getContext(...)
+ <canvas>.createCanvas(...).getContext(...)```
huh
what is this?

Your error, you're calling getContext() on the canvas itself, not an instance of the canvas, you first have to call createCanvas() to create a canvas instance and then call getContext() to get the context
they might have misspelled it
the code they sent says canvas while the error says Canvas
I changed everything to Canvas
and how do I do that
you literally have a variable called context ....
oh canvas not context. I see
;-;
...
const canvas = require('canvas');
const context = canvas.createCanvas(...).getContext(...);
...```
Or you can just rename the variable canvas in my example to Canvas
With whatever parameters those methods require, the last ... part is whatever code you want after it
I am so f*cking lost 😩 I thought canvas was easier
canvas.createCanvas(width: number, height: number) -> canvas.createCanvas(100, 100) for example
ok
does anyone here know anything about repl and website hosting
Someone might know, ask away
I use repl
Not every method accepts the same parameters, example of the correct usage:
<canvas>.createCanvas(100, 100).getContext('2d');```
There's a lot of tutorials out there that can teach you the correct usage of node canvas, so perhaps look at those
at Object.exports.run (/home/runner/Bulba-Bot-Recover/commands/hunt.js:90:44)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:1229) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:1229) [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.```
😔
yeah so, i switched back to repl, cuz no money for vps and i cloned my new github repo into my repl.
const server = express();
const port = 3000 || 3001;
const superagent = require('superagent');
server.set('views', __dirname + '/views');
server.set('view engine', 'ejs');
server.get('/', (req, res) => {
res
.status(200)
.sendFile(
path.join(__dirname, '..', 'HexagonRepl', 'pages', 'landing-page.html')
);
});
server.get('/commands', (req, res) => {
const commands = getCommands();
res.status(200).render('commands', { commands });
});
server.get('/friends', (req, res) => {
res
.status(200)
.sendFile(
path.join(__dirname, '..', 'HexagonRepl', 'pages', 'cool-people.html')
);
});
server.get('/terms-of-service', (req, res) => {
res
.status(200)
.sendFile(
path.join(__dirname, '..', 'HexagonRepl', 'pages', 'privacy.html')
);
});
server.get('/changelog', (req, res) => {
res
.status(200)
.sendFile(
path.join(__dirname, '..', 'HexagonRepl', 'pages', 'changelogs.html')
);
});
server.get('/snake', (req, res) => {
res
.status(200)
.sendFile(path.join(__dirname, '..', 'HexagonRepl', 'pages', 'snake.html'));
});
/*server.get('/dashboarddevelopertests123', (req, res) => {
res
.status(200)
.sendFile(
path.join(__dirname, '..', 'HexagonRepl', 'pages', 'test.html')
);
})*/
function keepAlive() {
server.listen(port, () => {
console.log('Server is Ready!');
});
keepAlive();
}```
This does not work. It gives me the error: "Error: listen EADDRINUSE: address already in use :::3000"
This is the same web code that I used before, which worked

But now it does not
i did
idk
isn't it process.env.PORT or something (at least for heroku)
or 8080
not sure what repl.it uses
ig it doesn't matter as long as it's open?
🤔
@earnest phoenix I had this error
they assign a random one through env
<CanvasRenderingContext2D>.canvas.toBuffer() -> context.canvas.toBuffer()
at least in heroku
what to replace into the <>?
the instance itself
oh
no 😦
@earnest phoenix it worked now, except that the image is empty
I replaced .gif for .png too
Show current code
const context = canvas.createCanvas(100, 100).getContext('2d');
const background = await canvas.loadImage('https://cdn2.bulbagarden.net/upload/thumb/f/f4/Safari_RTDX.png/1200px-Safari_RTDX.png')
const gif = await canvas.loadImage('https://play.pokemonshowdown.com/sprites/xyani/' + rand.toLowerCase() + '.gif')
context.drawImage(background, 0, 0, canvas.width, canvas.height);
context.drawImage(gif, 0, 0, canvas.width, canvas.height);
let avatar = message.author.displayAvatarURL({format: 'png'});
const embed = new Discord.MessageEmbed()
.attachFiles([{ attachment: context.canvas.toBuffer(), name: "hunt.png" }])
.setTitle('Pokémon')
.setColor('#1eb346')
.setDescription(`${message.author} congratulations, you caught a ` + rand + `!`)
.setImage('attachment://hunt.png')
.setTimestamp()
.setFooter('Gotta catch em all')
.setAuthor(message.author.tag, avatar);
await message.channel.send(embed);```
<canvas>.width and <canvas>.height is not a thing, because its not a canvas instance
so I just delete the context.DrawImage stuff?
<CanvasRenderingContext2D>.canvas.width and <CanvasRenderingContext2D>.canvas.height

Basically, canvas.width -> context.canvas.width and canvas.height -> context.canvas.height
Broken?
yes

Wdym format?
Also you're drawing both on top of each other, if the pokemon image doesn't have a transparent background, the image that was drawn before the pokemon image wouldn't appear
oof
and how to fix that
how can i add screen shots to my bots description?
oh
nvm
html
.-.
he told me to come here
The pokemon image you're loading is actually a gif which gets converted into a png that applies a white background to it, try loading the first frame of the gif first or manually get the first frame and load it
use html/markdown
is that in my bot code?
the bot's long description on website, must be in html
<img src="url" alt="alt text"> or 
ok
long description
ok thx
how can i add screen shots to my bots description?

why would it be in your bot
oooof for me
¯\_(ツ)_/¯
so what should I do then?
hi. so im a big php fan and its the language i love the most
i was wondering if DiscordPHP has any performance issues
??? Really?
i see it uses ReactPHP for making things asynchronous. afaik ReactPHP always did well on all of my projects
so i can access all users in a voice chat at a given moment without the privileged Members Intent?
once more thx for the help... my bot is stuck at 100 servers because of this
can i safely remove the members intent then?
@earnest phoenix
the schema
in the sourcebin is swhou
I was not meaning a small amount. I was meaning a ton
lol the convo is still going
yep
Hello! Anyone know what the dom property is to style scrollbars with js?
You can get the user ids yes
You can use an npm package called gif-frames to extract the first frame of the gif with a transparent background and draw that instead
Using canvas to load a gif and draw it automatically casts it to a png format, which applies a white background instead of a transparent one
ok
Hey I use discord.py and I am editing an image with PIL and want to send it as the image of an embed, but it doesnt work
e = discord.Embed()
with Image.open('baseForProfile.png') as im:
newim = im.copy()
newim = newim.filter(filter=ImageFilter.BLUR)
e.set_image(newim)
await ctx.send(embed=e)
Try replacing e.set_image with e.setImage(newim)
No?
Embed object has no attribute 'setImage'
that's discord.js
they're using discord.py
Strange, seems like that only happens when drawing an image before drawing the image from the gif
- without background
- with background
- the actual background that was drawn before the image
Here are the URLs to test:
Background: https://cdn2.bulbagarden.net/upload/thumb/f/f4/Safari_RTDX.png/1200px-Safari_RTDX.png
The pokemon gif: https://play.pokemonshowdown.com/sprites/xyani/silcoon.gif
don't you need to save the image first?
Use BytesIO and save the image in it, seek the BytesIO to 0, then pass the BytesIO to discord.File. Then, read this https://discordpy.readthedocs.io/en/stable/faq.html#how-do-i-use-a-local-image-file-for-an-embed-image
Thanks!
right thanks
"dangerouslySetInnerHTML"
because its vulnerable to injections
does react allow dangerouslySetInnerHTML on custom components
hmm... it looks unnecessary here
Replacing a part of a string with a custom react element...
anyone got suggests for a cheap vps to host my bot on (js)
GalaxyGate, Contabo
because i just realized i cant use my mongodb on heroku
...what's that url about
takes me to something sus
its a image hoster
pays.host
its supposed to embed it inyo a image
ill try again
workkk
there
how big is your bot
side toolbar
command wise or user or server?
server
And how much servers is it getting added in per day
do you cache everything?
i gained 40 in last 3 days
Get the cheapest one
so the 3$ one?
yep
oki thank you
galaxygate is quite expensive tbh
well cheaper then most i have seen
i would just moved to paid heroku
but thats like 40$ CAD
@cinder patio sorry got ping quick question is there a suggested time ishould upgrade from 3$?
because of how fast my bots growing
im trying to keep as low as i can on price
Once your bot uses almost all of the VPS' ram, or storage, or bandwidth, then it's time to upgrade
Oki, thank you agian
ive needed to get some faster CPU bcs of Machinelearning, and the only thing Digitalocean offers as the "cheap" upgrade costs already 40$/Month for 43$/Month i can get a Root server
damn
well, if you ever need to upgrade it's the cheapest you can get
yea
ive got started with 1GB ram, worked for a while but if you can afford more ram is not bad
I would wait until your bot grows and uses at least 1 GB
oki
otherwise you'd be wasting money
git is ideal
but you can also use FileZilla or similar tools to transfer files via sftp
yea
git is da best
i'd rahter kms then use FileZilla that just me lmaoo?
I'd not trust ftp for source-code transfer
anyone got ideas for being abel to edit my code anyways
insead of just on desktop
like if i needa use my laptop
just use git to keep all the places in sync
i used repl for a bit to edit code then send it to git then it would update in heroku
but repl stopped working didnt supprot some of my pakages
clone ur repo locally
yes
it just deleted everything new i did on desktop
that's what git is for
and replaces with laptop
you mean like pull it before i do?
that too, but even if you forget to do it git 99% the times can auto-merge the code
o
the last 1% it'll ask you to choose which line to keep
that crashed my bot before thats why i stopped
it started duping files
and code
but yea ill try again, thank you
what is c#?
A programming language.
how many different ones r they?
There's... .a few hundred of 'em

millions
If I'm using postgres for a db, should I open a connection and close on each transaction/query or should I just have one connection and leave it open the entire time?
the latter
cursors time out after a certain period of time
so there's no need to close em
oh wait postgres cursors not sure about those
yea
Hey I want to paste the avatar of a user on an image using PIL, but its giving me the ValueError: Cannot determine region size, use 4-box item
My code:
with Image.open('baseForProfile.png') as im:
newim = im.copy()
newim = newim.paste(ctx.author.avatar_url)
newim.save('newprofile.png')
Anyone know how to fix this?
You want to download/read the image from the avatar_url and read the bytes into a PIL image
errrr
does the bot.commands have a command queue somewhere? I want to not allow overlapping commands but dont want to make my own queue if i dont have to
for python
Oh oops
Is there any specific reason?
for not wanting overlapping commands? certain commands change different but potentially overlapping info within my database so i want the commands to wait for the changes of one before going with the next.
I was hoping that the discord bot libraries had natural support for a command queue but if not ill just try implementing asyncio stuff
currently im using cooldown
but i want the commands to be able to run after the other
instead of just denying it

not a py dev, but on js its pretty straightforward putting a queue in place.
seems to be the same on py.
https://www.fullstackpython.com/task-queues.html
i believe one of the virus checker bots on py uses redis queue iirc.
You can write one with just asyncio yourself
Hi! Anyone willing to give me some feedback on the design and layout for my site? https://aakhilv.me/
14 year old artist, musician, and student from Texas.
Good job on the website, dude.
WHY. WHY DO YOU TAUNT US SO
Ive been fooled
I agree
Material Design would say this is supposed to grow not shrink .
// file "a"
import { add } from "./functions.js";
// file "b"
const add = (a, b) => { return a + b };
export { add };
export default fail() { return "I failed" };
How in the world is export default going to work here?
what do you mean how is it going to work?
It's a fallback value, how is it going to work?
import fail, { add } from 'a';
and now you know 😄
Thanks for that! 🙂
Is the fallback value variable always first defined?
import { add }, fail from 'a';
Is this allowed?
yeah both work fine, it's not a question of order, thankfully.
yes, that would also work.
How would I assign a role based off of a user's custom status?
you'd need the presences intent
I have that lol
then just access their status
I don't know how to do that
what library are you using?
djs
So as I read my repl, I wonder what the fuck I was smoking
member.presence.activities[0] will give you the first activity
usually people only have one activity anyway, unless they're like listening to spotify or something
the activity contains name, details, type, emoji, etc
I'm tryna use the presence update event
sure
same thing
the event gives you 2 presences, one before the update, and another after the update
either one of them should have a .activities array
Yeah, and then I have to check the array for the name? Or is there another way?
you have to pick one of the activities from the array, usually the first one works
so activities[0]
that will give you an activity object, which contains name, details, type, emoji, etc
the actual text of the custom status will be in one of those, i dont remember which
just console.log the entire activity object
How do I define the user within the presence event or is it already done? @quartz kindle
Hover over the squiggly text to see the error.
I'd think presence.member right?
yes it should be presence.member
or presence.member.user if you want the actual User and not the Member
You found out your issue.
bot is not a variable in scope.
So you probably forgot to define your discord.py bot instance.
so not bot.... so I have to do client.....
The name can be anything. It's a matter of you creating an instance of the appropriate class.
so repalce bot with what?
Like I said,
The name can be anything. It's a matter of you creating an instance of the appropriate class.
This depends on what you're using: a regular bot instance or a command bot instance.
Actually why did you move from #topgg-api
stop moving around like a fish out of water and stick to #topgg-api ?
i am using client.command
@quartz kindle user.presence.activities[0].name is not a function
Though if I had to assume, you may be lacking in experience with Python.
and how can I know what I have to replace with bot
bot is an instance of a discord.py Client
I recommend you:
- See the documentation for the discord.py library (https://discordpy.readthedocs.io/en/latest/index.html)
- Spend more time learning Python (https://docs.python.org/3/tutorial/)
so what I have to replace with it§
sorry, its a screenshot of the other site 😅
dude
your bot variable is whatever name you gave it
when you created a new Discord client
you have to always use the same name you created
its something you decide
not someone else
lol
?
it was example
its whatever you put in your code
how do we go from a variable name to mee6
and where I ca nsee it because I still don t understand
Let's say, for example, if you created an instance of a discord.py client under a variable client, you'd use client
how did you create your discord client?
¯_(ツ)_/¯
in your code
lol
with developer protal
I don t know what you mean
where did you create a new Discord Client from the discord.py package
you import discord.py, then you create a new client
how can I know it??
show that code
The answer you need is not how to define your Discord client: it's experience.
okay
show where you import discord.py
and whre?
and what is with it?
you see
client is the name you created
so everywhere, you have to use client
so instead of bot, you use client
if you did xyz = commands.BOt()
then instead of bot you would write xyz
I want still using client.command not bot.command
this has to be the same as the name you created
if you created client then it has to be client.topggpy
okay
? like this
and now put token in it and it wil works?
and do you know why?
wait I am gonna cehck it
Omg
you didnt save your code lol
Here's what it says now @quartz kindle
okay I am go to
There are no activities
yes, you need to check if the user has any activity first
can sqlite3.executescript have parameters for values?
How?
if(presence.activities.length) or if(presence.activities[0])
This activity shit is confusing for me
seeing someone breaks Python's conventions feels tragic
well im not a python dev
Still thsi after safe
I'ma make it multi-guild support where people can set what role to award for whatever status they want
you. did. not. save. the. file.
your error says you still have bot in your code, not client
so you either didnt save, or you saved the wrong file
and how can I save it?? everytime this wrked as save
Usually CTRL+S in your editor
I am using repl.it
Then it's clearly not updating the code then
not much we can do about that if it can't even bother to save the things you're writing.
Or link us your repl. 
did you press the stop and run buttons in replit?
@_@
wait repl is shit shit and again very shit app
Okay I am gonan agai n
rewrite it
it was only bug in repl it wasn t saving things

Love you guys
and thank you for help : D
I really should get the new version done along with docs and an announcement
amen jesus shiva krishna budha alah quetzacoatl

what the fuck
oh god
iemanja izanagi zeus odin gilgamesh jupiter abad
@earnest phoenix Do I honestly need a custom JSON decoder for DataDict to make it serializable?
could you pickle it?
tsukiyomi amaterasu orisha osun horus osiris anubis baal enki enlil

Wouldn't json.dumps the dict suffice? With str passed on to the default parameter
i want to code an +rep system with +rep numbers and -rep numbers. how can i make that and which database should i use (like localstorage or mongodb etc.) (discord.js)
Can't you json.dumps __dict__
Eris, Aqua, Deities, Zeno, Arceus, BellDandy
Mongo is good I guess (If enough RAM)
not for public bot
only for my server
how can i learn mongo
the mongodb docs are amazing imo. https://docs.mongodb.com/
You wanna learn deep ?
Or something that works ?
second one
then follow what Woo gave
Otherwise I was gonna tell you to learn mongoose Schemas
Where are you gonna host the db?
On your VM or Their system (atlas)
windows server 2012 i have my own server rn
my VM
Then the first one
(I'll let you download and install)
And about the code,
Try this https://www.w3schools.com/nodejs/nodejs_mongodb.asp
oh god finally a short lesson in w3schools
those of you who learned programming on a phone, do you have any resources you can recommend for someone learning programming without a computer?
There are some tutorials and stuff on udemy but they all require you to follow along with a computer which kinda makes things harder
Is there any way to edit or delete interaction (message sent by bot)
sell ur phone
get a pc or laptop
i just bought a VPS with galazygate and im trying to get my bot on it i have nmever used a vps before and am super confused and cant find much on it can anyone help?
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
ask galaxy gate support
Is there any way to edit or delete interaction on discord.js?
Seems you can but is that an ideal workaround?
Especially considering the fact that users will have to work with it
@cinder patio do you mind helping u suggested it earlier
that's obviously not an option
hope the site has a copy paste button
and use that
and run ur code on something like repl.it
No idea. I don't use discord.js
lol
does replit work on mobile?
Enough to the point where some people use it
What's the use case?
GalaxyGate guides
im js
u can easily switch between code and console and so on
there's one for js too
never used python
and like no need to download stuff locally since its replit
Don't know where users will have to work with it, but having to do json.dumps(data.__dict__) doesn't look convenient
o thank you
there's one for js too, just click the link on the left side of the page
Thought it's meant to be sent to topgg
And to be quite far, what's the harm in subclassing dict?
It can go both ways, actually
Unless I split it into RequestData and ResponseData? 👀
Seems redundant tbh
What's another combo for "from" and "to"?
The first one is that it duplicates the data. Your last implementation was binding the value to the key as well as setting it as an attribute iirc. While that might only store the reference, that's not a good option imho. And, the second one, I'm not sure if it's still an issue, but you can inherit https://docs.python.org/3/library/collections.html#collections.UserDict instead. If you subclass a dict, the __init__ and the update method don't call the __setitem__ method. Also, with UserDict, you only have to implement __getitem__ and it'll work the same when you subscript it or calling the get method or doing key in operator (no need to re-implement get and __contains__ method.
previous / next. before / after.
I still haven't got the big picture of what you're trying to achieve
It has to be used in the context of a source (from) and a target (to)
lol. source / target then?
I could just use source and target as well
I'll play around tomorrow and see what could fit
And sorry for annoying you so early 
Naming things is one of the hardest parts of programming.
xd no worries
we can solve all the problems in the world except for naming
The bot developer's life lol.
I bet this Tim is smart too
I see what you did there.
hey
I go this
fetch('(something here)')
.then(response => response.json())
but says fetch is undefined.
I tryed doing something like const fetch = require('fetch')
But it didnt work.
😐
:.
const fetch = require('node-fetch')
Which dependence should I use to play Twitch lives.
None, you can't play videos
except if you want to use lavalink
No, like, you can only play audio, not videos
yeah, audio only ofc
i am looking at the link rn but i didn't understand it correctly. and i have a question, can i use mongo like localStorage?
Not really. localStorage and mongo have different API's. Also local storage is synchronous and mongo is asynchronous.
*in Node.js anyway
me with bad english: the what
oh okay understand it
btw i want to make +rep and -rep commands that players can use for other players. i want to show that for every user (if its not created, it will show probably 0 i can make that) but i don't know how to make it with numbers (localStorage)
So I'm using some emojis in my site, and I'm wondering, is there any way that I can keep the emojis in the Microsoft form, and not change into the Apple, Google, etc. emoji forms for all devices?
There's no "microsoft" or "apple" form
Emojis are just unicode characters that are parsed by the browser/system
ah
is this also true for class components?
Bruh
does js has something opposite of [].flatMap()
I want to convert an array into 2D matrix
up
hey umm
anyone know how to chain async functions?
class Instance {
async updateOne() {
return this;
}
async set(data) {
console.log(data);
}
}```
Lets say this is my instance where i use it like
x = new Instance()
but now to call the functions i have to use it like await (await x.updateOne()).set()
but i wanna use it this way -> await x.updateOne().set() // this throws a ".set" is not a function error
@quartz kindle @cinder patio
sorry for the pings
no thats not possible, u can use thenables though
conat data = await updateOne().then(val => val.set())
but
how does
mongoose do it then
they have multiple methods on the same instance
like new user().save().something()
now data will have the return value of set
ik, using then is same as putting parens
await (await func1()).func2()
same thing
can u show snippet, whr they're doing this
Ooh, that is called Builder design pattern
behind the scene there're just updating the query, with each function call. Finally awaits it
yeah but i couldn't reproduce that behaviour
yeah, it will not be very usefull for async tasks
Anyone here deploy their bot on kubernetes?
Yeah
just how I learnt ^
Do you know how to connect to your VPS via ssh?
Depends, if is a property of the class, then no, if it's a variable in the constuctor or any other method then yes
so in class components refs are only useful, for referencing dom elements
i did it already thank you tho
yeah
hello! I'm making a discord bot in java script and I'm having trouble finding out this error
anyone down to help me
the error
unexpected token )
take out a set of `
I see
i am not using vsc
it's like vsc
but ig mentally dumb
def not
forgot that exists
should i send a ss
or the code
k
the whole code
or the error part
client.commands.get(command).run(client, message, args);
catch(error){
console.errorerror;
}
}
})
Um
Use 3 backticks and then paste your code, it’s easier to read
(Just a tip going forward)
adding js or what language you use after the three ticks highlights things
^^
let likeThis
console.error(error); <--
u need to provide more code....
and paste that code here between
```js
// below here
tis true tbh. The missing extra ) your error is talking about is not quite visable with your code example.
Just do the whole thing if you wish 
alr
`client.on("message", async message => {
if(message.author.bot) return;
if(message.channel.type == 'dm') return;
if(message.content.startswith(prefix)) {
const args = message.content.slice(prefix.length).trim().split(/ +/);
const command = args.shift().tolowerCase();
if(!client.commands.has(command)) return;
try {
client.commands.get(command).run(client, message, args);
catch(error){
console.errorerror;
}
}
})`
3 backticks
client.on("message", async message => {
if(message.author.bot) return;
if(message.channel.type == 'dm') return;
if(message.content.startswith(prefix)) {
const args = message.content.slice(prefix.length).trim().split(/ +/);
const command = args.shift().tolowerCase();
if(!client.commands.has(command)) return;
try {
client.commands.get(command).run(client, message, args);
catch(error){
console.errorerror;
}
}
})
there.
I updated it
lol
probably wrong for the console part bec i'm not a js duder but what ev.
its giving the catch part
catch(error){
^^^^^
unexpected token 'catch'
Missing a }
Precisely
oof
I think it's try {} catch {} is it not
client.on("message", async message => {
if(message.author.bot) return;
if(message.channel.type == 'dm') return;
if(message.content.startswith(prefix)) {
const args = message.content.slice(prefix.length).trim().split(/ +/);
const command = args.shift().tolowerCase();
const commandToRun = client.commands.get(command)
if (!commandToRun) return;
try {
await commandToRun.run(client, message, args);
} catch(error){
console.log(error);
}
})
ya I was right.
You have to do try{} catch(error) {}
try {
commandToRun.run(client, message, args);
} catch(error){
console.log(error);
}
})
is where u messed up
that's the correct way of doing it
i see
client.on("message", async (message) => {
if (message.author.bot) return;
if (message.channel.type == "dm") return;
if (message.content.startswith(prefix)) {
const args = message.content.slice(prefix.length).trim().split(/ +/);
const command = args.shift().tolowerCase();
if (!client.commands.has(command)) return;
try {
client.commands.get(command).run(client, message, args);
} catch (error) {
console.log(error);
}
}
});
oh I see now
There, I ran prettier over it as well. You can have that for free.
didn't have to...
pretty code is good code
Linters are nice
I had too, it was making me twitch funny.
It means a native module was compiled for another platform.
Probably npm install was run on another machine?
So how do I fix it
I did that then got this
except, it gives me the same error as last time. unexpected token ')'
u have an extra ) somewhere in ur code
figure it out. start counting the parenthesis
alr
If you use VSC you can click each one and it will show you the closing )
quite handy.
Making a js discord bot is easier in visual studio code
nah, notepad >>>
ya there's a red line
then start using it today. U'll save alot of time
red line = bad
yep I can def use vsc
when I hover over it it's still saying unexpected token. ')' so let me find it
found it
So delete the ) where the red line is 
I'm really confused now
^
ik that
If you have an extra ) in there, it’ll mess everything up and throw a syntax error
now this aint make a damn cent
it's saying that somehow client.login("token")
is wrong
wtf
do you define "token" in a .json or something?
token is my bots token btw
Did you fix the error before that
yes
what's the exact error statement?
What’s the error
unexpected end of input
Can you paste the code
