#development

1 messages ยท Page 1977 of 1

modest maple
#

I haven't got anything better yet

#

sooo

#

Deal with it bloblul Worst case scenario it becomes a feature

pale vessel
#

where's that image supposed to be?

#

GH readme?

modest maple
#

yh

#

/ general brand logo

#

If you fancy making a logo

pale vessel
#

ah

#

you sure you want to include the version there?

modest maple
#

there's a ยฃ100 bounty for you WICKED

#

well this is just a general banner for the master readme

#

so yes i do want to take the version

modest maple
#

mmm no

split hazel
#

javascript sucks so much

#

its garbage

#

java is way better

sudden geyser
split hazel
#

why

sudden geyser
#

I don't like either of them

split hazel
#

k

#

your opinion is invalid

#

java is better

cinder patio
#

Those are not comparable

split hazel
#

why not:(

wooden ember
wooden ember
# split hazel java is way better

also agreed authough i have less experience with it and its harder to do (foe me atleast) its not like js where you can run broken code and only find out about it when it brakes at some random point in the future

#

also

#

thinking of js

cinder patio
#

typescript

wooden ember
#

how do i get the guild id of a guild the bot was kicked from?

#

in guessing its somthing like ```js
bot.on("GUILD_DELETE", guild() => {
info("bot removed from server. deleting server file")
let id = guild.id
clear(id)
});

cinder patio
#

guild =>

wooden ember
#

havent used that event since v12 so idk

wooden ember
#

just fiorgot to remove it

#

but thx though

#

but other than that should work right?

lyric mountain
#

also clear(guild.id)

#

no need to assign a variable

#

and add more info to that log, you can barely know what guild was it

wooden ember
#

fair enough

#

ok so i kicked it from my test server

#

and it didnt register the event

#

and also somthing i noticed is the reddy event hasnt bee firing either

woeful pike
#

do you really need to delete anything

#

seems like you're just losing data for no reason

wooden ember
#

yeah but bot has a file for each server

woeful pike
#

welp, there's ur problem

modest maple
#

said literally no GDPR lawsuit ever

woeful pike
#

what does gdpr have to do with this lol

wooden ember
#

so if its kicked from the server it needs to delete redundent data other whise the directory will fill up with crap

woeful pike
#

have you considered using a database instead

wooden ember
#

its saves a message and it can be as big as the discord character limit

modest maple
#

๐Ÿ‘๏ธ A single message

#

or

#

messages plural

wooden ember
#

and since thats only 1 field theres almost no reason to use on it would over complicate things

wooden ember
woeful pike
#

sqlite is stupidly easy and simple honestly but your call I guess

wooden ember
#

working on getting it to do more than one for each server but havent doen much with that atm

wooden ember
#

so we'de be back at square one

#

also in need food be back in a bit

split hazel
#

real programmers eat and code

brisk rapids
split hazel
#

real programmers send what they eat on facebook

sudden geyser
#

if you use facebook you don't exist

#

have fun with that existential crisis

wheat mesa
split hazel
#

moved to here because #general is all just web3 cringe

#

so hi guys

wheat mesa
#

Hi

earnest phoenix
#

how do I prevent this from happening ("confirm" an interaction)

solemn latch
#

Respond to the interaction

simple stump
#

How would I download a file from the internet?
Ex. if I have https://challonge.com/w9KSb8cCFd.svg and want to convert that image to a .jpg using sharp or fs, I'd need to download the image first. How would I accomplish this?

sudden geyser
#

It depends on the langauge.

#

For example, in JavaScript, it's popular to use the fetch module.

simple stump
#

Yeah I'm using JS

spark flint
#

how would i get the current time as a discord timestamp

#

js

sudden geyser
#

you mean of a discord timestamp?

sudden geyser
#

or you wanna generate an id from a timestamp?

spark flint
#

i mean like on guild join i want to send the timestamp

sudden geyser
#

oh

#

since you're using discord.js, isn't that included on the guild object (e.g. .createdTimestamp)

spark flint
#

not guild creation

#

i mean like get the current time so i can see when the bot joins the server

sudden geyser
#

Date.now()?

#

Or even guild.joinedTimestamp

spark flint
#

<t:${Math.round(guild.createdTimestamp / 1000)}:D>

#

that gets creation

sudden geyser
#

Yes, and it formats it as well

#

Though I don't know if dividing it by 1000 will give the correct time (I don't think it's necessary).

#

But you can use .joinedTimestamp like I mentioned

#

To get what time Discord thinks the bot joined

boreal iron
#

But make sure to use floor or abs in order to prevent a float in your message (time) format

sudden geyser
#

For <t:...> at least

boreal iron
#

Thatโ€™s why he divides the timestamp provided by the event by 1000

sudden geyser
#

Oh I see now

#

Discord does process it in seconds

boreal iron
#

ducking auto correct

#

Omg

#

Yes indeed

sudden geyser
#

But tried it with milliseconds just now and it's way over instead

boreal iron
#

It says seconds in the docs if Iโ€™m not wrong

sudden geyser
#

no

#

at least not here

#

it's implied though with the example

boreal iron
#

Well okay but the example at least shows it

#

But still

#

But make sure to use floor or abs in order to prevent a float in your message (time) format

spark flint
#
const { MessageEmbed } = require("discord.js");

module.exports = {
    name: "guildCreate",
    async execute(client, guild) {
        let embed = new MessageEmbed()
            .addField("ยป Owner", `<@${guild.ownerId}>`, true)
            .addField("ยป Channels",  guild.channels.cache.size, true)
            .addField("ยป Created at", `<t:${Math.round(guild.createdTimestamp / 1000)}:D>`, true)
            .addField("ยป Members", guild.memberCount.toString(), true)
            .addField("ยป Roles", guild.roles.cache.size, false)
            .setThumbnail(guild.iconURL())
            .setTitle(guild.name)
            .setDescription(`<t:${Date.now()}:D>`)
            .setFooter({text: `ID: ${guild.id}`})
        client.channels.fetch('941808789575835748')
        .then(channel => {
            channel.send({embeds: [embed]})
        })
        
    }
}```

RangeError [EMBED_FIELD_VALUE]: MessageEmbed field values must be non-empty strings.
at Function.verifyString (/workspace/node_modules/discord.js/src/util/Util.js:416:41)
at Function.normalizeField (/workspace/node_modules/discord.js/src/structures/MessageEmbed.js:544:19)
at /workspace/node_modules/discord.js/src/structures/MessageEmbed.js:565:14
at Array.map (<anonymous>)
at Function.normalizeFields (/workspace/node_modules/discord.js/src/structures/MessageEmbed.js:564:8)
at MessageEmbed.addFields (/workspace/node_modules/discord.js/src/structures/MessageEmbed.js:328:42)
at MessageEmbed.addField (/workspace/node_modules/discord.js/src/structures/MessageEmbed.js:319:17)
at Object.execute (/workspace/events/guildCreate.js:8:14)
at Client.<anonymous> (/workspace/index.js:34:46)
at Client.emit (node:events:520:28) {
[Symbol(code)]: 'EMBED_FIELD_VALUE'
}```

boreal iron
#

Date.now() returns ms, iirc

#

You gotta divide it and round it, too

#

And fill your empty field value (not title) with an actual string

pale vessel
#

guild.roles.cache.size.toLocaleString()

#

needs to be string not number

spark flint
#

ahhhh

pale vessel
#

use toLocaleString() instead of toString() to format the number (e.g. 1,000)

spark flint
#

guild.channels.cache.size.toLocaleString() too

boreal iron
#

You may wanna read what I mentioned two times above

split hazel
#

i hate how modules are becoming import only

#

been using require for years and now i have to import which i have to enable explicitly because it isnt enabled by default

sudden geyser
#

I haven't bothered to try understand them

#

still using require in my code bases

pale vessel
#

import makes it hard to refresh the cache

#

there are ways but they have compromises

split hazel
#

is this a protest or something ๐Ÿ’€

sudden geyser
#

yeah we're just lazy

#

except for the refresh part

#

restarting your entire app to change some text on the screen is painful

pale vessel
#

apparently one of the ways to refresh using ESM could cause a memory leak

split hazel
#

ffs just what i said

sudden geyser
#

reject import, return to require

split hazel
#

yeah say that to express

sudden geyser
#

is it straight up disallowed?

split hazel
#

yep it doesnt work

pale vessel
#

need to use import()

#

but it returns a promise

split hazel
#

just gets more complicated doesnt it

#

top level await isnt a thing yet in stable either

pale vessel
#

except if your module/app is in ESM

#

been there since node v14.8

#

or v14.3 under --experimental-top-level-await flag seems like

split hazel
#

why is it experimental lmao

#

what is there to experiment

pale vessel
#

because it was experimental

#

bro idk

#

๐Ÿ˜ญ

#

it's not anymore at least

split hazel
#

i am one step from quitting the javascript ecosystem

sudden geyser
#

e.g. what happens in the rust community often

split hazel
#

and theres also a very fucking load helicopter flying outside which is making me extra pissed off

sudden geyser
#

try riding it

split hazel
#

๐Ÿ˜ก๐Ÿ˜ก๐Ÿ˜ก๐Ÿ˜ก๐Ÿ˜ก๐Ÿ˜ก๐Ÿ˜ก๐Ÿ˜ก๐Ÿ˜ก๐Ÿ˜ก๐Ÿ˜ก

eternal osprey
#
  const excelToJson = require('convert-excel-to-json');
  const result = excelToJson({
    sourceFile: 'quest.xlsx'
  });

 
  let d = message.author
  let z = ''
  
  let de = result.Sheet1
  console.log(de)
  let n = ''
  
   
   
    const keys = Object.keys(de);
    for(let i = 1; i < 11; i++) {
      console.log(de[keys[i]].A)
      n += `**Keywords:** ${de[keys[i]].A} --- **SearchVolume:** ${de[keys[i]].B} --- **Category:** ${de[keys[i]].C} --- **Average Price:** ${de[keys[i]].D} --- **Monthly Sales:** ${de[keys[i]].E} --- **Monthly Revenue:** ${de[keys[i]].F} --- **Review Count:** ${de[keys[i]].G} --- **Reviews Rating:** ${de[keys[i]].H}\n\n`
    }```How would i remove the 11 de[keys[i]] from the excel file?
#

So that they cannot be drawn again

spark flint
#

how to do that KEKW

sudden geyser
#

use interactions with user/message types

split hazel
#

harass me all you want nerds

#

but for quick and dirty projects which need a database quick.db is ๐Ÿ”ฅ

#

its in the name after all

sudden geyser
#

yeah nothing wrong with it

quartz kindle
#

๐Ÿคฎ

#

:^)

