#development

1 messages · Page 1384 of 1

opal plank
#

its different

#

but yes im a bit tired

umbral zealot
#

oh yeah that would probably help dealing with noobs. good idea.

opal plank
north birch
#

but yes im a bit tired
@opal plank Oh im fucking dying

umbral zealot
#

fetch(jamieson.bottle())

earnest phoenix
#

"noobs" who are you calling a noob

vague kelp
#

@opal plank which language did you think this was 😂

opal plank
#

i mean i know its js

#

👀

earnest phoenix
#

It literally says on the link i sent

opal plank
#

imagine not using ts

#

spit

#

scrub

earnest phoenix
#

U wot

opal plank
#

spit

#

scrub

earnest phoenix
#

What if i switch to TS

opal plank
#

come to the dark side, we got donuts and typed objects

#

come swim in our integrated wiki and docs

vague kelp
#

Come to the darker side, we have cookies

opal plank
#

embed your soul with our errors before even compiling

#

enjoy the joyfulness of tpyes

earnest phoenix
#

Ah yes, errors hmm... Delicious

opal plank
#

better fixing errors while you coding than waking up the next day every 5AM with users dm'ing and flooding your ticket system with bug reports

earnest phoenix
#

It's 2 am and I'm making this function in first try, bruh moment?

opal plank
#

well, currently

#

there will be bugs

#

and then you'll come crawling

#

ts would babysit you

#

just saying

earnest phoenix
#

There was no bugs though xd

opal plank
#

whispers come to the dark side, its cozy

#

bugs are unexpected

earnest phoenix
#

Why is it called the dark side though

umbral zealot
#

It's also super strict and causes a lot of headaches, your dark side.

opal plank
#

strict good

earnest phoenix
#

Isn't it supposed to be light side or whatever because ts is better

opal plank
#

too much flexbility and you have it doing shit like
10 * '2' returning 20

umbral zealot
#

"better" is all about perspective. It's not better, it's different.

opal plank
#

i'd argue its better

#

its JS with safeguarding

earnest phoenix
#

It's just JavaScript with type guards

umbral zealot
#

Of course you would argue it's better, since you use it and you love it

#

I don't, and I don't think it's better.

earnest phoenix
#

too much flexbility and you have it doing shit like
10 * '2' returning 20
@opal plank Can't JS already do that

opal plank
#

i may be biased, yes, though comparing the two, ts is better, even with the drawbacks of typing more

#

adding a colen and a type isnt that hard

#

for the benefits it yields

#

not even talking about the shipped docs and declarations with most of the libs

#

popular* libs

earnest phoenix
#

Welp, i think i have answered my own question, it's the most efficient paginate function, big win win

umbral zealot
#

too much flexbility and you have it doing shit like
10 * '2' returning 20
@opal plank uhm... but that's... the correct answer...

opal plank
#

multiplying a string with a number?

#

yeah, no

umbral zealot
#

it's typecasting

#

it's not wrong, it's just different

opal plank
#

you are still multiplying strings with numbers

umbral zealot
#

Javascript is a loosely/dynamically typed language, this is by design.

opal plank
#

indeed, which is what makes its bugs unbelievably hard to ctach beforehand

#

you'll spend 80% of your time debugging stuff, later on when you are experience you'll still catch quite a few bugs

umbral zealot
#

Sure, but it's a choice that's been made, saying it's wrong is an opinion, not a fact.

opal plank
#

im not saying its wrong

#

im saying ts is better

#

it shouldnt multiply strings by numbers

#

even though it does

#

while my example is lacking, stuff like that can cause bugs in code quite easily

split hazel
#

ts reminds me of the python 3.6 update where you can optionally use static types

umbral zealot
#

by saying TS is better you're saying JS is worse.

earnest phoenix
#

so i am back

opal plank
#

worse, yes, too lose, not wrong

#

omg

earnest phoenix
#

i found no help

sudden geyser
#

You may as well not use JS at that point

umbral zealot
#

If you wanna use TS, use it, but I'm not going to be convinced.

earnest phoenix
#

you guys are useless

split hazel
#

thanks

umbral zealot
#

@earnest phoenix no u

sudden geyser
#

help with what

opal plank
#

@split hazel can u ban that guy, pls?

#

already too much drama

#

or a warning at least

#

fgor the love of god

earnest phoenix
#

so some guy just gave me some code randomly

#

@support.error
async def support_error(ctx, error):
if isinstance(error, discord.ext.commands.errors.CommandInvokeError):
await ctx.send(
f"<@!{ctx.author.id}>, the AI chat bot doesn't have all day for you, the support AI is now disconnected")
elif isinstance(error, discord.ext.commands.errors.CommandOnCooldown):
em = discord.Embed(
title="The AI bot is under heavy use, so you have to wait 5 minutes to use it again.",
colour=discord.Colour.red()
)
cooldowntime = '{:.2f}'.format(error.retry_after)
cooldowntime = float(cooldowntime)
cooldowntime = cooldowntime / 60
cooldowntime = round(cooldowntime)
msg = 'Please try again in {:.2f} seconds'.format(error.retry_after)
em.add_field(name="Cooldown : 5 minutes", value=f"{msg} or around {cooldowntime} minutes")
await ctx.send(embed=em)
else:
raise error

opal plank
#

so you WERE spoonfeed? nice

umbral zealot
#

ok and?

earnest phoenix
#

what is this

umbral zealot
#

It's code

opal plank
#

^^

earnest phoenix
#

hELp cTrL C CtrL V doesnt WORK

#

Or did you mean something else

umbral zealot
#

If you want to know what that does @earnest phoenix you'll need to actually stop being lazy and learn python

opal plank
#

@opal plank Multiplying string by numbers?
@earnest phoenix any other compiler would screech at you for multiplying different types. number * number

earnest phoenix
#

i am in process of learning python

umbral zealot
#

It would make coding a bot in python a lot easier if you knew the language you were trying to use

earnest phoenix
#

bruh

opal plank
#

It would make coding a bot in python a lot easier if you knew the language you were trying to use
@umbral zealot this

sudden geyser
#

string * number can be helpful

umbral zealot
#

Learning a language while making a bot is bad. Learn the language first, then make bots. Bots are hard.

earnest phoenix
#

i have 3 years experience in c#

split hazel
#

for larger projects i prefer ts since it catches so many more bugs at compile time

earnest phoenix
#

python is ez

sudden geyser
#

for example, Python uses it for repetition

umbral zealot
#

Apparently it's not ez enough for you to make bots

split hazel
#

and intellisense is much more reliable

earnest phoenix
#

Python iz ez yet you still don't know perfectly

umbral zealot
#

so maybe... like... go through a couple python tutorials

earnest phoenix
#

Makes sense

#

i know how to make linearregression in python so i know python

umbral zealot
#

I've been doing JS for 20 years, doesn't make me a C# expert either

earnest phoenix
#

I've been doing JS for 20 years, doesn't make me a C# expert either
@umbral zealot wait how old are oyu

umbral zealot
#

40

opal plank
earnest phoenix
#

i am 14

umbral zealot
#

Great. learn to learn shit

earnest phoenix
#

yes

umbral zealot
#

and stop being an entitled little tyler

opal plank
#

^^

earnest phoenix
#

i need python for my penetration testing course

opal plank
#

go. learn.

earnest phoenix
#

so i am learning it

umbral zealot
#

Great so go learn python, not bots.

earnest phoenix
#

I KNOW python

opal plank
#

copying code here isnt the way to go

#

you clearly dont

split hazel
#

if you knew python you wouldn't be here

umbral zealot
#

No you don't know python.

earnest phoenix
#

bruh

opal plank
#

if you knew python you wouldn't be here

earnest phoenix
#

Why are you learning python if you know python

#

if you knew python you wouldn't be here
@split hazel i know about python but i dont know about discord api ok?

