#development

1 messages · Page 2072 of 1

lament rock
#

Shards can only identify once every 5 sec

sharp geyser
#

Am I the only one who starts shard ids at 0?

feral aspen
#

But question...

#

What can I do, instead?

quartz kindle
#

if you have 2 shards, it should log twicr

feral aspen
#

API events ran twice, etc.

quartz kindle
#

then you did something wrong

#

are you using shard options in the client?

feral aspen
#

Which, particularly?

quartz kindle
#

like shards: "auto"

feral aspen
#

Oh, yes I am.

#

However, right now it's on 2, reason is is because whenever my real bot is on two shards, it crashes and never runs.

#

So I'm trying to test out why so on my testing one.

earnest phoenix
#

Hi, i got this error, i googled it, nothing, can someone help?

            if (interaction.customId === 'prev') {
                searchResult.prevSearch();
            } else if (interaction.customId === 'next') {
                searchResult.nextSearch();
            } else if (interaction.customId === 'cop') {
                await interaction.reply({ content: 'You copped this image.', ephemeral: true });
            } else if (interaction.customId === 'drop') {
                await interaction.reply({ content: 'You dropped this image.', ephemeral: true });
            }

When i press cop or drop it's showing this in console:

Error [INTERACTION_ALREADY_REPLIED]: The reply to this interaction has already been sent or deferred.
    at ButtonInteraction.update (C:\Users\renat\Desktop\cop or drop\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:210:46)
    at Client.<anonymous> (C:\Users\renat\Desktop\cop or drop\index.js:65:22)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  [Symbol(code)]: 'INTERACTION_ALREADY_REPLIED'
}
C:\Users\renat\Desktop\cop or drop\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:94
    if (this.deferred || this.replied) throw new Error('INTERACTION_ALREADY_REPLIED');
                                             ^

Error [INTERACTION_ALREADY_REPLIED]: The reply to this interaction has already been sent or deferred.
    at ButtonInteraction.reply (C:\Users\renat\Desktop\cop or drop\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:94:46)
    at Client.<anonymous> (C:\Users\renat\Desktop\cop or drop\index.js:71:22)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  [Symbol(code)]: 'INTERACTION_ALREADY_REPLIED'
}
PS C:\Users\renat\Desktop\cop or drop> 
#

it s showing this

#

and crashes

#

same for drop

lyric mountain
boreal iron
#

If so you can’t reply anymore but edit your reply (which is the deferring itself)

earnest phoenix
# lyric mountain show the rest of the code
client.on('interactionCreate', async interaction => {
    try {
        if (interaction.isCommand()) {
            const command = client.commands.get(interaction.commandName);
            if (!command) return;
            await command.execute(interaction);
        };

        if (interaction.isButton()) {
            const message = interaction.message;
            const messageID = message.id;
            
            const searchResult = await resultMap.get(messageID);
            if (interaction.customId === 'prev') {
                searchResult.prevSearch();
            } else if (interaction.customId === 'next') {
                searchResult.nextSearch();
            } else if (interaction.customId === 'cop') {
                 message.reply({ content: 'You copped this image.', ephemeral: true });
            } else if (interaction.customId === 'drop') {
                searchResult.nextSearch();
            }

            const oldEmbed = message.embeds[0];
            const newEmbed = new MessageEmbed(oldEmbed)
                .setDescription(`Result ${searchResult.currentResult + 1} of ${searchResult.resultArray.length}`)
                .spliceFields(0, 1, { name: searchResult.currentSearch().title, value: searchResult.currentSearch().displayLink })
                .setImage(await searchResult.currentSearch().link);

            const actionRow = message.components[0];
            actionRow.spliceComponents(4, 1, new MessageButton()
                .setLabel('View Original')
                .setStyle('LINK')
                .setURL(searchResult.currentSearch().image.contextLink)
            );
            await interaction.update({ embeds: [newEmbed], components: [actionRow] });
            return;
        }

        } catch (error) {
            console.error(error);
            await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
        }
    });
earnest phoenix
boreal iron
#

Wait lemme get to the PC

#

Can’t see shit on mobile

earnest phoenix
#

Huh

lyric mountain
#

and this

#

is going to clash with this

#

ah nvm, it'll enter in one of the two

earnest phoenix
#

I just want it to reply to the message

lyric mountain
#

try deferring

#

and remember, u can't use reply, update, deferReply or deferUpdate twice for the same interaction

earnest phoenix
#

Tried

boreal iron
#

also on which version are you?

#

interaction has no update() method afaik

earnest phoenix
#

13

boreal iron
#

the latest version has no update() method for a command interaction

#

oops

#

it's a button interaction

#

I see

earnest phoenix
#

Yes, it s button

boreal iron
#

anyways, after this is fired

message.reply({ content: 'You copped this image.', ephemeral: true });

you can't respond with this

await interaction.update({ embeds: [newEmbed], components: [actionRow] });

#

since you already responded

#

whatever 'You copped this image.' means requires you to return this reply

#

to stop the coding from going on

#

or if both messages are needed, you have to send a followUp response

earnest phoenix
#

But message.reply isn't ephemeral

boreal iron
#

It can't be ephemeral

#

You're responding to a message not an interaction

#

const message = interaction.message;

#

Responding to the interaction is interaction.reply(...)

#

Calling reply() on the message object will simply send a normal message to the channel (requiring a gateway connection) and has nothing to do with an actual interaction response which is a webhook

earnest phoenix
#

It isn t normal on interaction.reply

#

it can be ephemeral

boreal iron
#

You can only respond with an ephemeral message to an interaction

#

But you choosed to respond to the actual message not the interaction

earnest phoenix
#

like when you click on drop to show that

boreal iron
#

Did you read what I wrote above?

earnest phoenix
#

Yes

#

How to make it in interaction?

boreal iron
#

Stop replying to the message
Reply to the actual interaction

#

message.reply({ content: 'You copped this image.', ephemeral: true });
interaction.reply({ content: 'You copped this image.', ephemeral: true });

earnest phoenix
#

tried that

#

lol im dumb

#

so

#

the error

boreal iron
#

And keep in mind you can't responde a second time await interaction.update({ embeds: [newEmbed], components: [actionRow] });

#

This does not work

earnest phoenix
#

is from interaction.reply

boreal iron
#

You need to do a follow up message

earnest phoenix
#

tried

#

nonthing

boreal iron
#

For your second response just check if the interaction was already responded to

if(interaction.replied) await interaction.update({ embeds: [newEmbed], components: [actionRow] }); else await interaction.followUp({ embeds: [newEmbed], components: [actionRow] });
winged linden
#

sorry for late reply, but cant do that cuz this isnt a command, its an interval which checks new activity of user on a platform. if it gets new activity it sends a private message to the user

lyric mountain
#

wherever u can use .cache us can use .fetch

winged linden
#

not risking being rate limited

lyric mountain
#

what part of "it won't call the api every time" didn't u understand?

#

fetch will only call the api IF it isn't cached

winged linden
#

mmmm okay cool then

lyric mountain
#

also depending on what ur doing sending a message every 5s is the actual danger

