#development
1 messages · Page 183 of 1
that's just not how the lib is designed
djs = abstraction abstraction abstraction
Yes I know
I wish it was designed that way though
You can still be beginner friendly without all those builders that abstract away from the point of the library
Alright I think I got it
client.on("interactionCreate", async (interaction) => {
if (interaction.isChatInputCommand() && interaction.commandName === "ping") {
const embed = new EmbedBuilder()
.addtitle("Connect to our Server")
.addDescription("Test description");
};
});
is this correct?
no
do you not have intellisense? what are you working in 🤔
setTitle
the right question to ask
TypeError: (intermediate value).settitle is not a function
replit
now the command doesn't respond but no errors? 
I’d highly recommend learning some javascript before trying to make a bot. It’s a lot easier
looks like you may have gotten rid of the interaction.reply
interaction.reply({ embeds: [embed] });
this works right
I mean
I was fine at making bots 2 years ago
3*
in 2021
which is why I have the developer role,
but I forgot all of it and now there are so many changes
I’m not talking about learning the library
I’m talking about learning the language
That error told you exactly what was wrong but you (I’m assuming since you pasted it here) didn’t know what it meant
It’s important to understand the language before trying to make complex applications such as a discord bot
{
name: "ban",
description: "Bans a user from the server",
DefaultMemberPermission: false,
options: [
{
name: "User you wish to ban",
description: "The user you wish to ban",
type: ApplicationCommandOptionType.Mentionable,
required: true,
},
{
name: "Reason for ban",
description: "The reason for the ban",
type: ApplicationCommandOptionType.String,
required: true,
},
]
},
Error: DiscordAPIError[50035]: Invalid Form Body
1.options[0].name[STRING_TYPE_REGEX]: String value did not match validation regex.
1.options[0].name[APPLICATION_COMMAND_INVALID_NAME]: Command name is invalid
1.options[1].name[STRING_TYPE_REGEX]: String value did not match validation regex.
1.options[1].name[APPLICATION_COMMAND_INVALID_NAME]: Command name is invalid
at handleErrors (/home/runner/atlasbackend/node_modules/@discordjs/rest/dist/index.js:722:13)
how does this not work? I don't understand
You can't use capital letters and spaces in command name if i remember correctly
For options too
Removed them it has a different error now
DiscordAPIError[50035]: Invalid Form Body
1.options[0].name[APPLICATION_COMMAND_INVALID_NAME]: Command name is invalid
1.options[1].name[APPLICATION_COMMAND_INVALID_NAME]: Command name is invalid
you cant have uppercase letters
ty
client.on("interactionCreate", async (interaction) => {
if (interaction.isChatInputCommand() && interaction.commandName === "ban") {
const { options, member } = interaction;
const user = options.getUser("target-user");
const ID = user.id;
const banUser = client.users.cache.get(ID);
if (!member.permissions.has(Discord.PermissionFlagsBits.BanMembers)) {
return await interaction.reply({
content: "You must have ban permissions to ban users.",
ephemeral: true,
});
}
if (member.id === ID) {
return await interaction.reply({
content: "You cannot ban yourself!",
ephemeral: true,
});
}
let reason = interaction.options.getString("reason");
if (!reason) reason = "No reason provided";
const dmEmbed = new Discord.MessageEmbed()
.setColor("Blue")
.setDescription(`You have been banned from the Atlas SMP | ${reason}`);
const banEmbed = new Discord.MessageEmbed()
.setColor("Blue")
.setDescription(`${banUser.tag} has been banned | ${reason}`);
await interaction.guild.bans.create(banUser.id, { reason }).catch((err) => {
return interaction.reply({
content: "I cannot ban this member",
ephemeral: true,
});
});
await banUser.send({ embeds: [dmEmbed] }).catch((err) => {
return;
});
await interaction.reply({ embeds: [banEmbed] });
}
});
Why does this code throw error:
TypeError: Cannot read properties of null (reading 'id')
at Client.<anonymous> (/home/runner/atlasbackend/index.js:47:21)
TypeError: Cannot read properties of null (reading 'id')
Means you're using .id on a null variable.
Just glancing at your code, user.id; user might be null.
banUser.id; banUser might be null.
Ok I fixed that issue, and here is the updated code:
const express = require("express");
const app = express();
const { Client, Intents, Collection, MessageEmbed } = require("discord.js");
const { SlashCommandBuilder } = require('@discordjs/builders');
const {
REST,
Routes,
ApplicationCommandOptionType,
PermissionFlagsBits,
} = require("discord.js");
module.exports = {
data: new SlashCommandBuilder()
.setName("Ban")
.setDescription("Bans a user from Atlas SMP!")
.addUserOption(option => option.setName('user').setDescription('The user you wish to ban').setRequired(true))
.addStringOption(option => option.setName('reason').setDescription('The reason for the ban').setRequired(true)),
async execute(interaction, client){
const user = options.getUser("target-user");
const ID = user.id;
const banUser = client.users.cache.get(ID);
if (!member.permissions.has(Discord.PermissionFlagsBits.BanMembers)) {
return await interaction.reply({
content: "You must have ban permissions to ban users.",
ephemeral: true,
});
}
if (member.id === ID) {
return await interaction.reply({
content: "You cannot ban yourself!",
ephemeral: true,
});
}
let reason = interaction.options.getString("reason");
if (!reason) reason = "No reason provided";
const dmEmbed = new Discord.MessageEmbed()
.setColor("Blue")
.setDescription(`You have been banned from the Atlas SMP | ${reason}`);
const banEmbed = new Discord.MessageEmbed()
.setColor("Blue")
.setDescription(`${banUser.tag} has been banned | ${reason}`);
await interaction.guild.bans.create(banUser.id, { reason }).catch((err) => {
return interaction.reply({
content: "I cannot ban this member",
ephemeral: true,
});
});
await banUser.send({ embeds: [dmEmbed] }).catch((err) => {
return;
});
await interaction.reply({ embeds: [banEmbed] });
}
}
throws this error:
/home/runner/atlasbackend/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:46
throw this.error;
^
ExpectedConstraintError: Invalid string format
Shapeshift is input validation.
Its probably the name of your ban command, I think you just worked on this issue in another error you had above.
Why .setName("Ban")? 
Wdym?
It should be .setName("ban")
Are you sure you registered it correctly?
That's the only code I have for my ban command
it's in a ban.js file
Then you need to register it now
Should I just do that in my commands.js?
It depends on what it is. This is usually done in the main bot file (bot.js/index.js) because it is only launched once
You realistically shouldn't register it every time your bot launches.
IIRC, you can register it once and never register it again unless its edited.
If your bots ever in a reboot loop it & it registers all commands every time its easy to get a rate limit.
But that can be an issue for another day.
I registered it here?
Didn't I register it in the code I put above
in the ban.js
You're creating the command locally, but not sending any information to discord.
Nope, what is in this file needs to be registered using most likely rest.put() as you did with the ping command earlier
Can I register it in the same file?
How someone knows what is cooldown for Canvas api's rate limit?
This won't work. This file must be "fired" in some way for anything to work in it
How would I do that?
Is there some documentation?
Read that
I read it and I don't understand how it applies to my case
I read it and I don't understand it
don't set the content type
same error
what's ur current code?
oh
i changed type to image
and it worked
but how do i make it actually embed
would i need to send it as an embed or is there another way to have it display the img
Make sure the image isn’t breaking discord’s restrictions
An image can only be a certain width and height
Are you sure?
yes
this is the image i used
I’ve seen people say the same thing and it was actually the size of the image
if it helps its being uploaded via a slash cmd and its an ephemeral img
Doesn’t really matter here
this
So long as it’s not too big or the file isn’t too large it will embed most of the time. Also yea what flaze said
what obj?
attachment object
that won't do
u need the image as a blob/buffer in order to upload it
something like formData.append("files[0]", await (await fetch(img.url)).blob(), "image.png");
btw if i wanted to edit that same msg, this should work right:
(message is the webhook msg obj)
it doesnt seem to work and idk why
what doesn't work
the editing of the msg
it doesnt edit the message
the response.json just prints object Object
yea u JSON.stringify() it
turns out webhook id is returning false
sigh
the editing changes it into that
I'm not 100% on this, but editing images attachments isnt possible on webhooks right?
console.log uses util.inspect on Objects. Either stringify it with JSON.stringify (not String or toString) or util.inspect
yeah i stringified it
oh well
actually
i fixed it by simply not editing the image
since i dont need to
does anyone know the rate limit for fetching members in a role? i want to fetch the members in 12 roles
actually i could probably fetch all the guild members and then map for each role
If you perform a request, it tells you the bucket info. rate limits should not be hard coded
What’s wrong with topgg?
I’ve been receiving lot of complaints of people not being able to vote
Cause the site keeps crashing or just says something went wrong
It’s been like this for the past week entirely
This is nothing new, top.gg has such an episode on average every few days
Apparently the website is as stable as it has ever been

