#development

1 messages · Page 818 of 1

copper cradle
#

🤦

#

post both

digital ibex
copper cradle
#

aight

late hill
#

well yes

#

it never logs in

digital ibex
#

o

copper cradle
#

you're not even authenticating

pale vessel
#

what's bot.js for

copper cradle
#
#

and fucking learn

pale vessel
#

hey

copper cradle
#

don't copy & paste code

#

I'm being a bit deliberate

#

ik

pale vessel
#

why does he have 2 files

digital ibex
#

what

late hill
#

likely because he wants to switch things up

digital ibex
#

where has it been copied

late hill
#

and keep the old version

pale vessel
#

i thought he was sharding

late hill
#

not the issue right now

copper cradle
#

there's no way you wrote all of that and you don't know how it works

#

like

#

really

pale vessel
#

maybe he just forgot

digital ibex
#

i didn't write the class

#

thats all

copper cradle
#

yeah

late hill
#

which is kind of an issue

#

your commands won't work yet even if you fix the login

#

You just have a command class that's never used atm

digital ibex
#

oh

copper cradle
#

and those files have nothing to do with each other

#

like

#

what's the point of having those

#

if they don't interact with each other

digital ibex
#

ik

copper cradle
#

what are you even trying to accomplish with that

digital ibex
#

index.js and bot.js are nothing to do with each other

late hill
#

he wants to switch from the one file thing

#

to a command handler

digital ibex
#

yes

late hill
#

he just still has the old index

copper cradle
#

bruh

#

delete that index.js file lmao

pale vessel
#

no keep it somewhere else

#

wait you're right. it's better to rewrite the whole code

digital ibex
#

tbh

#

i am still confused on why you needed to see index.js but ok

pale vessel
#

tell you what, delete both files

#

ez

digital ibex
#

uh

copper cradle
#

@digital ibex bc you're not being clear

digital ibex
#

how would i set up my cmd handler then

copper cradle
#

dude

#

there are easier ways of doing so

pale vessel
#

d o c s

copper cradle
#

why don't you use discord.js-commando?

#

it has a built in command handler

digital ibex
#

i can use it with eris?

pale vessel
#

no

#

do you prefer eris?

digital ibex
#

yes

pale vessel
#

okay

copper cradle
#

well

pale vessel
#

that's all right

mossy vine
#

@copper cradle commando is ass

pale vessel
#

maybe he loves ass

copper cradle
#

@mossy vine ik

#

it's gay af

earnest phoenix
#

Help

#

discord js requires a peer of @Discordjs/uws@10.149.0 but none is installed you must install peer dependencies yourself

pale vessel
#

ignore that

#

it's optional

earnest phoenix
#

But it won't let me install sqlite

pale vessel
#

well install it then

earnest phoenix
#

I did but that comes

plucky jewel
#

Help with embed text

#

Pls

pale vessel
#

details please. what are you trying to do?

plucky jewel
tight plinth
#

@earnest phoenix show errors

#

When u try to install sqlite

earnest phoenix
#

Sry it on the TV

pale vessel
#

gyp lol

#

god damn it

earnest phoenix
#

Ik

tight plinth
#

Pnpm

#

Lol

earnest phoenix
#

I tried thing online ok

tight plinth
#

And

#

Upgrade node

open aspen
#

Pls bal

finite bough
#

@earnest phoenix ik why

tight plinth
earnest phoenix
#

@finite bough yes what is it

finite bough
#

@earnest phoenix install node-gyp

earnest phoenix
#

Hmmm

tight plinth
#

^^^

finite bough
#

it is required

earnest phoenix
#

Rip it doesn't work

pale vessel
#

Upgrade node

#

try that

earnest phoenix
#

That is the newest version

finite bough
#

it should work

pale vessel
#

but it does

#

Nt

finite bough
#

show error

#

@pale vessel dont make me nut on u

pale vessel
#

ah yes

earnest phoenix
#

Look on top

finite bough
#

new error

pale vessel
#

gyp always throws errors for me

finite bough
#

install node-pre-gyp then

pale vessel
#

that's not going to work

finite bough
#

believe it or not u cant do stuff without it

pale vessel
#

but tryitandsee

finite bough
#

sqlite needs it

#

if u dont want it

#

use some other db like quick db

pale vessel
#

i'm guessing quickdb isn't native

earnest phoenix
#

Can't

finite bough
#

install node-pre-gyp

#

it says there bro

earnest phoenix
#

K

finite bough
#

why dont people try to read the error

earnest phoenix
#

Rip

tight plinth
#

I have node 13

earnest phoenix
#

Doesn't work

finite bough
#

u still get the error

#

install: node-pre-gyp?

pale vessel
#

nope

earnest phoenix
#

Wait what is the new pre ver

finite bough
#

ehh

#

holdon

earnest phoenix
#

Or rath nodegyp ver

finite bough
#

0.14.0

earnest phoenix
#

Yah

#

It right

finite bough
#

working now

#

?

earnest phoenix
#

Nah

finite bough
#

show the new error

earnest phoenix
#

Is sqlite supported on Linux

finite bough
#

show ur package.json

earnest phoenix
pale vessel
#

i can't see shit

earnest phoenix
#

I could us my old js package

pale vessel
#

use node fetch

#

snekfetch is deprecated

finite bough
#

how about we fix the issue 1st before upgrading things

pale vessel
#

lol

#

you can't fix the first issue

hoary elm
#

Install SQLite3 as well I recieved that error when installing SQLite without it

finite bough
tight plinth
#

better-sqlite3

#

try this

finite bough
#

u forgot a gf

tight plinth
#

her u go

finite bough
#

yea

#

why am I using light theme

pale vessel
#

y not

earnest phoenix
#

Hmmm

#

Ohhhhh

pale vessel
#

figured it out?

earnest phoenix
#

Wait is there sqlite for Linux

pale vessel
#

what was that ohhhh for

earnest phoenix
#

Is it because it can't find it

#

If so we'll there goes my level codes

pale vessel
#

if someone knows a solution please tell me

#

i kinda need gyp too

#

but can't seem to install it

