#development
1 messages · Page 32 of 1
This tool does not give your bot an event to give a reward to the user. If you want to give a user a reward you'll want to create your own webhook.
to make your own webhook, the webhook URL should be http://YOUR_VPS_IP_ADDRESS:YOUR_APP_PORT/YOUR_APP_POST_PATH
@quartz kindle Can u tell me how to log votes?
💀
with a webhook, same as above
that webhook should be of the server?
no
the webhook URL should be http://YOUR_VPS_IP_ADDRESS:YOUR_APP_PORT/YOUR_APP_POST_PATH
how to create one
?
webhook url
Poor Tim
Anyone know who to ask to re-invite bot? 🤔
You mean like a specific bot?
Now I am waiting for the question on what is a webhook

what is a woman?
only a cat knows what a cat is
same with a woman
lmao
Great convo
the documentary was great
We just debunked the entire argument on what a women is in a matter of seconds
discord.js vs slash commands webhook server
djs looks better
lmao
Nah, like my bot for example, since I've basically migrated whole core to slash now
How do I make a vote reminder?
have an event fire every N minutes and check for users with lastVote distance higher than 12 hours
webhooks are web hooks
I was able to get 2 out of 3 intents, I'm going to have to come up with something unique to get the presence intent
why do you even need it?
"Unfortunately, I am denying" sounds so off
Is this the only way to create a 2-word command like [botprefix] disable global
looks super weird to me
and I don't wanna read the message content for the commands - it's what I'm trying to avoid atm
how? not based on on_message()?
will slash commands allow to have multiple words? 
though when I tried switching to slash I had some issues with my code
slashes allow up to 3 levels of nesting
oh nice
and yes, based on on_message()
well i use discord.js but, you can use arguments?
the command parser has to obviously be triggered from a message event
if it exists in discord.py
that means basically a bunch of IFs, a switch case or a dictionary with mapped functions, all of which defeat the purpose of improving performance I believe, am I wrong?
I think that also answers @light ingot 's comment
yeah tho
not really
involves if statements :/
at least in discord.js
you're thinking about ```
if (command === "stuff") {
...
} else if (command === "otherstuff") {
...
} else if (command === "morestuff") {
...
} else if (command === "thatstuff") {
...
}
...
I absolutely don't mean that
yeah
yeah i know
no you don't lmao
that's just for a single command
the thing is that my on_message is unfortunately my most hungry function due to the nature of my bot, so I'd prefer to be able to fire any other events directly rather than go through it every time
how would u check the command with good performance KuuHaku?
to properly make a command handler u won't be using if clauses to check if X is command Y
you'd use annotations coupled with reflection
it only checks if the sent message starts by the prefix and is it an actual command or not
that is pretty much unavoidable
technically speaking, an if else chain will always be faster than reflection
but not worth the maintainability hell
well my bot doesn't really lag tho
and i use tons of if else statements
basically everywhere in my bot
I guess changing to async postgres would also improve my performance, they claim by about 3 times
ifs aren't a performance issue, they're the lowest level of conditional execution
those are not the kind of things that actually matter in terms of performance, so its pretty much do whatever you prefer
do you do heavy processing in ur bot?
because, as you see, python is monothread like js
btw just for my understanding, any blocking command blocks the current event loop (for example the event fired for the message that was just sent), or is it blocking any other incoming events?
yeah I thought about multiprocessing
you can't
I mean, u can, but it'll be like in js where u spawn separate processes
blocking locks the entire process, so no new events can come in until its unblocked
I definitely need async postgres then XD
is your database local?
yeah what's wroung if I'd have 2-3 processes?
it's not local but it's local relative to where its hosted
if you connect to it via http/sockets, its already async
I use psycopg2
well, aside from the fact you'll need some tricks to be able to pass simple (read: not complex) values between processes
async is anything that needs to wait until it receives a response, it doesnt necessarily need the async keyword. for example, a callback can also be async
so not within the same server?
in js everything that connects to the internet or to your disk its async by default
wouldn't asyncpg have any advantage over psycopg2?
it's python tim
yeah its the python that blocks not the db
python should be the same
it is, they're probably awaiting the result
python does have a lot of blocking things in it
does python do blocking I/O?
It's within the same server I think, I host my bot on PythonAnywhere and they let u have Postgres if u pay more -.-
well, try shortening the resultset and optimizing ur queries
and use indexes
yep yep i do use an index
if you see NATURAL anywhere ir ur EXPLAIN PLAN that's something to worry
since I literally run Levenshtein distance query on every message unless it would be a command now
now wtf
it's inevitable
levenshtein is HEAVY depending on whether ur doing it for every message
well messages less than 255 chars
I know u hate DMs but I can't explain here exactly what I'm doing or what because it would be a great idea for people to steal
despite the heavy resource usage
a thing u could do to lighten the processing is checking if message.length >= shortestCommand.length and message.length <= longestCommand.length
haha
lol wut
levenshtein can halt your process easily, especially on python/js
jk my vms are already stuffed to capacity
the levenshtein runs on the databable
not if ur checking for every single message
the query takes about 200/300ms
depends what you're checking it against
all commands
if you have 50+ commands then yeah lol
why lol
ok so, here's the first bottleneck
how many servers?
but if it does I can basically tell it to look at the first X messages
not many, 113
not really advertising it
what exactly does you bot do?
you should be worried if it's already presenting performance issues at 113 guilds
The workflow could probably be optimized
ah so a chatbot
yes
but the users can teach it stuff
u tell it what to reply to which message
now levenshtein is used to check if ur msg has typos
well, there's a reason "neural networks" exist
Trying to apply standard logic to "AI" doesn't work out well
they were basically made for exactly that
you need a workflow for pattern recognition
hmm
that is kind of a side project i have, i bet working with neural networks means i have to get a degree lol
it's a veeeeeeeeery complex study to make something like that work
python is a good language of choice for that since it's heavily math based, but how you're going about it isn't ideal
typos against what? depending on what it is, it will be much faster to generate a table of all possible variations of the word and match that with the messages
and you're constrained to a closed domain
INTERESTING!
the cost in size will be, tho, O(n!)
you think it'd work better though? To have maybe hundreds of thousands of messages rather than thousands?
depends what you're checking against
checking whether the message is similar to any other message
by a distance that I calculate based on how long the message is
so if ur message is 40 chars long i accommodate for more typos
that's why you need pattern recognition because that falls apart if you word a sentence differently
well, if you try to generate a table of all possible variations, and if this table gets bigger than a few thousands or tens of thousands of entries, then its not worth it
absolutely for example has 10 characters, so 3.628.800 permutations, I'd put a few dozen of zeroes on that estimate
so yeah, depends on what you're matching
that if we're only counting the characters inside the text
else u get 26 possible chars per char
well levenshtein simply checks how many character changes need to be done to make it like the word absolutely
like i was thinking about the common censor filters people use, that match for common variations of fuck for example
which is not all permutations of the word, just the common ones
that might be doable with Soundex as well
leven is probably better, u just need to optimize it
you can also use heatmap-based analysis
like, store all typos and check the most common first
The distance is calculated as follows:
round(np.max(np.rint(np.nan_to_num((0, np.log10(msg_length - 2.5)*2.2)))))
this leads to a gradually growing allowance of typos for longer messages
Then the query is
SELECT reply FROM guildmessages WHERE guildid = %s::VARCHAR AND levenshtein(%s, message) <= %s::INTEGER ORDER BY RANDOM() LIMIT 1
for example, use leven to compare, if it matches, add the matched message to the database
but that would be more queries which is also consuming time, no?
or u mean do it in the same query
interesting!!!!
I like that idea
1 extra query
you'd have 2 tables: the main containing the actual triggers and the auxiliar (heatmap) containing the typos and their matches
check first the heatmap table (sorted by number of occurences, descending) to see if one matches
currently I first check if there's an exact match, then if there's a similar reply
if it does, use the matched result, else levenshtein the main table
then if there are replies taught on other servers (could be enabled or disabled in the bot)
that way u can have a list of common typos without having to populate it beforehand
bruh, how do I fix this, I haven't touch this project for like few months
space before json
ur fast lol
I mean, the double space between token in gives it away
Kuu lives here for support
I just open the project and not touching anything yet
Well I need to see how to store the heatmap with the rest of the real messages, because they are based on guild id, and then I'd have to store the typo ones for a specific guild, and that could create issues
check the json you're trying to read even if u didn't touch it
maybe the heatmap will be global to all guilds idk
just use a global heatmap
it'll be only used for lookup anyway
that's the problem, idk where 
still check for guild, but after you find a match
ah wait, just noticed "petitio"
that lib is outdated af
are u using erela.js btw?
yeh on some of the package
that lib wasn't update since last year
you're the second person to come here with petitio + erela issues
I see
there are probably alternatives to it, just give it a search like "node alternatives to erela.js"
erela is still being maintained btw
not the one in npm
last pub was 1 year ago
ah yes, I was in "erela" page
Idk why people don't just use the built in http library. It literally has a simple interface
i believe either youtube or spotify broke in erela.js, the last guy that came here was using both
the spotify integration
I had some gremlin come to me regarding my LavaLink remake complaining about erela.js support
lmao
welp, I can't play music because of this 
The solution is to not make a music bot
it isn't worth the hassle
I would know because I make my own - a lot of the software I integrate with is proprietary because the scalable music space sucks
I did too, dropped the module after having to deal with constant issues
usually if your bot isn't entirely dedicated to music, you're not gonna go too far
Try to read this and tell me: "YEP. Easy. idk what you're bitching about"
https://github.com/AmandaDiscord/Volcano/blob/main/src/worker.ts
what's the point though
we already have enough music bots
We do, but I think the draw towards them is that the popular ones implement their interfaces in an ugly fashion
Rhythm's dash was laggy as fuck when the queue had more than 50 tracks and that was because of how it handled elements
The discord interface was also very bland
Most of the work had been cut out for it in lavalink
i recently had opened an issue in GitHub about it
they told me to use the developement build of erela.js
Yeh
I swiitch the version to the build version
It works lmao
It's all because of 1 lib 💀
a couple of my commands
that's why I need to come up with something better to recieve that intent
ok but for what (like, examples) you need those intents?
I can only see maybe an absolutely niche use for it
"i want it just because i do, so im gonna invent something that needs it just so i can get it"
do explain me whats the need of music bots in the first place tho 🤔
how hard is it to use spotify, or just have youtube run somewhere ,-,|
lit adds up to the same thing, except discord quality being somehow lower ffs
people want others to listen to whatever they're listening to because they dont listen for their enjoyment, they listen to show off
Ummm, so basically my bot make a new link for server invite but it make the link have infinite use and only 1 day expire time, how do I limit the user to 1 per invite
Spotify bs lets u do that since 2018 or 19 tho lol, u can listen to what ur discord peeps listening to
but spotify requires the user to actually want to open your playlist
bot would lowkey take roughly same time if not more tho ll
but people can kinda "force" someone to listen more easily lmao
Join channel > Search the song in the bots queue command > set it to paly
open spotify > search song > click play