sudden geyser
#

I read/write to a local db.json file in my project and call it a day

split hazel
#

objects are the future

#

who even uses rows and columns nowadays

#

๐Ÿ˜‚๐Ÿ˜‚๐Ÿ˜‚๐Ÿ˜‚๐Ÿ˜‚๐Ÿ˜‚

sudden geyser
#

no, graphs will become the future

#

๐Ÿ“Š !!!

#

no wait ๐Ÿ“ˆ

quartz kindle
#

meaning its probably only from excel to json, and not back

#

you need something that can create or edit excel files

#

or save the json file and use the json from there on, and delete the excel file

eternal osprey
#

I just read the file outside the cron function, globally defined that.

#

At the end removed the keys from the json file, boom.

#

A cron function only runs once right? If the parameter is for example: Monday.

#

Would it run only once each monday? Yeah rigt?

quartz kindle
#

it should yeah

eternal osprey
#

Or would it constantly start another instance each monday.

#

Because that would be fucked up

split hazel
quartz kindle
#

lel

sudden geyser
#

can I get your autograph

quartz kindle
#

sure, here you go:
- Tim

fiery stream
#

How does one get mem usage for python discord bot

quartz kindle
#

have you tried googling python memory usage?

fiery stream
#

Yes its only for cli tho

#

I want something that can show data for bot stats yk

quartz kindle
#
import psutil
print(psutil.cpu_percent())
print(psutil.virtual_memory())  # physical memory usage
print('memory % used:', psutil.virtual_memory()[2])
#
import os
import psutil
pid = os.getpid()
python_process = psutil.Process(pid)
memoryUse = python_process.memory_info()[0]/2.**30  # memory use in GB...I think
print('memory use:', memoryUse)
fiery stream
#

Is that a accurate module ?

wooden ember
#

guys i found a new curced discord bot on github

#

its a pokimon bot

#

and its got 12k lines of code in a single file

#

most of which are else if chains

quartz kindle
#

does it have a giant if else for each pokemon?

sudden geyser
#

having a lot of lines in a single file is not necessarily a bad thing

wooden ember
sudden geyser
#

oh no

wheat mesa
#

but 12k lines for a discord bot in one file is fucking atrocious

quartz kindle
#

i remember some dude here writing a pokmon bot like that

#

wonder if its the same dude

#

show the code

wooden ember
sudden geyser
sudden geyser
#

oh god

lyric yacht
#

how do i see the bot i put on topgg?

sudden geyser
#

but hey it's well documented

quartz kindle
#

