#development

1 messages · Page 672 of 1

broken shale
#

when Im already at 10% RAM left

lusty dew
#

Oof

tight heath
#

@lusty dew yes very sure lmao

lusty dew
#

Then why isn't it working wtf

tight heath
#

oh waitttt

#

kb > mb > gb

#

so ug

#

1024³B = 1024²kB = 1024MB = 1GB

#

add a 1024 everywhere lol

#

mb = bytes / (1024 **2)
gb = bytes / (1024 ** 3)
gb = mb / 1024

lusty dew
#

Wait what

#

I'm not good at math can you explain it a bit?

#

And i don't understand this byte to kb to mb to gb conversion

winged thorn
#

oh yeah kilobytes exist

#

dumb us

#

byte -> kilobyte = /1024

#

kilobyte -> megabyte = /1024

#

megabyte -> gigabyte = /1024

lusty dew
#

So basically just divide by 1024 2 times to get mb?

winged thorn
#

yes

fierce thorn
#

1 kilobyte =
1000 bytes

lusty dew
#

Then I can check if that is greater then 1024 and if so send the gb format?

winged thorn
#

yup

lusty dew
#

Which I'ma have to edit a bit

#

Thanks!

winged thorn
lusty dew
#

Wait

#

So to get gigabytes

#

I'd divide 1024 two times then multiple 1024?

#

Or just keep dividing

onyx summit
#

afaik from bytes to GB you divide two times trough 1024

lusty dew
#

But I thought diving 2 times gives you mb

#

Cause you gotta convert bytes -> kb -> mb

#

That's 2 times dividing already

winged thorn
#

yes

#

correct

lusty dew
#

So if I divide another time I'd get gb?

winged thorn
#

indeed

lusty dew
#

Okay thanks

#

Divide three times to get gb got it

#

I'm making a mental note of that lol

winged thorn
#

lmao

onyx summit
#

my bad,
Bytes /1024/1024/1024

#

Just tested lel

winged thorn
lusty dew
#

Lol

tight heath
#

@fierce thorn no

winged thorn
#

The order of magnitude goes
bits -> bytes -> kilobytes -> megabytes -> gigabytes -> terabytes -> petabytes -> exabytes -> etc

tight heath
#

in cs you use 1024 because it's the closest power of 2

#

2 ** 10 that is

#

which makes much more sense since like everything is binary

winged thorn
#

with network transfer speeds tho you use 1000 instead for some reason

#

storage is always 1024

lusty dew
#

Mem is still off

#

In pm2 console it's above 100mb

#

Unless that whole thing = the mem in the console

onyx summit
#

pm2 shows the amount of ram the os gave to the process

#

but the actual used heap is way less

lusty dew
#

Mk well

#

How do I make it not a decimal?

winged thorn
#

math.floor I guess

lusty dew
#

Can't you use Math.floor or smth

onyx summit
#

.toFixed(2)

#

Gives it two numbers after the .

lusty dew
#

Okay thanks!

#

How do you get the ID of an animated emoji without nbitro

#

Nitro*

onyx summit
#

good question

lusty dew
#

Nvm

#

I just did -eval message.guild.emojis.find(i => i.name === "servers")

#

Lol

winged thorn
#

that works I guess

lusty dew
#

Didn't think it'd work but hey

#

😂

winged thorn
onyx summit
#

client.emojis.filter(x=> x.name==='your emoji name here').map(x=> x.toString())

winged thorn
onyx summit
#

that searches for it everywhere

winged thorn
#

noice

lusty dew
#

But I only want from my server ;3

onyx summit
lusty dew
#

Lol

winged thorn
#

if you're in the server

#

just do \:emoji here:

onyx summit
#

but its animated

winged thorn
#

and?

#

you can still do it

lusty dew
#

Not if you don't have nitro

onyx summit
#

I remember having issues with doing that

lusty dew
#

It wouldn't let me

winged thorn
#

that's odd

onyx summit
#

back then when I didnt have nitro uhuh

winged thorn
#

discord is just dumb tbh

lusty dew
#

See

winged thorn
#

why can't they make things consistent

lusty dew
#

Lol

trail dagger
#

How can i get member with a specified permission? Discord.py

#

if someone know please tell me today and not next year

winged thorn
#

Can you elaborate

#

Do you want to check if a member you already have has a specific permission or do you want to get a random member with a specific permission

grizzled canyon
#

Why do I get a forbidden 403 when trying to connect to the API with python?

winged thorn
#

Have you supplied your API key

earnest phoenix
#

are you sure it's a 403 while logging in

#

and not a 403 while trying to do something else e.g modify a user

trail dagger
#

@winged thorn i want to get all members in that guild with the specified permission

winged thorn
#

Filter guild.members by the permission then

grizzled canyon
#

I supplied my bot's token

earnest phoenix
#

incorrect token should return 401, not 403

#

i'm pretty much sure it's impossible to get 403 from logging in

grizzled canyon
#

I passed a different token an got 401

earnest phoenix
#

401 means incorrect token

grizzled canyon
#

yes

#

When I use the real one I get 403

earnest phoenix
#

are you using your bot's token?

grizzled canyon
#

The one that discordbots gave me

earnest phoenix
#

🤦

trail dagger
#

@winged thorn I dont remember how i can filter guild.member by permission

earnest phoenix
#

there you go

winged thorn
#
for member in guild.members:
    if some_permission in member.guild_permissions:
        do stuff```
slender thistle
#

member.guild_permissions.some_permission returning bool

winged thorn
#

or checking specific channel you can use member.permissions_in(channel)

trail dagger
#

if kick_members in member.guild_permissions: kick_members is not definded

#

not working

#

at all

#

not even a little bit

winged thorn
#

k

#

try

if member.guild_permissions.kick_members:```
trail dagger
#

