#development
1 messages ยท Page 912 of 1
@earnest phoenix from what i understood, your database is giving you the timestamp as a string, not as a unix number. the problem is not whether the date is correct or not, the problem is that youre not using the value correctly
you cannot do math functions with a value like "2020-05-06", its not a number, its text
pls store it as an epoch
before you can compare it with things such as Date.now(), you need to properly convert it into a unix number
how would i go about that then
look guys i know im dumb but im learning and i accept that
moment maybe if not native js
i told you how: new Date(yourdatabasevalue).getTime()
oh js
where would i put that
i mean, look at your code and it should be obvious?
bUt i Didn'T cOdE iT
flaze stfu
sorry that was bit too much
you are hella annoying
well if u cant tell from ur own code its the time bumped
also flaze thats supposed to be my job
it's my part time job now
each shard that I add increases my ram usage by about 1%. That should be normal right?
Well I mean it opens a new websocket connection for each shard, which has its own buffer
how big is a buffer
Depends on the implementation
For example in my gateway it uses a shared buffer, which increases every time it's necessary
@earnest phoenix
Because some packets can be quite large
@wide ridge each shard spawned by the sharding manager in fork mode will create a new process, which is a new instance of node.js
an instance of node.js contains the entire V8 engine, which by itself uses about 50mb of ram alltogether
so each shard = approx 50mb, before adding discord.js

you can try running shards in worker mode
worker threads are now stable as of node.js v12
I have a lot of CPU that isn't used by my bot (it's always < 7%), is there anything I can do to utilize it better?
tbh, i'd rather be underutilizing cpu than over.
the extra reactions are not necessary
lmao
the extra reactions are not necessary
@knotty steeple have a strawberry my friend
haha isnt that so fucking funny
one reaction per person guys cmon ๐
now you've done it lol
LOL
must think ur a comedy genius
when development becomes offtopic
abal needs to fix this eris bug
where it keeps on disconnecting and reconnecting every two hours or something
abal needs to make better collections
its not a bug
or just asking you to reconnect
does reconnecting reset the uptime
no
no
if you lib doesn't make it a fatal error
you mean its resetting client.uptime?
yes
lmao
i sound dumb
well if for some reason he links websocket statuses to client.uptime, then yeah
interesting
well it's not like it affects my bot in any way
it's just reconnecting
so it's fine ig
let me check
reconnecting triggers the ready event right?
or the shardReady event since ready is for all shards
Hi guyssss
whats ur problem
wrong channel to say that
that's not development related
@pale vessel you could always use process.uptime() instead
i'll do that instead
what kind of music do you guys listen to to help focus whilst doing the coding things?
preferably music i enjoy
lofi
discord.js v11.5.1 vs v12 ?
things i like distract me
i actually would prefer not to listen to anything
v12 if u dont want to rewrite when u update eventually
more often than not whenever i listen to music when programming i go on a worldwide tour
Normally its good to listen to music without any lyrics
so you can focus more on your coding
Because Audio makes you get distracted
as in text
lyrics
etc
Make it a background noise
so its not blasting into your ears
ah yes, development
I was reading a survey thing that suggested (according tot he programmers they surveyed) that electronic musics were the most common genre's that people listen to ๐
it was some kinda annual developer report survey thing.
electronic
lmao
why do u think people say lofi is to study and shit
i find electronic more distracting
tbh the best thing anyone can study to is mozart ~ as lame as that is. its been proven time and again to help increase brain activities somehow
not all classical music ~ only mozart.

