#development

1 messages Β· Page 1814 of 1

quartz kindle
#

i dont see sharp

vivid fulcrum
#

interop capability too

#

uses webview2

#

on windows at least

#

since it's c# it has native ability to interact with c++

#

so it's really powerful

#

electron without the node part

quartz kindle
#

like many others out there

split hazel
#

whaat? electron without node??? illegal

quartz kindle
#

theres a full list

vivid fulcrum
#

i wish node was natively multithreaded

#

the only reason why i'm using c# for my apps is because it isn't

split hazel
vivid fulcrum
split hazel
#

I don't know the specifics of it at all other than knowing they can't really direct access each others memory

#

kind of like a child process with ipc

vivid fulcrum
#

worker threads defeat the whole point of multithreading; synchronization

sudden geyser
#

shared mutable state notlikethis

quartz kindle
#

move your threading to c++

split hazel
vivid fulcrum
#

good point

split hazel
#

I prefer async as much as I can lol

vivid fulcrum
#

but that's the most common thing you'd use multi threading for

#

synchronization != synchronous execution

summer torrent
vivid fulcrum
#

wym

quartz kindle
#

likely too much book keeping

summer torrent
quartz kindle
#

v8 has an insane amount of statefulness for every single js value

vivid fulcrum
#

i have no idea

quartz kindle
#

it would be hell to make it thread safe

vivid fulcrum
#

a few documents i did read on it stems from js roots

#

the fact that for a long period of time js execution would run on a single thread in the browser

#

web workers got introduced to fix that problem though

split hazel
pale vessel
#

Is it a pipe dream doe

vivid fulcrum
quartz kindle
#

yeah

#

and it also supports pointers and 64 bit ints

split hazel
#

imagine if someone made cpython for node

#

they'd practically have to rewrite node

#

and js probably

#

would be sick though and I would be a customer

quartz kindle
#

quickjs does support 64 bit ints

#

v8 doesnt

split hazel
#

maybe v9 will

quartz kindle
#

v8 is already v9 tho

#

:^)

split hazel
#

v10

#

I'll wait for superior v8 to come out then

pale vessel
#

v8 v10

quartz kindle
#

@vivid fulcrum

With v9.2, the default is changed such that all Isolates within a process share the same 4GB virtual memory cage. This was done in anticipation of prototyping experimental shared memory features in JS

vivid fulcrum
#

wait what

#

i'll have to read up on that

#

mind sharing the url?

quartz kindle
#

array.at(-1) as a shortcut for array[array.length-1]

#

lel

vivid fulcrum
#

it doesn't even throw an error for an out of bounds?

#

returns undefined

#

lol

crimson vapor
vivid fulcrum
#

they should've went with a syntax-wise approach

#

something like python or c#

quartz kindle
#

they also added Object.hasOwn(obj, prop)

#

as a better alternative to Object.prototype.hasOwnProperty()

crimson vapor
#

isnt that like doing 'prop' in object or something?

peak patrol
#

Hi y'all

#

Can someone help me with a script?

#

const { PREFIX, LAVA_HOST, LAVA_PASSWORD, LAVA_PORT } = require('../../config');
const { MessageEmbed } = require("discord.js")

module.exports = async bot => {
console.log(${bot.user.username} is available now!)
setInterval(() => bot.user.setActivity(Upcoming is cool | ?help (Also custom!), { type: "WATCHING"}),5000)
};

#

That's what my friend sent me to set a costum status for your bot

cinder stratus
#

What are you trying to do?

#

Oh!

peak patrol
#

And I want to change it ti say something elese

#

else/

#

And here is result

cinder stratus
#

Like update every x minute?

peak patrol
#

No

#

Like the costum status of the bot says

#

Use .help

cinder stratus
#

Delete that screenshot from here.

peak patrol
#

sorry

cinder stratus
#

Because you exposed your repl.

peak patrol
#

Oh

cinder stratus
#

Anyone can see it.

peak patrol
#

right XD I'm dummy

cinder stratus
#

And there is a error in your console can you send that here.

pale vessel
crimson vapor
#

oh

cinder stratus
#

@pale vessel lol hello

pale vessel
#

Like "toString" in {}

cinder stratus
#

@peak patrol in your console

peak patrol
#

Uh

cinder stratus
#

The red thing you were seeing.

#

Like text in all red.

peak patrol
#

ik

#

What's the error

cinder stratus
#

Can you copy paste that here.

peak patrol
#

kk

#

nvm

cinder stratus
#

Okay

earnest phoenix
#

How can I use async functions to wait for my database to connect before global scope variables are defined? ```js
//Required
require('dotenv').config();
const uri = process.env.MONGOURL;
const MongoClient = require("mongodb").MongoClient;
const mongo = new MongoClient(uri, {useNewUrlParser: true, useUnifiedTopology: true});

let bname = "Beyblade";
let datas = {}

mongo.connect((err) => {
console.log("MongoDB connected for Beyblade.js");
});

/*let ids = mongo.db("main").collection("ids");
const id = ids.find({});
Promise.all([id]).then(data => {
let beys = data[0];
beys.forEach(bey => {
datas[bey._id] = {
latest: bey.latest,
name: bey._id
}
});
console.log("Updated data!");
});

setInterval(() => {
mongo.db("main").collection("ids").updateOne({_id: bname}, {$set: {latest: datas[bname].latest}});
}, 600000);*/

class Beyblade {
constructor(name, type, image, firstOwner, id){
this.name = name;
this.type = type;
this.image = image;
this.firstOwner = firstOwner;
this.level = 1;
this.xp = 0;
this.specials = [];
this.passives = [];
this.aliases = [];
this.gen = 1;
bname = name || this.name;
/* if(id) this.id = id;
else {
if(this.name !== "Buddy Bey"){
if(datas[this.name]){
this.id = datas[this.name].latest || 1;
datas[this.name].latest = (datas[this.name].latest || 1) + 1;
}else{
mongo.db("main").collection("ids").insertOne({_id: this.name, latest: 2});
datas[this.name] = {latest: 2};
this.id = 1;
}
ids.updateOne({_id: this.name}, {$set: {latest: datas[this.name].latest}});
}
}*/
}
async init(){
return true;
}
}

module.exports = Beyblade;```

#

the commented out part is commented out because of a mongodb error, since it won't wait for it to connect

pale vessel
#

Guild ID

crimson vapor
#

guild id

#

fuck I was too slow

pale vessel
#

message.guild.id

crimson vapor
#

me when no has permissions for doing this

pale vessel
#

😐

crimson vapor
#

everyone -> message.guild.id

pale vessel
#

Custom status is only for users doe

crimson vapor
#

no need

#

I think?

#

sec

#

yeah no need

pale vessel
#

Curb your not really

crimson vapor
#

oh

#

I did

#

createOverwrite

#

like the gamer I am

pale vessel
#

Example from docs

#

Yeah

#

Yeah

#

What version of Discord.js are you using?

#

