#development

1 messages · Page 695 of 1

quartz kindle
#

whats in bot.js line 107?

wooden lance
#

});

quartz kindle
#

are you sure it wasnt a dm?

wooden lance
#

const guildConf = client.settings.ensure(message.guild.id, defaultSettings); is the bit throwing back the error though

idle basalt
#

im pretty sure the only way for message.guild to be undefined is if you get a dm or if somethings wrong with your message object

#

console.log(message)

wooden lance
#

i added if (!message.guild) return; and still getting an error ```/root/DiscordBotApp/bot.js:217
const guildConf = client.settings.ensure(message.guild.id, defaultSettings);
^

TypeError: Cannot read property 'id' of null
at Client.client.on.message (/root/DiscordBotApp/bot.js:217:58)
at Client.emit (events.js:203:15)
at MessageCreateHandler.handle (/root/DiscordBotApp/node_modules/discord.js/src/client/websocket/packets/handlers/MessageCreate.js:9:34)
at WebSocketPacketManager.handle (/root/DiscordBotApp/node_modules/discord.js/src/client/websocket/packets/WebSocketPacketManager.js:105:65)
at WebSocketConnection.onPacket (/root/DiscordBotApp/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:333:35)
at WebSocketConnection.onMessage (/root/DiscordBotApp/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:296:17)
at WebSocket.onMessage (/root/DiscordBotApp/node_modules/ws/lib/event-target.js:120:16)
at WebSocket.emit (events.js:198:13)
at Receiver.receiverOnMessage (/root/DiscordBotApp/node_modules/ws/lib/websocket.js:789:20)
at Receiver.emit (events.js:198:13)

idle basalt
#

the if statement should go above your code

manic blade
#

UMM Is there a way to check if someone is invisible with a .net bot? ....

wooden lance
#

it is @idle basalt

idle basalt
wooden lance
#

literally right under client.on("message", message => {

idle basalt
#

that means something happens to make message.guild null before it gets to message.guild.id

#

just hastebin the whole file

wooden lance
#

Ok

quartz kindle
#

@wooden lance that error is on line 217 now

wooden lance
idle basalt
#

oh dude no

#

dont make multiple of the same event

wooden lance
#

simple enough

#

thats the issue then

idle basalt
#

could be

#

youre probably getting the error in a different place now

#

like tim noted its on a different line

#

so its probably in your other message event

#

you dont want to open multiple events of the same type, just put everything into one

#

if you want to compartmentalize, use modules

#

right now on every message you have 4 blocks of code running all at once

#

instead you should run it once and then choose the correct block with conditions

wooden lance
#

ok

idle basalt
#

some other tips, use .env to store all your various keys

#

and since youre already separating your commands into separate files, you can do the same with your events

idle basalt
#

does it work now?

wooden lance
#

gonna launch it now

idle basalt
wooden lance
#

the bot launched, so, time to test it

#
  const guildConf = client.settings.ensure(message.guild.id, defaultSettings);
                                                         ^

TypeError: Cannot read property 'id' of null
    at Client.client.on.message (/root/DiscordBotApp/bot.js:107:58)
    at Client.emit (events.js:198:13)
    at MessageCreateHandler.handle (/root/DiscordBotApp/node_modules/discord.js/src/client/websocket/packets/handlers/MessageCreate.js:9:34)
    at WebSocketPacketManager.handle (/root/DiscordBotApp/node_modules/discord.js/src/client/websocket/packets/WebSocketPacketManager.js:105:65)
    at WebSocketConnection.onPacket (/root/DiscordBotApp/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:333:35)
    at WebSocketConnection.onMessage (/root/DiscordBotApp/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:296:17)
    at WebSocket.onMessage (/root/DiscordBotApp/node_modules/ws/lib/event-target.js:120:16)
    at WebSocket.emit (events.js:198:13)
    at Receiver.receiverOnMessage (/root/DiscordBotApp/node_modules/ws/lib/websocket.js:789:20)
    at Receiver.emit (events.js:198:13)
idle basalt
#

console.log(message) above the line 107

wooden lance
#

ok

#

Crashed

#

The message that is being sent is liam:invitelinktest btw, dont really understand why we are getting the bot to relay the message to console.

idle basalt
#

youre logging the message object

#

guild is a property of the message object

#

youre trying to access the id property of the guild property of the message

#

but the guild property is null

#

so by logging the message, you can get more information about whats going on

wooden lance
#

ok

#

the response

idle basalt
#

message.guild clearly has a guild in it

#

wtf

#

send your code again

wooden lance
#

what code

idle basalt
#

the message event

wooden lance
#

ok

earnest phoenix
#

What is the limit of reactions a bot can make on a message @modern sable christmasthink

#

To counter any API abuse christmasthink

idle basalt
#

also now in your error it seems to happen on line 104 instead of 107

earnest phoenix
#

a message can have 20 different reactions @earnest phoenix

earnest phoenix
#

if the bot were to be only user to make reactions, then it's 20

#

@earnest phoenix yes but, bots must respect Discord's api

idle basalt
#

wait im an idiot

earnest phoenix
#

they must, but some of them don't

#

also what

wooden lance
earnest phoenix
#

a bot is allowed to place 20 reactions on a message

#

just not to spam it

idle basalt
#

no i lied im a double idiot

wooden lance
#

oof

#

im more of an idiot

idle basalt
#

thats strange man idk what to tell you

#

the message you log literally above the error line has a guild in it

wooden lance
#

ye

idle basalt
#

sorry :(

wooden lance
#

it's ok, i get this error a lot, normally when i use const

#

but the client.on before (the one that ran the commands) worked until i moved the code over.

#

ill try removing bit by bit

topaz fjord
#

@wooden lance have you tried moving ```js
const guildConf = client.settings.ensure(message.guild.id, defaultSettings);

