#development

1 messages · Page 1086 of 1

earnest phoenix
#

my website now live update guilds users and channels
@obtuse jolt ohhh good, im working to get that, but in java is more diff

digital ibex
#

imagine

#

lol

earnest phoenix
#

same

solemn latch
#

totes, but you need to give each user that privacy policy before adding them

#

to that online list

amber fractal
#

Well a privacy policy is required now

#

as per the new dev tos

opal plank
#

reminder that we are now required to add disclaimers to our bots

digital ibex
#

quick question, how can I get the discord.client object in a different process?

#

without using IPC if possible

#

and without sending it to an API

solemn latch
#

ipc just means sending stuff to other process's

#

🤔

opal plank
#

api too

amber fractal
#

that's literally what ipc is

#

lol

opal plank
#

make an index the redirect traffic

haughty igloo
#

i deleted bot .'(

amber fractal
#

sending it to another process is ipc

digital ibex
#

process communications

#

im not trying to do it like that tho

solemn latch
#

like what

digital ibex
#

no i mean like

#

if i've got process a, and i've got data in process b i want to send to process a, how can i do this?

opal plank
#

IPC

amber fractal
#

with ipc

opal plank
#

lmao

digital ibex
#

no other ways?

#

D:

opal plank
#

API

#

webserver

amber fractal
#

it's literally inter-process communication

digital ibex
#

without using an api too lol

warm cloud
#

iipc moment

opal plank
#

how do i write without a keyboard?

#

thats what you're asking

warm cloud
#

exactly

opal plank
#

why NOt use IPC?

digital ibex
#

hmm

#

it confuses me

warm cloud
#

how do i communicate between processes without communicating between processes

opal plank
#

just read a quick guide on it

digital ibex
#

hmm

opal plank
#

make server;
log both processes;
emit event(type and data)
listener on other end

#

boom

#

its not that complicated at all

digital ibex
#

oh

#

thats just what it is?

opal plank
#

yeah

digital ibex
#

i googled it the other day and 🥴

opal plank
#

its not hard at all

warm cloud
#

at a high level ofc yeah

opal plank
#

you seem to only need some basic stuff

#

IPC can be used for some really complicated shit

digital ibex
#

yeah

opal plank
#

but for basic stuff its not hard at all

digital ibex
#

im trying to send my bots data to a webserver

#

thats not complicated, is it?

opal plank
#

i use it to talk to my Yyoutube/twitch/discord bots

#

remember it has limitations on how much data it sends

#

you could also do Database to technically pass large quantities of data

#

WITH ipc

warm cloud
#

technically

opal plank
#

make a table, generate an id and put data into database. just use IPC to send the id over to the other process to fetch it

digital ibex
#

well, im trying to send the whole eris client object, and eris has almost everything in the client class

warm cloud
#

why are you sending an entire client object

digital ibex
#

so probably shouldn't use the db for this

opal plank
#

im not sure it'd be very nice to send large objects over

warm cloud
#

why are you even sending it

earnest phoenix
#

use named pipes and transfer bytes of data

opal plank
#

buffers lul

digital ibex
#

for many reasons, to make a chat on the website to speak in the support server, gets the bots statistics etc

#

and im not using widget either

warm cloud
#

that does NOt need the entire client object

opal plank
#

why not parse that and send it?

digital ibex
#

i know

opal plank
#

you named 5 things, why not send those 5 things in a json rather than the whole client?

warm cloud
#

ikr lmao

opal plank
#

send as needed

digital ibex
#

im not doing just that, i'd need to make an option to add reactions maybe or more stuff i dont realy know atm

#

wdym?

opal plank
#

make a small api

#

request the data you need

warm cloud
#

are you trying to interface discord on a website?

opal plank
#

build json

#

send it over

warm cloud
#

titan embeds did that already

digital ibex
#

im trying to make it mostly all myself

opal plank
#

use IPC to make a small api then

digital ibex
#

and im trying to send the data to the api

#

hmm

opal plank
#

heres the basic jist of IPC

#

you emmit 2 things

digital ibex
#

i'll look into ipc a bit more

opal plank
#

1 is type of event

#

second is data

#

with that in mind, make a server for IPC and then log both instances

#

now they are both linked together

#

now heres the fun part

earnest phoenix
#

there's like a plethora of ways to implement IPC

#

easiest being named pipes

opal plank
#

send the event 'request' to your place that has your client

#

and send the json with the properties of the data you need

#

for example

digital ibex
#

pipes?

solemn latch
digital ibex
#

i got an idea actually

#

make a private npm library which holds the data- nvm actually just realised that wont be dynamic

solemn latch
#

just do a basic api

#

can just be a dumb simple express api

obtuse jolt
#

poggers