Did you recently update?

#

Where did you get that code then?

#

message.author.displayAvatarURL

#

That would be valid in v11

#

Yep!

#

I think it's username first though

#

And then the icon

#

Since your username, Lyp isn't a valid protocol (http(s))

#

That's where the error came from

#

Now what in the world just happened

long crow
#

O.o

pale vessel
#

Am I dyslexic?

long crow
#

Some text just disappeared

pale vessel
#

I hope

long crow
#

Like magic

#

I got this dilemma where I want to make my repo public, but somehow pissed when someone just Ctrl + C, Ctrl + V my not so good codes but learn by myself and they claim it's them. But if it stay private, hard for me to progress learning and ask people for direction. Any idea/ recommendation? like .gitignore some of it etc?

pale vessel
#

Someone I knew had their bot open source but some jackass decided to clone it and claim it's theirs

#

So he had to make it private

#

It's either public or private, you choose

#

Licensing might help too

#

Mine is private solely for that reason

long crow
#

discord bot command licensing is like a meme

pale vessel
#

Haha, but if your bot is well known enough, maybe most people will recognize it

#

Maybe you make it open source at that point

long crow
#

I'm deciding to .gitignore my /dependancy and /data which I placed most my barebone command to work properly. not sure if that a good idea

#

Something like the Manga I meant, I don't mind each command module that much since that is the same thing as discord.js guide

pale vessel
#

Sounds good

#

Make the core public, and all the crucial commands/data that makes your bot the way it is (unique/good) private

#

That's what Berry did with his censor bot

#

The bot itself is public, but the filters are private

#

Since that's what actually makes it good

peak patrol
#

How do I make an Embed?

pale vessel
#

An Embed?

#

For?

peak patrol
#

An embed for text + pic

pale vessel
#

Are you using some sort of a library?

peak patrol
#

Replit

#

Node.JS

pale vessel
#

Node.JS? Err, Discord.js I guess?

peak patrol
#

no

#

node.js

pale vessel
#

What library?

#

Node.js would be your runtime

peak patrol
#

ok

#

Ummm so?

crimson vapor
#

probably djs

pale vessel
#

Detritusjs

#

Interesting

peak patrol
#

...

#

How do I make embed?

#

..

crimson vapor
#

{ embed: { title: "this is an embed" } }

pale vessel
#

{ embed: { title: "this is an embed" } } drake_nope
{ embeds: [{ title: "this is an embed" }] } drake_dope

peak patrol
#

That's it.-?

pale vessel
#

Yeah

#

We still don't know what library you're using but that's what it would look like raw

peak patrol
#

o

#

what is the library???

#

like

#

index.js???

pale vessel
#

A library is a package that you use for interacting with Discord's API/gateway

peak patrol
#

oh

#

express

#

and discord.js

pale vessel
#

I c

peak patrol
#

That's all of it

#

id even know what library do i add for an embled

pale vessel
#

You can pass that to your send method, like message.channel.send({ embed: new MessageEmbed().setTitle("A title") });

crimson vapor
#

why not just likejs message.channel.send( new MessageEmbed() .setTitle('A Title') )

peak patrol
#

Imma try

crimson vapor
#

strange

#

I never had that issue

pale vessel
#

That's for edit doe, probably work just fine for sending

peak patrol
#

Like? : message.channel.send(
new MessageEmbed()
.setTitle('Something')
)

pale vessel
#

Yeah

peak patrol
#

But where is the case

#

like if i receive message

#

just like that???

errant flax
#

is it best to cache the per guild prefixes so i wont have to keep fetching from the db 322_eth_flushed

pale vessel
#

Yeah

#

I know someone who doesn't do that and it's just as fast

#

But it's nice to cache

errant flax
#

thx pd_pepethumbsup

pale vessel
#

Ye

wooden kindle
#

whats shards used for

crimson vapor
#

flexing

#

its basically how big your bot is

#

the more guilds, the mods shards

#

its required at 2500 guilds

errant flax
#

shards r basically multiple clones of ur bot right bonk

plain talon
#

It’s an api connection

errant flax
#

i dont understand what u meant

plain talon
#

If you have 2 shards you have 2 active connections to the API, with your servers split across each connection to ease the load

crimson vapor
#

discord forces bots to separate into multiple ws connections (shards) to help them load balance

errant flax
#

what scopes do i need for adding a rich presence?

crimson vapor
#

to set a bot's presence? no scopes needed

pale vessel
#

Bots can't have rich presence though 🩴

errant flax
#

i meant a user's rich presence

pale vessel
#

That's not how it works

errant flax
#

im new to rich presence bonk

errant flax
pale vessel
#

NM

#

I didn't think you need one

#

You use your client ID and secret to obtain the RPC token

errant flax
#

if i did that the rich presence would just appear on my profile?

pale vessel
#

Err, no. You need a transport which could be IPC or a WebSocket

#

I've never worked with RPC before so I don't know much either

errant flax
#

wtf is an IPC plump_isee

pale vessel
#

But you need them to access the local RPC server

#

Inter process communication

errant flax
#

how would i do that hmm

pale vessel
#

RPC is deprecated in favor of Game SDK

slim umbra
#

please read the documentation regarding this instead of begging for help

pale vessel
#

But I guess you can take a look in docs

slim umbra
#

everything you have asked would be very easy to figure out if you put some time and effort into reading the docs

pale vessel
lament rock
#

you know shits bad when you seg fault in js AlienPersianDerp

finite citrus
#

I was working on an update when I saw my bot added to a verification server
Literally chills

earnest phoenix
#

What does that mean?

finite citrus
#

Means my bot just got verified pog

pure lily
#

how do I delete a saved pm2 process?

sick agate
#

pm2 delete processid

pure lily
# sick agate pm2 delete processid

β”‚ id β”‚ name β”‚ mode β”‚ β†Ί β”‚ status β”‚ cpu β”‚ memory β”‚
β”œβ”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ 0 β”‚ index β”‚ fork β”‚ 0 β”‚ online β”‚ 0% β”‚ 232.4mb β”‚
β”‚ 1 β”‚ index β”‚ fork β”‚ 0 β”‚ online β”‚ 0% β”‚ 122.7mb β”‚
β”‚ 2 β”‚ index β”‚ fork β”‚ 0 β”‚ online β”‚ 0% β”‚ 20.0mb

#

is id the 0 1 2

sick agate
#

No idea

#

They all habe the same name

pure lily
#

files

sick agate
#

Soo yeah

#

When did you execute it or did you execute anything after it @pure lily

cinder patio
#

just delete em all

sick agate
#

It should be 2 than

pure lily
sick agate
cinder patio
#

pm2 delete all

pure lily
sick agate
#

Ok sure

pure lily
#

then restart vps

earnest phoenix
#

hi how do we lock a channel for a role after a certain time?
i have this currently which will unlock the channel

