#development
1 messages Β· Page 780 of 1
Yeah
Np.
and how abou the dbl events?
Dynamically loading them?
Oh dbl events shouldn't be inside /events/ as you don't want to add them to your client.
Yeah good.
thanks!
(node:20526) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 debug listeners added. Use emitter.setMaxListeners() to increase limit
π yet another bug
are you using sepereate listeners for each command?
Looks like it
Possibility that the loader is called multiple times.
ay?
https://discordapp.com/channels/264445053596991498/272764566411149314/672736129212088350
what does that refer to?
Possibility that the loader is called multiple times.
nope
fate.readdir("./events/", (err, files) => {
if (err) return console.error(err);
files.forEach(file => {
const event = require(`./events/${file}`);
let eventName = file.split(".")[0];
client.on(eventName, async(...args) => event.bind(null, client)(...args));
});
});```
this the code
{event handler}
want me to show codes for each event?
and you can fell free to ping me
Do you have a seperate event for each thing?
Do console.log(client._events) after you finish loading them
(after the files.forEach block)
ye
nothing happens with that
after executing any command it shows this
(node:280) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 debug listeners added. Use emitter.setMaxListeners() to increase limit
Do you have a seperate event for each thing?
yes
ok
const client = new Discord.Client();
module.exports = {
name: "ping",
description: "Ping!",
execute(client, message, args) {
var sds = client.ping;
sds = sds.toPrecision(3);
message.channel
.send(":loading~5:Pinging...")
.then(message => message.delete(1000));
message.channel.send(`Pong ${sds}ms`);
}
};
Ok dont
module.exports = (client, message) => {
const args = message.content.slice(prefix.length).split(/ +/);
const commandName = args.shift().toLowerCase();
if (!client.commands.has(commandName)) return;
const command = client.commands.get(commandName)
|| client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName));
if (!command) return;
if (command.guildOnly && message.channel.type !== 'text') {
return message.reply('I can\'t execute that command inside DMs!');
}
try {
command.execute(client, message, args);
} catch (error) {
console.error(error);
message.reply('there was an error trying to execute that command!');
}
}
Dont Create new clients
Delete the new client part yes
okay done
You're importing client, so there's no need to make a new one every time, hence
module.exports = (client, message) => {```
oo okay
You can theoretically import anything too.
Where do you define client.commands?
index.js
π
Careful, you have an IP exposed.
Only a local IP
An internal ip lol
I just saw IP and was like, RED FLAG!

