#development

1 messages · Page 2 of 1

sterile lantern
#

i thought it was discord limiting login because of how many bots share the same ip

quartz kindle
#

so youre looking for a specific 429 that is on the /gateway/bot route

#

because all other 429s are not a problen

sterile lantern
#

so what exactly am i looking for here

quartz kindle
#

in most cases the gateway rate limit happens when trying to login, so it should be caught by the error generated by client.login

sterile lantern
#

oh i can just add a catch for that and then process.kill

quartz kindle
#

probably yes

#

is 1 the actual pid of the shell process? or is it just a shortcut for "this shell"?

#

because process.kill will likely need the actual pid

rose warren
#

wait 👀 since when could bots do links like this in message content?

#

and how?

sudden geyser
#

Is that a webhook message?

rose warren
#

possibly

#

i was thinking it might be a slash command

#

but can't test rn

sudden geyser
#

I doubt it is.

rose warren
#

Ah yeah looks like a webhook

#

Yeah it is

#

pog

lament rock
#

Slash commands route through webhooks and as such, you can embed links in text without wrapping them in message embeds

#

Everything webhooks can do, slash commands can do

spark flint
#

not regular bot messages tho Sad

lyric mountain
#

embeds can too

earnest phoenix
surreal sage
#

How do I convert a timestamp with format yyyy-MM-dd'T'HH:mm:ss.SSS'Z' to Unix/Epach

lyric mountain
#

doesn't new Date() allow inputting a string?

surreal sage
#

Yeah testing rn

#

Works ty

earnest phoenix
#

When i make a post request to /users/@me/channels with a recipient id, it tell me that bots cannot use this endpoint, i used this since 1 year, anyone know what is the new endpoint to send a message trough api ?

lyric mountain
#

did u change the base url?

#

to v10

earnest phoenix
#
const createChannelRequest = await fetch(`https://discord.com/api/v10/users/@me/channels`, {
        method: 'POST',
        headers: { 'Content-Type': 'application/json', 'Authorization': `Bot ${token}` },
        body: JSON.stringify({
            recipient_id: user.id
        }),
});

return

{ message: 'Bots cannot use this endpoint', code: 20001 }
lyric mountain
#

well, you could get the guild and then fetch the channels

#

maybe they made that endpoint user-only to prevent private channels leak or something

earnest phoenix
#

it's /users/@me, it's not guild channels

#

its all dm channel with bots & users

earnest phoenix
#

but it's not the guild channel endpoint

lyric mountain
#

discord has been very strict regarding data security in the past year

lyric mountain
earnest phoenix
#

i should not get this error then

lyric mountain
#

you should 100% be getting that error

#

read what I said again

#

you can't access a user-only endpoint by using a bot

wheat mesa
#

^^^^

earnest phoenix
#

but it's /users/@me it's not guild related, if it was, bot won't be able to send messages anymore then

wheat mesa
#

That’s not how it works

#

User endpoints are different than bot api endpoints

lyric mountain
wheat mesa
#

That endpoint is intended for users only

earnest phoenix
#

what's the endpoint for bots then

lyric mountain
#

none

wheat mesa
#

Use the documentation

earnest phoenix
#

how you send dm with a bot then

#

😂

lyric mountain
#

maybe they made that endpoint user-only to prevent private channels leak or something

earnest phoenix
#

you need to create a channel

lyric mountain
#

see the docs

wheat mesa
#

Use a library to do this stuff, why are you doing it libless in the first place

earnest phoenix
#

not specified on doc

lyric mountain
#

or...why are u calling the endpoint directly tho?

earnest phoenix
#

on doc it say it's /users/@me/channels

lyric mountain
earnest phoenix
lyric mountain
#

what language?

wheat mesa
#

You need to understand how the discord api actually works before trying to do things libless

lyric mountain
#

assembly?

wheat mesa
#

The discord api is very extensive

earnest phoenix
#

I already know how the api work

wheat mesa
#

Obviously not or you wouldn’t be here :p

earnest phoenix
#

You need a channel id to send a message with a bot, but the endpoint to create a channel doesn't work anymore, that's what im trying to say

lyric mountain
#

ok so, go to a library project github and see how they do it

#

you just need to see what endpoint they're calling

#

and with what data

#

optionally just go do discord documentation and find it

earnest phoenix
#

the discord doc is outdated

lyric mountain
#

then go to a discord lib project repository

#

like d.js or JDA (idk how "clean" d.js is, ik jda is well documented tho)

sharp geyser
earnest phoenix
#

POST request to api/v10/users/@me/channels, it should return a channel id, when you put a user id in recipients

wheat mesa
earnest phoenix
lyric mountain
#

you really ignore what I said didnt u?

wheat mesa
#

Use api v9 and see if it works for a quick test

earnest phoenix
surreal sage
#
                let currentPage = 1
                let messageId
                function getRow() {
                    const r = new Discord.MessageActionRow()
                    r.addComponents([
                        new Discord.MessageButton().setCustomId("previous").setEmoji("◀").setDisabled(JSON.parse(`${embeds.length > 1 && !currentPage <= 1 ? false : true}`)).setStyle("SUCCESS"),
                        // new Discord.MessageButton().setCustomId("trash").setEmoji("🗑").setStyle("SUCCESS"),
                        new Discord.MessageButton().setCustomId("next").setEmoji("▶").setDisabled(JSON.parse(`${embeds.length > 1 && !currentPage == embeds.length ? false : true}`)).setStyle("SUCCESS")
                    ])
                }
                let row = getRow()

                interaction.reply({ embeds: [embeds[currentPage - 1]], components: [row] }).then(a => { messageId = a.id })```
Getting this nice error that I have no clue of where it's located, I'm guessing it's inside **getRow()**
earnest phoenix
lyric mountain
#

I told u the solution yet your ego refuses to let u look how official library devs do it

sharp geyser
#

it isn't outdated

#

djs uses v10 of the api and still uses that same endpoint

surreal sage
earnest phoenix
sharp geyser
#

How are you forming the body

#

code would be helpful

#

we aren't going to play a guessing game

earnest phoenix
#
 const createChannelRequest = await fetch(`https://discord.com/api/v10/users/@me/channels`, {
        method: 'POST',
        headers: { 'Content-Type': 'application/json', 'Authorization': `Bot ${token}` },
        body: JSON.stringify({
            recipient_id: `${user.id}`
        }),
    });

return

{ message: 'Bots cannot use this endpoint', code: 20001 }
sharp geyser
#

Well discord doesn't even accept strinfied json last I heard

lyric mountain
#

they don't

wheat mesa
#

^

#

That’s probably your issue

sharp geyser
#

it is URLSearchParams

lyric mountain
#

it has to be a urlencoded body

sharp geyser
#

iirc

earnest phoenix
#

yeah it work now, thx yall 🙂

sharp geyser
#

👍

#

are you using discord-api-types perchance?

#

djs v14 is a lot harder to read

#

they split off their rest stuff from the main package

#

😔

scenic moat
sharp geyser
#

Wait you aren't the real tim

#

@quartz kindle we have an imposter

scenic moat
quartz kindle
#

xD

sharp geyser
lyric mountain
#

timposters

mint rock
#

hi, not bot related but i have a very weird network issue, can i ask here?

lyric mountain
#

just ask

mint rock
#

its very weird, so when i download things on web or test speed

#

its fast

#