finite bough
#

use glitch;)

earnest phoenix
#

glitch stinky

pale vessel
#

i thought pinging doesn't work anymore? like the app still sleep even after 12 hours

earnest phoenix
#

Oh dam I found something

finite bough
#

@pale vesselwdym

pale vessel
#

last time i used it, it didn't go well

earnest phoenix
tight plinth
#

use glitch;)
@finite bough hell no

pale vessel
#

rn I'm using heroku

earnest phoenix
#

i have to compile it my self

finite bough
#

why not

earnest phoenix
#

reeeeeeee

finite bough
#

@tight plinth why not

#

give me a good reason and I will accept

tight plinth
#

uptime

pale vessel
#

true

finite bough
#

I GOT 12 DAYS UPTIME

#

sry caps

tight plinth
#

without uptime robot orany http request

finite bough
#

kinda raged

#

nothing is free ya know

pale vessel
#

heroku is free

finite bough
#

5 lines of code to make ur bot have an awesome uptime doesnt hurt

tight plinth
#

I got my vps for free

zenith terrace
#

uptimerobot is free

tight plinth
#

lol

finite bough
#

^

#

I use it yes

#

on my main bot project

#

I got permission from glitch

#

to make my bot 24/7

#

without http or robots

pale vessel
#

seems legit

finite bough
#

they removed that feature coz

#

it was getting laggy

#

u can still see the feature on ur project

#

but u cant turn it on

#

in project status

#

or condition

pale vessel
#

what's it called?

plucky jewel
#

lol

pale vessel
#

good one

zenith terrace
#

Oof

tight plinth
#