return message.channel.updateOverwrite(roleId, { SEND_MESSAGES: true }) .then(message.channel.send(`GoodLuck`))```
lusty quest
#

add timers, for persistent timers over process restarts i would suggest to use redis with ttls

stable nimbus
#

I am looking to shorten how much code I am writing, starting with my config, so I want to take an array of userids, and see if the authors ID is in the array, I've written an example of what I could think of and what I would think it would look like, and I was wondering what I should really do because I don't think it is right at all.

config.admins = [ /* Array of userids*/ ]
if(message.author.id === config.admins) {
  // Do something
}
else {
  return message.channel.send('You do not have permission to run this command!');
}
lusty quest
#

array.includes might be the thing you search for

#

your way would probably not work bcs you check a string against an Array and will be always false

cinder patio
#

Is there any way to get the last repositories a user has made commits to via the github REST api? πŸ€” I've been searching the API for a while now and I can't find anything

iron delta
#

Ohh

#

@earnest phoenix

I do s? Then out that command in?

earnest phoenix
#

then

iron delta
#

This sounds like stuff to do on pc

earnest phoenix
iron delta
amber thistle
#

anyone know how would i make the avatar image on the creator area bigger? i tried increasing the size but it just zoomed in the image

earnest phoenix
amber thistle
#

i use a large size image

#

1000+ x 1000+

onyx hare
#

Would message.content work if I set that as a embed message? For example someone wants to β€œsave” text but not pin so they’d enter β€œ!save <msg>” and it sends a embed to a channel called β€œsaved information” title would be β€œUser saved this:, description: message.content” doable?

amber thistle
#

message.content would be null if there is only a embed and no content in that message

flat copper
#
let roles = client.data.boostRoles.map(r => {
			  message.guild.roles.cache.get(r.role).name
			}).join("\n")
			```
#

Why its not showing?

#

The names

quartz kindle
#

you are not returning

#

x => something
is equal to
x => { return something }

#

you are doing x => { something }

marsh bluff
#

yea so either remove the curly braces or add return before the message. ...

silent hornet
#

hey guys anyone know what this error is about? ( im using ytdl-core)

#

MinigetError: input stream: Status code: 403
at ClientRequest.<anonymous>
at Object.onceWrapper (events.js:483:26)
at ClientRequest.emit (events.js:376:20)
at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:647:27)
at HTTPParser.parserOnHeadersComplete (_http_common.js:126:17)
at TLSSocket.socketOnData (_http_client.js:515:22)
at TLSSocket.emit (events.js:376:20)
at addChunk (internal/streams/readable.js:309:12)
at readableAddChunk (internal/streams/readable.js:284:9)
at TLSSocket.Readable.push (internal/streams/readable.js:223:10)
at TLSWrap.onStreamRead (internal/stream_base_commons.js:188:23) {
statusCode: 403
}

visual dock
#

Hi I want to show up on the bot servers site.
The written language is BotJS.
What should I do?

rose warren
proven lantern
#

see any issues with this balance teams function?

#
const balanceTeams = ({players, numOfTeams}) => {
    let playersDescendingRank = [...players];

    // highest rated at index 0
    playersDescendingRank.sort((a, b) => b.rating - a.rating);

    const teams = [];
    for (let i = 0; i < numOfTeams; i++) {
        teams.push({
            players: [playersDescendingRank[i]],
            totalRating: playersDescendingRank[i].rating
        });
    }

    playersDescendingRank = playersDescendingRank.slice(numOfTeams);
    while (playersDescendingRank.length) {
        for (const team of teams) {
            if (!playersDescendingRank.length) {
                console.log("uneven teams");
                break;
            }
            const playerWithLowestRating = playersDescendingRank.pop();
            team.players.push(playerWithLowestRating);
            team.totalRating += playerWithLowestRating.rating
        }
        teams.sort((a, b) => b.totalRating - a.totalRating);
    }
    return teams;
}

const players = [
    {
        playerId: "123",
        rating: 1000
    },
    {
        playerId: "123",
        rating: 1050
    },
    {
        playerId: "123",
        rating: 1100
    },
    {
        playerId: "123",
        rating: 1150
    },
    {
        playerId: "123",
        rating: 1200
    },
    {
        playerId: "123",
        rating: 1250
    },
    {
        playerId: "123",
        rating: 1350
    },
    {
        playerId: "123",
        rating: 1400
    },

]
console.log(balanceTeams({players, numOfTeams: 2}))
module.exports = balanceTeams;```
solar cave
#

how can i write text on image in discord.py ex:welcome image with user id on image

slender thistle
#

PIL

quasi shard
solar cave
#

I can manipulate image but Idk how to write something on that image

solar cave
pale vessel
solar cave
#

Tnxs

quasi shard
#
bot.on('clickButton', async (button) => {
    if (button.id === 'basic_drone') {
        const user = button.clicker.user.id;
        const { pick } = gacha.simple(lootTable);
        await button.channel.send("<@" + user + ">\nCongrats , you opened a Basic Drone Pack just got a " + pick.name);
    }
})

Am I doing something wrong in this handler code for discord-buttons? It works fine but it always gives this little red error below.
P.S. It's my first time working with buttons.

pale vessel
#

You have to respond to the interaction

cinder patio
#

you need to respond to the interaction

quartz kindle
#

thou hast to respond to the interaction

small tangle
#

After evaluating all possibilities, the decision to respond to the interaction manifests itself

green kestrel
#

has everyone prepared their bots about me section yet?

pale vessel
#

I've always had it say my bot's summary

#

So it'll just be that once they push it

small tangle
#

does it support Link ?

pale vessel
#

Yeah

small tangle
#

nice

rocky bolt
tired panther
quasi shard
#

btw thanks, fixed it

pale vessel
cinder patio
#

omg thanks

#

can you also give me a docs link pleaseπŸ₯Ί

#

I found it it's under "Activity"

#

so unorganized jesus

errant flax
#

how do i make the object shown as a string cuz im trying to make an eval cmd and when im mentioning/logging an object it says [Object object] and I will always go to the console and see what the output is..
any fix for this?

pale vessel
#

Simple way is to use the inspect method from util

#

I think JSON.stringify() would also work but it's less customizable (you can't specify depth/show inenumerable props)

errant flax
#

json method kidna stinky notsopog

errant flax
#
const util = require("util")
module.exports = {
  name: "ev",
  category: "hidden",
  run:async(msg,args,client,cache)=>{
    if (msg.author.id!==client.application.owner.id) return msg.channel.send(`Only **${client.application.owner.tag}** can use this command!`)
    const code = args.join(" ")
    if (!code) return msg.channel.send("Bruh just input something")
    try {
      const evaled = await eval(code)
      console.log(evaled)
      msg.channel.send(`\`\`\`\n${util.inspect(evaled)}\n\`\`\``)
    } catch(e) {
      console.log(e.stack)
      msg.channel.send(`\`\`\`\n${e}\n\`\`\``)
    }
  }
}
#

oh its utils iara_laugh

pale vessel
#