```js
  if(!message.guild || message.author.bot) return;
wooden lance
#

IT WORKS OMG THANK YOU @topaz fjord

topaz fjord
#

ofc it does

#

you're using message.guild.id before you even check if the message is from a guild

wooden lance
#

yeah, im dumb like that

#

but thank you!

earnest phoenix
#

im trying to put this in my code bot.channels.get("<622171281285971988>").send("<your message content here>") but it comes back with "cannot read property 'send' of undefined. ??

knotty steeple
#

remove <>

earnest phoenix
#

ohh

#

wow im dumb lol

#

thx

slim heart
#

i want to make a live updated chart similar to the graphic of social blade live count, i have the websocket push every 3 seconds if there was a change to the number, but is there like a prebuilt front end library or something that i can use and port that number and time data into a neat graph like that.

earnest phoenix
#

I swear I remember there being one, just forget the name...

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

low wasp
#

No bad

#

Needs pagination

west raptor
#

@sage bobcat make it owner only

#

dbl doesnt allow bots that display all servers

amber fractal
#

uh

#

nvm

#

it already is

slim heart
west raptor
#

im blind

#

why is there the else randomly

slim heart
#

its to the previous if

west raptor
#

im aware

slim heart
#

if (whatever) action
else
works

west raptor
#

but why

slim heart
#

some people dont trust return idk

hushed berry
#

man, that formatting really hurts my brain

knotty steeple
#

same

slim heart
#

anyone get an answer to my question?

warm marsh
#

Nope?

slim heart
#

whyd u respond then

warm marsh
#

Just code one yourself?

slim heart
#

my question was a prebuilt frontend library

warm marsh
#

That takes data and turns it into a graph.

#

?*

slim heart
#

dont response to questions if you dont have an answer please

warm marsh
#

respond*

#

It's pretty hard to get a response when your question is very vague.

quartz kindle
#

your*

warm marsh
#

Yea

slim heart
#

its not that vague its kinda obvious what i asked for. a live chart built around a preexisting websocket

warm marsh
#

Yeah, If you couldn't find one by simply Googling. Just code one.

slim heart
#

thats why im asking here

#

and you're diverting the question away from anyone who could possibly have an answer
so please, if you dont have the answer to a question, dont respond

west raptor
#

Yeah, it's best to only respond if you have a solution or advice

#

it really contributes nothing to the question and/or conversation if you just say "idk" or "just google hahahahaha xd openeyelaughing"

amber fractal
#

@slim heart you mean something like grafana?

#

I dont have a real example

#

or I might

slim heart
#

doesnt it use prome?

amber fractal
#

prome?

#

idek what that is

slim heart
#

prometheus

amber fractal
#

what does that do tho

slim heart
#

im pretty sure its the backend manager for it

#

i already have the ws

inner jewel
#

grafana can have many backends

#

prometheus is just one

amber fractal
slim heart
#

the goal would be to create a thing any user can access thats updated live

#

idk how that works if grafana is meant to be used publicly?

amber fractal
#

It was just a suggestion that I knew of that may have worked ¯_(ツ)_/¯

slim heart
#

ill take a look tho ty

fallow quiver
#

I know how to edit JSONs using Java, but is there a way to create and delete JSON files using the bot?

nimble phoenix
#

is the bot maker on steam actually reliable?

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

nimble phoenix
#

...oh

#

why's that?

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

nimble phoenix
#

I don't really know anything at all. I've been using the dapper dino tutorials on youtube

sage bobcat
#

One message removed from a suspended account.

nimble phoenix
#

I only know bbcode and some html

#

so I don't really know where to start

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

knotty steeple
#

pls dont watch tutorials to make discord bots

sage bobcat
#

One message removed from a suspended account.

knotty steeple
#

half of them are outdated

#

and others are just bad

#

learn a programming language, pick a library look at the docs then make ur bot

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

nimble phoenix
#

oh my god I'm so confused

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

knotty steeple
#

python has more bullshit you have to know about

sage bobcat
#

One message removed from a suspended account.

knotty steeple
#

i can tell u from experience

sage bobcat
#

One message removed from a suspended account.

nimble phoenix
#

I've looked and asked everywhere for WHERE to start and didn't get anything.

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

nimble phoenix
#

I don't mind putting a few years of work into it and I don't want to be spoonfed I want to actually learn but I don't know where to start

sage bobcat
#

One message removed from a suspended account.

knotty steeple
#

^

sage bobcat
#

One message removed from a suspended account.

nimble phoenix
#

mkay

knotty steeple
#
sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

idle basalt
#

it doesnt take years to learn dw

knotty steeple
#

there is some code examples you can look at

#

it doesnt take years to learn a language it takes that time to master it

nimble phoenix
#

It's just been my dream to be a coder etc. for years, since I was a child, and I finally have the time I can put into it

sage bobcat
#

One message removed from a suspended account.

knotty steeple
#

hey

sage bobcat
#

One message removed from a suspended account.

knotty steeple
#

i made shitty js stuff when i was 10

idle basalt
#

a lot of people start on websites like codecademy

sage bobcat
#

One message removed from a suspended account.

nimble phoenix
#

I don't have money for CA

knotty steeple
#

its free MegaThonk

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

nimble phoenix
#

WHAT?

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

knotty steeple
#

udemy courses are paid

#

but good

nimble phoenix
#

It kept pushing me telling me it was like 10$ a month or something

knotty steeple
#

idk if udemy has js tho

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

nimble phoenix
#

codeacedamy

knotty steeple
#

codeacadamy

sage bobcat
#

One message removed from a suspended account.

knotty steeple
#

different site

#

its codecadamy

idle basalt
#

codecademy not codeacademy

sage bobcat
#

One message removed from a suspended account.

idle basalt
#

its totally free but there is a pro version if you want more from it

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

knotty steeple
#

which you shouldnt buy

sage bobcat
#

One message removed from a suspended account.

ebon tiger
#

How can i test my bot ?

sage bobcat
#

One message removed from a suspended account.

idle basalt
#

there are a million ways to start, just get started

knotty steeple
#

also dont get a linter

idle basalt
#

turn it on and.. test it... ??

#

like what

knotty steeple
#

this is actually bad advice but pls dont get a linter if you dont want to be screamed at for ur code

idle basalt
#

Thonk def get a linter

#

learn good practices right away and then you wont have to relearn how to write code if you plan on getting a job or something

nimble phoenix
#

what ever methods y'all have to share on how to get started I'm all open ears

idle basalt
#

we just gave you like 3

nimble phoenix
#

DV said they have something if I wanted it

idle basalt
#
  1. pick a lang (js is prob the easiest, esp since you want to make a discord bot)
  2. start learning/coding
knotty steeple
#

hey i personally hate linters mmLol

idle basalt
#

there are an infinite number of ways to get started, dont worry about it too much just start

knotty steeple
#

make a command line

#

app

#

thing

#

to experiment with node.js

#

before u make a bot

nimble phoenix
#

a... what?

idle basalt
#

a little thing that runs in your terminal

knotty steeple
#

a cli

#

a script that you can make so when you run it does certain things in your terminal

amber fractal
#

no not cli, command line app thing

knotty steeple
#

yes™

#

command line app thing

fallow quiver
#

I just started JS but Node is like a program that runs your script I pretty sure

amber fractal
#

clat

knotty steeple
#

node.js is a runtime for js

amber fractal
#

^

knotty steeple
#

node.js !== js

fallow quiver
#

You should really get Visual Code Studio, I've been using that and it works great

knotty steeple
#

or sublime text

amber fractal
#

That's a personal preference

knotty steeple
#

i use neovim

idle basalt
#

vim vim

amber fractal
#

vsc is 👌 tho

knotty steeple
#

i like vsc but it takes all my ram because electron

#

so just coding in my terminal works

fallow quiver
#

Can I use my bot to create and delete JSONs in the bot folder? Or can it only edit JSONs

knotty steeple
#

with node you can use fs

idle basalt
#

your bot can do whatever you want bro

nimble phoenix
#

I have vsc

fallow quiver
#

What would be the code for creating and deleting JSONs

idle basalt
#

google: delete a file node

fallow quiver
#

Ok

idle basalt
#

shockingly, youll find the answer

knotty steeple
#

for making a file

idle basalt
#

its like unlink or something to delete

knotty steeple
#
fs.appendFile('message.txt', 'data to append', (err) => {
  if (err) throw err;
  console.log('The "data to append" was appended to file!');
});
#

example

idle basalt
#

fs.unlinkSync('path/to/file')

lament apex
#

How does one get the Bot Developer role?

idle basalt
#

make a bot

#

and submit it to the website

lament apex
#

It's automatic?

nimble phoenix
#

yep once it gets accepted

knotty steeple
#

no

idle basalt
#

ye

nimble phoenix
knotty steeple
#

synchronously is bad

lament apex
#

Got it.

idle basalt
#

why?

knotty steeple
#

always try to do thing asynchronously

#
// Assuming that 'path/file.txt' is a regular file.
fs.unlink('path/file.txt', (err) => {
  if (err) throw err;
  console.log('path/file.txt was deleted');
});

idle basalt
#

eh

fallow quiver
#

So from my research I think its fs.writeFile("thing.json", dictstring);

knotty steeple
#

so you don't have blocking

#

and blocking can be bad

idle basalt
#

i thought you wanted to delete the file

fallow quiver
#

I need to create files to

knotty steeple
#

why are you making json files anyway

idle basalt
#

^

fallow quiver
#

The plan is that the bot can create JSONs that will store data for the sever so it will create a file calle `<servername>event.json

