#development

1 messages · Page 933 of 1

unique nimbus
#

I am not being toxic

turbid bough
#

@earnest phoenix might be forgetting an await?

#

or its not in an async function?

earnest phoenix
#

k i stored it in a var

lyric mountain
#

do you know how to access an array?

turbid bough
#

ok, now create a random integer from the length of the variable

vivid crescent
turbid bough
#

or that

earnest phoenix
#

i do not know how to access an array

#

wait

vivid crescent
#

Read that link

earnest phoenix
#

i think i do but im not sure

vivid crescent
#

Thaun it doesn't matter if we spoonfeed

unique nimbus
#

Let's not spoonfeed

vivid crescent
#

they won't realize the feed is there

#

so

turbid bough
#

we probably gonna waste even more time explaining him how to create an embed while accessing all the data his result is giving

lyric mountain
#

he's almost getting the first fish, stay strong guys

earnest phoenix
#

at least i know how to make an embed

vivid crescent
#

You know how to make an embed but not access arrays¿

earnest phoenix
#

kk now "for" gives me invalid syntax error message

turbid bough
#

if you watched like a youtube tutorial, wouldnt arrays be like on episode 2

pale vessel
#

probably one

turbid bough
#

you do not need a for loop

earnest phoenix
#

@turbid bough and where is the fault

turbid bough
#

idk have yet seen your code

earnest phoenix
turbid bough
#

you cant store a for loop in a variable

earnest phoenix
#

@turbid bough sent to?

#

well then change for to what?

#

no that came out wrong

turbid bough
#

just the reddit.subreddit

#

@earnest phoenix idk?

#

you just posted an error

earnest phoenix
#

"name reddit is not defined" go this after debugiing

turbid bough
#

uuh, how does your code look again?

lyric mountain
#

the whole code, if possible

earnest phoenix
vivid crescent
#

defaultfurret did you have a reddit api?

earnest phoenix
#

yes i do

#

i have set that up

turbid bough
#

idk you havent require'd it probably oh wait its python lol

vivid crescent
#

check the imports

turbid bough
#

so many js devs im beginning to confuse python with js

warm karma
#

I’ve used this before

#

so many js devs im beginning to confuse python with js
I’m the opposite lol

earnest phoenix
#

@vivid crescent i have praw as import

#

Hi

vivid crescent
#

you're gonna need to import reddit

earnest phoenix
#

i have

turbid bough
#

isnt it possibly praw.subreddit then?

vivid crescent
#

^

warm karma
#

I think it’s another library

#

Yeah, praw

turbid bough
#

ah nvm

#
import praw

reddit = praw.Reddit(client_id="my client id",
                     client_secret="my client secret",
                     user_agent="my user agent")```
earnest phoenix
#

module praw has no attribute to subreddit

#

yes i got that haun

#

thaun*

#

isnt it possibly praw.subreddit then?
@turbid bough no

warm karma
#

Wait

#

It’s reddit.Subreddit

turbid bough
#

docs dont say so

warm karma
#

You use the reddit variable you declared

#

Really?

vivid crescent
#

did you make reddit a global variable

earnest phoenix
#

yes but reddit also has no attribute to subreddit

warm karma
#

Oh

turbid bough
#

have you initialized reddit?

#

if so, can i see it?

#

obviously hiding the keys

earnest phoenix
#

yeah sure 1 sec

turbid bough
#

btw, if you have reddit initialized in another python file, you would need to import the other python file too

clear wraith
#

Error: Could not locate the bindings file.
I Tried to see wtf it wanted.... But i couldn't figure it out. Any suggestions on what I should do/be looking for?

earnest phoenix
vivid crescent
#

reddit needs to be above

turbid bough
#

yeah you need to do the reddit = stuff before you do reddit.subreddit

lyric mountain
#

lol that's very poorly hidden

earnest phoenix
#

now im confused again

turbid bough
#

code starts at line 0

#

goes to bottom

earnest phoenix
#

yeah

vivid crescent
#

put reddit = ..... above client = ....

earnest phoenix
#

oh

#

alright

warm karma
#

Yeah

turbid bough
#

for example

earnest phoenix
#

so you are saying i need to make a new variable or just move the "memes" up

lyric mountain
#

no

#

oh my

slender thistle
#

Just move it up

warm karma
#

lol

earnest phoenix
#

okaythanks

#

lol

lyric mountain
#

you can't put the chariot in front of the horses

turbid bough
#
print(test) = undefined
test = "test"
print(test) = "test"```
warm karma
#

No undefined in python

slender thistle
#

print(test) in that case would be an error

turbid bough
#

who said i knew python

#

i was writing it in js

warm karma
#

Oh

vivid crescent
#

excuses smh

earnest phoenix
#

still no attribure

#

attribute*

vivid crescent
#

show code v2

slender thistle
#

Just to piss you off as C# dev, 'string'

warm karma
#

Wdym

vivid crescent
#

char*

wise quartz
#

if i am using command groups can i add different cooldowns to each sub command? (Python: GWcodesPython)

warm karma
#

You can use that in python

turbid bough
#

👀

earnest phoenix
turbid bough
vivid crescent
#

your reddit line

slender thistle
#

@earnest phoenix Move the line where you assign to reddit above the memes line

lyric mountain
vivid crescent
#

not the memes = ... one, the other reddit one

warm karma
#

@wise quartz @commands.cooldown(1, delay, commands.BucketType.user)

earnest phoenix
#

holy shit i feel so dumb

unique nimbus
#

This is so bad

#

to watch

warm karma
#

With delay being the cooldown

wise quartz
#

@wise quartz @commands.cooldown(1, delay, commands.BucketType.user)
@warm karma thats not what i ment...

slender thistle
#

Technically you should be able to

warm karma
#

Sub command?

#

Oh didn’t see

slender thistle
#

Since they're sort of different commands on their own

earnest phoenix
#

@earnest phoenix Move the line where you assign to reddit above the memes line
@slender thistle sorry i do not get this.

warm karma
#

Yeah

#

OMG @earnest phoenix