#

not the fetch part

feral aspen
#

Hey, for my case, what can I be doing instead to safely spawn all shards? Eyes

lyric mountain
#

await all of them

#

only proceed when all shards are started

winged linden
lyric mountain
#

well, no problem then ig

feral aspen
#
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.every(x => x.ready) && manager.shards.size === manager.totalShards) manager.broadcast('allReady');
        console.log(manager.shards.every(x => x.ready));
        console.log(manager.shards.size === manager.totalShards);
    });
    console.log(`[SHARDS]: Launched shard ${shard.id}`);
});

manager.spawn({ delay: 10000, timeout: -1 });
lyric mountain
feral aspen
#

Alright, I will.

lyric mountain
#

just make a promise that awaits until all shards have started status

boreal iron
lyric mountain
#

do that outside of any shard event

#

right after you create the manager

#

do not proceed until everything is started

feral aspen
#

What do you mean? I'm confused on that part.

#

What should the promise contain, and where should I be resolving?

lyric mountain
#

where do you attach the events?

#

or does djs automatically attach them?

feral aspen
#

Which events?

lyric mountain
#

any event

#

guild events, interactions, messages, etc

feral aspen
#

I have them in a folder, but I'm confused on what you mean.

lyric mountain
#

where is the place where you attach the events to the manager?

#

eg. shardCreate is an event

#

messageCreate is too

feral aspen
#

Yes, however, all related shard things is in one file which is shard.js?

wheat mesa
#

You don't need to attach the events to the manager other than shardCreate

#

Because those other events are attached to the shardClients themselves

#

At least that's how it works in detritus

lyric mountain
#

I mean, he wants to await all shards to be ready before continuing, so you'd have to do that after you create the manager and before you allow interacting with the bot

#

idk where that'd be in d.js

feral aspen
#

There is two solutions:

#

A.

lyric mountain
#

here's how I do it (JDA), just to show what I'm trying to say

#

in my case I do it async because I don't need for all shards to be ready

#

if I had to I'd just remove the executor

feral aspen
#

I can either use manager.broadcast and add a process.on('message', async message => {}; to get the code and continue with the ready event, or just wait for all shards to spawn (which I'm not sure how).

lyric mountain
wheat mesa
#

<ShardManager>.spawn is a promise

feral aspen
#

Yes, I'm aware.

wheat mesa
#

I was going to say await it but I suppose that doesn't solve anything really

feral aspen
#

Yeah, shards would still be spawning.

#

My only issue is to how to await all shards to be ready before continuing.

cinder patio
#

why do you want that in the first place

feral aspen
#

I have two shards.

cinder patio
#

and?

feral aspen
#

In the ready event, I have broadcastEval.

#

I can't execute it without having all shards ready.

cinder patio
#

what does the broadcastEval do

feral aspen
#

Logs server count, member count, and channel count.

cinder patio
#

why not do that from the manager

feral aspen
#

Cause the shards are not ready.

cinder patio
#

await the spawn call

feral aspen
#

That did nothing.

cinder patio
#

it should resolve after all the shards are spawned

feral aspen
#

I mean, I should be adding a self-calling function, correct?

cinder patio
#

No I mean... log the server / member / channel count in your sharding manager code, not in each individual shard or the first shard

feral aspen
#

However, I'm using broadcastEval?

cinder patio
#

...so what

feral aspen
#

How am I supposed to achieve so?

cinder patio
#
(async () => {
const shards = await manager.spawn({delay: 10000, timeout: -1});
let guildCount = 0;
for (const [, shard] of shards) {
   guildCount += shard.getClientValue("guilds.cache.size");
   // other...
}
console.log(`Guilds: ${guildCount}`);
})();
#

try this

feral aspen
#

Yes, however, I'm using bot as in Discord.Client()?

#

I cannot use it while I'm spawning shards first.

cinder patio
#

what

#

that code gets executed after the shards are spawned

feral aspen
#

I'm aware, you know how shard.js is executed then index.js?

#
let activities = [`${(await bot.shard.fetchClientValues('guilds.cache.size').then(total => total.reduce((a, b) => a + b, 0))).toLocaleString()} servers!`, `${(await bot.shard.fetchClientValues('users.cache.size').then(total => total.reduce((a, b) => a + b, 0))).toLocaleString()} members!`, `wefwefwef`], i = 0;

setInterval(() => bot.user.setActivity(`${activities[i++ % activities.length]} || /help`, { type: 'PLAYING' }), 60000);
#

I have something like thise code.

#

I cannot put it in the shard.js file since I have bot.user?

cinder patio
#

I don't understand what you're asking just try the code I sent you

#

that shouldn't matter

feral aspen
#

It errors.

#

bot is undefined.

cinder patio
#

The code I sent not the code you sent

#

my code doesn't use bot anywhere

winged linden
#

Another question for the day😹

My system is a little complex so i am running into some problems tdy

Any idea how i can check if a user has a specific role in a specific server
Not by using message.guild.roles.find(role => role.id === "id"); //Find member
As i have to search for the role & user without a command

feral aspen
#

@cinder patio, here's a solution that I may want help in, I add in my ready.js file // process.on('message', async message => {}; and checking if message is equal to the code of something like manager.broadcast('allshardsready'), if you got what I mean.

#

Would that be possible?

#

If it is, then it would execute the code in the ready.js file, otherwise, wait for the shards to be fully ready.

wheat mesa
#

fetch the guild and the user in the guild, compare roles

cinder patio
#

I don't know if spawns just waits for the processes to spawn or if it waits for each shard to become ready

#

try it

feral aspen
#

Not sure how I'm supposed to check with message.

cinder patio
#

use bot.shard.on("message"

feral aspen
#

Ahh.

#

What? It's not a function.

feral aspen
feral aspen
earnest phoenix
#

How to change the color of the button?

lament rock
#

You can't

#

there are only a few styles

earnest phoenix
#

Tell me that few styles

cinder patio
feral aspen
lament rock
cinder patio
#

if it works then why are you asking me if it's correct

feral aspen
#

No, I just realised it now, that's why.

#

The only issue I'm facing right now is getting all shards ready, and I'm currently trying your code.

feral aspen
cinder patio
#

huh? is it working

feral aspen
#

It's running, moment.

cinder patio
#

we're not skipping anything

feral aspen
#

[, shard], what does this mean?

cinder patio
#

we're looping through a collection

#

shard is the value

#

we're skipping the key

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 => {
        console.log(`[SHARDS]: Launched shard ${shard.id}`);
    });
    
    const shards = await manager.spawn({ delay: 10000, timeout: -1 });
    for (const [, shard] of shards) {
        shard.send('allReady')
    }
})();
#

Fair enough, here's what I did, but ready.js isn't firing.

#

Is it because of shard.send()? Do I put manager.broadcast('allReady'); instead.

cinder patio
#

no, process.on probably doesn't work

#

or

#

add this in the loop

console.log(shard.ready);
#

and tell me what it says

winged linden
feral aspen
#

true, false.

feral aspen
winged linden
wheat mesa
#

fetch them

#

with the id

#