It's util, my bad

errant flax
#

still wont work

pale vessel
#

Check your console

errant flax
#

its just the error

pale vessel
#

You're only sending the error message there

errant flax
pale vessel
#

But it's the whole stack trace

#

You had console.log(e.stack)

#

Check what method the error originated from

woeful pike
#

usually when most js parsers see opening and closing brackets with a: b in it in a place where they expect a statement they interpret it as a block and a label

#

you need to wrap it in parentheses to force it to interpret it as an expression

errant flax
#

oh so ill just add parenthesis in the eval thing like

woeful pike
#

yes

errant flax
#
eval(`(${code})`)
woeful pike
#

only if your code is supposed to be an object literal

cinder patio
#

I mean you could add the parentheses in the arguments for the command, but I guess it doesn't really matter

#

wait it does matter

#

it won't work if your code is a statement

woeful pike
#

this is the same reason why if you do

console.log(stuff.map(thing => { thing }))

you're gonna get a bunch of [undefined, undefined] unless you do

console.log(stuff.map(thing => ({ thing })))
cinder patio
#

just do ({ name: "John" }) as the argument

woeful pike
#

because otherwise it thinks you're doing

stuff.map(thing => {
  thing;
  return;
})
errant flax
#

thx!

cinder patio
#

😩

errant flax
#

now i forgot why i need eval dog_kek

long crow
#

Looking good like this? I mean the interaction on each command from searching manga -> details -> recommendations The button doesn't look so interesting though

modest maple
#

being someone who serves alot of this sorta stuff to users

#

they generally only look at / care about the description in summary, the title, the image, genres and rating

#

everything else is just basically entirely ignored

long crow
#

hmm, I usually couldn't care less about rating though πŸ€”

cinder patio
#

rating is important

modest maple
#

Tends to be what alot of people look at when you're searching for something new

#

thats what i do ^

long crow
#

Maybe good idea to include rating, genres I agree, but api for recommendation is that limited to only link/images. sadge

modest maple
#

shrug The downsides of not using your own api bloblul

long crow
#

MAL api is lacking, and I don't think I want to scrap MAL for that. kekw

modest maple
#

MAL's api basically just doesnt exist lol

pale vessel
#

Jikan already scrapes MAL for you though, even has more info than MAL's official API

long crow
#

well, that is the recommendations api from jikan

modest maple
modest maple
long crow
#

rec api. KEKW

pale vessel
#

Fetch the anime by ID then

modest maple
#

Why not just make your own btw

long crow
#

I can, but don't think I have the time to tinker around scrapping MAL

proven lantern
quartz kindle
#

anime focused or manga focused?

#

for manga, i find mangaupdates much better than MAL, but they dont have an api, its easy to scrape them tho

long crow
#

tend to focus more on anime nowadays

sudden geyser
#

What does Your Name. have to do with the police

sudden geyser
#

unless my name's going to be on a list after watching

pale vessel
#

Maybe

hexed sedge
#

Hey! Can anyone help me really quick with some javascript?

earnest phoenix
#

Sure

hexed sedge
#

I need to export from a command the id of the author who ran the command and use it in another file. This is generally what the command looks like:

module.exports = {
    async execute(message, client, args) {
        const cmduser = message.author;

        module.exports = { cmduser };
    },
};

And the other file looks like this:

const { cmduser } = require('../commands/admin/options.js');

module.exports.run = async (menu) => {
    console.log(cmduser);
};

But when I run the second file, cmduser gives me invalid. Any idea why so?

#

It generally looks correct to me.

cinder patio
#

That's not possible

#

what you can do is store the ID in the client object

#

client.someUserId = cmduser;

#

then in your second file you'd do client.someUserId to get the id

#

The second file exports a command right?

earnest phoenix
#

Can't they just assign the ID as the value of a property to the exports?

hexed sedge
#

Then call that in the second file... Ok yeah that makes sense

hexed sedge
earnest phoenix
#

module.exports.id = someValue

#

That should export the ID as well when required

cinder patio
#

and you'll import the command WAY before it gets executed

pale vessel
#

Use fs and JSON.parse() 😎 πŸ‘ πŸ‘ πŸ‘ /s

#

Not possible even

pale vessel
#

What are you trying to do?

earnest phoenix
#

I mean, you can delete the cache and require it however; but gotta do some other stuff then, but yea you should store the ID in the client object or something

cinder patio
#

you still can't

hexed sedge
#

I need to export the message.author object to another file

wooden kindle
#
const { MessageButton } = require("discord-buttons");

    module.exports = {
    name: "b-test",
    description: "A new buttons command.",
    aliases: [""],
    usage: "",
    categoery: "test",

    run: async (client, message, args) => {

        const embed = new MessageEmbed()
        .setTitle(`Discord Buttons`)
        .setDescription(`**TEST MESSAGE 01**`)
        .setColor(`RANDOM`)

        const FirstButton = new MessageButton()
        .setStyle(`green`)
        .setLabel(`Yes`)
        .setID(`12345`)

        const SecondButton = new MessageButton()
        .setStyle(`red`)
        .setLabel(`No`)
        .setID(`234`)

        message.channel.send({ buttons: [FirstButton, SecondButton], embed: embed });

        client.on("clickButton", async (button) => {
            if (button.id === "12345") {
                button.defer()
                button.channel.send("id 12345")
                };

            if (button.id === "234") {
                button.defer()
                button.channel.send("id 234")
                };
        });
}
};``` 

idk what ive done wrong can someone help me. the message is being sent but no buttons
#

idk if im just stupid or what

hexed sedge
cinder patio
#

Attach it to your client.

earnest phoenix
hexed sedge
cinder patio
#

though even attaching it to your client is not ideal because if two people use the same command then client.someUserId is going to be the ID of the last person who used the command

#

preferably put all IDs in an array which is attached to the client

#

or a map

wooden kindle
#

i see

long crow
#

I think this look better than previous one πŸ™ƒ P.s, no rating for mangas

hexed sedge
waxen bough
#

ohh i see

grizzled dagger
long crow
#

what's what?

grizzled dagger
#

I dunno what your bot is but it looks cool

long crow
#

Thank you for the compliment, it moving on tortoise level

#

I mean the development of it, since I'm working adult

grizzled dagger
#

I know that feeling, I just finished re-writing my bot today

earnest phoenix
#

Is it possible to replace a file inside node_modules or edit it so it uses my custom code. Ik it is possible through using a repo link

cinder patio
#

fork the repository and use your repo instead of the node module

sudden geyser
#

I assume you're relying on AniList or MyAnimeList as your data source, but I just don't think the embed looks that great.

#

Like putting the ID in the title

#

Or trying to use the description field as both the score and synopsis, prioritizing the score first

#

Or the use of colons in the fields when it should be clear they have a value associated with them

#

Or the use of the cover image in the image and thumbnail fields.

#

Or how the ID is duplicated in the title and footer while the ID in the footer has no meaning to it.

#

I'm not saying you should strictly follow the semantic meaning of the fields, but I just think the design could use improvements.

long crow
#

It used for next button interaction, but I removed it afterward, I mean for the id on footer

#

But in the end opinion are opinion, x can say x, y can say y

tired panther
earnest phoenix
#

hello, How is it done in the photo?

#
        var next = new MessageButton()
        .setStyle("blurple")
        .setLabel("Next")
        .setID("next");

Nodejs - Discordjs

cinder patio
#

A custom emoji probably

#

Try \πŸ—‘οΈ in the label

earnest phoenix
#

are you sure

cinder patio
#

set your style to "danger"

split hazel
#

label?

#

theres a dedicated emoji field i think

cinder patio
#

only for custom emojis

earnest phoenix
#

How to make next emoji, back emoji and refresh emoji long question?

cinder patio
#

Put the emojis in the label

#

\⏭️

#

\◀️

earnest phoenix
#

you are right thank you

earnest phoenix
#

What's the difference between process and worker ?

quartz kindle
#

a process is a process

#

a worker is a thread or isolated instance inside the same process

earnest phoenix
#

Code: js let quest = client.quests.Math.random()
Error: xl Cannot read property 'random' of undefined

quartz kindle
#

client.quests.Math is undefined

wooden kindle
#

hey im gonna host my website on repl.it and this is a test but where do i put the code on the bottom

earnest phoenix
quartz kindle
#

show where you define it

earnest phoenix
# quartz kindle show where you define it
//blablabla
client.quests = new (Discord.Collection || Map)();
//blablabla
const questFiles = fs.readdirSync('./quests').filter(file => file.endsWith(".js"));
for (const file of questFiles) {
    const quest = require(`./quests/${file}`);
    client.quests.set(quest)
}```
#