That is working! Thanks

abstract crow
#

@onyx summit Is there a way that I can have the WS server just output data every second so that way whenever I request the data, it is always up to date?

unique nimbus
#

ngl idk what you are doing Vinnie but cant you loop it per second?

abstract crow
#

Yeah but like I don't see that as "economical" for the instance

earnest phoenix
#

thats not the point of a websocket

abstract crow
#

Like I just want the Websocket Server to output my info so no matter when I request it, it is always up to date

earnest phoenix
#

the point of a websocket is to be able to exchange realtime data

abstract crow
#

So heres what I need to do. Maybe WS isn't right then.

Send information from website to bot. Bot does something with that data
Bot sends off stats, website pulls it

earnest phoenix
#

client sends data to the website asking for it's data in return -> server gets it -> server returns back requested data

abstract crow
#

The website and the bot run on separate instances. I have my websites running with a script, and then my bot with another

#

Correct

#

Website tells bot: Hey, send a message in x channel with y content
Bot does that

#

Stats Page: Hey bot, give me the stats right now
Bot: 400 users, 275 servers

earnest phoenix
#

if your website needs to get client data just vice versa it

abstract crow
#

So you mean like the website sending off stuff to the client?

#

The bot is the server from what I was told

#

So website gets data from client, or client gets data from website?

earnest phoenix
#

you got told that your website should be also your websocket server since it needs to handle http requests already

abstract crow
#

Correct

#

So should I use the WS Server for the website sending stuff to the bot?

#

Website says send a message and the bot does that

earnest phoenix
#

and vice versa

abstract crow
#

Ok but is there a way that with the bot, whenever I request data from the WS server, it is automatically up to date?

earnest phoenix
#

you decide what to return in response

abstract crow
#

The website just says tell me the stats. The bot says ok here are the current stats and sends it

#

Does that mean that each request will pull the most up-to-date information

earnest phoenix
#

yes

abstract crow
#

Ok cool

#

What module do you guys recommend for a localhost WS server?

earnest phoenix
#

a websocket is like a continuous stream, it doesn't stop, if you send anything it will be received on the other end in real time, once you receive it you can handle the data and decide what you're going to do next

abstract crow
#

Gotcha

onyx summit
#

dunno tho, don't really use websockets

lusty dew
#

Gn guys I'm done for the night

#

Spent way too long on user-info and info command lmao

abstract crow
#

lol

#

Have a gn!

lusty dew
#

Thank you!

#

Also CHY4E @onyx summit

#

Your service can host websites right?

onyx summit
#

my server already hosts websites, yes

lusty dew
#

Okay, could I host one in the future?

onyx summit
#

sure

lusty dew
#

If I ever get around to it

#

Lol

abstract crow
#

Wait he has is own service?

#

Oooo

lusty dew
#

Ye he allows me to use it

#

Which is very nice of em

winged thorn
#

whats the pricing like

onyx summit
#

no, I have my own server

abstract crow
#

Ooooooo

winged thorn
#

oh it isn't public I getcha

onyx summit
#

and currently 5 plebs host their bots on it

abstract crow
#

lul

winged thorn
#

lmao

lusty dew
#

Hey

#

I'll have you know I'm an Omega pleb @onyx summit

#

:3

onyx summit
lusty dew
#

Lel

topaz fjord
#

@onyx summit ur a pleb

onyx summit
#

okay

#

anything more to say?

topaz fjord
#

not at this time thank you for paying attention mmLol

onyx summit
earnest phoenix
#

ok??

#

Everything Is Updated

#

you dont have to emphasize every message

#

discord is not a module

#

i dont open it with a module
le

west spoke
#

You imported the discord module

earnest phoenix
slender thistle
#

Do you have any folders named discord

earnest phoenix
#

the package name

abstract crow
#

don't run debug configuration. Just run node index.js

earnest phoenix
#

he is in py

#

yes

slender thistle
#

Even though it's python lul

abstract crow
#

Oh ok

earnest phoenix
#

@abstract crow gonna try

#

its py

abstract crow
#

Don't lol

slender thistle
#

Why

earnest phoenix
#

ok

abstract crow
#

Or debug idk

#

Imma give up

earnest phoenix
#

;-;

earnest phoenix
#

@slender thistle yep

slender thistle
#

So

#

Do you think that could be the issue?

earnest phoenix
#

or wdym

slender thistle
#

File/folders, whatever

#

Anything that is named discord

earnest phoenix
#

in folder i put discord.py i put folder named discord?

slender thistle
#

Let's turn logic on

earnest phoenix
#

i put here discord file

slender thistle
#

If you have any file in your bot's folder that is named discord (disregard the file extension), what do you need to do to fix the discord.ext package not found type of error?

earnest phoenix
#

yep

slender thistle
#

That's not a yes/no question

earnest phoenix
#

i need to fix it

#

ou need to do to fix the discord.ext package not found type of error?

#

yes i need

slender thistle
#

what do you need to do to fix the discord.ext package not found type of error?

earnest phoenix
#

i dont know

#

oof

sage bobcat
#

One message removed from a suspended account.

winged thorn
#

do you know how importing works in python?

slender thistle
#

It's trying to import the file you are running

earnest phoenix
slender thistle
#

I never said "create a folder named discord"

earnest phoenix
#

Then What

winged thorn
#

import discord, tries to import something called discord

slender thistle
#

Me:

Do you have any folders named discord
You:
Yes
Me:
Do you think that could be the issue?

earnest phoenix
#

i dont have folders named discord OMG

slender thistle
#

Calm down

#

Folder or file, anything that is named discord

earnest phoenix
#

can u edit it and send me ?

#

no one is downloading that

#

upload your code to a site