client.guilds.fetch('id')

winged linden
#

Yeah i did that

feral aspen
wheat mesa
#

and then that ^

winged linden
#

Okay let me try

wheat mesa
#

except not .cache.fetch() just .fetch()

#

Because that's not a thing

winged linden
#

Okay

winged linden
cinder patio
#

okay then do this

    let ready = 0;
    manager.on('shardCreate', shard => {
        if (shard.ready) ready += 1;
        else {
           shard.on("ready", () => {
              ready += 1;
              if (ready === manager.totalShards) {
                    for (const [, shard] of manager.shards) shard.send("allReady");
               }
           });
        }
    });
feral aspen
cinder patio
#

for now yes

#

try it

feral aspen
#

Alright, I'm launching the bot.

wheat mesa
feral aspen
# cinder patio try it
(async () => {
    require('dotenv').config();
    const { ShardingManager } = require('discord.js');
    const manager = new ShardingManager('./src/index.js', { token: process.env.TOKEN, totalShards: 2 });

    let ready = 0;
    
    manager.on('shardCreate', shard => {
        if (shard.ready) ready += 1;
        else {
            shard.on('ready', () => {
                ready += 1;
                if (ready === manager.totalShards) {
                    for (const [, shard] of manager.shards) shard.send("allReady");
                    console.log(ready);
                };
            });
        };
        console.log(`[SHARDS]: Launched shard ${shard.id}`);
    });
    
    await manager.spawn({ delay: 10000, timeout: -1 });
})();
#

This is what I exactly did, and still, nothing logs.

cinder patio
feral aspen
#

TypeError: Cannot read properties of null (reading 'on')

cinder patio
#

ok switch back to process.on

#

and add a console.log(ready) in the shard ready event

feral aspen
#

Ah, wait.

cinder patio
#

only 1?

feral aspen
#

Same code but:

shard.on('ready', () => {
    ready += 1;
    if (ready === manager.totalShards) {
        for (const [, shard] of manager.shards) shard.send("allReady");
    };
    console.log(ready);
});
#

Yup, for some weird reason.

cinder patio
#

but did you wait 10 seconds

feral aspen
feral aspen
feral aspen
#

It logs before shard 1 spawns.

cinder patio
#

did you wait

feral aspen
#

Yup, reaching a minute now.

cinder patio
#

so shard 1 is not emitting ready for whatever reason

feral aspen
#

Yes.

cinder patio
#

well

#

I don't know then

feral aspen
#

@cinder patio , it worked.

#
[SHARDS]: Launched shard 0
1
[SHARDS]: Launched shard 1
2
Shard ID 1 [...]
Shard ID 0 [...]
cinder patio
#

so you had to wait

feral aspen
#

Nope, I restarted and it works.

cinder patio
#

oh

#

weird

feral aspen
#

However, I'm so confused why my early code didn't work?

#

I was checking for the exact same thing?

cinder patio
#

so everything works now?

#

show it

feral aspen
#

I don't even remember the old one, but let me re-create it.

cinder patio
#

didn't you send it in here already

feral aspen
# cinder patio didn't you send it in here already
(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(`[SHARDS]: Launched shard ${shard.id}`);
    });
    
    await manager.spawn({ delay: 10000, timeout: -1 });
})();
#

Here, I rewrote the code.

#

This is what you told me and this is also my code, I merged it.

#

And it works. 👍

feral aspen
# cinder patio didn't you send it in here already

Alright, code works extremely well, just last thing. I have my ready.js file, and you know, depending on how many shards are spawned, it will equal to how many times the code will be executed inside the ready.js event. Is there a way I could check the amount of shards being spawned?

#

As in { token: process.env.TOKEN, totalShards: 2 });.

cinder patio
#

bot.shard.count?

feral aspen
#

It will straight equal to totalShards:, right?

cinder patio
#

yeah

feral aspen
#

Aha.

#

Indeed, I'm at 9 servers, right now.

#

Jk, 1.1k and the bot is barely handling.

#

Indeed, however, what I did now is a fix, I fixed not being able to spawn multiple shards, that's all.

boreal iron
#

Slash commands aren’t different to common commands except that you have to specify a name and description for it.
Once you wanna setup command options things are actually quite different as those options need to be registered and you have to choose from a list of available option types

#

But your in code argument parsing and handling isn’t really something you can transform to slash command options automatically

#

The earlier getting into it the better

#

Who knows if the message content intent really comes this fall or will be delayed once again

#

So be prepared

wheat mesa
#

I think they're sticking to the deadline at this point unless something goes wrong for some reason

#

I think the April 2022 thing was to make people think they HAD to switch over by then, but then they extended it for the few who were too lazy to do it in that timeframe

#

So that people don't get screwed and they also have more time to review message intent applications

eternal osprey
#

hey guys how do i re-register all slash cmds?

#

Because i changed some file names, thus some commands in the handler

#

now it;s throwing: DiscordAPIError[50035]: Invalid Form Body
0.options[0].name[STRING_TYPE_REGEX]: String value did not match validation regex.

wheat mesa
#

It means that some of your names are invalid

#

You should probably not have your command names rely on the file name

wheat mesa
eternal osprey
#

I see, i've fixed it!

#

They had a space in them.

#

the transition to v13 is really hard, but this server seems to be helping me a lot. Really grateful!

wheat mesa
#

Good to hear you're porting to v13

earnest phoenix
#

And v14 is coming out soon

carmine summit
#

Is it possible to remove a fulfilled promise from an array to run promise.any again to find the 2nd fastest array? Im using .filter but cant get it to work

boreal iron
quartz kindle
carmine summit
#

I cant, when i log something like promise.config, it returns promise instead of promise.config

quartz kindle
#

you need to add a way to identify them

#

for example ```js
const index = array.length;
const promise = something().then(result => ({ result, index }))
array.push(promise);

#

then you can do ```js
const { result, index } = await Promise.any(array);
array.splice(index, 1);

crystal wigeon
#

About 10k+ , so there are 10 shards

#

I’m still facing the issue btw

#

Apparently it’s not working in some servers but works in others

#

Is there anything I can do to figure out what the issue is

#

I don’t see any crash errors in my error logs

#

Very weird

proven escarp
#

Anyone knows how to add support for syntax highlighting in floating windows like fzf in vim/neovim?

#

Not really development but still

crystal wigeon
#

Bump

#

It’s been a problem for days now

wheat mesa
#

misty realizing he’s dumb moment

carmine summit
#

Oh I understand noww

sharp geyser
crystal wigeon
#

Someone help me pls

sharp geyser
#

No one can help if they don't know your issue

dry imp
crystal wigeon
#

And works on others

#

I’ve checked for crash logs or any other errors but nothing shows up

#

It doesn’t make sense tbh

carmine summit
#

So promise.any returns the promise that is fulfilled in all levels. Not just only on the first level?

boreal iron
dry imp
#

no i've called 911

boreal iron
#

enjoy your jail time and don’t pick up the soap

fast bronze
#

does anybody know how to setup a vps for replit and glitch ( like videos ? )

feral aspen
#

Why this? I just realised.