but downloading on steam and literally any other program is super slow

#

even chrome installer is super slow

lyric mountain
#

or test speed
what speed test program?

mint rock
#

first google one

#

like if i download any program online its fast, look

lyric mountain
#

hm, because ik most providers use caching, which adds some biasing to the speed results

#

maybe ur downloading a commonly downloaded program

#

try downloading ubuntu

mint rock
#

see, its normal

#

but

lyric mountain
#

it's not a normally downloaded file, so you'd get pretty accurate results

mint rock
#

on steam its so sloww

lyric mountain
#

check if your region is right on steam

mint rock
#

it is, i changed like 6 servers

lyric mountain
#

and whether your antivirus isn't getting in the way of it

mint rock
#

none, no av

#

yeah also youtube wont load its so werid

#

but

#

like...

#

its supposed to be like 10 seconds

#

not 22 minutes

#

man i changed dns, used proxy and vpn idk what else, changed hop limit

digital swan
#

you tried a different device? see if it’s ur internet or computer

solemn latch
wheat mesa
#

Not to mention your disk write speed as well

#

If you have a slow disk you’ll probably experience slow “download” speeds

rose warren
fossil bronze
#

I see I got no replies

#

But the FUD about sqlite not working with multiple processes seems to be just that

ashen orbit
#

is there a way to do something like embed.fields to see how many fields there are

rose warren
ashen orbit
#

ok thanks

#

saves some time

#

Error: Unsupported client

#

wait

#

wrong channel

#

mb

raw nest
#

Why does Prisma convert type "String" to "Varchar(191)"? Why 191 and not the maximum of 8 Bits => 255?

raw nest
eternal osprey
#
let message = await interaction.fetchReply()
                       message.editReply({ephemeral: true, content: `Dein Gegner hat nicht innerhalb von 30 Sekunden geantwortet. Sie werden daher gegen einen Bot kämpfen.\n\nIch sehe du hast wieder alles gegeben! Bleib dran, um neue Techniken und magische Sprüche zu erlernen. Du hast ${random_number} EP gemacht mit diesem kampf.`})
                    ```message.editReply() is not a function?
sharp geyser
#

no

#

fetchReply returns a message

#

so it would jus be .edit

eternal osprey
#

You are hot misty. Thank you

sharp geyser
#

idk if ephemeral will be possible here tho

eternal osprey
#

we could always try!

#
    channel = await interaction.guild.channels.create(`${interaction.options.getUser("gegner").username}-${interaction.user.username}`, {
                type: 'text',
                permissionOverwrites: [{
                    id: interaction.guild.id,
                    deny: ['VIEW_CHANNEL'],
                    deny: ['SEND_MESSAGES'],
                }, {
                    id: interaction.user.id,
                    allow: ['VIEW_CHANNEL'],
                    allow: ['SEND_MESSAGES'],
                }, {
                    id: interaction.options.getUser("gegner").id,
                    allow: ['VIEW_CHANNEL'],
                    allow: ['SEND_MESSAGES'],
                }]
            });```is interaction.guild.id even a thing? I always used to use message.guild.id and it worked
#

now it doesn't.

sharp geyser
#

well if interaction.guild.channels works then you should be able to get the id

#

you could do interaction.guildId if you don't wanna go through .guild

#

keep in mind tho if the command is used in dms there will be no guildId or .guild

eternal osprey
sharp geyser
#

You are not being descriptive

#

"Why doesn't this work then?" is not helpful to us trying to help you

eternal osprey
#

I am very sorry misty. let me help you

sharp geyser
#

What are the errors. What is it doing instead

eternal osprey
#

The channel doesn't have that lock in front of it (the one that indicates it has had permission overwrites). No errors at all, normal guild members still see the channel

sharp geyser
#

Why are you defining deny twice btw

#

It is logical that if it is an array it takes multiple

eternal osprey
#

Okay i know, it's just a bad habit of me

#

but still that wouldn't be the issue

sharp geyser
#

Yea I know I was just pointing it out

#

as for yyour issue I see nothing wrong

#

Unless discord.js changed how you define everyone

#

Yea I don't know that all looks correct to me

#

Based on the documentation that should work

quartz kindle
#

strings in v14 are not screaming snake case anymore

sharp geyser
#

Wait really?

#

Wait they don't even support strings do they?

#

you have to use the PermissionFlagsBits

quartz kindle
#

they do support strings

#

but they are now pascal case

sharp geyser
#

I still think it is better to use the enum

quartz kindle
#

allow: ["ViewChannel","SendMessages"]

#

yes, using the flags from the enum is recommended precisely because of this

digital swan
#

does discord-hybrid-sharding support v14 yet?

sharp geyser
#

Does not seem like they have mentioned anything about it

pearl trail
sharp geyser
#

It doesn't look like they depend on djs as a whole

#

So it probably doesn't matter what version you use it on

feral aspen
#
(async () => {
    require('dotenv').config();
    const { ShardingManager } = require('discord.js');
    const manager = new ShardingManager('./src/index.js', { token: process.env.TOKEN, totalShards: 2 });
    
    manager.on('shardCreate', shard => {
        shard.on('ready', () => {
            if (manager.shards.size === manager.totalShards && manager.shards.every(x => x.ready)) shard.send('allReady');
        });
        console.log(`[SHARDS]: Launched shard ${shard.id}`);
    });
    
    await manager.spawn({ delay: 10000, timeout: -1 });
})();

Another sharding issue, shard 0 spawns and ready event is fired, but shard 1 also spawns but ready event doesn't fire.

#

Ready event as in the shard.on.

quartz kindle
#

how do you know? you dont have any console.log inside it

feral aspen
#

Anyways, I'm keeping it one shard for this time.

#

It's weird, though, it used to log but now no. I'm still in V13.9.

earnest phoenix
#

When hosting the bot and dashboard do I host them in the same place?

sick agate
#

you don't need to

sharp geyser
#

you can

peak wing
#

Hey guys, I am trying to find a way to add a song to a queue.

I set the bot to play a song, but when I tell the bit to play another song it skips the current song to play the new song. How do I just make it play the next song after the current song to finish?

earnest phoenix
sharp geyser
#

it is really up to you

sick agate
#

yeah

earnest phoenix
#

How can I link the bot and dashboard

sick agate
#

a database

sharp geyser
#

you can make an api that handles fetching data related to the bot

earnest phoenix
#

Huh

sick agate
#

or IPC which you prova don't need to

sharp geyser
#

or you can host it on the same process so you already have info on the bot that you can just use

earnest phoenix
#

Mind sending me a website with a documantion explaining this

sharp geyser
#

I don't know of one

earnest phoenix
#

If anyone does please send me it

quartz kindle
feral aspen
# quartz kindle i dont see a console.log inside the shard.on("ready")
(async () => {
    require('dotenv').config();
    const { ShardingManager } = require('discord.js');
    const manager = new ShardingManager('./src/index.js', { token: process.env.TOKEN, totalShards: 2 });
    
    manager.on('shardCreate', shard => {
        shard.on('ready', () => {
            if (manager.shards.size === manager.totalShards && manager.shards.every(x => x.ready)) /*for (const [, shard] of manager.shards) */shard.send('allReady');

            console.log(manager.shards.size === manager.totalShards, manager.shards.size, manager.totalShards)
            console.log(manager.shards.every(x => x.ready));
        });
        console.log(`[SHARDS] Launched shard ${shard.id}`);
    });
    
    await manager.spawn({ delay: 10000, timeout: -1 });
})();
quartz kindle
#