slender thistle
#

Congratulations, you exposed your token

earnest phoenix
#

ok dm

slender thistle
#

I'm not fixing your code

#

Because the code is fine

earnest phoenix
#

ok

#

then what

slender thistle
#

I'm gonna ask you again. Do you have any files OR folders that are named discord?

earnest phoenix
#

Where do u want me to find ?

#

i downloaded discord and i have discord files

slender thistle
#

In the folder where you are running the bot file

earnest phoenix
#

no i just created

slender thistle
#

Great

#

You have a file AND a folder named discord

earnest phoenix
#

yea

#

i just made it

#

xd

slender thistle
#

Now, how do you think Python is going to find the PACKAGE, not your custom FOLDERS?

#

If they are named the same

earnest phoenix
#

then what to do

slender thistle
#

Logic, my friend

earnest phoenix
#

yes logic master

#

:

slender thistle
#

If you had two folders with the same name without knowing their contents, which one would you choose?

earnest phoenix
#

any

slender thistle
#

And that's not how Python importing works

abstract crow
#

Is there a way that I can insert into an SQL database but only if there is no current row?

#

With that value*

winged thorn
#

Select statement for a record with that id, if none insert

abstract crow
#

That is what I do now

#

But like I feel like it is overkill

#

There has to be a better way

winged thorn
#

There isn't an easier way

#

From what I've gathered

#

If you want to create a table there's if not exists but no equivalent for records afaik

slender thistle
#

First off, Python searches the folder the file (basically) was ran in. You have file and a folder named discord. Python imports them, but then you are doing from discord.ext import commands, when that gives the error. And the error appears because there's nothing named ext in the discord folder/file.

#

So you are importing the file you are running, essentially.

winged thorn
#

not the module you need

earnest phoenix
#

Ok thats good btw im not coder

#

thats why i dont know must things

slender thistle
#

I would suggest learning simple things (about Python, if you want to go that way) before getting to complex libraries

earnest phoenix
#

a sane person would actually first learn a language they're working with

broken shale
#

@onyx summit modified client

slender thistle
#

Wrong channel

earnest phoenix
#

@slender thistle still nothing btw

slender thistle
#

It would be better if you also sent screenshots that could help me understand what you mean by "nothing"

#

and whatever you did to attempt to fix the issue

abstract crow
#

Hey does anyone know why VScode sometimes when I hit ) or ", it goes to the " right next to the cursor, as if it knows I am ending something, but then other times it just makes another " so I have "memes"" or (memes))

zealous veldt
#

yes

abstract crow
#

But other times, when I hit ), it just goes to the next ) because it knows I am trying to end it

flint trellis
#

there's no way to disable it

#

i get the same issue sometimes

peak quail
#

how can i display the perms from a Role in a embed
🤔

abstract crow
#

we need more info..

peak quail
#

js

#

@ Vinniehat-.-#1067

maiden mauve
#

kinda confused at what answer you want

#

your basically asking how to display a variable in a discord message

#

do you want the syntax of the RichEmbed, how to get user roles?

earnest phoenix
#

Does anyone know the code of making bot-1 add bot-2 on the same server as bot-1?

idle mountain
#

You mean make a bot add another bot? You can’t

earnest phoenix
#

Per?

idle mountain
#

I mean technically you can I guess, but you’d have to simulate a browser and get past the captcha which is unrealistic

earnest phoenix
#

But there are systems that do that

#

Like you

abstract crow
#

If I have a domain, is there a way I can setup emails with it without paying?

earnest phoenix
#

completely normal catToday at 9:53 PM
I mean technically you can I guess, but you’d have to simulate a browser and get past the captcha which is unrealistic

you can't, bot invitation goes through oauth2

west spoke
#

You would have to sign in to the current user

abstract crow
#

Right

west spoke
#

You cant unless you have password

#

I think you can get email through api calls idk

violet dagger
#

right lads

#

im not usually one of the stupid people in this channel but im gonna be stupid this time

idle mountain
#

@earnest phoenix wasn’t thinking, thought of adding it automatically as a user rather than as a bot, my b

violet dagger
abstract crow
#

I don't have name

hollow saddle
#

Are you on stable or master

abstract crow
#

I just have Alive Again! ...., {type: "PLAYING"}

#

client.user.setActivity(status, { type: "PLAYING"});

earnest phoenix
#

Vinniehat-.-Today at 10:00 PM
If I have a domain, is there a way I can setup emails with it without paying?
link your domain to a webserver and then you can use something like nginx to create a mail proxy

hollow saddle
#

Cause yeah on stable, there is no name property

violet dagger
#

uhh im on the version you get when you install via npm mmLol

abstract crow
#

@earnest phoenix My domain is setup with NGINX already. The website is*

#

Would you happen to know where I can set up the mail proxy?

violet dagger
#

^11.4.2

hollow saddle
#

You can install both versions via npm lol

abstract crow
#

@violet dagger Just do client.user.setActivity(status, { type: "PLAYING"});

amber fractal
#

I use cloudflare to forward it to gmail mmulu

abstract crow
#

status = "Alive Again!..."

earnest phoenix
topaz fjord
#

you could try ActivityType.PLAYING

abstract crow
#

Fuck it I will show yo what I exactly do.

client.on("ready", async ready => {
    setInterval(function () {
        let status = statuses[Math.floor(Math.random() * statuses.length)];
        client.user.setActivity(status, { type: "PLAYING"});
    }, 15000)
})
#

const statuses = ["STATUS_1", "STATUS_2"] lol

#

It may not be neat but 🤷

#

thx cry

violet dagger
#

oh ok

#

@lethal wave

#

oh ok statuses show now

#

tf they are like the same thing

abstract crow
#

And it will change every 15 seconds 😃