ok so my bot used to work a few months ago, i haven't changed a thing in the code so i tried to revive and use it now it refused to work
any ideas why?
i get these in the console outputs
2024-02-12 10:04:37 INFO discord.client logging in using static token
2024-02-12 10:04:38 INFO discord.gateway Shard ID None has connected to Gateway (Session ID: 34fe665d4ebee525888f9a4cc97a1607).
but yet it doesn't interact whit any command i use in the server
i checked the priviliged intents and all were toggled on like they always were, so idk at this point i'm lost, and i think it can only be a new discord update that i'm not updated to causing this, so help me out here?
It would help if you sent the code for your bot
import discord
import os
import csv
intents = discord.Intents.default()
#intents.typing = False
client = discord.Client(intents=intents)
@client.event
async def on_ready():
print('the {0.user} is ready'.format(client))
@client.event
async def on_message(message):
if message.content.startswith('.'):
with open('chat.csv', 'r') as csv_file:
csv_reader = csv.reader(csv_file)
for line in csv_reader:
if message.content.startswith(line[0]):
await message.channel.send(line[1])
msg = message.content
list = ["*", "-", "/", "+"]
if message.author == client.user:
return
if message.content.startswith('pp'):
await message.channel.send('Hello!')
if any(x in msg for x in list):
def a_plus(a, b):
return a + b
def a_minus(a, b):
return a - b
def a_times(a, b):
return a * b
def a_division(a, b):
return a / b
for i in msg:
if i in list:
c = i
a, b = msg.split(c)
a, b = int(a), int(b)
if c:
if c == "+":
await message.channel.send(a_plus(a, b))
elif c == "-":
await message.channel.send(a_minus(a, b))
elif c == "*":
await message.channel.send(a_times(a, b))
elif c == "/":
await message.channel.send(a_division(a, b))
else:
await message.channel.send("bye")
client.run(os.environ['TOKEN'])
#it can't get any simpler it's just a calculator bot that with a csv file for chatting
damn
you might need to explicitly add message content intent
i don't think it's included inside the default intents
keep ur ego down 

