#development

1 messages · Page 189 of 1

pale vessel
#

lel

frosty gale
#

anyone know if javascript has a function for comparing two strings with resistance to timing attacks?

#

ill probably need to use a library for this but would be nice if crypto had it built in

#

wanted to tag voltrex but of course hes banned

#

at this point theyre banning anyone remotely useful and competent

lyric mountain
#

there's still tim

frosty gale
#

@quartz kindle any ideas?

lyric mountain
#

but well, if both sides are hashes, how would a timing attack work?

frosty gale
#

id of course use a password hashing and comparing library for this usually but in this case i dont need anything hashing just some simple resistance to timing attacks

harsh nova
lyric mountain
#

I'm still green regarding hacker attacks and exploits

frosty gale
#

but i think hashes are pretty good when it comes to timing attack resistance

lyric mountain
#

ok so lemme rephrase: why are those passwords not hashed?

frosty gale
#

its too simple and i need to be able to change the passwords via a config file quickly

#

dont worry this is not production work

#

i think you can make your own timing resistant compare function with some random iterations and delays but i think someone sophisticated enough can filter through that with statistics

quartz kindle
#

why is voltrex banned lol

lyric mountain
#

well, couldn't you add a random ms delay at one of the steps?

frosty gale
lyric mountain
#

this would give fake info to the attacker

harsh nova
#

Silly question but why are you worrying about timing attacks if it ain't prod anyhow? Genuine question as I'm dumb not tryin to question the decision itself

lyric mountain
#

but that's as deep as my knowledge about it goes

#

nobody went into details when I asked

frosty gale
#

better to be safe

quartz kindle
#

afaik js itself is invulnerable to timing attacks

frosty gale
#

actually i think you can use hashes by hashing both the password and user provided password then comparing them

#

timing attack gone?

quartz kindle
#

because the language itself is so random in terms of execution speed ]

frosty gale
#

yeah thats what i thought initially

lyric mountain
#

virtually nobody would attempt to translate it

#

or optionally, defer the comparison task to a separate api

frosty gale
#

its not the end of the world if it gets breached anyways

#

i think for added safety ill hash both passwords with sha1 then compare them

#

or i could always hash and salt the passwords on boot for all accounts in memory

#

sorry i believe sha1 is close to being not recommended for cryptography so# sha256 then

sage bobcat
frosty gale
sage bobcat
#

One message removed from a suspended account.

frosty gale
#

tim always comes through

#

i dont see anything about it online so it must be new

#

ah node v21

#

my node is 3 generations out of date to use this

lyric mountain
#

js ecosystem is so volatile that 300 libraries die are born every second

frosty gale
#

iha

#

let the rename process begin for sha1

sage bobcat
#

One message removed from a suspended account.

frosty gale
#

thanks

quartz kindle
#

it says it was added in node 6.6.0

frosty gale
#

oh fuck i was looking at the wrong thing

#

splendid

#

but as a side note its scary how many developers are unaware of timing attacks

#

but it just happens most crypto libraries handle that for you so they dont need to worry

sage bobcat
surreal sage
#

OKAY

#

WHAT?

#

i have

#

never seen this before

lyric mountain
#

nested too deep in folders

#

there's a hard limit for file paths

lament rock
#

using numerical indexes, I have to update all tracks after an index because the order gets fragmented. Going back to front like a linked list guarantees order albeit with it being O(n) to sort as each entry needs to find which other entry links to it. Plus you only need at max 2 updates for order

#

How much code currently goes:

const orderedTracks = []
let last = entries.find(i => i.next === null)
if (last) orderedTracks.push(last)
while (last) {
   last = entries.find(i => i.next = last.video_id)
   if (last) orderedTracks.shift(last);
}
#

My thing is that I need to reorder the tracks at any time to any index with minimal updates. My current solution suffers from needing all tracks in the code to sort and it being O(n)

sharp geyser
#

🤔

#

you can probably do some sql magic with the use of the ORDER keyword and update

quartz kindle
#

^this tbh

quartz kindle
#

option 1: store everything you need for the ordering in columns, use sql's own ordering functions when retrieving
option 2: store everything you need for ordering in a single row so that updating and reordering only takes 1 round trip to the db

lament rock
lament rock
#

The user can have their own order of the songs, so #1-length. Can return sections for pages

#

There is a mv command

quartz kindle
#

if the user defines the order, you can for example have a position column on the db, where each entry has a position number, when fetching you can do SELECT * FROM table WHERE id = X ORDER BY position

#

when updating, you dont necessarily need to update all entries, you can for example start creating intermediate numbers when needed

lament rock
#

oh?

quartz kindle
#

like you want to move position 6 to between position 2 and 3, you can set its position to like 2.5 or something

lament rock
#

I hate that idea lmao

quartz kindle
#

lmao

lament rock
#

I thought about just using another storage medium but lmao

#

err I guess I can also do something like this for updating:
UPDATE playlist_songs SET order = order + 1 WHERE order > ${index_moved_to} AND order < ${index_moved_from} for if index_moved_to is less than index_moved_from

#

Just one update operation

#

can easily flip the operators

#