slender thistle
#
reddit = ...
memes = reddit.stuff```
turbid bough
#

you cant access something that does not exist

unique nimbus
#

I feel like we are just teaching Mr. at this point

warm karma
#

Yeah ik

#

Don’t spoon feed him

earnest phoenix
#

ugh

slender thistle
#

Maybe let one person handle this instead of inserting your 5 cents in constantly

wise quartz
#

i mean they're not really different commands like you can count them as arguments for example if the group is called work and the sub command is build you can do !work build

earnest phoenix
#

the only thing i do not get is what has to be after the reddit =

turbid bough
#

the reddit.subreddit

warm karma
#

@wise quartz have you tried?

wise quartz
#

i'll rn

#

lol

warm karma
#

Ok

wise quartz
#

i just wanted to make sure

turbid bough
#

just put the memes inside the command function

earnest phoenix
#

wait wth

turbid bough
#

wait what

vivid crescent
#

bruh

earnest phoenix
#

yes i am confused

warm karma
#

REDDIT = REDDIT.SUBREDDIT?

#

BRUH

modest maple
#

you're overriding the module name

#

...

turbid bough
#

why did you remove your initialization lol

wise quartz
#

why is this guy trying to get memes from reddit? theres alot meme api(s) out there and they're much easier to use tbh...

vivid crescent
#

you know praw.Reddit

earnest phoenix
#

oh god

warm karma
#

you're overriding the module name
@modest maple the name of it is praw, right?

next remnant
#

praw is blocking

pale vessel
#

uhh not just reddit("dankmemes")?

next remnant
#

don't use it

vivid crescent
#

@next remnant don't make it more confusing we've come this far

wise quartz
#

10 people teaching 1 guy 😅 this is fun to watch

earnest phoenix
#

yes that makes it confusing af

slender thistle
#

Why do you feel the need to insert something that doesn't contribute to the current topic whatsoever

turbid bough
#

10 teachers trying to force learn a student how to code

warm karma
#

I know

#

He just wants to code a bot

wise quartz
#

i mean if he just made some searches thru docs or so he could've done it by now

warm karma
#

Yeah

turbid bough
modest maple
#

nah

warm karma
#

But he dosent even know how to move code

modest maple
#

he doesnt understand python basics, giving him the docs and saying "read" isnt gonna help

unique nimbus
#

I told him this at the very beginning

turbid bough
#

i meant this docs literally shows you how to do it basicly without telling him everything all over again

wise quartz
#

well if he doesn't know the python basics then he wont make it unless someone spoonfeed him the code

pale vessel
#

him: no

earnest phoenix
#

i know the very basics just not how to implement them into this reddit command

lyric mountain
#

no buddy

turbid bough
#

idk how more i can help if you cant read the simple doc

lyric mountain
#

this ain't about reddit module

#

it's about programming 101

slender thistle
#

Why are there so many people active at once

wise quartz
#

boredom

#

and quarantine

slender thistle
#

This isn't a channel for you to entertain yourself

lyric mountain
#

trying to find out why flatlist ain't working

#

in the mean time I'm trying to help him

wise quartz
#

i mean we're trying to help 😂

warm karma
#

lol

earnest phoenix
#

i just need this simple command done so 10 people being toxic at me isnt helping

warm karma
#

I tried using praw once

slender thistle
#

10 people at once trying to help doesn't actually help

turbid bough
#

it has gone one hour since he asked his first question

earnest phoenix
#

yes

vivid crescent
#

Show your full code again

pale vessel
#

wait really

#

wtf

vivid crescent
#

Without the keys

warm karma
#

Couldn’t figure out how to send the image

earnest phoenix
#

boomboom it is still the same because 10 people are all telling me different things

pale vessel
#

boomboom has no power

earnest phoenix
#

i am reading

#

@warm karma is it a local file or online?

pale vessel
#

:readthedocs:

slender thistle
#

@earnest phoenix Send your current code

warm karma
#

Wdym I was using praw

#

So online I guess?

vivid crescent
#

(Yeah but there was more at the bottom, I want to see if you changed it)

earnest phoenix
slender thistle
#

See the reddit = ... stuff?

turbid bough
earnest phoenix
#

ohhhhhhhhh

turbid bough
#

it was all in the docs

unique nimbus
#

bruh

lyric mountain
#

coding works by going top to bottom, so a thing at the top can't use something defined below

earnest phoenix
#

Command raised an exception: TypeError: object of type 'ListingGenerator' has no len

lyric mountain
#

alway remember define -> use

#

not use -> define

#

so it's an error at memes

#

since it's the only listinggenerator there

earnest phoenix
turbid bough
#

try casting memes with .list()?

slender thistle
#

list(generator)

earnest phoenix
#

do i put that list(generator) in my client.command part?

viral spade
#

What is the best discord lib for c++?

modest maple
#

custom

#

lol

turbid bough
#

in ctx.send yes

#

C++

slender thistle
#

Not literally that

earnest phoenix
#

yea

turbid bough
#

oh in random.choice prob

#

idk

#

or save it to an another variable

slender thistle
#

Depends on what they want mmulu

earnest phoenix
#

ivalid form body?

#

want to keep your sanity? don't use cpp for discord bots

unique nimbus
#

cpp?

#

Disgusting

#

Use Assembler

#

Would that even work

earnest phoenix
unique nimbus
#

Assembly

#

c:

earnest phoenix
#

imagine writing on a keyboard

#

i manually send voltage signals to my cpu

unique nimbus
#

Last time I did that, it died

#

so never again

earnest phoenix
#

omg same but with an arduino

lyric mountain
#

gotta write a bot in delphi

earnest phoenix
#

i fried it

unique nimbus
#

lmao]

earnest phoenix
#

@slender thistle sorry for ping but somehow i still messed up

unique nimbus
#

I thought I fried my Raspberry Pi 2

slender thistle
#

Send code

unique nimbus
#

I just corrupted Raspbian

earnest phoenix
unique nimbus
#

oh lord

slender thistle
#

.list isn't a thing

#

list is a built-in function from Python itself

earnest phoenix
#

oh

slender thistle
#

You can just pass memes as argument to random.choice without any need for list

earnest phoenix
#

so random.choice.memes?

slender thistle
#

argument for a function

#

aka function(argument)

#

If you did choice.memes, you'd say "memes is a property of choice"
but you need memes to be an argument of choice

earnest phoenix
#

now i did random.choice(memes) but i guess thats still not correct

slender thistle
#

That looks correct

earnest phoenix
#

it gave me the listing generator has no len error again

slender thistle
#

oh well, list(memes)

earnest phoenix
#

so random.list(memes)?

slender thistle
#

No, list(memes) will be the argument for function choice

#

You basically convert the ListingGenerator to a list, and then choose a random element

earnest phoenix
#

ok so i did random.choice(list(memes))

#

but for some strange reason now my async def on_ready has an error

slender thistle
#

What's the error

earnest phoenix
#

def

#

inv syntax

slender thistle
#

The full error please

earnest phoenix
#

Traceback (most recent call last):
File "C:\Users\Gebruiker\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 193, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\Gebruiker\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 86, in run_code
exec(code, run_globals)
File "c:\Users\Gebruiker.vscode\extensions\ms-python.python-2020.5.78807\pythonFiles\lib\python\debugpy\no_wheels\debugpy_main
.py", line 45, in <module>
cli.main()
File "c:\Users\Gebruiker.vscode\extensions\ms-python.python-2020.5.78807\pythonFiles\lib\python\debugpy\no_wheels\debugpy/..\debugpy\server\cli.py", line 430, in main
run()
File "c:\Users\Gebruiker.vscode\extensions\ms-python.python-2020.5.78807\pythonFiles\lib\python\debugpy\no_wheels\debugpy/..\debugpy\server\cli.py", line 267, in run_file
runpy.run_path(options.target, run_name=compat.force_str("main"))
File "C:\Users\Gebruiker\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 262, in run_path
code, fname = _get_code_from_file(run_name, path_name)
File "C:\Users\Gebruiker\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 237, in _get_code_from_file
code = compile(f.read(), fname, 'exec')
File "c:\Users\Gebruiker\Desktop\bot\bot.py", line 34
async def on_ready():
^
SyntaxError: invalid syntax

wise quartz
#

how can i add a cooldown to a command in a commands group? (rn it just takes the same cooldown as the one given to the group itself. but i want every command in that group to have a different cooldown so is it possible?) GWcodesPython

slender thistle
#

Anything below that error?

vivid crescent
#

invalid syntax

earnest phoenix
#

nope

viral spade
#

c++ not a good option for programming a discord bot?

slender thistle
#

What does your on_ready look like

earnest phoenix
#

now all my @lient.command text is not in use

vivid crescent
#

Most people don't go with .NET @viral spade

slender thistle
#

Send full code tbh

earnest phoenix
#

as in all or all related to the reddit command

neon crescent
#

hey @slender thistle i am having some trouble related to server count, can you please check #topgg-api ?

slender thistle
#

everything

earnest phoenix
#

Most people don't go with .NET
@vivid crescent
cpp is not a part of .net

#

c#, q#, f# and vb are

vivid crescent
#

Alright my bad

#

(Thanks for letting me know) But anyway still; if they are fine to code in that language it shouldn't be an issue

earnest phoenix
#

it is an issue

#

you often don't go with cpp for discord bots because it's very hard to implement a websocket handler in such a low level language

#

that's why all of the cpp libs are abandoned

#

it's really hard to keep up with gateway changes and implement them in cpp

slender thistle
#

@earnest phoenix Add one more closing parenthesis in the list(memes) stuff

earnest phoenix
#

oh god

#

it only sends the final part of the url now

slender thistle
#

wat

earnest phoenix
#

so only gly47l

#

not what is supposed to come in front

slender thistle
#

Probably what PRAW returns

#

So just add the base URL before blobshrug

earnest phoenix
#

but that is a problem

#

since some memes are gifs

#

praw did return it correctly before when it just sent 100 memes

unique nimbus
#

@slender thistle praw sends the full url

#

well image/gif url

earnest phoenix
#

yup but not anymore

#

well with this code i have

#

what api do you recommend for images if i were to use that

#

cant you just simply get the image url?

#

nope it only returns the final part

reef meadow
#

im in class hehe

wise quartz
#
    @work.command()
    @commands.cooldown(1, 120, commands.BucketType.user)
    async def builder(self, ctx):
        await ctx.send("Worked")
    
    @builder.error
    async def builder_error(self, ctx, error):
        if isinstance(error, commands.CommandOnCooldown):
            seconds = error.retry_after % 60
            msg = 'Try again in **{:.0f} Seconds**.'.format(seconds)
            embed = discord.Embed(title= "Cooldown", description= f"{msg}", colour = discord.Colour.red())
            await ctx.send(embed=embed)

shouldn't this work?

#

thats a command group btw

earnest phoenix
wise quartz
#

its not working man

#

thats why i asked here

reef meadow
#

im only 12 im not anderstanding nothing and im from Brasil goodbyr

earnest phoenix
#

Doesnt it have a base url?

#

oy

slender thistle
#

@reef meadow You are 12 years old?

earnest phoenix
reef meadow
#

yes

earnest phoenix
#

discord terms joined the chat

lyric mountain
#

had to be BR

earnest phoenix
#

bye bye GWnekomakiWaveBOYE

wise quartz
earnest phoenix
reef meadow
#

see you all later

earnest phoenix
#

nah

#

see ya never

#

🇫

lyric mountain
#

see ya in 2 years

earnest phoenix
slender thistle
earnest phoenix
#

ye ik ik

#

what api do you guys recommend for random images?

wise quartz
#
    @work.command()
    @commands.cooldown(1, 120, commands.BucketType.user)
    async def builder(self, ctx):
        await ctx.send("Worked")
    
    @builder.error
    async def builder_error(self, ctx, error):
        if isinstance(error, commands.CommandOnCooldown):
            seconds = error.retry_after % 60
            msg = 'Try again in **{:.0f} Seconds**.'.format(seconds)
            embed = discord.Embed(title= "Cooldown", description= f"{msg}", colour = discord.Colour.red())
            await ctx.send(embed=embed)

so why this ain't working?

earnest phoenix
#

what isn't working

slender thistle
#

Tried asking in d.py Discord yet?

wise quartz
#

what api do you guys recommend for random images?
@earnest phoenix there's tons of api(s) just search on google and you'll find them all

#

what isn't working
the cooldown

#

its taking the group cooldown instead

#

which is 60 seconds

#

Tried asking in d.py Discord yet?
ye but none is answering 😂

abstract glacier
#

،

slender thistle
#

-dotpost @abstract glacier

gilded plankBOT
#

@abstract glacier

Please do not post dots to clear your messages/get attention. It adds absolutely nothing to the conversation and just causes spam If you need to get attention, then say hello everyone. If you need to clear your messages, then press the Esc key. If you do not follow these instructions you will be muted.

abstract glacier
#

ok areyouserious

remote rivet
#

heylo

#

I need your help guys

#

I'm making a warn command

sudden geyser
#

you're comparing an object to a string and boolean btw

remote rivet
#

And I want to detect is lUser is a bot and if it's a bot, don't do the rest of the commands

#

Yeah it don't work

#
  if (commandName === 'warn') {
    let lUser = message.mentions.members.first();
    if(!lUser) return message.channel.send("You have to mention someone to warn!")
    if(lUser == message.author.id) return message.channel.send("You can't warn yourself!")
    warns[lUser.id].warns++;
    message.channel.send('<@'+lUser+'>' + " has been warn.");
  }
slender thistle
#

In C#, is there a way to create an array while applying certain arithmetic operations?
In Python which would be, for example, [x - 2 for x in myArray]

sudden geyser
#

lUser is going to be an instance of GuildMember. You're doing <GuildMember> === <String>. What does not work about your code.

remote rivet
#

Yep I see that

#

(sorry if I don't understand everything at first, I'm French)

earnest phoenix
#

They are 2 different things

#

You cant compare them

still merlin
earnest phoenix
#

luser.id === message.author.id

#

That's one way

remote rivet
#

Oh ok It can work

earnest phoenix
#

Missing paranthese@still merlin

still merlin
#

oh ty

pine bear
#

I need to create a more advanced command handler, this one is so simple, it works but hard to deal with

const fs = require('fs');
client.commands = new Discord.Collection();
client.aliases = new Discord.Collection();

const commandFiles = fs.readdirSync('./commands/').filter(file => file.endsWith('.js'));
for(const file of commandFiles){
    const command = require(`./commands/${file}`);

    client.commands.set(command.name, command)
}
   
client.on("message", message => {
    let args = message.content.split(" ");
    let command = client.commands.get(args[0])



    if(command)command.execute(message, args);
});
earnest phoenix
#

On the last line

sudden geyser
#

warns[lUser.id].warns++;
Also is this an in-memory object? How are you going to store it when the bot goes offline and comes back online?

still merlin
remote rivet
#

@sudden geyser It goes on a json

sudden geyser
#

I don't see you saving it.

#

Nor should you really use JSON as a database.

remote rivet
#
let warns = JSON.parse(fs.readFileSync("./warns.json", "utf8"))
earnest phoenix
#

@still merlin the msg.channel.bulkdelete line is missing the parentheses

still merlin
#

OHH thanks

earnest phoenix
#

After messages

remote rivet
#

I use the warns for other things

#

Like an auto anti-spam

#

(it's the goal of the bot, auto moderation)

earnest phoenix
#

Read the docs for the user object

#

They have properties

remote rivet
#

If I use

fs.writeFile("./warns.json", JSON.stringify(warns), (err) => {
            if (err) console.log(err)

It would save it, no ?

earnest phoenix
#

You need to compare the same thing for the if statement to work

remote rivet
#

Ok thanks

earnest phoenix
#

Great

digital ibex
#

hi

#

how can i check all the members which include an array of roles using eris?

hardy vector
#

i have this html button code html <a class="btn btn-primary btn-lg">More Info</a> and i want to link it to something how do i do that if i try with href then the css for it wont show

quartz kindle
#

@digital ibex didnt you ask that before? whats your current code?

#

@hardy vector wdym the css for it wont show?

digital ibex
#
let r = message.channel.guild.members.map((e) => message.channel.guild.roles.get(e));
message.channel.guild.members.map((e) => e.roles.include(r))
``` i asked before, yeah, then i had to go
hardy vector
#

