#development
1 messages · Page 89 of 1
the last row will always have the same number as the total count
or -1 if u start with 0
Row number will be what position it’s on but total count might be different
simply use a lone subquery to get the highest entry
brb hang on
explain analyze select collectionalias., count(1) over() as total_count from
(select collections., row_number() over(order by rank_id desc, id
asc) from "collections" where "user_id" = 1 and not "is_item") as
"collectionalias" limit 10
so this is the full query
told ya what u can do
yeah trying to re-do it haha
also, use GROUP BY instead of OVER (...) whenever possible
gotcha
going back to this query, what would i do if im trying to choose multiple row numbers?
like 5, 10
maybe run the same query twice hmmm
WHERE row_n IN (row_numbers)
you can do offset like that?
SELECT *
FROM collections
WHERE user_id = 1
AND NOT is_item
ORDER BY rank_id DESC, id
OFFSET :row_n LIMIT 1```
using offset is much faster, but it only allows 1 row
ye figured, so make this a sub query or split query ig
alr
should be faster either way, thanks
yw
Interesting thing, any thoughts?
i have slash command that works just fine on my pc as host, but when i setup bot on another host , command gives that error
Can provide command code if needed
lag probably
happens with me as well mmm, for every message it sends
Is it possibly slower?
btw for the get all query, when a filter is passed like a -name, i will need to count how many rows exist with that name right? if i moved the total count and row number outside, how would i be able to get this total count
for example: full inventory = 500 rows, but if filtered by name it would be 200 rows,
const total = db.select("SELECT row_number FROM table WHERE id = ${id} ORDER BY row_number DESC LIMIT 1")
yes, to get the total it'll always be a single, lone query
regardless of the rest
whats the API route to update server count on topgg again?
did anyone ever work with prisma before? How can I only push if I dont already have the id in the array? (I know I could fetch before and check with that but is there a more efficient way?)
just catch and ignore the error on update?
ohhh i misread
See the docs
yeah i found it
I'm trying to get the number before any other non-number character in strings such as 40/notifications,{"sid":"xxxx"}
I'm using the regex /^[0-9]{0,}/g
However, on the string I just showed, javascript returns null
Might be the global parameter
ok yep
lol
I don't see how the global flag would impact the match given you're using ^
Welcome to Regex in JavaScript
Hella inconsistent (in my cases)
though I'd replace {0,} for +
regex is supposed to be standardized across everything
* would fit better
so is sql
since it includes 0 matches
zero or more indeed
why'd you want to match nothing
regex is magic once you know how it works
+ would signal that no numbers were matched
even they recommend it!
all but the first*
I get the first number before any other character with /^[0-9]{0,}/
And then I put the result in a switch
And if the result is "42" it goes to the second regex
Which works
is it supposed to stop right before {?
Not really needed
It'll always be in the format as in this image
(can also start with [)
(can you copy paste good sir :))
no
also \ is unnecessary apparently
I already throught the thing for u, the least u can do is write damn
the thing is less than 15 chars
potato potata
Can you use 0 instead of null or undefined in the second parameter of JSON.stringify?
Originally: JSON.stringify({}, null, 4)
What I'm thinking of: JSON.stringify({}, 0, 4)
why don't u simply use with 1 param?
3rd one is indentation/formatting
ok but why do u need it formatted?
So I can view the whole json at once without being thrown with [Object] everywhere
I'm still in testing 
Getting request to https://users.roblox.com/v1/usernames/users failed, reason: Failed to fetch when trying to use node-fetch, same thing happened with axios
but when I visit it in browser or use postman/thunder client, it works
are you missing any headers?
is it possible the username isnt a real username?
no idea then
i tried console.log(err) and i get that
try adding Accept: application/json
oki doki
just in case
It had to be cors
of course
Of cors*
😭
Cors is the bane of every developer, because u simply can't solve it sometimes
who knows how to fix this?
its faster
faster than?
it got 20ms
20ms what?
https request response time in 20ms? I doubt that...
client.ws.ping is the websocket response time
not requests
hm
ws is an already established connection
are you requesting guild members of a huge guild?
yea
split the request into chunks
it starting doing that when someone invited it to big server today
how?
you should probably use the events from the websocket like guild create etc not a request to get all guild members
and the cache
ah i see
btw my advice is general concepts, I don't personally use js
but the approach applies to all libs
friday is ts and js it is mix of both
you using discord.js?
yeah
may i ask how?
sorry, I lost brain cells while i was at school
plus we don't want to read the docs/guide, nor do they make sense
every fucking time I open the mdn page for cors I'm left more confused
Having issues with influxDB and nginx on my ubuntu server - anyone able to help?
fucking true, istg cors exists in my nightmares
Tbf, i end up just allowing everything on cors during testing
Just to not have to deal with it
anyone know what equation mee6 uses for its leveling
that issue is usually caused by not having the members intent enabled
I have it that’s the thing
are you trying to fetch all members at startup?
It usually do that
do you have more than 120 guilds?
no
how many guilds?
31
does this error happen for all guilds?
I think so
do you have the intent enabled in both the bot code and the developer portal?
Yup
which djs version?
13.12.1
do this ```js
client.on("raw", data => {
if(data.t === "GUILD_MEMBERS_CHUNK") {
console.log(data.d)
}
})
then try to fetch members from a guild
and see if the members are actually being received
anyone here using flask and cors?
for some reason cors is not sending allow-headers
Access-Control-Allow-Headers: content-type
this is what it sends instead of Access-Control-Allow-Headers: *
im basically trying to allow all headers
CORS(app, supports_credentials=True, origins="*")
my cors config
idk what else to do, i tried adding allow_headers="*" from their docs, but nothing seems to work
in the preflight response i still see content-type as the only allowed header
maybe im understanding something wrong, hmmm
but the set-cookie header im setting in response im able to see it in the request but on the server axios side i dont see it in the interceptors
what are these 
Damn bro 🤣
uh
and also why ffmpeg.exe is this much
How many cmd do you have open
hey so im using flask, and flask cors
but in the response headers im not able to see set-cookie
i can see it in the request, but not in the axios interceptors
CORS(app, supports_credentials=True, origins="*")
this is my cors config
pretty much a basic app
someeone help ;-
just these two
lmao
Bruh that's a lot of code 😂
wdym