I'm struggling with math mentally though for other cases I don't wanna deal with :(

quartz kindle
#

xD

#

but yeah, the more work you let the db do for you, the better, usually

summer dust
#

How does Discord limit the size of attachments for bots?

deft wolf
#

This is the same limit as users

thorny cargo
deft wolf
#

Unless the server allows more

summer dust
thorny cargo
summer dust
thorny cargo
#

But anyways the limit should be 10 attachments if I aint wrong

thorny cargo
#

Not sure

deft wolf
thorny cargo
deft wolf
#

But this is the same limit as the limit of a regular user without nitro

thorny cargo
summer dust
deft wolf
#

Then read what this error means

#

It's probably not strictly related to Discord

thorny cargo
lapis siren
thorny cargo
#

Who is coding discord bots with py

lapis siren
#

Some people do. The explanation provided on the post applies.

deft wolf
#

Here you can find an explanation of what this error means and how to "get rid of it"

thorny cargo
deft wolf
#

This has nothing to do with the code really

summer dust
thorny cargo
deft wolf
#

If you have a poor internet connection, this error will still occur

thorny cargo
thorny cargo
pale vessel
#

try sending a normal message with that attachment instead of a webhook?

lapis siren
#

Weirdly enough, it's not a 413 they got, but a 500.

#

Nothing to do with file size, just an internet connection issue.

summer dust
#

here for my full code

const { MessageActionRow, MessageButton, MessageEmbed, Options, MessageAttachment } = require("discord.js");
const { SlashCommandBuilder } = require('@discordjs/builders');
const fs = require('fs');
const ytdl = require('ytdl-core');
const { v4: uuidv4 } = require('uuid'); // using uuid to create unique filename

function sanitizeFilename(filename) {
    return filename.replace(/[\\/:*?"<>|]/g, '_');
}
module.exports = {
    data: new SlashCommandBuilder()
        .setName("yt2mp4")
        .setDescription("Download video from YouTube to mp4 format (HIGHEST QUALITY REQUIRES BOOSTED SERVER LEVEL 2 ).")
        .addStringOption(option =>
            option.setName('link')
                .setDescription("Enter the youtube link to download the video.")
                .setRequired(true)
        )
        .addIntegerOption(option =>
            option.setName('quaility')
                .setDescription('Video option (1 - Audio and video , 2 - Video only (need server boot level 2) | deafult: lowest)')
                .setRequired(false)
        ),

    async execute(client, interaction, options) {
        const ytlink = interaction.options.getString("link");
        const quality = interaction.options.getInteger("quaility");
        console.log(quality);   
        const videoid = ytlink.split("?v=")[1];
        if (ytlink.includes('list=')) {
            return interaction.reply("Playlist is not supported")
        }
        const videoinfo = await ytdl.getInfo(videoid);
        const videoTitle = videoinfo.videoDetails.title;
        const videoURL = videoinfo.videoDetails.video_url;
        const Authordata = videoinfo.videoDetails.author;
        const Videoauthor = Authordata.name;
        console.log(`Got request download video: ${videoURL}|${videoTitle}|${Videoauthor}`);

        if (videoinfo.videoDetails.lengthSeconds > 900) {
            return interaction.reply("Due to attachment size limitations, the maximum length is 15 minutes.")
        } if (!videoURL) {
            return interaction.reply("Something went wrong, please try again later.")
        }
        else {
            const embed = new MessageEmbed()
                .setColor('#0099ff')
                .setTitle('Downloading...')
                .setDescription(`[${videoTitle}](${videoURL})`);
            await interaction.reply({ embeds: [embed] });

            const uniqueFilename = `${uuidv4()}.mp4`;
            const sanitizedFilename = sanitizeFilename(videoTitle);
            const videoPath = `cache/${sanitizedFilename}_${uniqueFilename}`;
            // Download video
            if (quality === 1) {
                videoStream = ytdl(ytlink, { filter: 'videoandaudio', quality: 'highestaudio' });
                console.log("lowest")
            } else if (quality === 2) {
                videoStream = ytdl(ytlink, { quality: 'highestvideo'});
                console.log("highest")
            } else {
                videoStream = ytdl(ytlink, {filter: 'videoandaudio',  quality: 'highestaudio' } );
                console.log("default")
            }
            const fileStream = fs.createWriteStream(videoPath);

            videoStream.pipe(fileStream);

            // Wait for download to finish
            await new Promise((resolve, reject) => {
                videoStream.on('end', resolve);
                videoStream.on('error', reject);
            });
           // Check if file is downloaded (debug only)
            const checkfile = fs.existsSync(videoPath);
            if (checkfile) {
                console.log("file downloaded")
            } else {
                console.log("file not downloaded")
            }

            // Send file to user
            const file = new MessageAttachment(videoPath);
            await interaction.followUp({ files: [file] });
            
        }
    
    }
};
thorny cargo
#

Can u followUp without defering ?

summer dust
#

i'm trying sending video quality === 2 with no audio

thorny cargo
#

Thats off topic but anyways

thorny cargo
pale vessel
#

if it's via url wait until they find out about https://cobalt.tools xD

#

the command is kind of pointless

deft wolf
#

In fact, there are plenty of YouTube downloaders on the Internet

#

More than enough

pale vessel
#

yeah. i use that one since it supports most social medias

deft wolf
#

What comes to my mind that would be useful in this style is some kind of API for e.g. Discord bots

eternal osprey
#

hey does anyone know condition coverage criteria regarding structural testing?

#

why have they written a test case for the last if such that it evaluates to false and the last return statement is executed

#

is true seen as a condition as well?

lyric mountain
#

no, true is a value on itself

#

they prolly did that because return (m == 4 || m == 6 || m == 9 || m == 11) && d <= 30 would be fairly unreadable

eternal osprey
#

(31/ <= 30, 12, 1800 <= y <= 9999): e.g, (29, 12, 2023)

nope they did it explicitly to execute return true as well.

#

I asked around and apparently they do see it as a condition, everything that is or evalautes as a boolean. Just in such trivial cases no further tests are possible.

lyric mountain
#

that's odd, because return true is by no means a condition

#

it's a result, just like doing return 1

#

I mean, you could argue it's an unary operation

eternal osprey
#

they that's exactly what they said

#

it was unary something

#

it's vague but i ma just do what i've been told lmao

lyric mountain
#
true (unary | has one value)
1 == 1 (binary | has two values)
true ? 1 : 2 (ternary | has three values)
#

basically

eternal osprey
#

I see

#

Indeed exactly

#

Thank you for clarifying that!!

real rose
#

ternary operator, my lover

lyric mountain
#

aaaaaa brain is smoking, stupid ricochet calculation

#

let's say I have a projectile moving at an angle X towards a target, given perfect reflection, how do I calculate the projectile angle after ricocheting on the target?

wheat mesa
#

It’s the same angle

#

Are we talking a flat horizontal/vertical surface like a wall?

lyric mountain
#

I'll try drawing

wheat mesa
#

Or are you talking an angled surface

lyric mountain
#

projectile is moving at an angle X (global space)

#

I'm trying to find Y

#

I have a function to find out angle between A and B, if required

real rose
#

going by that image "perfect reflection" looks like 90*

#

which would make y = 180 - 90 - x

#

but if its not precisely 90

#

wouldnt y = x ?

#

id agree with waffle

lyric mountain
#

like, X being the ball's angle

#

if Y = X then it'd pierce the cube

#

since no change in trajectory would be made

real rose
#

oh so youre like

#

protractor

lyric mountain
#

and it's not always 90º, it might come from arbitrary angles

#

here's some animated context

lyric mountain
#

note the first impact (I'm bad at aiming rotating things)

lyric mountain
#

if you pay attention to the projectile trajectories, it ricochets at really wrong angles

wheat mesa
green kestrel
#

that animation is majorly lagging my phone

lyric mountain
wheat mesa
#

Then the vertical vector is negated

#

Usually movement is determined by vectors and not angle + magnitude

#

Though you can use both

green kestrel
lyric mountain
#

thing is, how do I manage to cover both horizontal and vertical cases in a single formula?

real rose
wheat mesa
#

Velocity would only matter if that surface you’re colliding with can move

#

At that point you’d be dealing with elastic/inelastic collisions

green kestrel
#

there's a matrix op you can do on a vector that will translate it like this but I don't remember it, it's been a long time since I did maths like this myself I just use an engine

lyric mountain
#

for the walls I simply did PI - ang/2 * PI - ang since I always know when it hits horizontally or vertically

#

but for the enemies, there's not much way to check this

#

I mean, there is, by calculating the point of impact

green kestrel
#

simplest approach is what waffle said but the minute you add moving bodies, 3d space or anything complex...

lyric mountain
#

oh total realism doesn't matter much, consider only the angle part

green kestrel
#

things like pong just invert the X and Y Velocity

#

so if your X,Y Velocity is -1,-1, after collision it's 1,1

lyric mountain
#

guess I'll have to calculate which side of the rect the projectile hits then

green kestrel
#

or if it was -1,1 it would be 1,-1

#

you don't even need to do that

#

if you're just inverting velocities

lyric mountain
#

if I invert both it'll go back the way it came in

green kestrel
#

I assume your velocity is a 2D vector?

#

hmm true

lyric mountain
#

well...not exactly

green kestrel
#

I saw the image and I thought inverse normal, like light bouncing from an object in a ray trace

lyric mountain
#

the projectile displacement is calculated from its current angle * velocity

#

lemme get the formula I used

#
protected void move() {
  float[] vector = Utils.angToVec(getAngle());
  getCoordinates().translate(vector[0] * speed, vector[1] * speed);
}
green kestrel
#

there's an easy way to find out if you're in front of, parallel to or behind a plane

#

I can't remember the name of it

#

you'd use that to determine if how the vector intersects

#

then you invert it using the normal

#

which you get from the same function

wheat mesa
green kestrel
#

ah yes: dot product

lyric mountain
#

meaning I'll lose the flexibility of calculating sin/cos at realtime, but doesn't matter much for this game in specific

green kestrel
#

you can use dot product to determine where you are in relation to what you hit I think

#

it makes a change to be discussing game dev here lol

lyric mountain
#

I really need to study math more lul

wicked pivot
#
CombinedPropertyError (2)
  Received one or more errors

  input[3]
  | CombinedPropertyError (1)
  |   Received one or more errors
  | 
  |   input.value
  |   | ExpectedConstraintError > s.string.lengthGreaterThanOrEqual
  |   |   Invalid string length
  |   | 
  |   |   Expected: expected.length >= 1
  |   | 
  |   |   Received:
  |   |   | ''

  input[4]
  | CombinedPropertyError (1)
  |   Received one or more errors
  | 
  |   input.value
  |   | ExpectedConstraintError > s.string.lengthGreaterThanOrEqual
  |   |   Invalid string length
  |   | 
  |   |   Expected: expected.length >= 1
  |   | 
  |   |   Received:
  |   |   | ''

    at _ArrayValidator.handle (/root/bot/paladium/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:1205:70)
    at _ArrayValidator.parse (/root/bot/paladium/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:939:90)
    at EmbedBuilder.addFields (/root/bot/paladium/node_modules/@discordjs/builders/dist/index.js:225:31)
    at xpRequiredForJob (/root/bot/paladium/src/utils/expCalculator.js:361:10)
    at Object.run (/root/bot/paladium/src/commands/6 - calculator.js:66:31)
    at Object.execute (/root/bot/paladium/src/events/interactionCreate.js:53:25)```

I don't understand this error?
frank saffron
eternal osprey
# lyric mountain projectile is moving at an angle X (global space)

you can use a matrix to keep track of line x, and basically write an arbitrary line y in any direction, given x and the object, with an arbitrary length (but atleast longer than line x is). You then easily calculate the projection matrix of y given x, lets call it y'. There's a specific formula for that. This projection matrix y' will be the exact line that would occur if x would shadow over to y.

lyric mountain
past field
#

i messed up my bot and i need help! in the terminal, under the problem tab it’s showing this

quartz kindle
# past field

thats saying theres something wrong with your package.json

#

but thats not the actual bot problem

#

what happens when you run it?

past field
#

damn idk what i did

#

i get an error

quartz kindle
#

what error

past field
#

1 sec i’ll get it

#

so

#

i tried to create a / command as a translator

#

everything was working perfectly fine

#

then i installed npm discord.js @vitalets/google-translate-api

#

and that’s when all of this started happening

quartz kindle
#

that makes no sense

#

show your package.json

#

also show what happens when you actually run the bot

past field
#
    "name": "Build-A-Bot",
    "description": "Top.gg Build-A-Bot Event",
    "version": "1.0",
    "main": "index.js",
    "scripts": {
        "start": "node index.js"
    },
    "dependencies": {
        "@discordjs/builders": "^1.7.0",
        "@discordjs/rest": "*",
        "@vitalets/google-translate-api": "^9.2.0",
        "canvas": "^2.11.2",
        "date-fns": "^3.3.1",
        "discord.js": "^14.14.1",
        "dotenv": "^16.0.0",
        "moment-timezone": "^0.5.45",
        "sqlite3": "^5.1.7"
    },
    "engines": {
        "node": "16.x"
    }
}
#

I might see what it is....

#

that's the package.json

#

this is the error I get

#
C:\Users\Maurice\Desktop\Da-High-Roller-Bot-main\index.js:14
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_MESSAGE_REACTIONS, Intents.FLAGS.GUILD_MEMBERS] });
                                              ^

TypeError: Cannot read properties of undefined (reading 'FLAGS')
    at Object.<anonymous> (C:\Users\Maurice\Desktop\Da-High-Roller-Bot-main\index.js:14:47)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
    at node:internal/main/run_main_module:28:49

Node.js v20.11.1
PS C:\Users\Maurice\Desktop\Da-High-Roller-Bot-main>```
quartz kindle
#

Intents is undefined

past field
#

how would that have happened? the bots always worked and I didnt change anything

quartz kindle
#

show your index.js

past field
#

The whole thing?

quartz kindle
#

the beginning

past field
#

ok

quartz kindle
#

like the first 10-20 lines

past field
#
const dotenv = require('dotenv');
dotenv.config();
const fs = require('node:fs');
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');

// Require the necessary discord.js classes and variables
const { Client, Intents, Collection } = require('discord.js');
const token = process.env.DISCORD_TOKEN;
const config = require('./config.json');

// Create a new client instance
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_MESSAGE_REACTIONS, Intents.FLAGS.GUILD_MEMBERS] });

// Load our commands
client.commands = new Collection();
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));