this is a nice class tho ```js
function Pokemon(name, nick, no, form, type, item, level, totalxp, moves, ability, abilitySlot, nature, stats, iv, ev, gender, region, location, caughtAtLevel, shiny) {
this.name = name;
this.nick = nick;
this.no = no;
this.caughtIn = "Pokรฉ Ball";
this.type = type;
this.item = item;
this.level = level;
this.totalxp = totalxp;
this.moves = moves;
this.ability = ability;
this.abilitySlot = abilitySlot;
this.nature = nature;
this.stats = stats;
this.IVs = iv;
this.EVs = ev;
this.gender = gender;
this.ot = "None";
this.otid = 0;
this.date = moment().format();
this.region = region;
this.location = location;
this.caughtAtLevel = caughtAtLevel;
this.shiny = shiny;
this.lead = 0;
this.form = form;
this.friendship = 50;
this.evolving = 0;
this.status = null;
this.pv = Math.floor(Math.random() * 4294967296);
}

wheat mesa
#

Itโ€™s really difficult to read 12k lines of code on 99% of projects

sudden geyser
wheat mesa
#

Not to mention he destroys his client and logs back in each time he gets an unhandled error...

lyric yacht
wooden ember
#

and theres this function had to zom out to see all the elseif statements

sudden geyser
#

I don't mind 3k long java files because they're well placed

quartz kindle
#

lmao

wheat mesa
#

3k lines in a Java file is different though

#

Types make everything a lot less ambiguous

#

And itโ€™s basically a pure OOP lang

fiery stream
#

Lmfaoo the most lines of code i ve had in single file is no more then 500 lines

wheat mesa
#

Which means the entire language is basically structured around organizing data

wooden ember
sudden geyser
sudden geyser
wheat mesa
#

Iโ€™d rather see "String x" than just "x" in a function parameter and have to look through what the function does to see what "x" is

sudden geyser
#

then stretch that across 100-200 classes

#

that doesn't really have to do with file length though

#

that's about functions in general

wheat mesa
#

but imagine doing that for every function in a 3k line project

#

far easier to read with types imo

quartz kindle
#

so many imports lmao

wheat mesa
#

yeah I've seen that

#

to be fair though it's just static helper methods

#

just a lot of them

quartz kindle
#

the longest file i've ever written is a .d.ts file lmao

elder jewel
#

guys pls reply., how can I give someone owner perms on my bot?

quartz kindle
#

5k lines

sudden geyser
#

I've seen much longer

elder jewel
#

anyone?

sudden geyser
#

I think Discord.js's d.ts is like 30k-50k lines long

quartz kindle
#

nah

#

its 5k lines as well

sudden geyser
#

oh I was way off

quartz kindle
#

the only reason mine has 5k lines is because i put typings + jsdoc together in the same file

#

the jsdoc alone is like 3k lines

elder jewel
#

why is the site so slow

modest maple
#

Something something web3

sudden geyser
#

Why hasn't cancel culture kicked in yet

wheat mesa
#

what should I make with my beginner-intermediate skill level in c++

sudden geyser
#

a web server

wheat mesa
#

nah I'm gonna try some stuff with SDL

#

but that's a good idea if this goes south

wooden ember
#

anyone know why guild_delete isnt fireing when the bot is kicked from a server?

wheat mesa
#

do you have the GUILDS intent

sudden geyser
#

SDL?

wooden ember
wheat mesa
wooden ember
#
bot.on("GUILD_DELETE", guild => {
    info(`bot removed from ${guild.name} deleting server note`)
    clear(guild.id)
});
#

thats the code

wheat mesa
#

use the flag for the event

spark flint
#

guildDelete

wooden ember
wheat mesa
#

no..?

wooden ember
#

i thought they changed it in v13

wheat mesa
#

they changed intents

wooden ember
#

ah

wheat mesa
#

Intents.FLAGS.GUILDS

#

that type of thing

wooden ember
#

ah ok

#

now for some reason the info command it trying to run on startup for some odd reason but thats probably cuz i did somthing dumb

#

and also the guild delete event runs at startup too every time

#

probably cuz theres an unavalable guild

#

and i heard that causes the thing to fire the delete event for no reason

wheat mesa
#

yes

#

check if the guild is unavailable before doing anything with it

wooden ember
#

yeah just did that

#

working nicely

#

(also yes i knwo i missed the colon on the warn)

hidden gorge
#

me and @static tendon hosting our new bot that got approved on top.gg

sudden geyser
#

congrats ๐ŸŽ‰

hidden gorge
#

and yeah

#

a lot of issues happened earlier but our 3rd developer fixed it

#

my friend aka our 3rd developer is the owner of our hosting service

wheat mesa
#
#include <SDL.h>
#include <iostream>
#include <SDL_image.h>

const int SCREEN_WIDTH = 640;
const int SCREEN_HEIGHT = 480;

bool init();

bool loadMedia();

void close();

SDL_Window* gWindow = NULL;
SDL_Surface* gScreenSurface = NULL;
SDL_Surface* gHelloWorld = NULL;

int main(int argc, char* args[])
{
    if (!init()) {
        std::cerr << "Failed to initialize" << "\n";
    }
    else {
        if (!loadMedia()) {
            std::cerr << "Failed to load media" << "\n";
        }
        else {
            SDL_BlitSurface(gHelloWorld, NULL, gScreenSurface, NULL);
            SDL_UpdateWindowSurface(gWindow);
            SDL_Delay(5000);
        }
    }
    close();

    return 0;
}

bool init()
{
    bool success = true;

    if (SDL_Init(SDL_INIT_VIDEO) < 0) {
        std::cerr << "SDL Could not be initialized!\tErr: " << SDL_GetError() << "\n";
        success = false;
    }
    else {
        gWindow = SDL_CreateWindow("First game", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN);
        if (gWindow == NULL) {
            std::cerr << "SDLWindow Could not be created!\tErr: " << SDL_GetError() << "\n";
            success = false;
        }
        else {
            gScreenSurface = SDL_GetWindowSurface(gWindow);
        }
    }
    return success;
}

bool loadMedia()
{
    bool success = true;

    gHelloWorld = IMG_Load("./helloWorld.png");
    if (gHelloWorld == NULL) {
        std::cerr << "Image resource could not be loaded!\tErr: " << IMG_GetError() << "\n";
        success = false;
    }
    return success;
}

void close()
{
    SDL_FreeSurface(gHelloWorld);
    gHelloWorld = NULL;

    SDL_DestroyWindow(gWindow);
    gWindow = NULL;

    SDL_Quit();
}

sdl is fun

hidden gorge
#

wtf

wheat mesa
#

the result lmfao

quartz kindle
#

lmao

hidden gorge
quartz kindle
#

wat

hidden gorge
#

me and my friend now own a bot approved on top.gg

quartz kindle
#

cool

wheat mesa
#

uvuvwevwevwe onyetenyevwe ugwemubwem ossas

drowsy flume
#

anyone know why this is happening when my bot is verified

pale vessel
#

you turned on a privileged intent that your bot was not approved for

drowsy flume
#

but I thought that isnt needed until april 30

pale vessel
#

either guild members or guild member presences intent

drowsy flume
#

I sent an application, but discord never emailed me saying I did

#

anyone know how long it takes them to accept / deny the application for intents

sage bobcat
#

One message removed from a suspended account.

quartz kindle
#

@sage bobcat

sage bobcat
#

One message removed from a suspended account.

quartz kindle
#

@sage bobcat

sage bobcat
#

One message removed from a suspended account.

quartz kindle
#

@sage bobcat Faithy

hidden gorge
#

itโ€™s hard being a bot dev lol

#

and also exhausting

hybrid cargo
hidden gorge
#

well this is me @hybrid cargo

wheat mesa
#

...ok?

solemn jolt
#

hello I try to connect my Heroku application to discord webhook but this is don't work and Heroku is getting me this

{"message": "Cannot send an empty message", "code": 50006}
sudden geyser
#

That seems to be an error from Discord.

#

It means you aren't supplying content to be sent with the embed message

#

Like passing an empty string.

lament rock
#

not just with an embed

#

in a message in general

sudden geyser
#

meant message

solemn jolt
#

i think about somthing

#

heroku just send the json

#

not the embed

lament rock
#

you have to supply either a non empty content string, an array of embed(s) or an array of file(s)

solemn jolt
#
    {
    "id": "3e3a2b50-b52f-4bbc-a837-37c046befe20",
    "created_at": "2022-02-12T05:21:22Z",
    }
#

like this

lament rock
#

That doesn't work

solemn jolt
#

then how i can connect it ?

lament rock
#

channel.send(JSON.stringify(data))

#

assuming you're using JS

solemn jolt
#

this is mean i need to create a code to connect it like get the heroku json and change it to embed\

lament rock
#

I don't understand

solemn jolt
#

heroku have a webhook too

lament rock
#

When you pass a raw json to send to a channel, the lib you're using is assuming that it's data that can be transformed to raw data to send to Discord, which isn't the case in this instance. Most channel send functions in libs offer an overload to quickly send a string as content

solemn jolt
#

ok

#

ty

lament rock
#

I really can't see the appeal of people trying to make their own Discord lib. It's such a large commitment, that it most often ends up being a waste of time

#

most of my time is spent reading commit history instead of writing actual code which sucks

#

Modals seem really situational as well

solemn jolt
#

why this code is dont work

message.mentions.members.second()
round cove
#

good question

solemn jolt
#

๐Ÿ˜… what i do wrong in this code

round cove
#

Would help if I knew what error you had.

solemn jolt
#
2022-02-12T07:21:14.626739+00:00 app[worker.1]: /app/commands/Images/bed.js:24
2022-02-12T07:21:14.626756+00:00 app[worker.1]:         const user2 = message.mentions.members.second() || message.guild.members.cache.get(args[1])
2022-02-12T07:21:14.626756+00:00 app[worker.1]:                                                ^
2022-02-12T07:21:14.626757+00:00 app[worker.1]: 
2022-02-12T07:21:14.626758+00:00 app[worker.1]: TypeError: message.mentions.members.second is not a function
2022-02-12T07:21:14.626758+00:00 app[worker.1]:     at Bed.run (/app/commands/Images/bed.js:24:48)
2022-02-12T07:21:14.626758+00:00 app[worker.1]:     at module.exports.run (/app/events/messageCreate.js:148:11)
2022-02-12T07:21:14.626759+00:00 app[worker.1]:     at processTicksAndRejections (node:internal/process/task_queues:96:5)
#

this is the error

pearl trail
#

.second exist?

#

from what i see, it doesnt exist

solemn jolt
#

i try to get 2 mention user by this code

        const user = message.mentions.members.first() || message.guild.members.cache.get(args[0])
        const user2 = message.mentions.members.second() || message.guild.members.cache.get(args[1])
#

the fist one is work

#

but the second is not

pearl trail
#

yeah .second is not a thing in discordjs Collection

round cove
#

There's only first and last*.

solemn jolt
#

then what i need to do

#

i want to get second mention

earnest phoenix
#

you can always do .entries on members and get the second one from that

round cove
#

I mean you could probably do const members = message.mentions.members.values() and get an array

pearl trail
#

you might want to do this
[...message.mentions.members].map(x => x[1])[1]

earnest phoenix
#

What the fuck

#

That is dumb

round cove
#

I'm glad we all gave different answers.

pearl trail
round cove
#

LOL

earnest phoenix
#

Yui's answer works but that is putting twice the effort into something simple

round cove
#

spread the array and then wrap it into an array again

#

LOL?

pearl trail
earnest phoenix
#

And I bet it probably has a performance issue as well

earnest phoenix
#

members would then become an array yes

round cove
earnest phoenix
#

Why do you want the second mention though

round cove
#

Probably a hug command or something.

earnest phoenix
#

Mmm

solemn jolt
earnest phoenix
#

๐Ÿ‘€

#

I wont ask further

solemn jolt
#

work

#

LOL

high flint
#

Wkkwkwkkw

slow terrace
#

Hello,
how can i get the user who voted for my bot?

rose igloo
#

Hi

pulsar bone
#
  if 'test' in message.content:
    db[message.author.id] = int(5)
  if 'test2' in message.content:
    f= int(db[message.author.id])
    g= f + 5
    await message.channel.send(g)

error:-

Ignoring exception in on_message
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 351, in _run_event
    await coro(*args, **kwargs)
  File "main.py", line 44, in on_message
    f= int(db[message.author.id])
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/replit/database/database.py", line 439, in __getitem__
    raw_val = self.get_raw(key)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/replit/database/database.py", line 477, in get_raw
    r = self.sess.get(self.db_url + "/" + urllib.parse.quote(key))
  File "/usr/lib/python3.8/urllib/parse.py", line 851, in quote
    return quote_from_bytes(string, safe)
  File "/usr/lib/python3.8/urllib/parse.py", line 876, in quote_from_bytes
    raise TypeError("quote_from_bytes() expected bytes")
TypeError: quote_from_bytes() expected bytes
quartz kindle
dry imp
eternal osprey
#

How do i get what day it is today

#

I know its Date.now() and that i can format it, but how can i only get the day it is atm

#

So: Tuesday

#

or Wednesday

solemn latch
#

It's February 12th

eternal osprey
earnest phoenix
solemn latch
#

It's .day() or something lemme double check

#

.getDay()

Will return an int, 0 = Sunday
6 = Saturday

eternal osprey
#

hahah yeah i just saw it online, never knew that .getDay() was a thing. Thank you wowoowo!

earnest phoenix
#

how can i make something like

#

a timeout but without restarts

#

It'll countdown every 12h and change shop items, but I don't want it to restart every time the bot does, any solution?

spark flint
#

setTimeout

modest maple
solemn latch
#

set Interval is probably better, as the function to change shop items is probably always the same thing.

waxen idol
#

i noticed that when you add your bot on the website, when you insert your app ID, the field "short description" is autocompleted with your app's description, i'd like to know how to get the description of a user or bot using the discord api or an other method because i need this feature for my bot

spark flint
#

Wait fuck

#

Wrong channel

solemn latch
waxen idol
solemn latch
#

at the moment that's unavailable to bots.

waxen idol
#

ok thanks for the infos!

quartz kindle
solemn latch
#

oh i see, i misunderstood ๐Ÿ‘€

eternal osprey
#
  const collector = new Discord.MessageCollector(message.channel, filter, {
      max: questions.length,
      time: [60000]
     
    })```how would i set the filter to work in a dmchannel of a user defined as user1?