knotty steeple
#

do not do that

idle basalt
#

you probably want a database then

knotty steeple
#

use a database

idle basalt
#

json is fine sometimes but its usually more hassle than its worth

broken shale
#

I use json files to store emotes mmLol

knotty steeple
#

json files can be corrupted and if your bot is big json files are really bad

sinful lotus
#

Its better than saving all server data in single json tbh

knotty steeple
#

if you have to use json yes

sinful lotus
#

at least it womt corrupt since one guild = one json

idle basalt
#

i think json only gets corrupted with concurrent reads/writes

broken shale
#

yes

sinful lotus
#

writes only

#

reads are fine

idle basalt
#

so if you create a file for each guild and you dont let the users access them all at the same time, then youre chillin

knotty steeple
#

json corrupts if it is writing and it stops

#

randomly

idle basalt
#

but thats honestly a lot of trouble just use a db

knotty steeple
#

kinda like how my pc bios got corrupted

idle basalt
#

json isnt meant to store data like this

sinful lotus
#

but still I would suggest a proper db even your json idea is not bad

knotty steeple
#

sqlite is good for a small db

fallow quiver
#

I'm trying to use it to store a score data for each user when a mod starts an event, and then when an event is ended it send the scores and deletes or clears the file

sinful lotus
#

sqlite is good for 20k guilds even 50k

knotty steeple
#

really?

sinful lotus
#

just dont expect the same over 100k

knotty steeple
#

oof

#

time to use sqlite then its easier

sinful lotus
#

I used sqlite until 50k

knotty steeple
#

what did u switch to

fallow quiver
#

Would a database work for what I want it to?

sinful lotus
#

mariadb

idle basalt
#

yes

knotty steeple
#

mmm mariadb

idle basalt
#

thats what you want

knotty steeple
#

how did you move the data tho

idle basalt
#

wdym stormy, like how you can log in to the website?

sinful lotus
#

I did a data reset

knotty steeple
#

o

valid frigate
#

mongo gang

knotty steeple
#

pretty sure there should atleast be a way to transfer

#

from sqlite to mysql/mariadb

sinful lotus
#

mariadb is mysql but its better

knotty steeple
#

yes i know i use mariadb

sinful lotus
#

so if you plan to use mysql, just use mariadb

idle basalt
#

oh so like when someone joins it asks them to type a code or something?

knotty steeple
#

generate a random code

#

send that code in dms

#

wait for a response

idle basalt
#

and if you get it back then let em in

knotty steeple
#

if no response, kick

#

if response, give them a role or perms

sinful lotus
#

you dont need db for that

knotty steeple
#

¯_(ツ)_/¯

idle basalt
#

the other guy wants a db

sinful lotus
#

I personally made one with roles only

idle basalt
#

hes doing scores

knotty steeple
#

u dont need any db for it

idle basalt
#

no you dont need anything stormy

fallow quiver
#

Yeah, for event management