or if spotify always open, even easier xD
I use it when I'm driving or in metro tbh
for work stuff usually got my youtube playlist xD
i usually listen to youtube radio streams
but most of the time i dont really listen to anything
i enjoy the silence :^)
there's no silence here, just car noises 24.7 wwwww
so its either that, or some nice chill music
xD
I'd honestly take the music during work
Tho back to topic, its even funnier when music bots support spotify playlists xD
like.... bruh.... if you're going to open it anyways.. why bother ,-,|
its like bringing it home

they dont want to simply open the window and listen, they want to take the song and drag it home
into their discord homes
How do I limit generated invite link only can be used once
just as you would jail a bird because you want it to sing inside your home
Which lib u using?
discord.js ?
Has it documented already, or ask on official server xD
Pain 
uhhh no idea in v14 but ik in v12 or 10 was
message.guild.createInvite({options})
I mean like limit it for 1 use, mine currently don't have limit aka unlimited but it timed for 24hr before it expired
max use value to 1
atleast one of us had d.js docs pinned xD
havent done so on new laptop yet ,-,
nah
ye but needs u to have visited it b4
i fr havent visited it once since i started my recode to djs v14 ,-,
actually, i only need to type d
lit going off of update thing from v12-13 tehn adjusting to v14 xD
meh
xd
https://discordapp.com/channels/264445053596991498/264889891039608874/1011995279479804024
ok so bot still in server at least i know taht
btw @quartz kindle think i should just ask in #support later? 
Cant even test anything here anyways, since moved most to slash -,-
ask what?
to re-inv bot xD
thing's been sleeping here for maybe 2years? now while i was busy irl
Ye, its already here anyways as far as i can tell 🤔
ah icic,
will run console to leave server later ig
every now and then they make a poll, and only the most voted bots get added
all other thousands of bots here were already kicked
something about scalability issues or discord limiting the number of bots per server or something
all of the above i bet
xD
Ah yes but now what is the web and what is a hook
a web is a web
a hook is a hook
only a web knows what a web is
web means```
'W'eb
w'E'b
we'B'
are you singing dubstep?
Please don't spam
sorry i had my computer closed and stuff on my keyboard ;-;
mood
see the docs on which url u need to fetch
im not positive if im doing this correct
its always returning true
first one should be between 1 and 1, so 1. second one should be between 1 and 100
(I recommend making a function for your random generation so it's easy)
i need to use a variable for my ternaries later
i figured out the issue
okay im using an array to display strings on new lines. how do i handle duplicates?
example:
item
item
item2```
i would like it to display something like
item (x2)
item2```
^
I wish I could help. I am not fluent in js.
Unless there is a built-in function to do it, I would create an embedded loop and just have it compare x to y and if they are the same, delete y from the list.
But why would there even be duplicates? Can you just stop it at the source?
can't you just use "const legendary = (leg1 == leg2);"?
because its an inventory and looting system. you can get duplicate items
Okay. Can you look into doing that embedded loop thing? That's the only think I can think of
Loop over the array and assign each key to a value in an object
obj = {}
loop:
obj[array[i]] = obj[array[i]] + 1 if exists, else obj[array[i]] = 1
``` pseudocode
possibly. Again, I am not very fluent in js. So if you think that will work, go for it.
It’s not a js only problem tbh
oh, what is it?
oh, I see. Yeah, that's what I was thinking. Look it up I guess. I'll help.
const duplicates = numbers.filter((item, index) => index !== numbers.indexOf(item));
You can use this to find the duplicates
Yeah, I can't find a better algorithm
I don’t think that’s what he needs
use this
@uneven tartan
this is really weird to me i havent used anything like this before
yeah, me neither, but you can't just copy and paste it. You're going to have to do some work to get it right.
That was just an idea
Not actual copy and paste code
It’s basically just a map
On one server my bot started throwing discord.errors.Forbidden: 403 Forbidden (error code: 160002): Cannot reply without permission to read message history.
The bot recently went offline.
- Can it crash due to those errors?
- Does this mean that they didn't grant it the read message history SCOPE, or that they denied the permission for the bot/channel?
Also a small question, why would the bot enter on_message event if I used the decorator
@discord.ext.commands.bot_has_permissions(read_message_history=True, read_messages=True, send_messages=True)
and denied those permissions from the bot
they denied permission for the bot/channel.
not positive if it will cause a crash, so i would catch and return since that appears to be rare for you
thanks
Getting this error, can't find anything about that error (especially with Shard ID being None):
[WARNING ] discord.gateway: WebSocket in shard ID None is ratelimited, waiting 57.51 seconds
anyone knows what is causing this?
you're doing something too fast
on_message isn't a command
history isn't a scope, it's a permission and yes, they didn't give it to your bot
how do you add the preview of your website in your "Long description" in topgg?
iframes
<!DOCTYPE html>
<html>
<body>
<iframe src="ur SSL encrypted website here"></iframe>
</body>
</html>
only SSL encrypted websites will work. (https and not http)
thanks
I wonder what it could be, it happened pretty fast after the bot was started:
Aug 25 08:25:03 2022-08-25 08:25:03 - INFO - Connected to Postgres database successfully!
Aug 25 09:17:35 [2022-08-25 09:17:35] [INFO ] discord.client: logging in using static token
Aug 25 09:17:39 [2022-08-25 09:17:39] [INFO ] discord.gateway: Shard ID None has connected to Gateway (Session ID: c90bd81628b978a6aa2ce20a5acadc29).
Aug 25 09:17:40 2022-08-25 09:17:40 - INFO - Deleted stale guild 1004919883387121664 from DB successfully.
Aug 25 09:17:40 2022-08-25 09:17:40 - INFO - Left a guild. Name: . ID: 1004919883387121664
Aug 25 09:17:40 [2022-08-25 09:17:40] [WARNING ] discord.gateway: WebSocket in shard ID None is ratelimited, waiting 57.51 seconds
I figured it was due to it being event, so I just start by checking all of those at the beginning now
thanks, now I verify that I have that before doing anything 🙂
hard to say, but how many shards u have?
I get a counter for the on_message event 😅
I don't use the autosharedbot or create shards, didn't think I need that until like 2500+ guilds
😅
i have this but i want to seen by system
Why do you both need to track message count?
stats command
Still, how many shards?
But why is message count relevant?
It's even more worthless than user count
idk how to count them
Exactly, that's just waste of space
😅
I can see why, probably wanna know their bot performance in comparison to how many events are fired, but that would require more than just message events
Nobody cares about message count, plus you could simply fake that number and nobody would be able to prove
😅
thats too funy
For that you don't store message count, even less show it public
Metrics can be stored sure, but you do it for analytics reasons
968503014849671188
what can I do with the guild presence intent 
how would I get the shard count? @lyric mountain should this be right?
shard_servers = len([guild for guild in self.bot.guilds if guild.shard_id == shard_id])
No idea, check the docs
First tell me why you want it
Your bot is already having performance issues without presences being received, imagine with it
looks like after removing 14 unused imports I'm done with updating the discord library
Can some1 help me understand what is the difference in between
bot.db = await asyncpg.create_pool(database=database_name....
selected_stuff = await bot.db.fetch("SELECT * FROM guilds...
And this:
connection = await asyncpg.connect(
database=database_name, user=database_username, password=database_password, host=database_host_address, port=database_port
)
c = connection.cursor()
c.execute('SELECT * FROM guilds...)
?
What is that weird implementation of setting a pool into the bot object O_o
which auth? where is it happening?
okay in dev build most of stuff will not working
bro 😭
bruh
What does this mean, I didn't understand.. https://cdn.hamoodihajjiri.com/h20tUCO5a2 .
Is it like from const Discord = require('discord.js'); to like import Discord from 'discord.js'; or something.
CommonJS uses require + module.exports, ES Modules uses import + export
I think people prefer ESM today
I personally can't be bothered to learn it so I stick with require
You may want to read this https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
ESM is a bit more strict and the current ecosystem adopting ESM is either one or the other when it comes to CJS or ESM and often leaves a lot of improvements or bug fixes gated behind the transition from CJS to ESM. A lot of modules have already done so in my projects, so I am left with no choice but to drop them. Almost all of my projects support both
I think a lot of the paradigms it introduces like import/export default is useless requirements
The only good thing is top level await
I guess my heatsync module would receive more adoption because of its support for esm if more people used esm
I had all the intents enabled, still have, my bot hasn't passed 100 servers yet despite being verified
you still didn't answer why you need it
Welp, time to migrate then.
I don't mind paid option but if I am moving I probably gonna move away from Heroku
Any suggestions for a good deployment workflow?
heroku killing 12641248 bots with one move lmao
Lol
Great, now I have to think of a deployment solution.
wait heroku wont offer free plans anymore? lmao
Where should I host the bot if I have to pay anyways :p
I think I have exhausted every google option lmfao
lmao
im currently using hetzner
its about 5 bucks per month
i also have one on galaxygate, 2.75 per month
I probably gonna need Postgresql option :p
I do have a Linode tbf
But for VPS mostly
you can always install your own pg in a vps
Yeah, that I know
I just want something where I can shove in and forget about it.
Rare situation I need to intervene is when I do backups
When using asyncpg and a connection pool, should I create a global connection pool and only acquire() from it in the other modules? Or should I keep creating a new pool? Looked at numerous examples and couldn't figure the right usage.
Also not sure when to release the acquired connection from the pool and when to close the pool itself. Seems that everywhere they close the pool but doesn't it defeat the purpose of it?
Dear fellow programmers of all kind, I introduce to you this license: https://git.sr.ht/~boringcactus/fafol/tree/master/item/LICENSE-v0.1.md
lmao
oh yeah let people use it and then randomly decide they are evil and sue them
:^)
generally you want to have one connection pool per process, if those modules are all part of the same process, they should use the same pool
the pool should be alive for as long as the process is alive if its a long running process
imagine if some fang company had that deep as a dependency in their product
they'd get smited
xDDDD
Thanks Tim!
I wonder how you figured that out, I barely found normal docs for that library
i mean, its largely common sense if you think about it
creating and destroying pools for no reason doesnt make much sense
the era of creating and destroying database connections comes from the old php world where every operation would run in its own separate script
wtf asyncpg is impossible to use
not sure whats part of it its from man
what can cuz this?
@boreal iron
it keeps crashing my code, was doing all good before
something from your messageCreate event

did you update to Discord.js v14 when your code is v13 etc?
?
Nothing


i did long ago
from v12 to v13 though

did you upgrade your code with it?
it was doing all good yesterday
Wth
what updates have you made since it last worked?
What is this
wait, version of js for that bot is v12 but nodejs is v16, sorry i updated nodejs & not discordjs
ahh ok
bruh i really cant figure it out, it does that sometimes, crashes the bot then it stops
i use pm2, it start right away again but still
smells like uncaught exceptions
i got a webhook that sends the logs of my pm2 but yeah here you go
and how i am supposed to figure whats wrong
well, that error tells u exactly where it happens
ur trying to get cache of something that returned undefined
whats "discord sent a typing packet..."
and i have ?. after every cache event so if it doesnt cache it it doesnt cause problems
catch exceptions
process.on('uncaughtException', err => {
console.error(err)
});``` (https://nodejs.dev/en/learn/error-handling-in-nodejs#catching-uncaught-exceptions)
well, obviously it does in this case
i guess i am gonna rewrite my wholes bot code, dont want it crashing at unknown times
thanks sir
don't do that unless you enjoy spending weeks hunting mysterious bugs
at least add a log there
i mean its my best option. it will take time but will solve my problems
at least add a log
never mute global exceptions like that
they made exceptions crash the runtime for this very reason
so many shitty js codes that were barely holding together because people simply didn't care
i just did, i am gonna give it a couple of hours to see if it happens again
cuz it literally happens at random times for like no reason
and was doing all good before
catch the exceptions
good point
i accidentally deleted the console.error bit 
i did
big bun no baka
catch the exceptions where they happen
i will message back if it happens again
so u can give proper treatment to the cases
cuz i really cant know when it happens lmao
rip
now bot doesnt crash but i am getting that error bruv
time to debug
i am gonna check smth
Uhh... What discord.js version are you using exactly?
for this bot 12.5.1
i am looking to upgrade anyways, rewriting the code is smth that i should do
Of course you're gonna get that error if you're using v12
That version doesn't know how to handle the newer API requests
i am not using a new features though?
ah bruv
i am gonna update anyways soon. thanks for the help guys
Omg
What
Epic command
💀
for webhooks, how would i use a discord webhook? i put a discord webhook in the webhook url slot, but it doesnt send when i press send test
@vestal summit for discord webhooks for vote webhooks, either use https://webhook-topgg.com or code a solution (https://docs.top.gg)
Simplifying top.gg webhooks for all users, allowing non-developers and developers to use webhooks for their bot and server without confusing configuration.
oop
was writing a reply anyways lmao
how can i stop this?
don't spam requests to the discord api
1 min ratelimit makes me think you have something related to channels, am I right?
ye
Well, you see, channel ratelimit is VERY low compared to the rest
I think the only things that have lower ratelimit are name/avatar change and guild creation
Whatever you're doing, rethink whether it's really necessary
A "client"?
yes
Wdym?
a hosting client
You're not renting your server are you?
why
That's against ToS of pretty much any provider I know
Could get you into legal issues
i work at a bot hosting company
Well, I'm not sure why exactly you're helping your clients codewise, but tell them channels shouldn't be created too fast, and if they're making a "guild backup" feature, it won't go very far
Especially since last year when discord added a template feature
we use Pterodactyl
The story only gets worse on each page 💀
i’m only an administrator at the company and a client myself
This is as much as I can say without looking at the code
How do I turn my Promises in an object in an array into values?
currently have this, but it doesnt convert them to values
await Promise.allSettled(results.flatMap((a) => a.episodes.map((b) => b.status)));
console.log(results.flatMap((a) => a.episodes.map((b) => b.status)));
Tf is Promise.allSettled?
Promise.all gives error if one of the promises fails
Promise.allSettled doesn't care if a promise is rejected
ok i need some help now
Why not just ```js
for(const prom of promises) {
array.push(await prom)
}
though I might be stupid and that probably doesn't work
well, that is too slow.
...what
I want to send all the request at once then wait for all to be done
how so? anything else will be literally doing the same thing
No iterator is faster than crude loop
you cannot do that really
rather than send, wait for the reply, send, wait for the reply
It's like, the basemost iteration method
I hate to burst your bubble but js is single threaded and what you're trying to do sounds like a ratelimit nightmare
Trust me, it works. but I cannot find a way to turn the Promises into values
(Assuming there's some sort of fetching involved, that's usually the most common use case for async)
import discord
import os
from discord.ext import commands
bot = commands.Bot(command_prefix="!",intents=discord.Intents().all())
version='P&FS 1.1.0'
@bot.remove_command('help')
@bot.event
async def on_ready():
log=bot.get_channel(1004452126916878436)
embed=discord.Embed(title=f'{version} has started!', description=f'**Version:** {version}\n**Dev:** Lando the Tech Guy#7045\n**Hosted on:**, color=0xff0000)
embed.set_thumbnail(url="")
await log.send(embed=embed)
print("------")
print(f"{bot.user} | {bot.user.id} is connected to Discord!\nReady for all recipents!")
print("------")
print(' ')
print(' ')
print(' ')
print(' ')
print(' ')
print(' ')
print(' ')
print(' ')
print(' ')
print(' ')
print(' ')
print(' ')
print(' ')
print(' ')
print(' ')
print(' ')
print(' ')
print(' ')
print(' ')
print(' ')
print(' ')
print(' ')
print(' ')
print(' ')
print(' ')
print(' ')
print(' ')
print(' ')
print(' ')
print(' ')
print(' ')
print(' ')
print(' ')
print(' ')
print(' ')
print(' ')
print(' ')
print(' ')
print('===================================================================DEV CONSOLE==================================================================')
while True:
await bot.change_presence(status=discord.Status.online, activity=discord.Activity(
type=discord.ActivityType.watching, name="Pizza & Fries Submissions"))
await asyncio.sleep(60)
for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
bot.load_extension(f'cogs.{filename[:-3]}')
print(f"Loaded: {filename}")
bot.run('')```
WHAT THE FUCK
not my bot
wanna know why you're getting ratelimited?
You should stop attempting to fix your clients' codes if you're just a provider
oop
60ms delay between each status
It's like asking your ISP to win your game's match for you
the limit is like 5 changes every 25 seconds or something like that
even then you shouldn't change it that often
what should he set it to?
ok recommend?
What does allSettled return?
every 300 seconds?
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/allSettled looks like it just does exactly what I suggested
asyncio.sleep() takes seconds, not milliseconds
So it returns a collection of results
Don't map inside allSettled
First let it resolve the promises, THEN deal with the values
Just do await Promise.allSettled(yourPromises) and the result will be an array of your promises
Just a heads up, it does the exact same thing as I suggested 😛
Oh wait I'm super dumb with this python thing
Ye, it'll boil down to loops anyway
You're changing the status IN the while true loop, and sleeping after the while true
you're stuck in an infinite loop spamming requests to the dapi
reason number 2 of why python is garbage: I can't tell where scopes begin or end easily
Python is just turing-complete YAML
Yeah, @hidden gorge the problem is this for sure ^
Hi 👋🏽
I don't want the promises to be in a new array. I just want to convert the fulfilled promises into their values inn their respective locations
I'm currently doing it now using a for loop. Though I don't know how I can extract the values from there
i dont even think there is a delay for each loop
^
oh yea just saw that
Well, you're likely not going to achieve that very easily
You could try a traditional for loop like I said
for(let i = 0; i < array.length; i++) {
array[i] = await array[i];
}
for (let i = 0; i < results.length; i++) {
for (let j = 0; j < results[i].episodes.length; j++) {
results[i].episodes[j].status = //what do I put here? The value of this is `Promise { true }` I want to set this value to true
}
}
looks like a worse version of promise.all
The promises are already .allSettled
await results[i].episodes[j].status
just tried this, and somehow awaiting an ALREADY FULFILLED promise works....
I'm done. This is what I've got```js
await Promise.allSettled(results.flatMap((a) => a.episodes.map((b) => b.status)));
for (let i = 0; i < results.length; i++) {
for (let j = 0; j < results[i].episodes.length; j++) {
results[i].episodes[j].status = (await results[i].episodes[j].status) ? 1 : 0;
}
}
the cpu cycles used by creating and filling an array is going to take far less time than awaiting the promises
I don't see why you're mapping here, just seems like a waste to me
no idea where the map is necessary
but if it works it works I suppose
may I ask why you have an array of promises of this size anyways?
making a database request on every episode
bruh...
I'm soon gonna cache it locally to not spam it
You should instead make a batch request
^^^
Your database will be much happier with batch requests than "fuck you I'm gonna hit you with 350 requests in 5.6 seconds"
Is it better to send 50x1kb(50kb total) request or 1x500kb(500kb total) request?
The latter 100%
or should I be a good developer and ask the database to filter it for me
Filters can allow more than 1 return value
Like, grab all the data you'll use at once, not the entire table
yeah, instead of requesting to get 50 values at a time, im just gonna request the entire database and cache it...
That's pretty bad
Caches should only hold recently used values, not be a mirror of the entire database
Else u lose the "cache" benefit
well, how are you going to do it ?
cache everything that I've requested
but that's gonna result in 50 requests x 1 kb
do you know how to do that in mongodb?
No but there should be something akin to sql's IN
im just gonna cache the entire database. its not more than 10mb anyways
that defeats the purpose of a database pretty much
same here
It'll be fun until November 28 rolls around in this chat
Not as much fun as when September rolls around with message content intent 😉
Mmm
Doesn't that only affect verified people who use it
I haven't been keeping tabs on it tbh as I never use the message content anymore
have any new free server like heroku ?
Who wrote it like this wtf?
hello what is a loop
screw the people who invented the iso week date
mfs telling me "yes if Thursday, week 53"
replit

my country poor and Im poor. Even 1 dollar is too expensive.
Give me ur vps then
what bot permission is required to change channel permissions?
my bot was declined for requiring the MANAGE_CHANNELS permission for it's lock command
I still find this dumb
smh
Imagine needing the manage roles permission to change channel specific perms
I mean I’m not entirely sure if that’s the requirement
its confusing yeah
Its not clear on the dev docs
I would like one of the Bot Testers for their opinion
well you change the perms of a channel
just for a specific role
@everyone is also a role
What is wrong with this line?
is_paused = await bot.pool.fetch(sql_get_paused_status_for_guild, [guildid])
I seem to be getting an exception but it's not getting caught for some reason, probably related to the whole async shit. It's like nothing happens past that line.
the sql variable holds this:
""" SELECT ispaused::BOOLEAN FROM guilds WHERE guildid = $1::VARCHAR """
btw this one works fine:
ver = await bot.pool.fetch("SELECT version();")
print(f"TEST: {ver}")
have you tried (guildid, )
haven't. I did try , guildid
also why is your guildid a varchar
but they have no meanings as numbers, I read that it's recommended to keep it as text
it isnt
you never calculate something based off of them
that doesnt mean anything
they're just a collection of digits
if its a number, store it as a number
doesnt matter if youre going to do calculations or it or not
i dont understand why asyncpg parses query differently than psycopg2
I used to run conn.execute(sql_get_paused_status_for_guild, [guildid])
before switching to use asynpg
with the sql query having variables as %s
now they have to be $1, $2 etc, and the python execution is different too
and an exception is raised without being printed
doesn't work either
except Error as e:
logger.error(f"Could not get paused status for guild {guildid}. Error: {e}.")
when I debug it does get to the except line but doesn't get past it
the syntax did change
managed to show the error using raise
asyncpg.exceptions.DataError: invalid input for query argument $1: 1005891149342441572 (expected str, got int)
weird, i did cast it to varchar.. it worked with psycopg2
btw this one works mate thanks
Can we check if the text in css fits there?
If it doesn't fit, I'll scroll the text, so I need to be able to control it.
overflow-x: auto ig 
i'm try to do this
<marquee>text</marquee>
if i can find out if the text fits inside the div i can do that
why marquee
what youd want is to make the text have an overflow scroll and control it maybe with js or smthn
not manually scrolling the text will automatically scroll if it doesn't fit in the div
like this
marquee is deprecated and you probably want to achieve with css or js
how can i get the size of the text
Is there something like measueText like in canvas
String.length doesn't work very well because iiii and WWWW are not the same size
thanks
- only in relative fonts
IIII
WWWW
I really hate this error, can't figure it out: https://cdn.hamoodihajjiri.com/KqHXbL4DKg .
I've pointed an A record towards the VPS (to configure a reverse proxy via NGINX) cause I want to host an express website app.
I've mostly followed all steps within https://billing.oxide.host/knowledgebase/20/Virtual-Servers--How-to-setup-and-configure-a-reverse-proxy-using-NGINX.html .
However, I can't issue a certificate via certbot certonly.
Oxide Hosting - We currently provide consumers both reliable and high quality Virtual Servers (VPS), Game Hosting, Website Hosting, Discord Bot Hosting and Domains at affordable prices.
if you already have nginx running, use the webroot option
do note, self-signed certificates are flagged as insecure on chrome
thats not selfsigned is it?
in python how do i get someones username and tag for example bot#0000
ayo
can i msg u
sure
@boreal iron since you're the php dude, i need some suggestions for an image resizing script, currely using gmagick extension, and it appears to be horribly slow (> 1 minute for 6 images)
basically im reading a folder of images and for each image store 2 different sizes
$image = new Gmagick("gallery/".$path[0]."/".$path[1]);
$image->thumbnailimage(0, 1080);
$image->writeimage("img-gallery/".$name);
$image->thumbnailimage(300, 0);
$image->writeimage("img-gallery/thumb_".$name);
tim if I want to pull a git repo, keeping the local changes in case of a conflict, is it git pull -s ours?
nhe
it's for my auto-sync script
hello, i have a problem with my bot, specifically with mysql, i want to get the id in the database, but it give RowDataPacket { ID: 50 }, how can i extract the number 50?
const selectContent= `SELECT \`ID\` FROM \`shark_warn\` WHERE ID_Utente='${target.id}'`
var SELECT = selectContent
con.query(SELECT, function(err, result){
if (err) throw err;
var ArrayID = result[0]
if(result[9] === undefined) {
if (result[8] === undefined){
if(result[7] === undefined){
if(result[6] === undefined){
if(result[5] === undefined){
if(result[4] === undefined){
if(result[3] === undefined){
if(result[2] === undefined){
if(result[1] === undefined){
if(result[0] === undefined){
} else {
ArrayID = result[0]
}
}else {
ArrayID = result[1]
}
}else {
ArrayID = result[2]
}
}else {
ArrayID = result[3]
}
}else {
ArrayID = result[4]
}
}else {
ArrayID = result[5]
}
}else {
ArrayID = result[6]
}
}else {
ArrayID = result[7]
}
}else {
ArrayID = result[8]
}
}else {
ArrayID = result[9]
}
console.log(ArrayID)```
WHAT THE FUCK
this is my code
javascript
it's for getting the last id (is for a warn command)
congratulations, u won the "worst code formatting" competition, bae gets the second place
I'm not very practical with nodejs 😅
const SELECT = `SELECT \`ID\` FROM \`shark_warn\` WHERE ID_Utente='${target.id}'`;
con.query(SELECT, function(err, result){
if (err) throw err;
var ArrayID = result[result.length - 1];
}
i try it
all that could be reduced to ```js
const selectContent = "SELECT ID FROM shark_warn WHERE ID_Utente = ?1";
con.query(selectContent, (err, result) => {
if (err) throw err;
const ArrayID = result[0].ID; // query returns a row list
// use ArrayID here
}, [target.id]);
also, if you want only the last result, its much better to write it in the select query, but depends on what columns you have to filter with
or you can just do ORDER BY ID DESC LIMIT 1
it print RowDataPacket { ID: 57 }, and not 57
see my code
just add .ID lol
console.log(ArrayID.ID)?
@boreal iron nevermind lmao
for context, this takes almost 2 minutes on 6 images
$image = new Gmagick("gallery/".$path[0]."/".$path[1]);
$image->thumbnailimage(0, 1080);
$image->writeimage("img-gallery/".$name);
$image->thumbnailimage(300, 0);
$image->writeimage("img-gallery/thumb_".$name);
this takes 5 seconds ```php
$image = new Imagick();
$image->setOption("jpeg:size", '1080x1080');
$image->readImage("gallery/".$path[0]."/".$path[1]);
$image->thumbnailImage(1080, 1080, true);
$image->writeImage("img-gallery/".$name);
$image->thumbnailImage(300, 300, true);
$image->writeImage("img-gallery/thumb_".$name);
php is weird lmao
i always hear people saying imagick/gmagick is much better than gd
no idea why gmagick is so slow in this situation
don't even know why you should pick gmagick in the first place
imagick provides far more possibilities and features and is known to not have any vulnerabilities
some say gmagick is a better/improved imagick
well thing is GD is a very, very basic without many features
but I see you just creating a thumbnail
aka image resizing
which GD is totally enough for
well it's just fork of imagick afaik
without new features or anything else, which should be "more" optimized
but this is the status of like 10y ago
yeah
who knows what changes imagick has made over the time gmagick is missing now
sorry if i disturb you again, but how can i have the number of times the user appears on the database?
for exemple, the select give this: [
RowDataPacket { ID: 5 },
RowDataPacket { ID: 6 },
RowDataPacket { ID: 7 },
RowDataPacket { ID: 8 },
RowDataPacket { ID: 9 }
]
SELECT count(*) from shark_warn WHERE ID_Utente=...
thanks

until now
LMAO BAE
you should actually assign another col name as it will be weird without doing so
SELECT COUNT(*) AS total FROM shark_warn WHERE ID_Utente = ...
It rivals https://pastebin.com/SNMA66Fv
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.
physical pain
what the fuck am I witnessing
ahem I mean
Please use for loops using integers, that would clean up alot
or what tim etc said
would it be possible for anyone to ask the mods in microsoft community to unban me? or is there a way to appeal at all?
I need to ask something important 😭
😭 bruh
you lost your crown bae, get over it
HOW did u get banned?
I don't remember I think I was arguing with another member
but come on like almost a year has passed and I used to go there everytime I had a PC issue 😭
your ban email should contain the reason
rn I have one and I can't get no help
do you know windows 10...maybe u can help lmao
did u try searching if someone else had a similar issue?
yeah but no fix on the internet seemed to work yet
keep searching then
I changed my dedicated vram in regedit to around 2gb and now my gta v is having memory leaks
I jus wanna know how to change it back
I changed ... in regedit
so, yeah buddy, you fucked up
you don't simply "change" regedit and expect to be able to revert stuff at any time
it worked well on all games just gta v seems to be having weird texture alloc glitches
from what I read that's the reason anyway
what were u trying to do in the first place just out of curiosity
regedit is probably the deepest, most expert-ish place you can go to tweak windows
unless you know EXACTLY what you're doing (read: not following some random guy's comment), you shouldn't even open it
increase the amount of visible vram
to be able to play games that require more than 2gb vram (I have only 1gb)
worked well, could play all of them easy on medium settings either way
but not gta v
if the game expects to be able to use 2gb vram, u can't simply dig a hole and say "here, more ram"
well yeah and it's allocating more than my specs can handle that's why
i think that’s the closest you could get to downloading ram tho
I can't really express how fckd up that idea even is
it did work tho
clearly it didn't
probably because gta is a massive game that requires more than 1gb of vram
it's like...putting water in your car's tank so the gauge goes up
the others also required more than that
will it work? visibly, yes
is it a good idea? hell no
but ran smooth anyway
well if u change something like that u can’t just expect stuff to work
I think found a fix
there is a commandline script that restricts gta v to specific memory
if I can restrict it to the amount of memory I got it should work I think
so, lemme explain you why that's a messed up idea:
Imagine you have a table, you need to put your stuff in it to be able to use them.
One day, a guy tries to use your table, but he needs a bigger table because he uses more stuff at once
instead of buying a bigger table, you hypnotize him so he sees a table bigger than it is in reality
i can almost guarantee gta won’t work on that little vram
however, the moment he tries to put his stuff in the "table", it falls to the ground, he gets confused
he keeps trying, but for some reason, putting stuff in half the "table" makes it fall straight to the ground
he question: "If I can see a big table, why can't I put my stuff in it?"
why bae, why can't he?
may I also state, although considering it's you, I hope you created a restoration point before starting all this
else better prepare a format usb stick for a near future
nope, I did the reg trick thing I told u about around 2 years ago
any backup I did is looong gone
?? wdym 1gb is enough
even if not then I can just decrease the graphic settings
i really doubt it’ll run on 1gb without problems
people have run really old versions of gta 5 with 1gb of vram.
but its important to remember its been 7 years since then, gta 5 is a much larger game now. every new car, weapon, cosmetic, feature will bring the required vram up.
Theres a reason minimal system requirements exist
how do I make my bot stop processing the msg after command was invoked via await bot.process_commands(message)? It just continues the on_message event after already invoking the right command
return
yeah but I return inside the commands
no, return outside
how do I know whether the process_commands has done something?







