#development

1 messages · Page 1720 of 1

boreal pewter
#

and i want it to run on a different process

lusty quest
#

what does the commands do?

#

if you do image manipulation maybe make a internal API and run a external process for this stuff

#

i do this with Tensorflow for one of my Bots

split hazel
#

or boost whatever you're doing with node gyp if you have enough knowledge with that (or if there's a library for it)

cinder patio
#

they're using python

#

I mean you can call c functions from python but not with node-gym

split hazel
#

ah right

#

nowadays I assume everyone's using node here if I don't look

delicate shore
#

ight

vivid fulcrum
#

you can also do postman if you don't fancy working with CLIs

delicate shore
#

Still

#

the same error

#

online

vivid fulcrum
#

thonk

delicate shore
#
{
    "message": "401: Unauthorized",
    "code": 0
}
#

should I send my whole code on a bin

vivid fulcrum
#

sure

delicate shore
vivid fulcrum
#

are you able to dm the access token? i wanna check something

delicate shore
vivid fulcrum
#

sec

delicate shore
#

k

vivid fulcrum
#

i have dms turned off cause of message bots lmfao

#

i sent you a friend rq

delicate shore
#

ight

#

Thanks cry it works

#

I am just dum

earnest phoenix
#
if(reaction.emoji.name === ":white_check_mark:") {
                        let ad = message.channel.send("Veuillez rentrer le salon où envoyer l'embed:")
                        s2.channel.awaitMessages(filter, {max: 1, time: 300000, errors: ['time'] })
                        .then(async collected => {
                         const channel = message.mentions.channels.first() || message.guild.channels.cache.get(args[0]);
                         console.log(channel)
                         channel.send("hey")

                            
                        })```
https://media.discordapp.net/attachments/223867697312694272/835421321583919104/unknown.png
vivid fulcrum
#

channel is undefined

earnest phoenix
#

i know §!!!!

#

how to define channel now

vivid fulcrum
#

...get a channel that exists?

vale garden
#

hi

rustic nova
#

Since I'm still confused about the privileged intents: What exactly would a bot need presence data for?

#

actually nevermind lemme ask that in discord developers

#

Yeah nevermind, definitely not gonna need any of these HYPERKEK

fluid basin
#

good qn tbh

#

but theres quite a few bots with presence intent approved

vivid fulcrum
#

a good example is mod bots that have some anti ad system

#

checking for invite links in activity etc

waxen bough
#

i have anonymous dm system. when a user goes offline the dm session automatically ends

vivid fulcrum
#

i totally did not have a client on fiverr that ordered a program that uses user tokens to display invite links as their activity

long crow
#

it good for those who want to notify who is streaming, with presence intent

vivid fulcrum
#

and i totally did not make that

waxen bough
earnest phoenix
#

wiki12_#8466

boreal pewter
#

it would still take the same time, and hang the bot

fluid basin
#

it would run on another process?

boreal pewter
#

btw 20 seconds is abit much, it ususally takes 2-5 seconds, rare cases are up to 8-10

umbral zealot
#

child_process , IPC, and http APIs , are 3 ways to mitigate this

boreal pewter
#

I am already using multiple sub process for this from within python

umbral zealot
#

actually web workers too

#

oh it's python, right.

vivid fulcrum
#

seems that your underlying issue is that you're executing commands in a blocking manner

signal estuary
#

How do I check if the emoji exists on the server? So if the user writes :thisEmojidoesntExists: --> this emoji doesnt exist on the server. And if you write ❌--> this emoji exists

umbral zealot
#

anything that's async shouldn't block it

vivid fulcrum
#

theoretically, awaiting it puts it in ordered execution which has a close enough effect to blocking

boreal pewter
#

whats weird is that i am doing it asyncly

slender thistle
#

run_in_executor gang

boreal pewter
#
asyncio.ensure_future(prefixed_command(message))
#

and prefixed_command
basically calls the DB for some info, and generates image/gif

old cliff
#

The process stops responding and event execution is delayed for the time its being processed

boreal pewter
#

and if its a gif, it uses multithreading for each frame

umbral zealot
#

Maybe you just need a whole new level of computing power

lament rock
#

gif encoding can be computationally expensive

fluid basin
#

btw python multithreading isnt multiprocessing

lament rock
old cliff
#

Worker threads dont work coz i can't pass a function though it.... or maybe

fluid basin
lament rock
#

You have a predefined script that acts as an api then make local IPC calls to it

old cliff
#

Thats what I was thinking

signal estuary
#

How do I check if the emoji exists on the server? So if the user writes :thisEmojidoesntExists: --> this emoji doesnt exist on the server. And if you write ❌--> this emoji exists

old cliff
#

Move all image stuff to an api

lament rock
#

In my case, image manip isn't that expensive and the biggest bottleneck is actually uploading the image

boreal pewter
#

api wont help

umbral zealot
boreal pewter
#

u still have to await it

fluid basin
umbral zealot
#

await should not be process-blocking, though, Bentzy

boreal pewter
#

well

#

i already am not process blocking

lament rock
#

2 threads doing 2 different things is better than 1 thread being blocked

umbral zealot
#

I mean I don't use python so I don't know but async/await being blocking sounds absolutely wrong

boreal pewter
#

but while im generating gif the bot hangs

umbral zealot
#

Are you sure it's not in the same process

#

because that should only happen if it's in the same process

slender thistle
#

async functions aren't automatically async

fluid basin
boreal pewter
#

well im just using on_message

#

and this apperantly isnt really fully async

#

so if one on_message event still being handled, it hangs

#

or atleast this is what it seems from gifs

#

but i did have random images sent (from different commands) out of order which indicates thats not the case

#

so i dont even know anymore

#

maybe its just a file lock

lament rock
#

In that case, you should probably cache images in mem

#

unless that's totally unreasonable

boreal pewter
#

sadly it is unreasonable

#

i have a web dashboard where u can drag avatars and text with timeline on gif

#

then it generates it real time every time

#

and depends on who you tag in ur command, it places different avatar

#

it all worked pretty good until i had surge in servers and users

#

now with over 5k servers it still works good

#

but a-lot of times it misses on_guild_join and on_member_join

#

even when gifs arent hanging the bot

fluid basin
#

maybe you should scale your web processes?

boreal pewter
#

i assume it really messes with discord api when the bot stops responding and back

#

its on a pretty beefy server rn

fluid basin
#

hmm

boreal pewter
#

this is why i was asking in the beggining

#

can i just seperate it

#

have the gif gen on a different python

fluid basin
#

yeah you could

boreal pewter
#

and run it on the same shards

fluid basin
#

you could make, for example, a imagegen.py

#

that acts as an internal API server

#

and when you generate an image, you provide it with the necessary info to generate the image

umbral zealot
#

Look for custom emoji parsing regex on Google, I certainly don't have that sort of thing off hand.

slender thistle
#

@boreal pewter I was fucking around with websockets for a bit

fluid basin
#

oho

slender thistle
#

And I have two clients like this, one sends a request to server for elements in range from 0 to 1999, the other from 6000 to 7999

#

I'm running all 3 separately and the server seems to be handling stuff just fine

modest maple
#

the real question is

#

why are you using websockets

#

and not aiohttp

slender thistle
#

You mean aiohttp websockets or just aiohttp generally?

modest maple
#

aiohttp websockets

slender thistle
#

Are they more feasible/performant compared to websockets?

signal estuary
#

I want to have the info, how much user have a role. But

let role = args[0]
var InfoRole =  msg.member.guild.roles.cache.find(r => r.name == role);
InfoRole.members.size

doenst work. Can someone help me?

modest maple
#

considerably

slender thistle
#

Because I'm used to using the websockets module

#

I'll have a look at aiohttp websockets later

cinder patio
#

Also... you could look into UDP or TCP, which afaik use less resources than websockets

slender thistle
#

Tru

signal estuary
cinder patio
#

you have to be more specific

#

how does it not work?

#

any errors? something else happens?

signal estuary
#

No I dont get any errors. I just get back a random number, which is wrong

fluid basin
#

the cached amount of users might be different

signal estuary
fluid basin
#

your method is correct, but to get the exact number of users with the role, you will need to fetch the data of all members in the guild

boreal pewter
#

@slender thistle thats cool but how does that relate to me

boreal pewter
#

i still have to upload that image to the text channel at the end

#

so i would need async jobs for that

#

which i can implement

high bobcat
#

Can the ID of the person clicking the reaction be taken with d.js

boreal pewter
#

still no need for api

fluid basin
#

yes, you await the response from the other process

boreal pewter
#

without api

#

all im asking

slender thistle
#

Ya true

boreal pewter
#

is it considered good practice

#

to run 2 pythons

#

on same shareds

#

shards

#

different code

#

each one will handle different thing

opal plank
#

cant say on py, but on js it wouldnt be very smart

#

the client itself will create bloat

#

its better to have 1 client and then re-emit stuff to other procecsses

boreal pewter
#

interesting @opal plank

vivid fulcrum
#

2 pythons on same shards

#

what

opal plank
#

he meants 2 different processes

vivid fulcrum
#

oh

#

no

boreal pewter
#

2 .py files

opal plank
#

like running 2 processes with 2 clients on the same token

vivid fulcrum
#

your clients will lose sync with each other

boreal pewter
#

yeah i assumed no is the reasonable answer

vivid fulcrum
#

including sync with ratelimits

boreal pewter
#

i guess ill just use django channels

#

have the gif generation happen completely different

#

and have a collector of jobs that finds generated gifs, message and channel ids, and send the gif there

#

or something in that area

vivid fulcrum
#

why do you want to do it in the first place?

#

i'm assuming it's because the command takes too long and blocks other commands from executing or something

signal estuary
#

How do I get the info, how much user having a role?

role.members.size

This does not work. For example, it returns 2 even if 3 users have this role

vivid fulcrum
#

you have to cache all members in the guild

tiny jacinth
#

hey, does returning status code 404 and 20x do the same thing ?

vivid fulcrum
#

no

tiny jacinth
#

how

signal estuary
vivid fulcrum
#

they're entirely different status codes

vivid fulcrum
tiny jacinth
vivid fulcrum
#

??

tiny jacinth
#

*data

earnest phoenix
#

yeah ig there's no retries for 4xx

signal estuary
tiny jacinth
vivid fulcrum
#

keep in mind

#

this is resource intensive

tiny jacinth
#

like does the same thing

#

just different status code

earnest phoenix
#

I suppose

tiny jacinth
#

hmm ?

flat pelican
#

I'm currently trying to split my bot into multiple threads, how many clusters should I ideally run for a bot with 40 shards? blobthinking

signal estuary
vivid fulcrum
#

because members is an object

#

precisely, GuildMemberManager

#

look at the doc links i sent you

signal estuary
cinder patio
#

<Role>.members gets the members from the <Guild>.members collection

#

which stores only cached members, so you have to fetch all members

marble juniper
#

any npm package I can use to get frames of a video

#

maybe one with an fps option too

#

or some other way lol

#

I just need to extract frames of a video essentially and get them as image buffers or as image files

cinder patio
#

ffmpeg can do that

marble juniper
#

can I use it in docker

#

my bot runs in docker

cinder patio
marble juniper
#

can't I just install ffmpeg as a npm module

cinder patio
#

mm I don't think so

marble juniper
#

I just need some kind of way

cinder patio
#

use the image

next ferry
#
internal/modules/cjs/loader.js:818
  throw err;
  ^

Error: Cannot find module '/home/runner/REAL-TEST-2/events/client'
Require stack:
- /home/runner/REAL-TEST-2/real.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
    at Function.Module._load (internal/modules/cjs/loader.js:667:27)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at /home/runner/REAL-TEST-2/real.js:48:23
    at Array.forEach (<anonymous>)
    at /home/runner/REAL-TEST-2/real.js:47:11
    at FSReqCallback.oncomplete (fs.js:156:23) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/home/runner/REAL-TEST-2/real.js' ]
}```
#

please explain

#

urjently

umbral zealot
#

can you show the first, like, 5 lines of your real.js file

#

oh wait

#

line 47? yeah what's line 47?

#

that function that loads something in a forEach, show that

next ferry
#

@umbral zealot

fs.readdir(__dirname + "/events/", (err, files) => {
    if (err) return console.error(err);
    files.forEach(file => {
        const event = require(__dirname + `/events/${file}`);
        let eventName = file.split(".")[0];
        client.on(eventName, event.bind(null, client));
        console.log("Loading Event: "+eventName)
    });
});
eternal osprey
#

hey
okay so my bot has 2 running prefixes. One isn't working as (i think) this line is preventing the second prefix to work:

if (!message.content.startsWith(Config.prefix) || message.author.bot && query !== true) return;```
how can i make sure that both prefixes (Config.prefix and Config.prefix1) can both be used?
umbral zealot
next ferry
#

@umbral zealot no

#

error.js or mesaage.js teo file only in event

umbral zealot
#

that looks a whole lot like the code I wrote, so, can you show what's in your /events/ folder?

#

hmm

#

just those 2 files?

sage bobcat
#

One message removed from a suspended account.

next ferry
#
const { MessageEmbed } = require("discord.js")
const config = require('../configs/config.json');

module.exports = async (client, text, channel) => {
    let embed = new MessageEmbed()
    .setColor(embedcolor)
    .setDescription(text)
    .setFooter("Believe me i am REAL 🥺")
    await channel.send(embed)
}

errror.js

#
module.exports = async (client, message) => {
  if (message.author.bot) return;

  //Prefixes also have mention match
  const prefixMention = new RegExp(`^<@!?${client.user.id}> `);
  const prefix = message.content.match(prefixMention) ? message.content.match(prefixMention)[0] : client.config.prefix;

  if (message.content.indexOf(prefix) !== 0) return;

  const args = message.content.slice(prefix.length).trim().split(/ +/g);
  //Making the command lowerCase because our file name will be in lowerCase
  const command = args.shift().toLowerCase();

  //Searching a command
  const cmd = client.commands.get(command);
  //Searching a command aliases
  const aliases = client.commands.find(x => x.info.aliases.includes(command))

  //if(message.channel.type === "dm")return message.channel.send("None of the commands work in DMs. So please use commands in server!")
process.on("unhandledRejection", (reason, promise) => {
    try {
        console.error("Unhandled Rejection at: ", promise, "reason: ", reason.stack || reason);
    } catch {
        console.error(reason);
    }
});
require('events').EventEmitter.defaultMaxListeners = 25


  //Executing the codes when we get the command or aliases
  if(cmd){
    cmd.run(client, message, args);
  }else if(aliases){
    aliases.run(client, message, args);
  }else return
};

msg.js

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

umbral zealot
#

hmm

next ferry
#

@umbral zealot

sage bobcat
#

One message removed from a suspended account.

umbral zealot
#

yes no need to ping me ffs I'm reading the code

#

be patient

sage bobcat
#

One message removed from a suspended account.

next ferry
#

yeah sorry

cinder patio
#

process is .... process

umbral zealot
#

look the only reason you'd have a thing that says it can't find a module client is if you're trying to do something like require("client") or if you're trying to fs.readFile("client") or something

#

so you gotta have a weird require or readfile in there somewhere

#

trying to call a file that doesn't exist

next ferry
#

oh

#

am chechking

dusk scarab
#

Anyone here who knows discord.js well enough to tell me how do you get the channelID of a message with only the MessageID, i'm trying to do reaction roles and stuffs.

lament rock
#

you should store the channelID if you're only storing the messageID. You cannot reasonably get a channel ID with only a messageID

#

rest get message has channelID as a part of the path

next ferry
#

@umbral zealot hy

#
const Discord = require('discord.js');
const config = require('./configs/config.json');
const fs = require('fs');
const { Database } = require("quickmongo")
const db = new Database(config.database)
const http = require("http");
const path = require("path");
const express = require("express");
const chalk = require("chalk");
const moment = require("moment"); 
var Jimp = require("jimp");
const request = require("request");
const axios = require("axios");
const snekfetch = require("snekfetch");
const fetch = require("node-fetch");
const { Collection, Client } = require("discord.js");
const client = new Client();
client.commands = new Collection();
client.queue = new Map()

#

may be error in this section may be

#

am trying to find out clint call but

#

i dont got it

snow urchin
signal estuary
#

How can I get all arguments after the second argument?

compact echo
#

Slice off the second arguement?

fresh verge
#

How does one use list, and or dictionary manipulation? (Discord.js)

compact echo
#

Well most args that I see in discord bots are an array

#

so just use the slice function on the array and slice off 2 arguments?

signal estuary
compact echo
#

I legit just explained it...

#

Use the slice function on an array and slice off the first 2 arguments

cinder patio
compact echo
#

That's what I was talking bout but didn't wanna spoonfeed spoonfeed

cinder patio
fresh verge
compact echo
#

well I guess I can't say the best tho.

cinder patio
#

cringe

#

node-fetch best lib

signal estuary
#

it will still take all arguments

compact echo
#

lmao I use node-fetch some times

cinder patio
#

slice doesn't modify the array it creates a new one

signal estuary
#

and for what stands [1, 2, 3, 4, 5]?

cinder patio
#

I dunno it's your code...

#

with your args variable

signal estuary
#

whats with the arg 6?

#

I want to get all args after the second arg

#

3 - oo

cinder patio
#

oh my...

modest maple
signal estuary
still sky
#

Do you know how .slice works?

signal estuary
signal estuary
modest maple
cinder patio
still sky
cinder patio
#

[1, 2, 3, 4, 5] is an array with 5 elements, it was an example to show you that slice(2) is going to return all elements except the first two

#

the length of the array doesn't matter, as long as it has more than 2 elements, it's going to return all of them except the first 2

signal estuary
#

Im so dumb, sry for the issues

#

and thx for help

quaint wasp
#

how do I start it?

#

like

#

it says "on"

#

but the app it self isnt.

still sky
# quaint wasp

You need to setup worker, add "Procfile" at root with worker: npm run start

quaint wasp
#

I have that

still sky
quaint wasp
#

o

#

right

cobalt spruce
#

does anyone has a good tuto about quick db X discord js

quaint wasp
#

how do I define an error?

#

Isnt it already defined?

cinder patio
#

show more code

quaint wasp
earnest phoenix
# quaint wasp

Use try-catch to catch the error and do whatever with it

quaint wasp
#
const polle = new Discord.MessageEmbed()
.setTitle('New Poll')
.setDescription(`**${question}**`)

.addFields(
    { name:'Author', value:`${message.author}`, inline:false},
)
.setColor('RANDOM')
let msg = await pollchannel.send(polle)
await msg.react(':thumbsup:')
await msg.react(':thumbsdown:')

message.channel.send(`New poll had been created in ${pollchannel} by ${message.author}`)

if (error) {
    message.channel.send(`I got an error. Bruh. How are you even getting these?! \n Error: **${e}**`)
}

console.log("Poll command had been ran..")
}

    }
#

(not all)

earnest phoenix
#
try {
  ...
} catch (error) {
  ...
}```
#

Use that mate

lavish bramble
#

I wanna to host my bot 24/7
Can anyone suggest me the best platform to host my bot

deft flame
#

but they are paid

round quiver
#

free or paid?@lavish bramble

deft flame
#

hosting

lavish bramble
#

Free

#

😅

deft flame
#

then use somehost.xyz

#

or hostarc

#

they are free

lavish bramble
#

Is it 24/7

deft flame
#

yes

round quiver
#

yep

lavish bramble
#

Thnx

deft flame
#

np

lavish bramble
deft flame
#

yeah

lavish bramble
#

So u host that web

deft flame
#

yes, i host my bot on that hosting service

#

;P

lavish bramble
#

Oki

earnest phoenix
#

When starting out, is it better to code with JavaScript or Python. I heard it’s easier to code in Python, but JavaScript has more functionality within the API. Any recommendations?

crimson vapor
#

imho javascript is just english but you use . instead of

#

at least for the basics

#

ex. creating a bot:

const { Client } = require('discord.js')
const client = new Client()
client.login('token')```
dusky sundial
#

JavaScript will prepare you for the other languages better imo

crimson vapor
#

python is confusing for me but some people say its easier ¯_(ツ)_/¯

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

quartz kindle
#

why triple quote? python string? lmao

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
#

Alright, I was just scared to learn a language that wouldn’t be that useful 😅 thx

sage bobcat
#

One message removed from a suspended account.

still sky
#

sarcasm

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
#

All languages are useful

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

crimson vapor
#

ehhhh

earnest phoenix
#

Have you seen lolcode

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

quartz kindle
#

imagine a bank built with node.js

#

entirely

earnest phoenix
#

Didn't they use fortran instead

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
#

what

quartz kindle
#

and mongodb for the database

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
#

hmmm

#

That’s interesting

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

quartz kindle
#

the same way tons of businesses still run windows 98

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

quartz kindle
#

new languages are invented all the time

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
#

Most popular languages are old, but not invented all the exact same time which is obvious

quartz kindle
#

many times they are layers on top of other languages tho

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
#

For example C, the grandfather of all languages

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

quartz kindle
#

and brainfuck was inspired by pain and suffering in 1993

earnest phoenix
#

Lol

#

Lolcode: hold my beer

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

earnest phoenix
#

Looks like a mixture of every language

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
#

Wait so if learning JavaScript makes it easier to go into other languages, are all the other languages somewhat based on JavaScript? 😂

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

sage bobcat
#

One message removed from a suspended account.

quartz kindle
#

javascript is based on other langs mostly

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
#

By learning JavaScript, you learn the basics of programming and can easily learn other ones when you know the basics

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

quartz kindle
#

the basics of programming and logical problem solving are the same in nearly all languages

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
sage bobcat
#

One message removed from a suspended account.

earnest phoenix
#

Learning JS won't help you that much in staticly typed languages since JS is dynamically typed, so you can use TS, TS is just a superset of JS

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

quartz kindle
#

i regret not getting into programming sooner as well

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

earnest phoenix
#

Getting into programming really early helps a lot

quartz kindle
#

but what really helps is to have an actual goal

sage bobcat
#

One message removed from a suspended account.

quartz kindle
#

i only got seriously into programming when i came up with an actual goal of what i wanted to create

#

before that i couldnt

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
#

What's the point of programming when you don't have a goal or don't know what to create at all

quartz kindle
#

making a discord bot is a very common goal for many beginners here

earnest phoenix
#

not that early tho

#

Some people here got into it at like 11 years of age or something

#

Oh wow...

quartz kindle
#

wasnt there a popular discord bot that advertised itself as being made by a "9 year old programmer"?

earnest phoenix
#

Never heard of it

quartz kindle
#

i think i remember something like that back in 2015 or something

lavish bramble
#

In which lang I can create my own database?

earnest phoenix
quartz kindle
#

first chose which database software you want to use

earnest phoenix
sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

quartz kindle
#

i doubt they mean that

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

earnest phoenix
#

Is SQL good?

sage bobcat
#

One message removed from a suspended account.

quartz kindle
#

its a good language for interacting with relational databases

#

its not a complete programming language in itself tho

earnest phoenix
sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

earnest phoenix
#

All the tutorials I watched recommended them, so idk

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

quartz kindle
#

its a language specific for use with databases

earnest phoenix
#

Ahh okay

quartz kindle
#

so when you get to the point where you want to use a database, you'll learn it

earnest phoenix
#

SQL is not bad at all, some people have reasons to go for non-SQL stuff, there's no bad reason to actually use SQL

quartz kindle
#

i use sql myself

sage bobcat
#

One message removed from a suspended account.

sudden geyser
#

ORMs 💪

quartz kindle
#

ew no

#

:^)

earnest phoenix
#

man

#

What is that? Lol

opal plank
#

ordinary russian males

quartz kindle
#

it stands for Object Relational Mapping

opal plank
#

ORM

quartz kindle
#

lmfao

clever moat
#

Hey guys, you use google analytics in your bot's website?

quartz kindle
#

no

earnest phoenix
#

Now I am conflicted

opal plank
#

imagine having a website

quartz kindle
clever moat
earnest phoenix
#

Thx for the info 🙂

quartz kindle
opal plank
#

i would likely track that on the koa app itself instead

#

would likely give a lot more specific things

#

time spent on it per ip

#

which pages they visited

#

how many visitors

#

how many clicks on invites

quartz kindle
# earnest phoenix Thx for the info 🙂

here's an example ```js
// normal sql database
let mydata = "abc";
mydatabase.sql("INSERT INTO mydata (name) VALUES (?)").execute(mydata);

// ORM database
let mydata = "abc";
myormdatabase.set("name", mydata)

opal plank
#

theres a lot of data google cant track

opal plank
earnest phoenix
#

😂

quartz kindle
#

i have no reason to track data, i dont do anything with it

opal plank
#

me neither, but being a dataphile is a hard task

opal plank
#

i just ocasionally check it

#

THOUGH

#

in all fairnessnessness it can be handy data

deft flame
#

who tf still uses sqlite lol

#

why not mongo

earnest phoenix
opal plank
#

to be used to improve quality

quartz kindle
#

i do

#

sqlite > all

opal plank
#

postgres > all

deft flame
#

i use mongo -.-

quartz kindle
#

well good for you

#

:^)