quartz kindle
#

await message.author.createDM() to get the dm channel

#

filter is the same as any other, check for the author id

eternal osprey
#

Thanks tim!

earnest phoenix
earnest phoenix
#

and is there a better way to accomplish this? (shorter way) ```js
if (rarity === "Common") {
if (lvl === 1) req = 1;
if (lvl === 2) req = 2;
if (lvl === 3) req = 4;
if (lvl === 4) req = 10;
if (lvl === 5) req = 20;
if (lvl === 6) req = 50;
if (lvl === 7) req = 100;
if (lvl === 8) req = 200;
if (lvl === 9) req = 400;
if (lvl === 10) req = 800;
if (lvl === 11) req = 1000;
if (lvl === 12) req = 2000;
if (lvl === 13) req = "Max";
}

#

one time is nothing but i'm doing it repeatedly with other rarities

quartz kindle
slender thistle
#

If you do the same thing, you can create a function to avoid repeating. I could suggest a Map with the level as key and req as the value

#

Or that yeah

quartz kindle
# earnest phoenix from when the bot starts and infinitely

so like, the bot starts, run it once, then set a timeout to run it again every 12 hours? but if the bot restarts after like 2 hours, then it will run again, and 12 hours after that, meaning instead of 0-12-24 it would run at 0-2-14-26

earnest phoenix
#

oh

#

better i do it manually, it's not a big problem tho

#

ty anyways

quartz kindle
#

if you want it to be fixed at 12 hours, regardless of bot restarts, you can do it with a bit of math

quartz kindle
#

reqs is an array, arrays are zero indexed

earnest phoenix
#

the reqs[lvl -1] part

quartz kindle
#

for example ["a", "b", "c"] means "a" is at index 0, "b" is at index 1, etc

#

if your lvl starts at 1, then you need - 1 to get the first item in the array

#

because arrays start at 0

earnest phoenix
#

oh then this'll work same as my ifs?

quartz kindle
#

yes

earnest phoenix
#

ty

#

if my level starts in level 2, how is it?

quartz kindle
#

-2

earnest phoenix
#
  • 1?
#

ok

quartz kindle
#

you have to convert lvl to index

#

index always starts at 0

#

so you always have to convert the start level to 0

#

if start level is 5, then 5-5 = 0

earnest phoenix
#

now i'm confused

cinder patio
#

you could just use an object

#

more readable

quartz kindle
#

how do you get "a" ? you do object[0]. and to get "c"? you do object[2]

earnest phoenix
#

Anyone know a good discord.js slash command lib?

#

Or just how to use them in discord js

atomic kindle
#

If you want a boilerplate I can give you mine.

atomic kindle
hidden gorge
#

time to get to work on my bot

earnest phoenix
#

I'm a fucking noob when it comes to making discord.js slash commands

atomic kindle
#

I'll link you to the gist once I am on my laptop.

earnest phoenix
#

Okay

hidden gorge
#

lol i have a developer team of 4 people working on one bot

earnest phoenix
#

And i'm doing this


client.on('interactionCreate', async interaction => {
    if (!interaction.isCommand()) return;

    if (interaction.commandName === 'ping') {
        await interaction.reply('Pong!');
    }
});```
#