and those two console.logs dont log anything?

feral aspen
#

When spawning the second shard, no.

#

The only thing that logs is the [SHARDS] part during shard 1.

quartz kindle
# earnest phoenix If anyone does please send me it

a bot dashboard is a very broad subject, its the same as creating a website with a login system, it can be done in a million different ways, and you need to know both front end and back end code, as well as databases

quartz kindle
feral aspen
#

The SHARD log logs for the first shard so do the 2 console logs. However, the SHARD log also logs for the second shard, but the 2 console logs don't.

quartz kindle
#

what does the debug logs say?

feral aspen
#

I haven't really tested that out.

#

I'm just rewriting the bot for now then I'll get back to it.

sharp geyser
#

👀

#

But you are having issues with your shards identifying

#

listening to the debug event might help

feral aspen
#

Sure, I'll do that. I'll just finish the basic files then I'll figure it out.

last tapir
#

whats this

#

CHAT_INPUT?

sharp geyser
#

slash commands

#

so a chat input would be /commandName arg1

last tapir
#

this is my config code, and it works without it

#

so im a bit confused

#

should i be using it

sharp geyser
#

I think by default it will use it

#

I am not entirely sure

quartz kindle
rocky dagger
#

i got all of these commands but only the 5 last ones are actually loading please help

sharp geyser
#

show

#

code

rocky dagger
wheat mesa
#

First thing I’d recommend here is logging client.commandArray somewhere before/after you register your commands

#

Also instead of doing fs.readDirSync, I’d use the promise version of the fs API for asynchronous reads

rocky dagger
#

first an empty array then one with every command object inside

wheat mesa
#

There’s a version of the fs api that you can use async/await on, instead of being stuck in callback hell

#

Here’s a quick little tutorial that explains how to use it https://flaviocopes.com/node-fs-await/

Node.js built-in modules famously are not promise-based.
This is for historical reasons, as those modules were created before promises were a thing.
We’ve had promisify for quite some time, but I recently found out Node.js provides a new API that’s promise-based.
I thought it was new but it’s been introduced in Node.js 10 (2018, it’s been a whil...

rocky dagger
#

and how do i translate this import * as fs from 'node:fs/promises'; to using require?

near stratus
#

why do you still use require ?

#

It's 2022

rocky dagger
#

bc i havent learned import and when i tried i got some errors i had no idea how to fix

#

and people just told me to use require instead

wheat mesa
#

You might have to do something like
const fs = require('fs').promises;

#

Then you can use stuff like await fs.readFile(someDirHere)

#

Imo it’s much cleaner than using the synchronous version of fs

rocky dagger
#

then i cant use filters

near stratus
#

why can't you?

#
const a = await Something()
const b = a.filter(......)
rocky dagger
#

TypeError: fs.readdir(...).filter is not a function

sharp geyser
#

just do that

raw nest
#

I'm currently working with zod. Now I wonder if I should make an extra file to store all those Objects? Or other suggested file structure?

sudden geyser
#

what's zod

sharp geyser
raw nest
# sudden geyser what's zod
vivid fulcrum
sharp geyser
#

(await fs.readdir(...)).filter(...)

rocky dagger
#

U gotta have the () around await fs.readdir(...)?

sharp geyser
#

if you do it on one line yes

#

if you wanna put it in a variable and call .filter on a variable you can do it that way as well

rocky dagger
#

Ahh that’s the issue then

sharp geyser
#

wrapping it in parans just resolves the promise and allows you to use it directly after

near stratus
# sharp geyser ``(await fs.readdir(...)).filter(...)``
const SomeAsyncFunction = (smt) => {
   return new promise((resolve, reject) => {
       fs.readdir(....)
           .then(fileList => {
               resolve(fileList.filter(smt))
           }).catch(reject)
   })
}

//In your code
await SomeAsyncFunction(Filter function)
sharp geyser
#

That works as well ig

boreal iron
#
const map = new Map();

map.set(1, {"abc": 1});

const get = map.get(1);

get["bcd"] = 2;

map.set(1, get);

console.log(map);

So... map.set(1, get); isn't needed at all? I thought you can't manipulate maps without it's set() method?!

sharp geyser
#

no

quartz kindle
#

you dont need to use async fs if you're only loading files at startup

boreal iron
#

also there's a bracket { inside then which doesn't belong into

quartz kindle
boreal iron
#

ahh, okay makes sense

rocky dagger
sharp geyser
#

Show updated code

rocky dagger
#
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');
const { AsciiTable3, AlignmentEnum } = require('ascii-table3');
const fs = require('fs').promises;
const clientID = '811586423933108254';

module.exports = (client) => {
    client.loadedCommands = new AsciiTable3('Commands')
        .setHeading('Command', 'Command Name', 'Status', 'Reason')
        .setAlign(3, AsciiTable3.CENTER);
    client.handleCommands = async () => {
        const commandFolders = await fs.readdir(`./src/commands`);
        let files = [];
        const { commands, commandArray } = client;

        for (const folder of commandFolders) {
            const commandFiles = (await fs
                .readdir(`./src/commands/${folder}`))
                .filter((file) => file.endsWith(`.js`));

            for (const file of commandFiles) {
                const command = require(`../../commands/${folder}/${file}`);
                commands.set(command.data.name, command);
                commandArray.push(command.data);
                files.push(file);
            }
        }
        for (i = 0; i < commandArray.length; i++) {
            if (!commandArray[i].name) {
                client.loadedCommands.addRow(
                    files[i],
                    '\u00A0',
                    '⭕ FAILED',
                    'Missing a name.'
                );
            } else if (!commandArray[i].description) {
                client.loadedCommands.addRow(
                    files[i],
                    commandArray[i].name,
                    '⭕ FAILED',
                    'Missing a description.'
                );
            } else {
                client.loadedCommands.addRow(
                    files[i],
                    commandArray[i].name,
                    '🔷 SUCCESSFUL',
                    '\u00A0'
                );
            }
        }

        const rest = new REST({
            version: `9`,
        }).setToken(process.env.token);

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

                await rest.put(Routes.applicationCommands(clientID), {
                    body: client.commandArray,
                });

                console.log(`Successfully reloaded application (/) commands.`);
            } catch (error) {
                // console.error(error);
            }
        })();
    };
};```
feral aspen
wheat mesa
#

The Manager usually has a cache of type Collection, but also has other utility methods on top of it related specifically to the collection it’s managing

sharp geyser
rocky dagger
#

they are

sharp geyser
#

Have you tried publishing them to 1 singular guild to see if they actually are being created cause global commands can take a while to fully register

rocky dagger
#

that also didnt work and isnt commands registering instantly now?

lyric mountain
wheat mesa
#

Commands are not guaranteed to be registered globally instantly

#

It’s usually pretty fast nowadays but still not guaranteed

sharp geyser
#

That is why I always push to a specific guild when testing

pine nova
sharp geyser
#

At least I am guaranteed it to be there

boreal iron
pine nova
boreal iron
#

try calling a property like so object.fuck you

lyric mountain
#
map.set(1, {"\"\"": 1})
pine nova
boreal iron
rocky dagger
lyric mountain
#

how much did ya wait?

rocky dagger
#

since last time 15 min

#

with guild commands

#

and ive never had an issue like this before and those commands that showed up got made as soon as i launched the bot

sharp geyser
#

might I ask why are you doing the creation of the commands yourself through the rest

rocky dagger
#

because i found a tutorial that used it

sharp geyser
#

I would recommend using the client instead

#

client.application.commands.set(commandsArray, guildId)

#

let djs handle the request for you

rocky dagger
#

so remove the const rest = .... and replace the await rest.put(....) with what you sent

sharp geyser
#

I would recommend doing so, that way if they don't post it is either djs fault or you have malformed data in the commands data

rocky dagger
#

still a nope

sharp geyser
#

I have no idea what is going on then

#

You already say your commands array has all the commands so it should post

rocky dagger
#
  {
    name: 'add',
    description: 'Adds a dino or breeder',
    options: [ [Object], [Object] ]
  },
  {
    name: 'addbreeder',
    description: 'assignes a user to a dino to breed',
    options: [ [Object], [Object] ]
  },
  {
    name: 'adddino',
    description: 'adds a dino line to request',
    options: [ [Object] ]
  },
  {
    name: 'claim',
    description: 'Claim a dino you want',
    options: [ [Object], [Object] ]
  },
  {
    name: 'dinos',
    description: 'Lists every dino you are able to claim'
  },
  {
    name: 'list',
    description: 'gives the list of every dino thats added and those that are breeding them'
  },
  {
    name: 'next',
    description: 'Contines the queue for a dino',
    options: [ [Object] ]
  },
  {
    name: 'notify',
    description: 'Notifies the next person in queue',
    options: [ [Object], [Object] ]
  },
  {
    name: 'queue',
    description: 'Sends the queue of a spesific dino',
    options: [ [Object] ]
  },
  {
    name: 'remove',
    description: 'Removes a dino or breeder',
    options: [ [Object], [Object] ]
  },
  {
    name: 'request',
    description: 'Sends a requests for a dino if you want to breed',
    options: [ [Object] ]
  },
  { name: 'test', description: 'test' },
  {
    name: 'unclaim',
    description: 'Unclaim a dino you are in queue for',
    options: [ [Object] ]
  },
  { name: 'help', description: 'A description of all commands' },
  {
    name: 'settings',
    description: 'change settings for the bot',
    options: [ [Object], [Object], [Object], [Object], [Object] ]
  },
  {
    name: 'annonce',
    description: 'give an anouncment',
    options: [ [Object], [Object], [Object], [Object], [Object] ]
  },
  { name: 'button', description: 'Return a button' },
  { name: 'embed', description: 'Returnes an embed' },
  { name: 'menu', description: 'Return a menu' },
  { name: 'modal', description: 'Returns a modal' },
  { name: 'ping', description: 'repies with pong' }
]```
#

