#development

1 messages Ā· Page 58 of 1

thorny field
#

dont even know where to start with it

lyric mountain
#

start by reading some ToS'ses

#

to gather some reference

thorny field
#

would it be bad if i made mine on a google doc?

rustic nova
#

Would probably be enough yeah

earnest phoenix
#

cant wait to see my bot on top.gg

lyric mountain
rustic nova
#

or go even more overkill, pastebin

earnest phoenix
#

how do i make a vote command for my bot

earnest phoenix
rustic nova
#

You mean a command that is only usable after voting

earnest phoenix
#

no

#

a command that brings you to the votting site

rustic nova
#

just create a command that responds with a link to the voting page

earnest phoenix
#

ill have my developer do it lol

lyric mountain
earnest phoenix
#

and my prefix commands broke for no reason lol

#

could you help figure out what this means TypeError: Cannot read properties of undefined (reading 'createMessageComponentCollector')
at Object.execute (/home/runner/all-in-one/commands/info/help.js:224:35)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)

rustic nova
earnest phoenix
#

spooky i might have bigger issues now lol

earnest phoenix
rustic nova
#

cant look into it myself, you'll need to wait for someone who has knowledge in js

earnest phoenix
#

ok

#

thats the only command that broke is the issue lol

#

and my command to figure out why shuts off the bot

wheat mesa
#

holy mother of god

#

pro tip: please post the code that's actually relevant to your problem and not the entire 550 line file

#

because I'll just tell you now, I don't think anybody is going to read your code if you post something that big

boreal iron
#

Nor able to read a txt file on mobile

earnest phoenix
#

idk where in it lol

wheat mesa
#

read the error

#

help.js line 224 column 35

#

that's what the littlehelp.js:224:35 thing means

earnest phoenix
#