#

If I have two shards and I log bot.shard.broadcastEval(client => console.log(client.shard.ids)), it does [ 0 ] then [ 0 ] [ 1 ]

ancient nova
sacred aurora
#

is there a workaround to log if a bot delete a message?
since it didn't appear in the audit log, how can i get the bot that delete the message

ancient nova
#

wot?

#

just use the messageDelete event? I assume that's what you want

sacred aurora
#

yes but how can i get the bot that deleted the message

ancient nova
#

when you grab the message callback just do message.author

sacred aurora
#

what i'm trying to get is who delete the mesage

ancient nova
feral aspen
#

Nevermind, I figured it out.

sacred aurora
#

Do note these are impossible at the time of writing this and will return 'Unknown':

• See which bot deleted a message as Discord does not log message deletions for bots
• See if the author deleted their own message (Discord does not log this either)
• 100% determine if the message deleted matches the fetched audit log due to Discord not including the message ID in audit logs

oof i see this

ancient nova
#

oh well then I guess it's impossible

feral aspen
#

I have this broadcastEval() code, however:

bot.shard.broadcastEval(client => console.log('Shard ID', client.shard.ids[0], client.guilds.cache.map(guild => guild.name)));

When it comes to the results of the guild names, I can see, supposedly, guild called ABC in shard 0 and shard 1? What does this mean and is there something I should be doing?

crystal wigeon
#

EMJ_jerrycri pls help

#

Tim

#

google fued

#

anyone

pale vessel
#

Log the debug event and see if something's amiss

feral aspen
ancient nova
#

is anyone here good at moddeling? 😭

pale vessel
sudden geyser
#

Modeling what—bananas?

pale vessel
#

I have a 🍌 you could use as a model

crystal wigeon
#

I’ve got error logs on crash and process exist

pale vessel
#

Yeah, do that

crystal wigeon
#

Exit

pale vessel
#

Debug event should show some kind of info at least

opaque acorn
#

How can I link local images into embeds

#

?

ancient nova
crystal wigeon
ancient nova
#

but

crystal wigeon
ancient nova
#

also

#

modelling liminal spaces

lyric mountain
#

like, imagine we have a ballot box and 5 people, each will add a ticket to it

#

first person will see the box empty and say "there are 0 tickets"

#

the second will see a single ticket and say "there's 1 ticket"

#

the third "there're 2 tickets"

#

and so on

#

async operations dont know other async operations exist, unless you make them

feral aspen
#

Ahh, fair enough.

feral aspen
quartz kindle
#

where you do new Client(...)

feral aspen
#
const bot = new Client({ allowedMentions: { parse: ['everyone', 'roles', 'users'], }, partials: ['MESSAGE', 'CHANNEL', 'GUILD_MEMBER', 'GUILD_SCHEDULED_EVENT', 'REACTION', 'USER'], intents });```
quartz kindle
#

show your sharding manager file again

feral aspen
#

Moment.

#

totalShards: 2.

quartz kindle
#

from inside the client file, console.log(process.env.SHARDS, process.env.SHARD_COUNT)

feral aspen
#

0 2.

#

1 2

carmine summit
#

await Promise.any()

How do I return null if this code returns [AggregateError: All promises were rejected]
try{}catch{} doesn't seem to work
.catch() seem to work but, how can I return null?

quartz kindle
#

now console.log(client.shard.ids)

feral aspen
#
console.log(process.env.SHARDS, process.env.SHARD_COUNT);
console.log(bot.shard.ids);
[SHARDS]: Launched shard 0
0 2
[ 0 ]
[SHARDS]: Launched shard 1
1 2
[ 1 ]
quartz kindle
#

everything looks fine

carmine summit
feral aspen
#

Alright, lemme reproduce the issue, moment.

quartz kindle
feral aspen
#

No, it is, I just asked it wrong. 👍

#

I'll attempt to launch 8 shards with 9 servers.

feral aspen
# quartz kindle i dont see how this ^ would be possible

Alright, look at this:

bot.shard.broadcastEval(client => console.log('Shard ID', client.shard.ids[0], client.guilds.cache.map(guild => guild.name)));
``` ```js
Shard ID 4 [ "Alright, Don't Ask" ]
Shard ID 5 [ "Alright, Don't Ask" ]
Shard ID 3 [ "Alright, Don't Ask" ]
#

The same server in 3 shards?

cinder patio
#

well you're not supposed to shard with 9 guilds only, that's what's probably going on

quartz kindle
#

console.log the same stuff as before

feral aspen
#

Alright, moment.

#
[SHARDS]: Launched shard 0
0 8
[ 0 ]
[SHARDS]: Launched shard 1
1 8
[ 1 ]
[SHARDS]: Launched shard 2
2 8
[ 2 ]
... and so on
quartz kindle
#

log the guild ids

feral aspen
#

Yup, it logs the same IDs.

quartz kindle
#

youre sure youre not fetching that guild somewhere?

feral aspen
#

Where would I want to be fetching a guild?

#

And no, I'm not.

#

OH, wait, hold on.

quartz kindle
#

do this ```js
bot.on("raw", p => {
if(p.t === "GUILD_CREATE") {
console.log(p.d.name, p.d.id);
}
});

feral aspen
#

I was.

quartz kindle
#

that should be it then

feral aspen
#

Yup, it now works. However, how will I be able to get the guild ID and post the commands?

#

Do I use bot.guilds.cache.get instead or?

#

Since I'm using (await bot.guilds.fetch('737011108954505267')).commands.set(commandsArray.flat());.

quartz kindle
#

commands are a one time thing, it should not be set on every run

feral aspen
#

I realised.

quartz kindle
#

put the command setting in a separate script, and run it only when you change something

#

you also dont need to login to do that

feral aspen
#

Also, when every shard gets ready, my slash command handler file runs.

quartz kindle
#

thats fine

feral aspen
#

Even events.

quartz kindle
#

thats not an issue

#

just the commands.set() that should not be there

feral aspen
#

Supposedly, I have 4 shards.

#

We're executing the above code 4 times.

quartz kindle
#

yes, thats not a problem

feral aspen
#

Is it normal?

quartz kindle
#

yes

feral aspen
#

I think what I should only remove is slashcommands.

quartz kindle
#

that why you should not have any code in there that is not supposed to run multiple times, like creating slash commands

feral aspen
#

What else should not be ran multiple times?

quartz kindle
#

running a webserver/dashboard for example

feral aspen
quartz kindle
#

you remove it from there

carmine summit
#

how can I retry the function without it fulfilling?

async function proxy(q){
  //stuff
  if (!fastest) {
    return setTimeout(async () => {
      console.log("Retrying: All Rejected");
      return await proxy(q);
    }, 1000);
  }
}
feral aspen
#

When would I be able to run it.

pine nova
feral aspen
#

It's not like I can do something like node ./src/handlers/slashcommand.js && node ./src/shard.js. How would I be able to do it?

quartz kindle
quartz kindle
#

im not talking about the handlers

#

im talking about the code that creates/sets a new command

#

ie sends the command information to discord

#