sorry it took a while i had to do something

cinder patio
#

quests is a collection

#

maybe you mean client.quests.random()?

earnest phoenix
hexed sedge
#

Hello! I am having a small issue. Feel free to tell me that I am dumb at any point.
I have an array, and I want to move all the strings in that array to a different array, and at the same time edit the string to include more info-ish.
This is the code that I have so far (messy, I know)

const userinfo = [ 'accountid', 'accountname', 'accountrole', 'accountbalance,', 'verifiedtof' ];

        const options = [];

        const createOptions = async (item) => {
            const pushme = { value: item, description: `Enabled: ${await db.get(`${message.guild.id}_${item}`)}` }
            
            options.push(pushme);
        };

Can someone help me with why the array options will return empty?

cinder patio
#

You're creating a function and not calling it

hexed sedge
#

Oh its called in a piece of code I didnt copy

cinder patio
#

serious question: do you know what you're doing?

hexed sedge
cinder patio
#

well show us how you call the function

hexed sedge
#
if(args[0] == 'userinfo') userinfo.forEach(createOptions);
#

I am still in the process of learning javascript

cinder patio
#

And where are you console logging options? Is it after the call or before that

hexed sedge
#

After calling it

cinder patio
#

then it shouldn't be empty

hexed sedge
#
const userinfo = [ 'accountid', 'accountname', 'accountrole', 'accountbalance,', 'verifiedtof' ];

        const options = [];

        const createOptions = async (item) => {
            const pushme = { value: item, description: `Enabled: ${await db.get(`${message.guild.id}_${item}`)}` };

            options.push(pushme);
        };

        if(args[0] == 'userinfo') userinfo.forEach(createOptions);

        console.log(options);
cinder patio
#

Are you sure args[0] is equal to userinfo

hexed sedge
#

Yes, 100%

#

Otherwise the other code wouldnt run

cinder patio
#

only the userinfo.forEach(createOptions) part wouldn't run, unless you're checking somewhere else

#

and if you are, then that check in the code you showed is pointless

hexed sedge
#

If you want I can even show both the code and my terminal

cinder patio
#

console.log(args[0] === "userinfo") place this right before the if statement\

hexed sedge
#

Logs as true

#

Im extremely confused

cinder patio
#

oh it's cause createOptions is async

#

forEach and async don't mix well

#

you can't wait for the forEach to finish

hexed sedge
#

bruh

cinder patio
#

use a for loop

hexed sedge
#

Ok, Ill use that now

solemn latch
#

could you just map it?

#

op

#

i was scrolled up, nvm

cinder patio
#

You can, but you'll have to use Promise.all

#

complicates things

solemn latch
#

ah fair

hexed sedge
#

Finally got it to work how I wanted it, thanks @cinder patio <3

wooden kindle
#

on cloudflare

silk wadi
#

Yeah

#

Create a cname

#

Make sure proxy is dns only

#

And when it connects, u can change proxy to proxied

wooden kindle
#

ok

#

thanks @silk wadi

silk wadi
#

:)

naive turret
#

i gues its here i am going to ask about reaction role

cinder patio
#

I N T E R E S T I N G

#

any way to place the box shadow below the lightbulb

#

I guess an invisible div with a width and height as the lightbulb could do

cinder patio
#

nvm I used the drop-shadow function

woeful pike
#

are any of you using the top.gg api? Can you check to confirm the vote check endpoint is working for you again?

pale vessel
#

It works

#

Individual user vote, right? js { voted: 1 }

earnest phoenix
#

Where can i get a list of recommended cooldowns for Discord requests like ?
Role add/remove
Nickname change
Channel edit

lament rock
#

You'd have to look at raw request response headers for making requests

#

There is no list somewhere

earnest phoenix
#

does raw req response return guild id or user id?

lament rock
#

Some requests do

#

You'd have to look at docs for routes you use to see their return value

exotic coyote
#

Hello @earnest phoenix :p

wooden kindle
#

does shards update every 250 members

#

or 2,500

exotic coyote
#

2500

sudden geyser
#

2500 servers max per shard

wooden kindle
#

ok

#

thanks

visual chasm
#

Input: abc123
Output: Yes

Input: abc123#
Output: No

Input: aBc123
Output: Yes

Input: aBc123#
Output: No

Input: 123.,*/-+
Output: No

#

How can i do that?

visual chasm
cinder patio
#

regex

visual chasm
crimson vapor
#

o

visual chasm
#

but i don't know how it's done

crimson vapor
#

idk regex either

pale vessel
#

You know but you don't know

visual chasm
#

i know the regex but i don't know how to do it

pale vessel
#

regex.test(string)

visual chasm
#

^[A-Za-z0-9] but how can i check

pale vessel
#

I-

#

Also use ^[A-Za-z0-9]+$ if you want to match from start to end

crimson vapor
#

any site that has "regex" in its name will let you test it

visual chasm
#