const commands = [];
for (const file of commandFiles) {
    const command = require(`./commands/${file}`);
    client.commands.set(command.data.name, command);
    commands.push(command.data)
}

// Register slash commands
const rest = new REST({ version: '9' }).setToken(token);
console.log('Started refreshing slash commands...');
rest.put(
    Routes.applicationCommands(config.clientId), { body: commands },
);
console.log(`Successfully reloaded ${commands.length} slash commands!`);

// When the client is ready, run this code (only once)
client.once('ready', () => {
    console.log('Ready!');
});

// Our slash command handler
client.on('interactionCreate', async interaction => {
    if (!interaction.isCommand()) return;

    const command = client.commands.get(interaction.commandName);

    if (!command) return;

    try {
        await command.execute(interaction);
    } catch (error) {
        console.error(error);
        await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
    }
});
quartz kindle
#

your code is made for discord.js v13

#

you installed discord.js v14

past field
quartz kindle
#

if discord.js was not installed before, then npm install discord.js installs the latest version automatically, which is v14

past field
#

ohhhhh

#

so I should uninstall it and reinstall discord.js v13?

quartz kindle
#

either that or update your code for v14

#

you can install v13 like this npm install discord.js@13

past field
quartz kindle
past field
quartz kindle
#

for example

past field
quartz kindle
past field
#