const collector = helpmsg.createMessageComponentCollector({

wheat mesa
#

can you post a little bit more than that

#

Such as where helpmsg is defined

earnest phoenix
#

const collector = helpmsg.createMessageComponentCollector({
filter: (i) => (i.isButton() || i.isSelectMenu()) && i.user && i.message.author.id == client.user.id,
time: 180e3
});

    collector.on('collect', async b => {
      try {
        if (b.isButton()) {
          if (b.user.id !== message.author.id)
            return b.reply({
              content: `${client.allEmojis.x} **Only the one who typed \`${prefix}help\` is allowed to react!**`,
              ephemeral: true
            });
rustic nova
#

lets say, the whole codeblock starting from helpmsg till the end that causes the error

wheat mesa
#

🤦

wheat mesa
earnest phoenix
#

ok

#

there

wheat mesa
#

sigh

earnest phoenix
#

its a long file lol

wheat mesa
#

not to mention you still have not posted the only portion that is actually relevant to the problem. helpmsg is undefined, and we don't know why because we can't see where you defined it

earnest phoenix
#

so line 96 to 224

#

is were it says theres errors

wheat mesa
#

Here I'm just going to post it for you, let me look through it

#
var edited = false;

        let helpmsg = await message.reply({
          embeds: [OverviewEmbed],
          components: allbuttons_home
        }).catch(e => {
          console.log(e)
          return
        });

        const collector = helpmsg.createMessageComponentCollector({
          filter: (i) => (i.isButton() || i.isSelectMenu()) && i.user && i.message.author.id == client.user.id,
          time: 180e3
        });

#

that's what we needed

#

So, helpmsg is undefined

#

Can I see what your command handler looks like?

earnest phoenix
#

i dont were that would be in this mess

wheat mesa
#

Did you write this code

earnest phoenix
#

yes\

wheat mesa
#

...so you should know where your command handler is

earnest phoenix
#

i wasnt very organized when i did it

wheat mesa
#

Where do you call command.execute essentially

#

That's what I need to see

earnest phoenix
#

const {
Client
} = require("discord.js");
const {
Perms
} = require("../validator/permissions");
const {
promisify
} = require("util");
const {
glob
} = require("glob");
const PG = promisify(glob);

/**

  • @param {Client} client
    */

module.exports = async (client) => {
try {
let amount = 0;
(await PG(${process.cwd()}/commands/*/*.js)).map(async (file) => {
const command = require(file);
if (command.name) {
client.commands.set(command.name, command);
amount++;
} else {
await client.logger(Command Error: ${command.name || "Missing Name"} | Directory: ${file.split("/")[7] + / + file.split("/")[8]}.brightRed);
return;
}
if (command.userPermissions) {
if (!Perms.includes(command.userPermissions)) return await client.logger(Command Error: Invalid Permission | Directory: ${file.split("/")[7] + / + file.split("/")[8]}.brightRed);
}
if (command.botPermissions) {
if (!Perms.includes(command.botPermissions)) return await client.logger(Command Error: Invalid Permission | Directory: ${file.split("/")[7] + / + file.split("/")[8]}.brightRed);
}
if (command.aliases && Array.isArray(command.aliases)) command.aliases.forEach((alias) => client.aliases.set(alias, command.name));
});
await client.logger(${amount} Commands Loaded.brightGreen);
} catch (e) {
console.log(String(e.stack).bgRed)
}
}

wheat mesa
#

Okay that still doesn't show me anything. You are not ever calling command.execute() there

#

Basically where is client.on('messageCreate', async message => ...)

#

I need to see where you're calling your execute function on your commands, which I'm assuming is in your messageCreate event

earnest phoenix
wheat mesa
#

That's not how that works

#

You are calling .execute() somewhere in your code

#

That's what I need to see

#

That code you posted just loads your commands into a Collection property on your client

earnest phoenix
#

what should the file be called lol

wheat mesa
#

There's probably somewhere that you do for(const command of client.commands) or something similar

#

I don't know, you claimed you wrote this code so you should know where that is

#

I have a feeling you didn't write the code

#

Just sayin

#

It's okay if you didn't, but you need to be transparent with that so we know to assume that you're not sure where everything is

earnest phoenix
#

i wrote parts of the bot

#

not all of it

#

i wrote most of the commands

wheat mesa
#

It's probably in index.js or something similar, unless you have an event handler along with it

earnest phoenix
#

ah bot.js

wheat mesa
#

Unless you have an events folder, then it would probably be in events/messageCreate.js

#

(Or something similarly named)

earnest phoenix
#

this

#

thats my messageCreate.js

wheat mesa
#

holy

#

whoever wrote that cannot be a sane developer

#

the amount of conditions

earnest phoenix
#

dont ask me i jjust wrote the commands

#

while my devs did the rest

wheat mesa
#

Can you show me your event handler

#

probably in bot.js

earnest phoenix
#

const {
Events
} = require("../validator/eventNames");
const {
promisify
} = require("util");
const {
glob
} = require("glob");
const PG = promisify(glob);

/**

  • @param {Client} client
    */

module.exports = async (client) => {
try {

(await PG(`${process.cwd()}/events/*/*.js`)).map(async (file) => {
  const event = require(file);
  if (!Events.includes(event.name) || !event.name) {
    await client.logger(`Event Error: ${event.name || "MISSING"} | Directory: ${file.split("/")[6] + `/` + file.split("/")[7]}`.brightRed);
    return;
  }
  if (event.once) {
    client.once(event.name, (...args) => event.execute(client, ...args));
  } else {
    client.on(event.name, (...args) => event.execute(client, ...args));
  }
});
await client.logger(`Events Loaded`.brightGreen);
await client.logger(`Logging into the BOT...`.bold.yellow)

} catch (e) {
console.log(String(e.stack).bgRed)
}
};

wheat mesa
#

ok so that part is correct

earnest phoenix
#

this bot is not fun to find stuff in

wheat mesa
#

Other than that, the code is incredibly unreadable and hard to comb through for bugs

lyric mountain
wheat mesa
#

The likelihood is that message.reply() is failing

earnest phoenix
#

rn i only 2 errors that pop up so far

#

RangeError [BUTTON_URL]: MessageButton URL must be a string
at Function.verifyString (/home/runner/all-in-one/node_modules/discord.js/src/util/Util.js:416:41)
at MessageButton.setURL (/home/runner/all-in-one/node_modules/discord.js/src/structures/MessageButton.js:127:21)
at Object.execute (/home/runner/all-in-one/commands/utility/support.js:42:14)
at Object.execute (/home/runner/all-in-one/events/guild/messageCreate.js:177:29)
at Client.<anonymous> (/home/runner/all-in-one/structures/handlers/eventHandler.js:28:50)
at Client.emit (node:events:402:35)
at MessageCreateAction.handle (/home/runner/all-in-one/node_modules/discord.js/src/client/actions/MessageCreate.js:26:14)
at Object.module.exports [as MESSAGE_CREATE] (/home/runner/all-in-one/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (/home/runner/all-in-one/node_modules/discord.js/src/client/websocket/WebSocketManager.js:351:31)
at WebSocketShard.onPacket (/home/runner/all-in-one/node_modules/discord.js/src/client/websocket/WebSocketShard.js:444:22)
at WebSocketShard.onMessage (/home/runner/all-in-one/node_modules/discord.js/src/client/websocket/WebSocketShard.js:301:10)
at WebSocket.onMessage (/home/runner/all-in-one/node_modules/discord.js/node_modules/ws/lib/event-target.js:199:18)
at WebSocket.emit (node:events:390:28)
at Receiver.receiverOnMessage (/home/runner/all-in-one/node_modules/discord.js/node_modules/ws/lib/websocket.js:1137:20)
at Receiver.emit (node:events:390:28)
at Receiver.dataMessage (/home/runner/all-in-one/node_modules/discord.js/node_modules/ws/lib/receiver.js:528:14)

wheat mesa
#

try doing something like ```js
let helpmsg = await message.reply({
// Stuff
}).catch(e => {});
if(!helpmsg) return;

earnest phoenix
#

were would i put this lol

#

i mean what would i replace

wheat mesa
#

I can't help anymore, gotta write some college essays

earnest phoenix
#

work

#

let helpmsg = await message.reply({
embeds: [OverviewEmbed],
components: allbuttons_home
}).catch(e => {
console.log(e)
return
});

boreal iron
#

What ā€œdon’t workā€?

earnest phoenix
#

my help command

earnest phoenix
boreal iron
#

Ok once again… what doesn’t work

#

Provide some details

#

I don’t own a magical glass ball

quartz kindle
#

lies, yes you do

boreal iron
#

Shut up

#

I don’t

earnest phoenix
boreal iron
earnest phoenix
#

the same issue i had earlier

#

but it isnt sending the error

boreal iron
#

I wasn’t here previously

#

So explain please

#

Do you log errors?

earnest phoenix
#

TypeError: Cannot read properties of undefined (reading 'createMessageComponentCollector')
at Object.execute (/home/runner/all-in-one/commands/info/help.js:224:35)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)

quartz kindle
#

like a client of mine used to say:

the problem lies between the keyboard and the chair

earnest phoenix
#

this was the error i got

boreal iron
earnest phoenix
#

but ye the bot sends the errors to a channel in my support sserver

boreal iron
#

Well you’re calling createMessageComponentCollector on undefined

wheat mesa
#

enjoy this one fake

boreal iron
#

Oh

quartz kindle
#

yes fake, enjoy this one

boreal iron
#

I’m driving in 2 minutes

#

Is that too much for me? freerealestate

earnest phoenix
#

waffle couldnt fix it lol

boreal iron
#

Ya… waffle big nuuuub

earnest phoenix
#

where would the issue lie at

#

cause /help works

#

but not the prefix

boreal iron
#

help.js line 224

#

As the error says

earnest phoenix
#

helpmsg.createMessageComponentCollector({

#

thats line 224

boreal iron
#

ya so your var helpmsg is undefined

earnest phoenix
#

and it worked earlier

#

all i changed before it broke was emojis

boreal iron
#

How do you define it?

earnest phoenix
#

var edited = false;

    let helpmsg = await message.reply({
      embeds: [OverviewEmbed],
      components: allbuttons_home
    }).catch(e => {
      console.log(e)
      return
    });

    const collector = helpmsg.createMessageComponentCollector({
      filter: (i) => (i.isButton() || i.isSelectMenu()) && i.user && i.message.author.id == client.user.id,
      time: 180e3
    });
pale vessel
#

did it error?

#

it'll be undefined if it errors

earnest phoenix
#

it sent an error in discord

boreal iron
#

helpmsg is undefined

earnest phoenix
#

if i can find the backup of that command im gonna see if it fixes it

boreal iron
#

Still

#

If message.reply(…) fails helpmsg is undefined

earnest phoenix
#

and before i changed the emojis it was working fine

boreal iron
#

And before creating the collector on it you didn’t check if it’s undefined or nothing

earnest phoenix
#

so it worked fine until i changed the emojis through out the command

boreal iron
#

What does your console log says

earnest phoenix
#

nothing lol

boreal iron
#

Since it fails it has to log something

earnest phoenix
#

last thing it says is it loaded mongo

boreal iron
#

Does the reply work, is a message being sent

earnest phoenix
#

no

boreal iron
#

Probably crashing before there then

earnest phoenix
#

ok now the error pops up again

boreal iron
#

The one you mentioned above?

earnest phoenix
#

heres it more in depth

#

when i run the command

boreal iron
#

Still can’t open txt files on mobile, that hasn’t changed yet

earnest phoenix
#

well its to long to send

#

as text

boreal iron
#

Then use hastebin or sourcebin or trashbin

#

Or whatever

earnest phoenix
#

its 8 charchters over the limit

#

can you see that

boreal iron
#

Invalid form body

#

So yeah your reply won’t be sent

earnest phoenix
#

how is it invalid

boreal iron
#

Show how you defined the components

#

ā€œallbuttons_homeā€

earnest phoenix
#

if (b.customId == "Home") {
await helpmsg.edit({
embeds: [OverviewEmbed],
components: allbuttons_home,
// ephemeral: true
}).catch(e => {})
b.deferUpdate().catch(e => {})
}

boreal iron
#

Try again

#

Read again what I wrote

#

I wanna see how you defined your components

#

Because it’s wrong

earnest phoenix
#

idk where that is in this mess

boreal iron
#

Use search and find

#

allbuttons_home

#

Can’t be so difficult

earnest phoenix
#

ye it shows up in 6 spots

boreal iron
#

Then show them to me

earnest phoenix
#

if (b.customId == "Home") {
await helpmsg.edit({
embeds: [OverviewEmbed],
components: allbuttons_home,
// ephemeral: true
}).catch(e => {})
b.deferUpdate().catch(e => {})
}

boreal iron
#

I wanna see how it’s defined not where you call the var

#

allbuttons_home = …

earnest phoenix
#

const allbuttons_home = [allbuttons_home_list_Button, menuCategory]
const allbuttons_command_commant = [allbuttons_home_list_Button]
const allbuttons_buttons = [allbuttons_home_list_Button, buttonCategory, buttonCategory2, buttonCategory3]

#

found it

boreal iron
#

well

wheat mesa
#

(I have a feeling he didn't write this code)

boreal iron
#

Now show me how both items of your array are defined

earnest phoenix
#

not the whole bot

boreal iron
#

cough

earnest phoenix
#

components: allbuttons_command_commant,
// ephemeral: true
}).catch(e => {})
b.deferUpdate().catch(e => {})
}
if (b.customId == "Button_Menu") {
await helpmsg.edit({
embeds: [OverviewEmbed],
components: allbuttons_buttons,
// ephemeral: true
}).catch(e => {})
b.deferUpdate().catch(e => {})
}

boreal iron
#

allbuttons_home_list_Button and menuCategory

earnest phoenix
#

ok

#

let allbuttons_home_list_Button = new MessageActionRow()
.addComponents([button_home, button_cmd_list, button_button_menu])

boreal iron
#

sometimes snake case, sometimes camel case

#

My gosh

wheat mesa
boreal iron
#

AGAIN MORE VARS

earnest phoenix
#

let menuCategory = new MessageActionRow()
.addComponents([menuSelection])

boreal iron
#

Wtf

#

Show me them

earnest phoenix
#

vars are helpfull

boreal iron
#

No

#

In your case it’s completely nonsense

#

nonsense^2

wheat mesa
#

@boreal iron here's the full code if he hasn't sent the whole thing in a pastebin yet, just so you can have a look https://pastebin.com/SmBMiBbZ

boreal iron
#

Fuck pastebin on mobile man

wheat mesa
#

what site do you want it on

#

I'll post it on there

#

github gist?

earnest phoenix
#

there

boreal iron
#

There we go

earnest phoenix
#

the whole file

#

have fun looking through 500 lines of code\

boreal iron
#

I don’t wanna search the stuff myself on mobile

#

Provide me those 3 vars

#

Can’t be so difficult

earnest phoenix
#

let me go find them

boreal iron
#

Alright

#

Do it

earnest phoenix
#

.addComponents([button_home, button_cmd_list, button_button_menu])

    //   let buttonhome = new MessageActionRow()
    //   .addComponents([button_home.setDisabled(true), button_cmd_list.setDisabled(false), button_button_menu.setDisabled(false)])

    // let allbuttonscommand_commant = new MessageActionRow()
    //   .addComponents([button_home.setDisabled(false), button_cmd_list.setDisabled(true), button_button_menu.setDisabled(false)])

    // let allbuttonsbuttons = new MessageActionRow()
    //   .addComponents([button_home.setDisabled(false), button_cmd_list.setDisabled(false), button_button_menu.setDisabled(true)])
boreal iron
#

That’s not what I want

#

I want those 3 I shows in my screenshot

#

button_home, button_cmd_list and button_button_menu

earnest phoenix
#

// let buttonhome = new MessageActionRow()
// .addComponents([button_home.setDisabled(true), button_cmd_list.setDisabled(false), button_button_menu.setDisabled(false)])

    // let allbuttonscommand_commant = new MessageActionRow()
    //   .addComponents([button_home.setDisabled(false), button_cmd_list.setDisabled(true), button_button_menu.setDisabled(false)])

    // let allbuttonsbuttons = new MessageActionRow()
    //   .addComponents([button_home.setDisabled(false), button_cmd_list.setDisabled(false), button_button_menu.setDisabled(true)])
#

thats button home

boreal iron
#

NO

quartz kindle
#

lmao

boreal iron
#

That’s buttomhome and NOT button_home

#

Ffs

earnest phoenix
#

// let buttonhome = new MessageActionRow()

boreal iron
#

That’s still N O T button**_**home, that’s buttonhome

#

var IS NOT EQUAL TO vaR

#

or VaR

#

or vAr

earnest phoenix
#

let button_home = new MessageButton().setStyle('SECONDARY').setCustomId('Home').setEmoji("šŸ ").setLabel("Home")

boreal iron
#

or v_ar

#

Ok now I need some poor pleb using builders to tell us what you need to provide as argument in the setEmoji method

#

@wheat mesa

wheat mesa
#

takes a unicode emoji, what he has is right

earnest phoenix
#

šŸ 

wheat mesa
#

Just as long as šŸ  is in it's unicode form of \šŸ 

boreal iron
#

I guess it’s not then

earnest phoenix
#

when i typed it in it was in : house:

boreal iron
earnest phoenix
#

with out the space

boreal iron
#

Well there you go

#

There’s your issue

earnest phoenix
#

huh

#

how that the issue

boreal iron
#

:house: isn’t an emoji

wheat mesa
#

yeah you can't do that

boreal iron
#

It’s a string

earnest phoenix
#

ok fudge

wheat mesa
#

you have to do \šŸ 

#

fuck

earnest phoenix
#

i cant copy paste houses

pale vessel
#

\šŸ 

boreal iron
#

He he

earnest phoenix
#

i cant copy paste emojis

boreal iron
#

You can

wheat mesa
#

just look up "unicode house emoji"

boreal iron
#

Works in any editor

#

Even notepad

earnest phoenix
#

ok

boreal iron
#

You can even mark and copy it right of discord

earnest phoenix
#

so im coding this in on a chromebook

boreal iron
#

It will may show a weird character in your code

earnest phoenix
#

i dont have a text editor

boreal iron
#

But it is a valid Unicode emoji

#

And where do you enter your code?

wheat mesa
#

replit is an online IDE

boreal iron
#

There we go

earnest phoenix
#

i am using replit cause its an easy way to test it

boreal iron
#

Anyways… you will have to replace all of it with actual Unicode emojis

earnest phoenix
#

fudge

boreal iron
#

@quartz kindle @wheat mesa
So I solved it… now kneel down and praise lord FakE

wheat mesa
#

to be fair I didn't want to navigate through that mess in the first place lol

boreal iron
#

lazy bitches anywhere

wheat mesa
#

writing college admissions essays rn šŸ™„

boreal iron
#

Then gtfo of discord

#

My gosh

wheat mesa
#

I am chronically online

#

that and I'm asking friends from school for help, so

boreal iron
#

I see you’re a junkie

earnest phoenix
#

ok that should be fixed

#

nope

boreal iron
#

I can sell you some drugs to get rid of that issue mr waffle

earnest phoenix
#

it aint fixed lol

boreal iron
earnest phoenix
#

same error

boreal iron
#

Exactly the same?

earnest phoenix
#

no

#

it now says invalid emoji

boreal iron
#

I’ve seen so much I don’t even find the link anymore

wheat mesa
#

probably did something wrong

boreal iron
#

Send a screenshot of the code again

deft rock
#

How much for the damn drugs Waffle

boreal iron
#

Quiet

#

We’re selling to 18+ only

deft rock
#

i am 18+ šŸ˜‚

earnest phoenix
boreal iron
#

Are those the only buttons with emojis?

earnest phoenix
#

i think so

boreal iron
#

I mean you didn’t provide the two other vars I asked for yet

earnest phoenix
#

never mind

#

found more flippin buttons

boreal iron
#

Just search your code for setEmoji and make sure all are set as Unicode chars

odd nexus
#

its hard to setup a linter

#

in sublime text

earnest phoenix
earnest phoenix
boreal iron
#

You’re pissed because it’s fixed?

#

Being happy would make more sense to me

earnest phoenix
#

Cause it's a dumb issue

boreal iron
quasi depot
#

I have to update VSC right......?

earnest phoenix
#

Um

#

Wtf going on there

quasi depot
#

only If I could tell you.

earnest phoenix
wheat mesa
#

Nothing to do with VSC

boreal iron
#

Better uninstall any of it

#

And use notepad

#

++

hasty mulch
#

How do I get an API field to return None if it can't be found currently in Python?

wheat mesa
#

It's trying to compile stuff in C++ and they don't have any build tools for it

boreal iron
#

That’s exactly how it works young men

wheat mesa
#

Doesn't matter what IDE/editor you're using if you don't have the compiler

boreal iron
#

It does, trust me and listen to an old man

#

Just remove it from your system

#

And no error messages will pop up any more

#

I swear

quasi depot
#

...

boreal iron
quasi depot
#

I am still lost.

deft rock
#

with

wheat mesa
#

I told you how to solve your problem

deft rock
#

oh...yep not gonna get into this

boreal iron
#

Waffle can’t leave discord

deft rock
#

why? too addicted?

wheat mesa
#

I'm procrastinating on writing essays

deft rock
#
console.log('Go write your essays')
wheat mesa
#

I have no idea how to even begin with this, it's such a broad question and it's limited to 300 words

boreal iron
#

Tf is that English

#

Could also be me ofc

wheat mesa
hasty mulch
quasi depot
#

what tools would I need

rustic nova
quasi depot
#

you know about coding tho

rustic nova
#

not in js, one of the reasons above

#

barely could bother with that error

#

anyways it cant find your vscode installation, possibly reinstall it

wheat mesa
#

what

#

no

#

that's not it

#

Install visual studio

#

community

#

please

quasi depot
#

oh

wheat mesa
#

it's not anything to do with visual studio code

quasi depot
#

bruh

boreal iron
#

Not that waffle said this like 10 times already

wheat mesa
#

It needs Visual Studio Community's C++ compiler to compile some of your nodejs dependencies that have bindings to C++

quasi depot
rustic nova
#

there ya have it, I have barely any clue on js, now I shall disappear

wheat mesa
#

make sure you select "Desktop development with C++" when it prompts you

boreal iron
#

Imagine bitching about JS but using python

wheat mesa
quasi depot
#

ok

wheat mesa
#

(sorta)

boreal iron
#

Poor Aurel freerealestate

rustic nova
#

though must admit

#

cringe to require virtual studio to do some npm terminal based stuff

wheat mesa
#

node-gyp is a package for binding js to C++, but if you don't have a C++ compiler built into your system (most windows systems do not come with one by default), then it won't be able to compile stuff

quasi depot
#

oh

wheat mesa
#

It doesn't need the visual studio part, it just needs the build tools that are installed with visual studio

quasi depot
#

how hard is it to get redis database

odd nexus
#

how to install linter in replit?

lyric mountain
#

don't think u can

#

replit has its own editor

#

but on the other hand, why don't u simply download the project and edit it locally?

#

you can use git to keep both sides in sync

neon leaf
#

why does discord respond with bad request?

solemn latch
neon leaf
#

I got identify and guilds

sharp geyser
#

Is your redirect uri correct in the application?

#

same with ID, and secret

neon leaf
#

yes

sharp geyser
#

Show what your actual request body looks like in the end blurring out client_secret

neon leaf
#

ah, managed to fix it, originally I directly got the tokens but messed it up somehow and to fix that I just had to change the type in the uri to token

neon leaf
#

why am I getting a ton of 429s? Im just requesting user info and guild list when the page is loaded (requests are made on the browser, not bot)

earnest phoenix
neon leaf
#

are there any docs for this? Want to check if the user can invite bots

pale vessel
#

that would be the manage server/guild permission

slender wagon
#

I'm tryna check if an email is valid or not

#

like by the way how it is formed

#

tried a few ways but they don't seem to work

#

(javascript)

pallid salmon
#

.

boreal iron
#

Well… you gotta use regex to match your mail address

odd nexus
#

how to create environment variable?

#

@boreal iron

sharp saddle
#

rate**

odd nexus
#

how to create envirnonment variable?

#

its showing me thiss eror

sleek bear
#

How can i get the picture of the message author and maybe use it for embeds

boreal iron
rustic nova
boreal iron
boreal iron
#

soon I’m hacking into your car

rustic nova
#

omg

boreal iron
#

Yee welcome to the future of connecting anything

#

But no worries, everything is save!!!1!

neon leaf
#

whats the best way to authenticate requests to my bot api for the dashboard?

rustic nova
#

elaborate authenticate:

allowing your users to for example configure things?

neon leaf
#

yes, I dont want user xyz to configure settings that only user zyx can configure

rustic nova
#

on every session (since I'm assuming you'd use discord oauth), generate a new session token and track that internally in your bot api, associate that session token with an actual discord user

always check if the session token provided is actually associated with the action you're about to do (such as changing a user-specific prefix on a user that doesnt match the session token)

wheat mesa
#

Like, discord settings? You’re probably going to need an OAuth grant for seeing the user’s guilds and their permission levels in them

rustic nova
#

at least thats what I'm guessing you mean

rustic nova
wheat mesa
#

Aurel has more experience with this than I do, I’ll leave it to them

rustic nova
#

I dont KEKW I have actually tried to setup myself something like this, but that's the way I'd do that with my current knowledge of sessions

neon leaf
#

so I basically save a generated token in my db and if the user logs out / the oauth token expires it gets removed from the db?

wheat mesa
#

Nah, I haven’t ever made a dashboard lol

rustic nova
#

correct

#

always make sure to invalidate sessions to avoid zombie-sessions, also ensure you're not colliding sessions

neon leaf
#

couldnt I technically just use the accessToken?

rustic nova
#

bad idea

wheat mesa
#

Also you’re going to want to store the temporary token on the user’s browser locally, most higher level libs have easy ways to do that. Just so your user doesn’t have to log in between each request

rustic nova
#

use something that you provide yourself, the access token allows you to access the scope-data on a user

rustic nova
#

thus a session token

neon leaf
#

yeah, I already save stuff in cookies

rustic nova
#

but I highly suggest using a generated one from yourself

wheat mesa
#

Are cookies the way to go for that? I remember something about being told to not use cookies for tokens when I was making an API in ASP.NET

#

But maybe I’m remembering wrong

rustic nova
#

you can also use the session Storage, though since I have never actually done front-end based things on a dashboard, I have mainly worked with cookies

cinder patio
#

cookies are the go-to way because the server also has the access to them

#

with localStorage you'll always have to send it yourself

rustic nova
#

so essentially:

  • once a user authorizes, provide a cookie for example that contains a session token, associate session token with user (id, possibly access token, refresh token)
  • authorize actions using that session token, always confirm actions done with that session token are actually affecting that user associated with that token and not someone else
  • once a user logs out, invalidate session token
  • once a user authorizes again, invalidate previous session token
cinder patio
#

and the server can't set it in any way

rustic nova
#

though cookies are more easy, since these are sent along requests too

#

you could also go the way discord does it with their authorization tokens, I don't know if theres some standard on it

neon leaf
#

yeah, Ill try that. While im here, how can I search for something in an json array? example every json has a value property, how can I find the index where the value is x?

rustic nova
#

js right?

neon leaf
#

yea

rustic nova
#

yeah nvm gotta ask someone with proper js knowledge on that

earnest phoenix
#

im trying to make a reaction role with buttons. Everything works but when i click the button nothing happens and i dont get any errors

CODE:

    async handleButtonResponse(interaction, args, client) {
        const roleId = TEST_ROLE;
        if (interaction.isButton === "partnership_yes") {
            await interaction.member.roles.add(roleId);
            return await interaction.reply({
                content: `<@&${roleId}> role has been added!`,
                ephemeral: true,
            });
        } else if (interaction.isButton === "partnership_no") {
            await interaction.member.roles.remove(roleId);
            return await interaction.reply({
                content: `<@&${roleId}> role has been removed!`,
                ephemeral: true,
            });
        }
    }

If anyone can help me that would be be great

rustic nova
#

isButton is a boolean that contains either true if it is a button and false if it is not (such as being a select menu instead)

#

so both conditions would fail as you're comparing them with a string

boreal iron
rustic nova
#

shush

#

still have my point

boreal iron
rustic nova
#

so what you're possibly looking for is customId im guessing?

boreal iron
#

it is

rustic nova
#

no clue about discordjs, yet am able to read docs bigbrain

boreal iron
earnest phoenix
#

the custom id of the button is the same as the interaction part

boreal iron
#

Yes as the button triggers an interaction

earnest phoenix
#

but nothing works

boreal iron
#

just show us what u did

#

and explain what "doesn't work"

earnest phoenix
#

How can i get bot developer role?

solemn latch
#

Have an approved bot on topgg

earnest phoenix
#

I already have one

#

But i don't have the role

solemn latch
#

gotta love our bot going down every 10 seconds šŸ‘€

earnest phoenix
#

Ok thanks

earnest phoenix
#

well fudge my bots code is on and its dead

slender wagon
#
if (email.value.match(validRegex)) {

Cannot read properties of undefined (reading 'value')

#

help me fixxx

boreal iron
#

well

#

email is undefined

slender wagon
#

bruh

#

i had deleted a part of the code without noticing

cursive musk
#
RangeError: Invalid count value
    at String.repeat (<anonymous>)
    at /home/container/src/commands/information/help.js:243:37
    at /home/container/node_modules/discord.js/node_modules/@discordjs/collection/dist/index.js:1:3113
    at Function.from (<anonymous>)
    at Map.map (/home/container/node_modules/discord.js/node_modules/@discordjs/collection/dist/index.js:1:3053)
    at module.exports.run (/home/container/src/commands/information/help.js:237:12)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async module.exports.runCommand (/home/container/src/events/message/messageCreate.js:302:5)
    at async module.exports.run (/home/container/src/events/message/messageCreate.js:276:9)
#
else if (
      (args && args[0].toLowerCase() == "config") ||
      (args && args[0].toLowerCase() == "configuration")
    ) {
      embed.setTitle(` ${emojis.economy} - Configuration`);
      embed.setDescription(
        this.client.botCommands
          .filter((cmd) => cmd.category.toLowerCase() === "config")
          .map(
            (cmd) =>
              `${
                cmd.disabled || disabledCommands.includes(cmd.name || cmd)
                  ? red
                  : green
              } \`${cmd.name} ${" ".repeat(9 - Number(cmd.name.length))}:\` ${
                cmd.description
              }`
          )
          .join("\n")
      );

      embed.setFooter({
        text: `Requested by ${message.author.username}`,
        iconURL: message.author.displayAvatarURL({ dynamic: true }),
      });

      embed.setTimestamp();
      embed.addField(
        "\u200b",
        "**[Invite](https://universebot.xyz/invite) | " +
          "[Support Server](https://universebot.xyz/support) | " +
          "[Dashboard](https://universebot.xyz/dashboard)**"
      );
      return message.channel.sendCustom({ embeds: [embed] });
#

What is going on

violet haven
#

hello guys! i've been programming my own discord bot for 2 years and i would like to learn how to monetize it but i don't know where to start. Do u have useful links?

spark flint
#

its just .send

#

message.channel.send

cursive musk
#

but anyways

#

what is going on with the count eror

#

RangeError: Invalid count value

#

i sent the full error and code above

wheat mesa
#

We've helped you with this exact same issue before, that means you're passing a negative number to the .repeat function

#

And as Tim said before, there's a method called padEnd that you should use instead of doing this

#

^

cursive musk
# wheat mesa ^

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

#

Name isn't a defined value I guess

wheat mesa
#

Look at your code and adapt that to it, that was just an example

lyric mountain
sharp trellis
#

so im trying to listen to when users vote to track and give rewards

#

but it just doesnt work

#

like doesnt return anything

#

site link is alright

#

and everything

#

checked on the npm page for the tutorial but it didnt work

earnest phoenix
#

It's not alright if you're not receiving anything

sharp trellis
#
const webhook = new Webhook("my code")
const app = express();



app.post('/dblwebhook', webhook.listener(vote => {
  console.log(vote.user)
}))

app.listen(3000)

client.login(token)```
earnest phoenix
#

And what have you set as your webhook URL in the website? (Omit the IP address if you've put that in)

sharp trellis
#

for the webhook url i put

#

http://my ipv4 adress:3000/dblwebhook

earnest phoenix
#

Hmm that's correct, in the "my code" part are you putting in the password you entered in the website?

boreal iron
#

where are u running that code? on your PC, a server ... etc.?

sharp trellis
#

pc

boreal iron
#

well, you will have to open and forward the ports in your router and firewall

#

in order to receive incoming requests

#

and you're required to have a public ipv4 address

sharp trellis
#

kk

earnest phoenix
#

can i have help testing my bot

lyric mountain
#

what kind of help?

earnest phoenix
lyric mountain
#

why do u need other people to do that?

#

just test all the use-cases yourself

#

test as if you were purposely trying to mess it up

earnest phoenix
#

wich is what i need help testing

lyric mountain
#

why did u make 160 commands with no test?

rustic nova
#

clones drakeYea

lyric mountain
#

like, it's common sense to test your batch every few commands

#

else u get technical debt

rustic nova
#

KuuHaKu, do you like your bots with or without testing

earnest phoenix
#

most of it works from what ive tested

#

Discord bot developers on their way to shove as many commands as possible to their Discord bots (almost every bot has those commands)

lyric mountain
earnest phoenix
#

Oh God oh hell naw

#

its big

#

That's what she said troll

#

lol

#

i made a bug report command

#

thats sends the bug reports to the support server

lyric mountain
#

nobody ever reports

earnest phoenix
#

That could be abused, sending random shit just to troll

#

And yeah nobody ever uses those commands to report actual bugs

#

its a handy feature lol

lyric mountain
#

it is indeed, but in my 3 years of bot coding, I think I saw 6 or 7 valid reports

earnest phoenix
#

To you, it's better to just let people join the support server and report the bugs/issues they encounter

#

can i have help testing my tictactoe game

#

for the bot

lyric mountain
#

nowadays I just have a QA team to get the bugs themselves

earnest phoenix
#

i might use a vps a friend is offering if i give them credit for building the bot lol

#

so i dont have to pay the 5 dollars a month

#

$5 per month is literally nothing, I don't see why you wouldn't just pay it yourself unless you live in a country where no regional prices are available

wheat mesa
#

if you have no income $5/month is kinda expensive C:

#

But it's the cost of hosting

#

For renting hardware that's on 24/7, $5/month is nothing

boreal iron
#

Sell your body ezpz

sharp trellis
#

@boreal iron

#

Ive been trying to setup port forwarding

#

Its quite easy

#

But does it take some time to open

#

Once you click save

boreal iron
#

No

#

Changes on your firewall are immediately active

earnest phoenix
#

const Discord = require("discord.js");

        module.exports = {

name: "vote",
aliases: ["v"],
execute: async(client, message, args, data, db) => {

       const embed= new Discord.MessageEmbed()
       .addField(`Vote us Here -`, `[Click Here](https://voidbots.net/bot/1029882366212190260)``Vote us Here -`, `[Click Here](https://top.gg/bot/1029882366212190260)`)
      message.channel.send(embed)
    }
        }

module.exports.help = {
name: "vote",
description: "Vote the bot",
usage: "vote",
type: "General"
}

boreal iron
#

Show me what u did

earnest phoenix
boreal iron
#

My magical glass ball doesn’t tell what’s wrong/not working

#

Dunno it must be broken

earnest phoenix
#

(node:180) UnhandledPromiseRejectionWarning: TypeError: "Click Here" is not a function
at Object.execute (/home/runner/Sprites-all-in-one-Bot/commands/ā„¹ļø General Info/vote.js10113)
at module.exports (/home/runner/Sprites-all-in-one-Bot/events/message.js:162:25)
(Use node --trace-warnings ... to show where the warning was created)
(node:180) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:180) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

earnest phoenix
#

thats the error im getting

boreal iron
earnest phoenix
#

Just watch troll

boreal iron
sudden geyser
earnest phoenix
#

sure

boreal iron
#

Or use code blocks

sudden geyser
#

The ` inside the code will interfere with code blocks

boreal iron
#

Not with blocks

#

But with inline code blocks

sudden geyser
#

oh it doesn't

boreal iron
#

Not for me

earnest phoenix
boreal iron
#

But uploading it to somewhere else is better anyways than discord

sudden geyser
#

not the error

boreal iron
#

Lol

sudden geyser
#

the code

boreal iron
#

Not the error

earnest phoenix
#

ok

sudden geyser
#

see here

#

this creates two separate strings

earnest phoenix
#

ok

boreal iron
#

Also addField

#

Doesn’t it require an object now?

#

As the api expects it

earnest phoenix
#

You're basically trying to call a template string as a function (it's called template invocation)

#

Use a \ to escape the ` if you're using them inside a template string

boreal iron
#

Can you still pass he field name and value as arguments?

#

Thought that doesn’t work anymore

#

Can’t check the docs atm

earnest phoenix
#

how do i fix the bot

earnest phoenix
#

Although they seem to be using v13

#

i got it partial working

sudden geyser
#

why are there no builder methods in v14/main

earnest phoenix
#

now the bot kills the server

boreal iron
earnest phoenix
#

the bot turns off when i do .vote

earnest phoenix
sudden geyser
#

oh

#

that's confusing

earnest phoenix
#

You're supposed to use them

#

ok how do i add the second vote website

#

to the command

boreal iron
#

Not more or less

sharp trellis
#

Its supposed to work lol

#

Status is on

earnest phoenix
#

voltrex any help

sharp trellis
#

I put protocol on "both"

earnest phoenix
boreal iron
sharp trellis
#

Ah

#

Lemme see

earnest phoenix
#

@boreal iron help pls

earnest phoenix
earnest phoenix
#

and doesnt start

#

Because you're doing it incorrectly, what's the error?

#

none

#

it just kills itself

#

Show code

sharp trellis
#

@boreal iron i put my external address as the local ip address?

#

prob yeah

earnest phoenix
#

const embed= new Discord.MessageEmbed()
.addField(Vote us Here on void bots -, [Click Here](https://voidbots.net/bot/1029882366212190260) )
message.channel.send(embed)

earnest phoenix
#

That's not an error

sharp trellis
#

Still says port 3000 is closed on my ip

boreal iron
earnest phoenix
#

SyntaxError: Identifier 'embed' has already been declared

boreal iron
#

Err is mentioned in the docs

earnest phoenix
#

then how am i supposed to do this

#

Name the variable something else, it can be whatever you want

#

could make another command for it

sharp trellis
earnest phoenix
#

ill deal with it later

#

when i can get it on the new host

earnest phoenix
#

and how long do bots take to get verified

long marsh
#

What are you all using for your database of choice?

earnest phoenix
long marsh
#

I've heard a ton about MongoDB. Does anyone here use SQL?

boreal iron
#

Depends on your needs

long marsh
#

That's true. For an RPG write-heavy application, what would you recommend?

earnest phoenix
long marsh
#

I'm starting with Postgres for now. Traditional relational style has actually been my weakpoint since college, haha

boreal iron
#

Write intensive isn’t an issue but how you access and store data in other words the structure makes is important

long marsh
#

I understand storing data efficiently for your needs, but I've been reading a ton of conflicting articles. On the radical hand, some don't use any foreign keys ... strictly store everything needed on a page load / for a character. They'll even redundantly store data.

Then, on the normalization end, some folks will do everything in its own table and link everything back with foreign keys.

#

Some use databases to keep integrity, others place the burden on their application to handle it.

#

And I'm trying building a discord bot right now - struggling to think through it.

I had a discord bot before using DynamoDB. It worked really well and was super cheap, but restricted me for future querying patterns.

sudden geyser
#

In general, you should strive for a database with foreign keys/relations.

#

Having your database manage relations relieves you from many problems associated with linking data.

#

Of course, a database can do more than relations, and SQL can be a burden.

quartz kindle
#

generally speaking the tradeoff is between performance and space efficiency

#

tables with duplicated columns have better performance and allow independent queries but use more space

#

normalization is used for 2 things: reducing space (by removing duplicates) and protecting data (no duplicates mean no risk of accidentally changing an id in one table but not in another)

#

but those things cost read performance, so your queries will be slower

#

id say go for normalization if you have a column common to multiple tables that is frequently updated

#

so you dont have to update multiple tables every time

#

otherwise go for denorm

wet bloom
#

someone who know how to make a manual post request to post the server count?

earnest phoenix
#

How do i make a headline like that for my Bots description on top.gg?

#

and the text should be a bit smaller how do i do?

#
# Text
## Text
### Text
...
rustic nova
#

see these as <h1> <h2> and <h3>

earnest phoenix
#

ok thanks

radiant kraken
#

or removing the query parameters

#

if it still doesn't work then you can use inspect element

dry imp
#

i guess yea i can but thats pretty annoying to do

radiant kraken
#

at least you get the image

pale vessel
#

no problem

radiant kraken
#

why do you need a proxy for that

dry imp
#

idk but that works ig

radiant kraken
#

cors perhaps?

pale vessel
#

how's it cors if it returns 404

dry imp
#

ig this trailing stuff is the issue /revision/latest/scale-to-width-down/350?cb=20200411161426

radiant kraken
#

so what i said was true

dry imp
#

yes

earnest phoenix
#

Can anyone provide me an api which shows food images!? because mine isn't working 😭

eternal osprey
#

hey guys

#
void show_universe(Cell universe[NO_OF_ROWS][NO_OF_COLUMNS], string starter)
{
    ofstream output;
    output.open(starter);
    if(output.fail()){
        cout << "Error opening output file " << starter << endl;

    }
    // precondition
    assert(sizeof(universe[0]) / sizeof(Cell) == 60);
    // postcondition
    // Result is the display of the 2d universe array in the console with dimensions 40x60.
    for (int i = 0; i < NO_OF_ROWS; i++)
    {
        for (int j = 0; j < NO_OF_COLUMNS; j++)
        {

            if (universe[i][j] == Dead)
            {
                output << DEAD;
                cout << DEAD;
                if (j == 59)
                {
                    cout << '\n';
                    output << '\n';
                }
            }
            else
            {
                 output << LIVE;
                cout << LIVE;
                if (j == 59)
                {
                    cout << '\n';
                      output << '\n';
                }
            }
        }
    }
    output.close();
}
```i made this function in c++, it basically just showcases the game of life in the console. I have added it alongside:```c++
show_universe(next, saveuniverse);
sleep(350);
set_cursor_position(0,40);
clear_screen();
#

But as you can see its focking slow

#

as it writes each line one by one. Any way to optimize this

neon leaf
#

how can I get every server a user is on (yes, I know the bot also has to be on it) in discord.js v14?

boreal iron
#

Using Discord’s OAUTH flow to get informations like that from the user

#

But I guess that’s not what u mean

neon leaf
#

is there a way through discord.js though? I get ratelimited from oauth after 2 requests

boreal iron
#

You will have to fetch a guild member providing that user ID for every guild

#

Which I would consider as API spam

cinder patio
neon leaf
#

this should only make 1 request, right?

boreal iron
#

What’s your intention to map that collection?

#

for(const [id, guild] of client.guilds.cache) console.log(guild.name);

#

Just loop through it instead of creating an array for no reason

#

And no, it won’t make any api request

#

It just iterates your cache

neon leaf
#

and if I dont use my cache?

boreal iron
#

Fetching the guilds will do one request per guild, yes, but only if you enforce it

#

If not fetch will check the cache as well

neon leaf
#

I think im actually going in the wrong direction right now, I want to make my dashboard api check if a user is permitted to do that and etc, I thought about saving each of their guilds but if they left theyd still have access to it because im only checking when they authorize

boreal iron
#

You can’t constantly check that unless your bot is in any guild the user is, too

#

If so you gonna listen to the guild events for joining/leaving members

#

And update the user guilds in the background ones he joins/leaves a guild to be up to date

neon leaf
#

what if he is already in x guild but isnt in the db because the bot didnt detect it because the feature didnt exist yet?

#

I mean, I already display a list of servers a user is in, already have it only show guilds he has perms in but I need the api to know the same without getting my servers ip rate limited

boreal iron
#

But nothing I would recommend

#

And will get I rate limited as well

#

The user using your dashboard should perform a login via the OAUTH flow

#

Then keep his guild joins/leaves up to date by listening to the mentioned events

#

Let him login on any new session, don’t save the session and you should be always up to date

neon leaf
#

but with that, how would I know that he has permissions?

deft rock
#

any ideas?

rustic nova
#

trying to register commands in a server your bot is not in/your bot does not have perms to create slash commands

deft rock
#

ok, one sec

#

made sure it was the server and that it had the perms yet I get it still

#

Just reset token and it works now :/

deft rock
#

thank you Aurel

boreal iron
#

man resetting his token more often than changing his pants

earnest phoenix
#

My bot got hacled

sudden geyser
#

based

deft rock
astral path
wheat mesa
#

Probably posted his token somewhere without realizing it

earnest phoenix
#

And I had the token hidden

wheat mesa
#

doubt

#

Otherwise you wouldn’t have gotten ā€œhackedā€

earnest phoenix
#

P

deft rock
earnest phoenix
slender wagon
#
function validateEmail(email) {

            let validRegex = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;
            console.log(email + "This is the email")
            if (email.value.match(validRegex)) {
          
              return true;
          
            } else {
          
              return false;
          
            }
          
          }

so i am tryna validate an email

#

Cannot read properties of undefined (reading 'match')

#

getting this error rn

#

don't mind the console log, it was there just to confirm that email is passing

cinder patio
#

so what is email?

#

is it a string?

#

an object?

slender wagon
#

yes

#

string ofc

cinder patio
#

what does it log

slender wagon
#

the email

#

what i input

#

since this is a bot interaction

cinder patio
#

well then why do you have email.value.match and not email.match

slender wagon
#

right maybe cuz this comes from stack overflow

#

and i didn't bother changing much

cinder patio
#

also you could just return return email.value.match(validRegex) instead of having an if statement

slender wagon
#

can i

cinder patio
#

not helping you anymore with that attitude

#

learn javascript

slender wagon
#

oh i was honestly wondering

cinder patio
#

and understand what you're copy-pasting

slender wagon
#

sorry

#

the thing had other values previously since it was made to work in html

#

was returning some weird shit

#

so that explains .value

lyric mountain
#

your email regex is incomplete btw

slender wagon
#

wym

#

this is by far the longest shit i've seen the other regex were shorter

lyric mountain
#

like, there are no email regexes that'll work 100%, but the official RFC regex is much longer

#
(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])
#

javascript allows some compression of that thing

slender wagon
#
/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/

webpage shows this for js

boreal iron
#

who tf respects the rfc

slender wagon
#

so to verify 100% an email u should prolly use an api? or start making it urself?

boreal iron
#

no

lyric mountain
#

it's pretty much impossible to have a 100% proof email validator unless u try to send an email to it

boreal iron
#

you simply use a regex to filter the most out already, then send a verification email to verify the address

lyric mountain
#

that's why most sites use the "please verify your email"

slender wagon
#
 function validateEmail(email) {
            let validRegex = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
            return email.match(validRegex)
          }
        let emailValidation = await validateEmail(email)
        console.log("EMAIL VALIDATION: " + emailValidation)
        if (emailValidation === null) {
            return interaction.reply('Please use an actual email!')
        }
        const encodedEmail = encodeURIComponent(email)
        console.log(encodedEmail)
``` so this is what i came up with, looks OK to me
please let me know if i am using await wrong
boreal iron
#

why do people create vars when they only use it once

#

I will never get it

sudden geyser
#

so you know what it means

lyric mountain
#

it'd be worthy to compile that regex btw

slender wagon
#

i might add way more to the code idk

lyric mountain
#

so u don't recompile it on every function call

slender wagon
#

hmm

boreal iron
#

also why do you await that function?

lyric mountain
#

wait

#

ah nvm, just noticed the brackets are off

#

I thought u were recursively calling it

boreal iron
#

discord doesn't like tabs

lyric mountain
#

and yes, u dont need to await since it's not an async function

slender wagon
#

fixd

slender wagon
#

is this it?

#

I've noticed developer.mozilla has some crazy docs

lyric mountain
#

yes

#

save the result to a constant

#

however, there's a newer method

slender wagon
#

yeah i see there is a warning about this

lyric mountain
#

new RegExp("regex")

sudden geyser
#

I don't think new RegExp does any special "compilation" different from /.../

slender wagon
#

we need to put some testing into it

lyric mountain
#

hm, perhaps since it's a string literal

boreal iron
#

man... just crreate an useless var for it

#

that's it

#

all issues solved

slender wagon
#

no, i build quality

#

pls KEKW

boreal iron
sudden geyser
#

Here

Before regular expressions can be used, they have to be compiled. This process allows them to perform matches more efficiently. There are two ways to compile and get a RegExp object.

The literal notation results in compilation of the regular expression when the expression is evaluated. On the other hand, the constructor of the RegExp object, new RegExp('ab+c'), results in runtime compilation of the regular expression.

knotty quartz
#

How do you create webhooks?

slender wagon
#

like discord webhooks?

#

postgress or mongodb what would be the best choice for a discord bot

#

might get big

lyric mountain
#

postgres always

#

the scalability is on another level entirely

slender wagon
#

hehehe

neon leaf
#

not about development too much but how do I make this new .setColor() line have tabs accordingly to where its in?

quartz kindle
#

enable regex and type \t

#

i mean, if you want auto indentation, then you cant do it via search

lyric mountain
#

alt + 0009

knotty quartz
#

I know how to make them on Discord, I just don't know how to make them work.

#

Another Question can you make slowmode on Discord Slash Commands? Like 10s to prevent spam?

lyric mountain
#

you can use them yourself for stuff like messages with name and avatar unique for each message, or to have some kind of broadcasting feature

#

if u don't need something like that, webhooks will offer very little value compared to normal messages

knotty quartz
#

Is there something that helps you send the messages using them?

quartz kindle
#

most discord libraries have built in support for webhooks

sterile lantern
#

? looping through certain guild members (fetched) + i have intents on

#
  for(const userDocs of shuffled) {
        if(pickedDiscordIDs.length < amount) {
            let search = await users.find({ DiscordID: userDocs })
            let user = search[0].DiscordID;
            let guildMem = await message.guild.members.fetch({ user: user, withPresences: true, force: true });
            if(guildMem.presence != null && (guildMem.presence.status == 'online' || guildMem.presence.status == 'idle' || guildMem.presence.status == 'dnd')) {
                console.log(guildMem.presence.status);
                pickedDiscordIDs.push("<@" + user + ">");
                pickedRobloxUsers.push(search[0].RobloxUser);          
                console.log(pickedDiscordIDs.length);
                console.log(pickedDiscordIDs);
            }
        }
    }```
boreal iron
#

Just as note… if your presence is ā€œonlineā€ or ā€œdndā€ etc. it automatically means it can’t be null

sterile lantern
#

ah yeah that was just for testing

boreal iron
#

So that condition isn’t needed

sterile lantern
#

going to remove it after this is finalized

#

but ye idk why its giving a timeout error

#

google says intents problem but i have the server members intent on

boreal iron
#

I was about to say members not arriving in time can happen when fetching all members of big guilds

#

But that’s not the case

sterile lantern
#

ye thats why i was fetching one by one

boreal iron
#

How many does that fetch?

#

What’s the size of shuffled

sterile lantern
#

and also another reason y im not fetching all guild members is bc this cmd is only for people in the database

#

so it would b pretty useless to fetch everyone

#

since theres like 2k people not in the database

boreal iron
#

Oof 1.1k

#

Guess you’re getting rate limited hard

sterile lantern
#

i think

#

i have found the issue

#

dorm wifi is not that good lol

boreal iron
#

Still assuming you’re getting rate limited, too

#

1.1k requests will get you there real quick

sterile lantern
#

its not doing it all at once tho

#

ive printed out how many times it goes through

#

and its spaced out by like 1-2 seconds

#

its not like its instantly doing it

boreal iron
#

Well I don’t see any timeout or sleep

#

If shuffled really is 1k large then the requests will be made one after each other

#

Just the response will take a few seconds

sterile lantern
#

how would i make it wait like 1 second after each fetch

#

it says theres a time option

boreal iron
#

That entire concept isn’t really good tbh

#

Why would you need to fetch so many users anyways?

sterile lantern
#

i mean theoretically speaking im not fetching all 1.1k, i'm only fetching until i meet a certain # of users

#

its for a event bot so we pick only online members

#

out of the people who registered to join the event

#

usually we only need 100 members but a lot of members are offline

boreal iron
sterile lantern
#

but wouldnt fetching all members also result in the same error

#

fetching multiple members via #fetch()

boreal iron
#

Well you should enable the debug log to see if you’re getting rate limited

sterile lantern
#

o

#

how do u do that

boreal iron
#

djs has its own event for you can listen to

sterile lantern
#

o

#

client.on(debug?

boreal iron
#

Yeah

sterile lantern
#

alr ty

quartz kindle
#

the REQUEST_GUILD_MEMBERS gateway command is designed to handle large amounts of members at once, it can easily handle 1000+ members per second

#

just put all your member ids into a single fetch request

#

instead of making separate requests for each member

sterile lantern
#

hmm alr

sterile lantern
# quartz kindle instead of making separate requests for each member
let guildMem = await message.guild.members.fetch({ withPresences: true, force: true }).then(async members => {

    for(const userDocs of shuffled) {
        if(pickedDiscordIDs.length < amount) {
            let search = await users.find({ DiscordID: userDocs })
            let user = search[0].DiscordID;
            let guildMem = members.filter(m => m.user.id === user);
            console.log(guildMem.presence);

how come guildMem.presence returns undefined

#

guildMem returns the user perfectly fine

quartz kindle
#

do you have the presences intent?

sterile lantern
#

yes

#

it worked b4 i changed my code

quartz kindle
#

also, you dont need to fetch all members, you can specify an array of ids to fetch

sterile lantern
#

o

sterile lantern
#

this is shuffled

#
  • 1000 more values
quartz kindle
#

console.log members

sterile lantern
#

nothing prints

#

thats so weirdddd

#

it worked before i specified users

#

but like its an array so it should work

quartz kindle
#

add this event to your bot

#
client.on("guildMembersChunk", console.log)
sterile lantern
lyric mountain
#

do u have the intent?

sterile lantern
#

yes

lyric mountain
#

did u enable it?

sterile lantern
#

yep

lyric mountain
#

did u enable the partials?

sterile lantern
#

it worked before i specified the user

#

?

quartz kindle
#

how about this ```js
client.on("raw", x => {
if(x.t && x.t === "GUILD_MEMBERS_CHUNK") {
console.log(x.d)
}
})

sterile lantern
#

oh i just got a error actually

lyric mountain
sterile lantern
lyric mountain
#

or better yet, a database

sterile lantern
#

it is in a database

quartz kindle
#

are you running that code on startup?

sterile lantern
#

which code

#

the command?

quartz kindle
#

the members fetch thing

sterile lantern
#

uh well once it fully starts then i run the cmd