#development
1 messages · Page 695 of 1
});
are you sure it wasnt a dm?
const guildConf = client.settings.ensure(message.guild.id, defaultSettings); is the bit throwing back the error though
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)
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)
the if statement should go above your code
UMM Is there a way to check if someone is invisible with a .net bot? ....
it is @idle basalt

literally right under client.on("message", message => {
that means something happens to make message.guild null before it gets to message.guild.id
just hastebin the whole file
Ok
@wooden lance that error is on line 217 now
https://pastebin.com/rMDhu3cj there are some issues in it, fixing it now. like some really stupid mistakes
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
ok
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
does it work now?
gonna launch it now
btw, https://hasteb.in is easier than pastebin
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)
testing in #265156322012561408 btw
console.log(message) above the line 107
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.
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
what code
the message event
ok
What is the limit of reactions a bot can make on a message @modern sable 
To counter any API abuse 
also now in your error it seems to happen on line 104 instead of 107
a message can have 20 different reactions @earnest phoenix
@idle basalt https://pastebin.com/BYML1eAU
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
wait im an idiot

no i lied im a double idiot
thats strange man idk what to tell you
the message you log literally above the error line has a guild in it
ye
sorry :(
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
@idle basalt without this bit, it's fine. https://pastebin.com/6rXvNvKy
@wooden lance have you tried moving ```js
const guildConf = client.settings.ensure(message.guild.id, defaultSettings);
```js
if(!message.guild || message.author.bot) return;
IT WORKS OMG THANK YOU @topaz fjord
ofc it does
you're using message.guild.id before you even check if the message is from a guild
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. ??
remove <>
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.
I swear I remember there being one, just forget the name...
One message removed from a suspended account.
One message removed from a suspended account.
if(!owner.includes(message.author.id)) return
😩
its to the previous if
im aware
if (whatever) action
else
works
but why
some people dont trust return idk
man, that formatting really hurts my brain
same
anyone get an answer to my question?
Nope?
whyd u respond then
Just code one yourself?
my question was a prebuilt frontend library
dont response to questions if you dont have an answer please
your*
Yea
its not that vague its kinda obvious what i asked for. a live chart built around a preexisting websocket
Yeah, If you couldn't find one by simply Googling. Just code one.
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
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
"
@slim heart you mean something like grafana?
I dont have a real example
or I might
doesnt it use prome?
prometheus
what does that do tho
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?
It was just a suggestion that I knew of that may have worked ¯_(ツ)_/¯
ill take a look tho ty
I know how to edit JSONs using Java, but is there a way to create and delete JSON files using the bot?
is the bot maker on steam actually reliable?
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
I don't really know anything at all. I've been using the dapper dino tutorials on youtube
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
pls dont watch tutorials to make discord bots
One message removed from a suspended account.
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
help yourself
One message removed from a suspended account.
One message removed from a suspended account.
oh my god I'm so confused
One message removed from a suspended account.
One message removed from a suspended account.
python has more bullshit you have to know about
One message removed from a suspended account.
One message removed from a suspended account.
I've looked and asked everywhere for WHERE to start and didn't get anything.
One message removed from a suspended account.
One message removed from a suspended account.
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
One message removed from a suspended account.
^
One message removed from a suspended account.
mkay
also docs are a good thing to read https://discord.js.org/#/docs/main/stable/general/welcome
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
it doesnt take years to learn dw
there is some code examples you can look at
it doesnt take years to learn a language it takes that time to master it
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
One message removed from a suspended account.
hey
One message removed from a suspended account.
a lot of people start on websites like codecademy
One message removed from a suspended account.
I don't have money for CA
its free 
One message removed from a suspended account.
One message removed from a suspended account.
WHAT?
One message removed from a suspended account.
One message removed from a suspended account.
It kept pushing me telling me it was like 10$ a month or something
idk if udemy has js tho
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
codeacedamy
codeacadamy
One message removed from a suspended account.
codecademy not codeacademy
One message removed from a suspended account.
its totally free but there is a pro version if you want more from it
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
How can i test my bot ?
One message removed from a suspended account.
there are a million ways to start, just get started
also dont get a linter
this is actually bad advice but pls dont get a linter if you dont want to be screamed at for ur code
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
what ever methods y'all have to share on how to get started I'm all open ears
we just gave you like 3
DV said they have something if I wanted it
- pick a lang (js is prob the easiest, esp since you want to make a discord bot)
- start learning/coding
hey i personally hate linters 
there are an infinite number of ways to get started, dont worry about it too much just start
https://discordjs.guide and https://codecademy.com are good places to start
make a command line
app
thing
to experiment with node.js
before u make a bot
a... what?
a little thing that runs in your terminal
a cli
a script that you can make so when you run it does certain things in your terminal
no not cli, command line app thing
I just started JS but Node is like a program that runs your script I pretty sure
clat
node.js is a runtime for js
^
node.js !== js
You should really get Visual Code Studio, I've been using that and it works great
or sublime text
That's a personal preference
i use neovim
vim 
vsc is 👌 tho
i like vsc but it takes all my ram because electron
so just coding in my terminal works
Can I use my bot to create and delete JSONs in the bot folder? Or can it only edit JSONs
with node you can use fs
your bot can do whatever you want bro
I have vsc
What would be the code for creating and deleting JSONs
google: delete a file node
Ok
shockingly, youll find the answer
its like unlink or something to delete
fs.appendFile('message.txt', 'data to append', (err) => {
if (err) throw err;
console.log('The "data to append" was appended to file!');
});
example
fs.unlinkSync('path/to/file')
How does one get the Bot Developer role?
It's automatic?
yep once it gets accepted
no
ye
that's all in #502193464054644737
synchronously is bad
Got it.
why?
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');
});
eh
So from my research I think its fs.writeFile("thing.json", dictstring);
i thought you wanted to delete the file
I need to create files to
why are you making json files anyway
^
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
do not do that
you probably want a database then
use a database
json is fine sometimes but its usually more hassle than its worth
I use json files to store emotes 
json files can be corrupted and if your bot is big json files are really bad
Its better than saving all server data in single json tbh
if you have to use json yes
at least it womt corrupt since one guild = one json
i think json only gets corrupted with concurrent reads/writes
yes
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
but thats honestly a lot of trouble just use a db
json isnt meant to store data like this
but still I would suggest a proper db even your json idea is not bad
sqlite is good for a small db
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
sqlite is good for 20k guilds even 50k
really?
just dont expect the same over 100k
I used sqlite until 50k
what did u switch to
Would a database work for what I want it to?
mariadb
yes
mmm mariadb
thats what you want
how did you move the data tho
wdym stormy, like how you can log in to the website?
o
mongo gang
pretty sure there should atleast be a way to transfer
from sqlite to mysql/mariadb
mariadb is mysql but its better
yes i know i use mariadb
so if you plan to use mysql, just use mariadb
oh so like when someone joins it asks them to type a code or something?
and if you get it back then let em in
you dont need db for that
¯_(ツ)_/¯
the other guy wants a db
I personally made one with roles only
hes doing scores
u dont need any db for it
no you dont need anything stormy
Yeah, for event management
permissions 0 is just the everyone role
no youll be fine
ok so ive asked this probably once already b u t .
Also, do I have to submit all the code of my bot while adding it?
how can i actually spawn shards in djs by using websockets
just put the info it asks you for
an id, library
description
etc
and submit
@valid frigate u can use sharding managers
smh
Alright. Haven't looked over the page yet so I was just wondering...
id guess it means i 1) learn more about websockets and 2) to be a cool kid like ravy
smh