anyone know why this errors
const { channel } = message.member.voice;
(node:9952) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'voice' of undefined
member is undefined
could i define it with message.member?
discord.js v11.5.1 vs v12 ?
@lost kettle one of the two will die in a few months, and take all the bots that use it together
I'll let you guess which one
F
tim guess what
I am using v12 now
the same as before im just not understanding it like my brain isnt understanding
do you know what a string is?
discord.js
im getting the timestamp as a string
and?
},
bump: (msg) => {
con.query(`SELECT * FROM settings WHERE guildid = ${msg.guild.id}`, (err, result) => {
if (err) return console.log(err)
let cooldown = (60 * 60 * 1000)
if (result[0].premium === 1) {
cooldown = cooldown / 2
}
const now = Date.now()
const lastTimeBumped = result[0].last_time_bumped ? result[0].last_time_bumped : 0
if (now - lastTimeBumped > cooldown) {
con.query('SELECT * FROM settings', (err, row) => {
if (err) return console.log(err)
msg.guild.fetchInvites().then(invites => {
if (row.length - 1 <= 0) {
sendEmbed(msg, 'There are no other guilds for your advertisement to go, `p%invite` and setup the bot on other guilds before trying again.')
return
}
if (invites.size > 0) {
const invite = invites.first()
bumpLogic(msg, row, invite)
} else {
let channelID
const channels = msg.guild.channels.cache
for (const c of channels) {
const channelType = c[1].type
if (channelType === 'text') {
channelID = c[0]
break
}
}
const channel = channels.get(msg.guild.systemChannelID || channelID)
channel.createInvite().then(invite => {
bumpLogic(msg, row, invite)
sendEmbed(msg, `Bumped sucessfully to **${row.length - 1}** Servers.`)
})
}
})
})
con.query(`UPDATE settings SET last_time_bumped = NOW() WHERE guildid = ${msg.guild.id}`, (err) => {
if (err) console.log(err)
})
} else {
sendEmbed(msg, 'You must wait **** before you can use this command again.')
}
})
},```
so basically when they do p%bump it bumps there server add but it tells the database when they did it so they have to wait 1 hour before they can do it again
you are doing now - lastTimeBumped
do console.log(now) and console.log(lastTimeBumped)
and you'll see what im talking about
and you'll see the difference
1588809354760
2020-05-06T21:06:03.000Z
or console.log(typeof now) and console.log(typeof lastTimeBumped) if you are still confused
okay so from here where do i go
you need to convert lastTimeBumped into a proper unix timestamp, as a number
^
instead of Date.now() i do new Date().getTime()
no
oh without the new sorry
you dont change now, you change lastBumpTime
now is already a number, its fine as it is
you have to convert your timestamp from your database using new Date().getTime(), then you can compare it to the the Date.now().
you basically have this ```js
now = 1588809354760
lastBumpTime = "2020-05-06T21:06:03.000Z"
so you need to change lastBumpTime into a proper number
oh okay so to basically get that i use that one you said above there?
yes
i put it there and ran it now it says i must wait
show what you did to see if you did it right
const now = Date.now() console.log(now) const lastTimeBumped = new Date().getTime()
i think thats what you meant
no
you need the date from the database
and convert it into a timestamp
new Date(dateFromDB)
and then you use getTime()
then you can compare it against Date.now()
currently you're getting the current timestamp
which is the same as Date.now()
if you do new Date().getTime() without any argument, the result is exactly the same as Date.now() (the current date)
you have to use new Date().getTime() with the date you get from your database, like this: new Date(date_from_database).getTime()
Part of my code:
if (thing[loopnum].startsWith("thing ") || thing[loopnum] == "thing") {
So, if thing[loopnum] is thing <has argument>, it passes the if statement. If thing[loopnum] is thing (no arguments), it doesn't pass the if statement.
it should pass the statement, make sure the case is correct and there are no extra spaces somewhere
^ that's what im checking rn
if you want it to be case-insensitive, you can do thing[loopnum].trim().toLowerCase() === "thing"
.trim() removes any leading or trailing spaces and space-like characters (like new lines)
I honestly feel like i need to use .toString()
yeah if its not guaranteed to be a string, use .toString() as well
but you're combining those two even though one of them shouldn't pass the statement. am i understanding this wrong?
yes there is a redundancy here
if you remove the space from startsWith, it will work for both
^ it works but then you can do something like thingwueifbhweui which i dont want to allow
you can also use args
if you split on spaces and create an array of words, then thats not a problem
this is what most people do
im annoying you two i think which i dont want lol
you said i was annoying lol
actually when i tested with .toString() or .trim() i accidently added a space...
to thing
lets see which one it is
.trim() fixed it. Thanks.
do i put new Date(dateFromDB) literally
yes
then what run the bot or no
the date that you console.log earlier
dateFromDB has to be the value you get from your database
for example, in the code you showed before, it was rows[0].last_time_bumped
it shouldn't be that
if i remember correctly
wait that's from the db?
yes
then you don't need to convert it to a timestamp lol
is that in seconds though
im not sure ngl
i dont know sql to much little to nothing
but when i log console.log(lastTimeBumped) its different
when what was that from?
so if i do the bump feature now ill tell you what it says
what is lastTimeBumped?
i see it never mind
const lastTimeBumped = new Date(1588810719744)
@earnest phoenix is it this?
yes
as you can see those are actual numbers
you don't need to convert it to timestamp as it's already one
2020-05-07T00:29:10.800Z
yes thats what im not figuring or understanding
which one is coming from the database? the numbers or the date above?
then you need to use new Date(dateFromDB).getTime()
becuase went i turn the bot on it generates the correct numbers
where dateFromDB is the date you got from the db
now do i restart the bot
show the code first
} const now = Date.now() console.log(now) const lastTimeBumped = new Date(1588811344685).getTime() console.log(lastTimeBumped) if (now - lastTimeBumped > cooldown) {
like that?
btw javascript will round that number
every time i restart the bot i get new numbers obvs
oh nvm it's not as large as I thought it was
those aren't the date you gave me
2020-05-07T00:29:10.800Z
@earnest phoenix
it's supposed to be like this
yes
so what happened?
but its will change after every bump
no, you fetch it from the database
2020-05-07T00:29:10.800Z
@earnest phoenix how did you get this
where did you log it?
look in the code
and use that inside new Date(here).getTime()
const lastTimeBumped = new Date(dateFromDB).getTime()
console.log(lastTimeBumped)
if (now - lastTimeBumped > cooldown) {
dont mind the datefromdb
i didnt change it just yet
change your code to what it's supposed to be and send it
which line do i change thats what im saying or just do it for me
that way we arent going round in circles
Hey guys, what hosting service do you guys use for your bots? Considering I just wanna host one bot
can you send us your current code, the whole file
},
bump: (msg) => {
con.query(`SELECT * FROM settings WHERE guildid = ${msg.guild.id}`, (err, result) => {
if (err) return console.log(err)
let cooldown = (60 * 60 * 1000)
if (result[0].premium === 1) {
cooldown = cooldown / 2
}
const now = Date.now()
console.log(now)
const lastTimeBumped = new Date(dateFromDB).getTime()
console.log(lastTimeBumped)
if (now - lastTimeBumped > cooldown) {
con.query('SELECT * FROM settings', (err, row) => {
if (err) return console.log(err)
msg.guild.fetchInvites().then(invites => {
if (row.length - 1 <= 0) {
sendEmbed(msg, 'There are no other guilds for your advertisement to go, `p%invite` and setup the bot on other guilds before trying again.')
return
}
if (invites.size > 0) {
const invite = invites.first()
bumpLogic(msg, row, invite)
} else {
let channelID
const channels = msg.guild.channels.cache
for (const c of channels) {
const channelType = c[1].type
if (channelType === 'text') {
channelID = c[0]
break
}
}
const channel = channels.get(msg.guild.systemChannelID || channelID)
channel.createInvite().then(invite => {
bumpLogic(msg, row, invite)
sendEmbed(msg, `Bumped sucessfully to **${row.length - 1}** Servers.`)
})
}
})
})
con.query(`UPDATE settings SET last_time_bumped = NOW() WHERE guildid = ${msg.guild.id}`, (err) => {
if (err) console.log(err)
})
} else {
sendEmbed(msg, 'You must wait **** before you can use this command again.')
}
})```
you didn't define dateFromDB
no, like do you store the dates inside the database?
yes when someone does p%bump it logs the time and then once an hour passes it will let you do p%bump again
under results yeah?
i dont have that
it's undefined?
i just dont have that at all
all right, just console.log(results[0])
where fo you want that to go after what line or can i just it anywhere
oh I'm sorry
it's result
try the first thing i said
so it is
result[0].last_time_bumped
@pale vessel
so log it after that line
remove the console.log obviously lol
i said define so something like let dateFromDB = result[0].last_time_bumped
i literally just spoonfed you
is date from db the 1588812623213
it's the one you sent from phpmyadmin
https://gyazo.com/a4a4e65988506dabae3cca55754165af
@earnest phoenix
we're converting that to a timestamp so that we can compare it with Date.now() you get me
let 2020-05-07 00:29:05 = result[0].last_time_bumped
dude no
wtf
i even gave you the code
let ANYVARIABLENAMEYOUWANT = result[0].last_time_bumped
oh my goodness my brain
not that though
Tim help
you said its the one from the picture like hello
nah im out of this one
oh please
lmao
well Steven
i did say do it for me to get me out your hair
it's all yours
but he couldn't utilize it
take the piss out of me thats okay
sorry but it had to be done
lmao i can't
becuase this clearly isnt working
my brains to small
can anyone tell me why voice.channel is undefined
i would recommend learning some basic programming, you're running around in circles because you're trying to do something blindly and through guessing
well can you tell me then instead of taking the piss?
then i can learn for net time
nxt
next
because you were being too demanding misunderstood
we can't
im saying please can you
it's one of the rules
i asked nicely before i said if you dont mind id be grateful
okay so i done it but it dont give me any details lol
tbh lol i didnt think you meant just copy paste it in hhahaahha
right so i copied it in and started up the bot
I know this is a bot server, but hear me out could someone help me with collision detection? its just squares
if(x > self.x and x < self.x): return True
if(y > self.y and y < self.y): return True```
I tried this and it doesn't seem to work
oh wait
I might've done the signs wrong
one second
nah nvm
no idea how to do collision detection
what kind of collision is it? a line against a dot? or a shape against a dot?
or a shape against another shape?
or a ball/circle against another ball/circle?
Ball is the easiest
its to detect a cursor on a square
Tried this too
if(self.x < x + 1 and self.x + size > x and self.y < y + 1 and self.y + size > y): return True```
x and y are cursor coords and self.x and self.y are the coords of the square
size is how big the square is width and height
so if x > self.x and x < self.x+size and y > self.y and y < self.x+size
is this py? js's canvas has an isPointInPath function, maybe py's drawing libs have something similar
its python
pygame
this doesn't seem to work either
if(x > self.x and x < self.x + size and y > self.y and y < self.y+size): return True```
self.x and self.y are the upper left corner coordinates right?
heres how im looping through the "blocks" ```py
Mouse_x, Mouse_y = pygame.mouse.get_pos()
for block in renderedblocks:
block.draw(screen)
if(block.isSelected(Mouse_x, Mouse_y)):
print("Collision Detected!")``` and yes
when my cursor is anywhere on the screen it says "Detected.."
https://prnt.sc/scadyz
Oh I got it to work, It seems I have a "playerxoffset" etc
to move
so the map moves around the player
ah
Im not sure how to implement that though, Just add it to self.x and self.y
Im guessing
yeah
if the value of the offset increases, you need to decrease it from self
np :3
if(x > (self.x + playerxoffset) and x < (self.x + playerxoffset) + size and y > (self.y + playeryoffset) and y < (self.y+size + playeryoffset)): return True```
gj
does anyone know why voice.channel returns undefined? here's the code for reference
are they in a voice channel
why wouldn't they lmao
questionsโข๏ธ
i do be in a voice channel, if I wasn't It would return the "you are not in a voice channel message"
think I found a bit of a workaround. my only question is how can I add commandFile.run(client, message, args, config, queue) to ```try {
command.execute(message, args);
} catch (error) {
console.error(error);
console.log('There was an error executing a command in a guild, please keep an eye on logs');
if (typeof execute !== 'undefined') {}
}
})
replace the execute with the run?
Hey guys, what hosting service do you guys use for your bots? Considering I just wanna host one bot
I've looked at Vult VPS and AWS.. Wouldn't that be overkill for one bot?
if
x = [Map] {
'177188299943837696' => 1588815502000,
'487641086462918656' => 1588815777000
}```
How can I do
```js
x.foreach(u => {
msg.channel.send(u)
})```
And have it print `177188299943837696`?
@hidden canopy I usee heroku
its free
upload all your files to a private github page, set the worker up in a procfile and activate the dyno
if you want me to teach you how we can discuss in the dms
Iโm hosting with Heroku too @earnest phoenix but how do you use a database since everything resets when you restart or push?
I use a built in dyno plugin for mlab mongodb @heavy anchor
Ok cool thx
@heavy anchor if you have a paid db you can use something like keyv to store data like prefixes etc...
I donโt have any db yet Iโm just trying to figure out my opinions
@heavy anchor mlab has a free sandbox
good for hosting custom prefixes or whatnot
Oh really? Iโll check it out. Thx for the info
Is your bot in the server. It is.
how would I use two try statement, the second one asks for a "finally" statement
wait might've fixed it
message.guild
.createChannel("molly", "text")```
it says message.guild.createChannel is not a function
What version of Discord.js are you using?
12.1.1
Check out <Guild>.channels.create (https://discord.js.org/#/docs/main/stable/class/GuildChannelManager?scrollTo=create)
how could i get how many users are in the servers my bot is in
The "id" argument must be of type string. Received undefined first time getting this error. I find it strange. Here's the code response = await message.channel.awaitMessages(msg => 0 < msg.content && msg.content < videos.length + 1 && msg.author.id == message.author.id, {
having a feeling I should change msg to message
i can i get the total amount of channels my bot is in?
@earnest phoenix are you sure it's coming from that area.
at validateString (internal/validators.js:117:11)
at Module.require (internal/modules/cjs/loader.js:1035:3)
at require (internal/modules/cjs/helpers.js:77:18)
at Client.<anonymous> (C:\Users\jjpla\OneDrive\Documents\GitHub\disc-bot-rep\bot.js:58:31)
at Client.emit (events.js:310:20)
at MessageCreateAction.handle (C:\Users\jjpla\OneDrive\Documents\GitHub\disc-bot-rep\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (C:\Users\jjpla\OneDrive\Documents\GitHub\disc-bot-rep\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (C:\Users\jjpla\OneDrive\Documents\GitHub\disc-bot-rep\node_modules\discord.js\src\client\websocket\WebSocketManager.js:386:31)
at WebSocketShard.onPacket (C:\Users\jjpla\OneDrive\Documents\GitHub\disc-bot-rep\node_modules\discord.js\src\client\websocket\WebSocketShard.js:436:22)
at WebSocketShard.onMessage (C:\Users\jjpla\OneDrive\Documents\GitHub\disc-bot-rep\node_modules\discord.js\src\client\websocket\WebSocketShard.js:293:10)```
found it was actually pointing somwhere else
let commandFile = require(commands[command])
console.log((commands[command]))?

is it possible to get all the channels my bot is in
dicsord.js v11: client.channels
dicsord.js v12: client.channels.cache
if you want the count yea
how could i get the same thing but for users
replace 'channels' with 'users'..
it's a matter of following links in the docs to your destination
ERROR: connection refused 127.0.0.1.3000
i get this error when i try run my music bot
show your code
it looks like you added the port to the ip
im trying to determine if you did it manually if so replace the last full stop with a colon :
well im, trying to figure out how to open a port
const express = require("express");
const app = express();
const listener = app.listen(process.env.PORT, function() {
console.log("Your app is listening on port " + listener.address().port);
});```
what os?
windows
so would i just open it and replace js { "id": "default", "host": "localhost", "port": 46329,
the port with that port
i thought it was try catch ?
When ever i try to play a song with my music bot is says you must be in a voice channel but gives no error
@queen needle
try {
//this will run first
} catch (err) {
// if the code in the try block fails this runs
} finally {
// this code ALWAYS runs
}
ohh
There's isn't a catch block in the image they sent
you don't have to catch but you must link try with either a catch or a finally
yeah
Can someone tell me what's wrong with this? No error code```js
client.on('guildMemberAdd', async member => {
var user = await client.users.fetch(member.id)
var avtr = user.avatarURL()
if (!user.avatarURL()) {
var avtr = "https://discordapp.com/assets/322c936a8c8be1b803cd94861bdfa868.png"
}
var channelw = await client.channels.cache.get("700948323393077313")
const loopfinity = client.emojis.cache.get("701676280793399377");
const embedc = new Discord.MessageEmbed()
.setDescription(${loopfinity} + " | " + **${user.username}** + " has joined " + ${member.guild.name}!\n**User ID:** ${member.id}\n**Guild ID:** ${member.guild.id})
.setColor([84, 64, 205])
.setFooter(${user.username} joined ${member.guild.name})
.setTimestamp()
channelw.send(embedc).catch(err => console.log(err))
if (member.guild.id === "700948321904099370") {
var avtr = user.avatarURL()
if (!user.avatarURL()) {
var avtr = "https://discordapp.com/assets/322c936a8c8be1b803cd94861bdfa868.png"
}
const loopfinity = client.emojis.cache.get("701676280793399377");
const embedh = new Discord.MessageEmbed()
.setDescription(${loopfinity} + " | " + **${user.username}** + " has joined the server!")
.setColor([84, 64, 205])
.setFooter(${user.username} joined the server, ${avtr})
.setTimestamp()
member.guild.channels.cache.get('700948323393077310').send(embedh).catch(err => console.log(err))
}
});
wHaT's tHe ErRoR
No Error
also debug your code
Just doesn't show
ok so, what should happen and what does actually happen
It should send the embed, but it didn't, no error
I'm not gonna read it without knowing what I'm looking for
ok reading this on mobile is a pain in the ass
Is it possible to upload a file to is-inside.me subdomains using Node.JS?
The second part of the code works, this one doesn't.```js
client.on('guildMemberAdd', async member => {
var user = await client.users.fetch(member.id)
var avtr = user.avatarURL()
if (!user.avatarURL()) {
var avtr = "https://discordapp.com/assets/322c936a8c8be1b803cd94861bdfa868.png"
}
var channelw = await client.channels.cache.get("700948323393077313")
const loopfinity = client.emojis.cache.get("701676280793399377");
const embedc = new Discord.MessageEmbed()
.setDescription(${loopfinity} + " | " + **${user.username}** + " has joined " + ${member.guild.name}!\n**User ID:** ${member.id}\n**Guild ID:** ${member.guild.id})
.setColor([84, 64, 205])
.setFooter(${user.username} joined ${member.guild.name})
.setTimestamp()
channelw.send(embedc).catch(err => console.log(err))
})
@copper cradle
Evaling this doesn't work either ```js
async function s() {
var member = "683577627948351512"
var user = await client.users.fetch(member.id)
var avtr = user.avatarURL()
if (!user.avatarURL()) {
var avtr = "https://discordapp.com/assets/322c936a8c8be1b803cd94861bdfa868.png"
}
var channelw = await client.channels.cache.get("700948323393077313")
const loopfinity = client.emojis.cache.get("701676280793399377");
const embedc = new Discord.MessageEmbed()
.setDescription(${loopfinity} + " | " + **${user.username}** + " has joined " + ${member.guild.name}!\n**User ID:** ${member.id}\n**Guild ID:** ${member.guild.id})
.setColor([84, 64, 205])
.setFooter(${user.username} joined ${member.guild.name})
.setTimestamp()
channelw.send(embedc).catch(err => console.log(err))
}
s()
K thanks
var member = "683577627948351512"
var user = await client.users.fetch(member.id)```
A string does not have the property id
is it possible to get the messageid of a embed you create with a command to store it? want to use it to edit the embed with an event
Yeah just send the message
Then <Message>.id like any message.
Store it somewhere (like an object) then edit it in the event (if you have access to it)
you can store it with making a map object
that the easiest way to store it
client.customMap = new Map()
How do I upload a PNG to is-inside.me subdomains using node-fetch?
or should I use another library?
I recommend using axios
ok but how
@exotic lotus #topgg-api
No one replying in #topgg-api :/
@earnest phoenix you can take a look at the sharex config for either one of your subdomains at is-inside.me
sharex uses post requests and stuff too
so it has header options and stuff
and yeah then just send an axios request with the details
like headers etc
the problem im having is putting the PNG file into the body
it says invalid syntax "PNG" when i am using require
ok i'll try
var formData = new FormData();
then you can use append I think to add an object
and a file
should work
also in the headers it should be multipart/form-data
for Content-Type
ok thanks
i need to study what a formdata is first ๐คฃ
i got this when i tried to make a new form data
[06:00:52] Cluster 0 | Unhandled rejection at: Promise [object Promise] reason: ReferenceError: FormData is not defined
at Client.<anonymous> (/app/server.js:641:22)
at processTicksAndRejections (internal/process/task_queues.js:88:5)
k nvm i fixed it by installing the form-data module
formdata is like
for example on websites when you register with an email and password and you submit
thats part of a form
I wanna know how I would use another try statement if the first doesn't work
you can use many as you want
I want my command handler to run this
but this
is this
what library is dat
discord.js
@sudden geyser already tryed this but i get an empty response
any idea why updating to V12 creates this error HTTPError [AbortError]: The user aborted a request. On V11 it works fine. Other bots i created from the scratch on V12 dont get this error
restart your bot
this happens when the bot starts (every time)
when i start a other bot i dont get the issue
i guess its my internet connection but the other bots i made on V12 dont disconnect
Is it possible to set an image to an embed without an URL? I am using Eris and eris-additions. I know there's one in discord.js but I don't know how to port it to Eris.
you mean an attachment?
attach a file and then reference it via attachment://filename.extension as the url
@earnest phoenix how do i attach it?
you mean an attachment?
@pale vessel yes
second argument of createMessage
Eris, a NodeJS Discord library
Just out of curiosity, are there any discord libraries for c# will full api coverage?
I assume there must be?
yes, several
im not sure what the best but theres discord.net, dsharpplus or whatever its called, disqord, and prolly more
Wow thank you
โซ
@earnest phoenix execute
Is there any music module you can recommend for VDS? 
lavalink I don't know how to use
Made and maintained by one of the staff at discord lol
@modest maple unironically volt hadn't made a proper contribution in over a year and d.net is one of the trashiest libs out there right now lol
volt gave the repo to fox
it is rather ironic indeed
maybe it represents the state of discord's code rn
lmao
const DBL = require('dblapi.js');
const dbl = new DBL(TOKENU TAU DBL, { webhookPort: 5000, webhookAuth: 'password' });
dbl.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on('vote', vote => {
console.log(`User with ID ${vote.user} just voted!`);
});```
where must I insert my bot id?
idk how this owrks
i wanted to make a invite with bot
message.channel.createInvite({maxAge:max_age, maxUses:max_uses})
let max_age = args.slice(0);
if(!max_age) return max_age = 0;
but max_age is not working
output :
max_age: Value "[]" is not int.
pls help
console.log(max_age)
And you should see the issue.
ok
See the issue?
arrayName[0] to get the first in the array
No.
?
For example;
let maxAge = max_age[0]
Since you don't define args[0] like args[0] = max_age
smart xD
Working?
typing
Using d.js v12?
what version discord.js are you using?
@frail ocean IT WORKKK
Anyone uses sql?
and you need to define the channel too
"discord.js": "^12.2.0",
var channel =
client.on("message", async (message) => {
if(message.content !== "sh!invite") return;
let generateinvite = `https://discord.com/oauth2/authorize?client_id=${client.user.id}&scope=bot&permissions=392192`
message.author.send(generateinvite)
})```
why is my bot sending it multiple times?
then put the client.channel.fetch after that
Also you're using "bot" and "client", which one is it defined as?
^ good point
@earnest phoenix Multiple instances running?
wdym?
bot and client
Are you running the code multiple times?
no
@earnest phoenix does it send this multiple with this command only?
yes
var channel = client.channels.cache.get("ID")
commands work fine but events are doing it all multiple times
i have no idea why
yes
Else, I'd console.log at different points, see where it's running multiple times then we can zoom in on there
how can i console log its process thjo
@high geode What's the top line of the error? Well where it actually says it
tho
console.log("Here - 1")
for example
var channel = client.channels.cache.get("707183850828070962")const bot = new Discord.Client({disableEveryone: true});
^^^^^
SyntaxError: Unexpected token const
at Module._compile (internal/modules/cjs/loader.js:703:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:770:10)
at Module.load (internal/modules/cjs/loader.js:628:32)
at Function.Module._load (internal/modules/cjs/loader.js:555:12)
at Function.Module.runMain (internal/modules/cjs/loader.js:826:10)
at internal/main/run_main_module.js:17:11
if(message.content !== "sh!invite") return;
console.log("Hi")
let generateinvite = `https://discord.com/oauth2/authorize?client_id=${client.user.id}&scope=bot&permissions=392192`
message.author.send(generateinvite)
})```
In your code for examplwe
@high geode The const bot should be on a new line
bot.guilds.get("699189120945094757").channels.get("707183850828070962").send(${vote.user} voted voxility)
^
TypeError: bot.guilds.get is not a function
at DBLWebhook.<anonymous> (/app/server.js:14:14)
at DBLWebhook.emit (events.js:196:13)
at IncomingMessage.<anonymous> (/rbd/pnpm-volume/48f2957c-6991-4823-afce-9c4b8ef0edc3/node_modules/.registry.npmjs.org/dblapi.js/2.4.0/node_modules/dblapi.js/src/webhook.js:83:16)
at IncomingMessage.emit (events.js:201:15)
at endReadableNT (_stream_readable.js:1130:12)
at processTicksAndRejections (internal/process/task_queues.js:83:17)
again
var channel = client.channels.cache.get("707183850828070962")
const bot = new Discord.Client({disableEveryone: true});```
bot.guilds.cache.get......```
You need the "cache"
In v12.
Error?
bot.guilds.get("699189120945094757").channels.get("707183850828070962").send(${vote.user} voted voxility)
^
TypeError: bot.guilds.get is not a function
wth
just paste that?
No
bot.guilds.cache.get("699189120945094757").channels.get("707183850828070962").send(`${vote.user} voted voxility`)
or example when someone vote my bot, it auto dm me :
bot.users
.get("545490362568015873")
.send(``${vote.user.username} voted your bot``);
bot.guilds.cache.get("699189120945094757").channels.get("707183850828070962").send(${vote.user} voted voxility)
^
TypeError: Cannot read property 'channels' of undefined
but i have this
var channel = client.channels.cache.get("707183850828070962")
const bot = new Discord.Client({disableEveryone: true});```
what the hell
Is the IDs correct?
hey thereal
@earnest phoenix ?? What do you need help with? ๐
@earnest phoenix Where about's was the log?
client.on("message", async (message) => {
if(message.content !== "sh!invite") return;
let generateinvite = `https://discord.com/oauth2/authorize?client_id=${client.user.id}&scope=bot&permissions=392192`
console.log("a")
message.author.send(generateinvite)
})```
/app/server.js:14
bot.guilds.cache.get("699189120945094757").channels.get("707890056551202926").send(${vote.user} voted voxility)
^
TypeError: Cannot read property 'channels' of undefined
here
the error
why is it sending it multiple times?
Console.,log
message.author.tag
me?
And confirm it's your tag, and no one is running that command except you.
/app/server.js:14
bot.guilds.cache.get("699189120945094757").channels.get("707890056551202926").send(${vote.user} voted voxility)
^
TypeError: Cannot read property 'channels' of undefined
@high geode
Is the first id the one of your guild aka server?
Alright, so your message event is being fired multiple times.
but why is that
@high geode
Is the first id the one of your guild aka server?
@frail ocean ofc
Honestly, not so sure. Not encountered it before and typically it's due to multiple instances running. If I was you, I'd save the file and create a new one, gradually adding code to where it duplicates then you got your issue. Someone else might know exactly how to help however.
ahm how i can make when some one vote my bot it send me his name, cuz ${vote.user} it send me id. And ${vote.user.username} it said undefiened
Is the 2nd ID a correct channel id?
yes
console.log(bot.channels.cache.get("ID"))```
Just confirm it gets the correct channel and the ID is correct?
Lel wrong id
@earnest phoenix In D.JS:
let user = client.users.cache.get("ID")
let name = user.tag``` That'll be like `TheReal#1781`
ok
Try with client, you should only have bot or client for ease of purpose, but worth trying ๐คท
lemme test with this server
server id
264445053596991498
channel id
265156322012561408
Unless your bot is in this server, it probably won't work.
wait
i test with dbl server
bot.guilds.cache.get("264445053596991498
^^^^^^^^^^^^^^^^^^^
SyntaxError: Invalid or unexpected token
at Module._compile (internal/modules/cjs/loader.js:703:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:770:10
bot.channels.cache.get("ID") Same as guilds and users can only get those that the bot is in.
are in this server
cuz i am using v11
@earnest phoenix just remove .cache
@high geode use the server that your bot is in, if it isn't in one, make a test server and use that, since it should only read the channels etc that the bot is in for that method.
Is your bot in this server?
What are you trying to achieve by putting it in the ready event?
Like what is the end goal of this?
when someone votes
the bot
seend a messsage
on a channel
really voted me
just that
To the person who voted or as a log type thing for you (the developer)?
to me
in a channel
i wanna see
who votes
user voted voxility
in a log channel
So just for you?
yes
i just wanna see
who votes
like this one
for servers and who adds the bot
but for votes
Use the same code to get the channel from that event?
how i can make bot send link like in html :
<a href="https://google.com">click here</a>
any same function in discord.js
bot.guilds.get("699189120945094757").channels.get("707183850828070962").send(${vote.user} voted voxility)
this
bot.guilds.get("699189120945094757").channels.get("707183850828070962").send(`${vote.user} voted voxility`)```
but lemme change
the v
how i can make bot send link like in html :
<a href="https://google.com">click here</a>
any same function in discord.js
@earnest phoenix
.send("https://www.google.co.uk")
TypeError: Cannot read property 'get' of undefined
link on a text
Plain text in Discord that is a link works as a link, to make it a link but not embed wrap it in < and >
when u klick text, behind the text it will be link
TypeError: Cannot read property 'get' of undefined
Ah let me fetch it
this is the error
how can i fix that
TypeError: Cannot read property 'get' of undefined
cache ??
Where is the error though?
message.channel.send(text) ??
@earnest phoenix Potentially, not sure if its just on embeds, but worth a try.
@high geode Can you show me the line of xxxx invited xxxx
embed is better
@earnest phoenix same thing. IE:
.setDescription("Hi [this](https://google.co.uk/) is cool")```
yep thought so
@high geode Can you show me the line of
xxxx invited xxxx
@frail ocean what???
https://cdn.discordapp.com/attachments/272764566411149314/707893786860060672/unknown.png @high geode this, just reuse that code.
it doesnt work
In what way
bot.guilds.get("699189120945094757").channels.get("707183850828070962").send(${vote.user} a votat voxility)
this is the code
I'm talking about this https://cdn.discordapp.com/attachments/272764566411149314/707893786860060672/unknown.png
Take that bit of code, and just reuse it but for the voting
It'll have server ids, channel ids already in it for you
it doesnt work bro
TypeError: Cannot read property 'channels' of undefined
this is the error
That means either your channel is undefined, either wrong ID for example
cant be bro
because
i used this id
from this server
send me the id
from
send me
Why are you using that ID and not the one of the channel that you are using https://cdn.discordapp.com/attachments/272764566411149314/707893786860060672/unknown.png from?
hmm
good point
wairt
TypeError: Cannot read property 'channels' of undefined
still error
its the same
channel
and guild id
bot.guilds.get("699189120945094757").channels.get("707183850828070962").send('a votat voxility')
^
TypeError: Cannot read property 'channels' of undefined
same error
bot.guilds.cache
In v12 you need the cache
So your running v11 and v12?
i changed to v11

so i use v11 rn
fyi, v11 will stop working in october
still erroring
Was there a reason for that, just since I advise against downgrading
Yeah since it is not supported from October, and just makes it confusing for us who help people, as we prefer working in the latest version
Use v12
That guide will have all changes on for you
ok but when october comes, your bot will stop working if you have v11
Forgot the ' before Guild_Id
Oops
bot.guilds.get("699189120945094757").channels.get("707183850828070962").send('a votat voxility')
^
TypeError: Cannot read property 'channels' of undefined
what error is this
what the hell
....
the guild id works
channeel id works
that guild doesnt exist in your cache
either ur bot hasnt cached it or the guild id is invalid
bro it doesn work
TypeError: Cannot read property 'channels' of undefined
same error
and i changed the server
and the channel
what the hell
u dont have any guilds cached then lol
wdym
are u waiting for the bot to ready
brh
u could be trying to fetch the guild before the websocket connection fetched all the guilds the bot is in
bot.on('ready', () => {
// put code here
})
try this
same thing?
can I send you the invite link
and do you it?
please
i dont know
i try this
for 2 hours
and i dont know..
do you get the same error
what logs
what wrong here?
console.log(Logged in as ${client.user.tag}!);
i dont recive this
anymore
Also I recommend you format it better, it's easier to read rather than a mix of indentations.
do u have bot.login(token) anywehere