knotty steeple
#

you can just awaitMessage

#

for basic

amber fractal
#

permissions 0 is just the everyone role

idle basalt
#

no youll be fine

lament apex
#

Sorry wrong channel

#

Oh ok great.

valid frigate
#

ok so ive asked this probably once already b u t .

lament apex
#

Also, do I have to submit all the code of my bot while adding it?

valid frigate
#

how can i actually spawn shards in djs by using websockets

knotty steeple
#

just put the info it asks you for

#

an id, library

#

description

#

etc

#

and submit

#

@valid frigate u can use sharding managers

#

smh

lament apex
#

Alright. Haven't looked over the page yet so I was just wondering...

valid frigate
#

i'm aware but

#

what about making my own

knotty steeple
#

but

#

why

valid frigate
#

id guess it means i 1) learn more about websockets and 2) to be a cool kid like ravy

#

smh

knotty steeple
#

copy

slim heart
#

Wdym making your own

valid frigate
#

i'm interested in making kind of like

#

my own way to spawn shards

slim heart
#

You want to use raw discord websockets or do you want to make a manager that works straight into djs

valid frigate
#

uhhh something that would work straight into djs

#

probably since the discord api is scary

slim heart
#

I mean it’d be dumb to not use the djs manager for djs

#

Also, sharding managers don’t manage websockets

valid frigate
#

then again

#

maybe i can use websockets for something else

slim heart
#

Well ya gotta find what

valid frigate
#

yeah

slim heart
#

Like I just made Jaylon a completely raw websocket for discord

valid frigate
#

i mean websockets seem pretty cool

slim heart
#

With absolutely no caching and events n stuff lmao

valid frigate
#

sick

#

do you have any resources on learning websockets etc

slim heart
#

Well

valid frigate
#

google is one

slim heart
#

So here’s the thing, websockets are really simple, you send strings, and you receive strings

#

You connect, you get a socket, you can send things straight to that socket

valid frigate
#

interesting

slim heart
#

There’s not much more you need to know unless u want the specifics of like websocket server creation

valid frigate
#

so the client keeps the connection open vs. request/response

slim heart
#

Which is still pretty much the same principle but there’s a lot of things with client storing if you want to send to multiple people, stoof like that

#

Yeah, websockets don’t need any receiver input to send to something

valid frigate
#

ok cool

#

i think im gonna try making a websocket server

slim heart
#

there’s plenty of guides online to get you started there

valid frigate
#

ok thanks jpb

#

oh also congrats on cert :pogu:

slim heart
#

Tanks

pliant needle
#

What was js to change the bot's own nickname?

slim heart
#

Member.setNickname

pliant needle
#

Tyvm

fallow quiver
#

How would I reference the server name using discord.js?

idle basalt
#

<Guild>.name

#

docs bro

fallow quiver
#

Thanks

fallow quiver
#

I don't think that's it, I mean like
message.channel.send ("This Server Is: " <servername>)

idle basalt
#

<Guild> just means get the guild object from somewhere and then access the name property

#

you can get to the guild object however you want

fallow quiver
#

Ok Thank you

#

I've been "coding" a while but I just I just started Java a few days ago

idle basalt
#

well this is javascript

#

so

#

...

broken shale
#

also use template literals for the servername