for slash commands rn but the old commands don't go away

#

What could be the issue?

atomic kindle
#

It takes time for cache to flush.

hidden gorge
#

@earnest phoenix this is what iโ€™m doing rn

earnest phoenix
hidden gorge
atomic kindle
#

Are you pushing the commands to discord?

earnest phoenix
hidden gorge
round cove
#

If you made global commands before and changed command names so it's not the same they wont go away you'll have to delete ALL the commands first then regenerate them.

earnest phoenix
atomic kindle
hidden gorge
earnest phoenix
wheat mesa
#

Why not start it yourself @hidden gorge

#

Command handlers arenโ€™t hard

atomic kindle
#

And deletes all commands that are non existent in the new array of commands.

hidden gorge
earnest phoenix
#

Ah

hidden gorge
#

idiot*

wheat mesa
#

Also youโ€™re using a deprecated event

earnest phoenix
hidden gorge
atomic kindle
#

#general for chat maybe? It gets confusing if you chat here...

atomic kindle
earnest phoenix
#

Oh okay

#

Thank you

earnest phoenix
quartz kindle
#

the first result exists in object[0], but you dont have a level 0

#

so how would you ever get the first result?

earnest phoenix
#

oh wait

#

the - 1 is the level?

#

and the index

#

?

quartz kindle
#

const req = reqs[lvl - 1];

#

if lvl is 1, with -1 it becomes 0, so it gets the first item in the array/object

earnest phoenix
#

so if the level is 3, it'll be const req = reqs[lvl - 3];?

quartz kindle
#

if level is 5, then with -1 it becomes 4, so it gets the 5th item in the array/object

#

if level is 22, then with -1 it gets the 22nd item in the array/object

#

because the level starts at 1, but the array starts at 0, the difference is always -1

earnest phoenix
#

ohhh

#

ty for the explanation

#

now I understand

#

the lvl is from the db so I don't need the "if === epic", "if === rare"...

quartz kindle
#

yes

blissful falcon
#

So I'm having trouble making commands; I make a file, fill the file with the command I want, deploy the command to the guild and I do not see it when I do /{command_name}

earnest phoenix
#

lol why is it this hard to get new cards?

#

i'm just doing this ```js
if (arena <= 0) commorate = 2;
if (arena === 1) commorate = 4;
if (chss.rarity == 'Common') chr = Array(commorate).fill('nada');
if (chss.rarity == 'Rare') chr = Array(24).fill('nada');
if (chss.rarity == 'Epic') chr = Array(39).fill('nada');
if (chss.rarity == 'Legendary' || chss.rarity == 'Champion') chr = Array(84).fill('nada');
chr.push('chr');

#

I can understand rare, epic or legendary but commons are hard equally

lyric mountain
#

boy

#

please use switch when due

#

also idk what exactly you're doing there

#

other than filling arrays with nada

quartz kindle
#

i dont either

#

need more code

earnest phoenix
#

I can explain

#

common, rare... are rarities

#

i'm filling with nada to later choose a random content from length

quartz kindle
#

thats very inefficient

earnest phoenix
quartz kindle
#

and wheres the code that does the random selection?

earnest phoenix
#

before i used some math.random from here but it was too easy to get cards

#
let chra = chr[Math.floor(Math.random() * chr.length)];
#

that's the random selection

quartz kindle
#

and you want common to be 1 in 5?

#

rare 1 in 25

#

etc

#

?

earnest phoenix
#

yeah something like that

#

1 common in every 5/10 chests

quartz kindle
#

but if the rarity is rare, if they dont get rare, should they still try to get common?

#

or do they get nothing?

earnest phoenix
#

they get xp for owned cards

quartz kindle
#

yes but like

#

if rarity is rare

#

you have 1 in 25 chance of winning

#

if you dont win, do you still have a 1 in 5 chance to get a common?

earnest phoenix
#

no

#

it's definitive

quartz kindle
#

so its always "or nothing"

earnest phoenix
#

yeah

quartz kindle
#

then its much easier to use Math.random() directly, without arrays

earnest phoenix
#

but will be better with your suggestion

quartz kindle
#

Math.random() gives you a random number between 0 and 0.9999999

#

so if you do for example if(Math.random() > 0.8)

#

thats basically 1 in 5 chance for the random number to be bigger than 0.8

earnest phoenix
#

then it's similar to this

quartz kindle
#

yes

#

thats a much more efficient solution

earnest phoenix
#

this worked a while but I tried removing all my data and starting new, but then I saw that it's really easy to get cards

quartz kindle
#

then you need to adjust the numbers

earnest phoenix
#

Yeah used that too

quartz kindle
#

0.5 for example is 1 in 2 not 1 in 5

#

0.9 is 1 in 10

earnest phoenix
#

0.01 is 1 in 100?

quartz kindle
#

with the code from init you showed above, 1 in 100 would be 0.99

earnest phoenix
#

oh

#

then 0.999 will be 1 in 1000

quartz kindle
#

yes

earnest phoenix
#

that's why it didn't work

quartz kindle
#

0.01 is basically 99% chance of winning

earnest phoenix
#

lol

#

but ok, tysm

#

will try

quartz kindle
#

that answer was about a different comparison

#

if Math.random() < 0.001

earnest phoenix
#

realized it

quartz kindle
#

init's code is doing a different comparisonl

lyric mountain
#

also remember that rng is unbiased (well, mostly)

#

so you can always get 10 legendaries in sequence

#

or none in 1000000 tries

earnest phoenix
#

oh

quartz kindle
#

well, thats why its random

earnest phoenix
#

well no problem

lyric mountain
#

if you do want to GUARANTEE that at least one WILL drop in 100 tries you need to bias the rng

#

like store how many tries since last legendary drop

earnest phoenix
#

it depends on player's luck

feral aspen
#

FetchError: request to https://top.gg/api//bots/stats failed, reason: connect EHOSTUNREACH 2606:4700::6810:ae38:443

#

Ahh.. I love when this CRASHES MY BOT.

earnest phoenix
hidden gorge
#

oh god

#

i had to blur out the IP