if (!message.content.includes(/^[A-Za-z0-9]+$/) return; is it good?

pale vessel
cinder patio
#

you know regex but you don't know js thonkku

quartz kindle
#

includes doesnt accept regex

#

only strings

#

for regex you need to use match or test

#

or replace

visual chasm
quartz kindle
#

string.replace accepts regex, so does string.match and string.search, and regex.test

visual chasm
#

Obviously i'm making a mail system and i don't want the mail address to contain anything other than letters and numbers.

quartz kindle
#

you can use any of those functions

earnest phoenix
wooden kindle
#

is there any way to make your bot send a message in a channel when it goes offline or online

#

u think

sudden geyser
#

If you want to send details about the bot changing states (e.g. a system failure), you'll need to record the cause and use it when sending the message.

#

Like writing to a file.

wooden kindle
#

i see

hexed sedge
#

Hey! Whats the best package for the new slash commands? I dont exactly want to update my discord bot to v13 discord.js atm

carmine river
#

hey so is this channel only related to topgg api or can i ask a general question related to discord api too?

hexed sedge
solemn latch
#

this is general development

carmine river
#

ok thanks

hexed sedge
solemn latch
#

wow im slow πŸ‘€

hexed sedge
carmine river
earnest phoenix
earnest phoenix
#

When I input this into my code:

let questc = new (client.quests.get(quest.name))();```
I get this error:```xl
TypeError: client.quests.get(...) is not a constructor```
#

I looked it up and I'm pretty sure this is the right way to do this.

honest flume
#

Hey Everyone

earnest phoenix
#

hi

pale vessel
#

hi @everyone

errant flax
#

how do i sort an array of obj via a string..
like this

[
{
name: "Jhon",
age: 21
},
{
name: "Jake",
age: 20
}
]

this is just an example btw bonk

solemn latch
#

so you want jake to show up first?

errant flax
#

yes
i onlt know how to sort with numbers

#

not strings e_existential

lament rock
solemn latch
#

localCompare sorts alphabetically(it doesnt sort, but can be used to sort), but also sorts accents

#

so it may not work entirely the way you want

errant flax
lament rock
#

you can replace non alpha chars

errant flax
#

thx it works!

low relic
pale vessel
#

Yes

split hazel
#

dictionary or something idk I finished English

pale vessel
#

That doesn't look "shorter"

wheat jewel
#

Who is pinging me!

long crow
#

Not me

low relic
low relic
sudden geyser
#

Optional but useful in some cases

#

You may be thinking of JSON

long crow
#
params : {
platform,
type,
'sort-by' : sort,
},``` This is some cases where quotes is needed
lament rock
lament rock
#

idk. I dont use py

long crow
#

I'm debating to use duckduckgo IA api or not.. but it look tempting

amber thistle
#

why does // notes cause errors in my bot's css?

#

like if i do

// the nav bar
.class{ font-size: 100rem }

this css does not get executed

cinder patio
#

/* This is a css comment */

earnest phoenix
#

any one help me to setup aws

#

pls

#

i cant know how make intance and also deploy

#

so pls help me

vale garden
#

hi

#

does anyone know how to get a profile banner of a user?

fresh verge
#

Is it possible to add hyperlinks to non-embedded messages?

earnest phoenix
fresh verge
earnest phoenix
#

yeah that won't work, md links need to have embeds. observe:

no

fresh verge
#

I thought I’ve seen it in a regular message before. (Webhook).

#

Well what does surrounding a link with <> actually do?

earnest phoenix
#

Suppresses the embed

#

Any one please help me to setup aws

cinder patio
#

next.js is driving me nuts

#

dev build literally takes a minute to load, wtf?

#

and the strange thing is that it wasn't like this yesterday

worn sonnet
#

Hey, when temp ban with @ZeroTwo bot and if the bot went down or rebooted
will the user still get unbanned after the specified time when reboot?

#

I did temp ban with d.py with deafult code. i.e,

#
@bot.command()
async def ban(ctx, user:discord.User, duration: int):
    await ctx.guild.ban(user)
    await asyncio.sleep(duration)
    await ctx.guild.unban(user)
pale vessel
#

It won't

#

You have to store the ban info in a database and redo the process on startup by fetching your DB

worn sonnet
#

I know this wont

#

But does zero two do it?

crimson vapor
#

if its a popular bot, it does

worn sonnet
#

yeah so anothor DB chunk for temp bans and temp mutes

crimson vapor
#

mutes are normally temporary

worn sonnet
#

hmm.. I guess i will save only bans

pale vessel
#

Generally you should save all data that has to do with timeouts for persistency, no matter how long it may be. Once you restart your bot, everything will be reset

ornate otter
#

Hello, i've had this issue for a while and i just kinda left it until now, the margin-top is broken on my website but it only breaks when the website is on the host that i use, when i locally host it, it's fine, i contacted the host to see what was up, and he said it's never happened before and he doesn't think it's there end and i should try clearing cache, i tried it and it did nothing

cinder patio
#

there's no way a hosting service break / change the layout of the page, unless they change the code themselves

#

are you sure your local files are the same as the files that are on your host?

ornate otter
#

The files are exactly the same

#

and on the website the MT-5 IS THERE it's just not effective in the Same way

#

the margin on t he local hosted one seems to just be lower then on the hosted one

obtuse knoll
#

Can anyone help me with an idea I have for my discord bot? (discord.py)
I am trying to make it so that the bot works in direct messages, where it asks you some questions and you provide answers.
Then depending on your answers, it gives you a role in the server.

long crow
pale vessel
#

Try it and see mmLol

#

DiscordAPIError: Maximum number of allowed attachments in a message reached (10).

#

10

long crow
#

Yeah, got confirmation from discord developer server

#

It got the limit of 8mb too

summer torrent
#

what are you trying to do

eternal osprey
#

hey! Is there any way to directly write this object to like a txt file?

errant flax
#

whats the best db for a like smoll bot/project hmm

visual knoll
#

hm

eternal osprey
modest maple
#

if its a small bot just use sqlite

summer torrent
#

quick.db

errant flax
#

whats sqlite lookaround

#

i mean i already made a mongodb acc so ye just gonna have stick with mongodb 02shrug

crimson pike
#

How do I define discord.js client in app.js file?

errant flax
#

required the module?

summer torrent
#

what

errant flax
#

require*

crimson pike
#

no

pale vessel
#

Instantiate the client

summer torrent
#

what kind of question is that

crimson pike
#

There are codes for my bot in index.js and there are codes related to top.gg in app.js

summer torrent
#

and?

errant flax
#

i dont get what u mean bonk

summer torrent
#

didn't you wrote it?

#

or just copied from somewhere

errant flax
#

me ^ jk

crimson pike
#

I want to do something using the client in index.js in app.js

summer torrent
#

i don't understand you

errant flax
#

i suggest maybe export client in a separate file thats what i do

pale vessel
#

Make app.js a function and execute it in index.js (with client as parameter), maybe

errant flax
summer torrent
#

yeah

errant flax
#

just export the client in index.js or what flazepe said

crimson pike
#

thx

errant flax
#

np

visual chasm
#

How can i check if the message contains anything other than letters and symbols

pale vessel
#

What kinda symbols

eternal elbow
#

I wrote an api for the non-authorization part of my site, but anyone can access it by doing example.com/api/blabla, how can I make it safe?

eternal osprey
#

but does anyone know how to authenticate myself?

#

i already have my desired key but got no clue where to put it

visual chasm
radiant kraken
#

like if all the characters match a certain unicode range, return true otherwise false

visual chasm
radiant kraken
#

yeah sort of

visual chasm
#

i am very lazy, can you show me how to do it

radiant kraken
#

you can match only alphanumeric with \w tho

#

like /^\w+$/

earnest phoenix
#

hello

rustic nova
#

thanks

earnest phoenix
#

is it possible to host a bot that edits and reads from json files on hosting platforms like heroku?

#

all the guides i've watched only shows hosting a single index.js file

#

i think you can if you require it

#

require it and then still use fs to read and edit it?

lusty quest
#

dont use json as a "database" heroku deletes all files if the process restarts, or gets updated

earnest phoenix
#

it's temporary for now, as i have other things to work on, but maybe use replit for now then? they recently added an "always on" feature.

young rune
#

:/

#

and its not "recent"

#

lmao

earnest phoenix
#

i have the plan through school

young rune
#

lmao, better just use the always on trick

#

later ur school finds out

#

:))