#

🗿

opal plank
#

how is a command handler with cogs related to discord api?

earnest phoenix
#

Why are you learning python if you know python
@earnest phoenix i am practicing it

opal plank
#

if it handles everything ofr you?

earnest phoenix
#

i dont know

opal plank
earnest phoenix
#

ok i am done with discord bots

sudden geyser
#

lol

earnest phoenix
#

i dont care about cooldown

#

its perfect

opal plank
#

AND stubborn

#

yikes

earnest phoenix
#

bye

opal plank
#

o/

#

anyhow, back at TS

earnest phoenix
#

We went from databases to the programming language itself to the library and you want cooldowns but how are we going to help you if you weren't able to get it from the official discord.py server?

opal plank
#

they gone already

earnest phoenix
#

🗿 Why are we hurting our brains in this channel

split hazel
#

peace at last

opal plank
#

i wouldnt even waste time with him tbh, even though im a hypocrite for doing just that

quartz kindle
#

because y'all dumb

#

:^)

crimson vapor
#

hi Tim

opal plank
#

yes, we all dumb

split hazel
#

hi tim you came at the right time before you lost cells

quartz kindle
#

xDD

crimson vapor
#

no hi back?

#

sad

opal plank
#

dont lok at chat history tim

#

source: trust me, im an engineer

earnest phoenix
#

Tim calling us dumb because he didn't lose brain cells before we did

#

Obvious

opal plank
#

not like we'd be better tham him before this convo started anyway

#

tim too big brained

crimson vapor
#

care to explain what happened in that previous conversation that caused you to lose brain cels?

opal plank
#

we are too smoothed brained

#

the usual entitled skid that pops up every now and then that gets triggered because we dont spoonfeed him

#

tldr

crimson vapor
#

oh

#

nice

earnest phoenix
#

Lemme explain you this in a few words

Little tyler that doesn't listen at all

crimson vapor
#

the best is just explaining code in real words

#

so then they have to either beg for code

#

or decipher it

opal plank
#

hence why i love providing snippets in TS for JS users

crimson vapor
#

LOL

opal plank
#

i just wait and bait them to come back asking WHY IT ERRORS??

earnest phoenix
#

We literally told him everything we could mate

quartz kindle
#

lmao

crimson vapor
#

thats so terrible LOL

#

you're bullying them

#

at least give them python

opal plank
#

how dare we give them docs, snippets, databases, free databases, advice and everything else but NOT give gim spoonfed code that he can just copy paste

#

we clearly the bad guys

quartz kindle
#

yes, you are the bed guys

crimson vapor
#

LOL

opal plank
#

bed guys

earnest phoenix
#

bed

opal plank
#

hmmmm

earnest phoenix
#

Seems sus

quartz kindle
#

yes

opal plank
quartz kindle
#

because you put the kid to sleep

opal plank
#

oh my how lewd

crimson vapor
#

tbh not a bad star

opal plank
#

too bad, another 10 minute effort bot that wont see the day of light again

#

im gonna have trouble sleeping tonight

earnest phoenix
#

His brain malfunctioned so hard he fell asleep

opal plank
#

i feel like im being too toxic, imma grab some booze and chill with dem animie ti...tles of very good series

earnest phoenix
#

Weeb

crimson vapor
#

someone needs to make a tutorial on using google

#

and pin it here

#

tbh

#

can you buy .google domains?

earnest phoenix
#

That guy wouldn't even know what a "google" is

crimson vapor
#

because how.to-use.google would be good

earnest phoenix
#

I don't think .google domains even exist

crimson vapor
#

they do iirc

#

unless it is just chrome playing tricks on me

#

nope I don't think it is chrome lying to me

earnest phoenix
#

How do i make a const on python TrollFace

sudden geyser
#

You can't.

#

Nothing can truly be constant in Python.

earnest phoenix
stark abyss
#

this doesn't look like api

crimson vapor
#

const is a javascript keyword lol

stark abyss
#

web scrap maybe idk

earnest phoenix
#

yes

#

scrape the html

#

it's just a table so it isn't hard at all

#

cheerio?

worthy pine
#

@earnest phoenix use any scraper you want to use

drifting wedge
#

Read my nick

#

There you go

crimson vapor
#

@drifting wedge what type of pie is py?

drifting wedge
#

snake pie

crimson vapor
#

hmmm

#

seems like it would taste bad

silver lintel
#
let fetched;
        do {
          fetched = await message.channel.messages.fetch({ limit: 100 });
          message.channel.bulkDelete(fetched)
          .then(async () => {
            let msg = await message.channel.send(":white_check_mark: | Successfully deleted all the messages in <#" + message.channel + ">");
            msg.delete({ timeout: 3000 });
          })
          .catch((err) => {
            message.channel.send("The messages in this channel are too old for me to delete");
          });
        } while (fetched.size >= 2);
``` how can i end the loop if the msgs are too old?
earnest phoenix
#

I need help for canvas not work createLinearGradient, can someone help me ?

drifting wedge
#

whats the pip for googleapiclient?

wicked sapphire
#

How do you check if your bot has a specific perm?

earnest phoenix
#

Read the docs of the lib you're using ig

reef carbon
#

ALTER TABLE Users RENAME TO Test; I'm trying to do this but it says users relation is not found. The table name is Users so I'm not sure why this is happening.

blissful coral
#

What db is that I am curious @reef carbon

reef carbon
#

postgresql

blissful coral
#

K

desert hazel
#

on what?

#

How do i add a custom background to my bots page, plus how to i change the CSS of it ?

#

@blissful coral i did that and it did nothing

pale vessel
#

lol

blissful coral
#
.botimg {
border-radius: 50%
}
desert hazel
#

oh

#

thank you

#

where can i find a list of the supported variables?

pale vessel
#

learn css

desert hazel
#

but the variables will be different due to the site

#

like i wouldnt have been able to know it was .botimg

pale vessel
#

oh, you mean the selectors

desert hazel
#

yes

pale vessel
#

ctrl shift c

#

you'll see the selectors

desert hazel
#

the classes?

pale vessel
#

yes

#

could be IDs or tags too

#

hover over the element

desert hazel
#

yea i see it

#

it was bot-image

#

do i still need the .?

pale vessel
#

yeah

desert hazel
#

because its not changing

pale vessel
#

it actually depends

desert hazel
pale vessel
#

it could be the children

#

what are you changing again?

desert hazel
#

take the white square off

#

so we making the corners rounded

pale vessel
#

ah

#

try .bot-img img

#

it takes the img inside bot-img class

desert hazel
#

nop

#

wait

pale vessel
#

the css only works on your bot page

desert hazel
#

can i change them in the list

#

oh

#

yea i just thought that lmaoo

pale vessel
#

you can't, unfortunately

desert hazel
#

do you know how to change the background of the page?

pale vessel
#

change background-color of the body tag

desert hazel
#

wiat

#

no

#

.body { bgc

pale vessel
#

it's a tag so you need to remove .

#

. is for classes

desert hazel
#

ah

earnest phoenix
#

createLinearGradient is not working In nodejs GRRRRRRR

desert hazel
#

like this?

#

oh its rgba

#

nope

pale vessel
#

both work

#

hmm

desert hazel
#

wasnt changing

pale vessel
#

add a semicolon, just in case

desert hazel
#

where?

pale vessel
#

at the end of background-color

desert hazel
gentle quest
#

Hi people

desert hazel
#

that didnt work

gentle quest
#

What?

silver lintel
#
do {
          fetched = await message.channel.messages.fetch({ limit: 100 });
          message.channel.bulkDelete(fetched)
          .catch((err) => {
            message.channel.send("The messages in this channel are too old for me to delete");
          });
        } while (fetched.size >= 2);
``` how do i stop the loop in the .catch()?
sudden geyser
#