opal plank
#
bot a 
ipc.on('request', (request) => {//listen event request
let data;
  if(request.data) client.push data.data; //if request has data property in it, put whatever property
ipc.emit('return', data) //sends data to bot b
}


bot b
ipc.emit('request', (request) => { //emit event request
  let request;
request.data = true;
}
ipc.on('return' => {//heres your data from bot a} )

``` @digital ibex
#

does that give a rough idea of what i mean??

#

build your json to have the properties of the stuff you want

#

or just send an array and dynamically check

#

up to you , but thats a rough jist of how you'd be able to request stuff on the go

digital ibex
#

yeah, this confuses me.

opal plank
#

you used d.js before, no?

digital ibex
#

no

solemn latch
#

its pretty much
client.on('message') events

opal plank
#

^^

#

i was going to use that as example

#

events are emiited and listened to

#

you are listening to requests and emitting responses

#

its a very basic api

#

but for yourself

digital ibex
#

i'll just make my own api requests, thanks anyways

opal plank
#

lmao

#

aight

digital ibex
#

quick question

#

i might the use the api method

opal plank
#

IPC is just so you dont have to use websockets around

#

that example i gave you is just 2 events

#

send/receive

digital ibex
#

but on my pc u can make api requests to localhost, what about a linux machine, dashboard and bot are both hosted there?

opal plank
#

with IPC, yeah

#

you can use localhost

digital ibex
#

i mean the api method

opal plank
#

or use UDP

#

its all listed in the docs

#

lemme fetch it rq

amber fractal
#

you can make internal requests with http in node

digital ibex
#

i mean like

#

if i do fetch('localhsot whatever')

amber fractal
#

should work

digital ibex
#

would it work on a linux machine too?

solemn latch
#

yes

digital ibex
#

hm ok, thanks guys

opal plank
digital ibex
#

yeah

#

that was the thing which confused me along with a stackoverflow thing before :p

opal plank
#

look at the examples, it makes it quite easy to understand

#

check localhost and UDP examples

#

or it could be much more complicated like that

digital ibex
#

yeah

opal plank
#

i recommended your own event type, like request

digital ibex
#

im trying 2 different methods:

  1. make the api requests myself (preferably)
  2. make a small express server

im pretty sure d.js has a fetchApplication to get the application info, or something like that, im looking at the discord docs, how can i also do this?

#

i cant find it anywhere

opal plank
#

application info?

digital ibex
#

1 sec

opal plank
#

like in the portal?

#

to display all that?

digital ibex
#

yeah

#

i cant find that anywhere either :/

opal plank
#

for your own application you can use that iirc

#

actually

digital ibex
#

nvm actually

opal plank
#

nvm that doesnt do API calls

#

thats just reversing the snowflake

#

i though it did a call

digital ibex
#

it was this, but it turns out it gives the clients application

earnest phoenix
#

so many embed links

#

o ty

opal plank
#

is that not what you want?

digital ibex
#

i thought u could like

#

client.fetchApplication('client secret')

opal plank
#

client applications need oath iirc

digital ibex
#

i mean yeah, prob would be a security breach but ya lol

opal plank
#

try this

#

should not work for you

digital ibex
#

yeah

#

thats why u've got to do oauth

opal plank
#

im sure it needs oatuh

cinder patio
#

I really think you should use ICP instead of Websocket communication, it's more appropriate

opal plank
#

you know IPC well feud?

cinder patio
#

IPC*

digital ibex
#

it confuses me :/

opal plank
#

Feud might be able to give you a better help, this is what i recommended

#
bot a 
ipc.on('request', (request) => {//listen event request
let data;
  if(request.data) client.push data.data; //if request has data property in it, put whatever property
ipc.emit('return', data) //sends data to bot b
}


bot b
ipc.emit('request', (request) => { //emit event request
  let request;
request.data = true;
}
ipc.on('return' => {//heres your data from bot a} )

livid rivet
#

I am using discord.py, the extension thing, and my on_message_edit event gets triggered at any command

calm sedge
#

Where boys

#

Bots

livid rivet
#

I need some help

opal plank
#

2 events, one sending, one receiving

livid rivet
#

I haven't found any help on the internet or in the docs

karmic compass
#

how do i assign a role to a member in discord.js

cinder patio
#

I've never had the chance to use it practically but I 've experimented with it

opal plank
#

im using it, but its rather simple

#

im using similar structure to what i sent above

#

its somewhat an api

#

checks for each property of json object and builds it based on it, once its built, it emits back to the client who requested

cobalt eagle
#

hey i have a problem

#

i followed the official command handler guide

#

and

#

now my bot react with every prefix

#

i can put anything before the command name it'll still do it

#

here's the code

#

the prefix is *

edgy crown
#

did u add
if (message.content.startsWith(prefix)) return;
or smth

misty sigil
#

It’s prefix.length

#

not by the actual content

edgy crown
#

oh

#

i dont use that

cobalt eagle
#

prefix.length is line 81

edgy crown
#

also you may want to use
if (message.channel.type === "dm") return;

instead of (!message.guild)

cobalt eagle
#

on the sccreen

#

oh ok

pure lion
#

You only need prefix.length if you're using args properly

digital ibex
#

both do the same thing

cinder patio
#

Another thing you could use is node's built in worker threads/ child process module (which also uses IPC). Your express server could spawn the bot process (I'm assuming that's what you are doing?) and that way they can easily communicate

digital ibex
#

the bot doesn't have an express server

#

the dashboard does tho

cinder patio
#

Yeah that's what I meant

cobalt eagle
#

what ?

#

no the problem is

#

the command is sent regardless of the prefix

#

it could be

#

bban

#

çban

#

)ban

#

"ban

#

it'll be sent

#

or it should only be sent with *ban

misty sigil
#

BECAUSE YOU’RE USING PREFIX.LENGTH

#

shit caps

cobalt eagle
#

ok

#

so i need to remove prefix.length ?

misty sigil
#

it should be prefix afaik

#

just prefix

cobalt eagle
#

ok

earnest phoenix
#

Wait no

cobalt eagle
#

no ?

misty sigil
#

idek

earnest phoenix
#

you can't slice an string off with .slice

solemn latch
#

your slicing prefix out, but never checking if its at the beginning of content

earnest phoenix
#

That's correct, i assume Something is wrong with the command setup

#

Oh wait yea

#

if(!message.content.startsWith(prefix)) return;

plucky harness
#

Anyone uses asyncpg here?

cobalt eagle
#

thankssss

pure lion
#

The what

cobalt eagle
#

you guys are the bests

earnest phoenix
#

@plucky harness async package? Or what I'm confused, "asyncpg"

pure lion
#

Compiling async in ts to see how it works

#

X)

plucky harness
#

Asyncpg. Pg = postgresql for python

solemn latch
#

lmao

opal plank
#

not a single one

solemn latch
#

i found a dumb bug in my code.
tag @ here without any other text, and it responds like you tagged it directly.

I absolutely need to fix it asap, but its been like it for weeks, and has only happened twice.

opal plank
#

disable mentions

#

oooh

#

i see

solemn latch
#

oh i just need to check if its mentioning the bot directly

#

not checking if its being mentioned at all

opal plank
#

match regex

solemn latch
#

yeah

opal plank
#

'<!?idhere>'

solemn latch
#

funny enough, thats how i do prefix checks.

opal plank
#

u use ? for prefix?

sudden geyser
#

\d+

opal plank
#

?

#

one or 0

sudden geyser
#

ah no read that wrong

opal plank
#

! is for nickname

#

<!(can exist or not)ID>

solemn latch
#
if (message.mentions.has(client.user.id) && message.content.length < 23) return message.channel.send(`My prefix in this community is \`${serverSettings.prefix}\`\nUse ${serverSettings.prefix}help for help!`)
    const prefixMention = new RegExp(`^<@!?${client.user.id}> `);
    const prefix = message.content.match(prefixMention) ? message.content.match(prefixMention)[0] : serverSettings.prefix;
    if (!message.content.toLowerCase().startsWith(prefix.toLowerCase())) return;

opal plank
#

? is the same as !{0,1}

fickle arch
#

Is economy stuff need sort off extra things to do it like database to keep user data or something ?

opal plank
#

mine is similar, though i only use it on twitch

#

holdon

#

i really need to recode my twitch and youtube bots, they are getting far behind my main branch one

solemn latch
#

i could just do prefixMention first

#

then do both checks after

opal plank
#

thats my check

#

could remove that 0 too

solemn latch
#

extra things, just the way i like it

opal plank
#

Huh...

#

OMG

#

NO

#

oh thank god

#

nvm, its fine

solemn latch
#

i did it in like 30 seconds after someone suggested it

#

its still bad

opal plank
pure lion
#

The f u c k

opal plank
pure lion
#

What is a message.chat

opal plank
#

DB call to make sure its persistent after restart

#

thats not discord

#

thats twitch

pure lion
#

Oh

#

Twitch has a persistent dB system?

opal plank
#

my 'bot' isnt a bot per say

#

no, i added it

pure lion
#

Oh sick

opal plank
#

its a collection of bots

#

thats why it takes so long for me to make commands

#

i gotta add the same command on twitch, discord, youtube and the beta branch

solemn latch
#

oh intresting

opal plank
#

its one hell of a nightmare

#

its now instanely fun cuz 2 of them are on Ts

#

so i gotta write Ts AND Js

#

yes, theres a difference

#

my Ts is set to strict mode, so it'll fuck everything up

celest schooner
#

is it api abuse if i use my bot to dm owners of servers that use my bot that are over 300 members (excluding top.gg) a link to the new version of that bot

solemn latch
#

i would think so, yes.

celest schooner
#

even if

#

there like 6

solemn latch
#

api abuse is kind of a grey line.
6 requests i dont think will ever be enough for action to be taken against your account.

obtuse jolt
#

If you use like discord.js or discord.py they put ratelimits to make sure you don’t get banned

solemn latch
#

you can api abuse without hitting ratelimits

slender thistle
#

That's a wrong way to phrase it

#

d.js and d.py automatically handle the Discord ratelimits for you

earnest phoenix
#

check pins for a distinction between api abuse and normal usage

#

tldr

#

don't do anything the user didn't ask for

earnest phoenix
#

clIenT modIfiCatiOns

solemn latch
#

not my screenshot 🤔

misty sigil
#

large N? so like, 10 minutes?

solemn latch
#

they never really say

quartz kindle
#

doesnt server monitor do it every 10 minutes or so

amber fractal
#

just add a little extra response to each command that gives them a link to the new version anyways

solemn latch
#

or just put it in your bot status

amber fractal
#

lmao who looks at statuses, especially bot statuses

solemn latch
#

i stare at bot statuses all day

#

got a third monitor just for it

earnest phoenix
#

you need a backend server

honest perch
#

express is pretty easy

#

and then ejs

earnest phoenix
#

you're misunderstanding how client server relationships work

#

the client has to make a request to the backend server

#

any sort of webserver that's able to ping your bot or be logged in with the bot in order to return the correct stats

crimson vapor
#

The GitHub Pages would request your server and you would return a json of stats and stuff you want to send probably

earnest phoenix
#

^

digital ibex
#

hiii im back agaiin

#

any ideas how i can fix this error? FetchError: invalid json response body at <url> reason: Unexpected end of JSON input

#

yeah

crimson vapor
#

Are timers commands api abuse, they would be right?

earnest phoenix
#

blu, think about that for a minute

#

you would be giving details to your database to everyone

digital ibex
#

right click > inspect element > sources

earnest phoenix
#

you cannot put any sensitive information on the frontend, anyone can edit and view frontend code

digital ibex
#

any ideas about my error, cry?

earnest phoenix
#

no idea

#

parse the response body as a string or something then console.log the response

digital ibex
#

oof

#

oh ok

crimson vapor
#

is it a url or is it a file?

digital ibex
#

url

crimson vapor
#

wait you are using fetch?

digital ibex
#

would i do js const bob = await fetch('url', { other stuff here }); return String(bob); instead of just, return bob; ?

#

yeah i am

#

but then how can i access the response? 🤔

#

confusion101

sudden geyser
#

use bob.text() to convert it to a string, then log the result from the promise it returns

digital ibex
#

kk

#

im doing this: js const hook = await fetch(`https://discord.com/api/webhooks/${webhook.id}/${webhook.token}`, { // stuff here }).then((e) => e.json()); console.log(`a` + hook.text()); return hook; } the webhook gets sent, but nothing logs, any ideas?

split nova
#

Is it not webhook.text in ‘console.log(“a” + hook.text());

#

Idk i dont do ja

#

Js

crimson vapor
#

what the hell are you doing?

digital ibex
#

making an api request?

crimson vapor
#

why?

digital ibex
#

what

crimson vapor
#

im confused

split nova
#

Im pretty sure he can make an api request if he wants?

#

Or is that illegal

solemn latch
#

illegal

#

already reported

split nova
#

🥶

digital ibex
#

the response of the api request is erroring.. thats what im trying to fix

crimson vapor
#

why are you making an api request?

digital ibex
#

moyaing so hard rn

#

why does that matter?

crimson vapor
#

because I do not think it is needed

digital ibex
#

well the answer to ur question is to send a webhook to a channel

#

um... yes it is

crimson vapor
#

so are you creating a webhook and sending to it?

digital ibex
#

yes

crimson vapor
#

d.js 12?

digital ibex
#

no

#

im not using a library

crimson vapor
#

the fuck

split nova
#

try maybe:??

const hook = await fetch(`https://discord.com/api/webhooks/${webhook.id}/${webhook.token}`, {
      // stuff here
      }).then((e) => e.json());
   console.log(`a` + webhook.text());
   return hook;
}
crimson vapor
#

why not

solemn latch
#

thats what webhooks are for

#

lol

split nova
#

nvm im retarded

crimson vapor
#

are you making a bot or posting to a webhook?

split nova
#

didnt see the const

digital ibex
#

i am moyaing so hard rn

#

🗿

crimson vapor
#

moyaing? wut this

digital ibex
#

like really hard

#

\🗿

#

but.. back to my question, do u know how to fix it or..

solemn latch
#

what did you put in //stuff here?

digital ibex
#

or help..

crimson vapor
#

are you sending a message to a webhook?

solemn latch
#

webhooks are posts right?

crimson vapor
#

yes

digital ibex
#

just the header, method and body

#

yeah

#

no

#

no

#

the creating & sending the webhook works

#

and yeah, its a post

#

its the response whch is erroring

solemn latch
#

ah okay

#

wheres the docs for webhook responses?

digital ibex
#

not allowing me to do whatever i want underneath

crimson vapor
solemn latch
#

thanks

crimson vapor
#

np

#

reading a bit myself rn

#

so what are you trying to do with the webhook? @digital ibex

digital ibex
#

moyai

#

nothing

crimson vapor
#

wtf

digital ibex
#

its the response which is erroring

crimson vapor
#

may I ask why you need a response if you are not doing anything with it

solemn latch
#

param wait might be useful if your trying to get a response

digital ibex
#

i am moyaing so hard

crimson vapor
#

what is a moyaing

digital ibex
#

if i log webhook, it returns the webhook object

#

:moyai:

#

that

crimson vapor
#

doesnt look like a word

digital ibex
#

ok

#

just if u wanna know if the webhook works again, yes it does

crimson vapor
#

im just confused on what you are trying to do

digital ibex
#

nothing, im trying to make it stop erroing

#

the response im getting is causing an error

#

and idk how to fix it

split nova
#

wht error

digital ibex
#

any anything which i wanna do underneath, i cant do

#

its

#
FetchError: invalid json response body at <url> reason: Unexpected end of JSON input
solemn latch
#

are you sending the wait query string param

digital ibex
#

which one?

solemn latch
#

the only one that exists

digital ibex
#

the query?

#

1 sec

solemn latch
#

it doesnt say what the default is

digital ibex
#

yeah i am

solemn latch
#

oh nvm it does say

#

🤔

split nova
#

try this first and see if it works @digital ibex , if it does its something to do with ur config or wherever the webhook token is stored

const hook = await fetch(`https://discord.com/api/webhooks/webhookthingy/the_actual_token`, {
      // stuff here
      }).then((e) => e.json());
   console.log(`a` + hook.text());
   return hook;
}
#

so put the actual token in the link

crimson vapor
#

its not formatted

#

one sec

split nova
#

and the webhook thingy idk the name 😂

digital ibex
#

what???

solemn latch
#

i think your then is running before the console log, so its erroring out before it can log

crimson vapor
#

id

split nova
#

where it says actuall token

#

add the token

digital ibex
#

the moyai works..

#

no i mean

#

whoop

#

sthats because im moyaing so hard rn sorry. mind me

#

the webhook works

sudden hedge
#

Kind of a newbie, anyone know what this error is?

  throw err;
  ^

Error: Cannot find module './config.json'
Require stack:
- /Users/kamolkhon/Desktop/DiscordBot/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
    at Function.Module._load (internal/modules/cjs/loader.js:841:27)
    at Module.require (internal/modules/cjs/loader.js:1025:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (/Users/kamolkhon/Desktop/DiscordBot/index.js:3:16)
    at Module._compile (internal/modules/cjs/loader.js:1137:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
    at Module.load (internal/modules/cjs/loader.js:985:32)
    at Function.Module._load (internal/modules/cjs/loader.js:878:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/Users/kamolkhon/Desktop/DiscordBot/index.js' ]
}```
crimson vapor
#

yes

split nova
#

wrong path

crimson vapor
#

you are requiring a file that isnt there

#

or wrong path

digital ibex
#

and u want me to post my token ?

split nova
#

no

crimson vapor
#

no

split nova
#

do it yourself and see if it works

#

dont post anything here

digital ibex
#

do what myself?

split nova
#

lmao

solemn latch
#

the webhook is working tho 🤔

split nova
#

does the link work the url?

sudden hedge
#

you are requiring a file that isnt there
@crimson vapor How do I know what file I'm missing>

split nova
#

config.json

solemn latch
#

config.json

#

it says

sudden hedge
#

ohhh

digital ibex
split nova
#

is ur main js file and config.json in same folder? if so remove the ./

#

@sudden hedge

digital ibex
#

this what u wanna see?

#

cuz i am confused rn

sudden hedge
#

Thanks! @split nova

split nova
#

np , and @digital ibex u see where it says ${webhook.id}and ${webhook.token}

#

remove that and add the actual token and id

digital ibex
#

yes?

split nova
#

not a const

digital ibex
#

whats that gonna change?

#

nothing..

split nova
#

idk if u get a request then it means that ur link is the issue

sudden hedge
#

So for config.json, I'm supposed to enter the prefix right?

split nova
#

yeah u can do

solemn latch
#

the request is working

split nova
#

oh ok

solemn latch
#

the webhook is sending the message

#

in the channel

split nova
#

okok

#

my bad

#

one sec

#

are indents an issue in js? idk 😂

solemn latch
#

nah

sudden hedge
solemn latch
#

// means comment

sudden hedge
#

yes i know

#

Lol

digital ibex
#

json dont work like that

#

json: { "key": "value" }

sudden hedge
#

Oh

digital ibex
#

u probably want

#

{ "prefix": "ur prefix here" }

sudden hedge
#

Ah,

crimson vapor
#

{ "defaultPrefix": "!" } is a good way to do it

sudden hedge
#

Thanks a lot!

digital ibex
#

or just const prefix = notdefaultprefix || defaultprefix

#

ez

crimson vapor
#

no its a json file

digital ibex
#

ik

crimson vapor
#

also, dont store prefixes that change in a json file

sudden hedge
#

Oh, now I know how to work a .json file. Thanks a lot!

split nova
#

@digital ibex if u want to stop the error this is what i found:

_parseJSON: function(response) {
  return response.text().then(function(text) {
    return text ? JSON.parse(text) : {}
  })
}
digital ibex
#

kk

#

now i get this error: SyntaxError: Unexpected token o in JSON at position 1

sudden hedge
#
internal/modules/cjs/loader.js:1174
    throw err;
    ^

SyntaxError: /Users/kamolkhon/Desktop/DiscordBot/config.json: Unexpected end of JSON input
    at parse (<anonymous>)
    at Object.Module._extensions..json (internal/modules/cjs/loader.js:1171:22)
    at Module.load (internal/modules/cjs/loader.js:985:32)
    at Function.Module._load (internal/modules/cjs/loader.js:878:14)
    at Module.require (internal/modules/cjs/loader.js:1025:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (/Users/kamolkhon/Desktop/DiscordBot/index.js:3:16)
    at Module._compile (internal/modules/cjs/loader.js:1137:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
    at Module.load (internal/modules/cjs/loader.js:985:32)``` 
I'm pretty sure this means I ddi something wrong in config.json. But, I'm a bit new to programming language, so idk what it is or how to fix it heh 😅
opal plank
#

@sudden hedge its a bad token in your JSON

sudden hedge
#

Incorrect token?

crimson vapor
#

no

opal plank
#

json format is

{
"key": "value",
//continue
}```
crimson vapor
#

can you send the text in your config.json without sending your token or such

opal plank
#

^^

sudden hedge
solemn latch
#

save the file

opal plank
#

that should work just fine

solemn latch
sudden hedge
#

Ah, saved

split nova
#

hmm position one usually means no more parsing

#

is required

earnest phoenix
#

@sudden hedge uhh

sudden hedge
#

Yes?

opal plank
#

linter should take care of anything

earnest phoenix
#

wtf is ur name

sudden hedge
#

LOL

earnest phoenix
#

im not against it

sudden hedge
#

Its just something with my friend lmao

opal plank
earnest phoenix
#

does someone want free money

pallid glen
#

Me

solemn latch
#

no

opal plank
earnest phoenix
#

es

#

yes

opal plank
#

good

pallid glen
#

Btw

earnest phoenix
#

wut

pallid glen
#

Does anyone knows how to make a custom bot

opal plank
#

step 1

#

learn js

solemn latch
#

id say everyone here

earnest phoenix
#

this is develpment

opal plank
#

step 2

#

make bot

#

step 3

#

profit???

pallid glen
#

What profit

earnest phoenix
#

its gotta be approved

fast yacht
#

Any MongoDB wizards out there? I'm fetching a user document that has some values. When I print it out in the terminal I can see the values I want, but when I iterate the object, I only get one of them. Why's that?

opal plank
#

look behind you, joke went right over your head

earnest phoenix
#

😂

solemn latch
opal plank
#

best you can do is use bot-maker @pallid glen

solemn latch
#

profit

opal plank
#

i removed my account

earnest phoenix
#

@loud bison spawn 99999999

honest perch
#

...

earnest phoenix
#

i just found out im a dumbass

digital ibex
#

so.... any ideas @split nova ?

opal plank
#

?

pulsar forge
#

O

opal plank
#

token o at pos 1

#

JSON starts with {

digital ibex
#

?

#

ik

split nova
#

not really man , i said i dont really do js , that error means usually means no more parsing is required

#

sorry man i tried lol

digital ibex
#

yeah

#

but

#

thats the response of the api request which is erroring

#

not anything im doing

#

and idk how to fix it

opal plank
#

you havent used ipc, have you lost?

digital ibex
#

no

opal plank
#

you should

digital ibex
#

this is something different not related to what i was talking about earlier

opal plank
#

oh, i see

karmic compass
#

anyone have a good free 24/7 hosting service? using heroku rn but it only provides 550 hours per month

opal plank
solemn latch
#

shoot i forget the name everyones recommending recently

opal plank
#

danbot?

digital ibex
#

loc

solemn latch
#

nah, some free thing.
they offered quite a lot iirc

karmic compass
#

i mean

#

i could get 1000 hours per month by verifying with credit card but idk if thats a good idea

opal plank
#

aws

digital ibex
#

if u want a good free host, use LOC

opal plank
#

or f1

digital ibex
#

mind if i dm u the discord link?

karmic compass
digital ibex
#

no

#

lmao

karmic compass
#

nah i dont mind

#

dm me it

digital ibex
#

ok

snow urchin
digital ibex
#

have you looked at the docs?

solid falcon
#

@slender thistle #development message

do you know how to create like this? I'm using exec() function but always getting error

pale vessel
#

that is eval, not exec

violet haven
#

can you explain it to me? i'm new to development

solemn latch
#

./commandes/addrole.js wasnt found

violet haven
#

but it works in my computer

solemn latch
#

Commandes
commandes

pale vessel
#

isn't it case insensitive?

digital ibex
#

is this on a linux machine?

violet haven
#

so why is it working

#

no

digital ibex
#

the one it isnt working on

#

what is it running on then?

pale vessel
#

heroku is linux

digital ibex
#

in commandes folder, run ls see if u updated the code or something idk how heroku works

karmic compass
#

wait question about heroku, what do you have to pay for eventually? (in the resources tab, rn its $0.00 but when would it increase?)

digital ibex
#

yes

#

it slowly increases and becomes very expensive, is what i've heard

violet haven
#

i'm trying to change the folder's name

earnest phoenix
#

Does anyone have experience of using MongoDB? I installed the latest version of MongoDB to my CentOS server but when I did mongod to start it up, it stucked at the SHARDING section and timed out after a few minutes.

violet haven
#

ok it works but how do i do to run another script with heroku?

#

my bot is using lavalink so i need two cmd to run both "npm run llavalink" and "node index.js"

honest perch
#

Run lavalink separately then

violet haven
#

but i want it to be on heroku

opal plank
#

bash & chained commands

honest perch
#

Yes

#

You can

#

But i don't recommend it

violet haven
#

ok

opal plank
#

use package.json

honest perch
#

You will have to manually switch ips

#

Every couple of hours

opal plank
#

how about NOT use heroku?

#

cuz its not a hosting platform for bots?

honest perch
#

Use a vps for lavalink definitely

opal plank
#

*and your bot

misty sigil
#

oh yea

violet haven
#

what should i use so?

honest perch
#

Vps

opal plank
#

any decent VPS

violet haven
#

recommend me some

opal plank
honest perch
opal plank
#

i should add LoC to that tbf

honest perch
#

Galaxygate is quite popular

#

From what I've seen the internet speeds are fast too

opal plank
#

i cant be bothered to go check all those vps's to be honest

#

ive heard somes tuff about that, danbot and loc

honest perch
#

Theres one provider I despite

#

As they have workstations on metal shelves

opal plank
#

which is?

honest perch
#

Con

#

Tabo

opal plank
#

never heard

solid falcon
#

that is eval, not exec
@pale vessel on discord.py use eval? I'm discord.py user

tired nimbus
#

if you stop a collector without a reason will the end event's collected reason be a falsey value?

quartz kindle
#

it seems if no reason is provided, it defaults to "user"

#

assuming message collectors

#

timers override it tho

honest perch
#

Tim

#

How many languages do you know

amber fractal
#

All of them

frozen prawn
#

this is probably a dumb question but how do you include gifs in embeds?
since when i add a gif link it goes as a still image

quartz kindle
#

programming or...

honest perch
#

Programming

quartz kindle
#

mostly just js

honest perch
#

What about poothon

quartz kindle
#

never used

honest perch
#

So pretty much js

quartz kindle
#

plus html css and a bit of php of course

#

but js is the only thing i know well

honest perch
#

What about all langs

#

Not just programming

quartz kindle
#

english, portuguese and a bit of slovenian and spanish

opal plank
#

portuguese

torn ravine
#

how would I make my bot dm me when it joins a server

honest perch
#

Are you being stupid

#

Or

opal plank
#

listen on guildCreate event

honest perch
#

Actually asking

torn ravine
#

lol I’m being stupid

opal plank
#

so you dont wanna know?

#

aight fine

honest perch
torn ravine
#

actually yes I do

opal plank
#

decide ree

torn ravine
#

I do

opal plank
#

listen to the guildCreate event, then just get yourself from client.users cache and send dm

#

(im also assuming you're on d.js)

torn ravine
#

I know how to make the bot dm me

#

yes you’re correct

opal plank
#

perfect, you now the second part

#

now the first, part, which is listen to guildCreate event

#

do you know how to listen to events?

torn ravine
#

yep

opal plank
#

then you good to go?

torn ravine
#

Can I make my bot dm me using my user id?

opal plank
#

yeah

#

grab it from cache

torn ravine
#

how would I do that

opal plank
#

client.users cache

torn ravine
#

I think I know how to do that

opal plank
#

perfect, if you get stuck let me know

violet haven
torn ravine
#

I would get my id and use it as a constant, then I would pass it like “message.owner.send(message)”? @opal plank

opal plank
#

running bots on heroku? no, not okay

violet haven
#

Why?

opal plank
#

cuz heroku isnt a bot hosting service

torn ravine
#

heroku worked for me but

sudden geyser
#

btw charge your phone

violet haven
#

XD

opal plank
#

'works' isnt an excuse for 'should'

#

heroku isnt a bot hosting service, and they aggresively put down bots

#

heroku and glitch, both do

#

@torn ravine you could do that, yeah

#

actually

violet haven
#

But I want free hosting

opal plank
#

no, user.send()

frozen prawn
#

how do you include gifs in embeds, since when i add a gif link it goes as a still image?

#

@violet haven theres better options

opal plank
#

@violet haven plenty of free hosting out there that is proper for bots

frozen prawn
#

^

#

like danbot, or some others

violet haven
#

Ok I’ll search tomorrow good night🙃

bright flax
#

I’m waiting for my bot to get approved

frozen prawn
#

idk that many

opal plank
frozen prawn
#

Not Erwin do you know how to you include gifs in embeds, since when i add a gif link it goes as a still image?

sand scroll
#

hmm

opal plank
#

embeds? yeah, either thumbnail or image

sand scroll
#

would a purge command be in the Moderation section or the Utility section?

opal plank
#

make sure extension is gif btw

frozen prawn
#

yea, but when i do .setImage('https://i.ibb.co/2gwMDLJ/ranbom.gif')

sand scroll
#

Not Erwin do you know how to you include gifs in embeds, since when i add a gif link it goes as a still image?
@frozen prawn .setImage("url (including https://))

frozen prawn
#

it sends a static image

sand scroll
#

oh

#

set woops

frozen prawn
#

oh

#

is that moving?

#

nope ok user error

sand scroll
#

no

frozen prawn
#

lmao

sand scroll
#

would a purge command be in the Moderation section or the Utility section?

opal plank
raw turret
#

How do we get bot developer perm?

frozen prawn
#

fits both

sand scroll
#

How do we get bot developer perm?
@raw turret make a bot

opal plank
#

@raw turret wait approval

sand scroll
#

ez

frozen prawn
#

@raw turret submit your bot

raw turret
#

oky

#

tx

bright flax
#

Waiting for my bot to be approved

opal plank
#

then keep waiting

raw turret
#

I just added the bot, I'm waiting.

bright flax
#

100,000 years later

raw turret
#

:D

opal plank
#

good, if you have questions, feel free to ask, else go somewhere else

raw turret
#

okey

torn ravine
frozen prawn
opal plank
#

@frozen prawn from that link you sent i assume the gif itself isnt an actual gif lol

torn ravine
#

I did something

frozen prawn
#

there

#

@opal plank yea lol user error

amber fractal
torn ravine
#

@frozen prawn stop sending seizure inducing images

amber fractal
#

you need the actual gif.

frozen prawn
#

surry

opal plank
#

use that link on the embed

frozen prawn
#

i have the actually gif

#

the fil

#

e

bright flax
#

How long does it take for a bot to be approved

opal plank
#

set the embed payload image with that link

#

@bright flax 3+ weeks

bright flax
#

That rly does suck

frozen prawn
opal plank
#

second one

#

make sure it has extension

frozen prawn
#

ok

#

hm

#

its not actually showing the gif though

opal plank
#

cuz its this

#

https://i.ibb.co/rFwpMCp/ranbom.gif

#

not the one you sent

frozen prawn
#

ok

#

cool

amber fractal
#

You should be able to open it in your browser and it'll be an actual gif

opal plank
#

this chat giving me 2005 vibes with all the rainbow shit in chat

#

lol

frozen prawn
#

m-r help

#

oop

#

thanks it worked

opal plank
#

did that earlier today too. Thats what i get for having multiple discord clients open and alt tabbing and not looking

low shard
#

someone know why i got this i put my vaild passport

opal plank
#

prob send them a message

#

blurry usually gets that

#

though they usually say if you had it blurry or not

low shard
#

@opal plank me ?

frozen prawn
#

wait you have to send your passport to get verified?

opal plank
#

any valid document

low shard
#

yes ,

frozen prawn
#

ah ok

opal plank
#

@low shard yes

#

what

low shard
#

what what

#

passport

opal plank
#

what exactly are you asking for?

#

do i need to tell you how illegal that is?

#

false identity

low shard
#

ok sry

opal plank
trim saddle
#

wtf

knotty granite
#

Hi

halcyon ember
#

when you do await in an async on js it will stop running that and everything below it until the stuff above is done right

#

or with await it stops the rest of the process and lets it run after the line is done

quartz kindle
#

only the current async scope is stopped

#

not the process

karmic compass
#

how do i add a role to a user in discord.js? (using role names or ids)

sudden geyser
karmic compass
#

would this work?
var guildMember = message.author
guildMember.roles.add('id')

or this?
var role = client.roles.cache.find(whatever goes here for the role name finding thing)
var member = message.author
member.roles.add(role)

sudden geyser
#

It has to be a guild member instance, not a user instance (.author vs. .member).

karmic compass
#

so message.member?

sudden geyser
#

yes, try it out and see

karmic compass
#

alr ill get back to you one moment

opal plank
#

@karmic compass dont use vars, use let/const

karmic compass
#

good point, forgot that

#

it works! i'm going to try with the name one now

sudden geyser
#

.roles should be used on a guild instance.

karmic compass
#

can i have an example?

sudden geyser
#

The message object has a .guild property that represents the guild the message was sent from.

karmic compass
#

wait if a did a let theGuild = message.guild would that work?

#

and then instaed of putting client. do theGuild.

sudden geyser
#

yes

karmic compass
#

alr alr

#

the discord api is very interesting

sudden geyser
#

more like discord.js, but it'll get easier as you progress

karmic compass
#

yes, time to test 👀

#

very cool! thank you, surprised this community is very helpful. (it worked)

opal plank
#

raw api is a much bigger monster

sudden geyser
#

trust me discord's api looks like a puppy dog compared to some apis I've seen

bright dove
#

🐶

#

wow the fact that my first message is a dog emoji 🤦

opal plank
#

im using google api too

#

had to make my own lib-ish for youtube

bright dove
#

can someone explain what the circled bit means like I'm 5? very new to programming and/or discord.js and javascript and most of what I've done is from tutorials that don't explain very well

opal plank
#

for is a loop

#

so it'll loop that function for every file in it

#

then it'll declare (import) every file

#

and make a map the key/value

#

aka you're setting client.commands (which is a map), and inserting it the file name plus the function on it

#

if your file is called add

#

the run will code on that add like this

#

const command = require('./commands/add') (add.js, js is omitted)

#

@bright dove

#

cant explain more for dummies than that

bright dove
#

o

#

thanks

snow urchin
#

Anyway I can have <channel>.bulkDelete tell me how much messages it deleted, lets say I specify 100, but it deletes 56 since 44 are older than 2 weeks, how could I get that info

karmic compass
#

just for clarification will serverMember.roles.remove work aswell?

bright dove
#

ok so this works fine when I just have it say "pong!" but as soon as I try to actually add the ping it says that "client" isn't defined. how do I fix this?

#

description says API speed but I haven't actually added that yet lol

opal plank
#

@bright dove no

#

client is not defined

#

those are not decoration, they are there to help you

bright dove
#

huh

#

I know client isn't defined

#

that's what I said

opal plank
#

attach client onto message or pass client as an argument

bright dove
#

idk what that means 😨

opal plank
#

pass client as a parameter

bright dove
#

in the "execute(message, args)"? so make it "execute(client, message, args)"?

#

or am I still being dumb

opal plank
#

yeah

#

order is important

bright dove
#

ok good

opal plank
#

if you put client infront make sure client is infront on your index too

bright dove
#

index is where it's called on the main.js file right?

opal plank
#

yeah

#

index.js, app.js, main.js, bot.js

bright dove
#

ok noice

opal plank
#

its your initial file per say

bright dove
#

yee 🤠

#

well thanks

opal plank
bright dove
#

(I already did most of this stuff, but I ended up breaking it somehow and decided to start from scratch getting in-depth definitions for everything so I don't mess it up again)

opal plank
#

i'd recommend a private repo

#

on gitbuh

#

so you can commit working code, then change it on the go. worst case you got backups

bright dove
#

👍

digital ibex
#

i recommend not privatising

karmic compass
#

i released my github repository to the public a bit ago

digital ibex
#

it is better to make ur repos public for numerous reasons.

  1. receive feedback
  2. just looks better as a dev (my opinion)
  3. people can contribute to ur repo, making ur project even better
    thats just the stuff i can think of, the times when you probably shouldnt is if its an API. then keep it private if u want, otherwise make it public
#

all my projects are open source with the ones i can choose anyways, like the ones im leading the project

#

although, i do plan on making one of my projects private soon though.

grizzled raven
#

if theres a private option let people use it sunglassesheyyy

#

it doesnt make you any worse of a dev bigbrain

digital ibex
#

thats not what im saying

#

i purposely put "(my opinion)"

opal plank
#

i usually recommend private repos
reason 1, people dont copy your code blatently
reason 2, your bot probably isnt unique, theres not reason to make it public. It isnt a lib or something to be handed out

#

i recommended him the repo as a personal backup, not something public

wanton dew
#

^

opal plank
#

post bad code and 400 other people come here suddenly with EXACTLY 11 message listeners

digital ibex
#

the whole point of making ur code public is for feedback, yeah people copy but theres nothing much we can do about it catshrug

#

but yeah, i see where you're coming from

sudden geyser
#

I think 11 is just a default for Node.js

#

Some of where it's coming from is different.

opal plank
#

shivaco said it was likely a bad turkish tutorial

digital ibex
#

lmao

digital ibex
#

im pretty sure my website has had a memory leak or two

#

havent checked the logs because i really dont care

#

only because im storing users in the cache

#

ha

unique knoll
#

Is it common to put your Discord Bot js on Github and public for everyone using your Bot?

digital ibex
#

yes

#

just search: discord nodejs on github lol

opal plank
#

pls dont

digital ibex
#

wrong channel sir

opal plank
#

i was going to say, dont saturate the gitbub with bad code, but its already so bad it wont matter either way

digital ibex
#

O_O