the color for it

#

and the button border/color

quartz kindle
#

that code makes no sense

digital ibex
#

i edited it

quartz kindle
#

still kinda makes no sense, you're remapping members into roles, but using the member to get a role?

#

then remapping again?

digital ibex
#

well, yeah. since that is what i would do since i've only got an array of id's

quartz kindle
#

does guild.roles.get(member) gets you a list of roles that the member has?

digital ibex
#

uh, lemme try it

quartz kindle
#

and if it does, why not simply using member.roles which does the same thing according to the docs

#

have you tried what i said yesterday? members.filter(member => member.roles.some(role => arrayofroleids.includes(role)))

digital ibex
#

yeah

#

it just returns an empty array

nocturne grove
#

message.guild.roles.cache.get(message.member) returns undefined, @quartz kindle

#

but maybe v11 wasn't

quartz kindle
#

hes using eris

nocturne grove
#

ow oops

digital ibex
#
message.channel.guild.members.filter(member => member.roles.some(role => guild.mod.roles.includes(role).id))
``` is what i done , `guild.mod.roles` is an array like `message.channel.guild.roles`
quartz kindle
#

remove .id

digital ibex
#

kk

#

ok, it sends quite a bit, like a lot where my terminal can't see the top of it

#

so, 2 secs while i run my bot on command prompt

#

lmao

quartz kindle
#

eris has that weird problem

#

when i tried running eris for a test, it kept spamming my console with garbage for no reason

#

even tho i wasnt listening to any event

digital ibex
#

ah ha, it returns a massive array, so i have to do ...includes(role)[0].wahever

#

so

#

i done js message.channel.guild.members.filter(member => member.roles.some(role => guild.mod.roles.includes(role))).map((e) => e.roles.includes('703361344312967212')) and that returns ```js
[
true, true,
true, false,
false, false,
true, false
]