lyric mountain
hidden gorge
lyric mountain
feral aspen
spark flint
lyric mountain
hidden gorge
lyric mountain
#

for sure it is

spark flint
#

Also what are you trying to show in that pic

hidden gorge
lyric mountain
#

probably that 48% cpu spike

#

but I'm not sure

feral aspen
# lyric mountain catch the error

What am I supposed to be catching? ๐Ÿ˜‚

module.exports = async bot => {
    try {
        const AutoPoster = require("topgg-autoposter");
        const ap = AutoPoster(process.env.TOP_GG, bot);
    
        ap.on('posted', () => console.log('Successfully posted the server count at "Top.gg API".'));
    } catch {
        console.log('Failed to post the server count at "Top.gg API".')
    };
};
hidden gorge
lyric mountain
#

AutoPoster actually

feral aspen
#

I have node 17-4-0, even catching crashes it. ๐Ÿ’€

lyric mountain
#

or ap.on

#

whatever is a promise there

feral aspen
#

I don't know, dude. :/

#

It should be catched by } catch {.

lyric mountain
#

not for promises

quartz kindle
#

if ap is an event emitter

#

then there should be an ap.on("error")

lyric mountain
#

tim uses double quotes for js too (โœฟโ—กโ€ฟโ—ก)

feral aspen
#

What do you call the "error"?

#

A listener or... ?

quartz kindle
#

yes, an error listener

feral aspen
#

Oh, if it was called 'posted', it's called the posted listener?

#

Basically, a listener.

quartz kindle
#

yes

feral aspen
#

I can't seem to find the list of listeners on the documentation.

quartz kindle
#

posted is the name of the event

feral aspen
#

Ohh..

quartz kindle
#

so a listener for the posted event would be the event listener

lyric mountain
#

async stuff never gets caught with try-catch cuz they run in an entirely different context

quartz kindle
earnest phoenix
#

How can I check if an arg is undefined in js (for my bot in discord.js)?

quartz kindle
#

this is in the topgg-autoposter source code

#

so yes, there is an error event

#

however, it should not be crashing your bot

lyric mountain
earnest phoenix
#

Alright, thanks

quartz kindle
#

if a listener for the error event is not found, it should default to console.error

#

which does not crash the bot

feral aspen
quartz kindle
#

yes

lyric mountain
#

you can also omit error => and just do ap.on("error", console.log)

feral aspen
#

Oh, fair enough.

#

My bot is starting but the commands aren't working, I never touched my bot for 4 days. ;-;

earnest phoenix
feral aspen
#

Nope.

#

It's not even logging that a command is being used.

lyric mountain
#

any muted exceptions?

feral aspen
#

Weird, shard 0 has been launched.

lyric mountain
#

by muted exceptions I mean try { code } catch { nothing }

feral aspen
#

Oh.. no.

#

I don't do that except at guild events.

lyric mountain
#

do u use pm2?

feral aspen
#

Indeed.

lyric mountain
#

how many crashes today?

#

you might have been ratelimited for excessive IDENTIFY attempts

feral aspen
#

I'm afraid I don't understand.

feral aspen
lyric mountain
#

like, you can only login so many times in 24h

#

if your bot keeps crashing and restarting you might hit that limit

feral aspen
#

can or can't?

hidden gorge
#

well thatโ€™s just great i just had a hosting server failure

lyric mountain
feral aspen
#

What's the limit?

#

30? 40?

lyric mountain
#

I don't remember exactly

#

but it's high enough to not be hit normally

slender thistle
#

Wasn't it 1000 per like minute or hour

lyric mountain
#

unless you have an obscene amount of shards or got stuck in a restart loop

lyric mountain
slender thistle
#

Shrug

feral aspen
slender thistle
#

Point still stands though, the ratelimit is being hit ๐Ÿ˜†

lyric mountain
#

heavy load, so the server loses some requests

#

what u got there was the whole cloudflare error page in html

#

that was fast

hidden gorge
#

i gotta re code my bot great

#

my developer team didnโ€™t setup command handling so i gotta do that now

boreal iron
#

You better choose a different team then topggGuns

lyric mountain
quartz kindle
#

with a bunch of if elses ?

lyric mountain
#

that's haram

boreal iron
#

That what like most people have done in the beginning I guess freerealestate

earnest phoenix
#

How to web dev

#

:)

spark flint
#

Develop the web

earnest phoenix
#

gotcha

#

let me do that

azure lark
#

is there a way of check if a message collector ended because the time ran out with djs?

hidden gorge
#

@harsh nova

spark flint
#

LETS GOOO

#

FREE CRYPTO

hidden gorge
#

SCAM ABOVE

wheat mesa
#

FREE CRYPTO????

hidden gorge
#

ha he got banned

earnest phoenix
#

one last question @quartz kindle, if 0.9 is 1 in 10, then how will it be 1 in 20 and so on?

wheat mesa
#

Anything greater than 0.95 is about 1 in 20

#

(If youโ€™re using Math.random() Iโ€™m assuming)

earnest phoenix
#

oh

#

then 1 in 30?

wheat mesa
#

Think of it as percentages

#

0.95 is 5%

#

0.99 is 1%

earnest phoenix
#

oh that makes things easier

wheat mesa
#

1 in 30 would be about 3.33%, so it would be 0.9667 ish

earnest phoenix
#

nvm it's hard

wheat mesa
#

How

earnest phoenix
#

how I calculate

wheat mesa
#

For 1 in 30, do 1 - 1/30

#

For 1 in 50, do 1 - 1/50

#

Etc

earnest phoenix
#

oh

#

works

#

tysm

wheat mesa
#

๐Ÿ‘

earnest phoenix
#

when the number is like this, should i put it all?

wheat mesa
#

You can round it to the precision you think is correct

earnest phoenix
#

but will it be correct to put all?

wheat mesa
#

It would be more accurate, yes, but probably not necessary

earnest phoenix
#

ok

wheat mesa
#

Considering a number like that expands infinitely anyways

earnest phoenix
#

ok

#

tysm

wheat mesa
#

Depending on how small the probability is, 4-5 decimal places should be enough

#

But if you have really small probabilities then using more decimal places is likely necessary

earnest phoenix
#

ok

#
  async getRepos(): Promise<IGithubUserRepo[]> {
    // @ts-ignore
    const { data } = await this.octokit.request('GET /users/{username}/repos', {
      username: 'MistyyBoi'
    }) as IGithubUserRepo[]
    const repos = data.filter((r: IGithubUserRepo) => !r.private)
    return repos
  }

  async getCommits(): Promise<Map<string,number>> {
    const repos = await this.getRepos()
    const map: Map<string, number> = new Map()
    for(let repo of repos) {
      const { data } = await this.octokit.request('GET /repos/{owner}/{repo}/commits', {
        owner: 'MistyyBoi',
        repo: repo.name
      })
      map.set(repo.name, data.length)
    }

    return map
  }

Love how i get repos and commits?

wheat mesa
#

Uh... no?

#

๐Ÿ˜‰

earnest phoenix
#

Well blame github

#

they don't make it easy to get commits of a repo

#

They should just give you the commit count and shit

#

instead they give you the commits api url

wheat mesa
#

They have a webhook system

#

For updates to repos