deft flame
#

(:

opal plank
#

'iev ehard good things about the other thingy

earnest phoenix
opal plank
#

fuck whats the name

long crow
#

I just log in text files

#

Text files> all

opal plank
#

scylla

#

thats the one

#

foundationdb and scylla

#

someone was telling me at how good at scale they are

quartz kindle
#

do you need multi-process and/or multi-machine? use a regular db (mongo, postgres, mysql/mariadb)
no? use sqlite

#

its that simple

opal plank
#

even though im reluctant to even try foundationdb cuz its from apple

earnest phoenix
opal plank
#

cuz apple

earnest phoenix
#

Apple makes quality things 👌

opal plank
#

just knowing its apple, theres probably 58 overpriced paywalls behind it

quartz kindle
#

apple makes shit things

opal plank
#

^^

quartz kindle
#

and overprices them

opal plank
#

^^

earnest phoenix
#

Lmao

#

Understandable

quartz kindle
#

phones without chargers

opal plank
#

anyway, enough shitting on apple

earnest phoenix
#

ONE

#

😂

quartz kindle
#

and new chargers not compatible with old

opal plank
#

iev heard good things about their foundationdb tho

quartz kindle
#

apple was fined millions for selling phones without chargers in several countries

earnest phoenix
opal plank
earnest phoenix
#

Overpriced shit

#

Plus, it was Apple, and Swift, that got me into coding

quartz kindle
#

run away from apple while you can, dont let yourself degenerate into an apple fanboy

deft flame
#

help, why do i get this error?

(node:24) UnhandledPromiseRejectionWarning: Top.GG API Error: 404 Not Found
    at Api._request (/home/container/node_modules/@top-gg/sdk/dist/structs/Api.js:76:19)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async Api.postStats (/home/container/node_modules/@top-gg/sdk/dist/structs/Api.js:96:9)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:24) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:24) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.```
opal plank
#

i'll likely keep sticking with postgres/keydb though

#

postStats() failed

#

@slim heart

#

as to why, good question

earnest phoenix
opal plank
#

or, shall i say, inside of it

quartz kindle
#

a lot of apple shit has no indicators whatsoever

#

like syncing pics with icloud, you dont know how much its done, how much is left, or even if its actually doing something

opal plank
#

its made for users not for devs

#

no erros = pretty

slim heart
#

yeah im not getting the same errors so im not sure

opal plank
#

no users like errors on their screen

opal plank
#

that wasnt a yes or no question

#

what you have INSIDE there?

#

oh

#

i see why berry

#

@slim heart see their role? yeah, me neither

slim heart
#

ah yes

opal plank
#

@deft flame do you have a bot approved?

#

let me guess, bad token or nonexistent

quartz kindle
#

looks like an unnapproved bot

deft flame
#

just today i uploaded it

#

-.-

slim heart
#

you cant post to an unapproved bot

quartz kindle
#

you cant use the api while its not a approved

deft flame
#

oh

opal plank
#

you cant even get a token iirc

slim heart
#

there's a way

#

but it'll 404 as shown above

opal plank
#

i see

#

actually

#

i think xetera showed me a way before to get token

#

maybe it was shiv or veld

#

i cant recall

#

though it was on v1

quartz kindle
#

haxxor

earnest phoenix
#

What platform do you guys code on?

quartz kindle
#

like code editor?

#

vsc

opal plank
#

win64x/ obuntu 14+ for prod, vsc for editor

earnest phoenix
#

No I meant like OS, because I remember hearing someone say coding on Linux is better

quartz kindle
#

my pc is windows 10

#

my server is ubuntu 20

cinder patio
#

weirdsip why would coding on linux be better

quartz kindle
#

gcc

cinder patio
#

gcc also works on windows

opal plank
#

i dont think coding on linux is better at all tbh

#

its a straight up pain

quartz kindle
#

depends on the langs

#

for many low level languages, linux has better compilers and tools

opal plank
#

intalling ANYTHING on linux is a major pain, specially with drivers and deps

quartz kindle
#

but for high level languages such as js and py there is no difference

cinder patio
#

imo it's the opposite

opal plank
#

incompatible driver? good luck writing your own adapter

earnest phoenix
#

Lmao that’s true 😂

opal plank
#

anything you go offbrand will backfire gracefully on you

long crow
#

There is wsl

opal plank
#

of course, mainstream stuff is very well maintained, no complaints there

quartz kindle
#

i had issues before where compiling on linux worked out of the box and compiling the same thing on windows was a nigthmare

cinder patio
# quartz kindle but for high level languages such as js and py there is no difference
quartz kindle
#

many native libraries have specific installation instructions for windows

#

often requiring additional crap

opal plank
#

but it just seems to counter productive having to spend 15 minutes installing stuff with depedencies, drivers, etc when on windows we all have the same simple installer/wizzard
install/choose folder/i agree with terms(nobody reads)/ done

cinder patio
#

yeah true that's why I don't bother using c++

#

If I want performance I go with rust

quartz kindle
#

you mean

#

c+++oxygen

#

:^)

#

co++

#

c++o

opal plank
#

coco++

#

tim help

quartz kindle
#

c3pO

opal plank
#

its been a whole month procrastinating this

#

and i cant push it to prod until its done

#

hilp

quartz kindle
#

wut

opal plank
#

theres a big chunk of my code that needs rewriting, and thats literally the only thing preventing me from pushing updates to production

#

been hot-reloading this whole time

#

wanna du it fur me?

quartz kindle
#

exdee

opal plank
quartz kindle
#

in ts?

cinder patio
#

sounds like a you problem weirdsip

opal plank
#

think of it as practice

quartz kindle
#

no thx :^)

earnest phoenix
#

Wait, you guys work together on bots?

opal plank
#

reeee

#

imagine not working together with bots

cinder patio
#

never

quartz kindle
#

not really, we just bounce ideas off each other

opal plank
#

^^

quartz kindle
#

and help with shit

opal plank
#

its more of a "im too lazy to do it" rather than an actual "idk how to do this, please enlighten my ignorant self"

cinder patio
#

If c++ had a good package manager like cargo then I'd use c++ for everything

#

but alas

earnest phoenix
#

Oh, that was one thing stopping me from creating one lol, because bots like MEE6 have teams so it’s hard to compete with them... 💀

quartz kindle
#

c++ with a package manager would be a nighmare

quartz kindle
#

imagine searching among thousands of shit libs

#

made by junior devs

#

during internships

cinder patio
#

Shit devs cannot write c++ come on now

opal plank
#

it will take a good month or two to create a good bot if you pour some work everyday

cinder patio
#

this aint js KEKW

quartz kindle
#

interns and programming students who are forced to use c++

#

but have no idea what they're doing

cinder patio
#

oldEyes do these people exist

opal plank
#

sounds like the whole js community

quartz kindle
#

xD

earnest phoenix
#

...

opal plank
#

look mom, i made package with 12 lines, imma publish on npm and be famous

earnest phoenix
#

I feel attacked

quartz kindle
#

is-thirteen

opal plank
#

im willing to say 70% of npm packages are completely utter shit

cinder patio
#

I want to make a useless package one day

earnest phoenix
#

💀

quartz kindle
#

the worst thing

opal plank
#

safely, 50%

quartz kindle
#

is when you need X

opal plank
#

70% is my estimation based on opinion

quartz kindle
#

but there are 500 packages that do X

opal plank
#

and all of them claim to be the best

quartz kindle
#

because everyone makes their own

opal plank
#

or fastest

#

and end up being the worst

cinder patio
#

why are there a million libs for making http requests 😩

quartz kindle
#

and even worse then the ones with "fast" in their names are usually the slowest

cinder patio
#

I can name like ten http libs rn

opal plank
#

BuT TiM It H aS FAst in ThE NamE

#

SuRelY its FasT

quartz kindle
#

xD

#

i have a lib with fast in the name

#

but mine is actually fast

#

:^)

opal plank
#

should've gone out of the swarm tbh

opal plank
#

weeb above

opal plank
crimson vapor
#

fuck

quartz kindle
#

jasondb

#

ourcord

crimson vapor
#

I need to rewrite jasondb

#

shhhh

quartz kindle
#

does ourcord still exist?

crimson vapor
#

ehhhh

#

it shit

quartz kindle
#

no shit

opal plank
#

tell us something new

quartz kindle
#

but does it exist?

#

lmao

cinder patio
#

😩 what isn't shit these days

opal plank
#

postgres

#

and detritus

earnest phoenix
#

Is it bad to get code off of StackOverflow? 😔

opal plank
#

yes

quartz kindle
#

its bad to copy paste code

opal plank
#

if you LEARN from stackoverflow, yes, if you copy paste, then shame on uyou

cinder patio
#

imo it's not bad to copy paste if you know what the code's doing

quartz kindle
#

though i used to do that a lot

earnest phoenix
#

Nooooo, I would never steal code...

opal plank
#

copy apsting without knowing what it does, does you no good either

quartz kindle
#

copy apsting

opal plank
#

APstring

#

yes

#

Armor Piercing String

quartz kindle
#

nice

earnest phoenix
#

Lol, and I know, I don’t.

opal plank
#

and youtube vids

#

thats also bad practice

quartz kindle
#

did you guys know that each js string takes up a minimum of 40 bytes?

#

even if the string is 1 byte long

earnest phoenix
#

Although I do get mad sometimes when I finally find someone with the same issue, but then they just say they found the answer without actually saying what it was....

opal plank
#

sounds optimized

cinder patio
#

why

opal plank
#

i mainly find those in github issues

#

not on stackoverflow

quartz kindle
#

wanna know why discord.js is so bad with ram?

#

collections

opal plank
#

cuz it was meant for borwsers not for optimized code?

quartz kindle
#

the problem is not the collection class per se

#

its with now many instances of them are used

opal plank
#

howso?

earnest phoenix
quartz kindle
#

a map object has like 60 bytes of overhead

#

and djs uses hundreds of thousands of instances of them

opal plank
#

hmmm

#

im now curious

#

which would be better ram wise, dpy or detritus

quartz kindle
#

py is a little more memory efficient

#

its structures probably have less overhead

#

but its mostly the same thing

opal plank
#

not worth the forced indentation and spacing

#

fuck that

cinder patio
#

Okay, what if discord.js light edited the collection class, instead of it extending a map it just uses a plain object under the hood

earnest phoenix
quartz kindle
opal plank
#

hmmmm interesting

quartz kindle
#

its still a Map object

opal plank
#

have u tried on v16?

cinder patio
#

how

opal plank
#

using the v9 engine?

quartz kindle
#

8.9*

opal plank
#

dunno if they did any optimizations

quartz kindle
#

xd

opal plank
#

isnt it on 9?

quartz kindle
#

oh nvm it is v9

opal plank
#

new engine, might worth a look

quartz kindle
#

why the fuck did they name themselves v8

#

and now they are v8 v9

#

v8 version 9

cinder patio
#

Doesn't look like there are many optimizations in v9

#

faster super access

opal plank
#

there u have it

quartz kindle
#

ye

#

only improvements to regex, wasm and super

opal plank
#

hmmmm thats interesting

quartz kindle
# cinder patio how

djs uses Collections for everything, like a collection of guilds, and each guild has a collection of channels and each channel has a collection of messages, etc

#

those quickly multiply themselves to hundreds of thousands

#

and that causes a massive memory overhead

#

no matter what you do to the collection class

#

its always gonna be there

opal plank
#

each message has a collection of edits, each user has a collcection of presences, each channel has a collection of edits

cinder patio
#

yeah but what if instead of the class extending a map, it uses an object to store all pairs

quartz kindle
#

it would improve a little

#

but not much

#

Objects also have a big overhead

#

the problem is how the caching is structured

#

too many layers of depth

#

too many multipliers

#

i have ideas for a better caching strategy

#

will experiment with it in the future

#

but not in djsl

opal plank
#
class Map {
  constructor() {}
  get(val:any):any | undefined {
    return this[val];
  }
    set(key:any, val:any):void {
    this[val] =  val; 
  }
}
let map = new Map();

what about this

quartz kindle
#

an object with extra steps

#

xD

opal plank
#

basically

cinder patio
#

get can be boiled down to return this[val]

#

it'll be undefined if it's not in the object

quartz kindle
#

let me test something real quick

opal plank
#

i couldnt recall if it would error if you tried that

#

so i added that, but if it doesnt, yeah

#

thats better

cinder patio
#

js wouldn't be very dynamic if it errored ;d

opal plank
#

fixed

#

'tim bout to check if my big brain is proving to be smort?

cinder patio
#

yup, that's good although iterating would be a little harder to replicate

opal plank
#

i mean, not sure if theres anything better, but Object.keys()/entries()/values()

cinder patio
#

Yeah Object.entries

opal plank
#

technically i dont even need that | undefined

cinder patio
#
[Symbol.iterator]() { 
return Object.entries(this)
}
#

also add generics

opal plank
#

that would work

quartz kindle
#

guess which one uses more ram

opal plank
#

the first

quartz kindle
#

yup

opal plank
#

cuz more objects

quartz kindle
#

yup

opal plank
#

second is the c

#

and the b

#

by that logic

cinder patio
#

the second is faster probably cause the arrays all contain values of the same type

quartz kindle
#

a uses more ram than b and c combined

opal plank
#

damn

quartz kindle
#

thats my point

#

you know how databases use normalization and denormalization?

cinder patio
#

nope

quartz kindle
#

where you have tables with ids columns that reference keys in other tables

#

there is a trade of between access speed and storage

#

in dont remember which is which now, normalized or denormalized

#

but for example, instead of having a reference to another table, you have a key for another table

#

so you access table2 by getting the key from a column in table1 first

#

you essentially have duplicate data in table1 and table2

#

table1 has an id column with the ids for table1, and table2 has a "keysfortable1" column with the same data

#

thats done for faster access speeds

#

but doubles memory usage for that specific piece of data, becasue 2 different tables have the same values

#

in js you can basically do that exact same thing

#

and it actually uses less memory instead

#

its stupid

#

lmao

opal plank
#

and this has been Tim's Ted Talk. Applaud everyone!

#

though thats an interesting thing to know

cinder patio
#

👏 smort

opal plank
#

so the opposite can be done too

#

and instead read if off disk to preserve ram

#

though that would also decrease the speed

cinder patio
#

balance is everything

opal plank
#

for example, keeping cache of the keys instead of values

#

postgres for example has a approximate value of entries

#

couldnt you keep a small cache of only keys to be accessed/checked?

#

instead of loading the whole table for indexing?

quaint wasp
#

umm

quartz kindle
#

yes you can keep only keys in memory and store the actual data elsewhere

quaint wasp
#

anyone here using Heroku for hosting?

#

I need help with it.

quartz kindle
#

why are you using the heroku command line program?

#

what are you trying to do?

dusky gull
#

heyo can someone help me set up a bot role system?

quaint wasp
dusky gull
#

ive tried many times but its hard for me to figure out and i dont want to do it manually

quaint wasp
thin echo
#

I'm changing my bots code to JS and I'm trying to ping/mention the author of the/a message

quartz kindle
vivid fulcrum
#

the author property returns a User object

#

and finally the User object has a mention property

#

nevermind it does not

#

oh well

#

you can use the id property of the User object and then do this

thin echo
#

ok, I'm listening

vivid fulcrum
#
`<@${user.id}>`
thin echo
#

Is there a way I can change it to the users name and not id?

umbral zealot
#

you cannot ping a user without their ID, no.

thin echo
#

ok

#

I'm trying something

umbral zealot
#

You can however mention them and access message.mentions.first() to get their user

#

put that in a string and they get the ping

thin echo
#

Is there a way I can put the Author's name

#

not ping but just their name?

umbral zealot
#

user.username would give you a username, while user.tag would give to the full tag, like my Hindsight#2020

thin echo
#

tysm

quaint wasp
quartz kindle
#

you dont need that but ok lol

wintry raptor
#

Hello, is there a way you check the id of two channel with the same name?

vivid fulcrum
#

what's the context behind this question?

prime glacier
#

'guildMemberUpdate', (oldMember, newMember)
or 'nitroBoost', (booster) ?

vivid fulcrum
#

there isn't a nitro boost event

#

or a boost event in general

#

detecting a boost is really iffy

#

ironically enough, the event exists for user accounts lol

#

but not for bot accounts

#

keep in mind

#

a guild can turn off boost messages

#

so

earnest phoenix
vivid fulcrum
#

are you okay

#

there's literally no such event

earnest phoenix
#

Oh

vivid fulcrum
#

appellation's comment is the best one

#

vladfrangu's comment does not account for already existing boosters

#

the premium since timestamp does not change when an already boosting user

#

boosts again

#

so 🤷‍♂️

earnest phoenix
#

¯\_(ツ)_/¯

tardy hornet
#

where can i get the top.gg token for my bot?

weak cypress
#

@earnest phoenix I opened the yardım.js file in the commands section and pasted my code directly and deleted the LOG sections in the command handler, but encountered such an error. Note: I had to enter English, now you will translate xd

earnest phoenix
earnest phoenix
#

if(!message.guild.roles.cache.find(x => x.name === "Møon-verification")) {
                    message.guild.roles.create({
                        data: {
                            name: "Møon-verification",
                            color: "BLUE",
                            permissions: [ "SEND_MESSAGES", "READ_MESSAGE_HISTORY" ]
                        },
                        reason: "Configuration du système de vérification"
                    });
                }
                const moonRol = await message.guild.roles.cache.find(x => x.name === "Møon-verification");```