for ffmpeg it's expected
When you run commands thru cmd it can over load alot
yes
Ooh... Damn
Also try to not compile cmds cause that can over heat and overload the pc
well what should I do? there isn't any way to don't use ffmpeg... also my music bots are private (only have 1 server) so they shouldn't take this much ram! should they?
Wdym ?
When you write scripts and code
That takes up space
Whether it's ram or pc
Code once sourced and running take up memory
why tf does is have gui?
Alot depending how large and or servers are running it
even worse, why windows?
like, nothing against, but having a windows vps WITH gui will eat most of your resources
That too on top of everything
so you're getting about 60% of what u paid for
what do you mean GUI ? 
Omg gui is important to watch
visual interface
I will move to linux for next months
but still...
why this is happening 
I use vs code so
everyone has issues with cors

fr
vscode is an ide, flask is a framework
its not sending headers correctly at all, axios interceptors cant access, cookies or authorization header
hey so im using flask, and flask cors
but in the response headers im not able to see set-cookie
i can see it in the request, but not in the axios interceptors
CORS(app, supports_credentials=True, origins="*")
this is my cors config
pretty much a basic app
do u have anything in-between?
nop
like nginx or apache
localhost is an address
ik its just a basic backend server flask
and client react
with axios making the req
ah, ur testing locally?
ye
i can see the calls etc coming through
but axios interceptors cant access the cookies or authorization headers
Access-Control-Allow-Headers: content-type
Access-Control-Allow-Methods: DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT```
the response coming back from cors
i see the "set-cookie" as well
but axios interceptors are not able to see this
:
"18"
content-type
:
"text/html; charset=utf-8"```
this is all it has
I'm not well versed in flask, so idk if I can help
mmm
you need to rent a vps
because a bot is nothing more than a program that stays running indefinitely
no
u can also leave ur pc overnight, but it'll be more expensive than a vps due to energy bill
you dont "install" a vps
vps is a computer running somewhere else in the world
you buy one and u get access to it
Does anyone know what he's talking about?
there are a ton of tutorials around the net, u just need to search
probably to get the new badge
u run a bot and use a single command to get it, once every 30 days
I see
absolutely a waste of effort, but anyway
Average badge hunter
Found this gem on reddit recently
the guy who tried to fight discord and topgg doesn't know how to download releases from github apparently
LMAOO
"yes this is how you can get the badges"
Doesnt understand the basics of downloading files
Lmaoo
.addComponents(
new MessageButton()
.setCustomId("activate_list")
.setLabel('Activate')
.setStyle('SUCCESS'),
new MessageButton()
.setCustomId("deactivate_list")
.setLabel('Deactivate')
.setStyle('DANGER'),
new MessageButton()
.setCustomId("delete_list")
.setLabel('Delete')
.setStyle('DANGER')
).addComponents(
new MessageSelectMenu()
.setCustomId('select_list')
.setPlaceholder('Select action')
.addOptions([
{
label: 'Add Messages',
description: 'Add a message',
value: 'message_add',
},
{
label: 'Remove Messages',
description: 'Remove a message',
value: 'message_remove',
},
{
label: 'Change interval',
description: 'Update interval',
value: 'interval_change',
},
{
label: 'Add channel',
description: 'Add a channel',
value: 'targetchannel_add',
},
{
label: 'Remove channel',
description: 'Remove a channel',
value: 'targetchannel_remove',
}
]),
)```Does anyone know which is exceeding the maximum width?
Is it possible to add buttons and select menu to one message at all?
I think u can, but select menus take a whole row
So the solution to this problem is probably to make a second row with the select menu itself
Being thrown {"size":0,"timeout":0 when logging the response from node-fetch v2
I want to access the headers
use the built in fetch if node 17 or up otherwise use undici
"let's try axios!"

Everything else is just node module bloat in the name of "making dev work easier"
Lovely "invalid url"
well. Log the url
https://discord.com/api/webhooks/1068184401105653871/xxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxx is the webhook token
no query no params
if there are any special characters in the url, you should encode it
There aren't
Just for hahas, try passing it through the URL constructor
this is "request" btw
oh
interesting
request is a string
Now gotta fix the "request body invalid json"
even when the body is stringified, nun
ok fixed
"body" had to be "data"
TypeError: Cannot set property member of [object Object] which has only a getter
``` like I'm trying to do `message.member = <guild member>`, and it's showing this.
Any way to fix?
you're trying to change the member of a message?
yes 💀
it was working fine before, but now I've changed all my commands into class format
so it's showing this
I dont think djs has support for that, you'd probably want to create a custom message class
its certainly not the intended way of doing things though
djs can misbehave and throw weird errors doing that
umm
if your goal is to change things in this way a custom class is the way to go.
can you explain me a bit more about it, like what to do basically
I don't know what you're doing, so I cant really tell you exactly what to do.
actually I've a command which's a owner only command. basically owner can execute any command by selecting a different user
I don't want to delete it, i want to change it
// ... @interface DiscordJS.Message
readonly member: Member
it's readonly
you can't change it
why do you wanna change
tf, but I was able to change it earlier, infact in my old src, it's working fine
put it inside a variable
👀 doesn't this feature seem very abusable?
and send along with new request if that's what you meant
that returns the result of the expression regardless the assignment was successful or not
also
like woo said
make a custom handle class
that wraps around and escape sensitive data
it's successful, because the executor is changed and the command gets executed properly
the member field is returned from the api and it should be readonly
there's no reason to modify it
how can I check when will the ratelimit get removed of my bot 💀
👀 how are you getting rate limited so much?
this is the third ratelimit youve had in the past 30 days isnt it?
and the last one was a disable because your bot hit the ratelimit so often.
yeah, I'm fixing many things which may cause ratelimit, like it's a security bot and it has many recovery features, and spamming the harsh activities in server may cause it. As much I saw the logs, this ratelimit was because of mass message delete i guess
it got rate limit for 40 mins (at that time)
why can't your library handle the rate limit
Your bot is probably pretty close to getting disabled permanently by discord
wtf ¯_(ツ)_/¯
I've never seen a bot get a You are being blocked from accessing our API temporarily due to exceeding our rate limits frequently. before
it's been a feature for like a year or two
I knew it existed, just seems like theyve been getting ratelimits pretty consistently to get that warning
I NEVER got ratelimit messages lol
I don't understand how other security bot like wick & security doesn't get ratelimit
because they're controlling their own ratelimits
and maybe have gotten ratelimit raises by discord
tbh, I dont understand how you do get ratelimits.
me neither
this is probably the correct, many large bots have this Ig
that's why carl, dyno never get it
A small bot should certainly never reach the ratelimit like that
I can maybe see it hitting the channel ratelimit but definitely not the global one
until you have some haters who can try anything to takedown your bot
If you’re making a “security” bot then you should have good ratelimit handling
You should be expecting people to try to break it
I'm not sure if it is the global one.
the warning they got last time it sounds like its being flagged for hitting other ratelimits.
You are being blocked from accessing our API temporarily due to exceeding our rate limits frequently.
I literally saw a live stream in which a user created a bot, and literally he did scratch bans and it banned around 13k members within 2 mins
A good developer tries to account for all feasible sources for error
Might not be global, but this is definitely getting close to being looked into by discord
you can get globally banned for a while if you actively get ratelimited
Or permanently banned for continuously abusing the API
Disable the commands causing the ratelimits until you can solve it
hm, I'm working on it, I'm making some limits to it and large cooldown on heavy commands too
Is the python library topgg limited to discord.py or can used on forks as well?
Particularly disnake
embed.edit({embeds: stafflocked1, components: [row1, row2]})```I am trying to edit an embed that has 2 components with these values
where embed: let embed = channel.messages.fetch(interaction.message.id)
However it's throwing me an error
any suggestions?
What's the error?
TypeError: embed.edit is not a function
Because <TextChannel>.messages.fetch() returns a promise, you didn't resolve it
You're welcome
Show your code
embed.edit({embeds: stafflocked1, components: [row1, row2]})
coming from here again
What's stafflocked1 declared as?
it's an embed
const stafflocked1 = new MessageEmbed()
.setFooter({text: `🔒 | Maximum Server Security`})
.setTimestamp()
.setDescription(`**List Message Container:**\n\n${messages}`)
const row1 = new MessageActionRow()
.addComponents(
)
const row2 = new MessageActionRow().addComponents(
new MessageSelectMenu()```some reduced code so that it would just make clear what the vars are
is it because i cannot edit a message using .edit({components etc})?
should it rather be embed.embeds[0]?
The embeds option expects an array of embeds
Basically [stafflocked1]
Owh wow obv, thanks once again!
Do hyperlinks only work in embeds?
[Through here](https://discord.com/channels/${interaction.guild.id}/${staff.id}/${miauw.id})`})```This works within my embed but not really within a singular message
yes, only in embeds
or interaction replies
okkii thanks
import WebTorrent from 'webtorrent'
const client = new WebTorrent()
I get an unexpected identifier error
file:///C:/code/websites/webtorrent/node_modules/webtorrent/index.js:21
import info from './package.json' assert { type: 'json' }
^^^^^^
SyntaxError: Unexpected identifier
at ESMLoader.moduleStrategy (node:internal/modules/esm/translators:139:18)
at ESMLoader.moduleProvider (node:internal/modules/esm/loader:236:14)
[nodemon] app crashed - waiting for file changes before starting...
Changing to commonjs does not work
Any idea?
What Node.js version are you using?
Use the latest LTS release (currently v18.13.0), we enabled import assertions in the v18 releases by default, though they're still experimental
Import assertions allow module import statements to include additional information alongside the module specifier
Thx
so i have been ignoring this error thrown in typescript
import stream, { Readable } from 'stream';
import { promisify } from 'util';
const pipeline = promisify(stream.pipeline);
await pipeline(response.body!, res);
the error is coming from " response.body "
what node version?
there should already be an async pipeline from 'node:stream/promises
the experimental one
doesn't seem like i do
Hey there, anybody come up with a simple solution to transfer Data between a button and its Callback?
should i install them?
wdym?
if you're using typescript, yes install types/node as a dependency or a dev dependency
small data or big data?
https://share.reol.dev/JAKi7/ZAJIjAbo75.png
I have this button, and when i click it it needs to transfer a userID (Not from the one who clicked it)
small data: serialize it and put it inside the button's unique ID
big data: use a global map
^ and put the key in the unique ID
Hmm.. i thought about using a table inside a database
not good
it'll add unnecessary calls to the database + its latency
if u don't need it to persist through restarts, just use a map
even if u do, I'd just dump the map into a file before exiting and restore it on next start
after using the Node promise
The Problem is, when i attach it to the buttons uniqueID the callback wont fire because my loader doesnt work that way
how did you define pipeline?
new promise
? show code
Hello i want to display the number of servers on my website how i can do this?
how?
You can use one of several npm packages if you are using node.js or make an api request yourself. See the documentation
ok
@sharp geyser when we had our chat about rabbitmq, I got a few things wrong. Multiple clients can listen to the same queue and messages will persist in a queue until acknowledged. Amqp can be implemented over both udp and tcp, but rabbitmq only implements tcp and as such, most or all node clients are tcp only. RabbitMQ does not broadcast messages to all listeners of a queue unless you are using what's called a fanout exchange. By default, RabbitMQ is round-robin sending messages in a queue to listeners. There are channels in amqp, but those are per connection and tbh I have no clue what they are exactly.
Wait I repeat my question clearly i want to display the number of servers where my bot is on my website how i can do this?
After getting this info clarified, I am moving my bot to use RabbitMQ and gonna scale all of my stuff. Only fun thing will be that interactions can be sent to clusters which watch over different guilds than which guild it was sent into if there are multiple workers and per guild gateway actions will need to be routed somehow
there are many different ways you can do this
- you can put a small webserver inside your bot, that your website makes a request to using js
then the bot responds to the request with the number
- you can store the number in a database, and have the website access the same database to get the number
- you can setup a websocket communication between the bot and the website, but this is not really a good idea unless you want something specific and more advanced
- you can basically build the website inside the bot lol
thank you for the answer
const pipeline = new Promise(stream.pipeline);
how on earth did you come up with that idea
Stack overflow
thats wrong on so many levels lol
node has built in promisified streams under "stream/promises"

import { pipeline } from "node:stream/promises"
Is it possible for a server to only have bots in it? Not even users? This server just invited it, and normally my count is correct, but this thru me off.
yes, bots can create guilds if they're in less than 10 guilds
interesting...
Still need one user to invite bots
I'll research it more tomorrow. Still weird
unless theres like, someone so dedicated on the server that they're inviting a bunch of bots, then leaving the guild, then joining it again, inviting a bunch, then leaving etc
i mean the bot farm servers seems dedicated to the point ive seen a server grow 10k members (all bots) in a week
should still have someone invite them if they're growing that fast
Anyone know where I would put the invite link?
maybe it's in oauth2 -> general category, there's a field to add an authorization link at the bottom
guys, I have a bot which is connected to my FiveM server, the purpose of the bot is to fetch logs of the fiveM server, but the thing is that the traffic is too high, so my bots get rate limited frequently
any solution?
Control your Ratelimits
how fast are u even fetching it?
hey guys
does anyone know a good site where i can create a graph or table based on this relation: let m = xp / (5 * Math.pow(2, lvl-1));
I am trying to create a leveling system looking like this:
wait hold on a sec
isn't it just messages(level*2) - messages(current_level)?
I am fucking stupid
or no
could anyone help me to find a direct formula for this sequence lmao
5 * 2 ^ (level - 1)
for the site, https://www.desmos.com/calculator
I've this *.log* in my .gitignore, what does it mean by 2nd * at end?
Found it thank you soo much!
const Topgg = require("@top-gg/sdk");
const express = require("express");
const app = express();
const webhook = new Topgg.Webhook("hula!");
app.get("/", (req, res) => {
console.log(req.body); // Call your action on the request here
res.status(200).end(); // Responding is important
});
app.post(
"/dblwebhook",
webhook.listener((vote) => {
console.log(vote);
}
};```would anyone know by any chance why my voting system doesn't work?
stuff.log
stuff.loga
stuff.logstuff
stuff.logsomething
* is a wilcard for "anything"
so <anything>.log<anything>
Okay, thanks
But why that doesnt work by .env.* for these files,
.env.local
.env.development.local
.env.test.local
.env.production.local
the files need to end with .env
so
local.env
development.local.env
test.local.env
production.local.env
I've put the * at end here .env.*, so the matching files should starts with .env. NO?
that should work yes
https://www.digitalocean.com/community/tools/glob the site btw
does the togg api accept server votes?
Like an event for it
because my event doesn't trigger
109 lines of code 🧌
Granted that doesn’t matter because you’re only printing
Unless ofc you did a little bit of trolling and made your own printf function above it
which is why the first two lines are commented out
it turns out that i can't even run the goddamn compiled executable

yes
moving my bot to microservices
this shit difficult
I am very proud of what I did here tho
https://github.com/DasWolke/CloudGate
nice
https://www.geogebra.org/graphing?lang=en This is the best one I know
Desmos on top
desmos is in another level entirely
Hey
hi
Anyone else's bot suddenly appearing in servers like this?
bot farms
Figured
I would probably have to contact discord to get it removed right? because atm I have no idea how to remove it the system I have to force my bot to leave servers wont work on this one server for some reason
yeah I got that one
Wouldnt happen to have the server id would ya?
1068135541360578590
Thanks 🤝
👍
With java I'd start off with a few basic tutorial sites for basic projects by following along with them and trying to add in extra features with your own ideas
Then as you get more comfortable, try to make your own basic projects without a tutorial (looking up how to do something specific within the project is perfectly fine, but experimenting around with what you can do is fun and will teach you more)

yes
it got terminated again
for java I'd recommend baeldung courses
2nd one in the last day
they cover everything from frontend, backend, databases, RESTful apps, etc
Wowza
i call them api fuckery servers
Is that a bot just for blacklisting servers? XD seems useful
its for a few things
it blacklists users (mostly raid users) and it has a server blacklist
for phishing servers
anyways that server, they do it to ratelimit the bot and the channel, a lot of the bots they add do not handle errors and they crash 
Thats funny they actually screwed my bot up real bad today and that's the only reason why I noticed
I'd recommend Hyperskill (by JetBrains), but they'd paid now; though you could try a trial.
My bot went from like 2 ping to 24,000 ping and I was like holdup lol
jetbrains is doing courses now?
hyperskill / jetbrains academy has been a thing for years
but it was mostly in beta for a while
and free then
but it's paid now
and you know how jetbrains is with pricing
don't bother clicking on the pricing section
is it included in toolbox license?
yeah true
I hope so
yeah it's not
yep terminated
someone should start making lists on bizarre discord servers, the same way they do with bizarre subreddits
tos?
servers that break the discord tos?
yeah
time of sleep 
lmao
but they get categorised
whats qr?
QR scam servers
ah
those fake 18+ servers with fake wick
like fake qr codes and stuff
yeah
skid I can guess
skid is an old tag
💀 Those are still around?
that got migrated into tos
slowing down but yeah
like 3 added today
theres a bunch of contributors for this list, we generally catch them pretty quck
we love marengo
he handles most of the qr server reports
Thats an awesome project I would 100% contribute if I could

But yea this is crazy I've never heard of servers made just to crash bots 💀
just open a ticket and post that
i have before
LMAO
a bunch of us have tried to get him to join the cybersecurity server we're in
we have a bunch of dstaff there
anyways he has yet to reply
they get clyde closed
Seems useful
not enough reports icl
fuck clyde, all my homies hate autoresponse dude
i have like 10 pages of reports
lmao
i hate discord support sometimes
one of the bots i made for combat warriors got blocked by discord antispam
typical discord L
we held mod apps through the bot, the user clicked a button to get a dm to start an application, yet discord claimed 500 dms were sent without the user's consent?
the worse part? the name of the support worker that replied is the name of our mod bot 😭
taunting me fr
full message, they are fully ignoring all contact now
💀 Discord took the bot as it's own
caching
Because when the bot restarts it's no longer cached
do message ids still get passed?
What you can do is store the IDs of starboard messages, and on bot ready() fetch all the messages by ID and they'll be cached.
The hard part is, if you cache literally every single message, that will probably cause some latency of the bot booting especially when it becomes larger.
djs guide has a guide on this topic
Maybe I am a little incorrect depending on what this guide says. Never knew it existed 
Ah partials. That actually pretty nice ngl. Forgot those existed.
what djs version btw?
It was the partial thing
Partials: [Partials.Message, Partials.Reaction] is what it should have been
yeah thats what i thought
// When a reaction is received, check if the structure is partial
if (reaction.partial) {
// If the message this reaction belongs to was removed, the fetching might result in an API error which should be handled
try {
await reaction.fetch();
} catch (error) {
console.error('Something went wrong when fetching the message:', error);
// Return as `reaction.message.author` may be undefined/null
return;
}
}
since v14 they dont accept strings anymore
don't forget about reaction.partial
Converting from old versions and tutorials be old
ye
Use the official guide instead of random tutorials
coming soon in 2023: djs v50
I just really spent the last 2 hours trying to debug why an http route wasn't working only to figure out I forgot a / at the beginning
I shouldn't touch front end stuff with a 10 foot pole
On the plus side, I got interactions moved from being sent over the gateway to being sent over a webhook and made a decision of having my website store all of the queues and lavalink node connections in memory and be the authority versus each client. Now the clients are almost stateless and can be scaled endlessly
downside is that now my website has slash command code
xD
which reminds me, i need to change my interaction server a bit
offer the option to respond via rest instead of via webhook response, because when you respond the webhook response directly, there is no feedback from discord
so no way to confirm a defer went through for example
Well with webhooks, you either loopback the results to the webserver to 200 to Discord or defer. You can't 202 accepted
and cant use discord rest actions either
pretty sure you can, i've done it before
I just tried
an interaction received via webhook can be responded to via another rest request
instead of responding to the webhook
I have to defer all of my stuff and then edit the original response
If you can find a working system, do tell
as for now, bask in the jank: https://github.com/AmandaDiscord/Amanda
i'll need to try it again but i remember being able to do it to send files without defering
every time I tried, I just got unknown interaction
btw discord does unofficially accept file upload via webhook response, but they have a file size limit of 150kb for some reason
better not be like encoding your response in an image format
lmao
also, yes you can ignore the webhook and send the response via rest
i need to retest it to confirm, but im pretty sure all you need to do is delay the webhook response until you make the rest call
@wheat mesa nvm i just realised that i did test.exe instead of .\test.exe

powershell why
what would cause .toLocaleString() not to work?
wym
not formatting the number with commas
ah nevermind
found my issue
theory
they were forced to implement it for some client
but did a horrible job and never wanted to touch it again
How would I get the value of the dropdown..?
<form method="get" enctype="application/x-www-form-urlencoded" action="/html/codes/html_form_handler.cfm">
<legend><b>Encrypt in:</b></legend>
<span class="custom-dropdown small">
<select id="options" name="options">
<option value="atvash">Atbash Cipher</option>
<option value="vigenere">Vigenère Cipher</option>
<option value="railfence">Rail Fence Cipher</option>
</select>
</span>
<br>
<input id="start" type="button" value="Cipher" class="startButton" />
</form>``` I currently have : ```js
let e = document.getElementById("options");
let cipher = e.target.value;
When I console.log the cipher it just says it can't read its value, but when I do just e for cipher and not e.target.value it returns the whole form
never mind..
I am an idiot
ignore this
Rubberducking is surprisingly effective
How would i see if a reaction author is a bot? user.bot works
Multiple users can react with the same emoji, so there's <MessageReaction>.users which is a user manager to get the user you want
And after you have the user you want, you can check if they're a bot with the <User>.bot property
How would i do reaction.count but just for one type of emoji?
That property exists on a single reaction, and reactions are just an emoji, so you're getting the count for that specific emoji
Ok whoops
client.user will work for u
No that's not related to what they were asking about.
How can we get unavailability guilds and resolve them
What exactly do you mean by that?
how do yall call client in another file without creating a circular dependency?
managed to do this by creating a new file client.js in the root directory and just requiring that in index.js and exampleCommand.js. Is there any better other way to do this?
//client.js
const { Client, GatewayIntentBits } = require("discord.js");
const client = new Client({
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent],
});
module.exports = client;
Where do you need this client?
Because when it comes to interactions, you can just use interaction.client
Same with message.client
Generally speaking it’s probably best to pass your client into functions as a parameter instead of having a global client object
How can i make a button with when 2 users are reportet and i click on the first one then this ban the first user?
sounds like a bad idea, anyone can just make two accounts and ban anyone
but, youll probably want a database for that if you're using buttons.
no the message come to me
put the user ids in the button's uniqueID
thanks
I thought if it did the stereo to mono conversion correctly, but I couldn't come to a conclusion. First buffer stereo, second buffer mono
does that converted audio even play if you save it as a file?
that doesnt look like it would work, audio frames are much more complex than simply skipping every 2 bytes
this might be useful to you
uh peeps, i was wondering if anyone experienced wouldl ike to start a project with me together
i have some ideas
tim?
experienced guys ofc
@quartz kindle @lyric mountain you guys interested?
This isn't the place to look for co-developers
You can start on your own and if you have a problem, ask the guys for advice
^^
Also I've got sort of a stupid question, but how would I dynamically instantiate child classes of an abstract class? I'm trying to have an abstract InteractionCommand class that all slash commands will extend, but I don't know if I'm approaching this right (typescript)
export abstract class InteractionCommand {
name: string;
guildOnly: boolean;
permissionsClient: Array<PermissionFlags>;
permissionsUser: Array<PermissionFlags>;
abstract run(client: Client, interaction: Interaction): Promise<void> | void;
}
``` something similar to this
Oh wait
I can just make the default export an instance of said class
(Maybe? gonna try it)
Ok got it to work
Hi, im trying to get all the information top.gg and bot testing staff need to test my bot. what information would be helpful for a tester that I can prepare in advance to make the process easier?
It probably depends on how complex your bot is. Put yourself in the place of an ordinary user who may not understand how your bot works at all and try to explain it to him as best as possible
If anything you know how your bot works better than anyone else, try to test all of your edge cases and anything that you're concerned about
And then also try everything with the dumbest and most unexpected usages ever, never assume the end user understands how everything works
Thank you so much! I see your points there nynu and waffle!
if the tester comes across an issue, would they reach out to me to learn more? the bot is complex and I am worried that it might get declined for something that I wasn't able to share in advance
would submitting a doc like this be overkill? sorry for all the questions. this is the first bot im submitting for approval in a very long time.
You'll see a decline reason for your bot if it gets denied, and you also get the chance to contact the reviewer if you feel your decline reason wasn't justified
I suggest looking through #mod-logs for common decline reasons to see if your bot matches any of those
Thank you so much Waffle, i'll take a look at the mod-logs! thank you for answering my questions!
thank you to you as well NyNu!
☁️ ERROR AL CONECTAR A LA BASE DE DATOS DE MONGODB
Error: querySrv ENOTFOUND _mongodb._tcp.cluster0.z2bwm.mongodb.net
at QueryReqWrap.onresolve [as oncomplete] (node:internal/dns/callback_resolver:47:19) {
errno: undefined,
code: 'ENOTFOUND',
syscall: 'querySrv',
hostname: '_mongodb._tcp.cluster0.z2bwm.mongodb.net'
}
C:\Users\angel\Desktop\EloBot\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:151
const err = new MongooseError(message);
^
MongooseError: Operation sorteos.findOne() buffering timed out after 10000ms
at Timeout.<anonymous> (C:\Users\angel\Desktop\EloBot\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:151:23)
at listOnTimeout (node:internal/timers:564:17)
at process.processTimers (node:internal/timers:507:7)
can you help me on that please
@lone spindle
Does anyone know how to clean an update in Replit?
i gave npm update
agr keeps giving error
What's the error?
I accidentally ran npm update, now I don't know how to fix it
Anyone know what the methods are to upload slash commands in djs, I know the guide says to do that rest bullshit but I remember @boreal iron saying there was built in methods for handling that stuff
As much as I want to compare whether or not my local commands match to the uploaded commands, I'd prefer to use built in stuff if it already exists
You can access the client application via the <Client>.application property
I see
Does this handle pretty much everything for me or do I still have to compare the commands to see if they match my local version when I "upload" a command?
It already handles everything for you
Oh sweet
You can post all of your slash-commands at once with the set() method of that application command manager
Discord already does that for you
I know but I didn't want to hit ratelimits for it, since you can only make 200 PUT requests to that endpoint per day is my point
(iirc)
Thanks, exactly what I was looking for!
I thought that only counted to new commands
From my understanding I thought it counted everything
I could be wrong though I suppose
Either way this is much easier than using the rest dogshit
Yeah, I really don't see why the discord.js maintainers are recommending to use their REST library for that instead of just the built-in methods
Makes absolutely no sense
maybe it's just outdated?
They've had it in the guide for a while, but I'm pretty sure the built in methods existed back when the guide was written for that
The built-in methods existed before that REST library
Yeah
hmm
Seems so extra to do it the way they "recommend"
ok so thanks for that method @earnest phoenix, saved me probably 50 some odd lines of confusing and convoluted logic that didn't work properly
You're welcome
Now I've got this, super clean and simple ```ts
async checkAndUploadSlashCommands() {
if (!this.token) {
return;
}
const guildCommands = new Map<string, Array<SlashCommandBuilder>>();
const globalCommands = [];
for (const [name, command] of this.slashCommands) {
if (command.guildIds?.length > 0) {
for (const guildId of command.guildIds) {
const commands = guildCommands.get(guildId);
commands.push(command.data);
guildCommands.set(guildId, commands);
}
} else {
globalCommands.push(command.data);
}
}
await this.application.commands.set(globalCommands);
for (const [guildId, guildCommandArray] of guildCommands) {
await this.application.commands.set(guildCommandArray, guildId);
}
}
Probably could be better but works for me afaik
Nice it works perfectly!
question for the front-end devs that make web interfaces that actually look good
where
the fuck
do i start
because it unironically pisses me off that I am trying
but fucking cant cuz am a stupid backend-dev
I lowkey gave up on frontend for the time being
I'd prefer to stay behind the scenes because frontend is genuinely hard for me 😭
That's pretty good, don't see anything to optimize
Literally ANYTHING I wanna try to do requires fucking frontend which kills the motivation for me
felt that
honestly what I would do is just experiment around with some stuff like react and a lib to go with it like mantine, it makes the process a lot easier
it's not perfect or anything but it teaches you a lot
with component libs for react you can make some pretty decent looking stuff without having to fuck around with CSS for 27 years
Even though it's preference, you may want to omit the scopes ({}) for single operations, for example:
if (...) {
return;
}
To
if (...) return;
YES ITS THE CSS
react is just object oriented HTML essentially
Yeah I just prefer the former
Java style baked into my brain
second one rip readability
especially if I end up needing to modify something in that scope, i don't have to fuck around with adding brackets and stuff
The second one looks a lot more readable to most people
Though some people use to stay consistent with the styling of multiple operations, which is understandable
it is if thats the only thing between like:
int something = somecode.method.code.return();
if (something) return;
...
not if
if (something) return;
if (something) return;
if (something) return;
if (something) return;
if (something) return;
if (something) return;
if (something) return;
if (something) return;
if (something) return;
I have a problem with people not using brackets, a lot of people assume that if you just keep the indentation the same then the scope continues on like it's python or something
it hurts me
I've just had enough horror stories from reading my classmates' code and seeing the brackets
To be honest changing that to use scope blocks doesn't make it any more readable
So I keep mine clean and consistent
That's understandable
still don't know how I'm gonna handle subcommands yet but that's a bridge for me to cross later
{ bracket gang }
@rustic nova here's sayuri's site, they're fucking insane: https://endfield.sayuriu.tech/
.
You mean like how to know what sub-command is used and to respond to it?
no brackets kills readability imo, and sucks if you need another statement since you need to rewrite the whole expression
Nah for loading it, I gotta do some stuff with my handler to handle subdirectories and I also need to figure out how to route the request to the right execute function
as of right now my slash command loader is pretty scuffed
try {
const slashCommands = fs
.readdirSync(path.resolve(__dirname, '../commands/slash'), { withFileTypes: true })
.filter(file => ['js', 'ts'].some(e => file.name.endsWith(e)) && !file.name.endsWith('.d.ts'));
for (const file of slashCommands) {
const ret: CommandImport = (await import(
`file:///${path.resolve(__dirname, `../commands/slash/${file.name}`)}`
)).default;
client.slashCommands.set(ret.default.data.name, ret.default);
}
} catch (e) {
console.log(`Error occurred whilst loading commands: ${e}`);
}
For the dynamic import (import()) path you can use the fileURLToPath() method from the built-in node:url module
Oops I meant pathToFileURL(), I misremembered 
Got everything working now, I have an infrastructure for creating a bot C:
(Ignore the name, I haven't decided on one and just needed something to differentiate between my other bot)
I'm pretty happy with the way commands look at the moment as well: ```ts
import { CommandInteraction, SlashCommandBuilder } from 'discord.js';
import { WaffleClient } from '../../types/WaffleClient';
import { BaseCommand } from '../BaseCommand';
class TestCommand extends BaseCommand {
constructor() {
super({
data: new SlashCommandBuilder().setName('test').setDescription('testing new method'),
permissionsClient: [],
permissionsUser: [],
});
}
async run(client: WaffleClient, interaction: CommandInteraction) {
await interaction.reply('Test works!');
}
}
export default new TestCommand();
The builder is undesirable but makes my life easier
Very nice
Now I have a very nice level of control and customizability
hi
Just spent like 30 minutes implementing a permissions system just to realize that discord has slash commands permissions built in already
Damn
they didnt before, now they have yeah
I suppose it’s not a complete waste since I can keep the required bot permissions system and just get rid of the required user permissions
always good to keep a non-discord side backup
I dont trust the permissions on discord's end catching right
The permissions on discord's end allows server owners to configure them on their own
So if they configure it different than mine via discord then it'll be a mess
yeah, but tbf I dont trust em lmao
Thankfully I don't have to worry too much because my bot isn't going to have any moderation or anything like that in it
Too many moderation bots out here already
lmaoo yeah
I don't trust
the permissions ondiscord~~'s end catching up~~
FTFY
ok so I'm having some really weird behavior
I have a string that I created by joining an array of strings together with \n, and when I try to send that in a codeblock in a message I'm getting only the first value
Oh wait
It's because the backticks need a newline
nvm then
Any reason why this regex isn't working? I'm not quite sure what the issue is: ```ts
input.replace('/([A-Z])/g', ' $1').trim();
// Seperates "MyString" into "My String"
Oh I'm a moron
I put quotes
lmfao
Rubberducking saves the day again
I think I've done that like 10 times today tbh
sometimes I miss java's strongly typed catch blocks
Eh, u can't have typed exceptions in js?
can't even have them in ts
I can set the type but I can't have multiple catch blocks for different types
hence why I have to use instanceof
now I think my next step is figuring out how to implement subcommand handling here
well this looks like it's gonna suck
think it should be simple
given a subcommand is just a kind of command
though I did it a few days ago and it was kind of cancerous at first
my problem is that I'm still using the slash command builders for data
which is just a bad idea
and it was a bandaid solution at best
now I have to think of a way to post the data to discord and also differentiate between subcommands and regular commands on the local end
Ideally everything would inherit from my InteractionCommand class
But I just can't think of a way to do that feasibly
just create some index (object/map) with the stuff you need?
Maybe I could create some other class that keeps instances of InteractionCommands as "options"? No idea how I would represent that to discord's end though
I'm gonna take a quick food break and then I'll come back to think about it
Just check the command signature
And compare with ur commands
You'd need to make a signature parser tho, so you have something to compare against
wdym signature
/cmd some args
This is a command signature
So say, if u have /cmd <int> <string> you can match with your slash input
Alternatively, u can compare argument names
please tell me you've never written something like that before
NO
though I really don't see how something like this isn't possible:
const commands = {
avatar: {
data: ..., // builder stuff
instance: ..., // actual command class?
options: {
guild: { // subcommand maybe?
instance: ...,
...
}
}
}
}
I do something akin to this and just transform the object into different forms I want
Yeah I just have to think about how to specifically integrate something like that into my design
Okay I think I'm going to replace the builder type with my own type so it's easier to work with
since this is super simple
(And I'm not going to end up using half of it anyways)
That way instead of the stupid builders I can manually manipulate the data
agh nvm I don't think that even matters
If slash commands have subcommands, can they also be a standalone command?
Like if you have /a b, can there also be /a only?