earnest phoenix
#
export interface IGithubUserRepo {
  id: number;
  node_id: string;
  name: string;
  full_name: string;
  owner: IGithubRepoOwner
  private: boolean;
  html_url: string;
  description: string;
  fork: boolean;
  url: string;
  archive_url: string;
  assignees_url: string;
  blobs_url: string;
  branches_url: string;
  collaborators_url: string;
  comments_url: string;
  commits_url: string;
  compare_url: string;
  contents_url: string;
  contributors_url: string;
  deployments_url: string;
  downloads_url: string;
  events_url: string;
  forks_url: string;
  git_commits_url: string;
  git_refs_url: string;
  git_tags_url: string;
  git_url: string;
  issue_comment_url: string;
  issue_events_url: string;
  issues_url: string;
  keys_url: string;
  labels_url: string;
  languages_url: string;
  merges_url: string;
  milestones_url: string;
  notifications_url: string;
  pulls_url: string;
  releases_url: string;
  ssh_url: string;
  stargazers_url: string;
  statuses_url: string;
  subscribers_url: string;
  subscription_url: string;
  tags_url: string;
  teams_url: string;
  trees_url: string;
  clone_url: string;
  mirror_url: string;
  hooks_url: string;
  svn_url: string;
  homepage: string;
  languages: number | null | undefined | string
  forks_count: number;
  stargazers_count: number;
  watchers_count: number;
  size: number;
  default_branch: string;
  open_issues_count: number;
  is_template: boolean;
  topics: Array<string>;
  has_issues: boolean;
  has_projects: boolean;
  has_wiki: boolean;
  has_pages: boolean;
  has_downloads: boolean;
  archived: boolean;
  disabled: boolean;
  visibility: string;
  pushed_at: string;
  created_at: string;
  updated_at: string;
  permissions: IGithubUserRepoPermissions
  template_repository: string | null | undefined
}

All the lovely data you get back when requesting for a repo

#

Not what I am using this for

#

The numbers are the amount of commits that repo has

lyric mountain
#

make a git globe like in github

last tapir
#

how can i check if a command isn't executed by a group of users then return

lyric mountain
#

that shows real-time pushes

last tapir
#

i want to input the specific user ids

lyric mountain
earnest phoenix
last tapir
#

like if (message.author.id != id1 id2 id3) return;

lyric mountain
#

NO

earnest phoenix
#

use includes

wheat mesa
#

Make an array of IDs and use includes

lyric mountain
#

OR IS NEVER AN OPTION AFTER EQUALS

wheat mesa
#

Lol

lyric mountain
#

carve this in ur head

earnest phoenix
#
if(![arrayOfIds].includes(msg.author.id)) return;
wheat mesa
earnest phoenix
#

I can't figure out how to center it tho without fucking up the grid

spark flint
#
TypeError: connection.execute is not a function```
#
const mysql = require('mysql2/promise');
const bluebird = require('bluebird');

const connection = mysql.createConnection({
    host     : 'server',
    user     : 'user',
    password : 'password',
    database : 'dbname'
});

(async () => {
    const allUsers = await connection.execute('SELECT * FROM `blacklist`');
    allUsers.forEach(function(user) {
        console.log(user[0])
    })
})();```
split hazel
#

pov you import bluebird but dont do global.Promise = bluebird;

spark flint
#

oh fuck i see

#

forgot Promise: bluebird

#

been a long time since i used sql

#

moving away to a selfhosted mongo instance

split hazel
#

no idea why that error happens though

#

can you try query instead of execute

spark flint
#

same error

split hazel
#

you know what just log connection

#

ohhhhhhhhhhhhhhhhhhhhhhh waitttttttttttttttttttttttttttttttttttttttttt

#

createConnection could be a promise

spark flint
#

oh wait yeah

#

yeah it is

split hazel
#

next time keep your promises

#

you should also setup eslint to prevent things like that in the future

lament rock
#

Use of TypeScript + ESLint = cleaner and less error prone code

split hazel
#

do you need eslint when you're using typescript

#

and i personally stay away from typescript

#

it slows down my productivity

#

i often make and abandon a ton of projects and the ts setup just takes absolute ages

earnest phoenix
#

Eslint just annoys the fuck out of me

#

I delete eslint configs from projects that I use a gen on like angular, nestjs, etc

lament rock
#

The opposite for me. ESLint catches a few issues TS doesn't, plus consistent code style an old colleague of mine and I made up

earnest phoenix
#

I can't stand eslint

split hazel
#

then sit down

earnest phoenix
#

Did anyone ask for ur smartass comments :c

split hazel
#

no

#

i dont need to ask anyone

#

look at my avatar

#

i have sunglasses

earnest phoenix
#

no

split hazel
#

you only have a stupid hat

#

look how cool i am

#

also did i mention this avatar costs 3k

earnest phoenix
#

Did you just call my otter stupid

spark flint
#

no stupid otters here

#

only call ones

#

cool*

#

fucjk

#

i can't spell

woeful pike
spark flint
#

idk

#

but i'm ditching mysql

#

and using mongo

split hazel
#

idk exactly how but

woeful pike
split hazel
#

it says its faster and more memory efficient and supports cancellation

#

so i trust it

modest maple
#

Rip insteed

woeful pike
#

I can't imagine myself ever moving to mongo

modest maple
#

pithink Going from a perfectly ok relational DB to mongo

#

For a system that is largely wide column / relational

woeful pike
split hazel
#

i think mongo is one of the most heavy databases out there

modest maple
#

because it is

#

you add like 50 million records and it's eating up 5GB of Ram from the get go

split hazel
woeful pike
#

you know what's an interesting db

modest maple
#

Sled is nice

woeful pike
#

I've never had the chance to use it

modest maple
#

We use it for out metadata store in lnx

#

Its really nice for rust because it's threadsafe unlike Sqlite

split hazel
#

@woeful pikethis is interesting

spark flint
#

Never gonna get many

split hazel
#

so bluebird is essentially dead yeah

modest maple
spark flint
#

Because I hate MySQL

woeful pike
#

native promises used to be big time garbage but they're fine now

modest maple
spark flint
#

I use mariadb

modest maple
#

So why do you hate it?

spark flint
#

Thatโ€™s installed on the webserver I use ๐Ÿ˜‚

#

I just prefer Mongo

modest maple
#

๐Ÿ‘ Schemas exist to help you

woeful pike
#

one day I will find a usecase for mongodb

modest maple
#

will you though?

woeful pike
#

big doubt

split hazel
#

is mysql too different from mariadb (other than different storage engines)

modest maple
#

they're the same

#

Maria is a drop in replacement for MySQL

split hazel
#

ignoring the fact ones ran by an evil corporation

woeful pike
#

every time I've picked up mongo it's like how do I put relationships in this non-relational database

#

and then I go back to a relational db

modest maple
#

Mongo is relational

#

believe it or not

woeful pike
#

just store everything in the same document

modest maple
#

๐Ÿคก It's a complete meme of a system though

woeful pike
#

incredibly big brain

modest maple
#

no like

woeful pike
#

yeah they do actually have a concept of foreign keys now

modest maple
#

i litterally mean it has relations

#

but just

spark flint
#

At least I no longer store all my blacklist in a single json file

modest maple
#

holy moly they're slow and awkward

spark flint
#

I did 3 months ago

woeful pike
#

you can do some black magic to get data integrity too right

modest maple
#

not sure

woeful pike
#

does schema validation support foreign keys

#

it just makes me feel like... if the goal was to get away from relational databases why are you adding that exact concept back to mongo instead of just using something that was meant to work that way from day 1

split hazel
#