idle basalt
#
`string ${variable}`
```is equivalent to```js
'string' + variable```
#

to help better explain what fortis said

fallow quiver
#

Ok hopefully last question for a while, is there a way to get the ID for animated emojis if I don't have nitro, I know the bot can sent it but can I copy it from the emoji list somehow

broken shale
#

<client>.emojis.find(x => x.name == 'something').id

fallow quiver
#

Ok

valid frigate
#

get used to using ===

broken shale
#

I like == ¯_(ツ)_/¯

valid frigate
#

we dont want "true" === 1 to be a thing

#

https://stackoverflow.com/questions/359494/which-equals-operator-vs-should-be-used-in-javascript-comparisons

The lack of transitivity is alarming. My advice is to never use the evil twins. Instead, always use === and !==. All of the comparisons just shown produce false with the === operator.

#

from accepted answer, more details in the link

earnest phoenix
#

total brain fart but

#

how would you have a bot generate a random number again

loud salmon
#

@earnest phoenix check your language docs for generating randomness

earnest phoenix
#

ok 🙂

loud salmon
#

@earnest phoenix this isnt the place to find dev work..

#

dbl hardrequest

covert turtleBOT
#

You seem to have asked for a very specific bot/feature. You likely won't find it on the site if you haven't searched already... What you can do is talk to Oliy#0330 to get access to #434058442764714002 and find a developer willing to do the job. Be sure you provide enough details like payment options, if you are going to selfhost it or not, how fast you want it done, etc.

mental thorn
#

Is there a way I cant get rid of the annoying white border on the bot img?

wet forge
#

@mental thorn the border is defined at .columns .bot-img

#

honestly im gonna go remove that now too

quasi forge
quartz kindle
#

css is not canceled anywhere

#

that border is defined here

#

you just need to replace it with a rule of equal or higher specificity

wet forge
#

got it

.columns .bot-img {
    box-shadow: none !important
}
unique wagon
#

damn, let me get it

#

oh... i think its the s....

#

oops

#

i mean is there supposed to be a s?

unique nimbus
#

@commands.has_permissions(manage_channels=true)

#

if its in a cog

unique wagon
#

I defined it cmd.bot_has_permissions

unique nimbus
#
@commands.command()
@commands.has_permissions(manage_channels=true)
unique wagon
#

Manage_channels=true

#

ye i am confused

#

thats what i did...

unique nimbus
#

exactly like that?

unique wagon
#

has_permissions is for the user

#

it checks if the user has the perms

unique nimbus
#

yes

unique wagon
#

I am checking if the BOT has permissions

#

so i did this

#

@cmd.bot_has_permissions(Manage_channels=true)

unique nimbus
#

was there any errors

#

wait try

#
@cmd.self.bot_has_permissions(Manage_channels=true)
unique wagon
#

i dont need .self tho....

#

Its not defined as that

#

Let me make sure its works

#

i'll do another checl

earnest phoenix
#

İs true ?
if (!message.member.hasPermission('MANAGE_MESSAGES')) return message.channel.send('You don't have permissions to use this command!')

#

hasPermission

west raptor
#

Yes

#

I think new versions of d.js do message.member.permissions.has() though

fallow quiver
#

Is it possible to reference the server's logo? Some thing like this-

 if (message.content.startsWith (prefix + "startevent")) {
        embed = new discord.RichEmbed ()
            .setAuthor (message.author.username)
            .setDescription ("**Begining an Event!**")
            .setFooter ("*Please Wait A Moment Before You Begin")
            .addField ("Server: " + message.guild.name, ":LoadBuffer:")
            .setThumbnail ([Guild Image Goes Here])
            .setColor ("#0086ff");
hollow saddle
fallow quiver
#

I tried this and it tells me .iconURL is not a function

    if (message.content.startsWith (prefix + "startevent")) {
        icon = message.guild.iconURL()
        embed = new discord.RichEmbed ()
            .setAuthor (message.author.username)
            .setDescription ("**Begining an Event!**")
            .setFooter ("*Please Wait A Moment Before You Begin")
            .addField ("Server: " + message.guild.name, ":LoadBuffer:")
            .setThumbnail (icon)
            .setColor ("#0086ff");
hollow saddle
#

That’s because it is indeed not a function

#

It’s a property

grim aspen
#

correct

hollow saddle
#

message.guild.iconURL

fallow quiver
#

Thats what I have

earnest phoenix
#

it's a property

#

not a method

#

like the error says

hollow saddle
#

No, you have it as a function with the parenthesis

#

Remove them

fallow quiver
#

Ah

#

I feel pretty dumb

grim aspen
#

It would be like msg.channel.send()

#

It wouldn't be msg.channel.send

earnest phoenix
#

that's the wrong analogy

fallow quiver
#

So this message.channel.send() is a method
and message.guild.iconURL is a property

hollow saddle
#

Correct

fallow quiver
#

I'm learning

carmine echo
#

I've wasted about an hour on this regex and I don't know what I'm even doing with my life anymore, but it's still not working. Can anyone help me out?

/\b[oо0u🇴🇺]+[\s.,*_-`]*[w🇼]+[\s,.*_-`]*[oо0u🇴🇺]+/gi
earnest phoenix
#

events/message.js
Not working , what's wrong?
if (message.channel.type == 'dm') return message.channel.send("Commands are disabled in DM\"s")

carmine echo
#

Any errors?

#

If not, show more context

earnest phoenix
#

no error :/

carmine echo
#

Please show more code

earnest phoenix
#

more code?

carmine echo
#

Yes, the code around it

long blaze
#

yeah show the block of code which contains that statement, give more context

carmine echo
#

It's likely that you have something like if (message.channel.type != 'text') return above it

#

and honestly you don't need the bot to tell people that it's not available in dms, it's common sense (for most people at least )

earnest phoenix
#
  let client = message.client;
  let prefix = '+'
  if (message.author.bot) return;
  if (!message.content.startsWith(prefix)) return;
  if (message.channel.type == 'dm') return message.channel.send("Commands are disabled in DM\"s")
 let command = message.content.split(' ')[0].slice(prefix.length)
  let params = message.content.split(' ').slice(1)
  let cmd;
  if (client.commands.has(command)) cmd = client.commands.get(command)
  else if (client.aliases.has(command)) cmd = client.commands.get(client.aliases.get(command))
if (cmd){
cmd.run(client, message, args)
}
#

Here

carmine echo
#
if (!message.content.startsWith(prefix)) return;

This may be the problem. Does the message you're sending to the bot start with the prefix? If not, you should swap these lines https://i.imgur.com/ppXkOFo.png

wheat jolt
#

why this isn't a hyperlink

#

the link is undefined

#

nvm

earnest phoenix
#

how can i check if a user has been in a server for more than 2 days

#

what api are you using? If it's Discord.NET you can use SocketGuildUser.JoinedAt

#

default

#

what

#

idk

#

how do i check lol

#

what programming language are you using?

#

d js

#

oh

#

I don't know about discord.js rip

#

oh

#

api is not an api wrapper

#

🙂 thx for trying

#

does anyone else know how to check if a member has been in a server a certain amount of time/days? d.js

#

you don't need to repeat your question

#

damn i was just about to send that link

#

lmao you're too fast

#

ughh

#

i don't know how to implement it lmao

#

Can anyone take a look at my command reference and give me feedback? I think the sizes aren't good (they feel like they're both too large for a normal website, or either too small for its information density)

#

get a guild member, use that property and subtract it from the current date, then check if the difference is 2 days or less @earnest phoenix

#

oh didn't know you could do it with that function

#

but how would you check the difference

#

it's unreadable @earnest phoenix

#

Are you talking about the index.html page?

#

the whole website is unreadable and unpleasant to look at

#

oof

#

color scheme is iffy

#

yeah that's what I was thinking

#

I'm not good at html

#

not a big deal

#

there's also too much information

#

for something that's supposed to be a reference, this is too much to look at, it drives your user away from the site if there's too much text

#

btw hate to break the convo, but how would you check the difference?

#

haha how do you create that

#

is there a template on a page or something

#

lmgtfy, yes

#

I get that this message wasn't meant for me but holy shit it made me remember about the HTML color picker that creates a color scheme for you

#

thanks m8

#
  console.log(`Logged in as ${bot.user.tag}!`);
var date1 = new Date("08/09/2017");
var date2 = new Date("08/10/2017");
var diffDays = parseInt((date2 - date1) / (1000 * 60 * 60 * 24)); //gives day difference 
//one_day means 1000*60*60*24
//one_hour means 1000*60*60
//one_minute means 1000*60
//one_second means 1000
console.log(diffDays)
});


bot.on('message', async message => {
message.content.startsWith ('prefix + nuke'); {    

    
    if(message.author.bot) return;
     Math.floor((date2 - date1) / (1000*60*60*24))
  let messageArray = message.content.split(" ");
  let cmd = messageArray[0];
  let args = messageArray.slice(1);    



   if(!args[0]){
message.channel.send({embed: {
color: 3447003,
description: "User, you are incorrectly using this command.\n**Usage:** ``;nuke <@user>``\n**Example:** ``;nuke Ross#6821``"
}});
return;
}```
#

if i can get the difference of the days, how would i make it so a user has to be in the server for diffDays)?