XD
oo
lol tim what is ur security im already in ur system
Here's mine, 1.1.1.1, or 1.0.0.1
Building a async alchemy driver is fucking hell oml
code is now bug free thanks to ye all!
@modest maple make an emergency command for restart websocket π€·ββοΈ
@quartz kindle im in
xD
Lmao
are dbd bots allowed?
Iirc no
cuz its essentially just a template
afaik no
i hate my laif
@modest maple you asked if they intellij updated made it eat less ram
they apparently want to make it functional as a lightweight texted editor
So they trying to make another VSCode but with ide stuff
How can I create my own Command Promt command?
wat
How to change long description transparency??
background: none in CSS
π€£
Not funny didn't laugh
Also maybe #memes-and-media
That's my error message which I got using rethinkdb on glitch can't understand the error
I still prefer Bogosort
@earnest phoenix Look up the error, I found many solutions by doing so
multiple shards mean more ram usage, right?
I want to create an invitation connection link with the server ID to the server where bot is located, how can I do this? (Discord.js)
@grizzled raven yes but actually no, Ram is mostly effected by the guild count at lower shard counts
@toxic jolt what is it for?
For support
for you to join the guild?
Read the docs: https://discord.js.org/#/docs/main/stable/class/GuildChannel?scrollTo=createInvite
It also provides an example.
Another example you might like: https://stackoverflow.com/questions/53350871
I'm trying to make that my bot will create a temp instant invite for a guild that it's currently in. Is it possible? (This bot will be public, so it will be in a lot of guilds)
If so, I'm asking fo...
btw
if your doing for you to join the guild
DONT
it is a massive breach of privacy and is against tos
Remove border
@hybrid ruin thx
You're welcome
Thanks @slender thistle
.commit 
its an orm
it does it automatically
making this a module to import is the most fucking argggggg]#
returning exception unable to open database file
Traceback (most recent call last):
File "C:\Users\ChillFish8\AppData\Roaming\Python\Python37\site-packages\aiosqlite\core.py", line 153, in run
result = function()
File "C:\Users\ChillFish8\AppData\Roaming\Python\Python37\site-packages\aiosqlite\core.py", line 307, in connector
return sqlite3.connect(loc, **kwargs)
sqlite3.OperationalError: unable to open database file
Traceback (most recent call last):
File "D:/Crunchy/DataBases/PrefixDB.py", line 56, in <module>
asyncio.run(main())
File "C:\Users\ChillFish8\AppData\Local\Programs\Python\Python37\lib\asyncio\runners.py", line 43, in run
return loop.run_until_complete(main)
File "C:\Users\ChillFish8\AppData\Local\Programs\Python\Python37\lib\asyncio\base_events.py", line 579, in run_until_complete
return future.result()
File "D:/Crunchy/DataBases/PrefixDB.py", line 53, in main
await database.list_prefix()
File "D:/Crunchy/DataBases/PrefixDB.py", line 43, in list_prefix
rows = await self.db.fetch_all(query=query_)
File "C:\Users\ChillFish8\AppData\Roaming\Python\Python37\site-packages\databases\core.py", line 131, in fetch_all
return await connection.fetch_all(query, values)
File "C:\Users\ChillFish8\AppData\Roaming\Python\Python37\site-packages\databases\core.py", line 218, in fetch_all
return await self._connection.fetch_all(self._build_query(query, values))
File "C:\Users\ChillFish8\AppData\Roaming\Python\Python37\site-packages\databases\backends\sqlite.py", line 89, in fetch_all
assert self._connection is not None, "Connection is not acquired"
AssertionError: Connection is not acquired```
jesus
christ
@modest maple so 2000 guilds with one shard uses more ram than 2000 guilds with 2-3 shards?
sorta but its a almost insignificant amount
How do I make it so my bot sends messages in one specific channel with one command, like all the either commands work in other channels but a specific one doesnβt in the others
what lib
im not sure about js
Fuck
More shards use more ram, but depends on the language and lib
And sharding method
@earnest phoenix you can use message.guild.channels.get(channelid)
Or client.channels.get(channelid)
And then send to that channel
Yo
Wsp
How do I use this bot??
To monitor prices on stockx
Anyone can help me with that pls?
what bot
To monitor stockx prices
what bot
What this group is for?
Galaxy Gate or Digital Ocean
Or contabo
both have their pros and cons imo
Contabo is better but requires more experience imo
Galaxy Gate and DO are good for starters
but what should i choose?
Which every you want
but what would you suggest me?
hi
@quartz kindle would that be an else for the command I want in that channel ?
Has anyone worked with the twitter api? I am trying to avoid retweeting retweets. But can't find any info about how to check if a tweet is a retweet of another tweet
i tried using "-filter:retweets" in my search query for possible tweets to retweet but it doesnt seem to work :/
With the Java lib you can check if a tweet is a retweet with statusObject.isRetweet()
but i guess that is specific to that lib?
this is the specific lib i am using https://www.npmjs.com/package/twit
does galaxygate and digital ocean connect with github?
mkay i found the related page on twitters api doc. https://developer.twitter.com/en/docs/tweets/data-dictionary/overview/tweet-object
retweeted Boolean
Indicates whether this Tweet has been Retweeted by the authenticating user. Example:
what does this mean?
authenticating user? if the tweet has been retweeted by the person that created the tweet?
I'd guess it means the user who is sending the request 
With an sftp client
Anywhere
...
Literally google for sftp client
There are many of them
Its a software used to connect to a server
With the puspose of transfering files
For example, filezilla, winscp, mobaxfire...
Any program that supports "SFTP" can do it
ok ty
Connecting to ip Status: Connection attempt failed with "ECONNREFUSED - Connection refused by server".
sftp isnt ftp
yea
i mean it didnt ask for username so i used my email
ok
And you put the password to the server, not your email
yeah but it still gives me same error
Host: IP
Username: root
Password: PASSWORD
Port: Empty
did i do something wrong?
@topaz fjord
are you sure the password is correct?
yeah i just changed it too
In the protocol option you are using sftp?
protocol?
Wait
Okay you open filezilla, click the little icon in the top left
Assuming you've done it that way
I think if it's the first time
yeah it is
you need to click "New site"
ok
whats next
In the host bar, put sftp://your.host.ip.address
In port put 22
ok ty
so that was all that i had to do?
now i need to upload my bot file
i mean folder where its in
Yes
so basically see people live life
anyone know how can i Check if my bot has permissions to embed links?
the client user on a guild is set as me, so you can check the permissions with <guild>.me.hasPermission()
thats only a lil bit of 
but it is right
well
i cant teach otherways
ok its all uploaded now, so how can i make my bot active?
or online
uploaded to where
you
run it?
with node?
assuming that's what you are using anyway
if your bot is made with node, node <mainFile>
if not
idk
I'd recommend using pm2 tho
pretty kewl
if you have multiple bots
otherwise I wouldn't really worry about
download putty
maybe you can do it through galaxygates dashboard but i haven't figured it out
how do i even download it
The same way you used sftp to send the files, now you need to use ssh to access the machine and run commands on it
Download an ssh client
what he said lmao
Then login the same way, ip address, port 22, root, password
before any of that if i update my code, do i need to upload everything again?
oof
Unless you use a code editor with integrated sftp
thats partly why having a testing bot is a must have
you should have one anyway but
login as:
what do you think π©
do i need to input the username and password
yes
ok good im in
ping should be ping(self, ctx) I think
^
Client.say is not a thing
Client.send_message is also not a thing
On message delete is missing a decorator
I think that's it
in ssh it gives me this error```Error: ENOENT: no such file or directory, scandir './commands/'
at readdirSync (fs.js:887:3)
at module.exports (/root/neptune/handlers/command.js:9:5)
at /root/neptune/index.js:41:37
at Array.forEach (<anonymous>)
at Object.<anonymous> (/root/neptune/index.js:40:13)
at Module._compile (internal/modules/cjs/loader.js:1151:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1171:10)
at Module.load (internal/modules/cjs/loader.js:1000:32)
at Function.Module._load (internal/modules/cjs/loader.js:899:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47 {
errno: -2,
syscall: 'scandir',
code: 'ENOENT',
path: './commands/'
}
no?
Ew
Unless id need windows for a particular reason, id never go for a windows server
most people run linux servers
if i read the error is see: "no such file or directory, scandir './commands/'" but that does not make any sense
So ge running linux without even knowing lmao
how do you manage that..
Anyway, do you know how to navigate on a linux terminal?
@iron scroll why are you on the async docs
no its isnt its ubuntu
ubuntu is linux
Use the ls command do see the contents of the current folder, and the cd command to change folders
oh wow
i didnt know that π

@quartz kindle no i dont know how to navigate on a linux terminal
I just told you how
well with the error
i get that ls is reading contents of the current folder etc.
it's probably looking at the dir you're running from
Well, does it have a commands folder?
(iirc) nodejs looks at the current dir you're runnning from
yeah it does
so in handlers it's looking for $BOT_ROOT/commands
ok so i need to change every thing rn?
just change the dir it's looking for
You dont need to chanhe anythong
You jusr need to make sure all the files and folders are there
And that your bot files are in the rihht folders
And that yoire running it from the right folder
You been on the drink?
What
?
Nvm.
ok there are a lot of files that need changing dir
so what do i do
can i even change them without uploading them again
You can move files using the mv command
is there a way to mass move them
You can move folders
And you can use wildcard selections
Using *
All of this can be easily googled
ok i messed up when i upload everything again does it make every thing like it was before
Anyone ever used RestSharp before?
Anyways. When I try to post to an API It says the json is invalid.
Of course It is:
"{\"sex\":\"Male\",\"age\":25,\"evidence\":[{\"id\":\"s_102\",\"choice_id\":\"present\",\"initial\":true}]}"
Because apparently RestSharp serialize the object for you.
But how would I fix that?
var request = new RestRequest("/diagnosis", DataFormat.Json);
request.AddJsonBody(profile);
var response = Client.Post(request);
Output: "{\"message\":\"invalid json\"}"
When I use postman and remove every escaped characters It works fine.
@earnest phoenix uploading will replace existing files if a conflict happens, same as windows does
If you upload to a different folder or with different names, it doesnt replace anything
Just upload yoir entire bot folder and keep tje same structure as you have on your computer
You dont need to upload node_modules
You will need to install node, preferably the same version you have on your pc
And you woll need to run node install on the folder where you have your package.json
@tiny tinsel why not use HttpClient
@quartz kindle So i need to go rn but basically if i have things you said reuploaded i need to do mv commands neptune (bots file dir) and to every other file?
@tiny tinsel you can use newtonsoft.json to convert a class into a json string which you can use for api requests
That should work fine then because the json parses fine for what you sent
you can effectively make restsharp in 10 lines of code with async support and make it behave like you want it to natively using HttpClient
Newtonsoft.Json and generics with HttpClient and you got yourself a less expensive restsharp client
@earnest phoenix not if you upload them to the right places
You can literally chose where to upload what
ok but can i delete everything what on there rn?
Yes, you can do that with the rm command, or in filezilla as well
But dont delete the base folders, like root, etc, bin, usr, var, ...
Thats same as deleting system32 on windows
do i need to do rm file/folderName
You can do it in filezilla
Right click, delete
Or yes, rm file/folder
You need rm -r for folders
@earnest phoenix Your name describe my current mood. The issue wasn't RestSharp itself. I was sending "sex" with a capitalized letter at the beginning..
Their API is really broken to not output any errors for that.
ooooof
Male had to be "male"..
with what kind of relic of an api are you working with that it's case sensitive
I will contact them and tell them I think.
It probably check for case sensitives.. sad.
Infact everything is lowercase.
Wow.. like I didn't think that could be the issue. I had the problem since yesterday.
I was seriously about to giveup.
I tried 100 solutions on Stackoverflow.
Does anyone know how to fix 502 bad gateway errors on Cloudflare? I checked all the DNS records and they work. This broke my voting rewards system.
Handler now how prefix system setup after a rather poor error on my side
altho the async orm framework does not like sticking shit in folders
?
@modest maple skip it in awl
?
Is there any Discord API wrapper for NodeJS that supports Oauth2 methods
uhm heyyπ¦§
Is there any Discord API wrapper for NodeJS that supports Oauth2 methods
wat
almost all oauth endpoints are... normal endpoints
Isn't that like
Any discord js wrapper
Because that's what it requires to even use discord api
My internet
Like
Ffs
I am referring to a wrapper
So I don't have to do much work myself, for example instead of fetching data via HTTP, you may use lib.refreshToken("refresh_token")
I really didn't find any, since Discord Login Oauth2 is being used more and more in websites, I'd expect a lib or 2 to have this kind of functionality, and instead leaving noobs completely confused
I might work on creating one for public use if that is the case
Oauth2 is quite annoying for me to implement into websites, and that most likely ends up in bugs. Having a library lift a lot of the work is nice
Imagine if there was no libraries like discord.js or eris, people would be stranded lmao
What about any of these https://oauth.net/code/
there aren't any libs that do everything for you because it's completely up to you how you want to handle oauth
I just wanted to know, with discordjs specifically, I've been running a basic bot that just sends embeds for different information, not much is going on, at around 480 servers, suddenly I started noticing an increase from ~100mb of ram towards ~300mb within about a day, there wasn't a sudden skyrocket in user count or server count. Was this due to something on Discords side perhaps, memory leak or just bad coding 
consider reading https://aaronparecki.com/oauth-2-simplified/ if you're feeling confused
Like now my bot seems stable at around 100mb again
Just completely suddenly it rose about 200mb
a restart seemed to fix it though
Thats just discord.js caching users and messages
Djs uses a lot of ram due to caching by default
really? That seems a little drastic for such a short period of time
If you suspect a memory leak, then watch it for longer time
It should stabilize at around 300mb otherwise
For your server count
There are many things that can be done to optimize djs
I am aware. I have implemented oauth2 into websites (which 1 is being used quite frequently) I was just curious if there was a library already out there that handles rate limits and things like that. I know a library can't do all the work for you. But something as simple as <lib>.exchangeToken("") can save a lot of time instead of having to implement it yourself
Some of them might break certain functionality
hmm, might start tinkering with that a bit more
You can make a bot use less than 100mb at thousands of servers if you know what youre doing
D.JS should cut down on cache, just like Eris. Or at least have an option to disable caching of unnecessary things
Thwy already said they wont do it
Because many core features are writren around caching
But it can be done, and its not hard. You need to provide workarounds for certain things
I did it for my bot
50-60mb at 2k servera
Yes
Some featues wont be available, espexially if you disable guild subscriprions
(Dont mind my spelling lul)
My bot basically only relies on the ability to send embeds and add reactions, nothing too intensive so I don't think it needs too many events enabled lol
Could probably get by with disabling a good amount of stuff
Owning a bot that relies on guild member data to be 100% up to date, aswell as cached uses quite a bit of memory
which grows overtime as the cache grows
Do you send welcome messages or use the guild member events?
Those stop working if you disable guild subs
@earnest phoenix discord.js's memory jumps arent just members, disable the PRESENCE_UPDATE event as this event caches updates per member per server
This does however completely disable activities and things like presence as they wont be cached anymore
But this made my bot lose about 800MB memory on 3 day uptime
The problem is, disabling presence updates wont stop discord from sending them to you
Pretty much everything my bot needs is if a user if in a specific guild, user's roles, VC update events, reactions, and all the other basic things
Yes but they wont cache
So your bot will still use a fair amount of bandwidth and cpu just from procesing them
So thats not an issue
there's probably more but 
Tru
The difference of cpu usage with the event disabled saved me 2% of the cpu
It literally uses 2%...
9% total usage of the bot though
2% for caching
Yes
Not for decoding
2% to cache every damn bit
If your total usage is 9%, 8% of that is decoding presence packets
Meh as if the message event didnt recieve a huge load already
Trust me i tested it
My bot can climb to around 20GB memory in around a days uptime just from the guild member & user cache growing (but we cant really clear those as the bot needs them 24/7 for everything)
On my vps
Probably sweeping useless members can be a step in the right direction
Ye but how many guilds
as the cache grows it eventually reaches that
2 billion?
10k
most of the cache will be cached users
10k and 20gb christ
big servers take a lot of cache if you cache everything
Lul
the bot is in quite a lot of big servers too, further adding to the members cache
Im pretty sire if my bot ever reaches 10k, ot wont use more than 100mb ram
But why does it need every member cached tho
well if the bot calls discord api everytime it wants a member we'd be api banned quickly
But why does it need members so badly
maybe the bot needs the members for statistics or other calculations, there can be tons of reasons why a bot needs access to members at all times
If you dont need their presences then kill off the PRESENCE_UPDATE event
Saved probably half the memory
the ONLY thing my bot needs is the presences of every member
Christ
Lmao
Thats just
Pretty much the ordinary things a discord bot may need but has to have them way more
Look my bot had presence requirements, 3GB memory on 2 days can you imagine 200 guilds and 3GB MEMORY USAGE
So i killed off the presence event and bam, 100mb usage now
for example 200 users reacting at once, without cache lmao rip the bot
Lmfao
it does happen aswell
But like
My bot hovers around 300MB with 50ish servers
@blissful scaffold my bot is in 255 with 140mb now
You dont need to have a cached member for many of those things
Im not that worried about RAM, its cheap
For example, discord sends member info on each message
we need to see if a member is in a specific guild or/and the roles they have
For a 16 yo atleast
I think I saw 8GB for 5ish euro/month
and also if they are in a voice channel at times
Ah thwn yeah good luck lul
not upon message or reactions. most of the time those are needed outside of that
Look if ram isnt a problem then continue but you could just save so much @split hazel
If your bot requires things like caxhing all presences, and it ever grows big, ypid be better off writing a custom lib for it, and a custom storage solution
So the presence update is disabled?
The heck u got like 30 million members then?
on intervals
well around 3 million members across all shards and clusters but it can get larger
users*
some guilds have like 90k members
100k members on my bot, 140mb total bot usage, 23mb with just 1k members
Hmmm
This member cache is so terrible
But hey atleast it works
we're working on implementing some features that will sweep members that haven't reacted or basically are dead
Atleast my bot doesnt rape my vps's RAM anymore with presences
Yes
My new version of my bot can hit 29mb on the same application id
But to reach that low the cpu gets a load every few mins
Are you using sweeping?
Yup
Using snowflakes of members and users
And i just sweep all emojis and other stuff with it
I tried that for a while, moved on to something now
Well sweeping everything is great until that one guild member needs it again
Honestly I did try to get what uses what amount of memory via chrome debugger

I am not an expert in that area so all I saw in my perspective was a lot of jibberish
with occasional human words
I use the raw event to intercept caching and prevent it from happening
i wish i knew how some people debugged the amount of memory a specific feature uses
When music is in use 2gb free
How mich you pay for it?
Who me or speedy
You
Because of referrals getting me ~1.20$/month
Depending how much they buy
Every month
Thingy
Ye
Ye
Lmao
I need every cent
I dont think ill ever use it
Get donations from yoir bot
Especially when hosting a bot that only gets used for music in 3/255 guilds its in
The other 250 guilds are just dead
Lul
One of my anticaching features
Is get rid of unused channels, users and members
At login, my client.channels.size is 0
Lmao
Thats what my cache sweeper on my new bot versikn does
It uses snowflakes that tell when the last interaction was and that stuff
If its under a few minutes i usually delete it from the cache
Like 3 minute inactivity or smth
= gone
I ised to do that, but i found out tje message event automatixaly repopulatws channel cache
Fk spellong
So i stopped that from happenong
Not every channel right?
Now it only caches the channel if the message is an actual command
Just the channel where a message created
Welp
Ill gtg to sleep rather quite soon now lol
Tomorrow hangin out with my gf again

Well
2 weeks yes
Known her for 1.6 years and its finally official

funky flex but alright
imagine
Wrong server
Click on the button that says support server
Okay
Thanks
Why am I so confused
So uhh Where π° sorry for using your tine
Time**
Where do I find support server
How did you get here?
Uhh Searched up EcpeDiscord.com
And clicked where?
Well I searched up Ecpe Discord Clicked the first link and clicked join and Verified phone
Was this the first link? https://top.gg/servers/316150116513873923
Yes
Can you link it, or no
If you scroll down on that page, you should be able to see the actual information of the server you want
Thanks
The link to join on that page is invalid
hey bois when your using message.awaitReactions, once a user reacts does it stop looking for reactions?
depends on what options you give it
I read opinions lol
but like if i set the time to 1 min than is their a option to not make it exit the collector?
huh? you want to set the timer to 1min but have it cancel out or smth?
i'm just trying to get it to collected multiple emojis
but after it collects one than it stops collecting
master or stable
same on master
wdym? if you dont set a max amount of emojis it wont have a max
Hey can someone clear this up for me? When you create a new shard, it connects using a new gateway correct? Does this mean each shard has an individual Global API Rate Limit?
#memes-and-media @gloomy oar
@stoic gate not afaik
REST rate limits have nothing to do with sockets
Idk about socket commads tho, such as request guild members and update user presence
The api says 120 gateway events per 60 seconds
So across all shards, you globally will only ever have 120 events per 60 seconds?
Iβm just trying to understand how a large bot could ever realistically be under the Global Rate Limit
What library would you recommend if I wanted to build a web dashboard for a bot
php 
how do i export a class in node v13 as a default?
so instead of new kita.Server() i can do new kita()
currently exported like this:
const server = class Server {
...
}
export server;
I mean
Instead of doing const car = class
You can just write the class and then export the class
@sick cloud
class Thing {}
export Thing;
do i upload my bot files here?
that doesn't work
The fuck
yeah but before i did that then it cloud not find commands dir and etc
Wdym
export class Server { works
oh
but i have to do import { Server } from './Server.js';
now it doesn't know what it is
import './Server.js';
export const server = Server;
^
ReferenceError: Server is not defined```
export default class Server {
You need to do import './Server.js' as Server
No
I'm trying to think
Oh
Ffs es6
import Server from './Server.js'
Es6 sucks
so this now
import Server from './Server.js'
export default Server;
that works
however when i try to actually use it
import * as kita from './src/index.js';
const server = new kita();
i have to use new kita.default()
.-.
This is why I hate es6
yea
Using module.exports is so much easier
i might switch back
const Kita = require('./src/index');
const port = 80;
const app = new Kita();
app.get('/', (req, res) => {
/res.send('<h1>This is page 1</h1>');
});
app.start(port, () => {
console.log(`Ready to go on port ${port}`);
});
π
also no i cant mix them
Ah rip
@delicate zephyr gonna ask for your opinion on rendering - since i'm trying to keep this lib light, should i include html rendering support (ie. ejs, etc) or just basics (strings and .html files)?
anyone know a good way to make an exp bar using PIL in python. I used to have the code by i reset my pc, google is no help kek
@sick cloud use ejs since it'll be nicer for you to develop
this is a "light" replacement for express though not just for me
ok so i got my bot running but how do i keep it online 24/7
its got full support for ejs and all but you have to make the renderer yourself rn
@earnest phoenix pm2
pm2?
no, just making this for fun
nice
@earnest phoenix
npm install pm2 -g
pm2 start <your bots filename>.js --name <your bots name or something>
ie.
pm2 start bot.js --name cool-bot```
@earnest phoenix #general or #memes-and-media for chat
@earnest phoenix yes
and then theres some basic commands
pm2 stop <the name you set> <---- stop the bot/take it offline
pm2 restart <the name you set> <---- restart the bot
pm2 logs <the name you set> <---- view logs and errors. if you can't see the full error use "--lines 50" to see 50 more for example
aight ty
run pm2 startup and pm2 save
i was gonna say to run those too
then it will keep running even if your server restarts for whatever reason
iirc pm2 startup gives you a command to paste
but if i change the bots code do i just need to replace those files or what?
i mean on pc
yeah
replace the files on your vps then run pm2 restart like i sent before
you could set up a git repo for your bot and then you can just fetch/pull on your vps and restart
ok
Or use a code editor that supports sftp
You can also use pm2 in watch mode, which will restart your bot automatically whenever a file changes
sikgh
many
many things
oofed last night
i need to work out why its suddenly failing to connect to the ws
What code are you getting
[Errno 10061] Connect call failed ('192.168.0.25', 34566)
thats it xD
its not a discord ws
you havent actually assigned client at all
or even got the client object
which is an issue in itself
because client cant use cogs
you need the bot object to begin with
also client.latency wont work
is there any way to detect the most used color in a picture using JavaScript?
lol
what
use colorthief package
If you just want red/green/blue values, you can unpack the image into pixels, add them all up and divide by amount of pixels lol
^
@mossy vine is i update the bot do i need to do pm2 startup and pm2 save again?
how do I trigger a message when a specific user is tagged? there is list of userids in a database if the users in database are mentioned then it should trigger a message.
feel free to ping me
@earnest phoenix no
ok
@lofty vine check if message contains a mention. If it does, check if id exists in database. If does, send message
@lofty vine which library
js
discord.js?
message.mentions.first() gets the first mention (ordered by id), if it exists
um
Well you can also do this ^ but then yoi need all the relevant members in your database preloaded/cached in your code
yea how to do that
:readthedocs:
okay as you say!
What database?
0-30
using enmap?
enmap is the same as keyv, a database wrapper
yea ik
Then check your database documentation on how to get all values
And save them in an object or an array
o okay! thanks!!
Then use this object/array when checking if message contains a mention
ye thanks!
but I can't find out the way to store them all in a variable //{tried checking documentation at keyv and sqlite3}
Keyv doesnt have a way to get all entries, unless using the raw option
Bht since you dont have a lot of entries
Just loop over them
Good qiestoon, apparently keyv doesnt support tgat either lol
Literally a million ways
um...?
You can simply forget keyv and just do ```js
const userIds = [id1,id2,id3,id4,etc...]
lol
but I need the data to be stored throughout reboots and want users to add data to it
Then get a different db
Whatever floats your boat
You can use a wrapper, an orm or an actual db
There exist hundreds of solutions with varying levels of complexity
I think so, i havent used it
hard to code these things π
I use sqlite directly, without wrappers and orms
sqlite3?
Just a driver, in my case i prefer better-sqlite3
Its a driver, therefore it directly uses the SQL language
It can do anything an SQL database can
But you need to learn SQL, its an entire different language
how can i convert rgb to hex?
ask google
i have that code const rgbToHex = (r, g, b) => '#' + [r, g, b].map(x => { const hex = x.toString(16) return hex.length === 1 ? '0' + hex : hex }).join('') console.log(rgbToHex(0, 51, 255)); // '#0033ff'
but since color-thief returns me the rgb in a array that won't return me the hex rather a error
how to make bot β
wait nvm il, just search it up
<@&304313580025544704>
-atmods @drifting tiger
@drifting tiger
Please do not mention (ping) more than one or two moderators for help, unless there is an emergency.
Here are some examples of emergencies:
- Raids / Multiple members mass spamming.
- Severe disruption of Discord's ToS (NSFW content, etc)
- Anything that requires more than 2 moderators to handle.
what 
how
@grizzled raven better-sqlite3 has a very good explanation on the differences from other libs in their github. The main thing is that its a sync lib, so you have to work around that by using efficient queries, other than that its much faster than other libs
@drifting tiger how about read #502193464054644737
instead of pinging moderators
saves a lot of time || and a possible mute ||
@grizzled raven sqlite should automatically reuse deleted row ids no?
I remember reading in their docs that it does
i just use a unique uuid4 code for my Ids
In other words, the purpose of AUTOINCREMENT is to prevent the reuse of ROWIDs from previously deleted rows.
TypeError: Cannot read property 'toString' of undefined
``` @quartz kindle
x aint defined...
the error says otherwise
const rgbToHex = (r, g, b) => '#' + [r, g, b].map(x => {
console.log(x)
const hex = x.toString(16)
return hex.length === 1 ? '0' + hex : hex
}).join('')
console.log(rgbToHex(0, 51, 255)); // '#0033ff'
console log x and see if its returning it
@low wasp for autoincrement yes, i dont use it, i have user ids as primary key, so the hidden rowid col is regenerated
it returns me
0
51
255
rowid is autoincrement
Not if you have your own primary key
true
@quartz kindle can you help?
No time now
Ok
how to get my bots cpu usage
@earnest phoenix In C# I'd use System.Diagnostic PerformanceCounter but. I guess you should check: https://github.com/aphexcreations/healthjs
There is also process.cpuUsage()
@earnest phoenix what Lang?
js
process.cpuUsage() or https://github.com/aphexcreations/healthjs
Check both.
@tiny tinsel
i got my command but
it just sends me an number and with that number i would like to do this
let cpupercent = Math.round((cpu * max) / 1000) / 10;
```but what should the max be
for my server count i have use this
const { stringify } = require('querystring');
const { request } = require('https');
const update = () => {
const data = stringify({ server_count: client.guilds.size });
const req = request({
host: 'discordbots.org',
path: `/api/bots/${client.user.id}/stats`,
method: 'POST',
headers: {
'Authorization': 'API TOKEN',
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': Buffer.byteLength(data)
}
});
req.write(data);
req.end();
};
client.on('ready', update);
client.on('guildCreate', update);
client.on('guildRemove', update);
but still not showing me the server count
@quartz kindle even if you delete a row, the data is still there
i think sqlite just wont bring it up
@earnest phoenix the content type is json not wwwform
i have use that only
the content-length header is useless
mean???
after you successfully POSTed and get a 200 response code, you'll have to wait a minute or two for the guild count to update
but
still not showing
the servers
@grizzled raven if you mean the actual content of the row, not just the rowid, then it depends on the sync mode
Sqlite uses lots ot lazy processing to give control back to the user asap
Many changes remain in memory and take a while to be commited to disk
If you use synchronous off/0 for example, it operates at the fastest performance but doesnd sync data immediately
@earnest phoenix Last time I checked /stats content-type required application/x-www-form-urlencoded
Who reads docs amirite
Selenium Chrome Driver vs Selenium Firefox Driver is crazy.
hi i have a question that discord botom is running 0-24 but i'm not getting any errors but after a couple of hours of running it stops spontaneously i can't do anything log as the bot is running on a linux system with this command
sh -x start.sh &
I can do something to find out why the bot stops working
could I somehow log my activity?
are you using a free host
Yeah I just took a look at how dblpy sends the request
@earnest phoenix you could use something like tmux or screen to be able to see the console while your bot is running
Yes, me I use screen on Ubuntu π
screen gay
it's so buggy from my experience
i switched to tmux
@earnest phoenix home mini server machine
well you could always use a process manager like pm2
all I need to do is create a log file and save everything that happens
error code? console log ??