copy
Wdym making your own
You want to use raw discord websockets or do you want to make a manager that works straight into djs
uhhh something that would work straight into djs
probably since the discord api is scary

I mean it’d be dumb to not use the djs manager for djs
Also, sharding managers don’t manage websockets
Well ya gotta find what
yeah
Like I just made Jaylon a completely raw websocket for discord
i mean websockets seem pretty cool
With absolutely no caching and events n stuff lmao
Well
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
interesting
There’s not much more you need to know unless u want the specifics of like websocket server creation
so the client keeps the connection open vs. request/response
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
there’s plenty of guides online to get you started there
Tanks
What was js to change the bot's own nickname?
Member.setNickname
Tyvm
How would I reference the server name using discord.js?
Thanks
I don't think that's it, I mean like
message.channel.send ("This Server Is: " <servername>)
in this case, message.guild.name
<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
Ok Thank you
I've been "coding" a while but I just I just started Java a few days ago
also use template literals for the servername
`string ${variable}`
```is equivalent to```js
'string' + variable```
to help better explain what fortis said
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
<client>.emojis.find(x => x.name == 'something').id
Ok
get used to using ===
I like == ¯_(ツ)_/¯
we dont want "true" === 1 to be a thing
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 check your language docs for generating randomness
ok 🙂
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 the border is defined at .columns .bot-img
honestly im gonna go remove that now too
css is not canceled anywhere
that border is defined here
you just need to replace it with a rule of equal or higher specificity
got it
.columns .bot-img {
box-shadow: none !important
}
damn, let me get it
oh... i think its the s....
oops
i mean is there supposed to be a s?
I defined it cmd.bot_has_permissions
@commands.command()
@commands.has_permissions(manage_channels=true)
exactly like that?
yes
I am checking if the BOT has permissions
so i did this
@cmd.bot_has_permissions(Manage_channels=true)
was there any errors
wait try
@cmd.self.bot_has_permissions(Manage_channels=true)
i dont need .self tho....
Its not defined as that
Let me make sure its works
i'll do another checl
İs true ?
if (!message.member.hasPermission('MANAGE_MESSAGES')) return message.channel.send('You don't have permissions to use this command!')
hasPermission
Yes
I think new versions of d.js do message.member.permissions.has() though
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");
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");
correct
message.guild.iconURL
Thats what I have
that's the wrong analogy
So this message.channel.send() is a method
and message.guild.iconURL is a property
Correct
I'm learning
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
events/message.js
Not working , what's wrong?
if (message.channel.type == 'dm') return message.channel.send("Commands are disabled in DM\"s")
no error :/
Please show more code
more code?
Yes, the code around it
yeah show the block of code which contains that statement, give more context
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 )
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
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
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?
Is this a more pleasant red color?
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
i suggest using https://material.io/resources/color for complimentary colors
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)?
Do you think this is easier to look at?
(The color is probably going to change when I get to that)
just the pink
hurts
yeah I know
Better color?
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
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
Does anyone know where i can find some good documentation or maybe a working tutorial on music commands?
in which language
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
when you addfield
you are giving it an empty value
you are only setting the title
nvm
cant see it well on mobile
It has nothing to do with the embed, that works
@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
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
message.member.joinedAt - date will always give you a negative number
because the current date is always bigger than a past date
thats fine
thats not my concern
im just trying to figure out why it respons to every message liket his
because you are checking if a negative number is smaller than 2
and the answer is always yes
what message?
the code says it should respond to "prefix+test"
it doesn't, they don't have an if closure
//correct
if(something) {
// do something
}
//you did
something; {
// do something
}```
if (!something) return nothing;
close
also, 'prefix + help' is not getting the actual prefix, its getting the literal text "prefix + help"
yes
if (message.content.startsWith(prefix + 'help')) { poop; }
also, dont put semicolons inside parentheses
i mean winky face but lol
oh so switch it
exactly
yeah
👍
👍
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
@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
I'll give it a shot
not a error
oh
just a refernece error
const ms = require('parse-ms');
Where did you place it because it might not be getting seen
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