#

(The color is probably going to change when I get to that)

#

just the pink

#

hurts

#

yeah I know

#

yea

#

can someone fix my problem xD

#

its above

#

if i can get the difference of the days, how would i make it so a user has to be in the server for diffDays)?
it's a simple if check at this point

#

if it's 2 days or under, error out/return

fallow quiver
#

This is my script

    if (message.content.startsWith (prefix + "startevent")) {
        if (message.member.permissions.has('MANAGE_CHANNELS')) {
            embed = new discord.RichEmbed ()
                .setDescription ("**Begining an Event!**")
                .setFooter ("*Please Wait A Moment Before Begining*")
                .addField ("Server: " + message.guild.name, ":LoadBuffer:")
                .setThumbnail (message.guild.iconURL)
                .setColor ("#0086ff")

            message.channel.send (embed)
            var fs = require('fs')

            fs.writeFile(message.guild.name + 'score.db', 'Hello!', function (err) {
                if (err) throw err;
                console.log('Started Event!');
            });
        }
    }

when I try to run the command it tells me ReferenceError: channel is not defined
It was running fin before I added the writeFile

modern elm
#

Does anyone know where i can find some good documentation or maybe a working tutorial on music commands?

earnest phoenix
#

in which language

modern elm
#

javascript

#

discordjs

fallow quiver
#

Ok, I took off the message.guild.name and it worked, but I want it to create a file that contains the server name so that each server has its own db file

modern elm
#

when you addfield

#

you are giving it an empty value

#

you are only setting the title

#

nvm

#

cant see it well on mobile

fallow quiver
#

It has nothing to do with the embed, that works

west spoke
#

@fallow quiver you will want to use server ID

#

say two servers had the same name

#

it would cross over if you used server name as the DB name