if i open visual studio code, with my bot code and everything and i keep that running on like a non-used computer, does it go forever until i turn it off?
it would go until vscode is closed
but why would you need vscode just to run the bot?
you can run it from powershell or command prompt
how
yeah but its just a bot for my server
Is there a way for bots to verify members to bypass server filters, like normal human admins can do by right clicking on a member and clicking verify? For example, waiting 10 minutes in a server when verification is HIGH.
roles could bypass?
thats why the role <@&432583476659879936> exists here
but it doesnt anymore?
i mean why would you guys make a role for it
when you can just right click
and verify?
idk
because that feature is relatively new
so the people who specially verified, still have that role
<@&265125253443878912>
<@&585528734904352769>
application_id[NUMBER_TYPE_COERCE]: Value "YOUR CLIENT ID" is not snowflake.
what does this error mean
nvm fixed it
Am i going crazy or why can it not find this entry
because string != number
they're both strings and I'm using == so it shouldn't matter anyways
and I'm using == so it shouldn't matter anyways
for one never ever use double equals, it's a recipe for hard-to-find bugs, and using it for certain things like discord ids wouldn't work anyway
because the string will be cast to int, which will truncate the value
I believe the issue might be that you're using this inside an arrow function
try storing the lookup id in a constant
nah i've just found it, console.log(getData) wasn't where it was in that screenshot, i had moved it just so i could show what i was logging when i sent here, but when i ran it, it was an empty array 🤦♂️
In my opinion, even if it is a bot for only one server, it is still worth buying normal hosting. Even 512MB of RAM for a dollar or two a month is not that much, but the bot will work 24/7, especially if it is a bot that is supposed to deal with user verification, role assignment and such general server matters
?
even if it was a ping bot it'd be worth tbh
linux knowledge is never wasted
try [...datathinghere] nmaybe
always try spread operator when objects arent object-ing
for some reason when i try to update a field it just completely removes it
im using mongo-http
i tried w/out update and just $set, that didnt work either (just completely removed the array from the doc)
i already fixed it, its all good
how do i make it so they have to vote before using a command?
I don’t think you need the update part
On mobile so hard to show
Then remove the “ around $set
same problem
still deletes the array entirely
hm
idk if this works with that lib but
await db.collection('points').updateOne({ _id: "points" }, { $push: { "Approved Points": user } }, { upsert: true });```
thats how i'd do it personally
very weird
its also not the db operation failing.. it says its successful and modified 1 doc
nvm, it was a bracket issue
Is that a lib for mongo?
yeah
im using cf workers so im using a http lib of mongo
TopGGAPIError: 504 Gateway Timeout
504 means server fucked
no eta
There should be docs about it on their api docs
orite
cant find it
what language are you using?
anyone knows a good host for expressjs?
vps or website hosting
any free ones?
no
k thx
js
thank you
if i fetch guild members (which returns guild member objs and their role ids), can i filter the users with a specific role name or would i have to use id
members have role ids, role objects have role names
so to filter by name, you need to have the role object in the guild, so you can check its name with the id from the member
most libs will already do that for you as long as the roles are cached
meh i think id is just better
im using http so it would be a manual req
and theres like 10k+ members
afaik there is no way to filter members by roles without fetching all members, which is a pain in the arse
yeah im just fetching members then looping through them to see if they have a role
it's so dumb since there's guilds/:id/roles/:id/member-ids but they're locked to users only
pain au cul
hi tim, how's it going
Hello I want to create new Private Bot and give activity roles
for example if someone sent 500 messages in last 7 days I want to give them an specific role
Just need a little help for the structure can someone explain what is the best way to do it? 
The idea I have is this!
For each user set an array and a number called DailyMessagesCount in DB
And also create a DJS Collection called users and assign it to client like client.users
and count their messages in each hour like client.users++ for each message by them in messageCreate event and update DailyMessagesCount for each user in hour and then after that in the end of the day in 00:00 I will push DailyMessagesCount to that array in the DB and also I count the sum of the elements in the array and if the element is more than 500 I will assign them as Active Member and give them that role also after that if the elements of the array reach 7 I remove the first one and add new one so this way it will only count messages during last 7 days
how would i first defer a response, and then update it after the code completes? rn it just returns a response at the end
i tried this but it said unknown interaction
(the id and token are correct)
no im just using cf workers haha
yep its very cool but yet so tedious at the same time with all of these manual reqs
Yeah, for sure.
I have webhooks being sent from a cf worker, loved making it. PITA to maintain
unsure why this is erroring tho -- its not longer than 3 seconds
Its message.id right?
message.data.id would be the id of the application command
is that not the id ur supposed to provide
i couldve sworn i saw interaction id
lol that fixed it, thanks
Yeah, interaction id.
not the interaction.data.id
if you click on {interaction.id}
the first field is that id.
but is it possible to make it ephemeral
I haven't used a slash command bot in months.
you need to set it as ephemeral in the defer message right?
oh its just flags
so when i defer
should i create followup msg, or edit original response
it should be a follow up iirc.
alr ty
it seems to be stuck in thinking
this works
this doesnt
the return is in the else if (message.type ...
this is what response1 is
api/v10**//**websockets/
does // not cause issues here?
status code/text?
Just log (a.status, a.statusText)
It might help to wrap fetch in a function which logs every single fetch status and status text for every request. At least for development.
logs still empty
👀 is it not even reaching fetch?
might be that
altho i dont see why it would
let me try putting it inside the cmd block instead of the interaction
still nothing
its not even recognizing the cmd
let me try moving the defer into the cmd block
ok so i think the defer is somehow cancelling the interaction
bc after the defer, nothing prints
nothing works
and cloudfare shows up as canceled
👀 I'm not sure how to help with that.
Are you possibly running out of cpu time?
if you're on the free teir you get 10ms of cpu time before it cancels.
it also has 15 seconds of real time per request right?
You can defer, as long as you follow up within those 15 seconds(and dont run out of cpu time)
Why are you defering if you instantly respond?
fair
ah, thatll probably take longer than 15 seconds right?
You can store the relevant info in KV
You'll probably want to use an actual server for handling that specific command tbh.
even if its defered by a cf worker, then handled on server.
oof i wanted 2 do this for free
no other way to do this?
might just go manual way and keep the users stored in a database
and update it as we go along
wait
cpu time is 30 seconds
nvm looking at diff plan
i think thats $5/month for 30s
30 million CPU milliseconds included per month
+$0.02 per additional million CPU millisecondsMax of 30 seconds of CPU time per invocation
Max of 15 minutes of CPU time per Cron Trigger or Queue Consumer invocation
yeah, but then it uses up your duration pricing
yeah
workers are the best priced, but somehow the most expensive thing ever.
$5 and you get 8 hours of cpu time
meanwhile you can get hundreds of hours of cpu time a month for $3
but somehow cf workers still feel cheap
wait theres no possible way to fetch members of a specific role right
unfortunate that role obj doesnt contain a member list
😔
Sadly not
In order to keep an updated database of users with a specific role you'd need to use the gateway I think.
time to manually add all of these users into a database and add/remove when necessary
how fun
BUMP
hey guys i need a template nodejs for my discord bot djs v13, if someone vote my bot, it will send to my channel/their dms to thank them
nvm i read the docs
Little something I made https://github.com/zSnails/NeoNeedsKey
what module am i suppose to use for the api with python.
ads smh
if you ever have need for an anti DDOS tunnel, do NOT use x4b.
if you have unused credit in your account, they will never ever let you transfer it back to your card or paypal.
so its a case of "fine, you want to be a dick, i'll raise a disupute, not like i plan to continue using your service anyway"
are there any npm packages that cache a value for some time unless fetched before expiry?
like memory optimization caching
i want to store mongoose models in it
ima just write my own ig
i got my refund
they are NOT happy
lol
they basically called me a fraud
so i complained to paypal, i wont be taken for a mug
I use a library called expirymap
hmmmmm
or you could add a row to a database table for every message tracking the date and user id
count rows in last x days for giving roles and can delete older rows periodically
Well you can use redis if you really want to
oh oh more configuration oh lord
I said if you wanted to
ohhhh im gonna dieee
That’s just one of the many options
You could also just use a map
Also Id say it’d be pretty fun to make your own implementation of a map that has expiry entries
So why use a lib
Unless you just want to get it over with
That lib is dependency hell
It’s lib requires another lib that also requires another lib that also requires another lib
is it smart for companies that use mongodb to actually give the _id of a document to the user
e.g. an order's document
cuzz
Id contains nothing harmful afaik
even if it did it's hashed anyway
ID just resolves to date
thats it really
The 12-byte ObjectId consists of: A 4-byte timestamp, representing the ObjectId's creation, measured in seconds since the Unix epoch. A 5-byte random value generated once per process. This random value is unique to the machine and process.
oh, so not a hash
the eval was so fast it didn't even need to put the time it took to evaluate
fool of a took
win + r
cmd
node
i think the time navigating to that channel takes longer than opening node
oh yeah
mb
you can just windows button
type node
enter
and do stuff there

lol
Why do that when I can run something with my bot that’s on a version of node from 2.5 years ago? I want the legacy experience
shush
or if im already in browser, f12 and evaluate away
its great for simple js evals
yessir
Hello everyone . I'm looking for a coder for a bot project. Preferably French
I doubt you can find anyone on this channel. There is a certain group of people active here and 99% of them will not be willing to "work" with you 
especially because of the french part
heyy, this is more of a theoretical question. Is it possible to convert a non-deterministic turing machine to a deterministic one using a powerset construction?
holy fuck chitty 
Top 10 things you will never use in the real world™️
Speaking facts as usual
ok ty
@lyric mountain did you ever use textures in opengl? I'm trying to do a batch renderer but I can't seem to figure out why my texture is rendering as a black square
How can I create buttons that still work after a restart with discord.py?
didn't reach that part when I was writing my graphics2d wrapper
how did u load it?
I'm excited that I know what batch rendering is.
It worked for a while so I know it's not my loading
dump button states to database, load on restart
It broke after I added a "white square" dummy texture to use for plain color rendering
for example, if it's a role button, save the message ID to database and whatever else you need to re-create it
It works for colors so I'm really confused on why it doesn't work with proper textures
I'm going to clean up the code rq and see if I can figure it out
/buy
is there no other way?
ok thanks
I hate this
turns out my texture was being loaded wrong
I was loading it as GL_RGBA8 when it wanted GL_RGB
fucking jpg
opengl: graphics library by committee
what are the chances of voltrex being involved with it in some way?
I swear he's in every open source project
Hes probably part of it
any large library that involves C++ he likely has his hands in it
He's not
why are y'all still talking about him smh
I mean, he's a legend like tim
Dude is part of the backbone of most major frameworks while coding on a phone
he may be smart but not really emotionally
Wasn't here when it happened
¯_(ツ)_/¯
no u
no u two
rn i use slash cmd attachment option. if someone were to submit a video instead of a picture, how would i differentiate between them?
when someone tries a video it just uploads an img bc its being forced as an image
Your best bet is reading the first 4 (?) bytes of the file
Most if not all formats use magic bytes, which is unique for each format
Content type can be spoofed easily
You can write whatever you want on the headers
if they tried to make a photo a video, wouldnt it still upload it as a photo
Kinda, but you can intercept and modify the headers sent to the server
who?? the user or me?
The user
via a slash command?
Ah you mean through discord, thought you were doing for a sitr
no haha
In that case it's even easier
using cf workers :')
Just rename the extension
Discord trusts the extension too much
Rename png to mp4 and send it
lol ok
Would be an invalid video yeah, but discord would allow
Just read the first few bytes in the file, you can identify the format right away
Yeah, kinda
Whatever codec you use will be angry, but they usually ignore the extension and read the magic bytes as a fallback

what do you guys think about nginx now?
main dev split from them and created his own fork "freenginx"

wasn't nginx open source already?
yeah but look at mysql and mariadb
apparently the company behind nginx made some decisions without discussing with the dev team first
and some devs didnt like it
nice
You are the chosen one Null
Uh ?
what do you need?
To do a command system
I want to make a python discord bot with a cog command that requires voting in top.gg.
ah
time to note down what you wanted the bot to do as well as how to approach it from logic side
(don't think about implementation, just idea - "as a discord bot, how can i do {...}")
wow I hadn't thought of that thank you very much ^^
yw
Who has experience with elasticsearch? if so what are your thoughts on it, and if you don't like it what are some other free self-hosted options
hey guys
is there anyone out here that has used hadoop before?
how can we know how much mappers/reducer instances are being used for a map/reduce action?
Imagine i had a folder with 10 txt files across various datanodes within a cluster, and i wanted to like get one file that contains each word and their occurence.
if anyone could explain this, i would be trhilled.
if the function takes a callback, just increment a number in the callback
are you talking to me?
i cant lie this might be the best class i have had so far, about dockers and hadoop an allat
finally something pratical instead of theoretical like turing machines
yeah
fucking hell
authy decided to shutdown its desktop authenticator app
what a pain
yeah i got an email about that too
so, we went bowling after work because one of the guys was leaving. turns out when developers go bowling, we spend all our time abusing and finding xss exploits in the bowling management system lol
poor lane attendants had no clue wtf was happening lol
whos gonna win
I lost at the actual bowling
but won at disrupting the system lol
I was the big lol
2nd from bottom
This is probably the longest "hello" I've ever seen on this channel
hollywood bowl right?
me and my coworkers found the same thing haha
but you cant do much with it
looks like minimal html rendering so no script tags
would be considered very low severity
formData.append("payload_json", JSON.stringify({content: message, allowed_mentions: {"roles": ["roleid1", "roleid2"]}, avatar_url: <url here>, components}));
im trying to make a webhook ping two roles, but its not pinging any roles at all - any idea?
does the bot need permissions to ping roles in order for its webhook to ping roles?
i tried allowed_mentions: { "parse": ["roles"] } as well
TypeError: Failed to execute 'fetch' on 'Window': Failed to read the 'headers' property from 'RequestInit': String contains non ISO-8859-1 code point
fetch("http://127.0.0.1:4000/api/completed", {
method: "POST",
headers: {
"Content-Type": "application/json",
sessionkey: cookie,
cart: JSON.stringify(data),
},
body: JSON.stringify({ email: "data" }),
})```
i am unsure what this error even means
i mean it had to do with my headers, but it seems perfectly fine?
try omitting allowed_mentions unless the content you're posting is unknown
Pretty sure Headers have to start with Capital letters
On top of that, ISO-8859-1 refers to latin1 character encoding
So if it's non latin1, you should fix that
Can a competent dev take topgg over please and fix it finally so it'd work for more than just a few hours at a time, this is just unimaginable to always hear it's impossible to be fixed
ok this is pretty funny
Lowkey wish it worked
webhook uses the everyone role
so if the bot itself has perms it can ping right
the webhook was created by the bot
nope
bruh so in order for it to ping roles, @ everyone has to be able to ping roles???
I thought webhooks could always ping
yes, i believe so
webhooks are disconnected from the bot
this can be channel based right
like if i allowed the @ everyone role to ping in that specific channel
yeah
yes lol
really? certain things we were doing were doing weird stuff, see how it had 'the lane is broken' up above? 😄
The checking bot permissions is only for POST /channels/:channel_id/messages
Like Flaze said, webhooks are detached from the bot since you can use a webhook url on other services other than Discord and giving webhooks the same channel perms as the author isn't a good idea.
allowed_mentions also doesn't alter permissions like if the permission is denied on <@&guild_id> then it won't make a difference if it's present or not, just if the message would notify users, check if it should push those notifications
It's just the chat identity that's different
<@&guild_id> resolves to at at everyone
It's what you edit for permissions as well on an API level for the everyone role
but typing two ats is cringe so at everyone is just shorthand
strange that at everyone "works" in DMs
it's probably meant for group DMs
how can i know if i have latin1 character encoding? Also, so Sessionkey and Cart should be in the headers contrary to their lowercase ones?
discord only supports utf8
so whatever you're doing in whatever charset remember to convert it
when you display it
yo guys,
wanna ask by which time zone this website decides thats its a weekend or not ?
utc
it been answer in general
damn cross posts 
yup
nah utf-21 :^)
ah yes the sensible standard
why waste the 11 bits
for use on 21 bit systems
yes
sounds like the sort of data structures dpp has lol
wdym
we bit pack stuff to save memory
like the 40 or so booleans in stuff like users and guilds
C++ devs when they find out a boolean uses an entire byte (7 bits wasted, cannot let this happen)
and integers that can only hold a value up to 15 etc
Must use bitsets instead!
Bitsets are a wonderful thing
I haven’t ever looked at the internal implementation, do they occupy the same number of bytes as using bitwise operators over an integer would occupy? (Assuming that you set the size to be 32)
ayooo sameee
i use it in my library too
I’m assuming it’s a thin wrapper over bitwise operations so you don’t have to use your brain too hard for it
yesnt
I need to use bitsets for signatures in my ECS when I start developing it that’s why I’m wondering
we just use bitwise operators internally
I meant the stdlib bitset
but to the user we represent it via a set of methods that return or take bools
nah we don't use std::bitset
heavily underrated tbh
bit fields aren't complicated enough in my mind to need an abstraction
You’d be surprised the amount of kids in my CS classes that think booleans occupy 1 bit
it's just |, &, ^ and ~
Stdlib bitset is convenient when you need to specify a maximum size
the world if booleans occupy 1 bit
they "do", just with 8 bits of alignment 
Instead of having to manage multiple 64-bit numbers with bitwise operations
fuck alignment
00000001
----------^
the boolean
It’s even funnier when kids stuff an extra boolean into a struct and think that it’ll only increase the size by 1 byte
Chaotic neutral system
inb4 word alignment
alignment exists for a reason
and depending it may take 64 bits!!!
imagine 8 bytes used for your boolean
because of alignment
Yup
you can use pragma no pack and introduce a whole world of performance hurt
or pack stuff by hand
One 8 byte number + 1 boolean = 16 byte struct for x64
Crazy how I’m gonna actually need to think about this sort of stuff soon 😭
Game engines are fun
oh lmao
You can implement something super naive if you want but overall you have to think differently to get it to be more efficient
these optimisations are why I love c++ and developing dpp and why I don't use js
I think that if I can implement a really nice entity component system I’ll be set for making the game I want to make
:^)
these days my optimizations be nuts
Biggest issue at the moment is figuring out how to actually design an ECS
it's essentially fixed at around 60mb
nice
ecs aren't the hotness now
Damn, that’s about 3x as much ram as my engine eats right now
Granted all I have is a renderer
they hurt cpu cache
ECS is better for cpu cache
depends
imagine how much ram it occupies if it was coded in djs
Storing everything in contiguous arrays is wonderful for caching
you need a good block allocator to go with it that keeps the entities allocated in order in a block near the components
Entities are merely a thin wrapper over an ID
My biggest issue is that I don’t think I really want “systems”, but I don’t know how else to handle communication between components
I suppose I could just update every component in each componentarray and attach the entity they’re updating for to the update function
That sounds really slow though
Idk
If anyone has pointers on where to find resources for making an ECS without systems please lmk
hey guys, i made a UDP parser for my raw socket to basically mimic wireshark. I wanted some clarification if what i was doing is correct. So basically the full segment is all the data including the header which is a 64 bit, so 4 byte header. The data itself is 4 bytes as well. If we want to unpack the header, we get the full data segment and parse it into 4 equal sized segments, then we unpack the structures and format them correctly using encoding !HHHH as they are unsigned shorts. Once that's done, we can just get the rest of the data starting from indice 8, and that's basically how the packages work right? But does that mean that if a packet goes through the network pool each intermediate router must unpack and check the header for the source and destination ports? Isn't it really time consuming or do they use a different way of unpacking
someone has to end my suffering please
yes
each hop in the route analyses the header of an IP packet and may rewrite the destination IP if it's doing NAT
if it alters the packet it must recalc the checksum
ip stacks don't examine the packet payload it's treated as opaque data only
so 99.9% of the time they don't change the packet to route it but must be able to parse the header to know where to route the packet
i see!
That's really interesting can't lie
isn't there a faster method then instead of parsing the header etc?
wait no that's dumb. I think that with this header there can't really be a faster way?
there is but you can't do it
modern network cards have hardware acceleration for parsing and routing TCP/IP and UDP packets
but at the user level you don't have access to that, would have to be a kernel module or network card driver
I've written a TCP stack before which kinda half works and I didn't use any hardware acceleration
it's in C, what are you using?
i see. I didnt know all that.
I've written it in python as i wanted to create the parser pretty quickly without lots of bumps along the road.
I might use java in the end though if that's possible
anything is possible
speed and python don't go together very well :c
bigger q is, is it practical
would a tcp parser be more different compared to a udp one?
yes TCP is far more complex
I guess the header is the same but tcp has no data limit right?
yeah exactly
TCP operates on a sliding window system to handle throttling, back off and retries
a bit like zlib
i see, ofc you need way more error handling and basically need to retry sending if it fails. But the parser itself, would still have to unpack 8 bytes for the header but what about the data? Would that be any sized data?
like, in udp you are restrited to 8 bytes of actual data within the package
yes up to the max IP packet size
but iirc tcp has a no-limit protocol in data
i see
64400+ someghing
bytes
damn that's a big packet
but most network cards don't allow that
i'm sure he just wanted to get things done quickly first
it's basically the same as the MTU
couple of kb
or you have to deal with IP fragmentation
which is ew
"enjoy"
yeah, i didn't want to deal with huge loads of documentation and slow starting. This is usually the case with java in my experience. Python however is easy to start with.
it's like being kicked in the teeth by a horse
it's like someone made a sane standard and over time people shoehorned shit on top until it's a mess
like http basically
that didn't happen to udp
whahahah damn i hope i can still manage to do it
btw
while we are at it with the questions and the life lessons
i had a question about assigning ports
i read through the documents of ietf and found this part:
o The Well-Known Ports, 0 through 1023.
o The Registered Ports, 1024 through 49151
o The Dynamic and/or Private Ports, 49152 through 65535
what do they refer to with well known, registered, etc etc? Also, when i am in development process i sometimes assingn port 4000 or 5000 to a localhost process. I assume that's private right? Why does it work while it does not fall inbetween the given ranges here or do these ports above stand for a different usecase?
i just gave the bot perms to ping in that channel and it worked
Http for example
Basically standardized ports
Which are immutable and unusable for anything else
hello
I left the server a few months ago and now I have to resume my role as Bot Developer, what can I do?
Dm a mod
Thanks
Error
(process:22152): Pango-WARNING **: 00:23:26.417: couldn't load font "Chewy Not-Rotated 90px", falling back to "Sans Not-Rotated 90px", expect ugly output.
Code
const Canvas = require("canvas");
Canvas.registerFont(`./font/Chewy-Regular.ttf`, { family: "Regular" });
ctx.font = '90px Regular';
ctx.fillStyle = `#FFFFFF`;
ctx.fillText(name, 430, 200);
Reload Command Crashes
const { SlashCommandBuilder } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('reload')
.setDescription("[RoSearcher Developer Command]")
.addStringOption(option =>
option.setName('folder')
.setDescription("Command Folder")
.setRequired(true))
.addStringOption(option =>
option.setName('command')
.setDescription('The command to reload.')
.setRequired(true)),
async execute(interaction) {
const commandName = interaction.options.getString('command', true).toLowerCase();
const command = interaction.client.commands.get(commandName);
const folderName = interaction.options.getString('folder', true).toLowerCase();
if (interaction.user.id == "919674489581731842") {
if (!command) {
return interaction.reply(`There is no command with name \`${commandName}\`!`);
}
const resolvedPath = require.resolve(`${__dirname}/commands/${folderName}/${command.data.name}.js`);
console.log(resolvedPath);
delete require.cache[resolvedPath];
try {
interaction.client.commands.delete(command.data.name);
const newCommand = require(`./commands/${folderName}/${command.data.name}.js`);
interaction.client.commands.set(newCommand.data.name, newCommand);
await interaction.reply(`Command \`${newCommand.data.name}\` was reloaded!`);
} catch (error) {
console.error(error);
await interaction.reply(`There was an error while reloading a command \`${command.data.name}\`:\n\`${error.message}\``);
}
}
},
};
Error:
-Error executing command: Error: Cannot find module 'C:\Users\FRC 7722\Desktop\Projects\Bots\RoSearchBot\commands\developer/commands/misc/about.js'
Require stack:
- C:\Users\FRC 7722\Desktop\Projects\Bots\RoSearchBot\commands\developer\reload.js
- C:\Users\FRC 7722\Desktop\Projects\Bots\RoSearchBot\index.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1144:15)
at Function.resolve (node:internal/modules/helpers:187:19)
at Object.execute (C:\Users\FRC 7722\Desktop\Projects\Bots\RoSearchBot\commands\developer\reload.js:25:42)
at Client.<anonymous> (C:\Users\FRC 7722\Desktop\Projects\Bots\RoSearchBot\index.js:632:23)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\FRC 7722\\Desktop\\Projects\\Bots\\RoSearchBot\\commands\\developer\\reload.js',
'C:\\Users\\FRC 7722\\Desktop\\Projects\\Bots\\RoSearchBot\\index.js'
]
}
/reload folder:misc command:about
your path should probably be \commands\misc\about.js
in your code you do /commands/${foldername} ...
change the / to a \
i did and it crashes
for all?
yes
``` const newCommand = require(./commands/${folderName}/${command.data.name}.js);
this line
change the / to \
ok ima try it
Error executing command: Error: Cannot find module 'C:\Users\FRC 7722\Desktop\Projects\Bots\RoSearchBot\commands\developer/commands/misc/about.js'
at Object.execute (C:\Users\FRC 7722\Desktop\Projects\Bots\RoSearchBot\commands\developer\reload.js:25:42)
why is it doing \commands\developer/commands/misc
idk
its erroring at:
const resolvedPath = require.resolve(`${__dirname}/commands/${folderName}/${command.data.name}.js`);
no
its always happened
WAIT
ITS TRYING TO FIND THE COMMAND IN THE FOLDER IT WAS RAN IT
the command runs but it doesnt show any of the changes made
global commands can take up to 1 hour to propagate
ooooh
guild specific commands on the other hand update instantly, so you could use those if your bot is only in one guild
i found out how to make itwork
interesting, what'd you do
This but usually they don’t take very long at all tbh
let data = JSON.parse(localStorage.getItem("data"))
let cookie = JSON.parse(localStorage.getItem('key'))
console.log(cookie)
console.log(data)
fetch("http://127.0.0.1:4000/api/completed", {
method: "POST",
headers: {
"Content-Type": "application/json",
sessionKey: JSON.stringify(cookie),
cart: JSON.stringify(data), // Converting cart to a string
},
body: JSON.stringify({ email: "data" }),
})```
hey guys why is this error occuring here?
In all my other fetch operations this error does not happen, while i use the exact sme method (though i don't retrieve data from the localStorage.
Are you sure there isn’t like some sort of weird Cyrillic letter in that string or something
is there a reason why some of my button interactions fail but some of them work?? even if they fail, they still run through the entire cmd (just dont give the response) so im a bit confused
ik we should be replying within 3 seconds, which im pretty sure it does, but idk why its failing
it happens randomly
same with some commands
Sometimes the bot may take a little longer to execute the code, sometimes it's the code, sometimes the hosting
its using cf workers
if i were using gateway i would just defer
but i cant even defer with cf workers which sucks
You can defer immediately within the worker and then edit the original interaction response later on
the HTTP response from the worker should be the defer
then you can use rest to edit
alternatively, you can "load balance" interactions by receiving over the gateway, but if Discord asks you to reconnect, then the interactions might expire
depends on how fast you can reconnect and resume
but how would it work on cf workers
i tried deferring
and it is stuck on thinking
and doesnt respond
even tho i do the post request and reply to the original interaction
Dont followup or use the reply to interaction endpoint. You have to edit the original interaction response after deferring
You also need to wait for the http response to be sent before you can PATCH the interaction response
so basically defer immediately, then patch?
Yea
will try that
actually, how would i even do this? right now i return the response for the cf worker stuff, but if i returned a defer reply it wouldnt execute the code below it
response1 is the reply
Does anyone have any suggestions for SMTP services?
setImmediate and call a function in the callback before the return new Response
hmm
would
try { return the deferred response } finally { do the actual stuff } work as well
(setimmediate isnt supported)
it does defer, but it doesnt execute the setTimeout
i use both, i love them
postmark has amazing support
so does mailersend
thanks! much appreciated
I should be good with the free tier, since I'm really only using this for login and such
using mailersend that is since SMS, not sure if I'll have a use for SMS but we shall see
fairs
Is there a code for punishments, promote, demote and terminate like
Username: {username}
Rank: {rank}
Punishment: {punishment}
Reason: {reason}
?
Yeah that's not how this works
You're gonna need to start by learning a programming language
While I would normally recommend something like Java, if you only intend to program as a hobby/for discord bots and not as a profession, you can start off with javascript
Developing a system like that is going to require a relatively large amount of knowledge and there is no 20 line script that does it all for you
Okay, so is there a video? Or is the a format I can copy and paste it?
For what you want specifically? No, there is no video. There is no copy paste. You have to learn how to develop something like that by learning how a programming language works
https://www.codecademy.com/learn/introduction-to-javascript Taking what Waffle said, there are plenty of websites to get you started on Javascript. Take this one for example. I used it when I was first getting going with these things.
Here's another one that I just googled real quick, seems good and interactive: https://learnjavascript.online/app.html
This is not a quick process, so if you're just looking for a custom bot for your server, you're probably just going to want to hire a developer or find a friend that happens to know how to code
However if you intend on learning a programming language, feel free to ask for help here and in other programming related servers
Thanks
What if I want to learn Java 
oracle docs
Yikes
Java is fun

it's basically JavaScript just slightly different
should be easy if you come from a JS background
@sharp geyser did u give up on learning C++
you should do opengl
🧌
Here's a method I just wrote
std::vector<std::tuple<glm::vec2, glm::vec2, const unsigned char *>> Pack();
now THAT is cursed
@wheat mesa you should do OpenSSL
beyond belief
The return type is unreadable but so is the actual function
std::vector<std::tuple<glm::vec2, glm::vec2, const unsigned char *>> TextureAtlas::Pack() {
// ((x, y), (w, h), data)
std::vector<std::tuple<glm::vec2, glm::vec2, const unsigned char *>> returnValue;
stbrp_context ctx;
auto *nodes = new stbrp_node[m_Width];
stbrp_init_target(&ctx, m_Width, m_Height, nodes, m_Width);
auto *rects = new stbrp_rect[m_Textures.size()];
for (int i = 0; i < m_Textures.size(); i++) {
const auto &entry = m_Textures[i];
rects[i] = stbrp_rect{entry.id, entry.texture.Width(), entry.texture.Height(), 0, 0, false};
}
stbrp_pack_rects(&ctx, rects, m_Textures.size());
delete[] nodes;
int notPacked = 0;
for (int i = 0; i < m_Textures.size(); i++) {
const auto &entry = rects[i];
// Guaranteed to exist
const auto &texture = m_Textures[entry.id];
if (!entry.was_packed) {
notPacked++;
} else {
returnValue.emplace_back(glm::vec2(entry.x, entry.y), glm::vec2(entry.w, entry.h), texture.texture.Data());
m_IdToUV[entry.id] = {{entry.x / static_cast<float>(m_Width), entry.y / static_cast<float>(m_Height)},
{entry.w / static_cast<float>(m_Width), entry.h /
static_cast<float>(m_Height)}}; // (x, y), (w, h)
}
}
delete[] rects;
if (notPacked > 0) {
std::cout << "[WARNING]: " << notPacked << " textures could not fit in texture atlas!";
}
return returnValue;
}
and holy shit
it ACTUALLY WORKS
FIRST TRY
I think I'm leaking memory in there somewhere but I do not give a fuck right now
with less lines
i am genuinely impressed with myself
managed to do all of that with just 50 firefox tabs of obscure opengl documentation and a 2am flow state
I thought I understood Quaternions, but I had to double check with ChatGPT and now I think I get it. The w component was really confusing as I'm more used to Euler angles and 360° representations, but I guess the w component just helps with performance somehow and makes interpolation between rotations smoother
Now I got it down actually. That's really confusing to understand
Well I mean it makes sense now that I was able to correctly feed it a scenario and tell me if I was right
but at that point, I just don't understand what use case it has outside of animation
thats still a lot
(The “just” part was a joke)
It’s not that I gave up more like lost motivation
I’m just not certain on what to do anymore, I’d love to continue learning the language but quite honestly I’ve lost the love I had for programming largely due to discord bots and doing them for 3 years
I also never learned properly so my knowledge was very limited in the languages I did learn. I’m also just not as smart as everyone else I see pursuing it and it honestly bums me out
dw i'm not smart too
i still harbor some impostor syndrome around my friends
Can someone tell me about this
Error: Not enough sessions remaining to spawn 1 shards; only 0 remaining; resets at 2024-02-18T15
15.578Z"
i am stupid and i am happy
@wheat mesa
@solemn latch
dont ping random people for development questions
If someone knows they will answer.
i ping 2 they are developers
unless you are not ? 
I am, but I cant help you right now.
you have been ratelimited by Discord for disconnecting and reconnecting too often, you have to wait until that time has expired
nodemon on top lol
btw thanks
you should throttle it
restarting on every single file change won't be good
Especially if you often make small typos like me 
maybe consider code a watchdog for your bot, but for the command files
so that when said file changes, your bot can just re-import said modules
without having itself restarting
so real 😔
me when silly syntax error
Ohh
saves the full restart for when you change the core mechanics of the bot itself
reminded me that i wanted to make an interactive shell of the bot back in the day
so i can issue hot reload right there without stopping the bot from running
i was too lazy 😔
same i'm
can i have some help pls 😅 trying to make a bot.. i typed in npm i in the terminal and it says it can’t find the “package.json” file
did you npm init the folder you're working in?
no, i thought since the file was already in there it would load it up! sorry I’m new to this
package.json is?
yes, I’m following a video that Mac created on youtube on building a bot
how do i go about implementing context.waitUntil for deferring replies and stuff (cf workers)
you need to cd into your project
^
The terminal is in a different folder
how do i do this?
cd <path to your project>
in the terminal?
yes
really sorry if i’m asking stupid questions lol i’m new to this
no worries
so it doesn’t matter which one of the files on the left is selected?
based on this picture, your path is donm0/Da-High-Roller-Bot
so the command would be cd donm0/Da-High-Roller-Bot
nope
you need to type this into your terminal
nothing to do w files
im not sure where your project is located so you need to find the path to it
i have it connected to github! is that what you mean?
no, i mean the location of your repo on your laptop
where is the folder located on your laptop?
ok let me see if i can figure that out
i don’t remember making a folder, let me see if i can find one
i must have skipped that step lol
you mightve ran a command to clone a repo which would automatically create a folder
open your files and try to look for the folder
right click on any file in the explorer it should say "reveal in (something)" your file explorer or whatever its called in mac terms.
is there a way for me to download this onto my desktop and create that folder so i can have a path?
for some reason i’m not seeing a folder 😭
is it not already downloaded?
it looks like you've been modifying local files
The M next to config.json means modified
i created a fork in github of this, i thought that was me making my own copy
did this not open a local folder? 👀
👀 so weird, I wonder how you got here
i was following the video mac posted on youtube lol, should i just start over from the beginning?
or is there a way to fix it here