earnest phoenix
#

i don't know much about it though, like limits etc

#

why would my school mind me using a feature integrated in the replit plan

young rune
#

its not related to school.

#

the project itself.

earnest phoenix
#

huh, it's not like they're gonna pay any extra for it

young rune
#

HHAAA-

earnest phoenix
#

they don't

young rune
#

yeah i think its better off getting ur own account

#

instead of ur school one.

earnest phoenix
#

lol, im 100% sure it's not a problem

visual dock
#

Hellp

#
Error: MongooseError: The `uri` parameter to `openUri()` must be a string, got "undefined". Make sure the first parameter to `mongoose.connect()` or `mongoose.createConnection()`
#

Not Connected MongoDb

sudden geyser
#

did you check the parameters to .connect/.createConnection

visual dock
tired panther
#

interesting lol, no it wont die, I will maintain it , as long as I will live...

sudden geyser
#

so what is Config.mongoDB

visual dock
sudden geyser
#

try logging it

rose warren
visual dock
cinder patio
tired panther
split hazel
earnest phoenix
#

Why aren't there any updated version of passport-discord

young rune
#

sirs how do i make a webhook

boreal iron
#

How do we know u won't die tomorrow
lol pandasad

sudden geyser
split hazel
#

that's a slow point to make

sudden geyser
#

Sometimes the slow path is the fastest path

peak patrol
#

Hiya

#

I nΓ©es help :)

#

Need*

idle gale
#

Same

peak patrol
#

Oof

#

Somebody cimes help ussss we really really Wang iiiit :D

#

Want*

boreal iron
#

How about posting your issue?

idle gale
#

Yesss :))

peak patrol
#

Comes*

#

Ok

boreal iron
#

Instead of screaming for help...

peak patrol
#

I nΓ©es help in putting Γ  costume statuts for thΓ© bot

#

What are thΓ© hole steps

boreal iron
#

For JS, PY, PHP... ?

peak patrol
peak patrol
#

Node*

boreal iron
#

Using Discordjs?

peak patrol
#

Yup

peak patrol
#

Thanks

boreal iron
#

setPresence is capable of updating the client's status