nocturne grove
#

nice

#

Btw, why have you chosen to use Eris? I'm curioius what the reasons can be.

balmy knoll
#

[discord.js] How do I disconnect the bot from a voice channel?

earnest phoenix
balmy knoll
#

@earnest phoenix Thanks

lethal hawk
#

My bot has to delete a voice channel, but I get the API error below as response and the channel does not delete. The bot is added in the channels permissionOverwrites and has VIEW_CHANNEL and MANAGE_CHANNEL. How can I solve this, besides giving the bot administrator(which does solve the issue)

#
DiscordAPIError: Missing Access
    at RequestHandler.execute (/rbd/pnpm-volume/36094c96-e504-4ecf-ab99-62f02cdefd9c/node_modules/discord.js/src/rest/RequestHandler.js:170:25)
    at processTicksAndRejections (internal/process/task_queues.js:88:5) {
  name: 'DiscordAPIError',
  message: 'Missing Access',
  method: 'delete',
  path: '/channels/711971461811929129',
  code: 50001,
  httpStatus: 403
}
earnest phoenix
#

well does the bot have delete messages perms?

nocturne grove
#

@lethal hawk a bot requires CONNECT and MANAGE_CHANNEL to manage the channel

#

oh it's MANAGE_CHANNELS btw

lethal hawk
#

that solves it, I thought seeing the channel and managing was enough.
Thanks for the help

nocturne grove
#

no. Np

#

So VIEW_CHANNEL is not needed, really vague tho

turbid bough
#

you do need it

#

but its default on

#

for @ everyone

nocturne grove
#

no

#

I even tested it today, to check if my bot still was okay

turbid bough
#

No i mean, if you make it so @everyone cant see that channel, the bot can neither see it

#

but if you add that to the permissions, then the bot is able to see it

#

i think

nocturne grove
#

oh yes of course

#

but still, bots will always know each channel's name and id

earnest phoenix
#

how i make custom guild prefix?

lyric mountain
#

with a database

earnest phoenix
#

if u have link pls send

nocturne grove
#

btw, I saw guild.deleted can be changed over time, it will just change the object when the guild is not in client.guilds anymore. Does this also count for guild.available? Will that automatically change on existing objects?

earnest phoenix
#

you have to setup a database

#

@earnest phoenix

#

i understand

#

you could either host it locally or check some paid options

lyric mountain
#

I recommend sqlite or some other embeddable db

earnest phoenix
#

if 75 points means 75%/100%. Then what is 8000 points?????
if this works i can able to make a level card like mee6 so please tell me

pale vessel
#

meth

earnest phoenix
#

i am poor at math

#

ping me if you found the answer xd

pale vessel
#

holy shit those reactions

#

you gotta chill out mate

earnest phoenix
#

lol

digital ibex
#

@nocturne grove saves space, prefer it. doesn’t have random stuff like d.js

#

djs 4 me 🤢

#

there are a lot of reaons why i chose eris over djs tbh, thats just the main reason

dusky wedge
#

I am thinking about adding an url shortener to my bot, but is it allowed to lock some features behind voting? (For example: Password locked url, auto qr codes, etc)

mossy vine
#

is it allowed to lock some features behind voting?
yes and it is encouraged

dusky wedge
#

Ok, thank you :)

earnest phoenix
#

dis*couraged

turbid bough
#

im gonna make so the !vote command is disabled until you vote

earnest phoenix
#

stonks

#

bonks

nocturne grove
#

@digital ibex oh okay thanks

#

btw, I saw guild.deleted can be changed over time, it will just change the object when the guild is not in client.guilds anymore. Does this also count for guild.available? Will that automatically change on existing objects?
anyone who can confirm this?

earnest phoenix
#

you could use slice

#

or

#
var fruits = ["Banana", "Orange", "Apple", "Mango"];
delete fruits[0];           // Changes the first element in fruits to undefined 
#

something like this

#

go here

#

and read

#

actually dont use delete

#

use slice

#
var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.splice(0, 1);        // Removes the first element of fruits 
#

here is an example

#

0 is where it starts

#

and 1 is how many elements to remove

#

so if you wanna remove 2 after the index of 3

#

its array.slice(3, 2)

#

array.indexOf()

#

yes

earnest phoenix
#

what's your code

#

and what are you storing in the array

#

discord send my damn message

magic jackal
#

What would be a smart way of making this async? I'm still kinda new to async but still