thats the output if i log commandArray right before i do client.application.commands.set(commandArray, '494567290990493696')

sharp geyser
#

and none of them get posted?

rocky dagger
#

only the last 5

#

wait

#

logging client.application gives me null

rocky dagger
#

i got it to work now and i dont even wanna talk about it

feral aspen
#

What are you trying to do?

#

Bruh.

boreal iron
#

fake's here to save your day

#

what's up?

boreal iron
#

Doesn't look like so

rocky dagger
#

it is i just made a dumb dumb and i dont wanna talk about it

boreal iron
#

lemme guess, you tried to set the commands before the client has been ready?

earnest phoenix
#

How can I add slash command support for my discord bot in rust?

boreal iron
#

well has nothing really to do with your programming language

#

you register them to the API, then listen to the interaction_create event to receive interaction events

rocky dagger
#

v13 json style

boreal iron
#

ah, well I use the values (integers) the API expects

#

to get rid of djs changing the names of the enums etc.

rocky dagger
#

ye i used strings in some commands apparently

#

so that didnt work

boreal iron
#

same for styles, etc. likely for everything

#

yeah

#

djs doesn't parse them anymore

rocky dagger
#

now im just trying to see if i can detect if a name or description value is missing or type is a string then pass that into the table

#

so that wont happen again

boreal iron
#

well once you begin to use the values the API expects you will remember which value is what, quickly

rocky dagger
#

i just want to keep it as a backup

boreal iron
#

can't find a way to log my error to console and to a file

#

either I move the entire process stderr to my error log file or log it in the console

boreal iron
#

nvm can just initiate a new console

#

and move the stderr stream to my file

lament rock
#

You can also overwrite stdout and stderr and since console.log and console.error pipes to those streams. You can replace it with a stream.Passthrough iirc or stream.Transform if you can't specify a callback with Passthrough

boreal iron
#

Yeah might also be a solution

#

Guess it doesn’t make a big difference at all

nocturne dagger
#

anyone here any good with tailwindcss?

wheat mesa
#

Just ask your question

boreal iron
#

listen to the boy

pale vessel
#

He's a man now

#

And you're a grandpa

sharp geyser
#

no hes not

boreal iron
pale vessel
#

But he's older than you

sharp geyser
#

Who waffle?

pale vessel
#

Yes

sharp geyser
#

tf he is

#

Im the older one

pale vessel
#

Then why is he smarter

sharp geyser
#

He just turned 17 this year

#

I turned 17 last year

boreal iron
#

Case closed

sharp geyser
#

and ur an old man talking to underage kids

#

😎

boreal iron
#

I feel dirty now

sharp geyser
#

you should

boreal iron
#

And I like it smirk

sharp geyser
#

ok bud

boreal iron
#

Damn… not much going on today

sharp geyser
#

After careful consideration I am still going to use unity

#

Despite the negative feelings people are having towards it rn

sharp geyser
#

so ye

#

that happened

boreal iron
sharp geyser
#

Same freedom of speech spiel

boreal iron
#

Lemme guess, scam links?

sharp geyser
#

No

wheat mesa
sharp geyser
#

Arguing with staff cause he couldn't speak russian in general channel so he got muted for that

#

then repeated to dm me death threats in russian towards staff

boreal iron
#

lmao

sharp geyser
#

I am only half way to 18

#

actually more than half

wheat mesa
#

ancient

sharp geyser
#

like 3 more months

#

😎

boreal iron
#

Death threats just because getting muted freerealestate

#

Funny world we’re living in

sharp geyser
#

He also threated to cancel us on twitter

#

as if top.gg hasn't had that happen before

boreal iron
#

imagine using twitter

wheat mesa
#

Cancel me on twitter

sharp geyser
#

ok

#

What is ur twitter handle

wheat mesa
#

Twitter is 30% degens and 65% political degens and 5% shitposters

sharp geyser
#

cmon waffle

#

tell me

wheat mesa
#

I have a private account because my friends dm memes

sharp geyser
#

ok

#

but what is ur handle

#

idc if it is private

wheat mesa
#

Jwaffled I think

boreal iron
#

Or more

sharp geyser
#

this bozo?

wheat mesa
sharp geyser
#

Also still have my christmas pfp

#

ew

wheat mesa
#

Yes that bozo

sharp geyser
boreal iron
ancient nova
rocky dagger
#

u found jsfuck

ancient nova
#

it's weird

sudden geyser
#

Yeah I'd stay away from that thing

#

Just act like it doesn't exist

ancient nova
#

it's too late now:

rocky dagger
sudden geyser
rocky dagger
sudden geyser
#

yuck, no wrap text

rocky dagger
hard sierra
#