earnest phoenix
#
message.content.startsWith ('prefix + test'); {
if(message.author.bot) return;

const ms = require('parse-ms');
let date = new Date();
let mstime = message.member.joinedAt - date


if(ms(mstime).days < 2) {
message.channel.send({embed: {
color: 3447003,
description: `<@${message.author.id}>, this command may only be used by members who have been in this server for at least 2 days`
}});
}```
#

for some reason no matter what the message says it still sends the 2 days message

#

could you please help

quartz kindle
#

message.member.joinedAt - date will always give you a negative number

#

because the current date is always bigger than a past date

earnest phoenix
#

thats fine

#

thats not my concern

#

im just trying to figure out why it respons to every message liket his

quartz kindle
#

because you are checking if a negative number is smaller than 2

#

and the answer is always yes

earnest phoenix
#

but how can i make it

#

so it only responds to one specific message

quartz kindle
#

what message?

earnest phoenix
#

its in the code

#

;help should be the message it responds to.

quartz kindle
#

the code says it should respond to "prefix+test"

earnest phoenix
#

it doesn't, they don't have an if closure

quartz kindle
#

the if is not even right lol

#

there is no if at all

earnest phoenix
#

what

#

what did i do wrong?

quartz kindle
#
//correct
if(something) {
    // do something
}

//you did
something; {
    // do something
}```
weary lark
#
if (!something) return nothing;
earnest phoenix
#

so if(message.content.startsWith ('prefix + help');) {

#

?

#

doesn't work

weary lark
#

close

quartz kindle
#

also, 'prefix + help' is not getting the actual prefix, its getting the literal text "prefix + help"

weary lark
#

yes

earnest phoenix
#

oh lol

#

let me fix that

weary lark
#

if (message.content.startsWith(prefix + 'help')) { poop; }

quartz kindle
#

also, dont put semicolons inside parentheses

weary lark
#

i mean winky face but lol

earnest phoenix
#

ok

#

now how do i fix the negative number issue?

quartz kindle
#

simple math lol

#

10 - 12 = -2

#

if you want 2 instead, what do you do?

earnest phoenix
#

oh so switch it

quartz kindle
#

exactly

weary lark
#

yeah

earnest phoenix
#

haha

#

lol

#

ok thanks so much for the help

#

i really appreciate it guys !

quartz kindle
#

👍

weary lark
#

👍

earnest phoenix
#

ugh now i have a new issue with that exact code

#

when i switch the two variables

#

it comes up with ReferenceError: ms is not defined

#

doesn't crash or anything but still its annoying

weary lark
#

@earnest phoenix try going for a dark background and that header colour like #191919 or something, that discord blurple is good but shouldnt be used everywhere

earnest phoenix
#

I'll give it a shot

weary lark
#

alright

#

what line is it saying the error is on?

#

@earnest phoenix

earnest phoenix
#

not a error

weary lark
#

oh

earnest phoenix
#

just a refernece error

weary lark
#

just a reference

#

hm

#

weird

earnest phoenix
#

yea

#

when i do the command

unique nimbus
#

catch the error

#

thonk

#

you also didnt define ms

weary lark
#

const ms = require('parse-ms');

unique nimbus
#

Where did you place it because it might not be getting seen

earnest phoenix
#

and i set it so that if you've been in the server longer than 00000001 days you can use the command

#

but it still sends the "you can only use this if you've been in the servr" err

unique nimbus
#

make an else command?

#

idfk js

west raptor
earnest phoenix
#

?

west raptor
#

const ms = require('ms'); should probably be at the top of the file

earnest phoenix
#

ok

unique nimbus
#

thonk

west raptor
#

that just makes it to where it's not out of scope

#

like

#

100%

earnest phoenix
#

ok that worked

#

but i still have a error

west raptor
#

what is it?

earnest phoenix
#

it sends the "you haven't been in the server for long enough" even though i made it I only have to be in it .000000001 day

west raptor
#

can you log ms(mstime).days?

earnest phoenix
#

sure

quartz kindle
#

did "true" show up in your logs?

earnest phoenix
#

comes back as undefined

#

it must not be reading it

#

idk why tho

quartz kindle
#

console.log(ms(mstime))

earnest phoenix
#

kk

west raptor
#

well

#

there's your issue

quartz kindle
#

days is rounded

west raptor
#

mstime is probably wrong

earnest phoenix
#

ohhhh

west raptor
#

oh

earnest phoenix
#

days is rounded

west raptor
#

that

#

that too

earnest phoenix
#

let me try with a alt

#

brb

#

yeah thats the error

#

looks good to me than

wheat jolt
#

discord.js lib

earnest phoenix
#

something looks wrong thee

#

it should be

quartz kindle
#

@wheat jolt is the message cached?

wheat jolt
#

the bot restarted

quartz kindle
#

@earnest phoenix please dont try to help when you dont understand lol

wheat jolt
#

so i don't think so

earnest phoenix
#

lol

#

k bye

quartz kindle
#

messageReactionAdd only reacts on cached messages, unless you enable partials

wheat jolt
#

partials?

#

idk what's that

quartz kindle
#

partials fire events containing incomplete data

amber fractal
#

raw events

quartz kindle
#

for example, discord sends you all events, regardless or caching status, but the library does not fire them if there is missing data

amber fractal
#

AIG has a guide just for this

#

well by that I mean copy paste code

quartz kindle
#

if you enable partials, it will fire them with missing data, meaning the raction will only contain IDs and not full objects

#

v12 has an option to enable partials

#

in v11 it has to be done with the raw event iirc

amber fractal
#

Oh I didnt know master had an option

quartz kindle
#

yeah, although i dont know how exactly it behaves, since i havent used it

#

i graduated to using the raw event for everything lmao

unique nimbus
#

What is a good database to store users data which doesn't get suicidal

quartz kindle
#

any proper database?

unique nimbus
#

okay, what is easy to learn in your opinion

quartz kindle
#

for small applications, sqlite is great, everything else is overkill imo

unique nimbus
#

lmao

#

what if txt files with single characters in each file

#

I think that beats json anyway

quartz kindle
#

that will kill your drive lmao

unique nimbus
#

pff I downloaded 1M empty mp3 files

weary lark
#

why

quartz kindle
#

how big is your drive's cluster/sector size?

unique nimbus
#

it was on a server

#

and like 20gb storage

quartz kindle
#

ah well, a vps is probably running on a vm, so the data is probably written in a virtual file

unique nimbus
#

I mean

#

¯_(ツ)_/¯

#

Got any tutorials for sqlite you recommend?

quartz kindle
#

if it was in an actual disk, 1 million empty files would take 500mb+ on 512byte sectors and 64gb+ at 64k sectors

unique nimbus
#

lmao

quartz kindle
#

you can find sqlite tutorials anywhere, is 90% compatible with general SQL language

#

it also depends on which library/interface you use, so also check your library's docs

unique nimbus
#

yes

#

Time to see if I accidently break it

earnest phoenix
#

so i have a dilemna

#

im trying to set a description using ` around it so i can use <@${message.author.id}> function

#

but i want to have some of the text come up like this

#

how can i combine the two so it doesn't creash

unique nimbus
#

close the first one

#

open the next one

#

hello hello

#
`hello` `hello`
earnest phoenix
#

hello hello

#

let me test

#

no it doesn't work

#

because it thinks that the ` to start the first part of text is the end of the length

#

so it crashes on it

unique nimbus
#

then make it "

earnest phoenix
#

to ping the person

#

because it only works in ` function

#

?

amber fractal
#

dont ghost ping

#

it helps no one

earnest phoenix
#

i think he saw it

#

and i deleted it cause it took up space

amber fractal
#

it's a lot easier if you show the code you need help with

earnest phoenix
#

kk

#

cause there's too many ``

amber fractal
#

escape it

earnest phoenix
#

how

amber fractal
#

put a \ before each one you dont want to be read by code

earnest phoenix
#

how

#

like ``example``

#

?

amber fractal
#

just put a backslash before each one you want to be read as a character

earnest phoenix
#

let me test

#

oh thanks

#

🙂

#

weird question but

#
const bot = new Discord.Client();
var prefix = ";";
const ms = require('parse-ms');
let date = new Date();



bot.on('message', async message => {
let mstime = date - message.member.joinedAt

if (message.content.startsWith(prefix + 'nuke')) {
let messageArray = message.content.split(" ");
let cmd = messageArray[0];
let args = messageArray.slice(1);    
if(message.author.bot) return;
console.log(ms(mstime))



if(ms(mstime).days < 2) {
message.channel.send({embed: {
color: 3447003,
description: `<@${message.author.id}>, this command may only be used by members who have been in this server for at least 2 days.`
}});
}
if(!args[0]){
message.channel.send({embed: {
color: 3447003,
description:`<@${message.author.id}>, you are incorrectly using this command.\n**Usage:** ;\`\`nuke <@user>\`\`\n**Example:** \`\`;nuke Ross#6821\`\``
}});
return;
}
}
    
  }
);
#

is there a way to code it so i've "been" in my server for 2 days?

harsh nova
#

if you want to add javascript higlighting to your code so it is easier to understand, do
```js
code
```

earnest phoenix
#

just hoping someone can answer my questio

#

what do you mean by that

#

i mean

#

can i make a line in the code

#

that auto sets my days in the server as 2

#

so i dont have to wait

#

well, yes and no

#

y

#

you can't modify your actual data

#

oh

#

you can fake it though, check if the id of the message author matches your id

#

if it does, just skip the check altogether

#

yea

#

how would i do that

#

if closure

#

message author's id == your id

#

how

#

i told you how

#