ok i re-installed v13

#

but it's still saying that there's a problem with the package.json

#

String does not match the pattern of "^(?:(?:@(?:[a-z0-9-*~][a-z0-9-*._~]*)?/[a-z0-9-._~])|[a-z0-9-~])[a-z0-9-._~]*$". [Ln 2, Col 13]

quartz kindle
#

ignore that

#

whats important is what happens when you run the bot

past field
quartz kindle
#

but its just a warning, not an actual error

past field
#

that’s so random lol

quartz kindle
#

it will go away if you change the name to "name": "build-a-bot"

past field
#

ok gotcha

#

its not wanting to start

#

i did node . like normal and it's just sitting there

#

oh nvm its on now

#

just took way longer than normal

quartz kindle
#

👍

frosty gale
lyric mountain
#

@wheat mesa @green kestrel managed to get it working, used a cheap solution of checking which of the collision box' lines intersect with the projectile

#

since the box will always be an axis-aligned square

#

also reworked my screen-switching system to be stack-based because it was giving me a headache, and implemented a character selection screen

#

eventually I'll attempt implementing multiplayer, just need to figure out how

#

besides that, only thing that remains is the audio system that I managed to break in earlier updates

wheat mesa
#

looks really good actually

green kestrel
#

yeah

#

looks fun

#

add explosions next and slight screen shake

#

will give the shots some 'weight'

#

and increase the speed of the whole game 50%

#

including movement of player ship

quartz kindle
#

i think the game speed is fine

#

i would decrease the movement speed of the balls flying around, and make the player ship's speed upgradable via buffs

#

of course you can have a "hard" mode that increases game speed by 50%

#

for touhou enjoyers xd

eternal osprey
#

you use java right?

lyric mountain
#

yes but my head is smoking right now

lyric mountain
#

the spawn rate of enemies that drop upgrades is too low atm

#

they appear in yellow, you can see one at the end of the gif

#

I also need to find a better algorithm for spawning enemies

#

I use a point-buy system, but need to make some kind of director for choosing the appropriate enemies

#

I ALSO need a bigger variety of them lul, atm there are only 3 enemies + 1 boss

eternal osprey
#

might help you out

#

how are you currently representing your objects/directions? Using vectors i assume?

lyric mountain
#

Projectiles have their movement vectors calculated from the angle applied on the forward speed

#

The other entities are simple x/y movement

#

The repo is public btw, if you want to see it

#

Name change is still todo

lyric mountain
wheat mesa
#

I still think that you should be using vectors instead of angles

#

Like you can have an angle but it would be significantly easier to use both

lyric mountain
#

Calculating the projectile path would be considerably harder without angles

wheat mesa
#

You can keep both

lyric mountain
#

I kinda do use vectors tbh, like

wheat mesa
#

Angle can be used for updating the position but for collision resolution it’s much easier to use vectors

lyric mountain
#

A projectile moving at 45° would have [0.5, 0.5] movement multiplier

#

I just apply the projectile speed over that

lyric mountain
#

And hitbox

wheat mesa
#

oof angled hitboxes are rough

lyric mountain
#

Kinda, but java helps a lot at that

#

I'm already working with affinetransforms, so I just check if both shapes intersect

#

proj.getCollision().intersects(ent.getCollision()) basically

#

Ofc I won't be able to use my ricochet logic on that, but angled hitboxes only really matter for ultra long projectiles, like a laser

#

Now that I think about it, perhaps the formula gpt gave me earlier was probably right, I found that most of my issues were that the projectile was colliding twice, so changed direction twice

#

It was atan(-sin(ang) / cos(ang)) or smth

dusky idol
#

Can someone please explain what bot sharding is and how it helps? I've no idea whatsoever so start from basic

sharp geyser
# dusky idol Can someone please explain what bot sharding is and how it helps? I've no idea w...

At a certain point the limit of servers your bot can handle will impact your performance and even the ability to be invited to servers. Because of this discord has implemented a system called sharding which essentially splits your bot into multiple "instances" as one would say. This allows your bot to handle more servers and not spam the api and gateway. The way sharding works is when you make a connection to the gateway you send a shard id and the number of shards your bot spawns. This creates multiple gateway connections and splits the guilds amongst those shards. To handle what guilds you need some libraries give you helper methods to broadcast to all shards to find the guild you need or if you know the id you can fetch it.

#

With discord.js they make sharding stupid simple but there is also libraries that add more features

dusky idol
sharp geyser
#

No changes really need to be made hosting wise just make sure you have enough juice to support such a large guild size

#

It’s also not hard to implement at all

#

Especially with the progress of libs

dusky idol
sharp geyser
#

Well it’s not a necessity but with more guilds the more resources it’s going to use as it’s doing a lot more in response

dusky idol
#

Right now it's in 440 guilds so I believe I'm good for a while. I got told that I'll have to get over sharding once it crosses 1000

dusky idol
#

Eitherway thanks for assisting, I'll probably revisit this channel when I actually have to implement it

dusky idol
#

I'll go over that now

sharp geyser
dusky idol
sharp geyser
#

Nope it’s all hosted on the same instance

dusky idol
#

Alright, so are there any changes for the users of the bot? Or they won't find any difference

sharp geyser
#

Splitting the workload amongst multiple providers is not really useful unless you’re really doing something wrong or your bot is so big it needs that much resources

sharp geyser
#

It’s all a you thing as the developer

dusky idol
dusky idol
#

Also is there any issue if I just shard the bot right now?

sharp geyser
#

No but it’s unnecessary

#

You’d be causing yourself more of a headache

quartz kindle
sharp geyser
#

yea

dusky idol
sharp geyser
#

Guilds get allocated to shards typically at 1k per shard

sharp geyser
#

So 1.5k guilds with 2 shards is 1 shard having 1k the rest will go to the other shard

dusky idol
#

ah right

sharp geyser
#

oh?

quartz kindle
#

they will each have ~750

sharp geyser
dusky idol
sharp geyser
#

I thought they made it spread out for 1k per shard

quartz kindle
#

shard allocation follows a specific rule based on the guild id

dusky idol
#

i mean overall the performance is gonna get effected as its in more guilds

#

Also some commands of the bot processess all guilds it's in. For example
for i in bot.guilds: if ctx.author in guild.members: do this do that

quartz kindle
dusky idol
#

would that be a really big issue once the bot is in many servers

quartz kindle
#

each shard will run on its own process, so your code only sees the current shard

dusky idol
quartz kindle
#

for example, right now your bot runs in 1 process, so everything is inside the same program instance

sharp geyser
#

you can broadcast to all shards tho if need be

dusky idol
quartz kindle
#

when you have 2 shards, your bot will run in two processes, like if you made python bot1.py and python bot2.py

#

where each bot handles half the guilds

dusky idol
#

oh

quartz kindle
#

but thats done internally by the library

dusky idol
#

i see