nice work

pine nova
hard sierra
hard sierra
surreal sage
#

oop

#

options is not choices on last

iron vector
#

I couldn't figure out how to do this

midnight valve
#

Hey guys, not sure if im allowed to post this here, but I'm looking for someone that can make me a discord bot dashboard, please dm me if you can do this, there will be payment

#

Also, I would like it to look good!!

pearl trail
iron vector
pearl trail
#

make a second ActionRow

iron vector
# pearl trail make a second ActionRow

`const { ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js');

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

if (interaction.commandName === 'ping') {
	const row = new ActionRowBuilder()
		.addComponents(
			new ButtonBuilder()
				.setCustomId('primary')
				.setLabel('Primary')
				.setStyle(ButtonStyle.Primary),
		);

	await interaction.reply({ content: 'Pong!', components: [row] });
}

});`
like this ?

pearl trail
#

yes

surreal sage
#

Can you catch Discord.JS API Errors?

#

I'm copying a old eval command of mine but it doesn't catch api errors

#

using try {} catch () {}

pale vessel
#

await your calls

near stratus
winged linden
#

yoo got a question!

#

how can i have only one if(without an or) and have the ids in an array

#

sometimes its lots of ids, having them in an array seems more clean

near stratus
#

array.includes()

winter pasture
#

["abc", "xyz"].includes(message.guild.id)

winged linden
#

sound great, testing it out now!

winter pasture
#

Does anyone know how to get information about who invited a bot in DJS? 🙃
Like is there a addIntegration event I am not seeing or a property on guildMemberAdd?

fluid pivot
winter pasture
spark flint
#

Wait like 5 seconds on add for caching to clear

winter pasture
#

Ye, audit logs are fun 🙃

wooden ember
#

why are all my bots tokens invalid?

#

made like 7 bots on my account like a year ago and made them all join a vc whith my mates on a privet server and messed around with them

#

no im trying to use one to test some code

#

bot all the bots tokens are invalid

#

the one i still use the token is still good but the others are bogus

#

some arent in a server but the 3 thats are dont work

#

guess ima have to regen the tokens then and se if that works. btu could some one give me and explanation to why this has happend?

wheat mesa
#

Could be a lot of reasons. If you accidentally post your token on GitHub, discord will automatically reset it for you

wooden ember
#

mmm i know about that but i havent touched those bots in almost exactly a year

earnest phoenix
#

yeah

wooden ember
#

?

sharp geyser
#

Regenerate all their tokens ez

wooden ember
#

true but they where they all invalidated in the first place thouygh ?

sharp geyser
#

It's also very likely you just never had the right token in the first place

#

And if this is untrue it could be a number of other reasons that aren't worth thinking about

#

Just Regen the tokens and call it a day

wooden ember
#

theo bot had a bunch of tokens in a json file and loged onto each one after the other started it up today and they are all dead exept for one that ive been using more recently

#

yeah fair neough

lyric mountain
#

Ah, u don't mean ur bot

sharp geyser
#

What if I don't want to

winter pasture
sharp geyser
#

Imagine relying on discord to handle it

wooden ember
#

ok so tryna make a command handler for my test bot cuz its got like 20 commands now and really messy, also want to be able to reload the commands withough having to restart it

#

however keep gettting "cannot exicute undefined" error

#

code incomming

wheat mesa
#

uploads 45 files

wooden ember
#
    try {
        console.log(command)
        console.log(commands)
        commands.get(command).execute(bot, message, args);
    } catch (error) {
        console.log(chalk.red("[ERROR]: ")+error);
        message.reply('that command is broken lol').catch(error => {console.log(chalk.red('[ERROR]: ') + "Send Error - " + error); });

    }
#

so this is athe bit that the errors comming from

wheat mesa
#

well that doesn't really give us anything to work with tbh

wooden ember
#

im getting there

wheat mesa
#

ok ok

wooden ember
#

didnt want to post the entire file

#

commands.get(command).execute(bot, message, args); is where the error comes from

#
bot.commands = new Discord.Collection();

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

for (const file of commandFiles) {
    const command = require(`./commands/${file}`);
    bot.commands.set(command.name, command);
    console.log(chalk.yellow("[INFO]: ")+`loaded command: ${file}`)
}
#

is the handler in the index file

wooden ember
wheat mesa
#

what's commands

wooden ember
#

say is command

digital swan
wheat mesa
#

^

wooden ember
#

i did const { commands } = bot;

#

forgot to put that it

wheat mesa
#

How does one of your commands look

wooden ember
#

but yeah its undefined either way

#

one sec

#
const chalk = require('chalk');

module.exports = async (bot, msg, args) => {
    let message = msg.content.split(" ");
    msg.delete().catch(error => {console.log(chalk.red('[ERROR]: ') + "couldn't delete msg: " + error); }); 
    msg.channel.send(message.content.slice(4)).catch(error => {console.log(chalk.red('[ERROR]: ') + "Send Error - " + error); });
};
wheat mesa
#

well that's why

#

you never assign a name to it

wheat mesa
wooden ember
#

i thought it uses the file name? and yeah i wondered why that was like that

wheat mesa
#

There's no such thing as command.name when you're importing it

#