You'd need to use a try/catch block.

#

Wrap the expression in the try {...} catch (err) {...} block, await in the try block for message.channel.bulkDelete(...). You'll catch the error and use break in the catch block.

#

You could expand it to also cover the awaiting you're doing for fetched.

silver lintel
#
let fetched;
        do {
          fetched = await message.channel.messages.fetch({ limit: 100 });
          try {
            await message.channel.bulkDelete(fetched);
          } catch (err) {
            message.channel.send("The messages in this channel are too old for me to delete");
            break;
          }
        } while (fetched.size >= 2);
        message.channel.send(":white_check_mark: | Successfully deleted all the messages in <#" + message.channel + ">")
        .then(msg => msg.delete({ timeout: 3000 }));
``` how do i do it so the message.channel.send("✅ | Successfully deleted all the messages only comes after the do while loop
final token
#

tell dank memer to hire me now

#
let fetched;
        do {
          fetched = await message.channel.messages.fetch({ limit: 100 });
          try {
            await message.channel.bulkDelete(fetched);
          } catch (err) {
            message.channel.send("The messages in this channel are too old for me to delete");
            break;
          }
        } while (fetched.size >= 2);
        message.channel.send(":white_check_mark: | Successfully deleted all the messages in <#" + message.channel + ">")
        .then(msg => msg.delete({ timeout: 3000 }));
``` how do i do it so the message.channel.send("✅ | Successfully deleted all the messages only comes after the do while loop

@silver lintel i think you could do setInterval

silver lintel
#

:||

#

:|

final token
#

idk tbh

silver lintel
#

:/

#

Setinterval sets intervals

final token
#

dank memer should obviously hire me

#

Setinterval sets intervals
@silver lintel lmao i realised that

silver lintel
#

so a function executes after time

final token
#

if u used setinterval it would repeat ever amount of time

silver lintel
#

if u used setinterval it would repeat ever amount of time
@final token spongery

final token
#

im big brain

silver lintel
#

i have do loop

#

it already does that

crimson vapor
#

you could use setTimeout()

#

but it would be better to use a function that loops over it until there are 0 left to delete then send a message

brisk valve
#

hi

clever vector
#

hey developers

crimson vapor
#

show prop.help

earnest phoenix
#

U love it ? Tackerr spotify by me xD

#

cool

sage creek
#

Cool i am noob so i use bot ghost

obsidian escarp
#

Hi

sage creek
#

Hi

obsidian escarp
#

Gilbert

sage creek
#

What?

obsidian escarp
sage creek
#

?

obsidian escarp
#

'-'

sage creek
#

T_T

#

-

#

Y_Y

#

O_O

#

X_X

clever dust
#

why does a url can be accessible with http but not with https? (im using cloudflare and im new to it)

crimson vapor
#

https is secure and has some requirements

#

it normally means it is able to be trusted

delicate shore
#

Btw

#

why does a url can be accessible with http but not with https? (im using cloudflare and im new to it)
@clever dust
You haven't enabled ssl

#

I told you

#

Or it's either at lowest level

#

In cloudfare

#

It should be either at flexible

#

Or strict

#

But not the most strict
Because it won't work

#

As you are using GitHub for hosting that's why

clever dust
#

As you are using GitHub for hosting that's why
@delicate shore i don't

delicate shore
#

Then ?

#

Where are you ?

clever dust
#

at my home

delicate shore
#

Local hosting

#

Then also

#

Don't do the most strict

clever dust
#

i am not

#

im using the flexible

delicate shore
#

Are you sure ?

clever dust
#

yes

delicate shore
#

Hmm wait

gentle quest
#

Hey people

#

All right?

delicate shore
#

Alright I know this is basic JavaScript but I'm gonna ask
I have an array
And for each value of it I need to add a link in descriptionOf the embed Like array has - ['one','two']
So in discord embed in description it adds something like this -
First - one
Second - two

#

Do I need to map them first ?

#

Or what's the scenario

proper bolt
#

array.map(item => item + '\n')

tribal siren
#

i want to do a verification system only for my server

#

code looks like this

#

if(cmd === `${prefix}verifyen`){ if(message.deletable){ message.delete() } let role = message.guild.roles.cache.find(role => role.id === `775390638270578708`); let otherrole = message.guild.roles.cache.find(role => role.id = `775581337976963133`); if(message.guild.id == `775388232233517076`){ try{ message.member.roles.add(role); message.member.roles.remove(otherrole); message.member.send('Thank you for verifying! Enjoy your time in BraceDash!') } catch(err){ const embed = new Discord.MessageEmbed() .setAuthor('Oh no!') .setTitle('An error occured while running this command!') .setDescription(`${err}`) .setColor('RANDOM') .setFooter("DM my Dev to solve the error! (<owner)") .setTimestamp() message.reply(embed) } } else{ return; } }

#

it removes the otherrole

#

but doesn't add the role

#

what should i do in this situation

#

nvm i solved the problem

delicate shore
#

array.map(item => item + '\n')
@proper bolt
Thanks

verbal shore
#

Hello, my bot is Approved in Top.gg But Not Here I wonder why ?

normal sage
#

They stopped inviting bots.

verbal shore
#

why is that

normal sage
#

Discord now allows on 50 bots per server.

verbal shore
#

Okay thanks ❤️

hollow sedge
#

Discord now allows on 50 bots per server.
@normal sage not yet..no official statement either

normal sage
#

Oh ok

proven cliff
#

Hi everyone!

So I was helpfully recommended yesterday to use webscraping for my bot bye another member in this discord. I'm trying to make a discord bot (using discord.py) that would scrape images and text from websites. To be specific, it would scrape recipes from websites such as allrecipes.com or shoutabkhin.com and then display them inside discord.

I was wondering how exactly this would work. Does Discord's API have features for web scraping? Is there a way to do it in python or would I need to use a language such as javascript using discord.js? If anyone has any ideas or knows a helpful guide, it would be greatly appreciated. I've been trying to figure this out but can't find a way to do it. Is there a specific library I need to import? Language I need to use? Method to look into? Any help would be really nice as I can't find anything on this specific topic, since I've never used webscraping before.

hollow sedge
#

You should probably look into the aiohttp module for async webscraping

proven cliff
#

Thanks a lot

earnest phoenix
#

You should probably look into the aiohttp module for async webscraping
@hollow sedge also beautifulsoup

proven cliff
#

and does the website I'm scraping need to be in a certain format/language

hollow sedge
#

You should also look into an API/API wrapper that can just get the recipes with easy usage

earnest phoenix
#

with requests

proven cliff
#

as in can I scrape PHP and HTML websites?

normal sage
#

@proven cliff I’ve seen someone make something like this.

hollow sedge
#

no requests, requests is not async

proven cliff
#

oh

normal sage
#

So you want their discord @?

proven cliff
#

not really cause I'm trying to figure out myself and actually learn how to do it

earnest phoenix
#

no requests, requests is not async
@hollow sedge i use requests for web apis

proven cliff
#

I don't like copy pasting code if I can't replicate it myself organically

#

But thanks for the help guys

#

I'll look into both beautifulsoup and aiohttp

hollow sedge
#

@hollow sedge i use requests for web apis
@earnest phoenix ok, but it shouldn't be used for discord bots

#

As they are async

#

It will block the event loop and everything else will have to wait for it to finish

#

I'll look into both beautifulsoup and aiohttp
@proven cliff they're not mutually exclusive, you would typically use them together

proven cliff
#

oh

#

and would requests work?

hollow sedge
#

It would, but it wouldn't be good to use

proven cliff
#

I see

#

Thanks for all the help guys

#

very much appreciated :D

hollow sedge
#

I hope you find a solution

proven cliff
#

me too lmao

brittle hazel
#

how do i authorize myself? didnt understand properly. Like what does http authorization header mean? (in dbl)

lusty quest
#

you send your API key as a Header with the API request

#

to authenticate yourself to the API

verbal shore
#

Hello, can I ask something

lusty quest
#

there is the rule called dont ask2ask

#

just ask

verbal shore
#

what ?

lusty quest
#

read the channel topic

slender thistle
#

Just ask

pulsar bone
#

hey my foreach code working only once did anyone know why

earnest phoenix
#

provide more context with your issue

pulsar bone
#
{
    if (message.content.startsWith('update')) 
    {
        var channels;  
        channels = message.guild.channels.cache.forEach(gtg => 
        {
         // <Code>
        });
      
    };
  })```
#

it is only working for one channel

vale garden
#

hi

#

message.channel.createMessageCollector(filter, {time: 120000, max: 10 })

#

here

#

like you have max: 10

#

is there anything you can use to find a certain message from 10 messages

#

in py

#

using the bot.wait_for() coroutine

pulsar bone
#

i dont need message collecter
it is for updating permissions

vale garden
#

bruh im asking this for myself

#

lol

#

cuz i need a collector

pulsar bone
#

@earnest phoenix can you help

west oyster
#

Anyone Uses BCFD?

earnest phoenix
#

i need to know what you're doing inside of the forEach

pulsar bone
#

i need to know what you're doing inside of the forEach
@earnest phoenix updating permissions for a role in all channels

earnest phoenix
#

can your bot modify other channels

#

as in, does it hace perms

#

have*

pulsar bone
#

yes

earnest phoenix
#

thonk

pulsar bone
#

it have administrator

earnest phoenix
#

it should work fine

pulsar bone
#

working only once

#

@earnest phoenix help please 🥺

worthy pine
#

@pulsar bone replace var with let

#

maybe try it

pulsar bone
#

nope

#

@worthy pine

rain obsidian
knotty quartz
#

What language do you use?

rain obsidian
#

tr

#

turkey

knotty quartz
#

I mean the coding language

rain obsidian
#

he sorry

#

eng

knotty quartz
#

No like javascript python

earnest phoenix
#

JS?

rain obsidian
#

ı dont use python

knotty quartz
#

It looks like javascript

earnest phoenix
#

That why, what is your coding language?

rain obsidian
#

yeah

earnest phoenix
#

It looks like javascript
Yeah

rain obsidian
#

js

#

my code language eng

knotty quartz
#

Okay

#

@earnest phoenix Can you look at this please this is not the type of JS I use as mine is a database js which changes alot of the script for it to work

earnest phoenix
#

@earnest phoenix Can you look at this please this is not the type of JS I use as mine is a database js which changes alot of the script for it to work
@knotty quartz oke, wait

knotty quartz
#

Thanks

earnest phoenix
#

@rain obsidian can you please screenshot your logs like on terminal?

rain obsidian
#

ok

earnest phoenix
#

you need to declared the variable "args".

rain obsidian
#

Let me write 1 in the args part

earnest phoenix
#

👍

rain obsidian
#

t

#

thx

#

iii didn't work

honest perch
#

Please learn js

rain obsidian
pure lion
#

@rain obsidian show more code

fickle sapphire
#

You should probably remove that last )

ivory seal
#
                let collection = client.users.cache.filter(user=>user.id===`${top5[0].ID.split('-')[1]}`);
                var winner1 = collection.first().tag;
                var winner1msg = top5[0].data;
            }
            if(top5[1]){
                let collection = client.users.cache.filter(user=>user.id===`${top5[1].ID.split('-')[1]}`);
                var winner2 = collection.first().tag;
                console.log(winner2)
                var winner2msg = top5[1].data;
            }
            if(top5[2]){
                let collection = client.users.cache.filter(user=>user.id===`${top5[2].ID.split('-')[1]}`);
                var winner3=collection.first().tag;
                var winner3msg = top5[2].data;
            }
            if(top5[3]){
                let collection = client.users.cache.filter(user=>user.id===`${top5[3].ID.split('-')[1]}`);
                var winner4= collection.first().tag;
                var winner4msg = top5[3].data;
            }
            if(top5[4]){
                let collection = client.users.cache.filter(user=>user.id===`${top5[4].ID.split('-')[1]}`);
                var winner5=collection.first().tag;
                var winner5msg = top5[4].data;
            }
            if(top5[5]){
                let collection = client.users.cache.filter(user=>user.id===`${top5[5].ID.split('-')[1]}`);
                var winner6=collection.first().tag;
                var winner6msg = top5[5].data;
            }
            if(top5[6]){
                let collection = client.users.cache.filter(user=>user.id===`${top5[6].ID.split('-')[1]}`);
                var winner7 = collection.first().tag;
                var winner7msg = top5[6].data;
            }```` so this is my code , top5 is a array from quick.db but it returns this error ``*Cannot read property 'tag' of undefined                                                                                            ``
#

can someone help me?

lusty quest
#

is your collection valid?

ivory seal
#

i mean it is

#

but everytime i restart my vps it becomes invalid

#

then i have to clear all the data on quick.db to get it back working

lusty quest
#

well the collection gets reset every time you restart

#

and the restart seems to corrupt your DB

ivory seal
#

oh

#

what should i do?

lusty quest
#

what host did you use? a paid one or a free one?

ivory seal
#

paid vps

lusty quest
#

good so its not the usuall issue

#

how did you save your users?

ivory seal
#

quick.db is the db

lusty quest
#

yea but how did you collect the data

ivory seal
#

every time they send a message it adds 1 to the key messages-authorid

lusty quest
#

so you get a ton of duplicates

ivory seal
#

oh how?

#

it only adds to the key righ?

lusty quest
#

or did you increment the number by 1

ivory seal
#

i increment the number

#

i don't create new keys

lusty quest
#

ohh yea i know what your issue is. when you restart your VPS the cache gets released

ivory seal
#

what steps should i take then?

lusty quest
#

store the userids and then fetch the winner

#

fetch will get him back into the cache and then you can use .tag

ivory seal
#

it is stored?

#

its stored and then when a command is called it fetches the winners

lusty quest
#

yes you get it from the cache. the cache will only give you the userid not the full userobject

#

bcs the user is not cached after a restart

ivory seal
#

ah ok so u want me to save the user instead of its id righ?

lusty quest
#

no you store the id then fetch the user to get the userobject

ivory seal
#

thats what i do?

lusty quest
#

fetch(userid)

ivory seal
#

oh i use fetch?

#

kk give me asec

#

i used get

lusty quest
#

fetch will only for for single users iirc

#

it also dont use the cache

ivory seal
#

give me a sec

lusty quest
#

after you fetched the user once you can use the cache normally

ivory seal
#

ah ok

#

give me a sec

reef mantle
#
if(message.content.startsWith(prefix + "purge")
let amount = parseInt(args[0])
if(!message.member.hasPermission("MANAGE_MESSAGES")) {
return message.channel.send(`You do not have perms`)
}
if(!amount) {
return message.channel.send(`Specify amount`)
}
if(isNaN(amount)) {
return message.channel.send(`Valid amount`)
}
message.delete()
message.channel.bulkDelete(amount, true)```
#