quartz kindle
#

and the library provides communication between processes

#

usually

#

so if your command needs to access data from other shards, like all guilds in the entire bot, your code will need to send a message to the other process to request that number

#

and wait for the message to return with the result

#

thats called broadcasting

sharp geyser
quartz kindle
#

you will need to check if your library has that

sharp geyser
#

Most libraries give you methods to do this

#

so you dont need to do it yourself

dusky idol
#

Also for a bigger project, like a bot in countless servers, what resources are a must have hosting wise? Will more Ram or vCpus help?

quartz kindle
sharp geyser
#

is that shifting the id 22 bits?

quartz kindle
dusky idol
#

is that an operator

quartz kindle
#

ideally you should have 1cpu per shard, but usually thats not needed, a single cpu can usually handle more than one shard easily

sharp geyser
#

bro im so tired I frogor what >> does outside of c++

#

😭

quartz kindle
sharp geyser
#

what does that even do

#

an id is a stringified bigint

dusky idol
sharp geyser
#

at least in js

#

since js can't handle big numbers

dusky idol
#

I believe it's good enough for a good while?

quartz kindle
#

that should be good enough for 50k-100k

sharp geyser
#

8gb of ram is fine

dusky idol
#

thanks a lot

sharp geyser
#

Unless you use djs /s

dusky idol
#

hm

sharp geyser
#

500mb of ram used just on launch 💀

#

I wish this was a joke but djs uses a lot of ram

dusky idol
quartz kindle
#

this is what a snowflake is made of

dusky idol
#

the bot still uses a lot of ram tho i believe and it connects to the database everytime someone runs a command

quartz kindle
#

shifting to the right by 22 bits basically cuts off the instance and sequence parts

#

and leaves only the timestamp

dusky idol
#

the network usuage for the bot is usually really high

sharp geyser
#

so its a 64 bit int

quartz kindle
#

yes

sharp geyser
#

well 63 by that math, but yknow

#

probably has some overhead

quartz kindle
#

yeah, to account for future timestamps

#

41 bit timestamp is good until 2039

#

then you need 42 bits

sharp geyser
#

gotcha

#

so it shifts is 22 bits and then does a modulo of the number of shards

quartz kindle
#

yes

sharp geyser
#

now correct me if im wrong, but what the fuck does shifting it 22 bits even do

quartz kindle
#

so depending on the guild's creation date, it will be moduloed into a specific shard

sharp geyser
#

957347862314905610 like take this snowflake for example what does shifting it 22 bits do

quartz kindle
sharp geyser
#

🤔

quartz kindle
sharp geyser
#

see I know how to count in binary but idk how to use >> and such

quartz kindle
#

957347862314905610 >> 22 = 228249517039

#

228249517039 = timestamp for the creation of the id

#

aka the date when the id was created

sharp geyser
#

where does the 22 come from tho

quartz kindle
#

Snowflake IDs, or snowflakes, are a form of unique identifier used in distributed computing. The format was created by X (formerly Twitter) and is used for the IDs of tweets. It is popularly believed that every snowflake has a unique structure, so they took the name "snowflake ID". The format has been adopted by other companies, including Disco...

sharp geyser
#

but unless I am wrong, 22 bits is more than the timestamp no?

#

im also tired so I am definitely wrong

sharp geyser
quartz kindle
#

moving 22 bits to the right, cuts those bits off from the righ to the left

#

leaving only the bits on the left

sharp geyser
#

right right

quartz kindle
#

so its removing the sequence and instance parts of the snowflake

sharp geyser
#

binary is right to left

quartz kindle
#

and extracting the timestamp

sharp geyser
#

not left to right

quartz kindle
#

ye

sharp geyser
#

so it would start where that first instance is, and end at the last part of the timestamp

quartz kindle
#

not discord.js tho

sharp geyser
#

its exclusive not inclusive right?

quartz kindle
sharp geyser
#

ignroe my shitty writing

#

doing this with a mouse

quartz kindle
#

yes

#

it removes 22 bits from right to left

dusky idol
#

What database do you guys stick to

sharp geyser
#

but it doesn't include the last part of the instance

deft wolf
sharp geyser
#

so its exclusive in its operation right?

quartz kindle
#

its inclusive from right to left

sharp geyser
#

inclusive?

#

🤔

quartz kindle
#

i mean when counting lol

sharp geyser
#

ah I meant when performaning the shift

quartz kindle
#

but yes it excludes X number of digits

sharp geyser
#

it doesn't include that last I

quartz kindle
#

from right to left

deft wolf
sharp geyser
#

it just starts there

sharp geyser
#

keep in mind the db you use matters depending on how much you want to spend

quartz kindle
sharp geyser
#

sqlite has its limitations and works based off the disk

#

postgres is in the cloud but it scales differently

#

mongodb is a shitty db imo, cause scaling it is so damn annoying

dusky idol
#

I see, I've the code written for mongodb

quartz kindle
#

sqlite is more than good enough for 100k+ guilds

dusky idol
#

hm

sharp geyser
#

just don't expect to store any data thats json or arrays

#

unless you stringify it

quartz kindle
#

ye you need to model your data into table-based scheme

dusky idol
#

I'm usually just storing object types on the database

sharp geyser
#

unless sqlite has advanced since 2019

quartz kindle
#

same with postgres tbh

sharp geyser
#

postgres allows arrays

#

but I hardly ever use em

quartz kindle
#

although postgres supports json and arrays, its not recommended

sharp geyser
#

I model my data around tables and relations

quartz kindle
#

ye

sharp geyser
#

cause that is what sql is about

quartz kindle
#

exactly

sharp geyser
#

sql is meant to be relational

#

and to model your data exactly what its meant to be

quartz kindle
#

plus, disable all the safety options in sqlite and you get a fast af db

#

:^)

sharp geyser
#

a mistake I made in my early days was storing data that was meant to be attached to a table with multiple values was to use an array

#

and push to it

#

💀

sharp geyser
#

only you would be someone that'd do that

quartz kindle
#

yup

dusky idol
quartz kindle
#

i do backups so i dont mind losing data

sharp geyser
#

dont do what tim just said

quartz kindle
dusky idol
#

oh

quartz kindle
#

sqlite is free

dusky idol
#

I never worked much with anything except mongo sadly

quartz kindle
#

you run it inside your host

sharp geyser
#

the only thing sqlite costs you is your sanity and disk space

quartz kindle
#

lmao

dusky idol
#

ah i see

quartz kindle
#

sqlite is good af

sharp geyser
#

its good for prototyping

quartz kindle
#

i get 0.1ms latency on reads and writes

sharp geyser
#

but I will 100% use a cloud db for anything that matters

#

imagine storing your data in an sqlite file and running windows 98

#

:D

quartz kindle
#

lmao

#

sqlite technically supports more than 1tb of data

#

but my sqlite file is like 20mb rn

sharp geyser
#

it should theoretically support as much as your disk no?

#

or does it just shit itself at a certain point

quartz kindle
#

there are some limitations like everything