violet dagger
#

anyway thanks vinnie

abstract crow
#

np

violet dagger
#

yea mine will change to something retarded in 15 seconds

abstract crow
#

lol

violet dagger
#

yes ty

abstract crow
#

Yeah it randomizes it so it may be a duplicate

mossy vine
#

yeah i was about to point that out

violet dagger
#

Hoax Hotel viewers™

#

honestly hands down best yt channel of all time

mossy vine
#

429 is triggered when a ratelimit is hit right? so if several users spam my bots command, will it hit 429 errors?

slender thistle
#

Some Discord libs handle ratelimits so that 429s don't arise

flint trellis
#

coughs discord.js

mossy vine
#

does d.js and eris handle them?

slender thistle
#

Two ways to find out

#

Ask in their support servers or look at the source code

mossy vine
#

one, ask in server. two, wait until it becomes a problem

slender thistle
#

That makes it three then

mossy vine
#

lmao

marble juniper
#

just a simple question

#

how to make an eval command

#

cuz I have no idea how to do it

mossy vine
#

are you using javascript?

marble juniper
#

yes

mossy vine
#

use the builtin eval()

marble juniper
#

ok

mossy vine
#

just please please please make sure only you can run the command

marble juniper
#

yes

#

I already know how to make it

#

just checking for id

#

if it is the same as mine

mossy vine
#

then you just pass the content (removing prefixeval) to eval() and send what it returns

marble juniper
#

ok thanks

earnest phoenix
#

j

fervent pilot
#

When I added the bot it said no grant

#

How long do I have to wait to be able to add it to servers

quartz kindle
#

you need to disable the code grant option

#

in your discord developer settings

fervent pilot
#

Ok thank you

#

@quartz kindle I can’t see that option

quartz kindle
fervent pilot
#

Ok it’s off now

#

This might sound stupid but I’m new to making bots how do you upload the files to the bot so it knows what to do

#

@quartz kindle

quartz kindle
#

a bot is a program, the program needs to run somewhere

unique nimbus
#

you code it

#

yes

quartz kindle
#

either in your computer, or in a server

unique nimbus
quartz kindle
#

you pick a programming language, you install the required tools and dependencies, then you install the relevant discord library

unique nimbus
#

yes

fervent pilot
#

So I code on visual studio code on java script

quartz kindle
#

do you use node.js?

fervent pilot
#

Yes

quartz kindle
#

alright, so install one of the js discord libraries, for example discord.js

#

then follow their documentation

unique nimbus
#

isnt it npm install discord.js

#

idk js

fervent pilot
#

Yes I have installed discord.js

unique nimbus
#

I like manually doing the url and cant spell

quartz kindle
#

double fail

unique nimbus
#

there we go

quartz kindle
#

xD

unique nimbus
#

Read this

#

There should be a Beginners Guide however my wifi is slow so i cant check

fervent pilot
#

So do I upload the files to github then link github and heroku the use heroku to host the bot then create an invite link to my bot is that how it works?

#

@unique nimbus

unique nimbus
#

I don't use Heroku

#

Follow the tutorial ig

fervent pilot
#

Ok thanks for your help

opaque eagle
#

@west raptor ads

#

Thanks

#

This is a really dumb brain-fart-type question: In JavaScript, if I want to get the first N elements from an array, do I slice arr.slice(0,N) or arr.slice(0, N-1)?

shy rose
#

0,N iirc

#

can always just open a console and test that

opaque eagle
#

ok

broken shale
#

you can also look at the MDN docs mmLol

opaque eagle
#

Also one last thing... which one looks neater?```js
arr.map(i => arr.indexOf(i) < 5 ? i - 1 : i);``````js
let firstN = arr.slice(0,n)
.map(e => e - 1);

arr = [...firstN, ...arr.slice(n, arr.length)];```

inner jewel
#

arr.map((value, index) => index < 5 ? value - 1 : value)

opaque eagle
#

oh ok

inner jewel
opaque eagle
#

oh

#

wait no it was in the line before that lol

#

I map the array but i don't assign it to arr

#

wait still undefined... hmmm

inner jewel
#

because it returns undefined

#

look at all possible exit points of the function

opaque eagle
#

Ohhhhhhhhhh

#

I'm so dumb xD

#

The return keyword

#

Hmm... all of the test cases work properly except for #3, #5, and #7
(Test cases are in reddit link)

#

I added the test cases to the repl

lusty dew
#
if(member.lastMessage.content === null){
                    lastMessage = 'None'
                }else{
                    lastMessage = member.lastMessage.content
                }
#

I keep getting errors with the member.lastMessage.content === null thing

opaque eagle
#

Nvm I fixed it

lusty dew
#
2|clap  |     at Object.run (/home/panda/Clap Bot/commands/uInfo.js:31:39)
#

And that’s what I’m trying to check for hmph

#

Oh wait

#

Fixes it

lusty dew
#

I'm trying to get the account age in years if their age is older or equal to 1 year

#

The person I got the info on account was made in 2016

earnest phoenix
#

subtract the createdAt date from the date right now and you'll get the age

#

math basics

lusty dew
#

I am

#

Well actually I'm doing that in the check

#
if(userTime >= 31536000000){
                    time = moment(member.user.createdAt).format('Y')
                }else{
                    time = moment(member.user.createdAt).format('MM/D/YY | HH:mm:ss a')
                }
#

That's my code

#

And userTime = Date.now() - member.createdAt

#

The check works

#

I tested that twice

#

It's the formatting

#

I can't remember how to display just like 1 year or 2 years, it responds with 16 or 2016

#

Which I don't want

earnest phoenix
#

all you have to do is divide userTime by length of a year

#

or you can get the utc year and subtract it by 1970

lusty dew
#