const helpList = [];
client.commands.forEach(function(value, key, map) {
    helpList.push(`${key} = ${value.description}`)
})
msg.reply(arr)```
earnest phoenix
#

why would you make it async

#

also don't use forEach it's slow

magic jackal
#

oh

earnest phoenix
#

use the for keyword

magic jackal
#

hmm

earnest phoenix
#

(async function(value, key, map)

#

TJ

magic jackal
#

ye

halcyon ember
#

is there way to get all servers bot is in?

quartz kindle
#

async forEach is a very bad idea

magic jackal
#

I'm not going to do the forEach i'm rethinking it now

client.commands is a map

earnest phoenix
#

client.guilds

halcyon ember
#

oh thanks,

earnest phoenix
#

what difference with map and collection?

quartz kindle
#

collection extends map

#

which means collection is built on top of map to include more functionality

earnest phoenix
#

I think collection better than map

valid frigate
#

its been on the back of my mind for a while but how would i handle timed events in the most reasonable way possible? aka something other than setting timeouts e.g. for mutes/timed rewards etc

#

like

#

run a loop or smth idk how to go about this really

quartz kindle
#

a timeout is the only reliable way

#

however you can make a mix of timeouts and intervals

nocturne grove
#

@valid frigate make a database with timestamps and check every minute / 5 minutes which one should happen

earnest phoenix
#

or just like

halcyon ember
#

how to remove floats past 2 decimal places

valid frigate
#

well imagine if the bot's process gets interrupted

halcyon ember
#

like crop off the ending numbers

valid frigate
#

the timeout would also go poof?

earnest phoenix
#

on boot get all of the entries from the database and queue a setTimeout for each entry

#

substring lol

quartz kindle
#

.toFixed(2) will crop the number, but will also convert it into a string

earnest phoenix
valid frigate
#

sounds like a good idea

quartz kindle
#

if you dont want string convertion, the only way is parseInt(number * 100) / 100

valid frigate
#

so like store a timestamp and when the bot starts again, run over each document and start a timeout counting down till that time

nocturne grove
#

why on boot? Then you can't add new timestamps to it

earnest phoenix
#

yes... you can?

valid frigate
#

well technicaly yes you can

#

just start a new timeout after inserting the doc

earnest phoenix
#

just queue a new setTimeout and add the entry into the database

#

yes

#

lol

valid frigate
#

ok cool thank you

nocturne grove
#

ok but why xd
I'd do it the other way bot sure

earnest phoenix
#

to reduce database load

#

and you can cancel each timeout

#

just from memory

#

(in case someone decides to unmute, unban etc)

#

since temporary actions like bans and mutes need to be accurate to the second, the approach of queueing a new setTimeout for each entry is more viable

quartz kindle
#

the most efficient way possible would be something like this

setInterval(() => {
  if(dateToUnmute < Date.now() + 600000) {
     setTimeout(() => {
      unmute()
     }, dateToUnmute - Date.now())
  }
}, 600000)
#

you can mix that with a database and adjust the timers to your preference

nocturne grove
#

Why should they be precise? I mean: does 4:00:10 or 4:00:56 make a difference?

quartz kindle
#

imagine you want to mute someone for 1 minute

#

and they only get unmuted after 1 minute and 50 seconds

#

¯_(ツ)_/¯

earnest phoenix
#

lol

nocturne grove
#

Yeah okay but 1 min is weird haha

earnest phoenix
#

it really isn't

quartz kindle
#

i mean, sure you can do that

#

but people kinda expect bots to be precise

rare shadow
#

Sup

earnest phoenix
#

1 minute tempmutes etc. are warning signs for "hey you should maybe calm down" or something like that, if your bot isn't accurate, don't expect people to use it

quartz kindle
#

well, you can always make it a feature

#

name your bot "Approximate Bot"

nocturne grove
#

Well okay sure 😂

#

You're right

earnest phoenix
#

"fuck your opinion - i decide the length"

turbid bough
#

well, you just have to temporary store short-timed timers, and if its long-timed then you use a db

quartz kindle
#

$mute someone 30 minutes
"Approximate Bot": someone muted for approximately 30 minutes

turbid bough
#

then you retrieve that data

#

just store a datetime

still merlin
#

Is there a way i can keep my bot online 24/7

turbid bough
#

and it already will be kinda accurate

digital ibex
#

is there any way for me to get the shard latency for each shard, in eris?

quartz kindle
#

keep your program running 24/7

nocturne grove
#

Lol

earnest phoenix
#

well, you just have to temporary store short-timed timers, and if its long-timed then you use a db
you should always store in the db no matter how short the action is, if a crash happens while the short period is near expiring, well, they're going to stay muted/banned forever

digital ibex
#

like,
shard 0 - 100ms
shard 1 - 10ms
shard 2 - 200ms

turbid bough
#

yeah, imagine muting someone, bot goes offline, and then they will never unmuted

#

@earnest phoenix yeah ofcourse if you are using mutes yeah, but like if you were doing like non-important timers

quartz kindle
#

@digital ibex websocket latency can be found in client.shards.get(shardID).latency

digital ibex
#

ah, ty

nocturne grove
#

Ow wait I also still got a question somewhere

#

btw, I saw guild.deleted can be changed over time, it will just change the object when the guild is not in client.guilds anymore. Does this also count for guild.available? Will that automatically change on existing objects?
This one

quartz kindle
#

yes

nocturne grove
#

Okay nice

#

For me that sounds really weird tho

quartz kindle
#

if you do guild = client.guilds.cache.get() (if you're in djs v12)
then guild is a reference of the original guild, not a copy

digital ibex
#

DiscordHTTPError: 503 Service Unavailable on POST /api/v7/channels/702241622926295092/messages

nocturne grove
#

Like you store them in a var and it changes

quartz kindle
#

so whatever happens to the original guild, your copy of guild will also be affected

digital ibex
#

i'm getting that

#

with client.shards.get(3).latency

#

oh

#

wait, nvm

earnest phoenix
#

your bot failed to send the message

#

discord is having a stroke

quartz kindle
#

lmao

earnest phoenix
#

5xx errors are never your fault

#

it's discord

digital ibex
#

ohh, thats cool to know

#

ty

#

i'm learning a lot today, its great 🙂

quartz kindle
#

unless you do something so dumb that causes the server to crash

digital ibex
#

oh

quartz kindle
#

or course with something as big as discord, that should never happen

earnest phoenix
#

cough
||host a giveaway with 250k members in the guild expecting nothing will go wrong despite knowing your platform is prone to crashing 🙃 ||

quartz kindle
#

xD

#

they should rewrite more stuff into rust

earnest phoenix
#

i have no idea what they're even using right now

digital ibex
#

what would that change?

earnest phoenix
#

their api is a clusterfuck

quartz kindle
#

probably a bit of every lang out there

earnest phoenix
#

the gateway used to be python i think? or is? i dont know

#

but the rest api is a different lang

quartz kindle
#

imagine if they have a component running on LOLCODE or brainfuck just for the lulz

earnest phoenix
#

secret endpoint

digital ibex
#

how do you guys know these things lol?

#

i've got a lot to learn

earnest phoenix
#

years of experience

#

ig

quartz kindle
#

^

digital ibex
#

oh

quartz kindle
#

programming is neverending, you can study it for 50 years and still find a gazillion things you dont know

#

also because a lot changes every year lmao

digital ibex
#

i've only been programming for like, 7 months

quartz kindle
#

so everything you spent years learning is now suddenly obsolete

digital ibex
#

0_______________________0

quartz kindle
#

well, it doesnt happen that fast

earnest phoenix
#

my first ever project was a minecraft plugin in like java 7

#

fun

quartz kindle
#

but look at flash, it was once upon a time the most used lang on the internet, every website and their grandmother was using it

#

and now its dead

earnest phoenix
#

HAhaa my school still requires it so we can use their online books

quartz kindle
#

rip

#

people who were the gods of flash games now have to learn how to port all their games to html5

nocturne grove
#

We never did js at school but did Python and C#, and Python doesnt seem to have a high reputation lol

#

Oof

earnest phoenix
#

python was experimental at our school

digital ibex
#

what is flash used for?

#

my school ruined python 4 me

nocturne grove
#

Afaik internet games :)

earnest phoenix
#

it ended up getting thrown out because 90% of the students in the experimental class didn't like it

nocturne grove
#

Ow lol

quartz kindle
#

flash was primarily used for interactive content, games, videos, animations, etc

raven urchin
quartz kindle
#

even youtube was based on flash

digital ibex
#

o damn

quartz kindle
#

i cant read that pic at all @raven urchin

earnest phoenix
#

skies, forcefully creating invites into the guild isn't really advised

topaz fjord
#

jpegify

#

amazing

earnest phoenix
#

if you don't implicitly state that you're creating an invite, that's some form of api abuse

digital ibex
#

client.users.get('ur id').send('oof some1 removed ur bot')

sterile mesa
#
data.money += currency*10

is ^ the right script?
HeLp

earnest phoenix
#

i don't know, is it?

raven urchin
#

Oh, How can I make it dm me?

digital ibex
#

.

#

client.users.get('ur id').send('oof some1 removed ur bot')

raven urchin
#

Alright. Thank you

#

Oh I didn't see that message, sorry

digital ibex
#

np

grizzled raven
#

how slow would doing Object.keys() on an object with 1k fields that have IDs for keys, such as "707952322172420157"?

magic jackal
#

yo does anyone use table from npm?

Is it any good?

nocturne grove
#

If it already exists, just try

magic jackal
#

@grizzled raven log a timestamp at the time of you starting and the time of finish

#

check ms

grizzled raven
#

i dont have one but i guess when i get the chance

lyric mountain
#

use a loop to fill an array with 1k entries

#

then do the test

clever garnet
#

how do i make this a function

.setImage(`${message.author.displayAvatarURL}`)

earnest phoenix
clever garnet
#

go to return home

#

itll fix it prob

earnest phoenix
#

i tried but it didn’t do anything when i tried to update my server list thing

clever garnet
#

refresh i guess

earnest phoenix
#

discord's api is having a stroke and DBL depends on discord

#

so

#

everything is having a stroke

#

there's nothing you can do but sit, wait, and possibly have a mental breakdown while doing so

clever garnet
#

how do i make this a function

.setImage(`${message.author.displayAvatarURL}`)

nocturne grove
#

That is already a function

#

But you can remove the `${ }` tho

dusty onyx
#

python troubles ahaha

ok so essentially i want to be able to choose a random element from a list minus another pre-chosen element
so if i had a list k = [1, 2, 3, 4]
and i randomly choose 2 thru random.choice(k)
then is there a way to do random.choice(k) again but with no chance of it picking 2 again? i need all the elements to still be in the list, but the two random choices must be different
alternatively, as im assigning variables to each element chosen, if there's a way to do so with random.sample id love to know lol

nocturne grove
#

Idk Python really well, but cant you make another array with all indexes of the first apart from the specific choice, get a random thing of that array, and get that index in k array?

dusty onyx
#

ooh, ill try that :0

nocturne grove
#

👍

#

Maybe there's a faster way tho, idk

modest maple
#

or just do

#

[].pop(randint(1, n))

#

pop removed the indexed item and returns it

nocturne grove
#

Hmm. But if that affects the original array, it will not directly work the way he wants

marsh vale
#

I am trying to add my server to the discord servers website but every time I try, it says there's an error

halcyon ember
#

I have this const top10 = sql.prepare("SELECT * FROM scores ORDER BY usd DESC LIMIT 10;");

fickle arch
#

@marsh vale you using the discord calculator and put your bot ID to generate invite link ?.

halcyon ember
#

but it says top10 is not iterable

#
    embed.addField(client.users.get(data.user).tag, `$${data.usd}`);
  }``` with this