you only need to run that code when you create a new command or modify an existing command

#

it has nothing to do with the handlers

#

the handlers only receive the command and do something with it

#

keep all the handlers like they are, just remove the code that creates/sets the commands

#

when you need to create a new command or update an existing command, you create the code for that in a separate file and run that file separately one time only

#

and then update the handlers accordingly and restart the bot

feral aspen
#

Basically, I just add the .set() in another file and run it when needed.

quartz kindle
#

you can use this for example

#

you dont need a discord Client to create commands

feral aspen
quartz kindle
#

what do you need the guild for?

#

you dont need to fetch a guild to set commands

feral aspen
#

I'm setting the commands to a specific guild.

quartz kindle
#

if you still want to use a Client, then client.application.commands.set(commands, guildID)

feral aspen
#

Yeah, but aren't all guilds cached?

#

If I go to a server on Shard ID 0 and type what!eval bot.guilds.cache.map(x => x.name);, it returns a different set than a server on Shard ID 1.

quartz kindle
#

each shard has its own cache

crystal wigeon
#

Tim help meeee

low moat
#

i literally have no context about this but it just pops up every few minutes (im assuming its someone executing a command which is broken but i dont use discord buttons for this bot so i am so confused as to what its talking about) any ideas?

crystal wigeon
#

@quartz kindle sorry for ping, so like my bot is going offline in some servers but it’s working fine in others, it’s in 10k+ servers and there are 11 shards I’m not sure what’s happening. I checked logs there are no crash logs and I can also see 11 shards running EMJ_pepecry

#

Idk what to do

quartz kindle
low moat
crystal wigeon
#

When I reboot the shards are fine

#

For like 6 - 7 hours

quartz kindle
quartz kindle
#

you can hide the messages about heartbeats, since they are spammy

regal lion
#

Hello everyone,
I tried to verify bot but it doesn't work.
What is the problem?

When the bot is started with the /start command... it creates two channels, one config and one join channel. The config channel is locked for the bot itself and the admin, so when I create a channel I add the condition to enter the channel you need to have bot permission or higher.
I find bot permission like this:
const myRoleId = guild.roles.cache.find(
(role) => role.name === process.env.BOT_ROLE_NAME
).id;