?
const ms = require('ms'); should probably be at the top of the file
ok
thonk
what is it?
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
can you log ms(mstime).days?
sure
did "true" show up in your logs?
console.log(ms(mstime))
days is rounded
mstime is probably wrong
ohhhh
oh
days is rounded
@wheat jolt is the message cached?
the bot restarted
@earnest phoenix please dont try to help when you dont understand lol
so i don't think so
messageReactionAdd only reacts on cached messages, unless you enable partials
partials fire events containing incomplete data
raw events
for example, discord sends you all events, regardless or caching status, but the library does not fire them if there is missing data
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
Oh I didnt know master had an option
yeah, although i dont know how exactly it behaves, since i havent used it
i graduated to using the raw event for everything lmao
What is a good database to store users data which doesn't get suicidal
any proper database?
okay, what is easy to learn in your opinion
for small applications, sqlite is great, everything else is overkill imo
lmao
what if txt files with single characters in each file
I think that beats json anyway
that will kill your drive lmao
pff I downloaded 1M empty mp3 files
why
how big is your drive's cluster/sector size?
ah well, a vps is probably running on a vm, so the data is probably written in a virtual file
if it was in an actual disk, 1 million empty files would take 500mb+ on 512byte sectors and 64gb+ at 64k sectors
lmao
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
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
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
then make it "
than i cant use <@${message.author.id}> in it
to ping the person
because it only works in ` function
?
it's a lot easier if you show the code you need help with
escape it
how
put a \ before each one you dont want to be read by code
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?
if you want to add javascript higlighting to your code so it is easier to understand, do
```js
code
```
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
if(id of the message author equals your id) { do something }
Anyone know any good sharding methods to replace discord.js's built in one?
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
It takes TIME
So?
Might look in to it tho
Well that would work, how about autorespawning shards when going offline?
use shard events and exit the process on error
make the master process respawn the process on exit
Give this guy some special role
how do you make a library owo
the same way you split your code into files
use exports/module.exports
and put the file on github
oh wow
and then u publish to npm and hope for the best
im really annoyed that android studio doesn't create the build.gradle file with up to date deps
you can
Tim, dm me the npm module of yours for pm2 sharding
same
Thaanks
wheeze
djs-shenanigans
im debating over whether to shard via pm2 or some other method now
tim is definitely an expert on naming
so its like commando + whatever you added + discord.js
- anti-caching
i see
get() afaik
so i assume your client doesnt use get()
it uses both
fetch returns from cache if it is cached, otherwise it makes a request and puts it in cache iirc
I thought get() was the default name for fetching items from cache
you learn something new everyday
yes, get is from the cache only, fetch is from the cache with an api fallback
interesting
fetch is used mainly for when you have to get the user information
i use get for checking if the cache exists tho
what is this ws option in the client options
disable presence and typing events
I usually do only fetch when item isn't in cache
yes, that was the primary goal
to scale without worrying about ram/cpu
the rest is just stuff i usually use with my bots
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
only commands are cached
ah ok
messages containing commands and bot responses
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
hey so
im really bad at bot setup
and if anyone is willing to temp host a github bot
@quartz kindle mind helping me with this sorry for another ping lo
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?
@valid frigate in the library or in general with code?
talking about djs specificall
just wanna know sorta
i have no idea how messages are cached so yeah 
disable the message event, use raw, check for prefix + command handler in the raw
Tim you have big brain pls help?
raw has type any right
if it passes all checks, i use messages.add()
there might be other ways as well
like using new Message()
part of channel
Tim pls :(
but it returns as undefined
how did you try it?

ok so
how do you use a .env file
is it not process.env.THING
because that aint working
hi
there is no difference from an env file and a config file
its just how the file is used
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?
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)
}
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?
yes
how do i disable this from happening
tbh instead of listening to raw events im gonna try removing irrelevant messages from the cache insted
you can disable message caching from the client options