if (Closure

#

what

quartz kindle
#

if(id of the message author equals your id) { do something }

grave pilot
#

Anyone know any good sharding methods to replace discord.js's built in one?

quartz kindle
#

do something can be anything, from faking data, to entirely skipping checks

#

i made my own sharding method

#

its not hard to make your own

grave pilot
#

It takes TIME

west spoke
#

So?

grave pilot
#

Might look in to it tho

quartz kindle
#

you can use node-cluster

#

or simply launch child processes

grave pilot
#

Well that would work, how about autorespawning shards when going offline?

quartz kindle
#

use shard events and exit the process on error

#

make the master process respawn the process on exit

grave pilot
#

Why did I not think about that...

#

Thanks for saving my stupid ass

modern elm
#

lol

#

Tim is a good dude

grave pilot
#

Give this guy some special role

quartz kindle
#

lmao

#

i made a library which uses pm2 clusters for sharding lol

modern elm
#

how do you make a library owo

quartz kindle
#

the same way you split your code into files

#

use exports/module.exports

#

and put the file on github

modern elm
#

oh wow

topaz fjord
#

and then u publish to npm and hope for the best

grave pilot
#

Mind sending me the git?

#

Might try to use it

valid frigate
#

wait

#

you can use pm2 cluster mode for sharding?

topaz fjord
#

im really annoyed that android studio doesn't create the build.gradle file with up to date deps

quartz kindle
#

you can

valid frigate
#

:o

#

can you summarize how that would be done actually

#

never seen anyone do it

grave pilot
#

Tim, dm me the npm module of yours for pm2 sharding

valid frigate
#

same

quartz kindle
#

its not on npm, only on github

#

timotejroiko/djs-shenanigans

grave pilot
#

Thaanks

valid frigate
#

wheeze

topaz fjord
#

djs-shenanigans

valid frigate
#

im debating over whether to shard via pm2 or some other method now

topaz fjord
#

tim is definitely an expert on naming

quartz kindle
#

if you check the package you will know why i named it that way

#

lmao

topaz fjord
#

so its like commando + whatever you added + discord.js

quartz kindle
#
  • anti-caching
topaz fjord
#

i see

valid frigate
#

whats the difference between fetch() and get()

#

which one is the cached edition™

topaz fjord
#

get() afaik

valid frigate
#

so i assume your client doesnt use get()

quartz kindle
#

it uses both

earnest phoenix
#

fetch returns from cache if it is cached, otherwise it makes a request and puts it in cache iirc

topaz fjord
#

Thonk I thought get() was the default name for fetching items from cache

#

you learn something new everyday

quartz kindle
#

yes, get is from the cache only, fetch is from the cache with an api fallback

valid frigate
#

interesting

earnest phoenix
#

fetch is used mainly for when you have to get the user information

quartz kindle
#

i use get for checking if the cache exists tho

valid frigate
#

what is this ws option in the client options

quartz kindle
#

disable presence and typing events

topaz fjord
#

I usually do only fetch when item isn't in cache

valid frigate
#

nice

#

this looks like its meant to be fast tbh

quartz kindle
#

yes, that was the primary goal

#

to scale without worrying about ram/cpu

#

the rest is just stuff i usually use with my bots

valid frigate
#

interesting

#

im gonna do some tests using your client's options

#

oh yeah @quartz kindle should i be worried about the message cache lifetime being 1 day? or is there a reason behind that

quartz kindle
#

only commands are cached

valid frigate
#

ah ok

quartz kindle
#

messages containing commands and bot responses

valid frigate
#

right so

#

how do i only enable caching for commands and bot responses

#

i've been looking around and cant find a way to disable caching for other messages

earnest phoenix
#

hey so

#

im really bad at bot setup

#

and if anyone is willing to temp host a github bot

valid frigate
#

@quartz kindle mind helping me with this sorry for another ping lo

earnest phoenix
#

or help me start it

#

i would really greatly appreciate it

#

🤷

modern elm
#

so i know im gonna sound stupid for this

#

but

#

here goes

#

the way my cmd handler is set up is like so:
exports.help = async(bot, message, args){}

#

so what if i have a function

#

outside of the exports

#

but i want to reference bot

#

how would i do that?

quartz kindle
#

@valid frigate in the library or in general with code?

valid frigate
#

talking about djs specificall

#

just wanna know sorta

#

i have no idea how messages are cached so yeah mmulu

quartz kindle
#

disable the message event, use raw, check for prefix + command handler in the raw

modern elm
#

Tim you have big brain pls help?

valid frigate
#

raw has type any right

quartz kindle
#

if it passes all checks, i use messages.add()

#

there might be other ways as well

#

like using new Message()

valid frigate
#

ah

#

i assume messages.add() is part of guild

quartz kindle
#

part of channel

valid frigate
#

o

#

makes sense

#

ok thanks

modern elm
#

Tim pls :(

quartz kindle
#

@modern elm you need to pass bot to the function

#

function(bot)

modern elm
#

but it returns as undefined

quartz kindle
#

how did you try it?

modern elm
#

wait nvm i lied

#

the queue is wroting to my map

tight forum
knotty steeple
#

ok so

#

how do you use a .env file

#

is it not process.env.THING

#

because that aint working

modern elm
#

it is process.env.THING

#

cause that works

knotty steeple
#

helpful

#

doesnt work for me

earnest phoenix
#

hi

knotty steeple
#

oh you need a package

#

called dotenv

#

mmmm ok

quartz kindle
#

there is no difference from an env file and a config file

#

its just how the file is used

knotty steeple
#

+1 dependency

#

ill stay with my config.json yes mmLol

earnest phoenix
#

?zws

#

HM

#

-zws

#

fml

#

wiat

fallow quiver
#

How do you specify a user so even if they change their name the bot will know who they are? I want to test if a certain user sends a message

#

Would I just use their ID?

amber fractal
#

yes

#

ID cannot change

fallow quiver
#

So How would I say That

    message.delete(1000)
}
#

Is that correct or

#

Would I need to say

if (message.channel.id = <ID>) {
    message.delete(1000)
}
amber fractal
#

uh

#

the user id

#

message.channel.author Thonk

#

would work

fallow quiver
#

Ok

#

Thanks

valid frigate
#

am i understanding this correctly

#

if i listen for the message event on djs, the message is automatically cached before it gets passed to the callback?

quartz kindle
#

yes

valid frigate
#

how do i disable this from happening

#

tbh instead of listening to raw events im gonna try removing irrelevant messages from the cache insted

quartz kindle
#

you can disable message caching from the client options