only thing i like about mongo is you can nest objects and arrays

#

thats about it

#

even then it looks good on paper but can become difficult to query

woeful pike
#

it's a bit of a pitfall to think about databases the same way you think about objects in memory

modest maple
#

people went "oh new tech" and then went "oh wait actually relations are nice, schemas are nice"

spark flint
#

I love starting db wars

modest maple
#

not really wars

earnest phoenix
#

Lmao

spark flint
#

I just hate MySQL and prefer mongodb

earnest phoenix
#

i am using MongoDB too

#

๐Ÿ˜‹

lyric mountain
#

mysql is shitty yes

spark flint
#

I just switched to MySQL originally because it was the only one I really had access to/knew how to use

lyric mountain
#

use maria then

woeful pike
#

Im going to use scylla because discord uses it yurihacker

modest maple
#

Scylla is nice

#

I went to their Summit conference last week

lyric mountain
#

maria is mysql but less random seizures

modest maple
#

was very cool talking to everyone

woeful pike
#

if discord jumped off a bridge-

split hazel
#

im gonna use quick.db because turkish bots use it

spark flint
#

I should specify that

modest maple
#

Scylla low key scarely fast though

woeful pike
#

I do want to try cassandra/scylla but where tooling

#

do I need to write raw queries for every single operation

lyric mountain
modest maple
#

I mean Scylla supports REST, Dynamo drivers and Cassandra drivers

#

just FYI

split hazel
woeful pike
#

damn that's nice

split hazel
#

sequelize but cassandra

#

(sequelize sucks)

modest maple
#

Also I dont think you massively need it as much as your do SQL

#

your queries are always going to be simple

#

you're never going to have sub queries or these complicated join aggregations etc...

woeful pike
#

is that a wide column thing or

modest maple
#

it's mostly a performance thing

woeful pike
#

like what do you do instead

split hazel
#

also may i ask are bots on the website stored separately to bots in the queue

modest maple
#

JOINs are very expensive

#

and people use them too liberally

#

so it forces you to manually write your joins

#

or rethink your structure in a more wide column design

woeful pike
#

but if you're not doing joins on the database layer you're doing it at the application layer no?

#

that's kinda the original mongodb problem

modest maple
#

which is actually quite nice once you get over the initial hump

#

bearing in mind it has concepts of arrays, maps and set as first class types

#

so your lookups with them are incredibly fast and efficient

woeful pike
modest maple
#

2 separate queries is cheaper than 1 query doing a JOIN equivalent to the 2 queries

woeful pike
#

it's more efficient to do multiple round trips?

modest maple
#

yeah

#

by alot

woeful pike
#

huh

#

gotta learn more about how that works

modest maple
#

the drivers are able to pre-calculate what node they need to send the query to

#

so you go directly to the right node for each set of values you want to read and write on

woeful pike
#

that's kind of sick

modest maple
#

and in some case it can even target the exact core/shard

#

this is the whole Token aware system

#

Which gives you these scary setups like my current project in progress which has a mean latency of 1ms or less

woeful pike
#

is this in cases where you have a partition key you're doing lookups by that the db knows the right node to go to for that query?

modest maple
#

yeah

woeful pike
#

wouldn't you have to like restructure your db as you need different kinds of lookups then

modest maple
#
let users = vec![12, 123, 1234];
session.query_prepared("SELECT * FROM users WHERE id = ?", (users,).await?:

very fast

modest maple
woeful pike
#

tho I guess you literally do that when you add new indexes in relational dbs

modest maple
#

it forces you to rethink your design from the relation based system

#

Relationships tend to cripple performance at large scale

woeful pike
#

so you have the same denormalization issue as mongodb

modest maple
#

ish

woeful pike
#

I mean I guess that's the tradeoff, can't be too mad

modest maple
#

ngl

#

it is nice once you get used to it

#

because suddenly you go "oh i dont need redis or cache"

woeful pike
#

is it too much of a pain to change things once you need different kinds of business logic? Cuz you can't expect to perfectly plan out your db schema ahead of time

modest maple
#

and then go "oh it is so much easier to read without the joins

modest maple
woeful pike
#

hmmm

#

I could see that being an issue if you're just starting out

#

I guess cassandra and friends are there to solve a scaling issue once you have a fleshed out db with known data access patterns?

modest maple
#

a bit, although the simpler structure points out problems faster tbh

#
#[derive(Object, FromRow, ValueList, FieldNamesAsArray, Debug, Clone)]
#[oai(rename_all = "camelCase")]
pub struct DiscordRegisteredUser {
    pub id: JsSafeBigInt,
    pub username: String,
    pub discriminator: JsSafeInt,
    pub avatar: Option<String>,
    pub guilds: Vec<JsSafeBigInt>,
    pub co_owned_guilds: Vec<JsSafeBigInt>,
    pub created_on: Timestamp,
}
derive_upsert!(DiscordRegisteredUser, table = "users");

My lovely lil helper system for db models

cinder patio
#

I only use the free mongo cloud clusters for small projects, otherwise postgreSQL all the way

blissful falcon
#

So I'm having trouble making commands; I make a file, fill the file with the command I want, deploy the command to the guild and I do not see it when I do /{command_name}

spark flint
#

caching applies of course

#

try refreshing discord

#

and sometimes readd the bot

sudden geyser
#

If you just created new commands (as in the command wasn't registered before), it can take up to an hour to appear.

#

If you created guild commands, they should appear instantly, but you may need to run a command to have Discord refresh the list.

blissful falcon
sudden geyser
#

any command, though it should still appear instantly regardless

blissful falcon
#

But I also deleted a command and updated it and it was still there.

sudden geyser
#

can you share the file

blissful falcon
#

Which file?

#

The one I made or deleted?

sudden geyser
#

deploy-commands-guild.js

blissful falcon
#

Alr.

blissful falcon
# sudden geyser `deploy-commands-guild.js`
const Discord = require('discord.js');
const { SlashCommandBuilder } = require('@discordjs/builders');
const { Permissions, MessageButton, MessageActionRow, MessageSelectMenu } = require('discord.js');
const { token } = require('discord.js');
const clientId = require('discord.js');


const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');

const fs = require('fs');

const commands = [];
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));

// Place your client and guild ids here
"guildId"; "Id for the main guild"
"clientId"; "Id of my bot"

for (const file of commandFiles) {
    const command = require(`./commands/${file}`);
    commands.push(command.data.toJSON());
}

const rest = new REST({ version: '9' }).setToken(token);

(async () => {
    try {
        console.log('Started refreshing application (/) commands.');

        
            Routes.applicationCommands(clientId),
            { body: commands },
        

        console.log('Successfully reloaded application (/) commands.');
    } catch (error) {
        console.error(error);
    }
})();```
sudden geyser
#
Routes.applicationCommands(clientId),
{ body: commands },

Is this supposed to update the application commands? This looks incorrect.

blissful falcon
#

Yes, I suppose so.

#

But it was there before I think and it updated it.

#

But I mean, what should I change it to?

sudden geyser
#

A more correct answer would be

await rest.put(Routes.applicationCommands(clientId), { body: commands });

This would update the global commands. It comes from the example on the front page https://discord.js.org/#/docs/discord.js/stable/general/welcome

blissful falcon
#

So it would update the global commands, including the guild commands?

sudden geyser
#

Guild commands are local to a specific guild

#

For example, if you wanted to develop a command in a test server without anyone else seeing it.