sharp geyser
#

fair

#

stupid db /s

#

uses the disk but not even fully

#

smh

#

should write sqlite in rust ;)

quartz kindle
sharp geyser
#

its likely the numbers

dusky idol
quartz kindle
dusky idol
#

ah thats awesome

sharp geyser
#

still waiting on that astronomy api

#

the only bot I will ever make

#

is an astronomy bot using tims api

#

:D

dusky idol
#

my mongodb is at 4mbs something and it's in 500 guilds

deft wolf
sharp geyser
#

my db is at 400gb but thats because I am too lazy to delete test data /s

quartz kindle
sharp geyser
#

my g

#

its been since 2019

#

😭

quartz kindle
#

ye

#

lmao

#

but this time im actually working on it

sharp geyser
#

lmao

quartz kindle
#

because i have a paying client waiting

sharp geyser
#

you said that every single year

quartz kindle
#

lmao

#

i g2g work

sharp geyser
#

👀

quartz kindle
#

25 bucks per month

#

lol

sharp geyser
#

dayum

#

easy money

#

I will pay 40$ a month if you actually complete it /s

dusky idol
sharp geyser
#

nope but there are so many of them its useless

dusky idol
#

I'm working at a bot following the similar theme, just taking it a step further so it's doing quite well

sharp geyser
#

It used to be fun making bots, until you realize no one fucking cares about the art and just copies everyone

dusky idol
deft wolf
dusky idol
#

Not including the bots you make for others at commissions

#

Obv there are exceptions but in 9/10 cases it has to be a lot of work for a very small amount of income. Considering how hard it is to advertise a bot with all the competition

deft wolf
#

This is true, and often those bots that are really worth attention quickly turn out to be completely unprofitable and people abandon them

sharp geyser
#

making a discord bot to earn money is the stupidest idea ever

#

most of the time unless you are very luck you are breaking even

#

or making a very little profit margin

lyric mountain
dusky idol
lyric mountain
#

pymongo, for example if you use it, it has a connection pool

#

basically it keeps N connections open and simply reuse them when needed

quartz kindle
#

opening and closing it every time it very wasteful

#

but thats likely not whats using most of the ram

#

most of the ram usage in discord bots comes from the library caching all the discord data, like users, members, channels, guilds, messages, etc

dusky idol
#

i gotta see where I can open the pool from

lyric mountain
#

a tip if you want to reduce ram usage, is to disable presences and message content if you dont use them

#

or disable anything you dont use tbh

quartz kindle
#

if you have the presences intent enabled, thats gonna hog your network like crazy

#

presences literally account for like 90% of a bot's network traffic if they are enabled

#

also, if your library is not already using compression, turning it on will also save a LOT of network traffic

neon leaf
#

Is there a more efficient json parse / stringify than the default in nodejs? Like something that you give the data schema beforehand and it can optimize it's code to stringify that schema

quartz kindle
#

if you have the schema, there is a json library with schemas

neon leaf
#

What's it called

#

O

#

Thanks

quartz kindle
#

alternatively, if you want to go even faster and smaller, you can move away from json

#

for example messagepack or protobuf

#

both are binary formats that are faster and more efficient than json, but they are not human readable

#

protobuf uses schema, messagepack doesnt

neon leaf
#

Well the issue is that my API is sending quite big jsons

#

Around 400kb

#

And they sometimes take very long

#

Sometimes 200ms

#

Sometimes 3sec

quartz kindle
#

alternatively there is also something you can do to speed it up by quite a alot

#

take all the parts of your data that are fixed/predictable and create a json string with string interpolation

#

and only use JSON.stringify for things you have no control over or that are too dynamic

quartz kindle
#

very small sample size but it demonstrates the performance difference between JSON.stringify and raw string interpolation

#

not sure how this difference scales tho

#

also check if your api has any "cacheable" parts and pre-compile json strings for those parts

neon leaf
#

Yeah I think I'm gonna cache full json string

#

The api doesn't update often

#

So it's probably fine

quartz kindle
#

cool

neon leaf
#

The funny thing is

#

Someone managed to take down the entire server

#

By spamming those 400kb requests

#

Lol

quartz kindle
#

Lol

sage bobcat
surreal sage
lyric mountain
# quartz kindle

btw, wouldn't jit simply ditch the interpolated string as a no-op, thus giving a much smaller result?

#

stringify cant be ignored since it's a function, but the string is immutable

quartz kindle
quartz kindle
lyric mountain
#

why didn't js ignore that no-op loop?

eternal osprey
# lyric mountain Depends

i see will have a look and based on that send you a message on what you can do to project the angle.

quartz kindle
#

i guess it doesnt realise its a no-op until after it accesses the object

#

property access might invoke getters and such that still need to run even tho its a no-op

coral phoenix
#

what's the best way to deal with a lot of options in a command?
in discord.js

#

it feels weird just having a lot of getString and const

sharp geyser
#

not much you can do

coral phoenix
#

I'll just do it like this never mind

sharp geyser
#

Are you going to be using these multiple times

#

like what is the use case here because you are doing this inside a switch/case

coral phoenix
#

it's an odata filter and my idea is to modify it based on the user request

#

and looking through the minecraft marketplace database

sharp geyser
#

🤔

#

yes but like, you are doing this inside a switch case

#

so this leads me to believe you are going to be using these options multiple times

#

so this is not the best way to handle this if thats the case

coral phoenix
#

oh I a lot of sub commands the match and case is just for the search command

sharp geyser
#

Okay, ig do what you want

coral phoenix
sharp geyser
#

I just am not certain this is the best way to handle this, assuming any other case statements also rely on the options

coral phoenix
#

I don't think I'm following
I have the switch statement for each command and sub command
they are all in their own scopes and get broken after it ends

#

is there a better way?

sharp geyser
#

woah woah woah

#

now I think you are doing something seriously unecessary, unless I am not following

#

May I see the rest of the code? if its not too much to ask

coral phoenix
sharp geyser
#

oh god

coral phoenix
#

old code I'm going through it and optimising it but yeah

sharp geyser
#

That's a nightmare

coral phoenix
#

tell me a better way to do this

sharp geyser
#

Realistically you should not be handling the code like this, at least with commands.

Now i'd recommend making some sort of cmd handler that can handle sub commands.

#

Using a switch/case statement like this is by far the worst option

coral phoenix
#

but why are they bad?

#

aren't they faster than having if statements for command handling?

sharp geyser
#

because its messy, and even if they are "faster" it isn't always the best thing to use. Just like with if statements, switch/case also has its uses and stuff it is not meant for.

#

Also faster != better code

coral phoenix
#

ehh

sharp geyser
#

I recommend making a command handler, either a class based one or a function based one.

#

you will have an easier time managing everything rather than in a nested switch/case

#

though if you refuse to make any changes, then at least make functions to group your command code together and call them in the case bodies

coral phoenix
#

I just want to finish this bot as fast as possible I'll worry about making it readable after it's done
I've been working on it for the past 3 months

sharp geyser
#