marsh vale
#

I went on the discord servers website and tried adding an invite link and description to my server but it won't allow me

fickle arch
#

oof i had that kind of trouble before.

tawny ledge
#

Pfff, if we can't use the perm administrator, this perm is unusefull

#

Give all perms is quite similar to give the perm Administrator

#

++

marsh vale
#

so no one has a solution?

long eagle
#

what is better for a bot?

Node.JS or Java?

modest maple
#

what ever

neat ingot
#

so I ended up getting sidetracked af over the past two days. Made a module for easily creating and handling little minigame type things on discord. Made 5 fully finished minigames and started work on a 6th, and decided to just put the minigame commands into a new bot entirely 😄

modest maple
#

the JS Libs are both pretty bad but so is Java's

neat ingot
#

anyone got any ideas for other minigames that could be neat on discord? 🙂

#

things i can make little boards using ascii/emojis are ideal 😄

modest maple
#

ngl thats fucking clean

neat ingot
#

why thank you 🙂

earnest phoenix
#

help? my stats error doesn't work (discord.js v12)

const Discord = require("discord.js");
const run = module.exports.run = async (bot, msg, args) => {
    const os = require('os');
    const arch = os.arch()
    const used = process.memoryUsage().heapUsed / 1024 / 1024;
  
    let totalSeconds = process.uptime();
    let realTotalSecs = Math.floor(totalSeconds % 60);
    let days = Math.floor((totalSeconds % 31536000) / 86400);
    let hours = Math.floor((totalSeconds / 3600) % 24);
    let mins = Math.floor((totalSeconds / 60) % 60);
    var cpu = process.cpuUsage().system / 1024 / 1024;
    var cpu_usage = Math.round(cpu * 100) / 100;
    
    let info = new Discord.MessageEmbed()
        .setColor('#ff9900')
        .setDescription('**PAPER STATS**')
        .addField('📂 Total Servers', `**${bot.guilds.cache.size}** guilds`, true)
        .addField('📡 Total Channels', `**${bot.channels.cache.size}** channels.`, true)
        .addField('👥 Total Users', `**${bot.users.cache.size}** other users.`, true)
        .addField('💾 Memory usage', `${Math.round(used * 100) / 100}MB`) 
        .addField('💾 Node', `${process.version}`, true) 
        .addField('💾 Library', 'discord.js', true)
        .addField('💻 Operating System', `${os.platform} ${arch}`, true) 
        .addField('💽 CPU usage', `${cpu_usage}% Used`) 
        .addField('⏲️ Uptime', `Days: ${days} | Hours: ${hours} | Minutes: ${mins} | Seconds: ${realTotalSecs}`, true)
        .setFooter(`${bot.user.username}`, bot.user.displayAvatarURL)

msg.channel.send(info)
} 

module.exports.help = {
    name: 'stats'
}
neat ingot
#

'dowpdown' is the same design, but is a match3 tetris dropdown type of thing with different color counters 😄

magic jackal
#

@earnest phoenix What are you talking about?

#

What is the stack error? Can you paste what it errors on here?

earnest phoenix
#

no errors

#

when i run the command nothing happen

magic jackal
#

lemme try one sec

#

How do you fire this off? it works for me

earnest phoenix
#

idk, it just don't work

magic jackal
#

how do you not know? Did you not write this?

This is a module export, how do you call the export itself? Are you calling the run()

#

You need to call the export and fire it off, typically in another file when this is used.

#

let me add it to my testbot I'll show you

earnest phoenix
#

Ok

magic jackal
#

See here

#

I copied your code and it works for me

#

I call my command via module.export and I require() it inside of my index.js and I fire it off using client.commands.get('info').execute(_, msg)

earnest phoenix
#

Ok

magic jackal
#

btw your memory calculation is wrong

#

heap is different

white anvil
#

how did you manage to get a bot using 14mb ram

magic jackal
#

I use .rss that way it shows the full process

white anvil
#

wtf

magic jackal
#

He is doing the math wrong

white anvil
#

oh

magic jackal
#

used = process.memoryUsage().heapUsed / 1024 / 1024;

white anvil
#

thats heap used

#

right

magic jackal
#

yea

#

lmao

white anvil
#

i know someone that used external to make his usage look small ass

#

it was like 500kb

magic jackal
#

useful chart

white anvil
#

yeah

#

rss isnt 100% accurate still tho

#

theres no real way to properly calculate true memory usage

magic jackal
#

my calculation is this

function formatBytes(bytes){
    if (bytes>=1000000000) {bytes=(bytes/1000000000).toFixed(2)+'GB';}
    else if (bytes>=1000000) {bytes=(bytes/1000000).toFixed(2)+'MB';}
    else if (bytes>=1000) {bytes=(bytes/1000).toFixed(2)+'KB';}
    else if (bytes>1) {bytes=bytes+' bytes';}
    else if (bytes==1) {bytes=bytes+' byte';}
    else {bytes='0 byte';}
    return bytes;
}