Why would I still be using userTime?

earnest phoenix
#

ah wait you want to format it

lusty dew
#

Ye

#

So it just displays the number of years their account is

earnest phoenix
#

you don't even need moment for that

lusty dew
#

Like if they made their account in 2016 it'd display 3 years

#

Really?

#

Never knew you could do it a different way

earnest phoenix
valid frigate
#

and on a side note, exporting the constant shardingManager would just cause the main script to loop

lusty dew
#

@earnest phoenix I'm a bit confused by that, what would I use the getUTCFullYear thing on

#

Seems like the thing I'd use

#

To calculate what I need

earnest phoenix
#

it would be a Date instance of the date.now - createdAt differential

lusty dew
#

So I'd do userTime.getUTCFullYear()?

#

@earnest phoenix Thanks I saw my problem ^

#

I figured it out heh

earnest phoenix
#

nice 👍

lusty dew
#

Had to do new Date(userTime)

earnest phoenix
#

didn't see the question above, my b

lusty dew
#

It's fine

#

It led me to explore further and see my own problem!

abstract crow
#

So when I hit submit I need the HTML to run a JS file to send over information via a WS server... The thing is, is that I THINK I need node for that. How can I do that?

earnest phoenix
#

How do i make a dashboard for my bot? (IE: ability to select what commands can be used in a server, etc)

abstract crow
#

@earnest phoenix Oauth2

#

Use that and read up on the Discord Docs. It shows you what you need to get started and stuffios

earnest phoenix
#

Alright, thanks.

maiden mauve
#

I hate using full year date object

#

it's so much information for small tasks

#

but it always works

lusty dew
#

I'm trying to load guildData with a custom function but in my case I need to load it by guild ID which I can't cause I'm not loading the data in a command
Here's my code:
https://paste.nomsy.net/uzinukayuw.js
Trying to add in customizable prefixes per server

#

That's updated my bad

#

The link was being weird

untold parrot
#

Quick question about hosting. Are there any super easy hosting options for bots? I have a simple dice roller I'd like to have up 24/7 and launching it all the time via boxshell is getting old. I've tried the amazon AWS stuff but for whatever reason it shuts down about a day after starting.

maiden mauve
#

@untold parrot I've had pretty good uptime with Heroku.

#

every now and then some slow replies but 100% uptime

valid frigate
#

heroku doesnt count as a vps

#

you should consider hosting your bot in a vps, if you ask some experienced bot developers they can point you to good cheap options

#

iirc heroku also requires additional setup/if the bot isnt doing anything it shuts down after 30 minutes of inactivity

lusty dew
#

Heroku or glitch would get you API banned iirc

valid frigate
#

hosting has nothing to do with api, it's based on how many requests you make etc.

maiden mauve
#

why would heroku get you api banned?

#

@lusty dew

lusty dew
#

@valid frigate Heroku and glitch can cause API bans

#

Sorry that I worded it wrong

maiden mauve
#

I've been using Heroku for a month now

#

100% uptime

#

small project

valid frigate
#

even if it's small

#

vps time mmLol

lusty dew
#

Not sure about Heroku but glitch

valid frigate
#

plus you can mess around with your server as an added bonus

lusty dew
#

Causes API spam

maiden mauve
#

any server would be the same API threshold?

#

unless you literally sharded a new webserver for every guild?

lusty dew
#

Cause every time code is edited it autosaves and makes the bot relogin

maiden mauve
#

but local hosting (testing for example) you relogin in the bot 100 times a day

#

and its no issue

lusty dew
#

Which causes problems with API spam you're only allowed to login 1000 times before it's ratelimited

maiden mauve
#

unless your testing code specific to the server environment why would you push an update

lusty dew
#

So if you edit code on glitch 1000 times + taking In account if something goes wrong and errors glitch is just gonna keep logging your bot in over and over

maiden mauve
#

I've updated my code to Heroku maybe 15 times of the 300 i've done locally

lusty dew
#

Heroku is just bad either way

#

It wasn't mean for bots

#

Meant*

#

And you run into problems of something iirc needing to pay for more storage or whatever

maiden mauve
#

🤷

#

it works for my users

lusty dew
#

Still use a VPS...

#

It's highly recommended

#

And pretty cheap

valid frigate
#

someone mentioned like $3 a month

lusty dew
#

You can get a VPS that suits what you need for 3-5$

valid frigate
#
  • you can use people's DO referral codes for like $50 free
lusty dew
#

Ye

valid frigate
#

with their cheapest option you get 10 months without having to pay

lusty dew
#

Yea

untold parrot
#

Speaking of, with my little guy I'm making I notice in the shell that it has a tendency to log in a bunch of times even when I'm not editing any of my .js files, it stopped most of the logins after I turned off malwarebytes but it'll still sometimes still login and send the "ready" message as if it had been changed. I'm not sure what's happening.

lusty dew
#

Do you use nodemon?

untold parrot
#

Yeah, through boxstarter

lusty dew
#

Nodemon will restart your bot Everytime it senses a change in the bot files

untold parrot
#

Even if I'm not actively editing any of them?

lusty dew
#

You don't have to be editing them

#

The bot can write data to a json and it'd restart

untold parrot
#

That makes more sense

lusty dew
#

All that needs to happen for it to restart with nodemon is a change in any of the bot files

untold parrot
#

Gotcha, is there a better way to run the .js without it doing so? Or is that a required function of running a bot?

lusty dew
#

That's why I stopped using nodemon

untold parrot
#

