#development
1 messages ยท Page 1178 of 1
ty not erwin i shall use this
Anyone know a source where I can find code to set the bots "Playing" text?
I'm not asking for direct code, just a source.
The status?
yes
@exotic cradle what lib

discord.js...?
read this
oh ok
fucker had it on paste beforehand
thanks
wtf @misty sigil lol
true that, man of culture
wow
User: Asks how to set activity
Leuca: Sends that link
btw can i use free heroku hosting forever or do i have to switch if my bot gets big enough?
ok
because heroku will literally die if you host a 100+ server bot on it 
Uh-
// Set the client user's activity
client.user.setActivity('discord.js', { type: 'WATCHING' })
.then(presence => console.log(Activity set to ${presence.activities[0].name}))
.catch(console.error);
that was the code I used
wrap it in code blocks oh gosh
client isnt defined then
client.user is not defined until the "ready" event
oh
aH YES
How do I know how many guilds my bot is in?
<Client>.guilds.cache.size
@dreamy thistle <client>.guilds.cache.size
: o ty
CTRL+F for your everyday questions
Would this work?
client.user.setStatus('dnd', 'Made by KwinkyWolf')
or in my case
client.user.setStatus('online', 'Made by De'Toxanoche')
escape that quote
make sure you only modify the status after the ready event is called
ok thats what i thought
is it in client.on(ready, () => {})
no
well it needs to be


if()
if()
if()
if()
bad
also thats message event
unrelated to what was suggested
you want ready event
@exotic cradle https://discordjs.guide/command-handling/
highly recommend doing a command handler already
breh

highly recommend reading the guide already
It says bot is not defined tho
then define it
when i try bot.on

learn JS
I can star this to get it to #starboard
@delicate shore lol
if i want to
star
imagine coding a bot without knowing your own programming language
I did it
...
imagine coding erwin
Imagine Imagining
image.png
lol got starred anyways
what a useless star
anyway @paper cliff JS is javascript, the language you coding with
bru
learn JS
@opal plank thats like saying: learn to fly a plane
you trying to write a russian essay without knowing russian
ok
imagine imagining
Stay on channel topic please.
HEYHEYHEYHEY
somewhere in siberia russia a long long time ago
he was big and strog and his eyes were flamey glow
@exotic cradle And by the way, may be you named it client instead of bot
you can name your variables whatever you want tbh, as long as you use them accordingly its fine
it can be TheBestBotInTheWorld = new Client()
most people loook at him, with terror and the fear
but to moscow chicks he was a such a lovely dear
@delicate shore @exotic cradle Star any random messages or abuse starring and you will be muted.
module.exports = async function format(content, guildName, botId) {
let newContent = await content.split("{user}").join(`<@!${botId}>`).split("{user_name}").join("Bot Cool").split("{server}").join(guildName);
return newContent;
}
why it return nothing
(node:7188) UnhandledPromiseRejectionWarning: DiscordAPIError: Cannot send an empty message
Show us where you try to sending a message with the result of that function
in a Channel
also you don't need to await content.split because it doesn't return a promise
:0
instead of split/join did you mean to use replace lmao
why u awaiting it?
To some? Probably. To everyone? Probably not.

:(
help meeeee
dafuck you even doing dude
why do you need to await string manipulation
You don't
geniuses think alike
@opal plank i removed
bro
relax
i am not dumb
use .replace?
@paper cliff USED
export rather than module.exports
dont await manipulation
replace
async function
module.exports is fine. And yes obviously it doesn't need to be an async function anymore
you exporting a named function, should be using an export statement, otherwise if you only going to have 1 function, use an unnamed function statement
if its only one, no need to name it. if its named, it implies you'll have multiple functions
which is best to use export es6
and if the resulting message is empty, that probably means the input is empty
k
module.exports = (test) => {console.log(test)}
function a() {
return 'a';
}
function b() {
return 'b';
}
export a , b
import a , b from 'something'
how to get channel object by id in node?
No @opal plank wtf? Using exports is perfectly fine
dealing with exporting named stuff is better with export rather than modules
@paper cliff https://stackoverflow.com/questions/40294870/module-exports-vs-export-default-in-node-js-and-es6
const a = () => "a"
const b = () => "b"
modul.exports = { a, b }```
what you're doing is simply objectifying those functions
not exporting them
works too? yeah
also aliases
forgot to mention that
Using both module.exports and export are fine imo. You aren't losing much from using the standard module.exports
indeed both work, never said it wouldnt, its just better to use exports when dealing with named stuff
So, I used the on collect event for reaction collector, and run the command in two different server, and it messing up the result.
hastebin is not working in opera gx, so sent you the .txt
.
-dotpost
(reaction, user) => Object.values(reactionControls).includes(reaction.emoji.name),
{ time: time, dispose: true }
);
collector.on('collect', (reaction) => {
switch (reaction.emoji.name) {
case reactionControls.UP:
thumbsUp = reaction.count-1;
case reactionControls.DN:
thumbsDwn = reaction.count-1;
break;
}
})```
what's wrong here?
What's not working about it?
it doesn't count the correct reaction
i have an error installing lubuntu:
Command 'mount' return ed non-zero exit status 32.i don't know if this is about developement but i think this is a bug in the os
@cinder sandal e still unanswered

@earnest phoenix did you use eval(code)?
on the output?
/eval message.guild.roles.cache.get("545490362568015873")
on the output
wdym ?
Did you copy an actual role id
what am I doing wrong? It doesn't count the results
const collector = msg.createReactionCollector(
(reaction, user) => Object.values(reactionControls).includes(reaction.emoji.name),
{ time: time, dispose: true }
);
collector.on('collect', (reaction) => {
switch (reaction.emoji.name) {
case reactionControls.UP:
thumbsUp = reaction.count-1;
case reactionControls.DN:
thumbsDwn = reaction.count-1;
break;
}
})```
what happens? Do thumbsUp and thumbsDwn stay at 0?
Oh yes... lol that was on problem
now another
if I request the same commands twice at the same time, I get same result on both messages
Can bots check ip adress
no
no
@steel pelican that must be a game server?
Na a chat server
Sinedx, can you elaborate?
did you use any of their websites?
or, is the vpn's ip banned from that discord?
๐ค
iirc, discord does ip bans(users cant see it)
Sinedx, can you elaborate?
@cinder patio I used the code for a poll command.
If I use one /poll, it's working fine.
but if I do/poll aand/poll bat the same time, then the results are getting messed up
is there a way to prevent this from rounding to the nearest month?
moment(member.joinedAt, "YYYYMMDD").fromNow()
Sinedx, this shouldn't happen if all the code regarding the poll command is inside the function. If for example, you have some variables outside of the function that are used and changed in the poll function, things are gonna get messed up, yeah
I'm assuming everything is inside the command function?
where do you define thumbsUp and thumbsDwn? They might get turned into global variables after the first use
do let thumbsUp, thumbsDwn; at the beginning of the function that should solve the problem
Not sure if that's the issue, though
But it's best to define them before you use them
@glad charm kid trying to spam ads
Not sure if that's the issue, though
@cinder patio Yep, that was the issue
Thanks
I thought if I don't define them, it will say "thumbsUp is undefined"
but then it worked
and I was like ok
let's go
Sometimes javascript can be weird
true
I used awaitMessageReaction() earlier
but it didn't give me accurate reaction count
like if they spam the reaction button, it doesn't count them at all
I really don't know why that happens. I believe when you assign a variable name a value without any keywords it makes it global. It errors only when you access a variable that's not defined. It doesn't error when you assign it a value
ig u'r right
I did a big dumb today
I accidently deleted all my bots files
and the recovery software can't get it
I accidently deleted all my bots files
@teal fiber rip, next time use a source control manager like git-scm and upload the repo somewhere
version control you mean
It means the same thing really. Git calls itself git-scm. TFS refers to itself as Team Foundation Version Control (TFVC)
Semantics, I suppose @earnest phoenix
it was a dumb mistake because i needed to reinstall the OS on the laptop i was hosting it on
Yeah, bit rip. Upload repo to GitHub or azure devops or something next time
I want to run my bot in kubernetes (preferably easy to scale), can anyone link me resources that could help me (e.g. configuration files for the pods etc)
Are you familiar with kubernetes or docker?
docker yes, but kubernetes not really. I'm just interested if there is public information for this or if I have to start from zero
What does that mean?
Error: Cannot find module 'discord.js'
Require stack:
- C:\Users\User\Desktop\Giveaway Bot\server.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> (C:\Users\User\Desktop\Giveaway Bot\server.js:1:17)
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',
My code: https://srcb.in/9e53b41fd3
Seems like you didnt installed d.js before
I did! I typed npm install save --discord.js
oop, im late
Check if there is a discord.js folder inside the node-modules folder, or check your package.json file to confirm it's installed.
And then this is shown:
Error: Cannot find module 'moment-duration-format'
Require stack:
- C:\Users\User\Desktop\Giveaway Bot\server.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> (C:\Users\User\Desktop\Giveaway Bot\server.js:8:9)
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: [ 'C:\Users\User\Desktop\Giveaway Bot\server.js' ]
}
You haven't installed that either
just like you installed discord.js,
npm i moduleName
Replace moduleName with the package you are missing
No one noticed how npm install save --discord.js (the command they claimed to run) is completely wrong?
lol
Hi :D I think this is a pretty common error, but I can't install quick.db I tried running vs code as admin but still an error
any errors?
Error: Cannot find module 'quick.db'
Require stack:
- C:\Users\User\Desktop\Giveaway Bot\server.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> (C:\Users\User\Desktop\Giveaway Bot\server.js:14:10)
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: [ 'C:\Users\User\Desktop\Giveaway Bot\server.js' ]
@cinder patio
you should get that error when you require it, not when you install it
Hi :D I think this is a pretty common error, but I can't install
quick.dbI tried running vs code as admin but still an error
@gray zealot run powershell as admin and paste this:npm install --global windows-build-tools --vs2015
then install quick.db
no
what did you put in your terminal
npm i quick.db
did you install the build tools first?
yes
in an admin powershell
yes
do you still have the terminal open
yes
show me whats in the terminal
sorry, powershell or vs code
@earnest phoenix https://srcb.in/a287ed9d4c
@earnest phoenix https://srcb.in/a287ed9d4c
@earnest phoenix you dont have any storage space left lol
off
sorry, powershell or vs code
@gray zealot pretty sure you should use powershell
or command prompt
you cant run vscode terminal as admin i dont think
๐ ok
Now I have 23,5 GB but still @earnest phoenix
dude your error is literally just 300 lines of this:
npm WARN tar ENOSPC: no space left on device, write @earnest phoenix
I have installed node-gyp
@gray zealot try going to the bots files, right click and open powershell there
then try installing from powershell
hmm
try going to the quick.db server, they have a guide thing on how to install it
ye
@earnest phoenix now I have 57,2 I restarted visual but still
check the #quick.db pinned messages
then try reinstalling it
Wdym pinned messages?
what
Wdym?
i was talking to him
oh
ok
but what can I do?
Hello, why can a bot use 300 MB of memory?
when it has 32 servers
is it in this server?
Guys what is this server for
if so this server has 100k users, which is HUGE, if you want it to go down, you can ask a mod to kick it
Guys what is this server for
@ripe fulcrum, its for https://top.gg
Thanks
if so this server has 100k users, which is HUGE, if you want it to go down, you can ask a mod to kick it
and because of this he consumes so much?
yes
id say maybe it'll go down 100 megs, if you want your ram to go down, you can also use d.js light, which doesn't cache as much.
^ my method
ok
hey guys
i am running into a problem
i recently started my bot on my vps
and i am sure i have the good bot key in the config file
but for some reason it starts the bot from the former config file.
is the config file pushed to the VPs
you can host on a VPS
darnit 
font is not installed on canvas. what should i do
const { registerFont ,createCanvas, loadImage } = require('canvas')
registerFont(`${process.cwd()}/assets/fonts/neuville-bold.otf`, { family: 'Neuville' })
is the config file pushed to the VPs
@misty sigil yup
how can i get mongodb ping ?
let time1 = Date.now()
await db.findOne
let time2 = Date.now()
time2 - time1
ty
could someone tell me why my vps is running the file on a different bot
eventhough the bot token is right?
is there a guide on how to get discord voice channel ids?
I don't need it. I want to put it in one of my commands
What library are you using?
discord.js
And do you want to get a specific voice channel's ID, or some range.
An ID is a unique number which is used to identify a user, bot, channel, or message. To obtain an ID, right click on it and click "Copy ID"; this can be done from mobile by holding down.
Should you not see the option to acquire an ID, you need to enable "Developer Mode" which can be done from your user settings, under "appearance".
big brain
Could use this as a template or just link them to the Discord article
alright thanks
is there a way to check if a specified timer is too short? im using discordjs with the ms library and my current code for it isnt working, the bot just ignores it
What is time defined as?
args[0]
if time is ms(time) then it'll be in ms
You simply need to check the milliseconds to see if it's less than whatever required
package express { "error": "Missing required X-Access-Token header." } How do I fix this
can u help me?
how can you reduce your bot's RAM usage?
?
bot eats up a lot of memory)
๐ค
no it's just about the error i got
๐
what language do you use?
?
discord.js
try discord.js light
๐ค
what
there like v11 or I'm wrong?
just help me to resolve the error bruh
thats for you @open flicker
there like v11 or I'm wrong?
then can u help me?
not 100% sure thereโs v11 light
yea thats what I mean
sry it was missing some code
change const track to let track
just that?
is DJS light used by DJS v12?
yes
๐ค
Light is a third-party library.
Light is v12 I believe so
ok
light is v12 yes
also, if you're looking to save memory or any resources at all, consider using intents (https://discordjs.guide/popular-topics/intents.html#enabling-intents)
ok
does anyone use the mongodb driver for node
need help to update all fields with their own val but diff
each field (ie. price is a string, "9") but i need to update them all to number ie. 9
so like if price is "8" in one and "9" in another you want to change the type for each to be a number?
@topaz fjord yeah as they all got inserted as strings
hi can someone help me I try to copy the id from the channel but it not working
case 'quota-add':
if (!msg.content.startsWith(Prefix))return
let db = new sqlite.Database('./Patrols.db', sqlite.OPEN_READWRITE);
var PatrolTime = args.slice(1).join(" ")
if (!PatrolTime){
return msg.channel.send("How many minutes did you patrol for?")
}let Time = args[1]; let user = msg.author.tag let query = `SELECT * FROM data WHERE user = ?`; db.get(query, [user], (err, row) => { if (err) { console.log(err); return; } if (row === undefined) { let insertdata = db.prepare(`INSERT INTO data VALUES(?,?)`); insertdata.run(Time, user); insertdata.finalize(); console.log("done"); db.close(); msg.channel.send(`Successfully logged your patrol of ${args[1]} minutes!`) return; } else { let Time = row.PatrolTime + Math.floor(args[1]);; db.run(`UPDATE data SET PatrolTime = ?`, [Time]); msg.channel.send(`Successfully logged your patrol of ${args[1]} minutes! \n \n You now have a total of ${Time} minutes, epic`) console.log(Time) console.log(db) }
Ok so im making a bot that saves a number someone said into sqlite, how would I make it so it doesn't overwrite everyone else's numbers?
WHERE clause
UPDATE example_table SET example_column = 'example_value' WHERE another_column = 'must match this string'
@sick cloud https://stackoverflow.com/a/17068379
best to do it via the mongodb command line
np
the table is not a variable
Ohhh
It's like a spreadsheet (kinda)
Stoopid question but its 3AM for me so fuck it:
How do i get all args but not args[0] in JS
So would this work?
db.run(UPDATE data SET example_column = ? WHERE another_column = ?, [Time, user]);
get args instead of args[0]? lol
i get ars[0] too
the [index] is the item in the array you want
I need all args but not args[0]
try it and see
https://littlescreens.tk/suwU7/leyITOyE96.png this says trim is not a function
is args an array
yes
must be a string
Arrays don't have a .trim() function
you can't trim array
You're probably looking to call it on a string
AAAAAAAAAAAAAAAAAAAAA pain
javascript
is pain
Arrays are pretty common in every language
list 
i think js makes array manipulation pretty easy
python
AAAAAAAAAAAAAAAAAAAAA pain
@sterile minnow you probably want a for loop so you can handle each item in the array seperately
nvm got it myself
a for loop would let you go over each item like args[i] where each "loop" makes i + 1
can i make this less ugly
hey someone know where to rent cheap vps to make the bot online 24/7 ?
How about the configuration
wdym configuration
check pins ๐
do you mean the vps
uhhh
do you mean windows
vpses usually come with ubuntu or a distro of linux
not windows
iirc for $5/month DO gives you 1gb of ram, 1 vCore and 5 or 10gb storage, but you'd need to go to their site or pins maybe for details
yo where THE FUCK are the novelcovid docs
google is my enemy
nothing comes up but the npm page which doesnt have any docs on it
literally first result
send the repo then
wait
both belong to the same api
what is this
the point of a command handler is to prevent the need for a million if statements
I just added the command handler
I was gonna move them after I finished the eco system
well yeah, since you're still using if statements
I thought that eliminated the need
it does, once you remove all the if statements
So unless the if statements are gone, it won't work?
that's what you should do
what i'm saying is that you have a command handler; however, you still have if statements for each command as if you don't have one
a solution would be to add another if statement for the bal command, which is ridiculous, so
"true" solution is to remove every if statement to use the command handler properly
I'll do that rn
client.commands.get(command).execute
i open and close a db in every command which makes the response real slow..
can i make a global connection and use it in the entire program?
You can have a class where there is a connection object
And then you could pass around that instance as a service
Sounds like what you want is a inversion of control container or register a service dependency @earnest phoenix
Depends on the lib and db you use really.
A db server where you make the call over a network is pretty fast
ohh
Not really sure what you mean by open and close. Typically a DB server/service is in memory and calling it's API is meant to be as fast as possible
Connection pool.
wow
idk why im getting this error
https://codeine.is-inside.me/F6WIhZtN.png
https://codeine.is-inside.me/QvGrBZTN.png
even tho the same thing works when i do
console.log(`${client.user.username} is now up and running...`);```
but i cant really use client.on in that
what exactly are you trying to do?
trying to make help page with author = bot name
how are you doing your embed?
last option is to just put the bot name as static
Can I see your embed code?
color: '#3de956',
title: '[+] help',
author: {
name: `${client.user.username}`,
icon_url: 'https://i.imgur.com/S1qiKEA.jpg',
},
description: '',
timestamp: new Date(),
};
message.channel.send({ embed: helpEmbed });```
im yet to put stuff just stuck here
what language?
js
I mean
try generating embeds like this https://discordjs.guide/popular-topics/embeds.html
what is this
@sonic lodge ohhh shhiiiiittttt
thats what im doing
i prefer this object one over the native
looks cleaner to me
oh alright
Ok so Im trying to send a Embed but when it trys to send it gives me this
error: (node:41200) UnhandledPromiseRejectionWarning: TypeError: fields.flat is not a function
what language
js
Ok so Im trying to send a Embed but when it trys to send it gives me this
error: (node:41200) UnhandledPromiseRejectionWarning: TypeError: fields.flat is not a function
code?
@spare gale what did you ping me for
for this
what is the shhhiiiitttt?
@spare gale this font breaks my eyes
oh my jesus christ
@opal halo u'r missing a ";" in 2nd last line
you didn't have to ping me for it
@spare gale this font breaks my eyes
this code breaks me
Oh
@opal halo at least your code font is normal
ur missing it on the last line to
in js ';' not probably
that doesn't do anything though
well its the syntax idk if it fixes the problem ur getting or not
but syntax is still important
ยฏ_(ใ)_/ยฏ
@opal halo can I see the full error
hmm
(node:31096) UnhandledPromiseRejectionWarning: TypeError: fields.flat is not a function
at Function.normalizeFields (C:\Users\Lane\Desktop\DiscordBot3\node_modules\discord.js\src\structures\MessageEmbed.js:450:8)
at MessageEmbed.setup (C:\Users\Lane\Desktop\DiscordBot3\node_modules\discord.js\src\structures\MessageEmbed.js:78:91)
at new MessageEmbed (C:\Users\Lane\Desktop\DiscordBot3\node_modules\discord.js\src\structures\MessageEmbed.js:18:10)
at embedLikes.map.e (C:\Users\Lane\Desktop\DiscordBot3\node_modules\discord.js\src\structures\APIMessage.js:166:40)
at Array.map (<anonymous>)
at APIMessage.resolveData (C:\Users\Lane\Desktop\DiscordBot3\node_modules\discord.js\src\structures\APIMessage.js:166:31)
at TextChannel.send (C:\Users\Lane\Desktop\DiscordBot3\node_modules\discord.js\src\structures\interfaces\TextBasedChannel.js:166:62)
at Client.Bot.on.msg (C:\Users\Lane\Desktop\DiscordBot3\index3.js:78:25)
at Client.emit (events.js:198:13)
at MessageCreateAction.handle (C:\Users\Lane\Desktop\DiscordBot3\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
(node:31096) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:31096) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Lol
index3.js line 78 collum 25
yep
let me see whats there
my bot is sometimes go offline, hosted in vps with node.js with pm2, no errors, just going offline (650k users and 226 servers) how can i fix that?
@earnest phoenix
internet problems?
74 80
full screen pls
78 line not full
put your cursor on colum 25
windows/linux?
Ok
hosting on windows is just awful
Im on column 25
there are like 7 more bots
and they are online
hm
take a screenshot of the stuff around it
7 bots in 7 scripts?
Cant see the whole thing https://prnt.sc/u4b50u
i know its dumb to host 8 bots in 1 vps but idk why my bot that have 226 servers go offline
when im doing pm2 logs i dont see any errors
when restarting it is going back online
@torn ravine Any ideas?
hmmm, try to attach logger with logging discord connection
ok
Are you sure there is no error
@wary flame what do you mean
i see all logs and errors in one (pm2 logs helpful)
i just dont see one that making him going offline
Nvm then
@opal halo
@spare gale
add this to msg.send:
.catch(e => console.log(`Error: ${e}`)
i see only warnings :/
try switching the " to '
msg.channel.send(QuotaEmbed).catch(e=>console.log(`Error: ${e}`))
doing
client.on("disconnent", () => {
require("child_process").exec("pm2 restart helpful")
})
will work?
:'D
https://tryitands.ee @earnest phoenix
lol
XD
i believe its why this error..
its not in my code though
i saw this error many times
it's in discord.js code, upgrade node
https://github.com/discordjs/discord.js/issues/3913
first google url, np
:D
Oh
v14 is
Latest NODEJS version
not asking you to go to discord.js v12 even though I highly recommend it
14.8
he's already on v12, hence the error
node.js 8.0.1 is LATEST, PRETTY GOOD and, amm... and end. :'D
I got
just download the current one and it will ask you to upgrade
v14
you almost made me download it again lol
xD
im controool uuu
xD
ow, need more coffee
guys, how to create dynamic-loading plugins to bot? :/
wym?
a command handler
add plugin and send command? no :((((
aaaerrvrervew
come on, viruses, ill ready for fight
*died *
use firewall, antiviruses is shit
only in live cd it works good
i can add NOT, NOT and NOT stable bot to this server? xD
in pre pre pre pre closed beta xD
see when file is added to directory and add that file to cmd handler
@earnest phoenix So I updated the files, what do I do now?
https://stackoverflow.com/questions/13695046/watch-a-folder-for-changes-using-node-js-and-print-file-paths-when-they-are-cha @spare gale
WOOOOW
thx, i cant find it :////
thx, really
Eris or discord.js?
am, english?
discord.js
@earnest phoenix So I updated the files, what do I do now?
@opal halo
Any advantages of using Eris?
@opal halo just restart your bot ?
Oh ok
what is 'Eris' :/
npm package
o.0
throw err;
^
Error: Cannot find module 'discord.js'
at Function.Module._resolveFilename (module.js:548:15)
at Function.Module._load (module.js:475:25)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/app/shard.js:1:91)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)```
How to fix this error , i have even install discord.js in it , still it is showing me the same error
node js, node packet manager, ph
hii
const api = require('novelcovid');
const Discord = require('discord.js')
const client = new Discord.Client()
const db = require('quick.db')
const Canvas = require('canvas')
module.exports = {
name: "test",
description: "Checks a weather forecast",
async execute(message, args) {
const canvas = Canvas.createCanvas(700, 250);
const ctx = canvas.getContext('2d');
// Since the image takes time to load, you should await it
const background = await Canvas.loadImage('https://www.w3schools.com/w3css/img_lights.jpg');
// This uses the canvas dimensions to stretch the image onto the entire canvas
ctx.drawImage(background, 0, 0, canvas.width, canvas.height);
// Use helpful Attachment class structure to process the file for you
// Select the color of the stroke
ctx.strokeStyle = '#74037b';
// Draw a rectangle with the dimensions of the entire canvas
ctx.strokeRect(0, 0, canvas.width, canvas.height);
// Select the font size and type from one of the natively available fonts
ctx.font = '60px sans-serif';
// Select the style that will be used to fill the text in
ctx.fillStyle = '#ffffff';
// Actually fill the text with a solid color
ctx.fillText(message.author.username, canvas.width / 2.5, canvas.height / 1.8);
// Pick up the pen
ctx.beginPath();
// Start the arc to form a circle
ctx.arc(125, 125, 100, 0, Math.PI * 2, true);
// Put the pen down
ctx.closePath();
// Clip off the region you drew on
ctx.clip();
const avatar = await Canvas.loadImage(message.author.displayAvatarURL({ format: 'jpg' }));
// Draw a shape onto the main canvas
ctx.drawImage(avatar, 25, 25, 200, 200);
const attachment = new Discord.MessageAttachment(canvas.toBuffer(), 'welcome-image.png');
message.channel.send(`yo!`, attachment);
}
}
this is my code
but
throw err; ^ Error: Cannot find module 'discord.js' at Function.Module._resolveFilename (module.js:548:15) at Function.Module._load (module.js:475:25) at Module.require (module.js:597:17) at require (internal/module.js:11:18) at Object.<anonymous> (/app/shard.js:1:91) at Module._compile (module.js:653:30) at Object.Module._extensions..js (module.js:664:10) at Module.load (module.js:566:32) at tryModuleLoad (module.js:506:12) at Function.Module._load (module.js:498:3)``` How to fix this error , i have even install discord.js in it , still it is showing me the same error
show me your require discord.js, pls
lol
are you trying to use a different font?
wat
wdym different
ctx.font = '60px sans-serif';
this is the font
i dont understand what you mean by different
username in eng or styled text?
are you trying to use a font besides the default ones
kk
but do i specify a font or leave it
cuz i have no idea what the default font is
btw i removed it and tried
it gave the same result
it's system default
ctx.font = '60px';
console.log(message.author.username) normal text?
ok let me see
fetch or get the channel
why sometimes when restarting a process in pm2 the process starting twice ? (restarted a bot and the bot is responding twice)
Hm
is it inside the same guild?
Yes
why sometimes when restarting a process in pm2 the process starting twice ? (restarted a bot and the bot is responding twice)
bot self-coping ?
or what?
no
use guild#channels#[#cache]#find
use #get() instead of #find() if you already have the channel id
i will send a picture
kk
its just doing everything twice after restarting
if i will do pm2 kill && pm2 resurrect it will work just fine
it just i dont want to do this ..
in your disconnect action add self-kill
my grafana-server is active but I can't access that
https://i.imgur.com/WeYSu4I.png
https://i.imgur.com/TDmZcko.png
yea i did
yep
but why after doing "pm2 restart helpful" its started twice
your bot dont died, script still working, but u start new, if bot disconnected from discord. bot will reconnect, and on 1 bot worked many scripts
How would I make it so my bot posts in a certain channel?
@opal halo But in discord.js
hi i am back
Promise { <pending> }
YOO boi im active lol LMAOOO
Bot is ready with username: TradeBot alpha 0.5
Fontconfig error: Cannot load default config file
Multi
hi
this is my exact
stuff
in the console
it says fontconfig error
but i just installed fontconfig
ow...
delete ctx.font setting :/
lol ok
e.g. js guild.channels.cache.get("ID"); guild.channels.cache.find(channel => channel.name === "general");
problem in font, but what :///////
im still getting the same errorrrrrrr
Oh alright
im still getting the same errorrrrrrr
your system have fonts?
ofc lol
ok i havent activated windows so that might have something to do with it
also im using repl.it
i don't think repl.it has system fonts
register one
using Canvas.registerFont(path, { family: "Font Name" });
srry if i bad help, i dont seen this problem later :'D
ok see
@pale vessel
i did the thing
which you told me to do
but since repl isnt like on my pc
i dont think it can access anything on it
cuz
im getting this error
UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, lstat '/home/runner/Trade-Bot/C:UserssfudallyDownloadsabel.zipabel-regular.ttf'
Ok so I did this:
let channel = Bot.channels.fetch("746975182169571338");
channel.send(${user} just completed their quota :beautiful:);
Says send is not a function
@pale vessel
What do I do for cache?
@umbral pollen xD
don't put cache, you're fetching it
would cache not work?
tell him (@umbral pollen) - he dude xD
wat
no i'm playing osu
lol
you can't fetch something from cache
btw thx my thing works now
it's either await client.channels.fetch() or client.channels.cache.get()/find()
yes
show code
if (Time < 300){
let channel = await Bot.channels.fetch("746975182169571338");
channel.send(${user} just completed their quota :beautiful:);
}
more
if (row === undefined) {
let insertdata = db.prepare(INSERT INTO data VALUES(?,?));
insertdata.run(Time, user);
insertdata.finalize();
console.log("done");
db.close();
msg.channel.send(Successfully logged your patrol of ${args[1]} minutes!)
return;
} else {
let Time = row.PatrolTime + Math.floor(args[1]);;
db.run(UPDATE data SET PatrolTime = ? WHERE user = ?, [Time, user]);
msg.channel.send(Successfully logged your patrol of ${args[1]} minutes! \n \nYou now have a total of ${Time} minutes, epic)
if (Time < 300){
let channel = await Bot.channels.fetch("746975182169571338");
channel.send(${user} just completed their quota :beautiful:);
}
console.log(Time, user)
}
You want all the code?
not all
oh
ok heres the whole command
case 'quota-add':
if (!msg.content.startsWith(Prefix))return
let db = new sqlite.Database('./Patrols.db', sqlite.OPEN_READWRITE);
var PatrolTime = args.slice(1).join(" ")
if (!PatrolTime){
return msg.channel.send("How many minutes did you patrol for?")
}
let Time = args[1];
let user = msg.author.tag
if (Time > 999){
return msg.channel.send("lmao, you expect me to believe that you patrolled for that long? smh.")
}
let query = `SELECT * FROM data WHERE user = ?`;
db.get(query, [user], (err, row) => {
if (err) {
console.log(err);
return;
}
if (row === undefined) {
let insertdata = db.prepare(`INSERT INTO data VALUES(?,?)`);
insertdata.run(Time, user);
insertdata.finalize();
console.log("done");
db.close();
msg.channel.send(`Successfully logged your patrol of ${args[1]} minutes!`)
return;
} else {
let Time = row.PatrolTime + Math.floor(args[1]);;
db.run(`UPDATE data SET PatrolTime = ? WHERE user = ?`, [Time, user]);
msg.channel.send(`Successfully logged your patrol of ${args[1]} minutes! \n \nYou now have a total of ${Time} minutes, epic`)
if (Time < 300){
let channel = await Bot.channels.fetch("746975182169571338");
channel.send(`${user} just completed their quota :beautiful:`);
}
console.log(Time, user)
row is doing stuff with the data base though
that's a callback, it runs that function after it's done. you have to make the function async in order to use await
Oh ok
Ok so
Like this?
let channel = async (err, row) => {await Bot.channels.fetch("746975182169571338")} ;
yes
show code again, sorry
case 'quota-add':
if (!msg.content.startsWith(Prefix))return
let db = new sqlite.Database('./Patrols.db', sqlite.OPEN_READWRITE);
var PatrolTime = args.slice(1).join(" ")
if (!PatrolTime){
return msg.channel.send("How many minutes did you patrol for?")
}
let Time = args[1];
let user = msg.author.tag
if (Time > 999){
return msg.channel.send("lmao, you expect me to believe that you patrolled for that long? smh.")
}
let query = SELECT * FROM data WHERE user = ?;
db.get(query, [user], (err, row) => {
if (err) {
console.log(err);
return;
}
if (row === undefined) {
let insertdata = db.prepare(INSERT INTO data VALUES(?,?));
insertdata.run(Time, user);
insertdata.finalize();
console.log("done");
db.close();
msg.channel.send(Successfully logged your patrol of ${args[1]} minutes!)
return;
} else {
let Time = row.PatrolTime + Math.floor(args[1]);;
db.run(UPDATE data SET PatrolTime = ? WHERE user = ?, [Time, user]);
msg.channel.send(Successfully logged your patrol of ${args[1]} minutes! \n \nYou now have a total of ${Time} minutes, epic)
if (Time < 300){
let channel = await Bot.channels.fetch("746975182169571338");
channel.send(${user} just completed their quota :beautiful:);
}
console.log(Time, user)
whole command ^
thonk
lol
Bot is your client right?
Mhm
this would be easier to look at in a box
@opal halo you copied this straight from your code right?
Mhm
it's `
^
i don't see the markdown
`hi`
ik
nani
hm.
hm
guys, which editor u use?
notepad++
@opal halo that's the correct channel id right?
yes
yes
lol :DD
what's so funny about it smh
it just works
i don't need some advanced ide and debuggers
@opal halo https://discordapp.com/channels/264445053596991498/272764566411149314/746986557256499212 this is weird
did you literally put console.log(channel);?
Yes
but for code ill use Atom
woah not there
wait what
what
๐


alright thank