formatBytes(process.memoryUsage().rss)```
white anvil
#

you can probably do this more effectively using base 10 logarithms but math

green vale
#

So I'm sorting all of my bot's commands into folders inside of my command folder. At the moment, I use a command handler from An Idiot's Guide tutorial that I followed two years ago; Here's what I currently use to load commands:

const { promisify } = require("util");
const readdir = promisify(require("fs").readdir);
  var commands = await readdir(client.config.commandsroute);
  commands.forEach(f => {
    if (!f.endsWith(".js")) return; // I don't know if subdirectories count as files, so..
    const response = client.loadCommand(f);
    if (response) console.log(response);
  });

How can I do it so the fs module will read from the subdirectories? (I know that I can manually give each category folder its own forEach statement and stuff but I want to have it so the bot'll load the files automatically.)

white anvil
#

read the parent directory for the subdirectories and read the contents of each subdirectory iteratively

green vale
#

alright

white anvil
#

unless you wanna hardcode your subdirectory names

#

which i dont suggest you do

green vale
#

I could but that's gonna be a pain if I move it later

white anvil
#

yea

#

but readdir returns both files and folders

green vale
#

Unless if I deliberately make a new Linux user called "pi" and put my folder in the Desktop

#

OH it does

rigid raven
#

How can I send a message to a server having the id in discord.py?

green vale
#

what do you mean @rigid raven

rigid raven
#

i have the bot on my server and i want to send a message every 1hour (for example)

green vale
rigid raven
#

yeah, but i didn't see it 😦

green vale
#

wdym

#

and Jacher, I don't have a lot of experience with fs; how can I check inside the subdirectories in a forEach?

white anvil
#
const subDirectories = readDir(parent);
subDirectories.forEach(directory => { const files = readDir(directory); 
// add nested forEach here for files
})
earnest phoenix
#

you need the id to the text channel too, the guild id alone won't cut it

rigid raven
#

you need the id to the text channel too, the guild id alone won't cut it
@earnest phoenix ohhh, ok

green vale
#
  1. what is parent defined as?

  2. would readDir be another thing like this

const { promisify } = require("util");
const readdir = promisify(require("fs").readdir);

but readdir is replaced by readDir?

white anvil
#

u can use readdir

#

parent is just the path to the parent directory

green vale
#

oh alright

#

and directory is-okay

#

tysm

magic jackal
#

Mongo Gods, I need your help, I'm trying to get the top 5 rsults from my DB but I cant figure out mongo very well

This is what I have so far, how can I return the result itself?

client.database.collection('guilds').find({}, {
    sort: {
        'fcount': -1
    },
        skip: 0,
        limit: 5
    });
#

The length of this is 0

green vale
#

are you using mongoose

magic jackal
#

yea

green vale
#

okay

#

I don't really know since I don't use mongo myself lol

magic jackal
green vale
#

okay anyway back to me coding

#

what do you need help w/

slender thistle
#

Why does it DM everyone

green vale
#

sounds like abuse tbh

slender thistle
#

Literally just use a role or @everyone mention

#

Mass DMs are API abuse and against Discord ToS

astral yoke
#

if this is a retarded question just say you cant dont yell at me

#

but if you get an error

#

like this

#
    at item.request.gen.end (/rbd/pnpm-volume/8026e4ea-29c1-4714-8479-5e7241f9946b/node_modules/discord.js/src/client/rest/RequestHandlers/Sequential.js:85:15)
    at then (/rbd/pnpm-volume/8026e4ea-29c1-4714-8479-5e7241f9946b/node_modules/discord.js/node_modules/snekfetch/src/index.js:215:21)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:7141) 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(). (rejection id: 2)
(node:7141) [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.```
#

how are you able to check like where it came from

#

instead of just having it as an error

pale vessel
#

by making sure that your bot has correct permissions

green vale
#

C a t c h it

lyric mountain
#

Every single promise MUST have a catch

#

Else you risk being that lost

#

Where the error happened is written there btw

astral yoke
#

I don't know where the error happened

#

thats the thing

quartz kindle
#

you'll have to go over all your code

#

and add catches to all methods that interact with the api

astral yoke
#

Ah

#

I found it

#

since danny said to catch it

#

why is this erroring catch (error) return; SyntaxError: Unexpected token catch ```bot.on("messageDelete", async message => {
let logs = await message.guild.fetchAuditLogs({type: 72});
let embed = new Discord.RichEmbed()
.setTitle("DELETED MESSAGE")
.setColor("#fc3c3c")
.addField("Author", message.author.tag, true)
.addField("Channel", message.channel, true)
.addField("Message", message.content)
.setFooter(Message ID: ${message.id} | Author ID: ${message.author.id});
let channel = await bot.db.fetch(modlogchannel_${message.guild.id})
if(channel === null) {
return;
}
bot.channels.get(channel).send({
embed: embed
});
catch (error) return;

})```

quartz kindle
#

thats not how you catch things

astral yoke
#

Is it if error or what because catch error worked for my ban code?

quartz kindle
#

you have 2 promises in that piece of code

#

fetchAuditLogs and send

#

fetchAuditLogs is being awaited, so if that errors, you will receive a normal error

#

send() is not being awaited nor caught, so if that errors, you will receive an unhandled promise rejection

astral yoke
#

which is what I got

#