(I literally started all this a week ago so I'm very very new to all of this)

lusty dew
#

use the built in thing when you download nodejs

#

node botfile.js

#

Ofc change botfile to your main file name

untold parrot
#

Oh neat. Cool, yeah I was just following the nodemon instructions, I assume that it's mostly meant for hot reloading so you can test/run it at the same time?

lusty dew
#

Yea ig

#

But it was a bad idea imo

untold parrot
#

rad

#

Hmm, I wonder if my use of nodemon while on Amazon AWS is what caused it to eventually time out. I might see about just node n.js with it and see if it behaves any better.

lusty dew
#

If you are using a vps

#

Use pm2

untold parrot
#

The primary difference?

lusty dew
#

There you go

untold parrot
#

There is so much stuff I still need to learn.

#

Hah, that hits me everytime I see a new thing like this

lusty dew
#

Lol

#

Pm2 will keep your bot running on the vps

opaque eagle
#

Any way to make this any more efficient? It's been more than a minute since I ran that code, and it's still calculating.

Question: https://projecteuler.net/problem=12

#!/usr/bin/env ruby
def divisors(num)
    return (1..num).select { |n| num % n == 0 }
end

def find_tri_num(n)
    return (n * (n + 1)) / 2
end

i = 0
until divisors(find_tri_num(i)).length > 500
    i = i + 1
end

puts find_tri_num(i)```
#

I tried to "cheat" by counting down from 10,000 instead of counting up from 0, but then each calculation takes a fuck ton of time

stone dust
#

you can save some time by only calculating factors up to the square root of a number

opaque eagle
#

oh yeahhh

#

what if that number isn't a perfect square

stone dust
#

just subtract 1 if it is, I think

#

assuming the loop is inclusive

#

nvm

lusty dew
#

I am getting this I've got it 3 times now

#

I've already tried async/await

opaque eagle
#

Show code

lusty dew
#
  .addField('Last 1000 votes ' + `${dbl.getVotes().then(async votes => { await votes.length})}`, 'Only returns the last 1000 votes from dbl')```
opaque eagle
#

Go learn how promises work pls

#

That code frightens me

#

Also go and learn how arrow functions work

lusty dew
#

Hm?

#

Lol okay

opaque eagle
#

Also fix that mess you've got there with strings... that totally disregards what template literals were made to fix.```js
'Last 1000 votes ' + content

lusty dew
#

I'll format it how I want

opaque eagle
#

I don't think u understand why they exist in the first place

#

Also you're forgetting a }

lusty dew
#

And where is that?

opaque eagle
#

After votes.length

lusty dew
#

It's there

#

You're blind

opaque eagle
#

You need two

lusty dew
#

I have two

opaque eagle
#

One to close that disaster of an arrow function and the other for the interpolation

lusty dew
#

Again you're blind

opaque eagle
#

You have a parentheses in the middle

lusty dew
#

And another bracket at the end

opaque eagle
#

nvm

lusty dew
#

Which closes it

opaque eagle
#

that was smth else

lusty dew
#

See you're blind

#

Smh

#

And how is my arrow function a disaster?

#

Please do tell

opaque eagle
#

You seriously don't see what's wrong therejs async votes => { await votes.length}

lusty dew
#

Nope

valid frigate
#

bruh

opaque eagle
#

two things... unnecessary async/await + no return keyword

#

You need to go learn how javascript works

lusty dew
#

Okay

#

Cool GWcmeisterPeepoShrug

valid frigate
#

oh lmao theres no return value

opaque eagle
#

Yeah lol

#

He opened up those curly braces so he needs the return keyword there

valid frigate
#

to be honest

#

properties dont need async/await

opaque eagle
#

They don't

valid frigate
#

methods might

opaque eagle
#

That's why, go learn javascript

valid frigate
#

rule of thumb

opaque eagle
#

properties don't ever need async/await?

#

what r u talking about

valid frigate
#

idk

opaque eagle
#

methods need them if they return a promise

#

properties never return a promise....

valid frigate
#

uh yeah

#

¯_(ツ)_/¯

cinder patio
#

getters

opaque eagle
#

Yeah I guess

#

but Array.prototype.length doesn't so i guess we're good there

lusty dew
#

Meh still not working

opaque eagle
#

So you went ahead and learned how promises work?

valid frigate
#

is getVotes() async

opaque eagle
#

Tell me how you used your new understanding of promises to fix the error

lusty dew
#

Reading about it a bit rn

opaque eagle
#

Yeah @valid frigate

valid frigate
#

oh lmao

#

i dont read up on dbl api

opaque eagle
#

I don't use the JS library so eh

#

I like to write my own requests and webhook server

valid frigate
#

it's such a simple webhook server

opaque eagle
#

Yeah, I use my own webhook server that I wrote in Rust

spare venture
#

What would be the best way to gather shard/bot data, and output it to a website page? ( an example would be something, but a bit more simplified, what dyno has over his status page https://dyno.gg/status)

quartz kindle
#

run a webserver in the same machine and connect to the bot's database

opaque eagle
#

or use an api

gaunt basin
#

This has happened to be twice now

#

Anyone know who's in charge of this? I'm confident that it is not allowed

#

Also I'm in no servers with the bot

unique nimbus
#

@gaunt basin Can you get the id

#

I think it might be banned

opaque eagle
#

The user who made the invite link was banned

gaunt basin
#

535113488125788191
581988405139996682

unique nimbus
#

I think the bot is banned

gaunt basin
#

He wasn't

#

I joined the discord

opaque eagle
#

In the invite box, it says zPraDz has invited you to join"

gaunt basin
#

And he was there

unique nimbus
#

@tranquil bobcat

#

@jaunty iron

opaque eagle
#

that user was banned from DBL

unique nimbus
#

they aint here

gaunt basin
#

Oh ok

unique nimbus
#

else it would be pinged

gaunt basin
#

But anyone know why this is happening

#

Like this can't be allowed

unique nimbus
#

DM Advertising

#

they were banned

gaunt basin
#

Report to discord?

unique nimbus
#

nah the mods handles it

#

it happens daily ngl

gaunt basin
#

So this isn't against ToS?

opaque eagle
#

it is

unique nimbus
#

it is

gaunt basin
midnight vine
#

I make a converter in binary, unfortunately the for takes each number one by one, or it must take them by 5, I can not find a solution, see know one?

quartz kindle
#

make it an array and loop over the array instead?

#
"01010 10101 01001" -> ["01010","10101","01001"]
for item in array```
#

or however arrays work in python

midnight vine
#

this is a good idea, thanks

eager kraken
#

How do I retrieve the second mentioned member in a message in discord.js?

tight heath
#

the message mentions are a Collection which is an extended map

#

maps are not really meant to be indexed

#

you could do a hackaround using msg.mentions.first(2)[1]

#

or msg.mentions.array()[1]

#

@eager kraken

eager kraken
#

All this time, I was thinking message.mentions as an array.

#

Reeeeeee I am dumb.

tight heath
#

heh

#

it's a Collection

eager kraken
#

Tysm.

tight heath
#

yw ^°^

lusty dew
#

Didn't know you could pass numbers in the .first()

#

Though never was smart enough to look it up either lel

tight heath
#

:p

#

I've been using d.js for quite the while now sooo

lusty dew
#

Yea

#

I've been using it for 2 years now

#

Lel

#

Though I took a long break

tight heath
#

oh lmao

lusty dew
#

Yea

tight heath
#

my first project was may 2017

lusty dew
#

Oof

tight heath
#

so not much longer

lusty dew
#

Mine was 2017 as well

#

Very first bot I made was in python actually

#

Then I switched to d.js

tight heath
#

oh yeah

lusty dew
#

Then to d.js master

tight heath
#

i tried C# but it hurt my brain as a complete beginner

#

and yes master >>>>>>>>>>>>>>>> stable

lusty dew
#

About 2 months ago

#

I was recommended to learn

#

C, C#, C++, then Java

#

In that order

#

Or C# and C++ could have been switched around

#

It was about that order lel

#

Honestly wanna dive back into python

#

But I forgot all that I learned lel

#

@tight heath do you know python?

tight heath
#

the very basics only

lusty dew
#

Oof

#

Teach me ;3

#

Jk

#

I need to find a way to learn python again though

#

I don't think they have python docs do they?

earnest phoenix
#

nope

#

python docs are a no no

tight heath
#

there are py docs but they're only useful as a reference

#

not for learning

#

same as nodejs docs

#

¯_(ツ)_/¯

earnest phoenix
#

yeah true

tight heath
#

like

#

I've recently implemented my own small websocket thing in node

#

and looking up the crypto api in the docs was actually useful

earnest phoenix
#

i have not even made my bot idk where to start

tight heath
lusty dew
#

Learning a lang is a good start

tight heath
#

is by far the easiest way

#

the d.js community has so many help resources

lusty dew
#

I watched a 3hr crash course on python

#

Didn't work at all

#

I forgot everything 😂

tight heath
#

and it's cool

lusty dew
#

Oh shit

tight heath
#

yeah web dash lol

lusty dew
#

That's help me as well

tight heath
#

oauth2 is super complicated usually

lusty dew
#

I need to implement oauth2 in my project so I can connect it to a website

#

Bookmarking that shitn

tight heath
#

hehe

#

even though I prefer canvas-constructor

lusty dew
#

Book marking that as well

tight heath
#

and even more I prefer using C++

#

because image manipulation in js is slow as heck

lusty dew
#

You know C++?

tight heath
#

no but i have a guy in my project who does

#

so

#

¯_(ツ)_/¯

lusty dew
#

😂

tight heath
lusty dew
#

Nice

tight heath
#

but like don't get me wrong

lusty dew
#

I honestly wanna Collab with someone

tight heath
#

I can read C++

lusty dew
#

I miss it

tight heath
#

I just can't write it

#

btw you can join aero at any time :p

#

might even get a free JetBrains license

lusty dew
#

Aero?

tight heath
#

the project I'm working on

lusty dew
#

Ah cool

#

I have to get a new PC first

#

Been coding on my phone

#

Which is big ouchy

#

But luckily most of the errors i get are just typos

#

Lel

tight heath
lusty dew
#

👀

#

I heard jetbrains is good

tight heath
#

OSS licenses

#

and yup

lusty dew
#

Better then VSC?

tight heath
#

VSC is a text editor

#

JetBrains makes IDEs

#

stuff that actually understands what you're doing

lusty dew
#

Visual studio code is an IDE as well at times

#

When it decides to work

#

😂

tight heath
#

not really no

#

VSC is like a mixin between a text editor like sublime

#

and an actual IDE like IntelliJ

lusty dew
#

Most of the IDE extensions crash

tight heath
#

but it's not any of those

lusty dew
#

Ye

#

Jetbrains is good

#

Used a trial version of it

tight heath
#

well VSCode is in electron so it isn't very performant

lusty dew
#

Isn't discord in electron?

#

I heard that it was

unique nimbus
#

@lusty dew Are you a student?

lusty dew
#

Don't know if it's true

#

@unique nimbus Highschool yr

tight heath
#

discord client is electron

lusty dew
#

Ye

unique nimbus
lusty dew
#

O.o

unique nimbus
#

put in your student email and you get free professional

#

for a year then you have to renew it

tight heath
#

well using OSS I get licenses as long as the project exists

#

unrelated to student stuff

lusty dew
#

What project is aero working on rn?

tight heath
#

Aero is the project

#

:p

lusty dew
#

Oh

tight heath
lusty dew
#

What does it do

tight heath
#

lots of funny things, focus on extensive automod

#

and scalability

#

to handle shards and communication

#

basically this is my playground with everything future tech

#

all the stuff you wouldn't do in your first discord bot

#

but rather all the cool stuff

#

websockets, oauth2, clusterizing, imagegen, ...

lusty dew
#

I just looked at the profile command

#

Holy hell

#

😂

unique nimbus
#

profile commands are long normally

tight heath
#

oh lol idek if it works

#

most of this is copied from my old projects

unique nimbus
#

when I made my one it was like 150 lines

tight heath
lusty dew
#

I can help test it if you want UwU

tight heath
#

haven't refactored yet

#

oh sure

#

if you don't mind I'll dm you an inv

lusty dew
#

I once filled a json with 1000+ lines of data

#

No I don't

tight heath
#

yeet we use mongo

lusty dew
#

Go ahead

tight heath
#

:p

lusty dew
#

This was something mongo would hate

#

😂

#

It was a tos bot

#

Just something to do and fuck around with

#

Yukari

tight heath
#

oh oof

lusty dew
#

Deleted it from DBL a few days ago

#

Got up to 14 servers that's it

tight heath
#

someone needs to remind me to clusterize mongo

lusty dew
#

I use mongodb as well

tight heath
#

because currently mongo is the only thing not running in multiple instances

#

but only on one server

#

which means it's prone to errors and downtime

#

because like

#

all the rest runs in this

#

which are decentralized between 3 data centers

#

2 in EUW, 1 in US-East

quartz kindle
#

did you name them yourself?

lusty dew
#

Can someone help me with a mongodb problem

#

I don't get any errors

#

But my bot won't write userData to the db

#
const Discord = require('discord.js')
const db = require('./db_connections.js')
module.exports = (client) => {
    client.checkUserExist = async function (id, cb) {
    try {
      let data = await db.loadUserData(id)
      if (!data) {
        data = await db.writeUserData(id, {
          id,
          bal: client.settings.starting_balance,
          xp: client.settings.startingXP,
          xpMultiplier: 1,
          coinMultiplier: 1
        })
      }
      return cb ? void cb(null, data) : data
    } catch (e) {
      return cb ? void cb(e) : Promise.reject(e)
    }
  }

}
#

My friend helped me write this code

small prairie
#

i need help

#

on databases

#

i am using json which is HE** i dont like it at all my files have got corrupted two times i need help on setting some else like sqlite i cant use mongodb as the serveice which i am using to host my bot doesnt really alllows mongodb

earnest phoenix
#

don't use heroku

#

problem solved

small prairie
#

nah i dont use hereku lol

#

@earnest phoenix

#

and hows that prblem lol

quartz kindle
#

sqlite is more than enough for most cases

#

which language are you working on?

small prairie
#

discord.js

quartz kindle
#

take a look at better-sqlite3

small prairie
#

ohkay will do 👍

#

that will be okay for customizable prefix and other things right? like customizable message

#

like welcome message

quartz kindle
#

yes

#

reading from a small sqlite db usually takes less than 1ms

lusty dew
#

Damn

#

Someone else comes in talking about dbs and gets instant help

#

😂

quartz kindle
#

coincidence

lusty dew
#

IKR

#

Honestly though plz someone help user side database has been broken for weeks

quartz kindle
#

also i dont use mongo, and i dont know what your db class is, so i cant help

#

but you should at least show your db_connections file

lusty dew
#

Ye I was about too

#

Brb

winged thorn
#

I'd recommend sqlite

#

I use it

quartz kindle
#

same

lusty dew
#

Idk sqlite

#

But I am looking to switch dbs soon

winged thorn
#

It's simple

#

Just learn basic SQL syntax and you're set

lusty dew
#

I'll probably work on switching dbs when I get a PC

#

Old one broke

winged thorn
#

When I get back from holiday I was planning to switch to postgres

earnest phoenix
#

you can also use some ORM frameworks

#

e.g sequelize

lusty dew
#

Db_connections file

#

I'ma put that in a hastebin or smth

#

Brb

winged thorn
#

Isn't mongo just fancy json with good performance

tight heath
#

@quartz kindle those are the anemoi, greek wind deities

#

@winged thorn and caching and stuff

quartz kindle
#

cool names

lusty dew
#

I'm reading up on oauth2 at the same time

#

Holy hell

tight heath
#

@lusty dew you might wanna not put your credentials in a paste

lusty dew
#

Ah shit forgot

winged thorn
#

Yeah probably not a good idea

lusty dew
#

There

#

Lel

quartz kindle
#

well this is one thing i noticed

lusty dew
#

Oh shit fuck me

#

I forgot to change it again

#

Ugh

#

Changed

#

Maybe that was the problem all along?

quartz kindle
#

also, idk if you can use {id}, i can only see {id:id} in the mongo docs

lusty dew
#

It works for loadGuildData

#

writeGuildData*

quartz kindle
#

well then ok

lusty dew
#

Basically same thing with different naming

#

Could that callback thing have been the problem the whole time?

quartz kindle
#

no idea

#

try it and see

lusty dew
#

Well testing time

#

Lel

#

I'ma try and add a console log

quartz kindle
#

btw, any specific reason you are mixing promises and callbacks?

#

promises are kinda supposed to replace callbacks or avoid needing them

lusty dew
#

My friend helped me write the code he suggested that part

#

Idk why either

#

But I'm switching dbs rn

#

Soon*

#

So as long as it works for now

#

I'm fine with how it is

#

Nope

#

Didn't work @quartz kindle

#

Actually

#

Is the function even running

#

Wait I haven't called it yet

#

Is there a way I can call it when a user talks in the server?

cinder patio
#

in the message event

lusty dew
#

Would I pass it like client.checkUserExist(message)?

earnest phoenix
#

anyone here