shruganimated suit yourself

#

Im just telling you that its a bad idea to do it the way you are doing

#

but its ultimately up to you

#

mind you thats what you asked of me so

coral phoenix
#

I appreciate the feedback

#

what I do normally is first get the code/command working and then refactor it to make it readable

#

at least that way suits my style

sharp geyser
#

its not even about readablity tbh

#

while switch/case statements are relatively faster at lookup than if statements it isn't meant to be a fix all solution

#

sometimes switch/case just doesn't make sense to use

#

and tbh, in this case neither would if statements

coral phoenix
#

well ok

sharp geyser
#

the way i'd personally do it is

  1. Make a commands folder
  2. Make a command class that handles loading any files that has a class that extends it in a specified folder (e.g command folder)
  3. Load it then call the run method (or whatever you decide to call it) and pass in the appropriate params to it e.g for interaction commands pass in the interaction.
  4. Write some commands
#

with this you can extend this to allow command level permission checks like some frameworks do (namely sapphirejs)

coral phoenix
#

yeah I'm already working on that
one of the issues I have is that I have 3 global databases that most commands rely on
I want to try exporting them and pass them to the other files but always was too lazy

sharp geyser
#

you use 3 different databases?

#

ones that you own and control?

coral phoenix
#

yeah

sharp geyser
#

🤔

#

why?

#

that seems like a hassle

coral phoenix
#

one for liked accounts to the bot and language control
one for stats and logs control
and one for extra items like linked channels, creators database, bot bans etc

#

they are firestore databases

#

trying to optimise them to reduce the amount of reading and writing to the databases

sharp geyser
#

but the point of databases is to handle the read and write

#

you are just adding more overhead by using multiple

coral phoenix
#

firebase has a limited amount of them to do in a day unless I need to pay

sharp geyser
#

then dont use firebase

#

I assume you host this bot on a vps right?

#

postgres is free

#

even mongodb is free

#

firebase is a terrible db imo cause it costs to use, which shouldn't be a thing

coral phoenix
#

I use firebase because I like the service and I'm already balls deep

sharp geyser
#

fair enough

coral phoenix
#

the read are writes are so much that it doesn't matter

sharp geyser
#

not only are you balls deep but so is firebase, its a terrible service for what it offers

coral phoenix
#

20k writes, 20k deletes and 50k reads per day

sharp geyser
#

rookie numbers

#

databases can handle that and more so long as you use pooling and even without pooling it can still handle a hefty amount

coral phoenix
#

it costs very little aswell

#

like $0.03 something for 100k writes

#

well 0.03 for reads and 0.1 for writes

sharp geyser
#

yknow how much that is if you do 100k writes a day

coral phoenix
#

Ik I don't even need it lol but I find the service great

#

I'm having a partnership with some companies soon and it's doing it's job flawlessly

sharp geyser
#

neat

#

well good luck

#

I still think tim is right and discord channels are the best db @quartz kindle right?

coral phoenix
#

lol

lament rock
#

Someone I know made a library for this and I hate it so much

sharp geyser
#

I think I know the lib you are talking about

storm kernel
#

Every technology that sticks around this long has a proven purpose or niche 🙂

lyric mountain
#

and cortana?

quartz kindle
#

i cant find the original repo for that old discord-fs lib

#

now there's a shit ton of them

deft wolf
#

What do you think about the possibility of setting a banner for bots? PepoThink

quartz kindle
#

the readme is a solid 5/7

charred nest
#

makes life sm easier for connections

quartz kindle
#

who needs pooling when you have a memory mapped db :^)

charred nest
#

is discord giving anyone else an issue with updating their app directory info c_stare its been over a week and the only value it wont edit is the expanded desc

quartz kindle
#

i havent touched that in years

#

no idea how mine looks like

charred nest
#

LOL gotcha

#

the current for mine is so ugly/outdated and no matter what i do it wont update it. discord was like 'oh usually takes 24h' but its been a week

quartz kindle
#

weird

charred nest
#

im wondering if certain characters aren't able to be used SP_thinks i use ⸝⸝➜﹒to format something in it but i don't know if that would be why it just wouldn't update

north cairn
#

guys i was trying to get started to cloudfare
i installed it and did wrangler login and it opened a webpage where it asked for consent..i clicked allow and then this

spark flint
#

now you are logged in with wrangler it won't be live anymore

north cairn
#

to fix it

spark flint
#

nothing

#

you have already verified

#

thats just to login with cloudflare, nothing else

north cairn
spark flint
#

have you already done wrangler login

#

and did you click login on the cloudflare website

north cairn
#

bro i have logined in another tab at cloudfare workers

#

idk abt wrangler

north cairn
ashen scroll
#

hi i need some serious help like one of the serious one i am stuck in logic part idk what to do

#

its a logic part not code error and enything

solemn latch
north cairn
solemn latch
#

Are you using a remote machine?

#

IE, you're running wrangler somewhere not on the machine you're opening the browser on.

#

Like a vps

north cairn
#

i am doing on replit

solemn latch
#

Wrangler is typically intended to be run locally

north cairn
#

so i cant do on rpelit?

#

replit*

solemn latch
#

Did you open the link?

north cairn
#

yea

solemn latch
#

Should explain everything you need

north cairn
#

curl <LOCALHOST_URL>
where do i do this

#

in another tab or another shell

solemn latch
#

I dont use replit, so I cant answer that tbh.

#

I've never heard of wrangler being run on replit, if someones done it before there might be a guide online specifically for that.

thorn spruce
#

Hey, so i'm using sequelize as ORM and this happened,

as you can see for unknown reason this user_id isn't converted in string and i checked my types etc and i use Snowflake from Discord.js which is basically a string and even in my sequelize configuration for this table it's

    user_id:{type: DataTypes.BIGINT({length:49}),allowNull: false,references :{model: Players,key: 'user_id'},},

but for a reason i don't know it doesn't work for this specific ID 447880780019138560

#

Just found that's not from sequelize, my integer code treats the id as an integer

#

but this one only

green kestrel
#

how many here are adding banners to their bots rn?

deft wolf
#

Not now

#

I only tested it on my other bot

spark flint
#

its funny because its already bugged

#

bots shouldn't have that tag

green kestrel
#

lol didn't see the nitro tag on mobile

green kestrel
rustic scarab
#

Me wondering why the command is not giving out the role for the member.
Meanwhile the code:

spark flint
#

skill issue

green kestrel
#

skull tissue ded_skull

lyric mountain
#

another character

#

still need to write the description for it

#

basically a very agile ship with boomerang projectiles, which can pierce and hit once every 100ms

#

and can blink to the last projectile fired

#

fps is low on gif only btw, had to limit it to 30fps

solemn latch
frank horizon
#

ohh no way they released it officially

radiant kraken
surreal sage
#

dead chat

deft wolf
#

It is what it is

pale vessel
#

it's what it's

cloud bough
#

is it possible in current discord api to send components inside of an embed?

#

Ive been looking around and there really isnt much on the topic

#