flat copper
#
client.guilds.cache.forEach(g => {
				try {
					client.channels.cache.get(data.globalChat).send(embed)
				} catch (e) {
					return;
				}
			});```
I want it to send message to all channels which are in db but its spamming
boreal iron
#

Bad idea. Of course it's spamming, therefore API abuse

flat copper
#

How can I fix this?

boreal iron
#

By not sending the message to all guilds?!

flat copper
#

Well its global chat

solemn latch
#

globalchat imo is a really bad idea

quartz kindle
#

a foreach loop for that is a really bad idea too

boreal iron
#

badΒ² pandasad

quartz kindle
#

webhooks would be better than using a bot

flat copper
#

fixed

cinder patio
#

yo dream boy, don't avoid the problem

flat copper
#

Me?

earnest phoenix
#

How do i update my node to v14?

#

i wanna use djs v13 owo

cinder patio
#

Uninstall old node, install new node

#

or use nvm

#

but I think it's linux only

earnest phoenix
#

where i will do that?

#

oh-

#

i use replit

#

How i do it in repl

cinder patio
#

I dunno

earnest phoenix
#

oop-

#

Same

cinder patio
#

but I'm gonna guess that you can't

earnest phoenix
#

i

#

can it be updated in visual code?

cinder patio
#

oh wow look it took me a second to search on google for the issue

earnest phoenix
#

Oop

#

Thanks

boreal iron
#

it took me a second to search on google
Imagine using Google KEKW

split hazel
#

imagine taking you more than a second to quote that reply, respond to it and find a specific emoji and then posting it, most likely taking you more than a second therefore you have played yourself and wasted your time

boreal iron
#

Imagine writing that text ... smirk

lament rock
#

Imagine thinking about it

#

waste of brain time

#

too many cycles lost

boreal iron
#

aye... seems to be the right time for alcohol

obtuse knoll
#

Hey guys, can anyone help me with some discord.py stuff?

#

I am trying to make a sort of 'questionnaire' / 'survey' bot where if you DM it, it will respond with a question - you answer said question - and then it gives you another question

#

and repeats until the end

feral aspen
#

Where can I find the discord.js v13 docs?

smoky spire
grand salmon
split hazel
#

sucks to suck because of discord

grand salmon
#

discord kinda fucked a bunch of devs by denying some of their intents on verification

#

i shut my bot down because of that lol

boreal iron
#

The process should be even more strict, accepting ages 18+ only

boreal iron
#

master = v13

feral aspen
#

Ohh.

boreal iron
#

"Docs settings" top left corner

feral aspen
boreal iron
#

Select the branch

feral aspen
#

Goodness dude, the changes. πŸ˜‚

boreal iron
#

They've just changed their design, making the website uglier

feral aspen
#

The old website was so much better.

#

.. I can't even press back, so you'll have to go back by RESTARTING.

grand salmon
#

i love the new docs ;-;

tired panther
#

Which js library is good for doing POST requests?

lament rock
#

any http lib. If you want something lightweight, try centra

pale vessel
#

Oh no...

#

Phew

split hazel
#

reques-

pale vessel
#

I was assuming a masochistic answer from Papi

lament rock
#

import net from "net"

#

net best TCP lib

split hazel
#
const https = require('https')

const data = JSON.stringify({
  todo: 'Buy the milk'
})

const options = {
  hostname: 'whatever.com',
  port: 443,
  path: '/todos',
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Content-Length': data.length
  }
}

const req = https.request(options, res => {
  console.log(`statusCode: ${res.statusCode}`)

  res.on('data', d => {
    process.stdout.write(d)
  })
})

req.on('error', error => {
  console.error(error)
})

req.write(data)
req.end()
pale vessel
#

Aye

split hazel
#

i should actually try that

#

good way to understand http more indepth

tired panther
#

Imma just use node-fetch

pale vessel
#

It's simple enough

lament rock
#

isn't node-fetch deprecated

pale vessel
#

Request is

lament rock
#

ah

pale vessel
#

The npm one

clear marlin
#

use

#

superagent

feral aspen
#

Hello. πŸ‘‹

#

.. so I'm seeing some really advanced detailed websites, but whenever I see the source, it's like 1 line of code.

#

.. may I ask what they use to do that?

tired panther
feral aspen
#

Here's a random portfolio I found.

#

.. the source is legit 8 lines.. but it's supposed to be more.

boreal iron
#

just loads a JS app

#

if you wanna see the source code of the files, you have to follow the links

feral aspen
#

Ohh.

#

This website is legit crazy good.

boreal iron
#

I mean you can shrink your code to one line only... why not

#

minimal script version are a little bit smaller, missing all the spaces and line breaks

tired panther
#

The are using a builder, for loading the html

feral aspen
#

Ahh.. I see.

tired panther
#

There are some decent programms for creating complex images and animations

feral aspen
#

Damn..

#

Do you know any?

tired panther
#

They cost something lol

feral aspen
#

I know.. but like which website does that?

earnest phoenix
tired panther
cinder patio
#

So happy that typescript has macros now topggVeld

proven lantern
#

I have records stored in my database with a key that looks like this.

key=hash([playerId1, playerId2]

Each record stores the rating for that team of players. I am writing a function to create balanced teams given a list of playerIds. Since I'm storing data this way do i need to try fetching every team combination from the DB to find the most balanced teams?

Given this function how quickly does the number of DB calls grow by changing numOfTeams and listOfPlayers?

balanceTeams({numOfTeams, listOfPlayers})

proven lantern
#

because you are using typescript

earnest phoenix
#

If you are having issues with types then use the correct type

#

pepega

proven lantern
#

i dont have issues with types

#

i use javascript

earnest phoenix
#

Yea noob

proven lantern
#

i have issues with types in Java

earnest phoenix
#

Who doesn't

#

Java sucks balls

proven lantern
#

oop

#

yep

earnest phoenix
#

This is a joke java users dont cancel me

cinder patio
earnest phoenix
#

I might be confused on the term macro here

proven lantern
earnest phoenix
#

I am mad cause I have to implement openid into my project

#

But i have 0 idea how

vivid fulcrum
#

aspnet core gang

earnest phoenix
#

So ima play fallout 4

earnest phoenix
vivid fulcrum
#

one method for any platform that uses openid mmLol

cinder patio
#

macro is a very board term, think a function which expands into multiple statements

vivid fulcrum
#

i made a discord + steam auth verification site in like 10 minutes thanks to aspnet core

earnest phoenix
#

I am using nodejs though

#

and I don't like the idea of using an external thing for people to sign up with like auth0 or curity

vivid fulcrum
#

auth0 is so useful but i don't like using it at all

earnest phoenix
#

I would use it if it didn't require them to visit their site to sign up with.

#

I want them to signup on my site not some external source

proven lantern
#

any ideas here? if there is a team of like 50 players and they want to balance into 5 teams how many times would i need to call my db?
#development message

earnest phoenix
#

Why not call it once to get the 50 players and split them up into even 5 teams?

proven lantern
#

the db doesn't support querying

cinder patio
#

what db is it

proven lantern
#

dynamodb

#

everything i want to lookup has to be a flat key. anything nested can't be a key or queried on

proven lantern
earnest phoenix
#

I am confused about what you want

#

Didn't you wanna split 50 players into 5 teams?

proven lantern
#

yeah, but the teams of 5 have are what have the rating, not the individual players

#

so i cant just fetch the 50 players ratings

#

i have to fetch each possible team combination

#

then find the 5 teams with the lowest rating difference

earnest phoenix
#

Well your initial request made me think each player has a rating

#

I honestly have no idea what you are actually trying to accomplish so im afraid I can't really help

proven lantern
#

teams have an Elo rating and i'm trying to place players into teams that are as even as possible

#

i wrote this assuming there would be ranks for each player.

#
const balanceTeams = ({players, numOfTeams}) => {
    let playersDescendingRank = [...players];

    // highest rated at index 0
    playersDescendingRank.sort((a, b) => b.rating - a.rating);

    const teams = [];
    for (let i = 0; i < numOfTeams; i++) {
        teams.push({
            players: [playersDescendingRank[i]],
            totalRating: playersDescendingRank[i].rating
        });
    }

    playersDescendingRank = playersDescendingRank.slice(numOfTeams);
    while (playersDescendingRank.length) {
        for (const team of teams) {
            if (!playersDescendingRank.length) {
                console.log("uneven teams");
                break;
            }
            const playerWithLowestRating = playersDescendingRank.pop();
            team.players.push(playerWithLowestRating);
            team.totalRating += playerWithLowestRating.rating;
            team.avgRank = team.totalRating / team.players.length;
        }

        // keep the team with the
        teams.sort((a, b) => b.totalRating - a.totalRating);
    }
    return teams;
}

const players = [
    {
        playerId: "1",
        rating: 1000
    },
    {
        playerId: "2",
        rating: 1050
    },
    {
        playerId: "3",
        rating: 1100
    },
    {
        playerId: "4",
        rating: 1150
    }

]
console.log(balanceTeams({players, numOfTeams: 2}));
module.exports = balanceTeams;```
jovial nexus
#

how can i restart the entire node app with a command?

earnest phoenix
#

Just CTRL C it

jovial nexus
#

"with a command?"

earnest phoenix
#

Not sure there is such

proven lantern
#

use pm2 to run node

jovial nexus
#

im using it

earnest phoenix
#

since a node process runs until told not to

proven lantern
#

then pm2 restart [ID]

earnest phoenix
#

and with pm2 just use pm2 restart ID

jovial nexus
#

"with a command?"

#

from the bot

earnest phoenix
#

Could of specified that

proven lantern
#

exec

earnest phoenix
#

There is no way to do that really unless you wanna run pm2 restart ID

#

Which would work and bring the bot back online.

jovial nexus
#

yeah i can use exec in the child process

#

thank you

earnest phoenix
#

what does this mean
Exception: Request failed for https://discord.com returned code 400. Truncated server response: {"embeds": ["0"]} (use muteHttpExceptions option to examine full response) at onSubmit(Code:54:17)

vivid fulcrum
#

you didn't send a valid request

cinder patio
#

sassy kitty

earnest phoenix
#

I love http.cat

#

I use it in some of my older projects

strong sage
#

B

tired panther
proven lantern
#

is this the number of combinations for finding all combinations of 5 man teams with a pool of 50 players?

#

or this?

#

the db should be able to handle that many calls no problem

#

wait it would be this

#

why do numbers get so big