#development
1 messages · Page 210 of 1
I'll goof around with it for a bit, I've not played around with discord bots in awhile so I cant remember exactly what permission it is
good luck...
ping me when you find something !
just as a tip, u can set the perm on discord for the bot role and use "view server as role" to see what the bot'll be able to do
flip switches till you can manage channel permissions through it
😮
this way u dont need to reinvite the bot everytime to test what perm u need
okkkkk, my bot can manage role in the server, but can't manage permissions in the channels
yes, view server as role and flip the perms till you can
the last perm u flip will be the one you need
It shouldnt be admin, admin essentially means 'all other perms'
all other perms + ignore overrides
i think it's admin...
I've been a mod here for 3 and a half years and have never seen a bot need admin
cause with all perms my bot hasn't this perm
Which role does your bot have? 👀
and test is the one its modifying?
are you the owner of the server?
So you want to set other users to edit permissions of the channel via the bot?
In your code you're not setting that option at all
no, the bot should simply ban the channel to everyone and create exemptions for players with the specific role in the channel
"will have every permission" - All Admin does is enable all the discord permissions
So you just need a combination of the permissions
you need to find the right combo
it doesn't work when my bot has all permissions except admin
please
It looks like you can edit those permissions at 33 seconds right, the one you hover over is just to allow other users to change permissions of the channel.
i can't create a channel if i set permissions in my create method from djs, so it won't change anything
Figured one way to do it.
When you create the channel you can edit all these permissions freely
const channel = await guild.channels.create({
name: "test",
permissionOverwrites: [
{
id: User Or Role ID,
allow: [
PermissionsBitField.Flags.ViewChannel,
PermissionsBitField.Flags.SendMessages,
PermissionsBitField.Flags.ReadMessageHistory,
],
},
{
id: User Or Role ID,
deny: [
PermissionsBitField.Flags.ViewChannel,
PermissionsBitField.Flags.SendMessages,
PermissionsBitField.Flags.ReadMessageHistory,
],
},
],
});
no, i have a missing permissions error
intresting, my bot only has manage channels and it works fine.
do you want a video ?
Did you try setting the permissions when you create the channel?
And you're setting the roles permissions, not the users permission?
both
both?
i tried the both
I'm not sure how to help then.
This code worked, with just these permissions
I didnt try it without manage roles, but it does work.
Sadly I'm out of time today to help 😦
the bot can't create permissions !
Whats the code?
This
okay so, i got an idea for what i do with implementing languages in my macros language, and i'm planning to have a init folder to get the package
get the package in a function
and have a file with their names in, so i can get the transformer and the neutral class
have no idea how to load the modules
but i need to load them twice
like the non transformer version
and the transformer version
altogether
you have a channel override blocking the manage roles perm
the ONLY explanation for admin working and all perms not, is that you have an override
as that's the only thing admin has over all perms
I think your issue is that a static function shouldn’t need a self parameter, that’s the point
Either that or you’re trying to use a member function in a static context, which is also wrong
can a static function even have a "self"?
like, there's no instance to be called a self
ah nvm, misread ur comments
it can technically but it wouldnt make sense
since the whole point of static is to not have a class instance associated with it anyways
the equivalent of lying to the compiler lol
PM2 | App [OfferteApi:22] exited with code [1] via signal [SIGINT]
PM2 | App [OfferteApi:22] starting in -fork mode-
PM2 | App [OfferteApi:22] online
22|OfferteApi | Error: listen EADDRINUSE: address already in use :::8443
22|OfferteApi | at Server.setupListenHandle [as _listen2] (node:net:1751:16)
22|OfferteApi | at listenInCluster (node:net:1799:12)
22|OfferteApi | at Server.listen (node:net:1887:7)
22|OfferteApi | at Object.<anonymous> (/root/site/offerte.js:286:13)
22|OfferteApi | at Module._compile (node:internal/modules/cjs/loader:1256:14)
22|OfferteApi | at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
22|OfferteApi | at Module.load (node:internal/modules/cjs/loader:1119:32)
22|OfferteApi | at Module._load (node:internal/modules/cjs/loader:960:12)
22|OfferteApi | at Object.<anonymous> (/usr/lib/node_modules/pm2/lib/ProcessContainerFork.js:33:23)
22|OfferteApi | at Module._compile (node:internal/modules/cjs/loader:1256:14) {
22|OfferteApi | code: 'EADDRINUSE',
22|OfferteApi | errno: -98,
22|OfferteApi | syscall: 'listen',
22|OfferteApi | address: '::',
22|OfferteApi | port: 8443```
hey guys how the fuck do i fix this
an older instance of your app is probably still running or keeping the port reserved
try kill the app running on that port and try again
always attach to ports with REUSEADDR flag
else there are some cases when a process dies but still somehow hold the port's lock
kill by port
kill -9 $(lsof -t -i:port)
it's because i forgot the () in the class parsing
okay so, i need to know how to access the classes
have no idea how to do it
well, restart the server
and use reuseaddr from now on
usually happens because the kernel keeps the port reserved because it still thinks it's in use because you haven't gracefully released that port or stopped that program
it shouldn't happen but it does
kernel should figure out after a bit of time the port is free though
but no one has time for that
there's usually a lot of complex dependencies and reliances in place so kernel can't just go "if program exited, free port"
i am senior full stack & blockchain & AI developer.
I have enough experience of developing website, dApps and AI project.
Is there anyone looking for a dev?
a senior full stack dev wouldn't try to find jobs through dc
apply for a fucking job bro what you doing
It’s web3
No web3 jobs is going to use a real job site
because most are scams and rugpulls
blockchain?

they scared of working for a honeypot company
fixed !
does anyone know any good js sandboxes
i'm trying to make a feature that lets people code their own plugins, but i only want them to be able to access the context given to them
I know null made a sandbox package
not sure if it will work for you
whatever works best for ya
tbh not sure
the code will run remotely on a vps that has no access to any other data at all
just to be safe
yes
you could even use kubernetes and spawn small servers /joke

run that in docker
😏
Also wait
@radiant kraken its a sandbox
why can it access the filesystem

can't get users anyways
I guess tio allows you to access the fs its running on
welp got a working example
you define the post handler and do whatever you want
and you can get the full post object with .toJSON()
not working with Tio tho
hm doesn't support ?.
removed and it worked
can I see the full source code if you dont mind
cause I want to try it myself
that ?. should work
import tio from 'tio.js'
const evalCode = async () => {
const response = await tio(`
class Post {
constructor(obj) {
this.postObj = {
id: obj.id || '',
title: obj.title || '',
content: obj.content || '',
tags: obj.tags || [],
files: obj.files || [],
user: obj.user || {},
createdAt: obj.createdAt || '',
updatedAt: obj.updatedAt || '',
commentCount: obj.commentCount || 0,
upvotes: obj.upvotes || 0,
comments: obj.comments || []
}
}
getId() {
return this.postObj.id;
}
getTitle() {
return this.postObj.title;
}
getContent() {
return this.postObj.content;
}
getTags() {
return this.postObj.tags;
}
getFiles() {
return this.postObj.files;
}
getUser() {
return this.postObj.user;
}
getCreationDate() {
return this.postObj.createdAt;
}
getUpvotes() {
return this.postObj.upvotes;
}
getComments() {
return this.postObj.comments;
}
toJSON() {
return this.postObj;
}
}
const post = new Post({
"id": "67b8cc16-4525-4278-a93b-f2d1ee0e6008",
"title": "testtest",
"content": "est",
"tags": [],
"files": [
{
"name": "Background (9).png",
"hash": "7391c6c4239fbf5c947e0611b4bf46b859282100c0f19cc51020c109c68083be",
"cdnPath": "posts/67b8cc16-4525-4278-a93b-f2d1ee0e6008/7391c6c4239fbf5c947e0611b4bf46b859282100c0f19cc51020c109c68083be.png",
"mimetype": "image/png"
}
],
"user": {
"id": "5f97a041-0daf-4042-871b-dc6bac3e9892",
"username": "big.bun",
"avatar": "https://cdn.discordapp.com/avatars/471409054594498561/a_58afbdbbc758eedfcf5ce227fdc0349c.png"
},
"createdAt": "2024-05-22T10:56:50.177Z",
"updatedAt": "2024-05-22T10:56:50.177Z",
"commentCount": 1,
"upvotes": 0,
"comments": [
{
"id": "9d25d749-dbde-4157-bd2a-ebd3e3703dce",
"content": "test",
"user": {
"id": "5f97a041-0daf-4042-871b-dc6bac3e9892",
"username": "big.bun",
"avatar": "https://cdn.discordapp.com/avatars/471409054594498561/a_58afbdbbc758eedfcf5ce227fdc0349c.png"
},
"createdAt": "2024-05-22T12:15:44.690Z",
"updatedAt": null
}
]
})
async function postHandler(ctx) {
console.log(\`Post ID: \${ctx.getId()}\`);
console.log(\`Post Title: \${ctx.getTitle()}\`);
console.log(\`Post Content: \${ctx.getContent()}\`);
}
const handlePost = async () => {
await postHandler(post)
}
handlePost()
`);
console.log(response?.output || "No output?!?!")
}
evalCode()```
that doesn't have ?. tho
import tio from 'tio.js'
const evalCode = async () => {
const response = await tio(`
class Post {
constructor(obj) {
this.postObj = {
id: obj?.id || '',
title: obj?.title || '',
content: obj?.content || '',
tags: obj?.tags || [],
files: obj?.files || [],
user: obj?.user || {},
createdAt: obj?.createdAt || '',
updatedAt: obj?.updatedAt || '',
commentCount: obj?.commentCount || 0,
upvotes: obj?.upvotes || 0,
comments: obj?.comments || []
}
}
getId() {
return this.postObj.id;
}
getTitle() {
return this.postObj.title;
}
getContent() {
return this.postObj.content;
}
getTags() {
return this.postObj.tags;
}
getFiles() {
return this.postObj.files;
}
getUser() {
return this.postObj.user;
}
getCreationDate() {
return this.postObj.createdAt;
}
getUpvotes() {
return this.postObj.upvotes;
}
getComments() {
return this.postObj.comments;
}
toJSON() {
return this.postObj;
}
}
const post = new Post({
"id": "67b8cc16-4525-4278-a93b-f2d1ee0e6008",
"title": "testtest",
"content": "est",
"tags": [],
"files": [
{
"name": "Background (9).png",
"hash": "7391c6c4239fbf5c947e0611b4bf46b859282100c0f19cc51020c109c68083be",
"cdnPath": "posts/67b8cc16-4525-4278-a93b-f2d1ee0e6008/7391c6c4239fbf5c947e0611b4bf46b859282100c0f19cc51020c109c68083be.png",
"mimetype": "image/png"
}
],
"user": {
"id": "5f97a041-0daf-4042-871b-dc6bac3e9892",
"username": "big.bun",
"avatar": "https://cdn.discordapp.com/avatars/471409054594498561/a_58afbdbbc758eedfcf5ce227fdc0349c.png"
},
"createdAt": "2024-05-22T10:56:50.177Z",
"updatedAt": "2024-05-22T10:56:50.177Z",
"commentCount": 1,
"upvotes": 0,
"comments": [
{
"id": "9d25d749-dbde-4157-bd2a-ebd3e3703dce",
"content": "test",
"user": {
"id": "5f97a041-0daf-4042-871b-dc6bac3e9892",
"username": "big.bun",
"avatar": "https://cdn.discordapp.com/avatars/471409054594498561/a_58afbdbbc758eedfcf5ce227fdc0349c.png"
},
"createdAt": "2024-05-22T12:15:44.690Z",
"updatedAt": null
}
]
})
async function postHandler(ctx) {
console.log(\`Post ID: \${ctx.getId()}\`);
console.log(\`Post Title: \${ctx.getTitle()}\`);
console.log(\`Post Content: \${ctx.getContent()}\`);
}
const handlePost = async () => {
await postHandler(post)
}
handlePost()
`);
console.log(response?.output || "No output?!?!")
}
evalCode()```
thats with ?.
It is using the wrong langauge setting
tio uses v11 nodejs
?. was not added until v14
ah…
no idea why its so outdated tbh
I would not trust these sandbox code running modules
the amount of vulnerabilities they tend to be riddled with
might just use workers as a service then
which sometimes don't even get fixed bc the author abandoned the package
runs in the cloud, easy to setup, etc
just make your own sandbox
bro sharky get out of development
you dont belong here
I mean if you're not relying on any user input its probably fine but at that point I'd just use eval
or run the code directly like a normal person
but that library does run in some sandbox anyways so its fine
I thought it was just another one of those libraries that runs js code in some local sandbox
it runs in the tio servers, it's basically an API wrapper lmao
every eval is an HTTP request
heyyy i made it smh smh

okay so... i feel like i'm gonna repeat this
like, for when i cross things like
message -> { bi message }
how do i use json to gather pattern again?
so i don't need to create a spagetti code
more than what i'm doing
since my lack of knowledge forces me making a spagetti code
cenverting
my plan is to be able to stack up to biuls
like
||Hello world||
é só vc usar regex rapaz
quer dizer, mais regex
junta td em um negocio só
mas enfim, n sei oq re.sub faz, mas vc tbm pode usar um mapa e iterar ele pra comparar os patterns
melhor doq repetir a msm coisa 5 vezes
alias italico é tanto _assim_ qnt *assim*
o problema é seu saber como usar mapa
para iterar
tem como me ensinar a usar mapa
pois nunca usei ele
mapa, dictionary, json, td a msm coisa praticamente
uhhh...ok?
mods are asleep, signal as spam
If you spam links in all channels again I'll ban you to have it removed the messages for me

idk
https://files.sky.h4ck.me/files/YxwsgU.png
Holy shit so well coded 
thats a lotta ram
i beg you to use less points in the graphs and use graph smoothening functions
sure
no
huh?
https://files.sky.h4ck.me/files/Ykk4cw.png
WHY IS CPU EMPTY
my servers dont have a cpu
they're just codeblocks
```abc```
gets turned into
abc
blocked
💀
i got too late into my anime era
usually it hits you at like 16-17
mine hit at 21
is there anyway to log certain commands to discord's audit log?
Hey guys, how can a universal turing machine be used for the halting problem, with other words: How can a universal machine simulate another machine that may or may not halt given an input string.
Like, i asked chatgpt and searched the internet but unfortunately nothing. They had proofs, like the blank tape proof and halting proof, but i am more focused on a practical framework.
what's fucking my mind is, that if a normal turing machine won't halt, then the universal won't either? Even if we added a timeout or loop iteration, we can never be sure it definitely hit an infitine loop. It could be its normal behavior
The halting problem isn’t saying that Turing machines don’t halt, it’s saying that it’s not possible to make a general proof to tell if a machine will halt or not
Oh I think I see what you’re saying now
Nvm then what I said doesn’t answer your question
i appreciate the effort tho!
how can i get my bot to create a separate channel in a game? i’m using djsv13 and im having trouble finding the documentation
in a game?
Almost done
<GuildChannelManager>.create
The only way to my knowledge is to access the channel manager on a guild
I hate the entire field of cs
As a matter of fact I hate the entire “being valuable part of society” part
then dont do it

with that mindset this is impossible
Never going to be a multi millionare if you have a mindset like that
unless you want to be a miserable one
💀
💀
Chill maybe he is elon Musk
does his family own a diamond mine in south africa?
I m gOnNa cOmMit FrAUd
Not yet
but I soon will
Maybe i do something wrong, but what can i do to prevent this error?
I increased the timeout from 3 second to 15 second/20/30 and even 1 min with retry but still it happend
at RedirectableRequest.handleRequestTimeout (/root/DiscordMusicGiveawayBotNew/node_modules/axios/dist/node/axios.cjs:3124:16)
at RedirectableRequest.emit (node:events:514:28)
at Timeout.<anonymous> (/root/DiscordMusicGiveawayBotNew/node_modules/follow-redirects/index.js:210:12)
at listOnTimeout (node:internal/timers:573:17)
at process.processTimers (node:internal/timers:514:7)
at Axios.request (/root/DiscordMusicGiveawayBotNew/node_modules/axios/dist/node/axios.cjs:3877:41)
at runNextTicks (node:internal/process/task_queues:60:5)
at listOnTimeout (node:internal/timers:540:9)
at process.processTimers (node:internal/timers:514:7)
at async leaderboardJob (/root/DiscordMusicGiveawayBotNew/SiennaNation.js:238:7) {
code: 'ECONNABORTED',
The servers are up 24/7 with 100% uptime, but i don't understand why axios is not able to keep the connection or crash the connection
have you tried using other than axios?
Hmm, not actually. Is there something much more popular then axios?
I just saw now a lot of people call axios dead 😂😂
or probably undici
and is it really possible to have a channel that doesn’t show the “ <member> is typing….” status at the bottom?
it is
program your own chat server, that way you can control everything

someone I work with made a revamp of the matrix bridge and no typing indicator
switch to element (formerly matrix) and bridge to discord with bot backed webhooks
undici doesnt support http 2 which sucks
it achieves better throughput than http 1
binary frames and everything instead of decoding utf8 and finding boundaries like losers
Hy, node js bot. Bot not edit own message and Delete:/ permission set: manage message :/ My Own Discord Server succes edit another not. Missing permission?
Error log:
DiscordAPIError: Unknown Message
at RequestHandler.execute (/home/sajat/bot-disc/uj/node/node_modules/discord.js/sr$
����at runMicrotasks (<anonymous>)
����at processTicksAndRejections (node:internal/process/task_queues:96:5)
����at async RequestHandler.push (/home/sajat/bot-disc/uj/node/node_modules/discord.js$
����at async MessageManager.edit (/home/sajat/bot-disc/uj/node/node_modules/discord.js$
��method: 'patch',
��path: '/channels/1239350339824783381/messages/1243021954944995421',
��code: 10008,
��httpStatus: 404,
��requestData: {
����json: {
������content: undefined,
������tts: false,
������nonce: undefined,
������embeds: [Array],
������components: undefined,
������username: undefined,
������avatar_url: undefined,
������allowed_mentions: undefined,
������flags: 0,
������message_reference: undefined,
������attachments: undefined,
������sticker_ids: undefined,
������thread_name: undefined
����},
����files: []
��}
}
you are editing a message that no longer exists
Is it possible, using pure client side js to get an md5, sha1, sha224, sha256, sha384 or sha512 hash of a file input
should be possible yes
How sir
the crypto api is stupidly limited
first you need to be using a secure connection (https) to access it
and i dont think it supports many hashing algorithms
youd have to use a library for it
I mean I just need one of those
yeah looks like it supports it now finally https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest
The digest() method of the SubtleCrypto
interface generates a digest of the given data. A digest is a short
fixed-length value derived from some variable-length input. Cryptographic digests should
exhibit collision-resistance, meaning that it's hard to come up with two different
inputs that have the same digest value.
SHA-1?
Yes, I understand this part :/ but it exists. That's why the error is strange to me.
Obviously not
Either that or its ephemeral
ephemeral messages cannot be edited afaik
??
?
confusion ception
@sharp geyser my name is Mike Ross will U hire me
i know that error because people are deleting the gameboard message from my bot 💀

hey guys i am lost about networking
i jsut have a rough time understanding the difference between network and transport layers
suppose we have host a that needs to go through host b, c, d to reach host e.
then the transport layer would only come into play at the begin of host a (where it assigned port number to the process using the internet and doing a certain action) and host e right (to deliver the packet to the right process).
Because in between, we just have a host-host communication and network layer provides the play there so no ports are needed, or is this wrong?
i might just be right. Or i am paranoid. Or i am stupid but right. Or i could not be right but partially right. Or i could be totally wrong.
😭 whts the right and whats the wrong part
don't leave me in shambles here
Oh I have no idea
you see now what I mean
double and pass to next
Kuu gotta help me out here


it's over
you insert a row -> AFTER INSERT trigger happens
on a database?
yea
only those who can create tables can create triggers
only ppl with perms can iirc
imagine you have a ball
you prepare to throw the ball, this is when BEFORE THROW (imagine throw is an operation)
whatever u declare on that trigger will happen now
the ball gets thrown (operation is done)
then the AFTER THROW trigger happens
imagine gravity is declared here
so inside this trigger, ball.fall()
now we getting into physics
it's literally this, you add actions to happen before, during and after operations
ic
during would be the query itself
So I can make a trigger that happens before a select?
no, only for write operations

Then why were people earlier talking about triggers making checks redundant in code
triggers can be used to validate input
chatgpt clutched up yall
https://files.sky.h4ck.me/files/ZeVZub.png
Bruh i'm installing a ptero panel+wings in a ptero instance
or manipulate data in a way
imagine you have a child table, and you want to insert a row in parent table if it doesn't exist (to prevent contraint error)
you'd do in a trigger
CREATE TRIGGER make_parent
BEFORE INSERT -- Should run before inserting child
ON child_table -- Where to listen for actions
FOR EACH ROW -- Execute for individual rows, not whole operation
BEGIN -- Just an example, actual trigger DDL is different
-- Check if a parent with parent_id exists
IF (NOT exists(SELECT 1 FROM parent_table pt WHERE pt.id = NEW.parent_id)) THEN
-- If not, insert a parent
INSERT INTO parent_table (id, smth) VALUES (NEW.parent_id, 'mogus');
END IF;
END;
``` basically
huh
what is that black magic
Also what is the point of that
a child should always have a parent
there, added commments
you shouldnt insert into a child if there is no parent
yes, but you could
this trigger would generate a parent if one doesnt exist
ic
in a code example, triggers work like this:
void insertRows(Rows[] rows) {
for (Row row : rows) {
beforeInsert(row);
insert(row);
afterInsert(row);
}
}
or if not using FOR EACH ROW, it'd be like this ```java
void insertRows(Rows[] rows) {
beforeInsert();
for (Row row : rows) {
insert(row);
}
afterInsert();
}
java man

I cant read java
can you do it in lua
😏
jokes aside, thanks haku I understand a bit more
@lyric mountain you are good with java right?
How much overhead in kb/mb idk do class serialization add?
Cuz suppose you want to create a seperate class instance for 500 rows, for let's say hadoop parallel processing. then they all need to be in a java class but it means that it will add a class overhead to the already existing data.
what the fuck is hoolahoop parallel processing
it's...complicated
Class overhead is 14 bytes iirc
but it's really hard to get a precise formula as it's implementation detail
your best option is to use some agent like JOL or JAMM
hadoop, a way to process one big dataset using a distributed set of servers
i see, what do they do?
they measure
hmm i see
in hadoop, we can serialize a certain row of data into java classes.
We then create classes for reducers and mappers as well.
It's really strange, hadoop uses java classes for some reason
let me give you a code snippet
anyway, the only way to measure objects is through agents
give JOL a try, it aint hard to setup
private static class MyMapper
extends Mapper<LongWritable, Text, Text, IntWritable> {
private final static IntWritable ONE = new IntWritable(1);
private final static Text WORD = new Text();
@Override
public void map(LongWritable key, Text value, Context context)
throws IOException, InterruptedException {
String line = ((Text) value).toString();
StringTokenizer itr = new StringTokenizer(line);
while (itr.hasMoreTokens()) {
WORD.set(itr.nextToken());
context.write(WORD, ONE);
}
}
}
alrighty, i'll have a look.
https://openjdk.org/projects/code-tools/jol. Contribute to openjdk/jol development by creating an account on GitHub.
the readme only mentions cmdline commands, but u can use it from code too
i see i'll set it up and let you know if something happens. Thanks!
yw
what do i do if i have to change a bot’s oauth2 invite permissions (to make lock command work) on top.gg but it’s already been invited by some pepole with the current permissions on discord.py?
I don't know if you can do anything except add some information (embed) when executing the command that the bot lacks permission
Personally, I would make an announcement on my support server and those who follow the announcements would notice and possibly give the bot appropriate (new) permissions and the rest, unfortunately, remains unaware
Add a check on the command and tell the users if permission not found, to give bot new perm
you should have checks on the commands anyways if it uses some permission that normal bots dont need
otherwise you just get members who are confused on why it doesnt work
unrelated
is sql turing complete
Sql no, plpgsql is
In fact if you included postgres http extensions, you could probably write a bot on it
And it has native support to json
sounds like a 3am project
ive never used postgres yet but its sounding better day by day
its superior
ive only ever used sqlite3 and for servers mysql/mariadb
turns out ive been missing out
can i write a trigger in js
i see python is on the trigger language list
TIL plpython is a thing
IT HAS RUST WTF
holy hell pljava ftw
????
even shell lmao
lmao
guess the fuckin what
there's also javascript
honestly I didn't even consider there were other langs for postgres procedures
of course the rust people had to slide their pesky fingers into the postgres language list
does someone know how to improve my prisma sql query performance,
this is the current code
const versions = await ctr.useCache(`versions::builds::${type}`, async() => Object.fromEntries(await Promise.all((await ctr["@"].database.minecraftVersion.findMany({
where: {
builds: {
some: {
type
}
}
}, select: {
id: true,
type: true,
supported: true,
created: true
}, orderBy: {
created: 'asc'
}
})).map(async(version) => [
version.id,
{
type: version.type,
supported: version.supported,
created: version.created,
builds: await ctr["@"].database.minecraftServerBuild.count({
where: {
type,
versionId: version.id
}
}), latest: await ctr["@"].database.minecraftServerBuild.findFirst({
where: {
type,
versionId: version.id
}, orderBy: {
id: 'desc'
}, select: ctr["@"].database.commons.build(false)
})
}
]))), (t) => t(2).m())```
for each version it finds, it does 2 extra queries in promise.all, problem is this is insanely slow when you have 650 versions (5+ sec),
I already tried putting the resulting 1300 queries into one single transaction but that made it even slower
that's...sql?
raw sql would very likely be easier to optimize
just show the UML of the tables and say what u want to get
i want all minecraft versions where theres a build with type = xxx
and then for every version I want the count of builds and the latest on the same version (latest = highest id)
what's the name of the first table
minecraftServerBuilds
u said "the count of builds", but where's that data?
so the first table is child of the second?
technically yes
then that's actually a pretty short query
SELECT mv.id
, count(msb.id) AS builds
, max(msb.id) AS latest
FROM minecraftVersions mv
INNER JOIN minecraftServerBuilds msb ON msb.versionId = mv.id
WHERE mv.type = :TYPE
GROUP BY mv.id
ok ok, what?
atomics are just regular properties with get/set, the diff being they're updated across threads
that is, it exists as a single value
I still dont think I get what you mean exactly
got any example?
is there a way to directly select fields from latest?
yes, simply remove the group by and make count/max run on a window
actually, dont
make a select from the resultset
SELECT *
FROM (
SELECT mv.id
, count(msb.id) AS builds
, max(msb.id) AS latest
FROM minecraftVersions mv
INNER JOIN minecraftServerBuilds msb ON msb.versionId = mv.id
WHERE mv.type = :TYPE
GROUP BY mv.id
) x
INNER JOIN minecraftServerBuilds msb ON msb.id = x.latest
wow
can't you just put a reference of the block renderer on a variable in block entity?
why not?
I suggest trying to learn sql, most queries are rather simple to make and MUCH more optimized than any library could ever generate
if you want to make sure not to hold references from the GC, use WeakReference
just make sure to check whether it wasn't already collected before using the value
it has exactly all i need now
ah ok
except latest but im not gonna type everything out for one field
4th field
it should be at the topmost query
where u put it in the image u showed is correct
i mean it works
yes, but it doesn't change the order at all
it does sir
wdym
you cannot do this
filtering HAS to be in WHERE clause
the order by is working because ur not filtering at all
aaaaaaaaaaaaaaaaaaa
and it's likely duplicating results
the reason it shouldn't sort is because ur filtering by version id
if all builds are under the same version id, then all builds will have the same latest value
it's like sorting by "most delicious oranges" and also getting bananas and pears
no, but you can search for pre-existing ones
Can you help me
do i just tell them “Try reinviting me at (link here)” when the bot doesn’t have perms?
No, you tell them which perm the bot needs, so they can update the role or give bot a new role with higher perms
you can ofc tell em to reinvite
oh ok
but why not just say what perm it needs
cuz i think it’s simpler to just reinvite
well, anways you should have a check regardless.
Like
return channel.permissions_for(guild.me).send_messages```
or whatever your bot needs
except discord.Forbidden:
await interaction.response.send_message("I don't have permission to lock this channel, try reinviting me at (i will put the link here)", ephemeral=True) ```
i tried making this, is it ok?
its fine, but i would run the check before your the main function, so you can return early instead of have to rely on try except
wdym by running the check
like
do i replace the send_message perm with manage_roles then what do i do
Do you know that discord.py offers a check decorator? Which also supports custom checks
This check will run before your main function.
You then can have a error handle file, which where you can handle it
yes i knew that discord.py had a check decorator but i don’t understand how to implement it
you make a decorator like:
It needs to return true or false
def func():
async def predicate(interaction: discord.Interaction) -> bool:
...
return app_commands.check(predicate)```
and then you just add
@func to your command
and then you can handle errors on
async def on_app_command_error(self,interaction: Interaction, error: AppCommandError):
...
if isinstance(error, discord.app_commands.errors.MissingAnyRole):
...
and so on
even discord.js doesnt have this advanced functionality
This is very similar to what I did in my little mini framework I use for my bots
I also do something similar lmao
It’s also what detritus did/does
I have a couple of dedicated functions for different parts of the command running process
All optional ofc
you can actually make your dev life 1000% better if you invest in making helpers and automated checks
which is why I spent 2 months writing my framework before even starting to write the commands
now writing anything is effortless
yuppp
i made like a folder with reusable helpers for different purposes
and code templates
sharpen your knife now so you don't have to cut beef with a blunt edge later
i don't think that's a valid saying but i feel you kuu 🗣️
it is now
let string = "testtest"
function checkDuplicates(){
let leftPointer = 0;
let rightPointer = string.length / 2;
let duplicates = false;
while(true){
if(leftPointer == string.length / 2 && rightPointer == string.length){
duplicates = true;
break;
}
else if(!string[leftPointer] || !string[rightPointer]){
break;
}
else if(string[leftPointer] != string[rightPointer]){
break;
}else{
leftPointer += 1;
rightPointer += 1
}
}
return duplicates;
}
console.log(checkDuplicates())```
does anyone know how wheter the code can be more optimized?
I didn't use a double for loop on purpose as i need this function to run on pretty big textx
What the fuck
??
man fuck the identation
its just js and html
ik
is there a library that would create these index.js files automatically? should i just write something to do it myself?
HELP MY PC LAGS SO HARD
I CANT CLOSE IT
ALT f4 DOESNT WORK
bruh task manager crashed
would i need to build the index.js files during the build or should i create them right before they are accessed?
HOW TF
f12
ctrl + shift + p
"Disable JavaScript"
not needed edge crashed
time to make the site more powerful
https://files.sky.h4ck.me/files/8gUUzy.png
i think its 502 bad gateway
have you tried using windows key + shift + s?
mhm?
here you go
const pause = ms => new Promise(resolve => setTimeout(() => resolve(), ms));
const makeSound = async ()=> {
const context = new AudioContext();
const oscillator = context.createOscillator();
oscillator.type = "sawtooth";
oscillator.frequency.value = 1200;
oscillator.connect(context.destination);
oscillator.start();
await pause(100);
oscillator.stop();
}
makeSound();```
This would be really simple to do yourself. Read fs dir excluding index.js, append to a string +=
const ${fileNameHere} = require(\./${fileNameHere}`);\n`
loop again at the end inside of a module.exports and just declare the variable.
what about something like this?
const fs = require('fs');
const requirer = modulePath => {
// make sure index.js has been created in the module folder
const module = fs.existsSync(`./${modulePath}/index.js`);
// create the index.js file if it doesn't exist
if (!module) {
// todo: create the index.js file
const indexjs = '';
fs.writeFileSync(`./${modulePath}/index.js`, indexjs);
}
return require(`./${modulePath}/index.js`);
}```
oh wait
How do you make a bot
need to try
go to https://discord.com/developers/applications
Ok thanks
const fs = require('fs');
const requirer = modulePath => {
// make sure index.js has been created in the module folder
const indexExists = fs.existsSync(`./${modulePath}/index.js`);
// create the index.js file if it doesn't exist
if (indexExists === false) {
// get the name of every file in the module folder
const files = fs.readdirSync(`./${modulePath}`);
// create the index.js file with the require statements
const requireStatements = files.map(file => {
const fileName = file.split('.')[0];
return `const ${fileName} = require('./${fileName}');`;
}).join('\n');
// create the module.exports statement
const moduleExports = files.map(file => {
const fileName = file.split('.')[0];
return `${fileName},`;
}).join('\n');
// create the index.js file
const indexjs = `${requireStatements}\n\nmodule.exports = {\n${moduleExports}\n};`;
fs.writeFileSync(`./${modulePath}/index.js`, indexjs);
}
return require(`./${modulePath}/index.js`);
}```
Okay I made it
1243396666506215494
How do I make it trade and upload it to Top.gg
you need to write a program that uses the bot api key to do what you want it to do
What website do I do it on
any cloud provider can host it
First you need to learn how to program
just ask chat gpt and it'll write it for you
Please do not ever recommend that to someone
you like co-pilot better?
try out GitHub Copilot
i want to try out the JetBrains AI, but they are pushing it too hard
JetBrains broke the copilot plugin when they introduced their AI
What do you use
i use AWS but that's pretty tricky
and you need to setup a credit card
Im sorry for your bank account
Dont even worry about a hosting provider
First get your bot working locally
i agree with this. get it working locally
You can figure that all out later
use ngrok
Can I give one of you my bot
no
no thanks
K
Well i can host your bots
💀
problem?
how dare you engage in enterprise
Huh?
just kidding
i shouldn't do it this way
Anything wrong?
?
Why do you react with a Skull when i Said that i can host the bots
cause I wanted to
Alr.
@sharp geyser this is funny
lmao me doing rust?
idk
no, that's groovy
that's passing the method as a reference
instead of calling it
I could also use .& but I prefer the dots
lul, doing a self-finding endpoint registrer
then found out I can simply return the methods on a switch and calling it after to avoid repeating the same thing again and again

i wrote this and made an npm script to run it. then i manually check in the index.js files. this should work
const fs = require('fs');
const path = require('path');
const rootPath = path.resolve(process.cwd(), 'interaction-handler/common');
const folders = fs.readdirSync(rootPath);
for (const folder of folders) {
// make sure folder is a directory
if (!fs.lstatSync(path.resolve(rootPath, folder)).isDirectory()) {
continue;
}
const folderPath = path.resolve(rootPath, folder);
const files = fs.readdirSync(folderPath)
// filter out index.js
.filter(file => file !== 'index.js');
const requireStatements = files.map(file => {
const fileName = file.split('.')[0];
return `const ${fileName} = require('./${fileName}');`;
}).join('\n');
const moduleExports = files.map(file => {
const fileName = file.split('.')[0];
return ` ${fileName},`;
}).join('\n');
const indexjs = `${requireStatements}\n\nmodule.exports = {\n${moduleExports}\n};`;
fs.writeFileSync(path.resolve(folderPath, 'index.js'), indexjs);
}
What problem were you trying to solve
manually creating these files
uh
well the idea behind barrel files is you add onto them as you go
not at the very end
💀
i wanted something like Project Lombok but for JS
im refactoring all the stuff out of the utility folder. it got too big
i just do that at runtime
like my index.js file is basically your script
im actually starting to think about not doing it at all.
i wont be able to use intellij refactoring once i make the change
i just want to clean up my imports so they aren't taking up so many lines
Java & rust
iirc php also uses it
and some of C#
using config = System.Configuration;
...
var value = config::ConfigurationManager.AppSettings["Somthing"];
``` 
yuh
what is :: in C# for
extern perhaps
namespace member access, static method access
(I think null meant C#)
oh
extern?
ohhh icic thanks :)
c++ also
i think time has come to design my own file system
goal is for it to be comparable to ext4
unlike ntfs which just dumps data anywhere it can fit it on the drive which kills hard drive performance
you wont always be able to put stuff in contiguous blocks so the amount of usable space drops dramatically. How often a user will have to defragment or you run a defrag operation could be frequent which is a very costly and lengthy operation
more so than just using free space
make ext5
Well, it surely kills hdd performance, not so much ssd performance
i have a question
do in lark there is the spanish punctuation
like inverted exclamation
and interrogation?
most languages are based on English, so unlikely
i see i need to convert into something that it can interpret
also how do i open a traceback object?
here it's suppose to be print exec:
not traceback object
i have no idea why this didn't defected cid as cidilhja
*cidilha
that is ç character when transforming
wait
now i realize i'm being stupid
can any math dude confirm whether x - (a - b) is always equal to b - (a - x)?
feels like a marco question
its a genuine math question, like mathematically is that formula equal or not
like how do you prove mathematically that one formula equals another formula?
ive thrown it into desmos and it would appear so, with the exception that the resulting coordinates are flipped
no idea what that means, but i guess the answer is true
if so, i've been bamboozled by IEEE 754
ah nevermind yeah they seem to be identical
It’s always equal
believe it or not, my program literally crashed because of this
You can work out the algebra but you get x - a + b = x - a + b
text version if you wanna try it out
360 - (357.2459354891127 - 18.56128351829587)```
probably some rounding error because of the order of operation
does it really matter though
my program crashed
because of it
lmao
return a === planet || (angleDistance(planet, a) < d && angleDistance(planet, b) < d);
``` this is why it crashed
floats shouldnt really be relied on for precise calculations because they suck
even if you have infinite precision because it will still eventually screw up
bamboozled by IEEE 754
I don’t see why this would crash it
i mean, the line doesnt crash, but it caused an index not found situation, which leads to cant read X of Y
IEEE754 isn’t fully accurate but iirc it uses a rounding error for checking equality
Actually maybe I’m wrong
There’s something called the epsilon value you might want to look into if you’re comparing floats
or use a library like decimaljs
what happened was:
i have 3 points in a circle, and need to find out if point A is after point B and before point C
so i check if point A equals point B, or if distance from A to B and distance from A to C are both smaller than distance from B to C
but due to that rounding error, A was not equal to B, but the distance from A to C was equal as the distance from B to C
biggest LMAO moment ever in my JS career
the reason why tim decided to retire from js
my code literally did the equivalent of X !== A && (X - B === A - B)
never trust float math, always use <= and >=
Need a Math.approx
i wonder if theres a bank that stores balance as a float
if so thats the easiest money glitch
I'm working on a library that does Math on strings
ofc, it will only do it if all characters are a digit or it has one . for floats
i just truncate, exponent them up, then recast
😔
Man. Why do all C programmers talk about STDs? I'm scared my computer will give me one if I start on a clang
theres many different std versions too
but you dont have to use the stds if you dont want to
is there any IDE that can refactor imports using barrel files? For instance if i wanted to move bar into group2 is that possible with refactoring tools?
DEC64 would have fixed this
Intellij/webstorm can no?
nope, nothing that i've seen. i asked in their forums
Then it's likely unfeasible/not doable
Perhaps it's due to the imports being relative, not full paths
In which case it'd not be possible to locate all references
I haven't heard back yet. Just asked, but I don't think it exists.
Try transforming the imports into full paths
It's possible, it would just need to parse the left side of the import.
And seeing if the refractor applies
There are some linters that will do that I think
Hello, where can i ask about my bot commit from a month ago ?
This one? #mod-logs message
ahahah no way, it has millions of help commands
it's even written in the bot description
fair 😄
If you have any questions, you can write to the person who checked your bot
Thank you

its wrong
Write a private message to the person who checked your bot. You can discuss with them whether the rejection is correct or not
yes i am in the middle of the dms
lol
@bitter granite did you create a channel that starts with avalon- as described and used the command aqh (= help) ?
The manual and comments describe what one should :
1/ run the command « asetup »
2/ run the command « aqh » to see the help
I described this very extensively in the notes for mods
is it really a bot coded by you?
i did and he reply
thank you
ok...
I already have 2 bots on here
What seems to be the issue ?
I’m the sole dev and I poured my soul into that one for the last 4 months.
k cool
send me a bot invite via dm
It’s in my profile description
Im on my phone , I’ll try to manage a copy paste but I’m not sure Discord mobile will let me
i found it
asetup
Aqh on the created channel
prefix?
it’s all in the chat like karuta
but the letter a is always the first letter
you don’t need the /
Just aqh
Why enforce a specific channel name?
It’s enforced as a good practice for servers who want to use it. Otherwise commands and spam of commands could be inadvertently triggered on any channel on the server. It also helps the privacy side of things as the bot only reads channels dedicated to the game from this practice. It doesn’t read the other channels on the server.
So what happens if I type a sentence that begins with a?
Couldn't u use a white-list for that?
Only actual commands will trigger a response
I say this cuz I know a plenty of servers that like to stylize their channels, with unicode stuff and all
Can you expand on what you mean with a whitelist ?
I whitelist channels and keywords
I could add this but that is just another way of looking at step 1
I create the channel for them in one command
Yes, but the name would be allowed to be anything
As explained , it only does something if its an actual command
Is that a request so the bot can be validated ?
Not really
Just a tip to avoid people discarding the bot cuz naming rules
For example one of the servers my bot is in
I see
People like to make naming patterns
Some don't even use normal characters
But those "cool" characters
what do you guys recommend for dashboard, do i have to make it myself from the ground up
theres a million different ways to make one and it gets pretty annoying
you can make a custom one if you want to but a lot of people opt in for using some managed service that handles the UI part of it and you just code the functionality
or use a dashboard template and edit it to work with you
ye thats what i want, i dont really have much experience making websites, and when ive searched up how to make a dashboard for your discord bot for example, the only "good" ones ive found just make them from the ground up
and it looks real ugly
dont wanna learn html, css, and js
My reply a little bit up
yeah just wanna say its not easy, i was in your position a few years ago
i ended up making an extremely simple one with the help of https://getbootstrap.com/
which helps you out with aspects of ui
Db call
was wondering where he got without a db from
They didn't, they're using a fixed-name rule
But well, to further answer you, I have a settings table that has a bunch of customizable settings for servers, which I retrieve for every command, so I always have it at hand anyway
Calling the db on each command ?
Well, in my case it's for every message lul
Databases are able to handle lots of calls
You can do for every command without issue
I do it for every message somply because prefix is customizable
These things are meant to handle hundreds of queries per second
Also for some other stuff like xp buffs and whatnot
Do note tho, in my case I cache unmodified entities
I just saw this
for help cmd
it needs to work without external permision (https://bit.ly/botperms)
and work in any channel without special channel name
^ @limber wigeon
^ also another reason why u should have a whitelist command if u want to restrict commands
Not everyone gives bots moderation perms
Db call every time someone uses a command in your bot is nothing, I save, read and update information in the database at the time of each new reddit post on several thousand subreddits 
Lmao
If my database can handle it, so can yours
I now wanna know how many read do you get per month
Someday I will have to create a system to analyze e.g. the number of posts in a month or something like that, but for now I don't feel like doing it
Update me if you did
The only database I ever found that struggled with constant transactions is firebird
i'd still put things like that in a small local cache but sure
but in these use cases it really doesnt matter
how can i bundle an entire js/ts project with dependencies
ive tried esbuild and some other things
but i kept getting Error: Dynamic require of "fs" is not supported
looks related https://github.com/evanw/esbuild/issues/1921
How can we use dependencies that still use require while shipping esm? Is that possible? Minimal reproduction: https://github.com/enricoschaaf/esbuild-issue Just run node index.mjs. This was genera...
looks iffy though did you try other things
depends on your use case though
Thank you for your reply. I appreciate it. I will allow the aqh command to work on any channel.
Yep
LongNumber
NumberLong
after a long day finally got my bots advertisement system too work properly now i get to rest and look at my masterpiece oonce i add a cooldown system too it
i haven't heard pocketmine in a while
was like 9 messing around with it for an mcpe server
its not my actual server i run its someone elses that im partnered with but the goal of the bot is to provide a useful multiutil mc discord bot
Isn't Pocketmine dead because java players can't connect? I think I heard about an engine that allows both platforms to connect 
yeah there was an engine and no pocketmine is still kinda alive
also how did you get the experienced role?
If I knew, I would tell you 
I just sit here and help and answer questions and stuff. There is no strict requirement to get it
not sure why this system wasnt implemented sooner
My understanding is that other bots similar to mine count on the fact that the admins of the server are going to limit the bot "read" right to the channels they want the bot to be used on
it was in like pckt mine 2 and 3
but not available in 4 nor 5
But giving full responsibility to admins has shown to be a very poor idea in the past
And that whole idea of having to run 1 sql request for every command to check if that channel on that server is allowed gives me nightmares of shame and despair
?
So I think i'll just do as other massively popular bots do and do nothing
I have made 22 million queries in the last 15 days, really 1 query per command is nothing that terrible and the database is unfortunately a must have in my opinion
Help me process that feeling because just reading this make me want to cry
Has technology advanced enough that we can call a database non stop or
That's the problem, databases were created for this purpose - to be able to process thousands of requests per second
It reminds me of how perfectly great games were 4Mb 20 years ago and are now 400Gb
like , What are we doing
welp ngl my bot saves random msg content for it automod system and refuses to delete them after a certain period as my bot forgets things in like 20 secs
just add a cache, its not a big deal, if the settings are not in the cache for that specific server, ask the database for it and store it in cache for future commands
that way you only have 1 database call for each server
caching will still cost a lot on reboots
it wont
only cache the servers that use the commands
that way you only cache the things that are in use and on the go
wait you pay to host your bot?
And put everything in a collection that is used to check allowed channels, yep, that's what i had in mind but still, if i get 50000+ servers, it might take a while
1€ / sql request yes (just kidding)
my bot uses sql for free lol
I use mariadb on an EC2 but it's not the point