is there any js client.on('messageEdited', oldMessage, newMessage => { event on ds v12?

#

or smth similar

pale vessel
#

it's the same

tight plinth
#

lol

pale vessel
#

oldMessage, newMessage

#

not just message

zealous veldt
#

when using d.js sharding are you supposed to remove client#login from the bot file?

tight plinth
#

like this?

pale vessel
#

add bracket

#

and yes

tight plinth
#

according to djs guide yes @zealous veldt

compact tundra
#

anyone here good at obj c

lyric mountain
#

lol obj c

zealous veldt
#

ok

earnest phoenix
#

Can anyone help me with making a ticket system that involved reactions

compact tundra
#

i know but it’s the only normaal code lang for macos 10.7

lyric mountain
#

Can anyone help me with making a ticket system that involved reactions
@earnest phoenix language?

golden condor
#

@finite bough how is your bot 24/7

#

on glitch

zenith terrace
#

Bruh

slender thistle
#

Ehh

delicate zephyr
#

@modern sable

modern sable
#

@plucky jewel wrong channel

lyric mountain
#

I guess he meant "look, it worked!"

zenith terrace
#

@golden condor uptimerobot

golden condor
#

No

#

I know that

#

Just how it stop restarting

#

I use uptimerobot

#

They said it as if they didn't have restart

zenith terrace
#

Oh

#

Idk

grizzled raven
#

at what point in a bot's growth is a sqlite database not recommended anymore

lyric mountain
#

never

grizzled raven
#

ok

lyric mountain
#

HOWEVER

grizzled raven
lyric mountain
#

if you rely a lot on db-side operations then you might want to use a more complete db

#

I use mysql as main db and sqlite as cache db

grizzled raven
#

hm

earnest phoenix
#

mysql yuck

lyric mountain
#

but if you're using only common datatypes (text, numbers, dates, etc) then you can stay with sqlite as long as you want, it's fast af

#

@earnest phoenix ytho

grizzled raven
#

😳

earnest phoenix
#

because mysql is developed by oracle

median ridge
earnest phoenix
#

and oracle is well... oracle, they're idiots

grizzled raven
#

try {} catch{} 😎

earnest phoenix
#

postgres is superior

grizzled raven
#

oh wait py

golden condor
median ridge
#

I meant except ____:

grizzled raven
#

try: True catch: False finally: None

earnest phoenix
#

what's your code

grizzled raven
#

yes im so cool

golden condor
#

Who me?

slender thistle
#

discord.HTTPException

earnest phoenix
#

no, super mech

golden condor
#

Ok

earnest phoenix
#

try catching wastes memory, do your best to fix the problem instead

lyric mountain
#

@earnest phoenix mysql has no fault that oracle's being a dick, it's a quite good db

median ridge
#

What if a user doesn't send a url

earnest phoenix
#

it's outdated and slow

lyric mountain
#

slow?

slender thistle
#

Set a default value

lyric mountain
#

outdated??

median ridge
#

Well, I wanted to tell the user that it was not valid.

earnest phoenix
#

a number of benchmarks show mysql being outperformed by postgres

#

postgres is also opensource

lyric mountain
#

could you show me your source?

earnest phoenix
#

what

modest maple
#

you can litterally look it up

lyric mountain
modest maple
#

its pretty well regarded that Mysql is lesser than Postgres

earnest phoenix
#

it's development related, it doesn't need to be in off topic

modest maple
#

^

earnest phoenix
#

anyways, almost every stress test between mysql and postgres shows that postgres outperforms by a mile

lyric mountain
modest maple
#

it is related

earnest phoenix
#

indeed it is

lyric mountain
#

not about bots

#

anyway

earnest phoenix
#

????????????

#

the bot is in parentheses for a reason

#

this is on topic for development peepoClown

lyric mountain
#

|| still ||
I'll see how better postgres is, then I'll say what I think

modest maple
#

its pretty much better in every way tbh

earnest phoenix
#

^

#

i've tried both

#

my experience with postgres vs mysql is like heaven vs hell

#

lmao

lyric mountain
#

I'll have to try it myself, every case is a case

earnest phoenix
#

you'll often see postgres being used in newer indie games

#

because of the sheer fact it outperforms mysql in big datasets

modest maple
#

i either use Postgres or Datomic

zenith terrace
#

Wee woo

#

Bot

dark swift
#

how do I hide my api key from github?

earnest phoenix
#

use a gitignore

#

and have the key in a config file of sorts

zenith terrace
#

Or just edit it I guess

earnest phoenix
#

Could forget to take it out when making a new commit though

#

So tbf you could but you probably shouldn't

#

and just make life easier with a gitignore™️

golden condor
#

Hello I am using ytdl

#

and my bot keeps connecting and disconnecting

#

With the error "undefined"

earnest phoenix
#

I think we'll need a bit more than just that

golden condor
#

That's all I have

solemn quartz
#

lol

golden condor
#

MY bot just restarted and keeps doing this now all of a sudden

earnest phoenix
#

nobody can help you if you don't provide more info about the error, and don't provide code

solemn quartz
earnest phoenix
#

^^^^

solemn quartz
#

lol

golden condor
#

Ok

earnest phoenix
#

My bot has an error how do I fix it??

solemn quartz
#

lol

lol

golden condor
#

I am just giving what I had to work with

solemn quartz
#

@golden condor give us the command code

#

and the error code

#

we will see

#

That's it

golden condor
#

erro = undefined

solemn quartz
#

I meaned the command code :p

#

but its the same

#

So what is the command you need help with?

golden condor
#

I dunno

#

It is either

solemn quartz
#

...

golden condor
#

play

earnest phoenix
#

have you heard of debugging

golden condor
#

Or the music handler

#

I use firefox and glitch won't allow me to

earnest phoenix
#

lol

#

bye

golden condor
earnest phoenix
#

I'm going with cry on this BlobFearSweat

solemn quartz
#

lol

golden condor
#

Look

#

This is the error

solemn quartz
golden condor
#

I just did

#

I made it ages ago

solemn quartz
#

There is the voice channel thing too if you dont do that const

earnest phoenix
#

By made i'm assuming copy paste 😳

solemn quartz
#

lol

golden condor
#

No

#

I followed a tutorial

solemn quartz
#

Wait

golden condor
#

A YouTube vid

solemn quartz
#

Do you use Visual Studio Code to code?

golden condor
#

That sin't important

#

No

solemn quartz
#

oh

#

then im ded

#

-bots Tonkky

gilded plankBOT
#

tickNo User not found

golden condor
#

I don't get the problem I have

solemn quartz
#

-bots Tonkku

gilded plankBOT
#

tickNo User not found

earnest phoenix
#

Following a tutorial is basically advanced copy paste ngl

solemn quartz
#

Lol

#

code it yourself

#

For my joinVC and leaveVC commands i coded it myself

#

i've seen a youtube video, but i wanted to make it myself

golden condor
#

I did improvise most of it

solemn quartz
#

like

#

lol

golden condor
#

I just need help fixing my error

solemn quartz
#

coding its not improvising

golden condor
#

I dont need a solding

solemn quartz
#

Btw what do you use to code?

golden condor
#

Glitch

solemn quartz
#

hmmmm

earnest phoenix
#

considering you don't know what debugging is I think someone needs a lil bit of learning blobcatban

solemn quartz
#

did you do const Discord = require('discord.js') [probably you did]

golden condor
#

Yes

solemn quartz
#

ok

#

lemme see a thing

crimson vapor
#

I agree

solemn quartz
#

wat?

golden condor
#

What do you wanna see?

crimson vapor
#

Although you can learn from videos, I think it is best to understand what you want to do, then problem solve, which means going through the js docs and d.js docs

solemn quartz
#

yea

#

like i did

#

i just seen how to start from videos

golden condor
#

What you wanna see?

solemn quartz
#

I think you need to ask to another person because i dont use Glitch

#

i dont know on what channel

#

just look here

earnest phoenix
#

i hope you're aware that both glitch and heroku aren't powerful enough to run a music bot

solemn quartz
#
golden condor
#

Well @earnest phoenix I think you are wrong on that one

earnest phoenix
#

i'm really not

golden condor
#

As I have done it

#

All this time

#

The past 2 months

solemn quartz
#

but it doesnt work :p

earnest phoenix
#

probably because your bot is unpopular lol

golden condor
#

This is the one error Ive had

earnest phoenix
#

try having more than 10 concurrent guilds and your bot is going to crash

solemn quartz
#

lol

earnest phoenix
#

For a private bot Glitch will work fine, but if you intend to make the bot public, good luck keeping it running

#

That thing gonna die flooshed_egg

#

i like how people here flex with public bots hosted on glitch & heroku when having 20 guilds and a single command usage per day

solemn quartz
#

i suggest Visual Studio Code

#

like

golden condor
earnest phoenix
#

now let 10 guilds stream music and your bot is going to crash

crimson vapor
#

you did the users wrong

solemn quartz
#

i suggest Visual Studio Code
everyone does

earnest phoenix
#

👍

#

How many people actually use the bot

#

just because it's in 176 servers doesn't mean people are playing music or anything

solemn quartz
#

lul

earnest phoenix
#

But the second people are like, aww cool lets listen to some music

#

that's exactly why i said concurrent lol

#

Sometimes you gotta use easy words for the wee ones

golden condor
#

Ok

#

I get it

solemn quartz
crimson vapor
#

just checked my logs, 0 commands used in the last day, yay

#

and 20 guilds

#

so average

solemn quartz
#

lol

#

-bots MILLION

gilded plankBOT
#

tickNo User not found

solemn quartz
#

shit

#

-bots 277183033344524288

gilded plankBOT
golden condor
solemn quartz
#

ik

crimson vapor
#

yeah you should do that in testing

solemn quartz
#

im just seeing what is his bot

crimson vapor
#

do to testing and do !t!rank

#

go*

solemn quartz
#

ok

#

im lazy

golden condor
#

Ffs

#

No one actually helped and now everyone is just complaining at me

crimson vapor
#

what is the actual error?

slate oyster
#

My bot has been running since about January of 1970

hoary elm
#

Ooof

modest maple
#

you've been connected for longer than the total

#

xD

hoary elm
#

Discord bot that existed before Discord..... interesting

slate mist
#

What if unix time started with January first 0001

quartz kindle
#

it would be too big for computers to handle with 32bit integers

crimson vapor
#

What day on what year will computers reset?

modest maple
#

on the day my firewall doesnt block the webserver as root

slate oyster
#

Yea
what happens when the time is higher than Long.MAX

quartz kindle
#

32bit unix timestamps reset on 2038

slate oyster
#

Ok
thx

#

In 18 years some crazy stuff might happen

quartz kindle
#

like the earth exploding

crimson vapor
#

nah

#

computers will update probably

#

well

#

they would have to change to 64 bit

slate oyster
#

Or use BigInt

quartz kindle
#

many things are already 64bit

#

so not a hard change

crimson vapor
#

I wouldn't think it would be

#

of Tim, could you explain how an api for a bot would work? or point me in a direction that I could learn about it? if not all good

quartz kindle
#

what kind of api?

crimson vapor
#

Im not sure, but people say that they have api's created for their bot

#

at least, I think thats what they say

grizzled raven
#

they

quartz kindle
#

well, an api is a server you run that gives you data

modest maple
#

like a REST based api i imagine

grizzled raven
#

wait nvm i suck at everything

quartz kindle
#

actually the word api can be applied to many things, not necessarily online

modest maple
#

yh ik

#

I used / still do use Websocket servers for the old backend until i switch to a REST api

quartz kindle
#

i have a rest api as well, reworking my bot to actually use it

crimson vapor
#

so how do rest api's work for a discord bot?

modest maple
#

pretty much like any normal api

quartz kindle
#

the same way any other rest api

modest maple
#

run a webserver

#

using bot

#

send Get / post requests to api

#

get response from webserver

crimson vapor
#

im sorry, I dont know about rest api's

quartz kindle
#

i mean

#

first you need to know what you want to do

#

in my case, what i wanted to do

#

is have my bot's functions and calculations be usable in other projects

forest junco
#

Anyone got a javascript .js for anti spam?

modest maple
#

we are not giving u code

quartz kindle
#

and instead of having those functions inside my bot's code

modest maple
#

yup

#

makes life alot easier

earnest phoenix
#

@forest junco try GitHub

quartz kindle
#

with parameters

#

and receives a response

modest maple
#

in terms of scaleability aswell

crimson vapor
#

so you gain the ability to use your bot's code with other applications such as a website?

quartz kindle
#

yes

#

specific parts of it

modest maple
#

if you run a webserver and have a decent chunk of the databases behind that it is very very easy to make a webdashboard with it aswell

crimson vapor
#

how exactly do the api's work? http requests?

modest maple
#

yup

quartz kindle
#

lets say your bot has an image command, that randomly sends an image, and lets say you have 500 images stored in a folder in your bot's files

#

instead of having your bot open the images folder, chose a random image, and send

#

you make another project, make a webserver, and put a function on an endpoint

#

such as if you access yourwebsite.com/image your webserver will do what your bot did before, open the folder, pick a random image, and send it back to you

#

then instead of manking your bot do that, your bot just opens that link

#

and you can use that link in other projects

#

and you only need to maintain 1 folder of images

crimson vapor
#

this makes sense

quartz kindle
#

instead of having a folder for all projects that you want to do that with

crimson vapor
#

and seems kind of efficient, but at the cost of delay?

quartz kindle
#

yup

modest maple
#

not really

crimson vapor
#

but minimal

modest maple
#

yh

#

depends on how youre hosting it etc..

#

like a local host based set of Rest endpoints keeps the latency down in the 1-10ms usually

crimson vapor
#

and you would host this api on a web server? using node or what?

quartz kindle
#

if the webserver is on the same machine as your other projects, it will be < 10ms

modest maple
#

alot of languages support webservers

quartz kindle
#

node is one option yes

crimson vapor
#

what do you guys use?

tight heath
#

an image dedi

quartz kindle
#

i use node behind an nginx reverse proxy

modest maple
#

i use python and django because its what im most competent with and then microthreading

tight heath
#

same as tim but in golang

crimson vapor
#

"nginx reverse proxy" - meaning?

modest maple
#

yeetus that ipus

quartz kindle
#

nginx is a traditional webserver, like apache

#

it receives connections, resolves domain names, and points them to files on your computer

#

node.js is a fairly new webserver, so there is a lot of things that it is not very good at yet

#

like SSL for example

modest maple
#

if you were going to make your API external with a domain you would use some sort of apche based system normally

quartz kindle
#

so using nginx as a traditional server is more efficient than directly exposing node to the web

modest maple
#

but alot of languages and frameworks etc.... all have support for apache deployment

quartz kindle
#

so my nginx receives connections, and internally redirects them to my node server

faint hare
#

Is node good for backend/api ?

quartz kindle
#

its as good as any other webserver

crimson vapor
#

I assume that protects your code or the process?

quartz kindle
#

it has pros and cons

#

so it depends on the workload

earnest phoenix
#

a reverse proxy helps you handle stress on your internal webserver

quartz kindle
#

it protects, and also makes some things like SSL more efficient

#

a reverse proxy can also act as a load balancer

#

for example you can run multiple node servers doing exactly the same thing

#

and have nginx distribute connections to them

crimson vapor
#

node can only use one core, right?

quartz kindle
#

usually yes

modest maple
#

there is probably the ability to thread and multi processes

quartz kindle
#

unless you use workers and child processes

modest maple
#

^^

#

My webserver splits every request into a threadlet (micro thread) which allows it to scale upto how ever many logical cores you have x 600

earnest phoenix
#

👀

crimson vapor
#

I would like to learn about this by trying it

quartz kindle
#

my api's scalability is quite bad tbh

#

lmao

modest maple
#

xD

quartz kindle
#

im gonna make a version 2 and completely redesign it

#

also need to move servers, its currently hosted on google gce

#

which has horrible disk speeds

modest maple
#

just host mine on one of my local host machines with an NVME drive

#

altho is it worth the NVME drive, meh

quartz kindle
#

yeah nvme is a must for my api

modest maple
#

better than the big SSD which has like 50MB read and writes

quartz kindle
#

i uses a lot of i/o

crimson vapor
#

api's need the speed?

modest maple
#

depends

quartz kindle
#

if you're gonna release it to the public, yes

#

like i am

modest maple
#

REST based APIs tend to want to be moderately quick

#

if you are making your bot rely of the api in terms of storing data etc..

#

then it is a must

crimson vapor
#

Where do I learn more about api's?

quartz kindle
#

a public rest api needs to be very fast, as they can potentially have hundreds of people using them per second (unlikely but still)

#

also needs to have rate limits

modest maple
#

in theory mine can potentially cope with 14,000 requests a second

#

however

#

the ram will of eaten shit by then

quartz kindle
#

i havent tested mine with more than 10-20 per second lmao

#

it will probably die

modest maple
#

Datomic DB eats ram and cores for breakfast

quartz kindle
#

mine uses 30 year-old C code that loads data from files on disk

modest maple
#

OOF

quartz kindle
#

10gb worth of files

modest maple
#

even the people who use glitch felt that

quartz kindle
#

xD

modest maple
quartz kindle
#

nonetheless its actually still very efficient

#

but ssd makes a huge diff

#

i tested a function that scans 21k files and compiles data from them

#

on google it would take 2min on average

#

on galaxygate takes around 7 seconds

vestal star
#

My bot does not receive votes using the webhook

#

Somebody please help

#

No wait....

#

Could I send a dm to anyone who votes

summer torrent
#

yes

#

My bot does not receive votes using the webhook
@vestal star #topgg-api

astral yoke
#

How would I make a warnings command?

sudden geyser
#

Save a list of warned users with a database. When a mod runs the command (you decide what's classified as a mod), check the args and find the user they wanted to "warn". Do your magic in the background by adding it to the db and there you go.

hollow granite
#

Could someone help me with this error? I get it whenever I try to send an embed.

    at Function.normalizeFields (C:\Users\_____\OneDrive\Documents\Coding\Node\Discord\Bot\node_modules\discord.js\src\structures\MessageEmbed.js:436:8)        
    at MessageEmbed.addFields (C:\Users\_____\OneDrive\Documents\Coding\Node\Discord\Bot\node_modules\discord.js\src\structures\MessageEmbed.js:252:42)
    at MessageEmbed.addField (C:\Users\_____\OneDrive\Documents\Coding\Node\Discord\Bot\node_modules\discord.js\src\structures\MessageEmbed.js:243:17)
    at Object.embed (C:\Users\_____\OneDrive\Documents\Coding\Node\Discord\Bot\commands\help.js:23:23)
    at Object.run (C:\Users\_____\OneDrive\Documents\Coding\Node\Discord\Bot\commands\help.js:66:73)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:13316) 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:13316) [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.```
crimson vapor
#

send the code

quartz kindle
#

@hollow granitediscord.js v12 requires node.js v12 or higher

crimson vapor
#

I never realized that that could be an issue

quartz kindle
#

yeah, array.flat() doesnt exist before node v11, and discord.js makes use of a lot of newer javascript functions which were added to node only recently

crimson vapor
#

oh

#

what does array.flat() do?

quartz kindle
#

flatens an array like this

#

[[1,2],[3,4]] => [1,2,3,4]

crimson vapor
#

oh

#

ok

hollow granite
#

Thanks, it works now.

west spoke
#

wait is that function in python, or is there something similar to it?

quartz kindle
#

oh thats a framework nvm

#

found this in stackoverflow flat_list = [item for sublist in l for item in sublist] lol

copper cradle
#

why are so many people using fields.flat()

#

like srsly

dusky marsh
#

Probably some new tut up that everyone is ripping code from

copper cradle
#

that's what I was thinking

quartz kindle
#

no

#

its used internally by discord.js

#

by embed stuff like .addField()

earnest phoenix
#
module.exports = {
    name: "getstatus",
    desc: "Gets status from discord's status.",
    usage: "",
    execute: async (message, args) => {
    message.delete();
    
    fetch('https://srhpyqt94yxb.statuspage.io/api/v2/status.json')
        .then(response => response.json())
         .then(data => {
              message.channel.send(data)
    });
}};
(node:14) UnhandledPromiseRejectionWarning: ReferenceError: fetch is not defined
at Object.execute (/home/container/commands/Music/testget.js:8:5)
at Client.<anonymous> (/home/container/index.js:60:13)
at Client.emit (events.js:210:5)
at MessageCreateHandler.handle (/home/container/node_modules/discord.js/src/client/websocket/packets/handlers/MessageCreate.js:9:34)
at WebSocketPacketManager.handle (/home/container/node_modules/discord.js/src/client/websocket/packets/WebSocketPacketManager.js:105:65)
at WebSocketConnection.onPacket (/home/container/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:333:35)
at WebSocketConnection.onMessage (/home/container/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:296:17)
at WebSocket.onMessage (/home/container/node_modules/ws/lib/event-target.js:120:16)
at WebSocket.emit (events.js:210:5)
at Receiver.receiverOnMessage (/home/container/node_modules/ws/lib/websocket.js:789:20)
(node:14) 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: 1)
(node:14) [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.

Is fetch removed from JS?

quartz kindle
#

you mean the fetch api that exists in browsers?

#

it doesnt exist in node

earnest phoenix
#

o

#

I forgot about that

#

Hehe..

quartz kindle
#

you can use node-fetch, which is a package that simulates fetch

#

and makes it work the same as in browsers

wide ridge
#

When I try to shard using 3 shards, my bot runs my command twice. Does anyone know what might be the issue? I'm using discordjs

#

Is it because I'm using more shards than I need to?

grizzled raven
#

multiple events maybe

#

check that first

#

eval client._events and see if message (and others) comes up as an array or an async function

wide ridge
#

Ok I'll try that

#

what happens if it does?

copper cradle
#

if it comes as an array you're getting duplicate events

#

if it comes as an async function then you should be fine

wide ridge
#

I get this:
message: [AsyncFunction]

#

I have a function in my bot.js that runs commands,
client.on('message', async msg => {
...
commandfile.run(client, msg, args);
}

quartz kindle
#

did you fully restart your bot when you changed your sharding?

#

restarted all processes and all shards?

floral bloom
#

Is there an issue with the API or something? It's almost like there are two instances of my bot in one server. Almost every command I run it does the action twice.

#

I checked the code and found nothing.

wide ridge
#

did you fully restart your bot when you changed your sharding?
@quartz kindle I'm trying to set up sharding for my bot rn, and yeah I fully restarted it

amber fractal
#

did you run the file in another terminal?

#

you can run any amount of instances of the same bot

wide ridge
#

my issue is mostly that when I try sharding it sends multiple messages when it should only send 1

#

😭

floral bloom
#

Almost every command I use (ping, eval, update) it sends the success message twice and does the action twice as well.

grizzled raven
#

huh

cerulean pebble
#

hmm how to deloy dbl.js on heroku i try this way but i think it never work 😦

#

*deloy module

quartz kindle
#

@wide ridgeshow code i guess...

#

@floral bloom you too

floral bloom
#

Hm, what code? I'm not sure what part is causing it and I have a few hundred lines of code.

quartz kindle
#

all of it

wide ridge
#

so that's my sharding manager, and my indexOld.js

floral bloom
#

It doesn't do it for every command though.

quartz kindle
#

then show the eval command

wide ridge
#

@quartz kindle anything seem off about the way I run commands?

floral bloom
#

It does duplicate actions for (so far) the ping, help, eval, update, and info command.

quartz kindle
#

@wide ridgeyeah i dont see anything wrong there

wide ridge
#

o.O

floral bloom
#

Huh...

quartz kindle
#

anyway, not much i can help with without seeing code

#

the problem could be anywhere

floral bloom
#

I have a similar command handler as Gopi and we seem to both be having the problem of the bot sending multiple messages (correct me if I'm wrong).

let commandFile = require(`./commands/${command}.js`);
commandFile.run(bot, message, args);
cerulean pebble
#

hmm how to deloy dbl.js on heroku i try this way but i think it never work 😦
@cerulean pebble .

#

help me

wide ridge
#

yeah I'm having the same issue @floral bloom 😭

floral bloom
#

And no error messages either.

#

It's weird...

quartz kindle
#

well there is likely a reason

#

you gotta keep looking

cerulean pebble
#

lol no one help

copper cradle
#

@cerulean pebble deploy, not deloy

#

to deploy just do what you always would

#

to call that env var do process.DBL

#

nooo

#

process.env.DBL

wide ridge
#

I'm trying to run 5 shards but when I run my commands it shows 3 messages

copper cradle
#

lmao

#

@cerulean pebble btw, what's your native lang?

quartz kindle
#

@wide ridgecheck if there are no duplicate guilds

cerulean pebble
#

@copper cradle is this right

#

@copper cradle i am in Japan now

copper cradle
#

aighr

#

no

#

to call the var in your code

#

bruh

#

name it whatever you want

#

call it the same way you're calling 'token'

cerulean pebble
#

oke

copper cradle
#

by call it I mean

#

in your code

cerulean pebble
#

hmm

#

@copper cradle hmmm you mean if use config var

#

so not need deploy DBL token to github right

copper cradle
#

nope

#

I mean

#

you could do it

#

it's not like you need a public repo...

cerulean pebble
#

you mean ?

#

i can't

#

heroku not have module DBL so when i upload code i must delete 2 lines that in picture

copper cradle
#

dude

#

I don't understand what you're saying

#

are you getting any errors?

cerulean pebble
#

yup

copper cradle
#

@ocean frigate ?

#

this is node.js not python

#

lmao

ocean frigate
#

this is node.js not python
@copper cradle ooof

#

I'm sorry

copper cradle
cerulean pebble
#

hmmm

ocean frigate
#

I just opened this channel and saw the message

cerulean pebble
#

i mean the heroku not have module dbl.js

copper cradle
#

lol

cerulean pebble
#

so that's error

ocean frigate
#

Did not scroll up

copper cradle
#

send the error log

cerulean pebble
#

@copper cradle =))) i use the config var but i think it not work

copper cradle
#

I think that's not the error

#

I think you haven't installed dblapi.js

cerulean pebble
#

@copper cradle yeah

#

that's what i mean

copper cradle
#

did u run npm i dblapi.js

cerulean pebble
#

no how to run it in heroku

copper cradle
#

yeah that has nothing to do with config vars

#

dude

#

just

cerulean pebble
#

i am stupid

#

=)))

copper cradle
#

go to your bot's folder (on your machine) and in the console run npm i dblapi.js

#

then deploy your entire bot again

#

that's it

cerulean pebble
#

i did

#

bot can run in machine version

copper cradle
#

deploy it again

#

send the error log that you're getting from heroku's built in console

cerulean pebble
#

error log not find module

#

PM =))

visual sandal
#

I have a djs bot...
This is one of my onEvent statements

client.on(`channelCreate`, channel => {
    let myGuild = client.guilds.get(`${config.myGuild}`);
    if (channel.guild.id === myGuild.id) {
        let totalChannelCount = `${myGuild.channels.size}`;
        let totalChannels = myGuild.channels.get(`${config.channelCount}`);
        totalChannels.setName(`Channel Count: ` + totalChannelCount)
            .catch(error => sendLog(error));
    }
});

I get this error -> TypeError: Cannot read property 'id' of undefined in the if statement when i run a command

#

It only happens when i run the invite command of my bot

    if (command === `invite`) { // Sends invite link for Client
        const inviteEmbed = new Discord.RichEmbed()
            .setColor(`${config.embed_color}`)
            .setTitle(`${config.client_name}'s invite links`)
            .addField(`Here is ${config.client_name}'s invite link with administrator permissions`, `${config.invite_link}`, true)
            .addField(`Here is ${config.client_name}'s invite link without administrator permissions`, `${config.noAdmin_invite}`, true)
            .setFooter(`Provided by: ${config.client_name}`);
        message.author.send(inviteEmbed);
        return;
    }

^ the invite command doesn't even relate to the channelCreate

#

and the id error happens with the channel.guild.id

summer torrent
#

channel.guild is undefined

visual sandal
#

ofc.. i am not creating a new channel in my server

#

I am sending a command to send invite links of my bot

#

but it is triggering the channelCreate, and there is no new channel so it is undefined

copper cradle
#

@visual sandal console.log channel and see what you're getting

visual sandal
#

kk

#

prints nothing

#

cause it is undefined

#

works when creating a channel cause.. well.. a channel exists

#

but it shouldn't run for the invite command

copper cradle
#

wait

#

dude

#

like

#

you never defined channel

#

did you actually expect channel to be a global var?

#

channel is inside the function you're calling when the event channelCreate fires

#

and it's only available inside of that scope

#

JavaScript has two scopes – global and local. Any variable declared outside of a function belongs to the global scope, and is therefore accessible from anywhere in your code. Each function has its own scope, and any variable declared within that function is only accessible from that function and any nested functions

#

@visual sandal

#

you got to be kidding

visual sandal
#

ouef

regal saddle
#

zSnails gettin mad V2

finite bough
#

@golden condor watch.json

copper cradle
#

@regal saddle 😳

cerulean pebble
#

hmm

#

how to install dbi on heroku

regal saddle
#

@regal saddle 😳
Ill get every rage doe...be careful.

copper cradle
#

😳

lilac wharf
#

@cerulean pebble this should do. (I'd suggest running it on a local environment and then deploying it)

npm i <module>
npm i dblapi.js

dusky marsh
#

heroku just needs your package json and it installs all node packages for you

cerulean pebble
#

@lilac wharf how to make it on heroku

hoary elm
#

@cerulean pebble as Canarado said Heroku uses your Package.JSON to install modules for you, easiest way to get it to install the module is add it to the package manually shrug

#

or run the npm i dblapi.js command outside of Heroku Via your Terminal, Shell, Cmd Prompt or w.e you use and then re-deploy

cerulean pebble
#

hmm

#

oke

#

tks for sp me

#

i will try

lilac wharf
hoary elm
cerulean pebble
#

hmm

visual sandal
#

?

astral yoke
#

Hello. I have an error.

#

This is the code where I get it.

#

```connection.query(SELECT * FROM account WHERE id = '${message.author.id}', function (err, rows) { //selecting user id
if (err) throw err;

if(rows.length < 1) { //if the user has no info in table | no id it inserts ID - XP - LEVEL 
    sql = `INSERT INTO account (id, xp, level) VALUES ('${message.author.id}', '${generateXp()}', ${lvl})`
} else {
        let xp = rows[0].xp; //xp = the amount xp in database

        sql = `UPDATE account SET xp = ${xp + generateXp()} WHERE id = '${message.author.id}'`; //update xp

        let nxtLvl = rows[0].level * levelup;  //how many +1 level per xp points

        if(nxtLvl <= rows[0].xp){ //If level supass that amount it 
        connection.query(`UPDATE account SET level = ${rows[0].level + 1} WHERE id = '${message.author.id}'`) //updates level
        }

        //levelup message 
        if(nxtLvl <= rows[0].xp){
        const lvlup = new RichEmbed()
        .setDescription(`Hello, ${message.author.username} you leveled up to ${rows[0].level + 1}`)
        .setColor(tutu)
        message.channel.send(lvlup)
        }
}

connection.query(sql)
})```

#

this is the error.

#
[2020-03-11 22:06:09]: [Log]: Got data from botconfig file!
[2020-03-11 22:06:09]: [Log]: Note: If you want to exit the bot, type exit into the console.
[2020-03-11 22:06:09]: [Log]: Successfully loaded other files.
[2020-03-11 22:06:09]: [Error]: ReferenceError: Cannot access 'config' before initialization
    at Object.<anonymous> (C:\Users\Cools\dog1bot\src\index.js:44:43)
    at Module._compile (internal/modules/cjs/loader.js:1128:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
    at Module.load (internal/modules/cjs/loader.js:983:32)
    at Function.Module._load (internal/modules/cjs/loader.js:891:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! fyre@1.0.0 start: `node src/index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the fyre@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Cools\AppData\Roaming\npm-cache\_logs\2020-03-12T05_06_09_456Z-debug.log

C:\Users\Cools\dog1bot>```
#

Can someone help?

prime cliff
#

ReferenceError: Cannot access 'config' before initialization

#

run_main_module.js:17:47 | index.js:44:43

restive furnace
#

initialize config, like var config = "a", thats basic js, so if you fall into this type of errors and can't fix them, go learn basic js.

astral yoke
#

would it work though if I put var config = "a"?

hoary elm
#

Of course it would but you can't try and use it in a variable or a arg prior to initializing it

Example

message.channel.send(config.helpMsg)

var config = require ('./config')
``` is wrong the variable should be intialized before being called
astral yoke
#

yeah cause higher i have

#

const config = require ("../../main-db.json");

#

I'm just gonna scrap the idea.

#

And get a new idea on what to do.

prime cliff
#

Or learn how to debug thinksmart and read error messages

#

Also when it says run_main_module.js:17:47 | index.js:44:43

#

It means the error is coming from that file on line 17 or 47 not sure what js formats it

restive furnace
#

line 17, colum 47

#

column

marble juniper
#

all variables should if possible be at the beginning of the code or at the beginning of code brackets

prime cliff
#

Wasn't sure of the 47 column his code must be pretty messy

marble juniper
#

bet

#

and I bet that he used copy paste because who would ever make a mistake like that

#

but im not trying to judge

astral yoke
#

yeah okay buddys

earnest phoenix
#

Quick question about discord bots

#

Is it possible to make bots be able to interact with each other?

#

I set up a timer on a bot called mee6 to repeat a phrase every 12 hrs (which if a human said, would trigger another bot to complete an action) but the other bot doesn’t seem to see the timed message

#

You mean like bot respond to another bot?

#

Yes. Kinda

#

Is it possible

#

Hmm...
Have you used the
if (message.author.bot) return; code in your bot?

#

If you did... It won't respond to any bot

#

I haven’t, didn’t even know that existed

#

Hmm

#

For example what did you wanted your bot to say when mee6 responded?

#

@earnest phoenix

#

It’s a game stats server, so mee6 says $clanwar and another bot called deck shop responds with stats about a current war.

#

For example if you haven't used the code above and typed a code for example:

 return message.channel.send("moment");
}```
And if a bot said bruh it would respond with moment
#

It responds back with the exact same thing

#

@earnest phoenix

prime cliff
#

Why are you....

#

Are you trying to use Mee6 to code...

earnest phoenix
#

The wot

#

@earnest phoenix wait are you trying to code inside the message respond method of mee6

#

?

#

[Visible CONFUSION]

#

@earnest phoenix have you made a bot?

#

Not exactly trying to code. I just want mee6 to be able to loop the charade $clanwar and have the other bot respond

#

@earnest phoenix have you made a bot?
No, Not really

prime cliff
#
  1. Mee6 can only do that like every 3 hours with an auto timer
  2. Most bots don't respond to other bots
  3. Mee6 does not load or run code you give it
earnest phoenix
#

Hmm... You want like for mee6 to say something and other bot respond to mee6?

#

Hmm... You want like for mee6 to say something and other bot respond to mee6?
@earnest phoenix yes

#

But which bot you want it to respond to mee6?

#

It’s called Deck Shop, it’s a Clash Royale game tracker

#

Hmm... I think it can't because the bot that you're talking about might have the
if (message.author.bot) return;
Code inside of it... So... It cannot respond to the mee6 or mee6 can't respond to it if it has that

#

I see, is there any others that may work? I also have yagpdb but I decided not to do that because it was way too complicated (at least for me)

#

I mean like none of them will work because some bots are aware of other bots telling them what to do just like the bot you're trying to rig or do something with it(Deck shop or whatever)...
Just with one single line of code sooo...
Rip

#

Oh, ok

#

Thanks @earnest phoenix really appreciate the help

#

Np

marble juniper
#

no bot will work

earnest phoenix
#

Really nice to help

#

Yup

marble juniper
#

it just sends your code as a string

#

doesn't eval it

#

because that would be a security break and no bot would eval your message anyways

earnest phoenix
#

Some bots can respond to other bots if they doesn't have the code above...(scroll up)

marble juniper
#

if (message.author.bot) return

earnest phoenix
#

But most of them have it sooo... Whatever

#

Yes

marble juniper
#

imagine this

#

both bots have the same prefix

#

for example !!

#

and when a user uses !!help

#

the other bot responds

#

then the other bot responds

#

then the other

#

it would be an infinite loop

earnest phoenix
#

True

#

Yup... Infinity loop until API ratelimit takes them down

marble juniper
#

thats 1 reason

#

out of some others

earnest phoenix
#

Discord would even might break because of that Infinite loop

#

But would take a very long time

marble juniper
#

once this server didn't had bot with common prefixes unmuted

#

only one person was enough to make this server die

#

now imagine those bots would all respond to each other

#

which are probably more than a thousand

earnest phoenix
#

Yup... Every of one your actions have an unexpected consequential danger in it
One mistake can take down all

marble juniper
#

another reason would be you have something like economy

#

and a second bot just to farm for you

earnest phoenix
#

Unexpected just like a code not initializing and giving an error

#

Yup

#

That would be like unfair to every player of a currency including bot...
For example Dank memer...

#

Farm and farm and you rich if that would have happened

marble juniper
#

I think he gets the point now

#

and I think he is gone already lol

earnest phoenix
#

Still here

#

Yea he just appreciated the help and woosh.. gone

#

Oh

marble juniper
#

k

earnest phoenix
#

Lol

#

Welp...

tight plinth
#

Wat happens here

marble juniper
#

anyways im off

tight plinth
#

Currency, I see

marble juniper
#

@tight plinth development being active

earnest phoenix
#

Nothing just code talking and stuff

marble juniper
#

an illegal activity

tight plinth
#

No

earnest phoenix
#

API breaking limit activity

tight plinth
#

illegal is no tim

#

So this chat is illegal

earnest phoenix
#

The wot

marble juniper
#

@earnest phoenix wanted to execute code through mee6

tight plinth
#

Erm

#

Bruh

earnest phoenix
#

Yes and no smh

tight plinth
#

Actually you can't

#

Devs are not dumb

marble juniper
#

im gonna go watch netflix bye

earnest phoenix
#

That's just the most unexpected thing i've seen in my life...
I wasn't expecting that tho
My life is complete... I can GAME END NOW

tight plinth
#

Bye linkus

earnest phoenix
#

I mean he tried to execute codes from inside of a bot message method

tight plinth
#

Well lol

#

Of course it won't work

earnest phoenix
#

Yup

tight plinth
#

The bot literally sends the lines of code without executing them

#

And mee6 isn't coded in us or whatever

earnest phoenix
#

A bot mounted on a pile of code, running on a code, would execute a code through a message method code? Lmao

tight plinth
#

It's coded in mee6

earnest phoenix
#

I wasn’t trying to code in mee6, just send a command (not code) though it for another bot to respond

#

Oh lmao i see...
You though it was going to work but nah... Good job tho giving it a shot even though it wasn't going to work

tight plinth
#

Lol

#

Bots aren't stupid

earnest phoenix
#

Well that’s debatable

#

They're just like brains but with no functions if it has no codes...
You command with codes... The bot follow it

#

@tight plinth and bots can be stupid if they aren't given correct codes or not even given codes to them...

#

Hmm

tight plinth
#

Hm

#

In this case they are stupid

earnest phoenix
#

Hmm you code on PC or mobile?

tight plinth
#

Both

#

But pc when I can

earnest phoenix
#

I do it on mobile but what kind of program are you using?
Termux?

tight plinth
#

Termius

earnest phoenix
#

Hmm

#

Do you use nano or vim?

tight plinth
#

An android app called quickedit

#

100x better

earnest phoenix
#

Oh you write it with an outside the box third party app

#

Nice

#

Very NICE

tight plinth
#

And then re-upload

earnest phoenix
#

Welp... That seems to be obvious to do that lol

tight plinth
tight plinth
prime cliff
#

Are you oh my god what an elite master

tight plinth
#

And u click upload back to derver