what is wrong in this guys?

lusty quest
#

what did you want to accomplish?

reef mantle
#

see now

lusty quest
#

did you get an error?

reef mantle
#

nah

#

it just does not work

lusty quest
#

also you dont need 2 message delete. iirc use your amount + 1 to remove also the command message.

reef mantle
#

where bro?

lusty quest
#

its just a notice not important for now

reef mantle
#

oh

#

but can you find the error in it?

lusty quest
#
await msg.channel.messages.fetch({ limit: amount + 1}).then(messages => { // Fetches the messages
    msg.channel.bulkDelete(messages // Bulk deletes all messages that have been fetched and are not older than 14 days (due to the Discord API)
)});
#

did you tryed something like this?

#

there are some API limitations. max 2 weeks old and max 100 messages

reef mantle
#

nah

#

so where should i put it?

#

tel me pls

lusty quest
#

did you know how to write stuff in js?

reef mantle
#

i mean yes

#

but i am still an average

#

i never wrote stuff with await

lusty quest
#

then you should know where this 2 lines of code go

reef mantle
#

what does await do btw?

lusty quest
#

this makes it async -> waits for it to complete

reef mantle
#

oh

#

so where should i put your code?

lusty quest
#

read your code and compare whats different

#

(we are here not allowed to spoonfeed)