But for some reason on server they are testing, I can not find id of my bot role. (it's undefined)
Can someone help, thanks 🙂

quartz kindle
#

is the bot role created automatically? did you setup its permissions in the invite url?

#

also, make sure your bot does respond with something useful in case the role is not found, instead of just crashing or becoming unresponsive

#

proper error messages and instructions are important for the bot to get verified

velvet scarab
#

how i can make these styles?

rugged dawn
#

-htmldesc

gilded plankBOT
rugged dawn
#

visit the hyperlink and refer how to do that, if you need help further with that this channel is always an option

quick ridge
#

FetchError: maximum redirect reached at: https://www.instagram.com/miafitz/?__a=1&__d=dis i get this error when i try to fetch this url

#

but when I open the site in browser it outputs correctly

quartz kindle
#

works fine for me

wheat mesa
#

do your own projects and don't follow tutorials

#

you'll be stuck in tutorial hell and you won't learn much from them

sick agate
#

idk your ideas

wheat mesa
#

^

lyric mountain
#

"in 3 hours" to understando how to make a hello world right?

#

in no fckin way u can understand js in 3 hours

#

well, start with a hello world program

#

then move on to a calculator

#

during the tutorial?

#

then do again

#

this time without a tutorial

wheat mesa
#

Do not fall into tutorial hell

wooden ember
#

bruh i just yolo-ed into making a discord bot with no knowledge of js at all

#

worked kinda alright

wheat mesa
lyric mountain
#

try doing everything again but without the tuto

wheat mesa
#

Make your own projects

#

Without tutorials

#

I'll give you some basic questions then

#

What is a string?

wooden ember
wheat mesa
#

And how do you make a variable with the value of "Hello world!" in javascript?

#

No

wooden ember
#

bruh

wheat mesa
#

That is not what I asked

random horizon
#

how to make a vote system?

lyric mountain
#

WRONG

wheat mesa
#

And what different ways can you make variables in javascript?

random horizon
#

someone voted and receive moneeeey

lyric mountain
#

oh goddamn that's wrong

#

ur whole project is crashing for no visible reason now

wheat mesa
#

And what does const do?

#

(Compared to the others)

#

What does immutable mean

lyric mountain
#

u pushed to production, 34 emails from clients saying their server is dead

#

why? because var

wheat mesa
#

Do not use var

lyric mountain
#

var is the big nono

wheat mesa
#

Unless you know exactly what you're doing

wooden ember
#

why?

wheat mesa
#

Even then it should be avoided

wooden ember
#

i dont use it i just use let but idk why its bad

wheat mesa
#

Because it hoists to the top of the function scope

wooden ember
#

meaning?

#

yeah

lyric mountain
wheat mesa
#

So ```js
let b = a + 5;
var a = 2;

#

But it will not output what you think it does

wooden ember
#

oh i see

lyric mountain
#

this gets way worse when you use libraries that also use var

wheat mesa
#

b will be NaN

wooden ember
#

lol

lyric mountain
#

token leak buddy

wooden ember
#

big funny

lyric mountain
#

it wasn't fire

random horizon
#

❌ Function $httpGet returned an error: HTTP GET returned an error: Get "https://normal-api.ml/topgg/hasvoted?bot=970724325491638303&user=905524360436125746&token=": x509: certificate is valid for *.parkingcrew.net, parkingcrew.net, not normal-api.ml

wooden ember
#

huh?

#

ah

lyric mountain
#

hello world -> calculator -> snake is my go-to project chain when learning a new language

#

try it

wheat mesa
#

That's a pretty good method

stable eagle
#

Snake?

lyric mountain
#

ye

wooden ember
#

yeah

#

the nokia one

#

with code lol

lyric mountain
#

it's pretty easy to make even on CLI-only

wheat mesa
#

Another thing you could make is like a "school" where you have a student class, teacher class, class class, school class, etc. But I usually use that method for more object-oriented languages

lyric mountain
#

uses a ton of recursion and arrays

#

docs + ctrl + space

wheat mesa
#

Because you need to learn on your own by experimenting

wooden ember
#

object orientated stiff bends my brain in ways i dont like

wheat mesa
#

Following tutorials is only going to assure that you know less

wheat mesa
#

It doesn't change the fact that somebody else told you exactly how to write that code

lyric mountain
#

u exceeded ur allowed bandwidth basically

wheat mesa
#

You have to experiment on your own to learn

wooden ember
#

rip code of github anbd mash it with other code from github and then try and work out why nothings working

wheat mesa
wooden ember
#

lol

wheat mesa
#

He was not serious

wooden ember
#

i mean its not about anything

wheat mesa
#

Please please please do not copy code off of github if you're seriously wanting to learn anything

#

We told you like 15 times

lyric mountain
#

depending on ur IDE u can also use ctrl + Q to read the docs without having to open a new window

wheat mesa
#

Make your own project, try things out

lyric mountain
#

and of course, use an IDE, no need to be hardcore and code in np++

wheat mesa
#

If you are struggling with the basics, go back to some basic syntax tutorials online and try to apply that to your own project

wooden ember
#

i mean i copyed methods and commands of github before but never riped the whole thing in one cuz thats just uninventive

wheat mesa
#

The only times I copy off of github is when I'm too lazy to write something tedious and I understand the code

lyric mountain
#

ah yes, a thing that's very important regarding programming: do not try to learn the words, try to learn the "why"s and "how"s

wooden ember
#

half the stuff i find interesting is outdated anyway so i gotta write it from scratch anyway

wheat mesa
#

I've had a few times where I look at somebody's github, then asked them what their thought process was before I copy it/modify it to my own project

lyric mountain
#

it's not your job to write, it's your job to know where to write

wheat mesa
#

For example, I was asking @lyric mountain about reflection for a forge mod I was writing, and looking at how he did it in his github for his discord bot

wooden ember
#

like the command i made to play my cassette player over discord was based on some code snipit from 2016 lol

wheat mesa
#

That's when github is really handy, to figure things out by asking yourself "Why did this person write this the way they did?"

wooden ember
#

was compleatly borked

wooden ember
#

good to see the other ways of writing the same thing

lyric mountain
wheat mesa
#

Exactly

lyric mountain
#

don't see the code, see how they did and why they did

wheat mesa
#

That small part of your reflection snippet helped a great deal with understanding how reflection works

#

Something that I had previously never done with Java before

lyric mountain
#

tbh I rewrote most of it KEKW

#

when I created my new command handler

wheat mesa
#

Fair, I never ended up being able to use it anyways because the forge discord is toxic asf and half the people in there are "don't use old version" dickheads

lyric mountain
#

but good that it worked for u, reflections are pretty easy once you get the concept

wooden ember
#

reminds me, i gotta make a command handeler for my test bot soon

#

its got almost 20 commands lol

wheat mesa
#

But I did end up using reflection in a similar way for my C# recursive descent parser for math expressions

#

KEKW very scuffed though

#

But it's fine, the comment I left explains it all

lyric mountain
#

lmao

#

I had to rewrite to include my custom syntax language

#

together with its parser

wheat mesa
#

Oh yeah that's right you wrote your own parser for that

#

Nice

lyric mountain
#

but really, I love how reflections allow finding code anywhere in the project

#

instead of having to declare paths and classes in a collection

#

so back to this, js barely has datatypes, no need to worry about it too much (for now)

wheat mesa
#

Meh, I disagree on the worrying about it part

#

You need to know types

#

Before you can go typeless

#

😉

proven lantern
#

types = training wheels

wheat mesa
#

Wrong

proven lantern
#

js isn't a good language to start with for that reason

wheat mesa
#

Types make your life easier

proven lantern
#

training wheels do too, until you know what your doing. then they get in the way

wheat mesa
#

Everything still has an underlying type regardless of how you see it

lyric mountain
#

never had types getting in my way, usually it's the opposite since I can know what a value is by simply hovering on it

wheat mesa
#

Yeah same

lyric mountain
#

also makes life easier for the compiler

wheat mesa
#

I personally like typescript because it guarantees that you're not responsible for making sure the types are correct when passed to your functions and other things

proven lantern
#

reflection is used to get around the type system

wheat mesa
#

Not really no

#

Reflection bypasses the type system but it's because you may need information at runtime that is not available to you before runtime

#

Not because you want to make your code unsafe on purpose

lyric mountain
#

reflection is basically doing runtime operations

#

instead of traditional compile-time

#

like injecting values, changing structure, attaching new classes, getting declarations, etc

wheat mesa
#

For example in Java reflection is really useful for doing operations with classes with certain annotations and such

lyric mountain
#

funny enough u can get the variable's name with that

proven lantern
#

i remember having to use reflection to write a unit test for a private method once

#

such a mess

wheat mesa
#

Pretty sure there's a lot of testing frameworks that can do that for you but yeah

#

or just make it public for testing purposes

proven lantern
#

or make it protected and put the unit test in the same package

wheat mesa
#

That's not what protected does

proven lantern
#

but the method should be private

wheat mesa
#

You're thinking of no access modifier

#

(I assume we're talking about Java here)

proven lantern
#

yeah

#

i thought protected meant other stuff in the same package could access

wheat mesa
#

No

#

protected means classes that inherit from that class can access it

#

if you put no access specifier on a class member in java it automatically becomes package access

proven lantern
#

isn't that protected?

wheat mesa
#

No

#

It's a special modifier that doesn't have a keyword for it

proven lantern
#

i found it. it's called package private

wheat mesa
#
class MyClass {
  protected int myInt = 5;
  int myPackageInt = 5;
}

class MySubClassNotInSamePackage extends MyClass {
  // Can access myInt, but not myPackageInt
}

class SomeOtherClassInSamePackage {
  // Can access myPackageInt, but not myInt
}
wheat mesa
#

Interesting

proven lantern
#

no, that's just what it's called

#

default scope

wheat mesa
#

Oh

#

Yeah

proven lantern
#

the protected keyword is an access modifier for method and variable of a class. When a method or a variable is marked as protected, it can be accessed from: Within the enclosing class. Other classes in the same package as the enclosing class.
Is this part true for protected?
Other classes in the same package as the enclosing class.

wheat mesa
#

To my knowledge that's not correct

#

I can test it rq though

proven lantern
wheat mesa
#

Ok apparently that works

#

In my CS class we were taught that doesn't work

#

But apparently it does

proven lantern
#

maybe java change it

wheat mesa
#

We did use a pretty old java version

#

I think Java 8

lyric mountain
#

protected is broader than package-private

wheat mesa
#

I think we just barely had the stream API so I'm pretty confident it was 8

lyric mountain
#

private < package < protected < public

proven lantern
#

package being the default right?

lyric mountain
#

ye

#

u cant really type package cuz that's for another thing

proven lantern
#

package doesn't allow other classes in the same package to access?

lyric mountain
#

it does

#

but only within the same package

proven lantern
#

what the diff between package and protected?

lyric mountain
#

protected also allows subclasses

#

if u somehow extended a protected class from another package, it'd be able to access its methods

#

but since u can't (at least during compile-time), it works the same as package

proven lantern
#

ah, so it's only for runtime stuff? can't reflection bypass that all anyways?

lyric mountain
#

reflection doesn't care about scopes at all

proven lantern
#

lol

lyric mountain
#

u can access anything anytime, just need to setAccessible(true)

#

so let's say both package and protected are technically the same but conceptually different

proven lantern
#

interesting

lyric mountain
#

then there are final and sealed classes lmao

#

but that's something I didn't understand fully yet

proven lantern
#

final is my favorite keyword in java

lyric mountain
#

final int countdown

#

it's the final countdown

proven lantern
#

that song did pop into my head

#

not going to lie

lyric mountain
#

it's as rooted as rickroll into human history

#

types

#

not really

#

whatever runs the code will usually add it anyway during "compilation"

wheat mesa
#

You should probably add them anyways, it’s better code style

lyric mountain
#

oh, also remember that == (equals with typecasting) and === (equals)

wheat mesa
#

What

#

You do not need a domain to learn javascript

proven lantern
#

watch out for stuff like this. js function whoops() { return { hello: "world" } }

function whoops() {
    return {
        hello: "world"
    }
}

these two functions do different things

wheat mesa
#

^

#

This is why you should add semicolons on your own

lyric mountain
#

*sips coffee* js moment

wheat mesa
#

So you can be more explicit in what you intend

#

(Or just use a linter that does it for you, like eslint or prettier)

#

Js is backend

lyric mountain
#

both no?

#

node is back

#

ah wait

wheat mesa
#

I mean you could argue that it’s both but it’s a programming language designed for logic at its core

lyric mountain
#

yeah it's backend

proven lantern
wheat mesa
#

Yes but the linters will add semicolons for you

#

So you can more easily see that you’re making a mistake

lyric mountain
#

was thinking abt webpages, but that's technically html referencing js

proven lantern
#

gotcha

wheat mesa
#

Thought you wanted to learn js

lyric mountain
#

js doesn't need a domain

wheat mesa
#

Personally I don’t do any python

#

I tend to stay away from hot messes like that

lyric mountain
#

ye

wheat mesa
#

You don’t need a website to learn js either

#

Sells domain names

lyric mountain
#

domains are just for aesthetics

#

(and ssl)

#

js is just like any other language, u get something to execute it and simply run

#

usually u get node

proven lantern
#

your computer is the host

wheat mesa
#

Js is most commonly found in the backends of websites, but the language’s use extends far beyond the scope of the web

lyric mountain
#

to make something public

wheat mesa
#

Because they want to host their website online to the public

proven lantern
#

you dont want to point a domain to your ip most likely

lyric mountain
#

you wouldn't want to use your IP as the address

wheat mesa
#

I think you’re losing sight of what js is lol

#

Javascript is a programming language

#

You can use it for many purposes

#

One of those common purposes is websites

#

But there are many more

#

You can make websites “public” by buying a domain name and pointing it to a host (such as a VPS) that serves all the content of your website to the client

proven lantern
#

use google domains

wheat mesa
#

Yes, but I wouldn’t recommend purchasing anything until you already have your project ready to be put online

#

Since domain names are usually a yearly/monthly cost

#

But yeah there’s a lot of different sites

#

Usually they use a web framework of some sort, like React.js

proven lantern
wheat mesa
#

But you can also do it with regular html, css, and js

#

Yes

wheat mesa
#

React is frontend but also backend in a way

proven lantern
#

use sveltekit

wheat mesa
#

Yeah that’s what I’m planning on

#

Svelte is a templating compiler isn’t it? Never used it before

#

Yeah

lyric mountain
#

u can do anything with any programming lang really, the sky (and the computer) is the limit

#

nope

proven lantern
wheat mesa
#

Depends on what you want to do in the future

#

If you want to develop websites for a living, then definitely

lyric mountain
#

u can, which is what people call frontend devs (or fullstack when both back and front)

wheat mesa
#

If you want to stick with backend stuff (Which in my opinion is where the real fun happens), then not really

#

In terms of employment? Not really. You won’t be earning much if anything from a discord bot

lyric mountain
#

oh boy

#

many

wheat mesa
#

A ton

#

There’s so many different specialties

lyric mountain
#

look around, there's a chance that there's at least one thing that involves programming in your sight

#

the lamp? yep, programming (the power grid)

wheat mesa
#

Cybersecurity, lang dev, game dev, even rest api dev is pretty much its own thing now

#

So many options to choose from

#

Those are the specialties though

lyric mountain
#

programming is the closest you get to being a god (in virtual world)

wheat mesa
#

You don’t have to learn all about them

#

You can dive so far into one specialty and be a master of it

#

While not needing to know a ton about all the other fields

#

Probably just general backend development

#

I wouldn’t really put them in a category

lyric mountain
#

it's really hard to comprehend how vast programming is

wheat mesa
#

Usually it’s a good idea to dive into a few different fields and find something you like, and then master that one thing and learn a bit about all the other fields

#

And then master others if you find you enjoy them as well

lyric mountain
#

I had, but scrapped it because I didn't like how it was done

wheat mesa
#

There’s too much to learn for one lifetime however

lyric mountain
#

can go from a couple dollars to thousands of dollars

wheat mesa
#

Nothing. I’m just a student lol

lyric mountain
#

java

wheat mesa
#

My dream job would probably be to work on Roslyn

lyric mountain
#

no, just java

wheat mesa
#

Or maybe even work on a language with rust

lyric mountain
#

that was long ago, doesn't mean much besides that I applied for verification at the beginning

wheat mesa
#

But lang dev is definitely where I think I’m heading

lyric mountain
#

that's a hard question

#

idk, maybe the fact that no matter how much knowledge I get there's always more to learn

#

I hate hitting a cap

#

I guess

wheat mesa
#

Game dev also sounds kinda fun if I didn’t already know that most game companies suck to work for

#

Unity is pretty cool

#

Unreal is more beefy and scarier

lyric mountain
#

I wanted to do professional game dev but...c++

wheat mesa
#

A lot of games are also written in C# to be fair

lyric mountain
#

c++? ohh yeah it is

wheat mesa
#

Most AAA games use C++ and a custom engine though

#

Python is slow

#

Especially in the world of game dev

#

Where things need to be fast

lyric mountain
#

python wasnt made for complex tasks really, it excels at doing small or repetitive tasks

wheat mesa
#

C++ itself isn’t necessarily THAT hard, but debugging it is a nightmare

lyric mountain
#

but u can do if u want, pretty much all VNs are made in python too

wheat mesa
#

Plenty

#

Not that I know of

#

I’m sure there’s plenty of games out there made entirely in python, but it’s probably not a very complex game to be fair

lyric mountain
#

visual novels

wheat mesa
#

There’s some more complex stuff

lyric mountain
#

idk other examples of games made with python

wheat mesa
#

Unity is a good compromise between language complexity and speed, since it uses C# for the scripting

#

You can use any language for game dev

#

Some excel more than others at it though

#

C++ is the most popular game development language of choice

#

C# is probably 2nd

#

C++ is low level. C++ requires you to manage memory on your own, and has things like pointers and references. C# on the other hand is what’s called a garbage collected language, which basically means you don’t have to worry about manually managing memory. C# has references and pointers, but you don’t ever really directly work with them (aside from the occasional ref keyword) unless you’re doing some wonky stuff.

#

C++ is also very multi paradigm, but C# is mostly object oriented

#

Depends on what you want to do with it

#

C# has less complexity, but C++ is faster to run

#

If you need really really fast performance, C++ is the way to go

#

Definitely not C++

#

C++ will chew you up and spit you out; it does not hold your hand pretty much at all

#

After javascript I’d recommend probably Java or C#

#

Java and C# are very very similar

#

Java is pretty much C# with some differences

#

They’re probably relatively similar in terms of speed

pine nova
wheat mesa
#

Java is certainly the less complex option between the two

proven escarp
#

cause java came before

#

c# is a ripoff of java

wheat mesa
#

C# is like Java++

#

Better Java imo

#

But more complex

proven escarp
#

wtf

wheat mesa
proven escarp
#

mh'

wheat mesa
#

Like typescript

proven escarp
#

yeah i guess

#

typescript is nice tho

wheat mesa
#

Typescript is amazing

#

And so is C#

#

It has types

#

Here I'll show you an example

proven escarp
#
interface IExample {
  name: string;
  likes: number;
}```
wheat mesa
#
// In javascript, a function that adds two numbers
function add(number1, number2) {
  return number1 + number2
}
``` ```ts
// In typescript, a function that adds two numbers
function add(number1: number, number2: number) {
  return number1 + number2;
}
#

Because technically in the first example, add("hello ", "world"); would produce the output of "hello world" even though you intended it to be used with two numbers, and not two strings

wheat mesa
#

Whereas in typescript doing that would fail before the program even runs, because it knows that you want two numbers to be passed into the function instead

#

Thanks for asking questions C:

proven escarp
#

issoke

wheat mesa
#

Nope. I love computer science so I’m happy to answer questions

proven escarp
wheat mesa
#

No

#

About to go into my senior year in high school

lyric mountain
wheat mesa
#

I’m sure in some scenarios yeah

lyric mountain
#

Partly because java is to bytecode what c++ is to assembly too

wheat mesa
#

But the garbage collector is the main reason for the performance gap at this point

lyric mountain
#

Yeah, there's that

wheat mesa
#

Granted a garbage collector is much better than a memory leak, so better be good with C++!

lyric mountain
#

Ohno fatorial, now u created C++++

wheat mesa
#

Lol

quartz kindle
#

/r/unexpectedfactorial

ember canopy
#

Ah ello?

#

Can somone fix my z bot

austere surge
ember canopy
#

Its offline

ember canopy
#

I thought u guys gonna help me

craggy pine
#

They are asking you what it is

austere surge
sharp saddle
#

be specific

#

@ember canopy

ember canopy
#

Hehe sorry

#

Am waiting for somone can fix my offline bot

craggy pine
#

That's not the information they are asking for.

craggy pine
#

Yes...?

ember canopy
#

Idk where i can find the coding yet

wheat mesa
#

You need to create code for your computer/host to run, then your bot will come online and start responding to whatever you give it

woeful pike
wheat mesa
#

Does that not work?

ember canopy
#

Am dead

woeful pike
#

I don't think you can define a monoid in typescript

sudden geyser
#

what's a monoid

hidden gorge
#

Does anyone know how to setup Recaptcha on a website?

earnest phoenix
#

@everyone t

fallen holly
#

how can i check permission for a user in slash command

proven escarp
fallen holly
#

not working

#

trying to display the user perms like this but in slash command

proven escarp
fallen holly
#

for slash cmd

proven escarp
#

For the bot

fallen holly
#

.js

proven escarp
#

That's a lang

lyric mountain
#

.js 👍

proven escarp
#

Not a library

#

Do you mean Discord.js?

fallen holly
#

yea

#

discord.js

proven escarp
#

Ok

#

@fallen holly Ok so you could check permissions with GuildMember#permissionsIn(BaseChannel) which gives you the current permissions of said user for a defined channel.

#

I hope this helps 😉

surreal sequoia
#

B

crystal wigeon
#

Hi so, if I see interaction failed errors does that count as getting blocked temporarily?

crystal wigeon
#

also just a quick question, if the bot is in 10200 servers, does the last shard handle 1.2k servers?

#

cause its only spawning 10 shards

wheat mesa
#

Shards can handle up to 2000 guilds each

earnest phoenix
#

Hey, I just wanted to know how can i host my bot made with typescript cuz i can't find a way to host in heroku. if you could help that would be great ty <33

bright hornet
#

How do I fetch this one? Using

const check = con.findOne({
    memberID: Array
})

const listing = check.members
return console.log(listing)
``` return as undefined tho
near stratus
#

just need some skill

earnest phoenix
near stratus
earnest phoenix
near stratus
#

.......

#

ts-node I see

#

ever heard of tsc ?

earnest phoenix
near stratus
#

use that

#

ts-node was never made for production
at least that's what I remember

#

make your start script something like
tsc && node . (Guessing you configured it right)

#

in tsconfig
so something like

{
  "compilerOptions": {
    "target": "ESNext",
    "module": "commonjs",
    "rootDir": "src",
    "declaration": true,
    "outDir": "build",
    "removeComments": true,
    "newLine": "crlf",
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "strict": true,
    "noImplicitAny": true,
    "strictNullChecks": true,
    "skipLibCheck": true
  }
}
#

and in package.json put

#

"main": "./build/main.js",

earnest phoenix
#

how to do increasing number effect

near stratus
#

number += 1

earnest phoenix
#

no no as in on website

near stratus
cinder patio
#

just use a setInterval

winter pasture
near stratus
earnest phoenix
near stratus
#

that's pretty much the same

#

set count as state

#

create a setInterval

#

and do something like (if number > count) (count ++)

#

display count

#

done

earnest phoenix
#

ohh alright

winter pasture
pearl trail
#

wont that decrease the performance if its like 10k?

#

*the for loop

cinder patio
#

I mean for a few seconds yes

winter pasture
#

It will defo re-render a lot. If you dont have like hundreds of counters, it should be fine

cinder patio
#

oh yeah that for loop is not needed

#

just use a setInterval

winter pasture
#

Oh yeah, that was a bad example

earnest phoenix
#

oh-

#

i was checking it out

steady remnant
#

Pls beg

#

Awww

regal lion
#

Hello everyone,
I tried to verify bot but it doesn't work.
What is the problem?

When the bot is started with the /start command... it creates two channels, one config and one join channel. The config channel is locked for the bot itself and the admin, so when I create a channel I add the condition to enter the channel you need to have bot permission or higher.
I find bot permission like this:
const myRoleId = guild.roles.cache.find(
(role) => role.name === process.env.BOT_ROLE_NAME
).id;

But for some reason on server they are testing, I can not find id of my bot role. (it's undefined)
Can someone help, thanks 🙂
Role for bot is auto created on invite?

near stratus
#

and after doing a little search I found it was already explained to you by vision

regal lion
#

Yeah, but how should I create bot role?

near stratus
#

why would you need bot role anyway?

near stratus
regal lion
#

Because I am creating thread (config) which is locked for bot and admins...

near stratus
#

idk which language / library you're using

regal lion
#

Typescript, DiscordX, DiscordJS

near stratus
#

<Guild>.roles.create()

regal lion
#

Okay, thanks!

bright hornet
#

Anyone knows how to fetch the array without any other string? using the _id is not working, yep didnt work earlier

carmine summit
#

I have an array of settled promises, half of them are fulfilled, half of them are rejected. How can I filter out the rejected ones? I could do Math.random() < 0.5;, but that's just dumb

forest drift
#

is there a way to detect when someone replies to a bot?

forest drift
earnest phoenix
#

TypeError: Cannot read properties of undefined (reading 'send')

near stratus