When I get the id of a newly created role, it returns undefined (basically it can't find ...) and I have to issue the command a second time for it to find.
The awaits are not enough, .then () cannot be fixed here because in any case I get the identifier that it already exists or not, how I could do so that it does not do both at the same time ?
vivid fulcrum
#

find is not an async operation

#

there's no need for await there

#

and

#

use the role that's returned from the create method

#

you're supposed to await that

earnest phoenix
#

Yes but if the role exists, it will not execute the role creation

vivid fulcrum
#

yes it will

#

lol

#

you don't await so the code doesn't even wait for the role to be created and instantly jumps to trying to find it

#

and even if you do await it

#

you would be finding it as soon as it's created

#

and you still won't find it

#

because there's not enough time for it to go over the gateway, get parsed and added to the collection

earnest phoenix
#

Ok, thx

vivid fulcrum
#

tldr you want this

const role = find(condition) ?? await create();
#

this will attempt to find such a role

#

if it doesn't exist

#

it will create it

#

and you're granted that the role variable will always be a Role object

#

unless you don't have permissions to create a role

#

in that case, it will error out

earnest phoenix
#

How I can fix this?

PS C:\Users\...> node ./dist/server.js
file:///C:/Users/.../dist/server.js:3
import { ShardingManager } from 'discord.js-light';
         ^^^^^^^^^^^^^^^
SyntaxError: Named export 'ShardingManager' not found. The requested module 'discord.js-light' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from 'discord.js-light';
const { ShardingManager } = pkg;

tsconfig.json

{
    "compilerOptions": {
        "target": "ES6",
        "module": "ES2020",
        "outDir": "./dist",
        "rootDir": "./src",
        "removeComments": true,
        "esModuleInterop": true,
        "resolveJsonModule": true,
        "noImplicitAny": false,
        "moduleResolution": "Node"
    },
}```
deft flame
#

umm, discord.js-light doesn't exist I guess

unreal estuary
#

how can a discord bot do this?

ornate bramble
earnest phoenix
deft flame
#

Oh nvm

ornate bramble
#

@earnest phoenix need some help ❤️

quartz kindle
#

CommonJS modules can always be imported via the default export, for example using:

import pkg from 'discord.js-light';
const { ShardingManager } = pkg;

earnest phoenix
#

npx tsc node ./dist/server.js

quartz kindle
#

ah thats the compiled code?

earnest phoenix
quartz kindle
#

no idea then

#

shit like this is why i hate ts

earnest phoenix
#

😔

quartz kindle
#

in your tsconfig