You need something more like ```js
module.exports = {
name: 'say'
execute: async (bot, msg, args) => {
// stuff
}
}

wooden ember
#

yeah i had thats before (some of this code is from an old bot i made with a handler)

#

i just thought it wasnt needed cuz it used the file name

#

oh well its been a while since ive delt with handlers

wheat mesa
#

require() only returns the exported object within the file, not the file itself

wooden ember
#

fair enough

sacred aurora
#

does someone know how to wait for mongodb gridfs upload?
here's my current code, but it's never resolved

async (filename, path, metadata) => {
    const stream = createReadStream(path).pipe(
      serverBucket.openUploadStream(filename, {
        chunkSizeBytes: 1048576,
        metadata,
      })
    );

    return new Promise((resolve, reject) => {
      stream.on("end", resolve);
      stream.on("error", reject);
    });
}

*turns out to be "finish" instead of "end" oof

earnest phoenix
#

I'm thinking of a way to translate the bot according to the client's language, the problem is to find some docs that talk about it...

earnest phoenix
near stratus
earnest phoenix
#

Heres what my bot currently does, im looking for suggestions:

Get URL from user/avatar -> push data to google - > get data - > push data to API- > get URL of search -> return data from vision in embed, showing total matching images online -> get screenshot of google.com's image search, to show mods/admins a clean version of the results

its a reverse image search bot, could anything be added?

lyric mountain
#

Anything that involves google is a risk by itself

near stratus
lyric mountain
#

Lmao

earnest phoenix
near stratus
#

nvm r/oppai was banned
r/OppaiLove

lyric mountain
#

Like, the final use-case

earnest phoenix
lyric mountain
#

Ok but, is someone really gonna use it?

earnest phoenix
#

4k searches done so far

#

425k members use it

lyric mountain
#

Like it's already a common sense that nobody uses a their own image as pfp

earnest phoenix
#

well, total members

#

maybe 100 people use it lmao

lyric mountain
#

At least no womans

earnest phoenix
lyric mountain
#

Because that'd be literally asking for DM assault

lyric mountain
#

You see, the web is a horny place

wheat mesa
#

I mean it’s pretty much common sense to not reveal information about yourself on the internet like your face to random people

earnest phoenix
#

lol yes, yes it is

earnest phoenix
wheat mesa
#

But I see the use case for reverse image searching

lyric mountain
#

99% of women who do use own images for profile in sites like discord get DM assaulted by horny people

#

Just look at reddit

wheat mesa
earnest phoenix
wheat mesa
#

Mainly because it’s easy for kids to get on there

earnest phoenix
#

but discord doesnt seem to care 😛

near stratus
wheat mesa
#

I can see the use case for reverse image searching if someone sends a picture of “themself” to you to verify if they’re actually being genuine

earnest phoenix
earnest phoenix
#

the other 30 are avatar scans and then random selfie scans from chanels in servers

near stratus
wheat mesa
#

But you gotta be really careful with what you allow to be shown in what channels

lyric mountain
#

There's also the doxx risk

wheat mesa
#

Google images is not a safe place to screenshot without the channel being marked as nsfw, especially if someone reverse image searches something nsfw

wheat mesa
#

Perhaps you could include the screenshot only if the channel it’s in is marked as nsfw

lyric mountain
#

I already pointed that at the beginning

near stratus
#

@earnest phoenix Just put safe=active in the url param

near stratus
lyric mountain
#

Ehh idk, I wouldn't trust google filter

near stratus
winter pasture
#

Google safe search allows educational NSFW

#

So yeah, heads up, it may not do what you think it will do

near stratus
#

proceeds to search a peanus

lyric mountain
#

Vegana

wheat mesa
#

Yeah, no filter is 100% accurate either

near stratus
#

wut this?

#

I'm getting this from sentry so can't pinpoint the exact location

#

And djs logs are useless as always

sudden geyser
#

have fun searching

near stratus
#

So,
Will I need read history perm to send messages?

#

That's new

near stratus
sudden geyser
#

that's not what I mean by searching

near stratus
#

nvm I'll just do

process.on('unhandledRejection', (a) => {
    console.log(a)
})
process.on('uncaughtException', (a) => {
    console.log(a)
});
#

Let node suck itself

digital swan
earnest phoenix
#

@near stratus

#

I need help

#

To make a vouch bot

sharp geyser
#

You can't reply to a message you don't know exists

solid coral
#

Is there a way to vote for my own bot but as a test, so that the vote is not counted but still the event is executed?

boreal iron
#

Yes use the test button on topgg

eternal osprey
#

hey guys

#

what intents do i need for the voiceupdate event to work?

#

i already added the Intents.flags.guilds

stuck dawn
#

i don't understand how can i define toUpdate

quartz kindle
#

the error is saying that setState requires one of the following keys: show, health, armor, hunger, thirst

#

toUpdate is not recognized as any of those keys, as its just a generic string

#

you need to typecast toUpdate to specify those keys instead of just being a generic string

stuck dawn
#

ty

sharp saddle
proven escarp
sharp saddle
#

see the error code: "ERR_EMPTY_RESPONSE"

sharp saddle
#

idfk why

sharp saddle
#

so annoying

dry imp
#

L

lyric mountain
#

Both your server's and webserver's

near stratus
near stratus
earnest phoenix
#

help

earnest phoenix
#
let { label, value, description, emoji } = option;
          ^

TypeError: Cannot destructure property 'label' of 'option' as it is null.```
#

yeah I can't do null in this case but like
you get what I'm trying to do
I wanna display options only if they match the condition

earnest phoenix
#

nevermind I had to use [] instead of null

boreal iron
near stratus
boreal iron
earnest phoenix
#

my method worked

boreal iron
near stratus
#

They said it was giving extra errors

earnest phoenix
#

im getting db.set is not a function error

#
            db.set(guild.id, a[i]) 
            db.set(a[i], channel[2].id)
sharp saddle
#

literally nothing

boreal iron
#

Wasn’t really aware there has been an issue

proven escarp
earnest phoenix
#

i fixed

eternal osprey
#
if(talkedrecently.has(message.member.id)){
return
}```
        Uncaught TypeError TypeError: Cannot read property 'id' of null
#

Huh why is this happening>?

#

The rest of the code performs well (it does give me a role like it should)

#

but it errors and send this

#

it came from this exact line

boreal iron
#

well, member is null obviously

wheat mesa
#

Probably used in a DM

#

Make sure that you only check for spam/whatever you’re doing in a guild

eternal osprey
eternal osprey
wheat mesa
#

Well then it’s happening somewhere else. Member is most definitely null, it does not magically appear after being null for no reason

#

What’s message

#

I assume a Message object but you gotta be careful with the order you have your arguments in for your command handler

lyric mountain
sharp saddle
#

well

#

i found this while debugging

#

also this in client

lyric mountain
#

I had uncountable issues with that little bugger

#

may I ask, what are u using it for?

earnest phoenix
#

does somebody know how I can linesplit urls in an embed
e.g.

raw/ayatugerud```

and still make it clickable?
lyric mountain
#

u cant

#

because to break line u need to use \n, which is an invalid url character

cinder patio
#

why do you want to do that anyways

lyric mountain
#