so should I do for it (channel) await send({ or?

quartz kindle
#

so if you do await bot.channels.get().send(), the error will become a normal error
if you do bot.channels.get().send().catch(), you will catch the error in the promise

#

so basically

#
// option 1
try {
  await function()
} catch(error) {
  console.log(error)
}

// option 2
function().catch(error => console.log(error))

astral yoke
#

ohhh ahhh

#

makes sense

quartz kindle
#

if you await it, it is forced to return to the normal flow, and its error will be converted to a normal error
if its not awaited, then it never returns to the normal flow, so you have to .catch() it to catch the error inside the promise

earnest phoenix
#

The Owner widget don't work

turbid bough
#

from 1-10, how good of an idea is it to make a new thread for each command executed?

#

in c#

white anvil
#

depends what the commands do

#

resource intensive shit should always be ran on its own thread to make it non blocking

hardy vector
#

this guy said he hosted his bot on his old computer does that mean he has to keep it on 24/7

white anvil
#

yes

hardy vector
#

oh

#

thats a waste of electricity

pale vessel
#

i mean an old computer uses less power

hardy vector
#

tru

quartz kindle
#

old computers usually use more power

pale vessel
#

OOF

hardy vector
#

wait wat

#

ok

white anvil
#

a raspberry pi is an extremely affordable and efficient way to host a small discord bot at home

astral yoke
#

Just invest in a VPS

quartz kindle
#

a vps is going to be an order of magnitude cheaper compared to the electricity cost of self-hosting

white anvil
#

raspberry pi consumes next to no power

#

but i would recommend vps ye

quartz kindle
#

a pi can actually be cheaper than a vps ye

#

a single laptop cpu uses 5-10x more power than an entire pi lmao

#

just the cpu

white anvil
#

i should host my bot on a pi cluster

#

one pi per guild :D

#

honestly the only problem with pis is the lack of cooling but for most use cases they shouldnt be getting that hot

quartz kindle
#

one pi per guild wtf

white anvil
#

you can buy this 750 pi cluster

quartz kindle
#

you can probably run 1 pi per shard

white anvil
#

idk why you would but the offer is there

#

yeah probably

quartz kindle
#

how much for it?

#

is it preconfigured for shared resources? or do i have to install linux 700 times

white anvil
#

i have no idea

#

i just got this image off google

quartz kindle
#

get one of those and resell it as vps hosting

white anvil
#

i would imagine its shared

#

nah sell it as dedi

#

cheapest dedis on the market

quartz kindle
#

but as a vps you can oversell

#

more money

white anvil
#

true true

#

trying to cool that thing would be a pig

quartz kindle
#

add some ssds and configure your virtualizer to use them as ram

#

cheap high-core high-ram vps

white anvil
#

those poor ssds

earnest phoenix
#

not to mention the "ram" will be 🐌

white anvil
#

rip to all the sata ssds that have died a painful death of swap overdose

#

honestly nvme swap isnt even that slow

quartz kindle
#

you can raid a few nvme's and get about half the speed of actual ram

#

which is more than good enough

earnest phoenix
#

but seek time tho?

quartz kindle
#

the noobs who will be buying your hosting wont notice

earnest phoenix
#

Thonk makes sense

white anvil
#

id still use this over windows server ngl

quartz kindle
#

use some cool tech that keeps hot data on actual ram and delegates the bulk to the ssds

hardy vector
#

get one of those and resell it as vps hosting
@quartz kindle big brain moment

#

how can i make a bot send a message in a channel every x hours

earnest phoenix
#

^with a timer

magic jackal
#

cron jobs too

tepid hedge
#

Need a bit of help with this. trying to send a discord private message to users with a certain role. Have everything done, minus the actual sending of the message.

if(command === "test") {
    let user = message.author
    const role = message.guild.roles.cache.get("712058154090758248");
    if (!role) return user.send('That is not a role!');

    let membersWithRole = message.guild.roles.cache.get("712058154090758248").members;
    membersWithRole.client.send("test")
}
#

Have been getting the error "cannot read property send" of undefined, which I expected.

earnest phoenix
#

wait

#

you cant use a members list to send messages, check the docs

#

plus massdming would be considered api abuse afaik

tepid hedge
#

Its used in a private server where the people have all asked/agreed to be private messaged from it

white anvil
#

it is a case by case thing

sudden geyser
#

A collection does not have the property .client

white anvil
#

u should be fine if its private

quartz kindle
#

you should use a for loop and await send to each user

tepid hedge
#

A collection does not have the property .client
I've been going through docs and anything I can find to try and see what I can do

sudden geyser
#

okay well go to the class about guild member manager

digital ibex
#

using a for loop like tim said would work fine

sudden geyser
#

and iterate over the .cache property like tim said and use a for loop

quartz kindle
#

role.members already gives you a collection of members, you can iterate directly on it

#

and send to each member in a loop

tepid hedge
#

How do I take out each individual member from membersWithRole and add them to the loop queue?

quartz kindle
#

the easiest way is using a for of loop

#
for(let [id,value] of collection) {
  // do things
}
tepid hedge
#

So put the loop inside that, then send the message?

fickle quest
#

Hello guys

white anvil
#

Hello guy

tepid hedge
#

I don't know how to pull data from collections, this is a first

fickle quest
#

Is there any bot that can boot my server

digital ibex
#

wut

fickle quest
#

Is there any bot that can boot my server free

magic jackal
#

@fickle quest boot??

#

what do you mean?

tepid hedge
#

I think he means boost

magic jackal
#

boost?

tepid hedge
#

A) No, that's not how it works, B) This isn't the channel for that.

magic jackal
#

yeah buy nitro see above

fickle quest
#

I am looking for someone who wants to make my own server beautiful

quartz kindle
#

@tepid hedge membersWithRole is a collection

#

so for(let [id,value] or membersWithRole) will give you the id and value of each item in the collection

#

in this case, the id of the member as id, and the member object of the member and value

magic jackal
#

This is development, and a bot list discord, I think you are in the wrong server to ask that question.

fickle quest
#

Is there anyone like that

magic jackal
#

....

fickle quest
#

please help me

#

Please

magic jackal
#

I'll redo your discord for $60 Wrong server, we don't do that here, maybe ask in #memes-and-media

clear wraith
#

Ok... Im getting frustrated. I have uninstalled and reinstalled quick.db for the 3rd time in a row... Because that is what i had to do to fix the error that was occurring.

#

What can I do to decrease the times I have to uninstall and install quick.db?

earnest phoenix
#

uninstalling and reinstalling isnt gonna fix the issue

halcyon ember
#

how to crop off end of a float to 2 decimal places

#

i keep getting numbers like 1.0000000002

digital ibex
#

what language?

#

@halcyon ember ^

clear wraith
#

/rbd/pnpm-volume/3e0e7ff0-a6f9-4413-afc4-43ee427079be/node_modules/.registry.npmjs.org/bindings/1.5.0/node_modules/bindings/bindings.js:135

throw err;

^

Error: Could not locate the bindings file. Tried:

→ /rbd/pnpm-volume/3e0e7ff0-a6f9-4413-afc4-43ee427079be/node_modules/.registry.npmjs.org/better-sqlite3/6.0.1/node_modules/better-sqlite3/build/better_sqlite3.node

→ /rbd/pnpm-volume/3e0e7ff0-a6f9-4413-afc4-43ee427079be/node_modules/.registry.npmjs.org/better-sqlite3/6.0.1/node_modules/better-sqlite3/build/Debug/better_sqlite3.node

→ /rbd/pnpm-volume/3e0e7ff0-a6f9-4413-afc4-43ee427079be/node_modules/.registry.npmjs.org/better-sqlite3/6.0.1/node_modules/better-sqlite3/build/Release/better_sqlite3.node

→ /rbd/pnpm-volume/3e0e7ff0-a6f9-4413-afc4-43ee427079be/node_modules/.registry.npmjs.org/better-sqlite3/6.0.1/node_modules/better-sqlite3/out/Debug/better_sqlite3.node

→ /rbd/pnpm-volume/3e0e7ff0-a6f9-4413-afc4-43ee427079be/node_modules/.registry.npmjs.org/better-sqlite3/6.0.1/node_modules/better-sqlite3/Debug/better_sqlite3.node

→ /rbd/pnpm-volume/3e0e7ff0-a6f9-4413-afc4-43ee427079be/node_modules/.registry.npmjs.org/better-sqlite3/6.0.1/node_modules/better-sqlite3/out/Release/better_sqlite3.node

→ /rbd/pnpm-volume/3e0e7ff0-a6f9-4413-afc4-43ee427079be/node_modules/.registry.npmjs.org/better-sqlite3/6.0.1/node_modules/better-sqlite3/Release/better_sqlite3.node

#

Then how can i fix the issue

quartz kindle
#

n.toFixed(2) if you're fine with converting it to string
parseInt(n * 100) / 100 if you want to keep it as a number
@halcyon ember

halcyon ember
#

@digital ibex discordjs

digital ibex
#

then tims way

halcyon ember
#

@quartz kindle if i need to keep it a float with two decimal places do I parseFloat or what

#

cuz i need it precise to like 2 decimal/4 decimal places but parseInt would convert that to integer

quartz kindle
halcyon ember
#

oh

#

let me try and see

quartz kindle
#

multiply by 100 to move 2 digits to the left
parseInt to remove decimals
divide by 100 to move 2 digits back to the right

halcyon ember
#

ahhh

#

makes sense

quartz kindle
#

if you want more digits, change 100 to the number of 0s you want digits

clear wraith
#

Idk why it keeps saying i have an error then... If its the same error showing up 300 times a day. And I've tried everything I can do. @earnest phoenix

halcyon ember
#

how do I put it into a function that applies that to every user every min

quartz kindle
#

@clear wraith try running enable-pnpm in your glitch terminal/console

clear wraith
#

What will that do?

quartz kindle
#

restart and reinstall your project

clear wraith
#

Ok

digital ibex
#

roman, not really relevant to ur problem, but, when i was getting errors with quick.db, i just switched to mongo, 100% recommend

clear wraith
#

I suck at switching

earnest phoenix
#

@clear wraith whats the error?

clear wraith
#

Its up there a couple messages 👆 @earnest phoenix

halcyon ember
#

my code gives user 2 currency every now and then, but somehow it goes into decimal places like 0.00000000001. How do I put what tim did (n.toFixed(2) and parseInt) into a function that does it to every user every few seconds

quartz kindle
#

you dont need to do that every few seconds

#

you just need to do that when you actually use those values

halcyon ember
#

oh

quartz kindle
#

for example, when putting those values in an embed

#

just do value.toFixed(2) in the embed

halcyon ember
#

ahhh

#

ok that worked pretty well, excpet theres like numbers with excess 0s at the end

quartz kindle
#

like 1.00?

#

.toFixed() does that, as its name implies, it fixes the length of the number by adding or removing decimals

tepid hedge
#

@quartz kindle Came back after a bit, im testing out what you said (js for(let [id,value] of collection) { // do things }

If I run console.log as a test, how do I post the values?

quartz kindle
#

if you dont want it to affect integers, you need to either ignore them Number.isInteger(n) ? n : n.toFixed(2) or use the math way as explained before parseInt(n * 100) / 100

halcyon ember
#

ah

#

thanks :D

tepid hedge
quartz kindle
#

well of course, you need to put your own collection in there

tepid hedge
#

forgot that I undid that

#

So now I have the bot logging the id, so now all I have to do is set an interval, and then send the message like this?
client.users,get("IDHERE).send("message")