Nevermind, I answered my own question. "Embed" Doesn't have any property for components 😦 sad times

deft wolf
#

You can add components under the embed

eternal osprey
#

i just discovered that cloudfare doesn't use normal hashes using a hash function for protection, but they use a random generated hash based off fucking lava lamps??

#

that's so sick, who the fuck came up with that idea though. Genuinely 1000iq

spark flint
#

lmfao yeah

eternal osprey
#

madd

lament rock
sharp geyser
lyric mountain
radiant kraken
lyric mountain
#

Ah yeah

trail crystal
#

Hi

low orbit
radiant kraken
#

they'll just buy another set of lava lamps

neon leaf
#

just a few relations

small tangle
frosty gale
#

im designing a chat app which uses websockets in browsers for relaying events to users of course, but I'm wondering what the best way would be to handle this, thinking big production scale

#

should i delve in things like compression? i heard compression for js with things like zlib sucks because of its fragmentation, now this was for node so not sure about v8 in browsers (or even spidermonkey)

#

but given the small nature of 99% of messages i doubt compression would provide much benefit so id rule that out

#

i was more interested in using BSON instead of raw JSON since that would save massively on transmitting redundant JSON things like quotes and reusing names

eternal osprey
#

backup lavalamps KEKW

#

but on the other hand, the room must be pretty secured or not? Maybe like shock absorbing concrete coatings or sum

dusky idol
#

I've never tried either Karuto or Sofi bot in my life but one of my bot users wants me to implement a feature similar to those bots. How does that work? I don't believe if discord allows me to track what account belongs to which user. Isn't this similar to IP tracking or something? https://prnt.sc/2H0wJXMY3ACn

Lightshot

Captured with Lightshot

#

Well to people who cant look into image I'll copy paste the text

for new players, the bot should have a verifying thing like what the karuta/sofi bot has. this will prevent people from using their alts as it wont let them verify if they already have a main, you can like add this when theres more people using the bot or something

deft wolf
#

Or if, for example, someone is able to register using mobile data on their phone and on their computer

dusky idol
#

Even tho the bigger bots most likely won't leak your data or use it for suspicious activities, still overall they are tracking the ip

deft wolf
#

Yes, but the IP address is not as "sensitive information" as it may seem. An ordinary Discord user doesn't have to worry about this, it's worse if you are a "public person"

#

Of course, there are data and password leaks, but if they are not interesting in any way, no one will be interested in them

dusky idol
#

Got it, thanks a lot

past field
#

is it a lot for me to code in a listening event for my bot coded with discord.js with chat gpt?

#

I'm sure there's a node module I have to install but I just have a feeling that is a lot more complicated than a node module and listening event

quartz kindle
#

as well as protobuf instead of json

#

protobuf + zlib is pretty much state of the art bandwidth savings, you're probably looking at 90-95% size reduction

#

and cpu-wise its probably gonna be faster than json

#

but you need a pre-defined schema to use protobuf

wheat mesa
#

I highly recommend against using chatgpt since the code it generates is pretty garbage

past field
past field
#

like if someone @‘s my bot a question, it will respond with an answer

#

i’m still learning discord.js and the terminology of coding so bare with me lol

quartz kindle
#

chatgpt does provide an API, both official and unofficial apis exist

wheat mesa
#

(Also, the API is not free iirc)

quartz kindle
#

on npm you will find many packages that use these apis

#

so you can try one of them

quartz kindle
wheat mesa
#

Unless they’ve made it free since I last checked

#

Ah

quartz kindle
#

but heavily rate limited

wheat mesa
#

1 request per day ;^)

past field
#

ah ok so it’s not really worth trying to do unless i pay for an official api

quartz kindle
#

last checked almost a year ago lol

#

so quite likely they are dead by now

past field
#

ah ok lol i won’t even bother then 😂

humble gyro
#

its pretty affordable

#

for my bot i use gpt as a base for conversational feature and it costs me like 4$

covert palm
#

It's likely that such a feature will cost more than it earns, depends how you monetize it

harsh nova
covert palm
#

Hey, I used to be part of the DMP and moderated in quite a lot of servers in the past, I've never owned them but probably had a moderator role in the 3 unofficial servers at some point

harsh nova
deft wolf
#

Carl bot status page 🔥

covert palm
#

So glad my bot doesn't connect to the gateway. It's sometimes a challenge and not always possible depending on what you want to do, but it avoids having to deal with shards like that.

pale vessel
#

yeah, my bot does connect to the gateway, but it could still work without it

quartz kindle
#

mine also doesnt anymore

#

but honestly slash commends are unstable af

#

text message commands via gateway were much more stable

humble gyro
#

hey is there anyone here who uses the top.gg api?

spark flint
#

hi

humble gyro
#

im migrating the "v0" api

#

wondering if someone has a decent suite of uses to validate consistency

spark flint
#

i use reviews api, entity fetching api, search api

#

and probably more KEKW

humble gyro
#

uh

#

which api is this

#

those are not in the legacy api iirc

spark flint
#

theres so many different api paths i lose track

humble gyro
#

/api/*

#

needs bot token

#

e.g. to check votes

#

the sdks should implement the routes iirc

humble gyro
#

ah

#

ok

spark flint
#

requires auth for the first one

humble gyro
#

yeah the client ones are not part of the "api"

spark flint
#

incognito returns unauth

#

yeah

humble gyro
#

but cool

spark flint
#

just allows people to create review incentives

#

anyways im getting sidetracked KEKW

#

ok so v0 covers anything in the docs right

surreal sage
#

alr hard one

#

i got a file

#

im guessing it's sql

#

it's fixed width, 4096 kb

#

whole lot of these

#

Þï¾­

#

how can I properly decode it

surreal sage
#

varbinary?

humble gyro
#

we use them to load the UI

spark flint
#

they're also passed via props im pretty sure uhh

humble gyro
humble gyro
spark flint
#

tbf its impossible to block that since people can just automate getting props (nextjs my beloved)

#

yeah

humble gyro
#

yea

#

its what it is

eternal osprey
#

is anyone familiar with the hoare triples and annotated programs? If so, can anyone help me to construct such an annotated program given an inference tree?

humble gyro
#

do u use any of the weird obscure undocumented stuff?

radiant kraken
#

well i don't use it directly; i just maintain the Rust SDK for it onesieKEKW

#

nope

humble gyro
#

ah

#

kk

radiant kraken
#

what about it?

humble gyro
#

im migrating the v0 api rn

#

trying to understand what's actually being used outside of our docs

#

routes will stay the same + documented flows will stay

#

errors are clearer now, which is nice

#

idk if there was a error type in the libraries

radiant kraken
#

poggies

humble gyro
#

but that's slightly different

#

but stuff like accessing the api with user tokens (no longer obtainable) are removed

radiant kraken
#

lesgo

humble gyro
#

just wanna keep the v0 api as little as possible

#

so we can move our focus towards v1

#

which will be actually clean

radiant kraken
frosty gale
#

possible but a bit inflexible