what you can do (although I don't really get why) is:

[https://hastebin.com/](https://hastebin.com/raw/ayatugerud)
[raw/ayatugerud](https://hastebin.com/raw/ayatugerud)
#

it's technically 2 links, but should work as u asked for

warm ferry
#

Hello

sharp saddle
lyric mountain
earnest phoenix
#

because I believe it looks better

#

alright thanks doe

wheat mesa
#

you could just use markdown to just make it a shorter link

sharp saddle
eternal osprey
#

ey guys i have an issue that's fucking me in my ass rn: js client.on('messageCreate', async (message) => { console.log(message.member) if(message.member.user.bot === true){ return } })Uncaught TypeError TypeError: Cannot read property 'user' of null. My log first logs the guildmember and then logs null/ Why is it being fired twice lol?

lyric mountain
pale vessel
#

Kinky

lyric mountain
#

but well why don't u simply message.author (or user idk)

#

also, did u check if ur not registering the event twice?

sharp saddle
sharp saddle
#

message.member.user.bot?

#

smh

lyric mountain
lyric mountain
#

and doesn't error out of nowhere like s.io

wind kayak
sharp saddle
lyric mountain
#

I think the ws is is more widely used

boreal brook
#

.addChoices(option.StringChoices.choices.map(c => [String(c[0]).replace(/\s+/g, '_').toLowerCase(), String(c[1])])),
where should the name: '...', value: '......' between

#

is now v13 and i will go to v14

boreal iron
#

oh

sharp saddle
boreal iron
#

lol the chat didn't scroll down

#

so forget what I said

wheat mesa
#

so no type coercion

boreal iron
#

better use !!message.member.user.bot === true

wheat mesa
boreal iron
#

actually what he's looking for is:

#
client.on('messageCreate', message =>
{
  if(message.author?.bot) return;
}
wheat mesa
#

no >:C

boreal iron
#

yes, author isn't always present

wheat mesa
#

ok well I assumed that it was always there

#

I forgor how discord works

boreal iron
#

according to the docs it seems like it's not

#

(djs docs)

wheat mesa
#

perhaps webhooks

boreal iron
#

maybe isn't available if you don't have partials subscribed

#

or this

#

yeah idk

#

@wheat mesa is this site working for you?

near stratus
boreal brook
#

.addChoices(option.StringChoices.choices.map(c => [String(c[0]).replace(/\s+/g, '_').toLowerCase(), String(c[1])])),

where should the name: '...', value: '......' between
is now v13 and i will go to v14

boreal iron
#

weird it's just white for me

wheat mesa
#

im getting a 406 as well

boreal iron
#

is my browser broken

#

network log doesn't log any status code at all

#

tf

lyric mountain
boreal brook
#

?

boreal iron
#

he means where he needs to put the options into

#

just show the associated code if you want an useful answer

boreal brook
#

Good moment

wheat mesa
#

holy fuck

#

wtf is that

boreal brook
#

slash command handler

wheat mesa
#

that is a LOT of repeated code

#

and a lot of typecasts for seemingly no reason

boreal brook
wheat mesa
#

again, most of it is just repeated

#

you could most definitely condense this

near stratus
#

String("UwU")

boreal brook
near stratus
boreal brook
boreal iron
#

WHY do you import your command file let pull = require(`../slashCommands/${dir}/${file}`); and then PUSH the structure which is already as the API expects it INTO A SLASH COMMAND builder?

#

what a nonsense

boreal brook
wheat mesa
#

don't

#

there is a fuck ton of code in there

#

that would be like 3 messages of just pure textwall

near stratus
wheat mesa
#

no

#

well yes

near stratus
#

I just did

wheat mesa
#

but not easy to read

boreal brook
wheat mesa
#

it gets cut off after a few lines

#

like 60ish lines

#

third party sites are much better, it also allows mobile users to read it easily

near stratus
boreal brook
near stratus
#

but the people who'll help you can't use it

boreal iron
#
module.exports = {
    name: "customspeed",
    description: "Verander de snelheid van de bot.",
    options: [ 
        {
            "StringChoices": {
                name: "snelheid_getal",

                description: "Welk snelheidsbedrag moet de muziek hebben?",
                required: true,
                choices: [
                    ["0.25", "0.25"],
                    ["0.50", "0.5"],
                    ["0.75", "0.75"],
                    ["1", "1"],
                    ["1.25", "1.25"],
                    ["1.50", "1.5"],
                    ["1.75", "1.75"],
                    ["2", "2"],
                    
                ]
            }
        }, 
    ]
module.exports = {
            name: "customspeed",
            description: "Verander de snelheid van de bot.",
            options:
            [
                {
                    type: 3,
                    name: "snelheid_getal",
                    description: "Welk snelheidsbedrag moet de muziek hebben?",
                    required: true,
                    choices:
                    [
                        {
                            name: "0.50",
                            value: "0.5"
                        },
                        {
                            name: "0.75",
                            value: "0.75"
                        },
                        {
                            name: "1",
                            value: "1"
                        },
                        {
                            name: "1.50",
                            value: "1.5"
                        },
                        ...
                    ]
                }
            ]
        }
near stratus
#

wtf

boreal iron
#

choosing this sturcture in your command files is exactly what the API expects

#

oops, there're some of my names and descriptions still in

boreal brook
#

Yes I do a lot in my slash command handler, which can make my codes shorter

earnest phoenix
#

does anyone know a good npm library/package where I can create a word scrambler and unscrambler ( instead of having to make my own function in js )
basically I am trying to scramble an URL ( so people won't be able to figure out the URL so easily )
the URL serves the purpose to get the base64 encoded json objects from it
and I would like to hide it from the people,
so I want to create a scrambler that randomly scrambles the URL

#

like here
and then I pass the scrambler variable to some function and then unscramble the url

boreal brook
#

but how do I adjust line 72 in the slashcommand handler to v14, so with that name and value

boreal iron
#

Defining an useless key like StringChoices makes no sense at all

#

Just assign a type to the option or choice

#

Which is exactly like the API expects it

boreal brook
boreal iron
#

Then you can literally get rid of 75% of your repeating code

near stratus
boreal brook
#

Yeah but that's not the point, I'm here to ask how can I change that line to v14 instead of talking to me length of my code

near stratus
#

saying can't access private property raw

near stratus
boreal iron
boreal brook
near stratus
near stratus
boreal iron
#

why the heck would you use client.raw to send your requests? I never said this

boreal iron
#

if you wanna keep your horrible structure, go on

#

there are the docs

#

to v14

near stratus
boreal brook
#

I just want to know how to do that line because I can't figure it out with the docs.

boreal iron
#

The builders do only create the raw objects for you as it will be send to the API as it excepts it

boreal iron
#

Since the builder constructors are continuesely changing their name, or removing methods or guards, just write the objects yourself instead of using builders

#

Ok an example:

near stratus
#

send / edit won't take raw

meager solstice
#

Hi !
I found a code on GitHub which allows to create a database of movies (because I am the creator of a movie server)...
Except that there is a problem... When I follow all the instructions that are written on the GitHub I get an error...
The error concerns the resolvers...

    at file:///C:/Users/Lucas/Desktop/Cin%C3%A9Mix%20Search/src/resolver.js:28:53
    at ModuleJob.run (node:internal/modules/esm/module_job:193:25)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:541:24)
    at async loadESM (node:internal/process/esm_loader:83:5)
    at async handleMainPromise (node:internal/modules/run_main:65:12)```

The GitHub: https://github.com/RealAlphabet/StreamSearch
I would just like to run the bot on my server and not take knowledge or anything...
GitHub

Contribute to RealAlphabet/StreamSearch development by creating an account on GitHub.

wheat mesa
boreal iron
wheat mesa
#
payload.reply({ embed: {
  title: 'Title',
  description: 'Desc',
  fields: [
    { name: 'something', value: 'something else' }
  ]
  color: 0,
}});
#

pretty easy

#

much better than the builder stuff 99% of the time

#

and slash command options are really easy too

#

I feel like the builders were given as tasks to the junior devs to make them busy so the senior devs could work on important api stuff at discord KEKW

boreal iron
#

For example instead of using embed builders, just write the object yourself - that's SHORTER, FASTER and looks better (imo)

let embed =
{
    color: resolveColor(colors.somecolor),
    description: "some description here"
};

Instead of using the action row builder, then component builder (select menu/button builder etc.) write the object yourself (once again)

let component =
{
    type: 1,
    components:
    [
        { type: 2, style: 5, label: "button1", url: links.discord },
        { type: 2, style: 5, label: "button2", url: links.website }
    ]
};

Then pass those vars as options LIKE you would pass your builder vars

await message.reply({ embeds: [embed], components: [component] }).catch(() => null);
wooden ember
#

bruh what is all that stuff for?

#

not been keeping up with all the new stuff

wheat mesa
#

That's not new really

wooden ember
#

its starting to show lol

wheat mesa
#

It's just the actual way the object looks

wooden ember
#

bruh i was using 12 untill a month or so ago

boreal iron
#

Another embed example:

let embed =
{
    color: resolveColor(colors.somecolor),
    author: { name: "Title", icon_url: icons.someimageurl },
    description: "some description here",
    fields:
    [
        { name: "**Field title**", value: "Field description" },
        { name: "**Field title**", value: "Field description" },
        { name: "**Field title**", value: "Field description" }
    ]
};
wheat mesa
#

So you don't have to use stuff like ```js
let embed = new MessageEmbed()
.setThis()
.setThat()
.setEtc();

wooden ember
#

i know that you gotta send the embed in a funny way now instead of just msg.channel.send(embed)

#

but thats bout it

wheat mesa
#

Here's an actual example of some code I used: ```ts
return payload.editOrRespond({
embed: {
color: Constants.KanzenColors.ERROR,
description: 'I am unable to ban that user due to my role position.',
},
});

#

Much cleaner than making an object and using methods imo

wheat mesa
#

Most people use the object builders that are built into djs

#

But most of the time (I'd argue at least) just doing the structure manually is easier

wooden ember
#

i thought you couldnt use it the old way now, just throws an error about inproper formatting or somthing

#

i cant remember

wheat mesa
#

Well yeah you can't do THAT anymore

#

We're just talking about the creation of the embed itself

boreal iron
#

That's EXACTLY what the builders are doing for you

wooden ember
earnest phoenix
#

anyone know a good scrambling & unscrambling algorithm

boreal iron
#

you call the annoying constructer, call the methods like addActionRow() or addFields() etc. and the class returns the final object for you in the structure the API expects @near stratus

#

as written above

wheat mesa
#

I usually only use the builders when I have something like this: ```ts
let embed = new Embed()
.setTitle('Some conditional embed')
// Set other stuff down here

if(someCondition) {
embed.setDescription('Some condition passed');
} else if(anotherCondition) {
embed.setDescription('Another condition passed instead!');
} else {
embed.setDescription('No conditions were passed');
}

boreal iron
#

the fight against the builders has just begun

earnest phoenix
wheat mesa
#

my man it's an example

earnest phoenix
#

ok

wheat mesa
#

also that has nothing to do with what I was saying lmao

boreal iron
#
if(someCondition) {
  embed.setDescription('Some condition passed');
} else if(anotherCondition) {
  embed.setDescription('Another condition passed instead!');
} else {
  embed.setDescription('No conditions were passed');
}

Why calling setDescription()?

if(someCondition) {
  embed.description = 'Some condition passed';
} else if(anotherCondition) {
  embed.description = 'Another condition passed instead!';
} else {
  embed.description = 'No conditions were passed';
}
wheat mesa
#

typescript private props

#

Plus it's more explicit

#

I don't like setting internal properties of something without a setter

#

It's just better practice

boreal iron
#

smh

earnest phoenix
wheat mesa
#

In this case it's perfectly fine but in general I don't do that

boreal iron
wheat mesa
#

We're talking about why using the raw structure instead of builders is better

#

yeah

earnest phoenix
#

whats wrong with that

boreal iron
#

anything

earnest phoenix
#

ok name one

wheat mesa
#

it's unnecessary 95% of the time

earnest phoenix
#

why so

boreal iron
#

97%

wheat mesa
#

because you can just do something like this: ```ts
return payload.editOrRespond({
embed: {
color: Constants.KanzenColors.ERROR,
description: 'I am unable to ban that user due to my role position.',
},
});

#

(Too lazy to write a different example)

boreal iron
#

not bloating this channel by repeating everyting 5 times

wheat mesa
#

I use the raw structure even for the more complex components, though I don't like putting type: 1 and stuff like that

#

I usually use the enum

boreal iron
#

Then use djs enums

wheat mesa
#

for the types so it's easier to read

earnest phoenix
wheat mesa
#

No?

#

It's really easy

#

If anything calling 5 methods every time you want to make an embed is annoying

earnest phoenix
#

u can just make a function for that builder and then pass arguments like description

wheat mesa
#

That's not the point

earnest phoenix
#

it saves u lots of code if ur gonna edit embeds lots

#

so what is ur point

boreal iron
wooden ember
wheat mesa
#

The raw structure is easier to write than making a bunch of jumbled calls

wheat mesa
#

I don't like that style

#

Not to say I haven't done it before, but I still don't like it

wooden ember
#

how so?

earnest phoenix
wheat mesa
#

You can store it in a variable

#

And modify it as you wish

boreal iron
earnest phoenix
#

and why would u use a variable over the builder

wheat mesa
#

This structure is easier to read, it's more explicit when you're writing it

#

Because the builder is basically pointless

#

The embed is really easy to represent as an object

earnest phoenix
#

its up to everyones preference really

boreal iron
#

tbh it is absolutelly pointless

earnest phoenix
wheat mesa
#

Most people's "preference" is because they don't know that u could do otherwise

boreal iron
#

even more since builders being renamed every major version, now their scope has changed etc.

earnest phoenix
#

🤷‍♀️

wooden ember
wheat mesa
#

And once they get stuck on the builders they don't go back

boreal iron
#

and methods/guards being added/removed without any reason

earnest phoenix
#

yeah discord is dumb as hell with that

wheat mesa
#

I use detritus and things very rarely get name changes so it's not really a big deal but still

earnest phoenix
#

v14 is hilarious

wooden ember
#

basically every new version is "hilarious"

wheat mesa
#

The biggest name change in detritus was like renaming SlashCommandClient (And anything to do with slash commands/interactions) to InteractionCommandClient

boreal iron
boreal iron
pale vessel
#

{

}

boreal iron
#

No need to tell me that

earnest phoenix
wheat mesa
#

Although I must admit the raw structure method is more annoying if you're not using typescript

boreal iron
wheat mesa
#

that sounds like a hassle

earnest phoenix
#

wdym hassle

#

its just copy paste

wheat mesa
#

Why would you do that if you could just avoid it all in the first place?

earnest phoenix
#

why would u avoid it in first place if it only takes u copy paste

#

its no big deal as u can see

wheat mesa
#

idk about you but I'd rather not copy paste 500 billion files every time djs makes a change to the builders

boreal iron
earnest phoenix
#

v500000014 sounds amazing

boreal iron
#

have fun changing your code on any major version and on other releases, too

wheat mesa
#

not to mention djs was an insufferable experience after I swapped to detritus

#

everything is just so much better with detritus tbh

#

Pretty much no major breaking changes between updates, very quick support for new features, a built in command handler, etc

boreal iron
#

tbh when seeing how people "code" and paste things together it doesn't matter at all which lib they use

#

they will always prefer djs I guess since you can copy and paste tons of stuff

earnest phoenix
#

they will not prefer anything

#

doesnt matter to them

#

as long as code === works

wheat mesa
#

it's so easy to start up your bot!

#

(Although this is not counting sharding which is something I'm doing in a bot I'm working on)

#

sharding is really easy to handle anyways

boreal iron
#

but djs has a fairly nice documentation to be honest and it's performance is quite okay if you don't think about ridiculous upscaling

quartz kindle
#

ridonkeylous

boreal iron
#

oh no

quartz kindle
#

oh yes

wooden ember
#

lol

wheat mesa
#

detritus needs to update the request lib they use to something else though, it's a memory hog

boreal iron
#

OH NO detritus using SCREAMING snake case

#

omg

earnest phoenix
boreal iron
#

don't tell djs

wheat mesa
quartz kindle
quartz kindle
#

i also had many issues just from trying it out

#

im back to https lol

boreal iron
#

what the fucking heck sort of requests you all do to experience this sort of issues?

wheat mesa
#

cake's notsobot uses ~130gb of ram in 725k servers with detritus

boreal iron
#

never had any issues why the http(s) libs or nowadays node-fetch

wheat mesa
boreal iron
#

not at all

wheat mesa
#

Granted he caches a lot

wooden ember
#

damn how did you get all that info

wheat mesa
#

his bot has a command

#

for it

wooden ember
#

ah

quartz kindle
#

is it hosted on a single machine or did they switch to multiple machines/kubernetes?