#development
1 messages · Page 220 of 1
lol
😔
you're cooking?
i'm learning
That’s cheating 😡
Honestly it’s better to manually roll out your own parser for your first few languages if your intent is to learn
expression → equality ;
equality → comparison ( ( "!=" | "==" ) comparison )* ;
comparison → term ( ( ">" | ">=" | "<" | "<=" ) term )* ;
term → factor ( ( "-" | "+" ) factor )* ;
factor → unary ( ( "/" | "*" ) unary )* ;
unary → ( "!" | "-" ) unary
| primary ;
primary → NUMBER | STRING | "true" | "false" | "nil"
| "(" expression ")" ;
@wheat mesa
HOW THE FUCK DOES THIS MAKE SENSE
😭
wait
Is it because expression evaluates to equality, which trickles down the ladder in terms of building a complete syntax?
because equality at the end of the day is making a reference to all of them
as each one references the next
I once fell into that trap
still not sure what it means by equality being the "lowest prescendence"
when I was writing my expression parser
I swear this book promised me it would have very little theory
😭
turns out the generated AST was impossible to work with
to process it all I'd have to write a very large file
https://craftinginterpreters.com/parsing-expressions.html#ambiguity-and-the-parsing-game this entire section makes no sense to me
😭
This book is making me realize just how dumb I am when it comes to programming
its not a good feeling
nah, making asts is like that
The words he uses to describe things granted is very dumbed down
but I still do not understand the concept and theory behind an AST and the grammar rules and such
yes
this is how you implement operator precedence at a parser level
you add a different rule for each level, and each rule feeds into the next until you get back to the bottom
the other option is you can do it all in one rule and then fix it with a second pass and a different parser dedicated just to operator precedence
which would be cool actually because then theoretically users could define their own operators with their own precedences
I see
I just have no idea how t oread that
like how would (9 / 3) * 2 look going based off those rules
like what is the order at which it is evaluated
cuz I see no way an expression like that can escape comparison since there is no comparison going on
so would it not get stuck at that parsing stage in the grammar?
no because look at the grammar
expression → equality ;
equality → comparison ( ( "!=" | "==" ) comparison )* ;
comparison → term ( ( ">" | ">=" | "<" | "<=" ) term )* ;
term → factor ( ( "-" | "+" ) factor )* ;
factor → unary ( ( "/" | "*" ) unary )* ;
unary → ( "!" | "-" ) unary
| primary ;
primary → NUMBER | STRING | "true" | "false" | "nil"
| "(" expression ")" ;
putting it here cuz tired of scrolling
term (('>' | ... | '<') term)*;
oh wait does the * mean 0 or more?
yes
so that means if there is 0 it moves on?
that rule is equivalent to term | term (('<' | ... | '>') term) (im actually not sure if * is 0-1 or 1+ or 0+ or what so yknow)
if it's the same as regex then 0+ but
term (('>' | ... | '<') term)*; what is the point of the term outside of the paren if its inside the paren as well
like term (('>' | ... | '<') term)*;
because
whats the point of that term
that's the part that enables everything
how so?
if there's no operator, it continues down the parse tree
1 + 1 / 1 -1 would be the term and then it allows for plugging in >
and then that 1 + 1 and 1 - 1 would continue trickling down the parse tree until it is associated properly
but if you were simply doing 1 + 1
it'd go
expression -> equality nothing there -> comparison nothing there -> term ah there is a + -> 1 & 1 move on to factor nothing there -> unary nothing -> primary ah 1 & 1 are numbers -> primary (NUMBER) term (+) primary (NUMBER)
expression: group1 (('+' | '-') group1)*;
group1: group2 (('*' | '/') group2)*;
group2: unary group3 | group3;
group3: '(' expression ')' | atom;
atom: NUMBER;
that's a simpler grammar
i might actually even write a simpler lexer and parser to demonstrate it hold on
is this correct?
something like that
@sharp geyser wrote a quick parser for that expression, this is the result of parsing -2 * (3 + 4)
i'm also stupid and forgot to parse group 2 i think lol
oh wait no i just named it wrong
ok that's the actual result
hm ic
you were right
oh was i
kekw
So all a CFG is, is just plugging in values once they are determined
and sometimes they can be indefinite if you don't specify an escape condition like say allowing it to be 0 or more, or an empty character or something else in the grammar
like
S -> aSB
B -> b
this would cause an indefinitely loop of aabbabbbabbb or smth
I am going based off a video I just watched and notes someone sent me on understanding a CFG
private Expr Primary()
{
if (MatchExpr(TokenType.FALSE)) return new Expr.Literal(false);
if (MatchExpr(TokenType.TRUE)) return new Expr.Literal(true);
if (MatchExpr(TokenType.NIL)) return new Expr.Literal(null);
if(MatchExpr(TokenType.NUMBER, TokenType.STRING))
{
return new Expr.Literal(Previous().literal);
}
if(MatchExpr(TokenType.LEFT_PAREN))
{
Expr expr = Expression();
Consume(TokenType.RIGHT_BRACE, "Expected a ')' after expression");
return new Expr.Grouping(expr);
}
// How would I handle this return case?
}
So what should I return if none of the MatchExpr follow through? I was thinking of somehow making it return a EOF token but idk how that'd work
The java code for this is weird because java will accept any return statement as an ending, C# on the other hand needs a top level return as well e.g one directly returning in the scope of the function and not inside an if statement or smth
I don't necessarily want to return a null literal do i?
cause my first thought might of been to do
private Expr Primary()
{
if (MatchExpr(TokenType.FALSE)) return new Expr.Literal(false);
if (MatchExpr(TokenType.TRUE)) return new Expr.Literal(true);
if (MatchExpr(TokenType.NIL)) return new Expr.Literal(null);
if(MatchExpr(TokenType.NUMBER, TokenType.STRING))
{
return new Expr.Literal(Previous().literal);
}
if(MatchExpr(TokenType.LEFT_PAREN))
{
Expr expr = Expression();
Consume(TokenType.RIGHT_BRACE, "Expected a ')' after expression");
return new Expr.Grouping(expr);
}
// How would I handle this return case?
return new Expr.Literal(null)
}
but that seems counter-productive to what the code is trying to do which is do nothing if none of the if statements match.
looks like you fianlly understand the tokens
yea
it was easy to understand after breaking it down and thinking ofi t like placeholders
const fs = require('fs');
const client = new Client({
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MESSAGES
]
});
client.commands = new Map();
// Load commands
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
client.commands.set(command.name, command);
}
// Load event handlers
const eventFiles = fs.readdirSync('./events').filter(file => file.endsWith('.js'));
for (const file of eventFiles) {
const event = require(`./events/${file}`);
if (event.once) {
client.once(event.name, (...args) => event.execute(...args, client));
} else {
client.on(event.name, (...args) => event.execute(...args, client));
}
}
client.login('Token');```
What is wrong with this?
It looks like it works without any problems. What error do you have in the console?
^
TypeError: Cannot read properties of undefined (reading 'FLAGS')
at Object.<anonymous> (D:\Invite Manager\index.js:6:17)
at Module._compile (node:internal/modules/cjs/loader:1434:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1518:10)
at Module.load (node:internal/modules/cjs/loader:1249:32)
at Module._load (node:internal/modules/cjs/loader:1065:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:158:12)
at node:internal/main/run_main_module:30:49```
So you are using discord.js v14 right?
yes
Intents has been changed to GatewayIntentBits in v14
https://discordjs.guide/additional-info/changes-in-v14.html#enum-values
What GatewayIntentBits would i need?
It's your bot, you should know what intents it needs 
where did it go wrong 💔
Is server.Guild one?
lmao another naming update just for the sake of updating
const fs = require('fs');
const client = new Client
intents:
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMembers,
client.commands = new Collection();
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
client.commands.set(command.data.name, command);
}
const eventFiles = fs.readdirSync('./events').filter(file => file.endsWith('.js'));
for (const file of eventFiles) {
const event = require(`./events/${file}`);
if (event.once) {
client.once(event.name, (...args) => event.execute(...args, client));
} else {
client.on(event.name, (...args) => event.execute(...args, client));
}
}
client.login('Token');```
Says ClientMissingIntents
they even changed the uppercase constant to pascalcase
Let me guess what is wrong here 
I have no idea where all your brackets went
should I continue optimizing some endpoints or is this good enough? (db is on same server, so 0 ping)
Why is my commands not syncing with discord?
Because you have to register them in the Discord API
Now i did that
DId the API
Now what
Now the commands should pop up when you type /
Nope
I have 3 other ones but i deleted those
Do i have to add it in my index.js?
I don't quite understand what you mean now. Have you registered commands before?
Nope just started today kinda
exactly
Generally, this should not be added to index.js because the code from it is fired every time the bot is turned on. You don't want to register commands again every time your bot starts, only when the situation requires it. Therefore, it is recommended to create a separate file for deploying commands
hard to say without context, but i see a fucking high failure rate on some
well failure rate = 4xx or 5xx
most are just ratelimits or unauthenticated
feeling cute might make my own wiki alternative to mediawiki for no reason
private void Syncronize()
{
Advance();
while (!IsAtEnd())
{
if (Previous().type == TokenType.SEMICOLON) return;
switch (Peek().type)
{
case TokenType.CLASS:
case TokenType.FUN:
case TokenType.VAR:
case TokenType.FOR:
case TokenType.IF:
case TokenType.WHILE:
case TokenType.PRINT:
case TokenType.RETURN:
return;
}
Advance();
}
}
Not quite sure what this is exactly doing
It has to do with something about synchronizing the recursive descent parser's state
But I dont quite understand how it is doingthat
all its doing is returning whenever it runs ito the keywords class, fun, var, for, if, while, print and return
oh and a semi then it consumes that token moving on
Pulled directly from the book
With recursive descent, the parser’s state—which rules it is in the middle of recognizing—is not stored explicitly in fields. Instead, we use Java’s own call stack to track what the parser is doing. Each rule in the middle of being parsed is a call frame on the stack. In order to reset that state, we need to clear out those call frames.
The natural way to do that in Java is exceptions. When we want to synchronize, we throw that ParseError object. Higher up in the method for the grammar rule we are synchronizing to, we’ll catch it. Since we synchronize on statement boundaries, we’ll catch the exception there. After the exception is caught, the parser is in the right state. All that’s left is to synchronize the tokens.
We want to discard tokens until we’re right at the beginning of the next statement. That boundary is pretty easy to spot—it’s one of the main reasons we picked it. After a semicolon, we’re probably finished with a statement. Most statements start with a keyword—for, if, return, var, etc. When the next token is any of those, we’re probably about to start a statement.
It says it makes use of the call stack, but idk if that applies to C# as well (im sure it does since they both are similar in how they compile I think)
Side Note:
I have this string representation of my AST: (/ (* (group (* 2 10)) 40) 3)
Is this how it'd look like written out?
const placementDisplay = require("../record_match/placementDisplay");
const displayLeaderboard = (elo_ratings) => {
if (elo_ratings.length === 0) {
return `No players have played any matches yet. Use \`/record_match\` to record a match.`;
}
let leaderboard = "";
const limit = 4096;
for (const eloRating of elo_ratings) {
// Skip hidden ratings
if (eloRating.hidden) {
continue;
}
// the next line to add to the leaderboard
const nextLine = `${placementDisplay(eloRating.placement)} ${
eloRating.players.map(p => `**__${p.name}__**`).join(" ■ ")
} ${eloRating.elo}\n`
// the potential length of the leaderboard if the next line is added
const potentialLeaderboardLength = leaderboard.length + nextLine.length;
// if the next line would exceed the 4096-character limit, break the loop
if (potentialLeaderboardLength > limit) {
console.log("Leaderboard too long, breaking");
break;
}
// add the next line to the leaderboard
leaderboard += nextLine;
}
return leaderboard.trim();
}
module.exports = displayLeaderboard;
I am trying to prevent discord from trimming the message in the middle of a line, but it seems to be trimming some of the message. are there too many new lines \n?
what is discord doing to my messages?
i believe the 4k limit for embeds includes title and other text fields
so all texts combined cannot exceed 4k
the trimming is weird tho, one would think it would error instead
embed description
so yeah idk
are you using a library or raw api?
wrong chat
it seems to be related to emojis
what if you remove those first 3 emojis?
emojis count towards the limit in their full form name:id, not in their short form
the emojis are being sent as text like this :first_place:
oh yeah, that would be longer. i only have those 3 emojis
what about the squares in the middle?
there is a chance discord counts them as 2 characters
perhaps, let me check
also a weird things how Player 2 was removed, but the elo is there and the placement for the next line is there
what if you remove the formatting
it's the formatting
discord must have some sort of bug there
they count characters based on how its rendered
not the characters you send
maybe the rendering turns into html
and they count the full tags
there is a 4096 character limit that the API enforces. you will get an error back from the API if you send too many characters
but i am sending less than 4096 characters so the API accepts it, but still cuts it down in size
there are some issues about it on their gh
i think they have a bug like this somewhere too
const tokens = [
"102nd ", "**__Player 1__** ", '1000\n',
"103rd ", "**__Player 1__** ", '1000\n',
];
const maxLength = 20;
const description = tokens.reduce((acc, token) => {
if (acc.length + token.length > maxLength) {
return acc;
}
return acc + token;
}, "");
console.log(description);```
that's how this happened
quite likely
and they run that after transforming and formatting the text
which probably turns it into html
@river flicker
could be this too
ong
Array.from splits the string in terms of unicode codepoints, while string itself is internally encoded in UTF-8 iirc
the weird thing is that i can retrieve the whole message using the API. it's just when it displays in discord that it cuts down the message
if it's longer than 4096 it rejects the message
I think this is mainly due to them increasing the limit for nitro users
and bots have basically nitro limits on messages
no it's a bug
6000 total and 4096 for the description alone
if you go above it rejects the message
it's this. like 4080 or something like that
4069
open discord in the browser, inspect element your embed
chatgpt moment
not entirely wrong
whats the character count of the entire content?
including the html tags
7196
weird
what about the count without the newline spans?
counting only the content and the strong/u tags
// Check if the bot has permission to send messages in the music channel
if (!interaction.guild.me.permissionsIn(musicChannel).has(PermissionsBitField.Flags.SendMessages)) {
return interaction.reply("I don't have permissions to send messages in that channel.").catch(err => {
client.error(err);
});
}
its not working am i missing something?
Shouldn't it be ineraction.guild.members.me? 
like this?
hmm
im guessing they count the characters from the formatting tags but dont count the spans for newlines
hmm i try that and array return this
[
'CreateInstantInvite', 'AddReactions',
'Stream', 'SendMessages',
'EmbedLinks', 'AttachFiles',
'ReadMessageHistory', 'UseExternalEmojis',
'Speak', 'UseVAD',
'ChangeNickname', 'UseApplicationCommands',
'RequestToSpeak', 'CreatePublicThreads',
'CreatePrivateThreads', 'UseExternalStickers',
'SendMessagesInThreads', 'UseEmbeddedActivities',
'UseSoundboard', 'UseExternalSounds',
'SendVoiceMessages', 'SendPolls'
]
when bot dont have send message permission in that channel
the math still doesnt addup completely tho
im guessign you could open an issue on their github and wee what they say
perhaps
But this array is not in the if statemant you sent above, so it shows up when the bot have permission to send messages, right?
gaming
I sense ChatGPT
Gotta be cursed.
wym cursed
What
hmmm, i forgot, triviabot is keeping a count of http requests by status code for posting webhooks
since i started counting, about 3 years ago, triviabot has sent 90 million messages 😮
that is just... absolutely nuts
the misaligned arm was triggering my ocd
LMAO
Bros arm was detatched
Eh?…jit used the LAWS OF PHYSICS
"well a pro made it"
guys does this look like a pro's work
yes
what about a throw error statement without a catch block
if they leave whos going to fix it
Gotta secure your own job!
it's sorta getting out of hand now
is something being read wrong?
How are we supposed to know
yeah I dont really know either atp
Do you have any errors?
no errors
If something is going wrong, its highly likely the error is being dismissed
lemme just try something that could break the whole thing
actually I wont do that
found the problem
when someone votes it doesnt get pushed to the database
no idea how to fix it
¯_(ツ)_/¯
module.exports = async (data: VoteUser) => {
getCollection("votes").updateOne({id: data.user_id}, {"$push": {votes: {at: Date.now(), source: data.source}}}, {upsert: true});
addEvent({
type: "vote",
command: "vote",
source: data.source
});
}
this isnt working?
it should be though
did you await
updateOne could fail
has anyone been able to successfully change their verified bot's name?
like did discord let you
I have never had such a need, but someone on DDevs wrote that it is not that simple because you also need to have some reason to do it
I found this message
Possibke but super hard
Basicly you need a reason
Usualy it needs to be legal reason
you can probably make some shit up
like some arbitrary company that has a similar name to your bot is threatening to sue for it
doubt theyll investigate it
"We need proof" 
or just rebrand and thats probably a good enough reason
register your bot's name as a trademark, sue yourself, profit
are you edging because of webp+gzip combo
yes
@lyric mountain do u know how to publish a jar file to sonatype?
i tried looking up online and it seemed that some of the results are outdated
You don't publish a jar file, you deploy
what's the difference
You never upload a file, you build there + source and javadocs
noooooo 😭
You'll use sonatype plugin for this
my java library involves some native binaries
If it's in the classpath I think it's sent together with anything else
the native binary files are stored in a zip file in the repository
and unzipped before being built to a jar
Well
You'll need to include it as a resource
As in, the resources folder
Then call it from there
resource?
like this? ```
jar {
from('./bin') {
include '.dll'
include '.dylib'
include '*.so'
}
}
what about this though
put in resources folder, anything there will be included in the output
you can also instruct the users to download one of the native bundles and put it in a predictable folder in the project
might work, I'm unsure how they'll show it after deployal tho
packages deployed through the plugin are signed and checked for CVEs automatically
I figure its about time I play with redis. Does anyone have an NPM lib they use/reccomend? 👀
👍
quick tip, setup a linux dev environment
you'll have a hard time trying to get redis to work on windows
Yeah, I'm on linux anyway
you're fine then
Also isn't redis no longer free & open source?
Some parts are iirc
yea they changed their licenses and caused an outroar
dk if they changed em back or not
changing license midway on a very popular project just means people will fork the hell out of it while the original thing falls to oblivion
cant think of a single case where it worked out well
Its still too early to tell which fork will survive and be maintained, so for now redis will work for me
keydb ftw
Hey why my application cant be launched using the installed tab. It says lsunch override only
making your own redis ftw
const result = binding.readdir(
^
Error: ENOTDIR: not a directory, scandir 'D:\Invite Manager\commands\ping.js'
at Object.readdirSync (node:fs:1509:26)
at Object.<anonymous> (D:\Invite Manager\index.js:15:26)
at Module._compile (node:internal/modules/cjs/loader:1434:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1518:10)
at Module.load (node:internal/modules/cjs/loader:1249:32)
at Module._load (node:internal/modules/cjs/loader:1065:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:158:12)
at node:internal/main/run_main_module:30:49 {
errno: -4052,
code: 'ENOTDIR',
syscall: 'scandir',
path: 'D:\Invite Manager\commands\ping.js'
How do i fix that
average person asking for help about code
you did not provide code and the error is a little obvious
Oh shoot
I just started
Without the code it's hard to say how to fix it
you're trying to use readdir on a file
What's that?
...did you copy the bot from somewhere?
I was on the Discord.js guide
So kinda
I'd advise against trying to make a bot without any introduction to coding whatsoever
you'll very likely end up with a non-functional bot or be unable to do anything outside what's written in the guides
but well, to answer your question, readdir which is likely being used to dynamically load commands cannot be used on files, as files aren't directories
for files you use require instead
KO4 memes before release
I still dont get why ur posting it here
you cant
it tells you what to do
that doesnt matter
you need to be logged in on the registry
and authorize that machine to make publishes
hey thanks no thanks i had to add registry-url to actions/setup-node
import { VoteUser } from './VoteUser';
import { getCollection } from '../mongo';
import { addEvent } from '../functions';
module.exports = async (data: VoteUser) => {
await getCollection("votes").updateOne(
{ id: data.user_id },
{ "$push": { votes: { at: Date.now(), source: data.source } } },
{ upsert: true }
);
await addEvent({
type: "vote",
command: "vote",
source: data.source
});
}
it still doesnt push
is addEvent async
also
actually
run a debugger
insert breakpoint on addEvent
see if it hits
and also, log the result of updateOne and verify if it's updated successfully
import { VoteUser } from './VoteUser';
import { getCollection } from '../mongo';
import { addEvent } from '../functions';
module.exports = async (data: VoteUser) => {
try {
await getCollection("votes").updateOne(
{ id: data.user_id },
{ "$push": { votes: { at: Date.now(), source: data.source } } },
{ upsert: true }
);
} catch (error) {
console.error('Error updating votes collection:', error);
throw new Error('Failed to update votes collection');
}
try {
debugger;
await addEvent({
type: "vote",
command: "vote",
source: data.source
});
} catch (error) {
console.error('Error adding event:', error);
throw new Error('Failed to add event (u suk ballz at coding)');
}
}
I havent tested it
tim says bye
@lyric mountain sir
lmao nah
wait
skytable is a db
so why is it being compared to redis
redis isn't really a database
its a caching layer at most
tf is blueql
is it their custom sql language

it honestly looks rather neat
the first nosql db that actually looks promising
i hate to say it but it looks just like postgres with extra steps with mongodb roots
aye?
Indeed, but as a nosql db
it looks more promising than mongodb
as far as nosql goes i'd rather use something like this than mongodb
do you want to help with an sql query
const stats = await client.$queryRawUnsafe<{
type: MinecraftServerType
minecraft: BigInt
project: BigInt
builds: BigInt
}[]>(types.map((type) => `
SELECT
'${type}' AS type,
(SELECT COUNT(*)
FROM "minecraftVersions" mv
WHERE EXISTS (
SELECT 1
FROM "minecraftServerBuilds" b
WHERE b."versionId" = mv.id
AND b.type = '${type}'
)
) AS minecraft,
(SELECT COUNT(*)
FROM "projectVersions" pv
WHERE EXISTS (
SELECT 1
FROM "minecraftServerBuilds" b
WHERE b."projectVersionId" = pv.id
AND b.type = '${type}'
)
) AS project,
(SELECT COUNT(*)
FROM "minecraftServerBuilds" msb
WHERE msb."type" = '${type}'
) AS builds
`).join(`
UNION ALL
`).concat(';')
)```
this is my current solution
minecraft?
first tell me what u want
for each type in the "MinecraftServerType" enum, I want to know how many builds, projectVersions and minecraftVersions
yes
why are u doing union all?
I really do not know
its slightly faster than what i had before
but still quite slow
a bit busy atm, I'll come back in a few mins
k
[ERROR] [9055:12:36] at resolveColor (/home/simplyreact/node_modules/discord.js/src/util/Util.js:260:63)
[ERROR] [9055:12:36] at EmbedBuilder.setColor (/home/simplyreact/node_modules/discord.js/src/structures/EmbedBuilder.js:22:36)
[ERROR] [9055:12:36] at module.exports (/home/simplyreact/out/events/interactionCreateModal.js:21:65)
[ERROR] [9055:12:36] at Client.emit (node:events:513:28)
[ERROR] [9055:12:36] at module.exports (/home/simplyreact/out/events/interactionCreate.js:9:13)
[ERROR] [9055:12:36] at Client.emit (node:events:513:28)
[ERROR] [9055:12:36] at InteractionCreateAction.handle (/home/simplyreact/node_modules/discord.js/src/client/actions/InteractionCreate.js:97:12)
[ERROR] [9055:12:36] at module.exports [as INTERACTION_CREATE] (/home/simplyreact/node_modules/discord.js/src/client/websocket/handlers/INTERACTION_CREATE.js:4:36)
[ERROR] [9055:12:36] at WebSocketManager.handlePacket (/home/simplyreact/node_modules/discord.js/src/client/websocket/WebSocketManager.js:352:31)
[ERROR] [9055:12:36] at WebSocketShard.onPacket (/home/simplyreact/node_modules/discord.js/src/client/websocket/WebSocketShard.js:494:22) {
[ERROR] [9055:12:36] code: 'ColorConvert'
[ERROR] [9055:12:36] }
💀
im so done
is this by any chance vulnerable to sql injection
funnily enough thats how most sql injection cases occur
developers assume a certain value is always controlled by them but forget about that one small factor
thats why I am only using unsafe query in this one place in my entire codebase
types is a constant array
readonly
from what i understand, dont you need to access all rows to get the counts you need?
if you need a full table scan anyway, theres not much you can do to make it faster than a full table scan
well
I have a feeling im doing multiple
because a full scan is very quick in my case
only ~2mil rows in all those tables
you might as well SELECT buildNumber, versionId, projectVersionId from MinecraftServerBuilds
and then count it in js
rip my ram
i guess you can make sql do it somehow, from only 1 table scan
try this
SELECT buildNumber, versionId, projectVersionId, COUNT(*) FROM MinecraftServerBuilds GROUP BY buildNumber, versionId, projectVersionId
I feel so wrong 💀💀💀💀💀
How does this have anything remotely to do with the development channel
circles
red
color
color = something used in discordjs
lets first establish a baseline, how fast is it if you just run multiple queries? SELECT COUNT(*) FROM minecraftServerBuilds WHERE type = "${type}"
This seems like some wild roleplay type shit
dont tell me top.gg roleplay is making a comeback /j
27ms for paper
28ms for quilt
pretty much all around 30ms
well
yea but I bet you can make it faster tim
you are the god of optimization
minecraftServerBuilds is 104k rows
i see
and for each type, you want an output like this? builds: 7375, versions: 783453, projectVersions: 495983953
yes
@quartz kindle I have found the solution
SELECT
"type",
COUNT(DISTINCT "versionId") AS versions,
COUNT(DISTINCT "projectVersionId") AS project_versions,
COUNT(*) AS builds
FROM
"minecraftServerBuilds"
GROUP BY
"type";
149ms
cool
i didnt even know you could do this tbh
you can compound count ofc
just for the heck of it, what would be the performance of dumping 104k rows and counting in js?
lmao
I think this phenomenon is called "v8 stack trace: "
xD
super fast, but make sure to make 1 request per row.
for the performance
jenius
also, is type indexed?
ah yes
well, type apparently isnt
lmao
ahh hell nah, i hired a fiverr developer for some graphics they gave me doodo
deadass served me shit
70$ for this bitch ass
lol
ah yes, an update is available!
runs pnpm update
"Already up to date"
runs pnpm update next
"Already up to date"
:(
well
update follows semver
it does not update major automatically
you need to edit package.json for that or do pnpm i eslint@latest
ughhh
beware of eslint v9 tho
if you're still using the eslintrc file you're gonna have a bad time
compatibility shucks with extensions i think
just on the latest v8 for now
as long as it works..
yea i didnt really like how the settings for rules were done
no types either..
just pray it works
barely updated it nvm
@frosty gale Are you familiar with using DNSSec over regular DNS?
havent heard of it 😦
It's over for me.
I need to migrate to DNSSec with 0% practical knowledge, only theory
no
yup
just saw 5 websites
owned and operated by the same company
with the same similair designs
selling the same products
competing against urself..
5 of them is crazy

and all 5 of them probably generate revenue
don't hate the player hate the game
gotta make money in this world
anyone have a good strategy for tagging players in a lobby while staying within the character limit?
i had a lobby of 96 people, tried to tag all players that the game is about to start then crash’s with 2000 characters limit
just dont
1 method you can do is make a channel jsut for that lobby
so you can ping everyone
:)
i was thinking have the server owner create a role for the game, bot will assign it when they hit “join” and when the game starts it’ll say “Game is starting @(role name)” so they get pinged and the bot just removes it from everyone once the game ends.. is this possible?
Yes
but relying on the server owner to do so is ill advised
just make it yourself
assign people to it when they join and when the game starts and ping em
remove role from em at the end
Note you will run into limits doing this
so its better to create a private channel, have an array of ids. that you will use for channel overwrites making it so only those people can view the channel disallowing everyone else
and then ping everyone
ahhhh that’s a good idea
Is typescript easier than most languages?
const channel = await guild.channels.create('somename', {
permissionOverwrites: [
{
id: arrayOfIds
allow: [arrayOfPermissionBitFlags]
},
{
id: guild.id,
deny: [PermissionBit.Flags.ViewChannel] // or smth idk
}
]
})
I might be wrong on the arrayOfIds part
but iirc you can use an array of ids
if not
just loop through the array of members in the lobby and make a permission overwrite for each of em
const channel = await guild.channels.create('somename', {
permissionOverwrites: [
{
id: guild.id,
deny: [PermissionBit.Flags.ViewChannel] // or smth idk
},
...arrayOfMembers.map((r) => { return { id: r.id, allow: [ViewChannelPermission] } })
]
})
I think that could work idk
Haven't done js in a while
nvm
there we go
that should work
:)
@past field try this when creating the channel
dont have to follow it exact but this is one way to do it
i’ll try this!!
"easier" no
Someone said it was
typescript is the same thing as javascript but with an extra safety layer where you have to declare the types you are using
for example, in tyopescript you dont do const abc = 1, you do const abc: number = 1
you can still do const abc = 1
just illustrating an example ignoring inference for now
Ohh
typescript is only useful when you want to enforce the type of something, like a class declearation, or a function declaration
generics are also helpful unless you are using js
the idea is that with typescript you have more control over the types of things you are using, instead of letting javascript guess them

So less errors?
It also prevents stuff like say a function takes in a parameter of a string but you give it a number
so it will error before runtime
because types dont match
nope, much more errors
but thats the point of ts
it errors more because it has more typesafety
it forces you to think in terms of types rather than js's way of "ah yes this will work for now"
javascript forgives your mistakes and tries to run anyway
typescript doesnt forgive you and wont let you run unless the code is actually good
yup and thats the beauty of the type system
imo at least
js's way of thinking is flawed imo
What about PY?
py also has types yes
py is a different language altogether, it uses indentation as the main way to organize your code
so for example
I love how thats the difference you point out, and not its biggest flaw
no you dont
that brain is a curse
you constantly want to optimize everything
the horror
the pain
I feel bad for tim
i curse a lot so it works out.
😔
if(a) {
b;
}
if(a) { b; }
``` these are both the same thing in js, it uses the brackets, regardless of spaces and new lines
```py
if a:
b
``` with py the `b` needs to be exactly where it is, one line below and more to the right >>>
tim is at the top of a lonely tower of optimization
I loved fucking with people's py code by spamming tab in random places or putting a hidden character

lmao
"BUT THERE IS NO FUCKING SPACE"
So py is more strict
its not more strict, its different
if you want a strict language learn C++
spaces and newlines have meaning, where in js they dont
js uses () and {} to define blocks and limits, py uses spaces and newlines instead, less typing but you need to pay more attention
I dont think anything matters in js https://github.com/top-gg/Luca/blob/master/bot.js#L215-L243
JS is so hard 😦
what kind of bot are you trying to make?
Ah yes the beauty of JS
its hard because you're a beginner
otherwise js is one of the easier languages out there
I am trying to make a bump bot 🙂
JS is easy if learned the right way
if you want to learn programming, be prepared to spend at least a few months learning
just like you would when learning a foreign language
for example french or italian
I used chatgpt and max said around 5 months to actually get good good
all depends on your conviction
If you go into it not wanting to spend the time to learn it it will take longer
but if you sit down and take the time to learn it, you will acheive great results
How would I learn?
For months on end
If you dont want to spend the time to learn
programming is not right for you
Programming is not something you learn over night, or quickly
when learning a foreign language, how do you start? you dont read a book in french to learn french
you start with the basics, basic grammar rules, basic words and their meanings
Yeahhhh
but I read a book in js to learn js
😏
Be honest how many languages do yoy know?
a few
🤥
Bruh
How can yoy remember it all?
and some c++
I've been programming for 7 years
It just sticks after a while

once you understand programming in general, its much easier to learn new languages, as they all share common traits
I don't memorize the entire langauge by heart no
but I know the basics
and I know how to google what I dont know
every language shares the basics for the most part
So there is var | let | const
Strings, Ints, Bools
Var is variable so like numbers right?
don't use var
Why not?
var has some issues perserving scope (or whatever its called)
for example, most languages have variables, most languages have if else conditions, most languages have loops
there are a lot of things that programming languages share, they just do it a little different, with different keywords, different syntaxes
let is for variables you want to be mutable meaning you can reassign the values of
const = constant
meaning it will ALWAYS be that value you set
it cannot be reassigned
Yeah
so you can do
let a = 5;
a = 7
console.log(a) // 7
but you cant do
const b = 5;
b = 7; // errors here because b is a constant
console.log(b);
What's scope?
I can give you an example
const a = 5;
function b() {
const c = 6;
}
console.log(a) // 5
console.log(c) // Will error because C is defined inside the scope of a function
Basically scope is like a boundary
Anything defined inside that function, cannot be used outside of it
there are 3 types of scopes, global, function and block
// this is the global scope
function abc() {
// this is a function scope
}
if() {
// this is a block scope
}
yo ucan also make a separate scope inside stuff right
like
function abc() {
let a = 5;
{
let b = 6;
}
console.log(a + b) // will error because b is defined in its own scope
}``` right tim?
or am I mixing up languages
yup
😔
basically anything inside of {} is its own scope
it separates whats inside from whats outside
So in a ping command what would i use?
thats like asking "now that i know how to say dog and cat in french, how do i read a french book?"
Like I do /ping bot will say Pong
it'd be either a block scope or a function scope
What scope would I use?
you use whatever the library tells you to use
discord.js is a big big program created to help you connect with discord
I am gonna ask a stupid question but what's library mean in code
discord.js is the one that tells you what you should use
discord.js is a library
Yoy would get a error if you use a wrong one?
a library is a big piece of javascript code that someone else wrote and you can use by downloading and installing it
its a collection of code that helps you make something
ima go tho so ima let tim explain any other questions oyu have
bye guys
Lol
i g2g
Lmao
Yoy guys can leave
shut up sky
🙂
Sowwy

You made a bot you can help me 😉
Everything
I still dont even know the issue myself
Cause we aren't going to teach you how to program
thats up to you
All we do is guide you in the problems you face while programming
But yoy guys are amazing teachers
Oh he doesnt have a bot yet?
Nope not even close
Right but there isn't enough time in the world for me to help you every step of the way
you have to be reliant on your own self

Yuh
Best resource I can give you
It teaches a lot about JS
Sorry
we don't troll new people in this channel
I have makes a blurry sense
I understand some of it
But not all
Kinda
It's like 75% I don't know
have you heard about the dunning kruger effect?
xD
Anything you dont understand ask here
No what's that?
Ok ty so much 🙂
Cognitive bias in which incompetent people tend to assess themselves as skilled
Its the peak of mount stupid stuff
Oh
its expected that it wont make sense to you at all
😭
not wrong tho
Swear learning language development makes me think im in that valley of despair
Programming spawned in my Head
your head spawned in programming

Idfk i understood everything so fast
your spawning in head programming

there is still a lot you dont know
How fast?
trust me bro
Yes i know
I bet that is true
Programming is something you will never master
How many servers your bot got
There will ALWAYS be something to learn
400
Just wondering no hate at all
I bet even the actual language developers of the langs you guys use don't know their own language fully
💀
Nice
400... um... speed
Not the best
When was it made?
He made that bot last month
1 month ago
How already 400
Fr
and all his bot does is play tictactoe
Lmao
indeed
Agreed
Was it hard it make a tictac toe bot?
his uses ai
a good specific purpose bot will take you far, provided its not too niche
Mine is very niche
It will still reach millions of servers
trust

hueheuhue
The only thing i don't understand is the index that trips me up
mine is hard stuck for like 2 years now
Lol
lel
idk how but hte magical effect of C++
gonna use D++
Use brainfuck
makes bos succeed
Do people even make Bots in that?
Time to recode TicTacToe
D++ is made in C++ which is more memory efficient
Into C++??????
for reference, D++ is a discord library, like discord.js, but for C++
it stands for Discord++
So once you get into those thousands of servers most people go libless or swap to a more memory efficient language
like C++
Yuh
tell that to all those top 20 bots that use js and py
Those bots are so deep in they can't be arsed to change
it'd be cheaper buying more server room than hiring devs that specialize in C++ or some other language
Some have 11k and they use JS is that bad or good?
JS only becomes a limitation at large amounts of servers
Mac's bot uses 16gb of ram
some have 5 million servers and use js
Lmao
Why? And how
thousands
Imagine
Your bot is free for you
depends on who they go through
No its not
Do yoy host it your self or hosting servers?
google compute engine
Once your bot is in millions of servers it becomes a job
Self
It makes enough money to sustain you most of the time
Those dyno devs make BANK
sapphire is a shit bot ngl
@warm imp all of my Stuff is hosted on my local Servers
oh god
giving sky another chance to flex his servers
No
Serwers
sewers

When yoy make new commands do yoy have to add it in the index.js and your handlers?
im playing maplestory
no idea what that is
makes sense
oh wait that game
nvm I do know what that is
god haven't played that in AGES
Handlers
lmao
let me give you a suggestion
forget about slash commands for now
play around with text commands instead
for example !ping
Pong! 9ms
you will need to configure something in your discord app tho
but its gonna be much much easier to start with
and you're gonna have a better time understanding whats going on
also forget about handlers and all that crap
Would I need to import that in my index.js if I make it
only if you continue using handlers
i would recommend not using handlers for now
stick the the basics
Everything has to be sorted otherwise I can't cope
Same