reef mantle
#

ok so spoonfeed me in dm

#

lol jk

lusty quest
#

i dont do DMs bcs people expect more there

reef mantle
#

oh

#

np

#

but thnx for the help

stiff walrus
#
const Discord = require('discord.js');
const client = new Discord.Client();

const config = require('../config.json')
const command = require('./command')

client.on('ready', () => {
    console.log('The client is ready!')

    command(client, 'ping', message => {
        message.channel.send('Pong!')
    })
})```

so for couple days i getting that error 'cannot find module discord.js' but i installed so many times, 
```js
const Discord = require('discord.js');
const client = new Discord.Client();```
i already did this but same error... i need a help
lusty quest
#

did you ran npm install discord.js?

stiff walrus
#

yes

lusty quest
#

delete the node_modules folder and run npm install. this will delete all installed modules and installs them again

#

this helps sometimes

stiff walrus
#

okay

lusty quest
#

did you moved the folder?

stiff walrus
#

nope

#

i was moving

lusty quest
#

dont move. delete

#

you will download them anyways

stiff walrus
#

still same

#

error

lusty quest
#

delete the node_modules folder.

#

then install again.

#

then you got still the error?

stiff walrus
#

npm i discord.js?

lusty quest
#

no npm install

#

this will install all modules listed in the package.json

stiff walrus
#

PS C:\Users\Lenovo\Desktop\command> node index.js
internal/modules/cjs/loader.js:883
throw err;
^

Error: Cannot find module 'discord.js'
Require stack:

  • C:\Users\Lenovo\Desktop\command\index.js
lusty quest
#

hmm try npm remove discord.js
then npm install discord.js

stiff walrus
#

ready okay

#

it worked

#

thanks

vale garden
#

hi

#
async def spawn(caught):
         if caught == False:

          msg = await bot.wait_for('message', check = check)
          
          if "p!c" in msg.content.lower():

           if msg.content.lower() == f'p!c {pkmn_list[rand_no][0]}':
 
            await message.channel.send(f"Congratulations {msg.author.mention}! You caught a {pkmn_list[rand_no][1]}!")
            caught = True
            return True

           else: 

            await message.channel.send("That is the wrong pokémon!")
            caught = False
            await spawn(caught)
          
          else:
            await spawn(False)

        def check(m):
         return caught == False

        while await spawn(caught) == True:
         caught = True
#

i have all of this

#

and shouldnt the value of caught become True as per the last line.. if first it goes into an else block in def spawn() which recurses it causing it to end up becoming true when it goes into the if block

#

cuz if it goes into an else block even once it does not change from False to True ever

#

plz help

lusty quest
#

py?

eternal osprey
#

hey guys

#
const name = getName(raid.pokemon_id);
                                    const lat1 = raid.lat.substring(1);
                                    const lng1 = raid.lng.substring(1);
                                    
                                    console.log(name, + "\n" + raid.gym_name, + "\n" + lat1, + "\n" + lng1);
                                    return `${lat1}, ${lng1}\n`
                                           + `**${raid.gym_name}**` + "\n"
                                           + `**Raid level: **${raid.level}  |  ${name}  |  **Pokemon Cp: **${raid.cp}\n`
                                           + `**Egg Spawn Time: ** ${getFormattedTime(raid.raid_spawn)}\n`
                                           + `**Raid Start Time: **${getFormattedTime(raid.raid_start)} | **Raid End Time: **${getFormattedTime(raid.raid_end)}\n`
                                           + `http://www.google.com/maps/@${lat1},${lng1},6z`
                                           
                               });
                               
      const reactionEmoji1 = message.guild.emojis.cache.find(emoji => emoji.name === 'valor');
      const reactionEmoji2 = message.guild.emojis.cache.find(emoji => emoji.name === 'mystic');
      const reactionEmoji3 = message.guild.emojis.cache.find(emoji => emoji.name === 'instinct');
      
      if (timer !== null)
      {
        clearInterval(timer)
      }

      timer = setInterval(async ()=>{
        if (responses.length > 0)
        
        {
          let msg = await message.channel.send(responses.shift());
          await message.channel.send(exampleEmbed);``` as you see lat1 and lng1 and even the embed are defined outside the scope they are called in. How do i fix it?
#

as of now, it is saying lat1 lng1 undefined

lusty quest
#

where did you get the error?

eternal osprey
#

in the .setDescription

#

as lat1 and lng1 are defined outside the scope they are called in

#

but how should i approach this problem?

lusty quest
#

i dont see anywhere .setDescription

#

set it at a higher scope or use var, but var is not really the thing you want. you could also use a function

eternal osprey
#
console.log(name, + "\n" + raid.gym_name, + "\n" + lat1, + "\n" + lng1);
                                    return `${lat1}, ${lng1}\n`
                                           + `**${raid.gym_name}**` + "\n"
                                           + `**Raid level: **${raid.level}  |  ${name}  |  **Pokemon Cp: **${raid.cp}\n`
                                           + `**Egg Spawn Time: ** ${getFormattedTime(raid.raid_spawn)}\n`
                                           + `**Raid Start Time: **${getFormattedTime(raid.raid_start)} | **Raid End Time: **${getFormattedTime(raid.raid_end)}\n`
                                           
                                           
                               });
                               
      const reactionEmoji1 = message.guild.emojis.cache.find(emoji => emoji.name === 'valor');
      const reactionEmoji2 = message.guild.emojis.cache.find(emoji => emoji.name === 'mystic');
      const reactionEmoji3 = message.guild.emojis.cache.find(emoji => emoji.name === 'instinct');
      const exampleEmbed = new Discord.MessageEmbed()
      .setColor('RANDOM')
      .setDescription(`[Google Maps](http://www.google.com/maps/@${lat1},${lng1},6z)` + " | " +  `[Apple Maps](https://www.apple.com/maps/?daddr=${lat1},${lng1})`)
      .setFooter("Command Created For Pokehub!") 
      
      if (timer !== null)
      {
        clearInterval(timer)```
lusty quest
#

var ignores the scope

eternal osprey
#

sorry for my clumsiness

#

ah okay that is great to hear

#

but is var not static?

lusty quest
#

const is also static?

#

var is more or less deprecated but still there to keep older software working

eternal osprey
#

hmm okay great!

vale garden
#

py?
@lusty quest yea

eternal osprey
#

thanks

lusty quest
#

cant help you with py @vale garden

vale garden
#

oof ok

eternal osprey
#

@vale garden i can.

#

what is the problem

vale garden
#

hi

#

well my problem was fixed

#

but i have another question

#
@bot.command()
async def pick(cmd, choice = None):
    pokemon_choices = ('Charmander', 'Squirtle', 'Bulbasaur')
    if choice.lower() in pokemon_choices.lower():
      
#

i have all of this

#

to check if the any element of the set pokemon_choices in all lowercase is equal to arg1 in all lowercase

#

now if that is true

#

how can i find the index of the arg1 in the pokemon_choices set

#

@eternal osprey

#

that is my question

eternal osprey
#

use case statements

vale garden
#

wdym

#

yea ik i can check it like that but is there a quick way

#

to just get the index

#

lol

eternal osprey
#

okay sorry mister.

#

just gave an option.

earnest phoenix
#

why don't you use dict? with the pokemon names being the keys

#

also that is tuple, not set

stable eagle
#
    const prefixes = ['<', '/', '%']
prefixes.forEach(async prefix => {
//rest of code
})

My bot responds 3 times because of the prefix being an array, is there a way to fix that?

earnest phoenix
#

just use index method to get the index of it, pokemon_choices.index(choice.capitalize())

#

guys

#

i jsut solved the problem

#

i listened to you and actually read the code

#

and it was easy

#

YES

#

now i can publish my bot

stable eagle
#

wait imma try a for loop

pure lion
#
        msg.guild.member(person).kick().catch(() => {
            return msg.channel.send(`I could not kick ${person}`)
        }).then(() => {
            if (msg.guild.member(person)) return;
            else return client.emit("newcase", {
                type: "kick",
                channel: msg.channel,
                offender: person,
                timestamp: msg.createdTimestamp,
                reason: reason ? reason : "No reason provided"
            });
        });
```this code is supposed to try to kick a member and then check if theyve been kicked, if they have then emit newcase to the client but it doesnt emit even if the person is kicked
#

it works for my ban which has virtually the same code

fickle sapphire
#

Kick doesn't use a reason for standard

pure lion
#

w

glossy dragon
#

I have a question: I want to programm a python discord bot but get_all_members doesn't really work anymore

#

for member in client.get_all_members(): print(member)

#

´for member in client.get_all_members():
print(member)´

earnest phoenix
#

have you enabled member intent?

pure lion
#

^

glossy dragon
#

I dont know

#

Where is that

stable eagle
#

On discord developer portal

#

your bots settings

earnest phoenix
glossy dragon
pure lion
#

give it a couple mins

earnest phoenix
#

open the link, you gotta pass Intents object with members set to True to intents kwarg of discord.Client or any class that inherits it

glossy dragon
#

Ohh I found the solution! I only turned on the Presence Intent to and now everything workes fine. Thank you for your help and time👍

open the link, you gotta pass Intents object with members set to True to intents kwarg of discord.Client or any class that inherits it
@earnest phoenix

pure lion
#
        msg.guild.member(person).kick().catch(() => {
            return msg.channel.send(`I could not kick ${person}`)
        }).then(() => {
            if (msg.guild.member(person)) return;
            else return client.emit("newcase", {
                type: "kick",
                channel: msg.channel,
                offender: person,
                timestamp: msg.createdTimestamp,
                reason: reason ? reason : "No reason provided"
            });
        });
```this code is supposed to try to kick a member and then check if theyve been kicked, if they have then emit newcase to the client but it doesnt emit even if the person is kicked

lemme just bring it back here so its annoying everyone else

silver lintel
#
let fetched;
        do {
          fetched = await message.channel.messages.fetch({ limit: 100 });
          try {
            await message.channel.bulkDelete(fetched);
          } catch (err) {
            message.channel.send("The messages in this channel are too old for me to delete");
            break;
          }
        } while (fetched.size >= 2);
        message.channel.send("✅ | Successfully deleted all the messages in <#" + message.channel + ">")
        .then(msg => msg.delete({ timeout: 3000 }));
``` how do i do it so the message.channel.send("✅ | Successfully deleted all the messages only comes after the do while loop
vale garden
#

why don't you use dict? with the pokemon names being the keys
@earnest phoenix oh yea thats a good idea

#

thx

pure lion
#

sdoighsdoihsoighf

silver lintel
#

@pure lion put .then() before the .catch()

pure lion
#

it didnt emit

#

still banned tho

#

it worked

#

@silver lintel tank c:

silver lintel
#

Np

#

If you think about it, catching catches he problem, but then will run after

pure lion
#

also it wont read when someone joins and leaves, im assuming i need an intent

silver lintel
#

But if you do then before, it will catch

pure lion
#

If you think about it, catching catches he problem, but then will run after
ohhhhhh sgbjjiksdgh noted

lusty quest
#

yea joining leaving needs an intend

pure lion
#

so catch always goes at the end

#

yea joining leaving needs an intend
alr

#

whats the name in so i can add it in the bot files

silver lintel
#

Go to discord Dev portal

#

And go to bot

pure lion
#

server members added

#

alright so

#
const client = new discord.Client({ws: {intents: ["GUILD_MEMBERS"]}});
```i did that
#

and now kick doesnt work

#

the message event broke

stable eagle
#
    const prefixes = ['<', '/', '%']
prefixes.forEach(async prefix => {
//rest of code
})

My bot responds 3 times because of the prefix being an array, is there a way to fix that?

pure lion
#

@stable eagle what is rest of code

stable eagle
#

Uh, well executing command

pure lion
#

youre executing the command 3 times

stable eagle
#
    const commandName = args.shift().toLowerCase();

    const command = client.commands.get(commandName)
        || client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName));

    if (!command) return;

try {
    return command.execute(message, args)
} catch(err) {
errembed.setDescription(err)
        message.channel.send(errembed)
}```
pure lion
#

yeah it executes it 3 times

stable eagle
#

I dont see why tho

silver lintel
#

Command.executr(message, args)

#

You're doing that 3 times

pure lion
#

just do

if (prefixes.some(p => msg.content.startsWith(p))) {
  // execute command
}```
silver lintel
#

^

pure lion
#

can someone tell me why my message event broke when i enabled the guild members event

silver lintel
#

You would literally only have to change one line of code

pure lion
#

which

silver lintel
#

Sorry talking to Milo

pure lion
#

ah

stable eagle
#

no

ripe lion
#

join pls

pure lion
#

@weak parrot h

ripe lion
#

no firends to play with

weak parrot
#

Not really the server for that

ripe lion
#

join pls

weak parrot
#

Dude

pure lion
#

lmao

weak parrot
#

Stop posting it here

#

Like I said

#

Not the server for that

pure lion
#

or the channel for that matter

weak parrot
#

Channel doesn't matter just not this server in general

pure lion
#

so yeah can someone help me, the message event just broke

#

because i enabled the GUILD_MEMBERS thing™️

outer perch
#

does anyone have a tip for multilanguage support in bots?

#

like a DIY guide or anything?

silver lintel
#

Well you can have a database storing langs for the guild

#

And have diff langs

outer perch
#

the problem is how do I have the other languages

#

I know that C/P'ing the code but with another language is dumb

restive furnace
#

uhh code

#

probably most of the users are uncached or something

#

and ur fetching every single one

fickle sapphire
#

Oof

restive furnace
#
  • that loop isn't asynchronous
west oyster
#

How can I set the permission my bot need

silver lintel
#

In oauth2

west oyster
#

Ok

restive furnace
#

try asynchronous loops

#

smth like this ```js
async function processArray(array) {
array.forEach(async (item) => {
await func(item);
})
console.log('Done!');
}````

#

async

#

instead of sync

pure lion
#

can someone help me with my bot, i enabled the guild members intent and it works, but the message listener seems to have stopped working

fiery canyon
#

For discord api requests, is it 50/1s per client, or 50/1s per shard

pale vessel
#

smth like this ```js
async function processArray(array) {
array.forEach(async (item) => {
await func(item);
})
console.log('Done!');
}````
@restive furnace this wouldn't even work

#

you can't use async in forEach(), you need a for loop

pure lion
#

For discord api requests, is it 50/1s per client, or 50/1s per shard
not sharding, the bot is is one server

earnest phoenix
#

@low orbit

#

you might have to get it from id unfortunately, but im not an expert in mongodb

#

oh nice lool

stable eagle
#

Does anyone know an api which retrieves famous people? Like, their name, birthdate etc.

earnest phoenix
stable eagle
#

ty

earnest phoenix
#

np

neon heart
#
var output = await message.channel.send(`\`\`\`js\n${clean(code).replace(client.token, "-")}\n\`\`\``)
      await output.react('❎')
      const filter = (reaction, user) => user.id !== message.client.user.id && user.id === message.author.id;
      var collector = output.createReactionCollector(filter, {time: 60000});
      collector.on("collect", (reaction, user) => {
        if (collector && !collector.ended) collector.stop();
        switch (reaction.emoji.name) {
          case "❎":
            reaction.users.remove(user).catch(console.error);
            output.delete()
            break;

          default:
            reaction.users.remove(user).catch(console.error);
            break;
        }
      });
      collector.on("end", () => {
        output.reactions.removeAll().catch(console.error);
      });

error DiscordAPIError: Unknown Message method: 'delete',

#

wrong in output.delete()?

earnest phoenix
#

it's trying to remove all the reactions although the message doesn't exist anymore

#

that's why it says unknown message

neon heart
#

ohh

#

then i must remove reactions.users.remove(user).catch()?

pure lion
#

yeah so the message event still doesnt fire on message

#
const client = new discord.Client({
    ws: {
        intents: ["GUILD_MEMBERS", "GUILD_MESSAGES"]
    }
});
```here are my intents
#

also i have the GUILD_MEMBERS intent enabled

#

and the bot is in one server only

pale vessel
#

nothing appears in console?

pure lion
#

yeah

#

also i fixed it

opal plank
#

am i the only lazy one that did Intents.ALL?

#

i feel bad now

vague imp
#

@pure lion you don't need to mention them in current version

pure lion
#

yeah i realised

vague imp
#

Discord api v6 don't need them to be mentioned

#

Once they shift to V8 then maybe we need to mention it

pure lion
#

can someone remind me how to send files without using the MessageAttachment constructor

#

welcomeChannel.send({attachment: { something like thi-

pale vessel
#

send({ files: [{ attachment: <Buffer>, name: "image.png" }], embed: { image: { url: "attachment://image.png" } } });

pure lion
#

ah

#

i had it the wrong way

tired panther
#
TypeError: Cannot read property 'id' of undefined
    at Object.execute (C:\Users\shahn\3D Objects\Botcode\sharding\commands\rolesetup.js:49:19)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
Unhandled promise rejection: TypeError: Cannot read property 'id' of undefined
    at Object.execute (C:\Users\shahn\3D Objects\Botcode\sharding\commands\rolesetup.js:49:19)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)

why does this happen?

let trole = await message.guild.roles.cache.find(role => role.name.includes(`ME`));
console.log(trole.id);
if(trole){
return message.channel.send("back")}
message.guild.roles.create({ data: { name: 'ME', permissions: ['VIEW_CHANNEL'], mentionable: true } });
trole = await message.guild.roles.cache.find(role => role.name.includes(`ME`));
``` the first times it works, the second times, does not work
#

and it works in my first server, but not in my seconf server

midnight blaze
#

@pale vessel ```js
async function processArray (array) {
let files = [];
await files.push(array)

for await (const contents of files) {
console.log(contents)
}
}

processArray([2,3,4,5,5])

this could work, right?
pale vessel
#

why await the push

#

but yes, i think so

midnight blaze
#

there more await the better 🤷‍♂️

pale vessel
#

it will probably just log the array itself lol

regal creek
#
TypeError: Cannot read property 'id' of undefined
    at Object.execute (C:\Users\shahn\3D Objects\Botcode\sharding\commands\rolesetup.js:49:19)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
Unhandled promise rejection: TypeError: Cannot read property 'id' of undefined
    at Object.execute (C:\Users\shahn\3D Objects\Botcode\sharding\commands\rolesetup.js:49:19)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)

why does this happen?

let trole = await message.guild.roles.cache.find(role => role.name.includes(`ME`));
console.log(trole.id);
if(trole){
return message.channel.send("back")}
message.guild.roles.create({ data: { name: 'ME', permissions: ['VIEW_CHANNEL'], mentionable: true } });
trole = await message.guild.roles.cache.find(role => role.name.includes(`ME`));
``` the first times it works, the second times, does not work

@tired panther the ME role doesnt exist

pale vessel
#

can you show a screenshot of the role?

#

and you don't need await for cache.find(), what is it with you people and await lmao

regal creek
#

They're awaiting life kekw

tribal siren
#
      await reaction.message.guild.members.cache.get(user.id).roles.add('777041754268368917');
    }
    if(reaction.emoji.name === '🎮'){
      await reaction.message.guild.members.cache.get(user.id).roles.add('777041546787815424');
    }
    if(reaction.emoji.name === '777164612197941288'){
      await reaction.message.guild.members.cache.get(user.id).roles.add('777162743382933504');
    }
    if(reaction.emoji.name === '🎁'){
      await reaction.message.guild.members.cache.get(user.id).roles.add('777162589095723018');
    }
    if(reaction.emoji.name === '777165284418387988'){
      await reaction.message.guild.members.cache.get(user.id).roles.add('776353743155232778');
    }```
#

why does it only work with the default emojis?

lusty quest
#

bcs the default emojis are unicode. custom emojis are a little bit annoying to work with

#

and you look for emoji name not id

tribal siren
#

oh

#

oooooh

#

ok thank you

outer perch
#

I programmed a shop in my bot, but with the categories and pages it has, it now takes 1-2 secs. to answer, cuz I have it all in shop.js
any tips to reorganize it?

lusty quest
#

offload it to a website.

#

or maybe use more efficent code

outer perch
#

I am using a lot of Switches

#

I have an online DB, but I am using a .json for the shop items so I don't overuse the DB

lusty quest
#

yea thats the issue i guess

outer perch
#

the problem is

lusty quest
#

json is slow

outer perch
#

I don't pay for the host, neither the DB

lusty quest
#

rip

outer perch
#

got no money for that yet

lusty quest
#

what db did you use? Mongo?

outer perch
#

Free Plans all over the place

#

Firebase

molten yarrow
#

cache it

lusty quest
#

^

outer perch
#

cache what

#

the shop pages?

lusty quest
#

your Shop items

molten yarrow
#

all your items from json

outer perch
#

I'm not used to caching, I only used it for prefixes

#

and it was simple

molten yarrow
#

its the same

lusty quest
#

you just store values in the cache there is no real difference

outer perch
#

the load time increased since I added pages actually

#

not the items

lusty quest
#

how is you strategy for reading the Json file?

outer perch
#

let me give you a snippet

tired panther
#

How do u request if a web site link is there? I mean if it exists?

lusty quest
#

you want to check if a URL is valid?

tired panther
#

yes

lusty quest
#

@outer perch use hastebin for a ton of code

earnest phoenix
#

you need to make a request to the url to check if it's valid

outer perch
#
case 'cores':
petHudColorsEmbed = new MessageEmbed(mainEmbed)
.setTitle('Loja Incrível - PetHUDs (Cores)')
.setDescription(`\`${prefix}shop buy pethud [Nome do Item]\` para comprar ou \`${prefix}shop view pethud [item]\` para ver.`)
.setFooter('Página 1 de 1')
.spliceFields(0, mainEmbed.fields.length, [
{ name: 'Black', value: `Preço ¤${items.petHuds.black.price}`, inline: true },
{ name: 'Blue', value: `Preço ¤${items.petHuds.blue.price}`, inline: true },
{ name: 'Brown', value: `Preço ¤${items.petHuds.brown.price}`, inline: true },
{ name: 'Green', value: `Preço ¤${items.petHuds.green.price}`, inline: true },
{ name: 'Orange', value: `Preço ¤${items.petHuds.orange.price}`, inline: true },
{ name: 'Pink', value: `Preço ¤${items.petHuds.pink.price}`, inline: true },
{ name: 'Purple', value: `Preço ¤${items.petHuds.purple.price}`, inline: true },
{ name: 'Red', value: `Preço ¤${items.petHuds.red.price}`, inline: true },
{ name: 'Yellow', value: `Preço ¤${items.petHuds.yellow.price}`, inline: true },
]);
Message.channel.send(petHudColorsEmbed);
break;
lusty quest
#

use node-fetch as example and call the URL, if you get a valid return it exist, if it errors out the URL is invalid

outer perch
#

it's in 🇵🇹 some of it

#

my .json is built-in

#

items is a require of the .json

lusty quest
#

yea cache your json will probably help. each field will call the json

molten yarrow
#

yep true

outer perch
#

so require doesn't cache?

lusty quest
#

not really

outer perch
#

yikes

#

I thought so

lusty quest
#

wait nvm require caches

#

A better approach would be to instead use a combination of fs.watch, fs.readFile and JSON.parse to reload the changing data. No need to fiddle with the cache or restart the server.

An even better approach would probably be to use a database of some sort instead of the filesystem.```
outer perch
#

so the problem here may be the amount of Switches and Cases it has

lusty quest
#

how did you make the pages change? i use it in one of my bots and its fine there

#

but i also use a Paid Host and run a Database on a 2nd Paid host

outer perch
#

edits are triggered by the commands

#

case 'page/category'

#

edit:

lusty quest
#

so you use commands to show new pages?

#

the bot goes online on discord?

#

then the bot is online

#

or did you want stuff like uptime?

#

js?

#

client.guilds.cache.size()

#

will only update when the bot restarts

wicked pivot
#

hi, i just did something that gives the position to happen. but I would like to do more and have something that gives the name of the user who joined before and after how to do

function getJoinMember(ID, guild) {
        if (!guild.member(ID)) return;
    
        let arr = guild.members.cache.array();
        arr.sort((a, b) => a.joinedAt - b.joinedAt);

        for (let i = 0; i < arr.length; i++) {
          if (arr[i].id == ID) return i;
        }
    }```
strong fractal
#

Guys, I wanted to ask about your opinion...

#

I want to make my bot multilingual

#

So it supports 2 languages

#

Is it a good way to just make 2 different command for one, but in different languages?

honest perch
#

make a json file

strong fractal
#

I don’t want to store data

#

Idk why XD

honest perch
#

then that will be hard

#

most just make a json file with phrases

strong fractal
#

Oof

honest perch
#

like

{
"WELCOME_MESSAGE": "Welcome message here",
}
strong fractal
#

That’s dict

#

But...

#

What I mean is

#

Command /help

#

And command /хелп (the same but in another language)

#

They work same

#

But they have different phrases

#

Maybe not the best way

#

But I want these 2 commands work at the same time properly

honest perch
#

again i suggest doing configs

#

and just doing aliases for commands

strong fractal
#

But aliases work the other way?

#

Like they are just different names for one same command

vale garden
#

hi

honest perch
#

Like they are just different names for one same command
@strong fractal yes and its easier to do aliases then have loads of commands

#

much better to maintain and organise

vale garden
#

im new to py.. and i have this question

#
list = [[1, 2, 3], [2, 4, 6], [3, 6, 9], [4, 8, 12]]
#

if i have something like this

pale vessel
strong fractal
#

@vale garden 4 lists in a list

vale garden
#

yep

#

ik

#

so does anyone know, how i can make a new list out of the first terms of each of the inner lists

strong fractal
#

@honest perch I have no idea how can I work with json etc to make it support 2 languages

#

XD

honest perch
#

get the users language from the database

#

and then use the correct json file

earnest phoenix
#

C:\Users\nsapo\OneDrive\Desktop\Bot\Revange-Bot>npm run dev

Revange-Bot@1.0.0 dev ``C:\Users\nsapo\OneDrive\Desktop\Bot\Revange-Bot
nodemon ./src/bot.js

'nodemon' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! Revange-Bot@1.0.0 dev: nodemon ./src/bot.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the Revange-Bot@1.0.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\nsapo\AppData\Roaming\npm-cache\_logs\2020-11-14T16_24_52_937Z-debug.log

#

help ?

vale garden
#

does anyone have the answer to my ques?

strong fractal
#

@honest perch users language must be set by an owner of a server?

#

Or smth

pale vessel
#

you want the first term?

#

you mean first item?

strong fractal
#

First term of each list?

#

Does somebody in here have a good example of a code of multilingual bot?

#

Like it’s hard XD

earnest phoenix
#

help ?

pale vessel
#

Like it’s hard XD
@strong fractal nah

honest perch
#

like this

const userlang = //somehow get the user language from a db
const en = require('./data.json')
message.channel.send(`${userlang}`.WELCOME_MESSAGE);
strong fractal
#

I use python :(

#

Not js

#

Oof

honest perch
#

something like that but i doubt the syntax works

pale vessel
#

you can use dicts```py
langs = {
"en": {
"welcome": "Welcome"
},
"ja": {
"welcome": "ようこそ!"
}
}

lang = langs["en"]
print(lang["welcome"]) # Welcome```

strong fractal
#

But...

pale vessel
#

"en" would be the user language that you fetch from your database/cache

strong fractal
#

I have never dealt with a database in discord.py before XD

#

Wai

pale vessel
#

you should get started on that first then

#

take it slowly xd

strong fractal
#

Soo...

honest perch
#

i suggest mongodb for things like this

strong fractal
#

Should I store a language for servers or for users?

pale vessel
#

depends

strong fractal
#

For servers I believe?

#

If it’s not dm

pale vessel
#

users can take quite a space

#

servers are easier to maintain and only take one document for every server

honest perch
pale vessel
#

pymongo is a good one, i heard

#

not sure since i don't code in python

#

if shivaco has time, he can probably help you with mongo

#

best not to disturb him though

strong fractal
#

Yes

#

@pale vessel I am so Thonk Thonk Thonk

#

Is it ok if I just stick with writing different commands with just dame languages

#

Then I will try to use a json with dictionaries in one command?

honest perch
#

Is it possible to send a message to the owner guild when the bot joined the server ?
@sand dune guildCreate event

finite grove
#

fuck

#

fuck

#

fuck

wicked pivot
#

how can i have the number of file in a folder with fs?

lusty quest
#

@raw stream try reinstalling the module that is breaking

#

if this doesnt work make sure the Build tools are installed and install the module that is breaking again

pale vessel
#

@sand dune owner should be guild.members.cache.get(guild.ownerID) but i recommend fetching it: const owner = await guild.members.fetch(guild.ownerID) (your function needs to be async)

#

how can i have the number of file in a folder with fs?
@wicked pivot you can use fs.readdirSync(path).length

#

it's guild.members, not guild.users @sand dune

strong fractal
#

@sand dune ?

#

Is it ok if I just stick with writing different commands with just different languages
?

#

Then I will try to use a json with dictionaries in one command?
?

#

Sorry wrong person XD

pale vessel
#

@earnest phoenix use `, not '

slender thistle
#

Ok

wicked pivot
#

@wicked pivot you can use fs.readdirSync(path).length
@pale vessel thx

pale vessel
slender thistle
#

so does anyone know, how i can make a new list out of the first terms of each of the inner lists
@vale garden so out of that 4D you want a one dimension list like [1,2,3,4,5,6,7,8,9]?

#

or

#

oh

pale vessel
#

just flat it or something

slender thistle
#

[1,2,3,4]?

pale vessel
#

what library?

#

for discord.js it's guildDelete

novel kelp
#

guys do you know how can i get video thumbnail with ytdl-core

#

i cant get it can you help me

vale garden
#

@vale garden so out of that 4D you want a one dimension list like [1,2,3,4,5,6,7,8,9]?
@slender thistle yes i did

#

but i ended up figuring it out lol

slender thistle
#

well yee haw

#

thanks for being able to figure it out on your own