#development
1 messages · Page 1675 of 1
TypeError: canbnot read property locked of undefined
wait you have 80mb heap used????
if(tim.locked) {
tim.stayLocked()
} else {
tim.lockIn(development)
}```
I mean, yeah detritus is cool and such, but if I cant understand it, no use for me
client.users.cache.size
client.channels.cache.size
client.guilds.cache.size
client.guilds.cache.reduce((a,b) => a + b.members.cache.size)
client.guilds.cache.reduce((a,b) => a + b.roles.cache.size)
client.guilds.cache.reduce((a,b) => a + b.presences.cache.size)
client.channels.cache.reduce((a,b) => a + b.messages.cache.size)
``` @long crow
@opal plank #development message
there's also voice states cache you can add to that
voice no, since this is not music bot
you will still have it tho
but if you have the VOICE_STATES intent then you have cached voice states
ye
also cached messages
so idk what happened
why does djs cache so much
but
makes no sense to me
for some reason they're merged now
client.channels.cache.reduce((a,b) => a + b.messages.cache.size)
even tho I didn't do shit
["GUILDS","GUILD_MESSAGES","DIRECT_MESSAGES","GUILD_INTEGRATIONS","GUILD_WEBHOOKS","GUILD_INVITES","GUILD_MESSAGE_REACTIONS","GUILD_PRESENCES","GUILD_MEMBERS"],
all the intents I have
add those caches i listed to your stats command and see what causes the memory usage increase
Is there a way to load certain folders in a certain order on startup?
yes
and lol, I got better answer here than djs discord itself
This is not related to djs kekw
you could say im an expert on discord.js caching lmao
Tim is djs caching
or lazy
hmm
lets say I have 2 coordinates
{ x: 10, z: 0 }
{ x: 0, z: 10 }
how could I create an array that would be a ray that has a step of 0.1?
I need to do some math in my code rn
lol
can someone tell me how much a custom gamberling bot would be in cash
depends on the person you ask
That all depends on who you're asking, and how complex you want it to be
what does that mean?
a ray of step 0.1
im getting this error pls help
basically
my bot dont login
so from 0 to 10 in 0.1 increments?
yeah
vds constantly loses internet, how do i fix it?
A for loop but increment by 0.1
but in the real case scenario I have
instead of 1
3 variables
Which DNS is the best for Discord Bot pls help
so what is a basike one like would it cost more then 50 or 100 $
let start = 0;
let end = 10;
let step = 0.1;
let array = [];
while(start < end) {
array.push(start);
start += step;
}
lul
why not a for loop
I said its with x and y and z
Again, it depends on who you're asking. There is no standard pricing for Discord bots
oh
its a vec3 in a 3d space
give an example with 3 variables
increment all 3 variables on each step
const pos1 = { x: 10, y: 0, z: 0 }
const pos2 = { x: 0, y: 0, z: 10 }
thats just an example
lol
in the actual code its ofc random
so you want to go from pos1 to pos2 gradually?
loop through every one
ok so if i was asking some one in here since your bot develiperss how much would it cost for one u to make one? thats kinda what i wont to know
add 1 to z remove one from x
Kwai617635478 entrai kkkk
yeah but x and y and z is random when I use it in the actual code
y needs to be considered too
you want a straight line in 3d space from one point to another right?
ex.
{ x: 10, z: 0 }
{ x: 9, z: 1 }
{ x: 8, z: 2 }
{ x: 7, z: 3 }
{ x: 6, z: 4 }
{ x: 0, z: 10 }```
yeah
as an array
the steps will be different for each coordinate
so a step of 0.1 on which coordinate?
that would be fucky wucky with a y value tho
idk
like
you can make a formula
if you start from 0,0,0 and you go to 3,6,5 then the step from 0 to 6 will be one thing, the step from 0 to 3 will be half of that
like y = mx + b
so you need to chose which coordinate you want the steps to be in
is this for the minecraft bot thing
yes
not just for minecraft bot
its for the fomular of calculating explosion damage for minecraft entities
for mineflayer an open source repository that lets you make minecraft bots in js
thats why im asking in the first place
lol
but how would I do that
if the coordinates can be negative and are random
you can do steps based on distance
so you need to triangulate the destination to measure the true distance, instead of axial distance
So I have this array [6, 6, 6, 6, 6] this array could also be [6, 5, 4, 3, 2] right now I need to get the index of it I'm using .indexOf()+1 to ge t it but when I have the first array it alwayssais: Level 1 but it needs to say Level 1, Level 2, Level 3 ... how would I do this?
champion["q"].map(cd => `Level ${champion["q"].indexOf(cd)+1} **${cd}s**`).join("\n")
This is what I'm doing
the true distance between the two points in 3d is the same formula as the diagonal distance of a cube
yep
it should be super easy actually
you can make the formula using the y - y1 = m(x - x1)
but 3d version
idk that one
all you need is 1 end point and the slope
im not too sure how that would work in 3d space
yeah
oh ic
iterate over the length of the array
so for loop instead of mapping right
const arr = [0, 1, 2, 3]
let str = '';
for (let i in arr) {
i++
str += `Level ${i}`
}```
euh
i think i did it right but try this ```js
x = 6;
y = 68;
z = 4;
d2 = Math.sqrt(x2 + y2);
d3 = Math.sqrt(z2 + d22); // true 3d distance
square root
root
what is even **
power
square root of x²+y² is the 2d distance of the hypotenusa
can't you do the third root of x ** 2 + y ** 2 + z ** 2
now that I think about it I should have looked at stackoverflow first
shit no I typed z 2 times
Isn't that the pythagorean theorem

wait it does work
its derived
x = 55;
y = 68;
z = 44;
Math.sqrt(x**2 + y**2 + z**2)
the what
does math.sqrt return an array though
lol
no
no
you would do it on all points
I need an array of positions
not necessarily
search generating all points inbetween 2 vectors
use that formula to get the true distance
then use the steps on this true distance
and recalculate x/y/z based on it
thank you 😄
though it to, it looks similar, but it isnt
it should be 68.381284
no it kinda is
distance formula is the same thing as pythagreon theorm
a^2 + b^2 = c^2
c = root(a^2 + b^2 )
thats pythagorean
there is a big difference
My brain hurts from this
draw it on paper @marble juniper
makes it easier when dealing with shapes and numbers
It's the same thing, but instead of c you're searching the distance
x = 55;
y = 68;
z = 44;
d3 = Math.sqrt(x**2 + y**2 + z**2)
array = [];
for(let i = 0; i < d3; i += 0.1) {
array.push({
x: i * x / d3,
y: i * y / d3,
z: i * z / d3
})
}
you need to do original x - target x, etc
find distance and generate an array of points
to get the distance x, etc
okie
then do the opposite to get positions again
original x + incremented distance x, etc
since you get an array of distances
since you have points you can also just make the formula
To find the equation of a line in a two-dimensional plane, we need to know a point that the line passes through as well as the slope. Similarly, in three-dimensional space, we can obtain the equation of a line if we know a point that the line passes through as well as the direction vector, which designates the direction of the line. The formula ...
this is actually pretty cool
i hardly understand math formulas
same
i need to translate them to code so i can understand xd
the proof is just beyond me but I think I get most of it
where would I put the second position though
lol
Link if you take about 30 mins to read about vectors im sure the answer is going to be a bit simpler than that
x,y,z are the distance between both positions
so you need to x = positionX1 - positionX2, y = positionY1 - positionY2, etc
5/7
in 2d space its essentially that
oooh ok
Hi
can also use math.abs to keep distance positive
because you know
we have to keep distance from positive people
(covid joke)
How can i learn my bot is confirm

One of the angles must be 90 degrees tho
if you are given 2 points there will always be a square and therefore a 90 degree angle
Yea
@quartz kindle I don't even know what those big numbers came from
show what you implemented
ids instead of sizes
xd
The wait time is 2-3 weeks.
const { version } = require("discord.js");
const moment = require("moment");
require("moment-duration-format");
module.exports = {
name:'stats',
aliases:['info','status'],
description: 'Show the statistic of bot',
guildOnly:true,
async run(message) {
const duration = moment.duration(message.client.uptime).format(" D [days], H [hrs], m [mins], s [secs]");
message.channel.send(`= STATISTICS =
• Mem Usage :: ${(process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2)} MB
• Uptime :: ${duration}
• Users :: ${message.client.users.cache.size.toLocaleString()}
• Servers :: ${message.client.guilds.cache.size.toLocaleString()}
• Channels :: ${message.client.channels.cache.size.toLocaleString()}
• Discord.js :: v${version}
• Node :: ${process.version}
• User :: ${message.client.users.cache.size}
• Channels :: ${message.client.channels.cache.size}
• Guilds :: ${message.client.guilds.cache.size}
• Members :: ${message.client.guilds.cache.reduce((a,b) => a + b.members.cache.size.toLocaleString())}
• Roles :: ${message.client.guilds.cache.reduce((a,b) => a + b.roles.cache.size)}
• Presence :: ${message.client.guilds.cache.reduce((a,b) => a + b.presences.cache.size)}
• Platform :: ${process.platform} ${process.arch}`, {code: "asciidoc"});
}
};```
How can I make my node.js bot 24/7
b.members.cache.size.toLocaleString()
you cant do that there
do it after the reduce
Umm ok thx
lol
.reduce(...).toLocaleString()
at least you got my point now with what I meant with my question

im bad at making jokes sorry
what the hell is a "rosette"
How can I make my node.js bot 24/7
You can't get the badge
Umm how did you get
Umm ok
Host it on a VPS online. Or make sure your computer never goes down.
xD
It has a price. Right?
still same, but no more ,
can you show the code again?
There are free hosting services. You can check in the pins for more deatails.
const { version } = require("discord.js");
const moment = require("moment");
require("moment-duration-format");
module.exports = {
name:'stats',
aliases:['info','status'],
description: 'Show the statistic of bot',
guildOnly:true,
async run(message) {
const duration = moment.duration(message.client.uptime).format(" D [days], H [hrs], m [mins], s [secs]");
message.channel.send(`= STATISTICS =
• Mem Usage :: ${(process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2)} MB
• Uptime :: ${duration}
• Users :: ${message.client.users.cache.size.toLocaleString()}
• Servers :: ${message.client.guilds.cache.size.toLocaleString()}
• Channels :: ${message.client.channels.cache.size.toLocaleString()}
• Discord.js :: v${version}
• Node :: ${process.version}
• User :: ${message.client.users.cache.size}
• Channels :: ${message.client.channels.cache.size}
• Guilds :: ${message.client.guilds.cache.size}
• Members :: ${message.client.guilds.cache.reduce((a,b) => a + b.members.cache.size).toLocaleString()}
• Roles :: ${message.client.guilds.cache.reduce((a,b) => a + b.roles.cache.size)}
• Presence :: ${message.client.guilds.cache.reduce((a,b) => a + b.presences.cache.size)}
• Platform :: ${process.platform} ${process.arch}`, {code: "asciidoc"});
}
};```
@quartz kindle
Which vps though
Read the pins to this channel for more information.
Make the starting accumulator in the reduce function 0
do .reduce((a,b) => a + b.members.cache.size, 0) then
Ok ty
which is weird because the reduce docs say accumulator is the result of the first iteration of no initial value is given
but maybe its incorrectly implemented by Collection
I think Guild#valueOf returns the guild's ID
ah
If no initialValue is provided, then accumulator will be equal to the first value in the array, and currentValue will be equal to the second.
so accumulator is the value of b / array[0], not the result of the first iteration
Did you.... err did you read the JS docs, Tim?
Oh no... no no all our hope is gone now.
How can i get Bot developer role
i read a lot of docs
you get it when your bot is approved
Oh ok
@quartz kindle What those numbers supposed to do though
Thanks for answer
you have duplicate users, channels and guilds, you can remove those
the numbers are there so you can see more cache information now, so then your ram usage increases, you will see which cache caused it
sounds like a chuck norris joke lmao
bread
javascript moment
but?
also, add the messages cache, which is also a memory eater
client.channels.cache.reduce((a,b) => a + b.messages.cache.size, 0)
message caches make no sense tbh unless you need message edits
oh yeah
though I use the exact line as ${message.client.channels.cache.size.toLocaleString()}
client.channels.cache.filter(c => c.messages).reduce((a,b) => a + b.messages.cache.size, 0)
because non-text channels have no messages
lemme try again
you can limit the precision if you dont want so many decimals
Though there's no point in limiting it unless you want to display these numbers somewhere
yes
the new status
oops
ok so now you have a more complete view of the discord.js cache
now restart your bot to clear the ram
then watch which caches increase ram the most
I think I will use ==
for the first time
thats not very efficient but ok
math is always faster than string conversion
I just used .toFixed
Math.round(number * 10) / 10
ok
yeah that works thanks
lol
thanks for the help again
appreciate it
ur the best tim and co
now the values in that array are distances
fresh reboot
because they are calculated from the original distance betwee both points
if you want positions, for example to draw a line
you need to convert each of those items in the array back to positions
for example positionX1 = originalX + array[0].x
positionX2 = originalX + array[1].x
etc
now watch as your ram increases, which of the caches change the most
ok I see thanks
I observed message and presence
that quite fast changes
var date = new Intl.DateTimeFormat('en-US', { dateStyle: 'medium', timeStyle: 'medium', timeZone: 'America/New_York' }).format(Date.now())
I want this to be URC
UTC*
rn it’s EST
yes, those are usually high-memory causers
you can disable presences by removing the intent
and you can limit message caching using the client options
👍
I believe you can just change the timezone value to 'Etc/UTC'
removing the presences intent will also prevent online members from being cached at login
which will also help with memory saving
Etc?
I might be thinking wrong, but I believe that is the default string for UTC times (although it might just be a python thing). you could also try DATE.UTC()
what can be count reasonable for message caching? 50 is good?
I am trying to make a command where my bot shows how many servers it is in, but everything I find doesn't work. this is discord.py
Hey there Tim 😄
Your bot should be a client, and client has a field guilds that you can call to see a list of the guilds it is connected to, so all you should have to do is something like len(client.guilds) to get the number of servers
Please help.
const hentai_channels = ["hentai-fans", "hentai-channel", "hentai-love", "hentai-lol"]
var hentai = message.guild.channels.find(channel => channel.type ==="text" && channel.name == hentai_channels.includes(hentai_channels))
message.reply('channel: ' + hentai)```
 __**I want to do;**__ *Find that say "`const hentai_channel = [`' and tag a channel for "`message.reply`"*
Use hentai_channels.includes("channel name" to check if the channel name is inside the hentai_channels array
i like it
like this?
yes
thanks
var hentai = message.guild.channels.find(channel => channel.type ==="text" && channel.name == hentai_channels.includes(hentai_channels))```
let see
ohw no not hentai
No
not like this
don't compare channel.name to hentai_channels.includes(hentai_channels), and don't give the includes function the array, give it channel.name
const Discord = require("discord.js")
module.exports = {
name: "dice",
run(message, client) {
var dice1 = new Discord.MessageEmbed()
.setImage("https://rolladie.net/images/dice/dice1.jpg")
var dice2 = new Discord.MessageEmbed()
.setImage("https://rolladie.net/images/dice/dice2.jpg")
var dice3 = new Discord.MessageEmbed()
.setImage("https://rolladie.net/images/dice/dice3.jpg")
var dice4 = new Discord.MessageEmbed()
.setImage("https://rolladie.net/images/dice/dice4.jpg")
var dice5 = new Discord.MessageEmbed()
.setImage("https://rolladie.net/images/dice/dice5.jpg")
var dice6 = new Discord.MessageEmbed()
.setImage("https://rolladie.net/images/dice/dice6.jpg")
var pages = [
dice1,
dice2,
dice3,
dice4,
dice5,
dice6
];
var author = message.author;
const random = pages[Math.round(Math.random() * (pages.length - 1))]
message.channel.send(pages[0]).then( async message => {
await message.react('🔄');
var collector = message.createReactionCollector(
// only collect left and right arrow reactions from the message author
(reaction, user) => ['🔄'].includes(reaction.emoji.name) && user.id === author.id,
)
collector.on('collect', reaction => {
reaction.users.remove(author.id)
if (reaction.emoji.name === '🔄') {
message.edit(random);
}
})
})
}
};``` made this embed paged dice command only probles that it can edit it self only ones if you press the reaction it just stays on the changed pages how do i fix this
dont worked
ohh sorry
in what language is this bot tf
discord.js v11
nooo i mean is it turkish orrr
You are still comparing channel.name to hentai_channels.includes...
smooth
just hentai_channels.includes...
v11 is deprecated
im stupid pls change this code :D
const hentai_channels = ["hentai-fans", "hentai-channel", "hentai-love", "hentai-lol"]
var hentai = message.guild.channels.find(channel => channel.type ==="text" && hentai_channels.includes(hentai_channels))
message.reply('channel: ' + hentai)```
i so stupid
Remove channel.name ==
yes
no
You are still passing hentai_channels to the include function instead of the channel.name property
learn to code
don't copy things blindly
I did these before I didn't write them but the internet is gone
sure
tbh good question
djs will probably include it
but@you can do it mhm
Hm
const Discord = require("discord.js")
module.exports = {
name: "dice",
run(message, client) {
var dice1 = new Discord.MessageEmbed()
.setImage("https://rolladie.net/images/dice/dice1.jpg")
var dice2 = new Discord.MessageEmbed()
.setImage("https://rolladie.net/images/dice/dice2.jpg")
var dice3 = new Discord.MessageEmbed()
.setImage("https://rolladie.net/images/dice/dice3.jpg")
var dice4 = new Discord.MessageEmbed()
.setImage("https://rolladie.net/images/dice/dice4.jpg")
var dice5 = new Discord.MessageEmbed()
.setImage("https://rolladie.net/images/dice/dice5.jpg")
var dice6 = new Discord.MessageEmbed()
.setImage("https://rolladie.net/images/dice/dice6.jpg")
var pages = [
dice1,
dice2,
dice3,
dice4,
dice5,
dice6
];
var author = message.author;
const random = pages[Math.round(Math.random() * (pages.length - 1))]
message.channel.send(pages[0]).then( async message => {
await message.react('🔄');
var collector = message.createReactionCollector(
// only collect left and right arrow reactions from the message author
(reaction, user) => ['🔄'].includes(reaction.emoji.name) && user.id === author.id,
)
collector.on('collect', reaction => {
reaction.users.remove(author.id)
if (reaction.emoji.name === '🔄') {
message.edit(random);
}
})
})
}
};``` made this embed paged dice command only probles that it can edit it self only ones if you press the reaction it just stays on the changed pages how do i fix this
random is the same even after the user reacts
you need to generate a new random number when a user react, not before
no... just define the random variable inside the collect event
so the random embed is different everytime someone reacts to the message
ooohw
Oop
hey guys im wondering if anyone here has used datadog...i just got it today and i wanna set up some metrics for my bot but im a bit clueless rn
so far i found theres a library for javascript
No sorry dude
help
replit is reinstalling wrong versions of all dependencies which causes zero to reinstall them
and the next time i press run replit installs them again
how do you prevent replit from giving you a stroke
buy a vps 
im not hosting a bot
im using repl as an actual ide
vps' are not only for bots
how can i escape strings for mysql queries in Java?
your library you use for interacting with the database should already have some sort of sanitization method
which library are you using
one from some Person from github.
it has prepared Statements but i dont know if this is what i want
it is
const Discord = require('discord.js')
module.exports = {
name: 'dm',
run: async (message, args) => {
const user = client.users.cache.get('774903577068044298');
user.send('hello');
}
}
Can someone help me with this code its suppose to dm the user with my message but it does not work
debug it
whats the Error you get?
Show your command handler
Wait
await messageReply
oh my jesus
that is a dumpster fire
you're meant to use a single message event
handle everything from there
to make thins easy you can use npm modules like easy-embed-pages
||Not selfpromoting||
that code is just glued copypasted snippets 😔
Not really
yes really
u need to generate random everytime
i can mention 2 people right now who are instantly able to recognize over 50% of that code because they wrote it
sice its static
lemme guess
million and flaze
The other guy was nicer
close enough
or maybe oliy and veld
eevie and flaze
they wrote the complete gibberish luca code
i forgot how to spell eevee

hindsight you mean
yeah
I mean, it's Evie, Evelyne, Evie.Codes, whatever.
is there a way to get data from a website when they're not an api?
scrape it
scraping
ah duck im slow

how?
puppeteer is a bit much if there's no js
if you have ram to burn
I just need to get this data
there might be another way
reverse engineer the website code and see how they're fetching the data
if the data you need is loaded without js -> GET request and parse the html
if the data you need is loaded with js -> use puppeteer
also this
they have an internal API most likely
if not, the site is SSR'd
i don't think xml parsers would really work
bro i need help hosting my bot
there are probably existing libraries to help you parsing html
what do u guys use to host ur bot?
look in the pins
there is a ton of info about hosting there
oh wow
i know that in c# i used HtmlAgilityPack to scrape genius lyrics
which channel?
this channel
tl;dr special servers
of course
cry can i ask you smth
i wonder if you could run a very barebones discord gateway implementation on an arduino
sure
depends
why are you still whitename
i don't really enjoy public bot development anymore
nope use phin it's super lightweight
does the content that u want to scrape is dynamic?
if not then u can just use node fetch
same
i just made h bot to get access to bot developers channel
I have no clue
yes
content can be dynamic even with a site that doesn't use js
thats just for the get request
dynamic content != js website
right
since there's SSRing
server sided rendering
oh
server renders the website and then sends it to the client
yup
though it's best to confirm by disabling js in your browser
reloading the site
and seeing if you still see the data
just see page source
if you don't see the data, you're going to need puppeteer
I'm having an issue getting the avatar of my bot updated. I changed it a few weeks ago and tried changing it again but its still showing as empty. Any ideas? https://top.gg/bot/798271376020340746
Buy, sell and fight for pixel's on your server's Pixelboard. Pixelboard is an economy bot, and multiplayer game which provides endless fun.
try editing your bot description or something just to refresh it
🤷♂️
it's cache dependant
topgg doesn't check with discord for your bot details everytime someone visits the bot page
it instead caches the data
so when you change it in discord
it becomes stale (useless) data
so you need to somehow trigger a refresh
editing your bot description would usually work
its res.text()
ok; hopefully works just tried the description
TypeError: res.text is not a function
const res = await p("https://www.counterstats.net/league-of-legends/yasuo");
console.log(res.text())
they're not using node fetch
code913 told me to use phin
res.body.toString()
nice
yup
any tips on how I should do that?
you can use cheerio
htmlparser2 i guess
or maybe that
no idea
i've seen my friends use it
i don't know if htmlparser2 supports querying via xpath
which is arguably the easiest way to scrape for an element
let inc = new punishments({
Number: 0
});
inc.save();```
i saved the increment as 0
now when i run a command,
and it saves the data, i want it to increment by 1
hmm wait actually i would need to remove that
since it'd keep setting the number to 0
oh my i would just imagine the code being full of "<" and ">" strings
bruv hard coded
but i used that in the old days tho :v
if you just want to extract a single piece of information from html, then its quite simple
just find a single unique pattern before and after the target piece
htmlparser2 has weird documentation how do I parse an HTML object?
dunno either
lets just use cheerio
u can use selector to get the element that you want to scrape
I think I'm doing it wrong
const res = await p("https://www.counterstats.net/league-of-legends/yasuo");
let body = res.body.toString();
let data = cheerio.load(body);
console.log(data.html())
It returns the exact same as body
well yeah
so in my punishments collection, i have something called inc and its set to Number: 0
u search for the element
how would i fetch that number (using mongoose)
Because you're loading the html string and returning the html
so like data("selector")

data.html("percentage")?
nvm im pretty sure i need to do a diff collection
I need the div with class percentage
but there's like 20
and the content?
just this?
yes
<a href="/league-of-legends/yasuo/vs-gragas/middle/all" class="radial-progress radial-progress--med green" data-progress="61" data-final="61">
<div class="circle">
<div class="mask full">
<div class="fill"></div>
</div>
<div class="mask half">
<div class="fill"></div>
<div class="fill fix"></div>
</div>
</div>
<div class="inset">
<img src="https://www.mobafire.com/images/champion/square/gragas.png" alt="Counter Stats for Gragas">
</div>
<span class="percentage">60.84%</span>
</a>
so the title and then the hero list with its percentage?
Right click on the html element and click on "Copy > Copy XPath"
I need that what I sent but like 20 times
does cheerio support xpath?
if it doesn't then go with selectors
hm
You can just <Selector>('span[class="percentage"]')
or just "span.percentage"
or you can just use the dev tools to copy the selector
<img src="https://www.mobafire.com/images/champion/square/gragas.png" alt="Counter Stats for Gragas">
</div>
<span class="percentage">60.84%</span>
I need these 2
for like the 20 items in that list
Right click on the html element and click on "Copy > Copy XPath"
give it to Cheerio
data.html("//*[@id="body"]/div/div[3]/div[1]/a[1]")?
what about it is not understandable?
const Discord = require('discord.js')
module.exports = {
name: 'botinfo',
run: async (message, args) => {
const sayMessage = args.join(" ")
const embed = new Discord.MessageEmbed()
.setTitle("Bot information")
.setDescription("The bot was made by Nathithegamer99#2594 designed on 01/March/2021")
.addField("🤖Bot Name:`Dr.Denzy#0598`")
.addField("🇦🇺Language:`English`")
.addField("☁️Prefix:`+`")
.setColor("#FF005B")
.setFooter("Dr.Denzy Bot Information")
message.channel.send(embed)
}
}
Why does it say undefined in my embed
because you didnt fill out the "value" part of the fields
so what do I do then?
How do I add the value ?
.addField("Prefix", "+")
just make a second property
that second property is the value part of the field
console.log(data("//*[@id=\"body\"]/div/div[3]/div[1]/a[1]")) unmatched selector
if u want ur embeds to look like the format u sent, just use description with \n and surround bold text in ** text **
instead of addField
or you could also use
.addFields(
{ name: "Prefix", value: "+", inline: false }
)
then you can add multiple at a time
its an xpath
and cheerio can't do that
You should really learn to read documentation
wait can cheerio do that
how would i change Inc here
i did inc.find, and it printed that
but i want to change Inc to 1
via code
right
<Collection>.updateOne(query, changes)
oh
do you have the docs
for mongoose
i cant seem to find it
queery would be Inc right
query*
<a href="/league-of-legends/yasuo/vs-nocturne/middle/all" class="radial-progress radial-progress--big green" data-progress="0" data-final="61">
<div class="circle">
<div class="mask full">
<div class="fill"></div>
</div>
<div class="mask half">
<div class="fill"></div>
<div class="fill fix"></div>
</div>
</div>
<div class="inset">
<img src="https://www.mobafire.com/images/champion/square/nocturne.png" alt="Counter Stats for Nocturne">
</div>
<span class="percentage">61.00%</span>
</a>
If I find it in under 10 seconds you owe me five bucks
Now I have this
@tulip ledge is there 387 heroes?
cheerio returned this to me
hmm
No 157 or something like that
i shall check again
oof
You didn't find it??
query will be { "Inc": 0 }
search for mongodb docs not mongoose
what if i wanted to increment Inc
updateOne(query, {$inc: { Inc: 1} })
increment everytime the command is run
essentially, a case ID system
if someone gets warned, case ID is 1
what googlefeud said
right so it's just saved as Inc: 0
You probably want to find it via the user's id or something
i have a question regarding discord media links. need help urgent
not Inc
if u query for Inc: 0, then after increment u wont be able to access that
so use id or something
find via user ID?
well,
i made a new collection
for case IDs
and just have one thing there
which is Inc
now whenever the cmd is ran, it would increment Inc by 1, assign CaseID as that number, and save Inc
Ok
uuh... so can you give us the structure of your document?
Alright so I managed to get the first 20 champions of the list their html thingy now I turned the whole list into an array that looks something like this:
["<a href="/league-of-legends/yasuo/vs-nocturne/middle/all" class="radial-progress radial-progress--big green" data-progress="0" data-final="61">
<div class="circle">
<div class="mask full">
<div class="fill"></div>
</div>
<div class="mask half">
<div class="fill"></div>
<div class="fill fix"></div>
</div>
</div>
<div class="inset">
<img src="https://www.mobafire.com/images/champion/square/nocturne.png" alt="Counter Stats for Nocturne">
</div>
<span class="percentage">61.00%</span>", ...]
Now is there a way to access the img src and the thing between <span class="percentage"> and </span>
check dm
tada bum
And _id is the case ID?
...
might not be the best way to do it since ur essentially just keeping track of the length of cases
you need to link that value to something
i think he is trying to use Inc as an ID for some other object
otherwise what's the point of it
yes
if i understand correctly
im trying to increment Inc everytime cmd is ran
and then assign that new Inc to a caseID
then save
theres probably a wayyyy easier way to do this
hello, the discord media links.there is media.discordapp. and another is images-ext. are both links permanent as long as i dont delete the original file ?
yes
okie okie, i had to copy the original gif i uploaded which was as media.discord form and when i copied it, it became images-ext. i was afraid it will be temporary
so my increment doc is saved as
[ { _id: 60621b98ba0c41023da6cdad, Inc: 0, __v: 0 } ]
and when someone gets warned, inc should increment by 1
and save
so there's no duplicate IDs
although idk how to fetch Inc
and increment it
well incrementing would just be ++
well
i cant save it into the other
cuz id need a user id, punishtype, date, etc
sooo
how would i fetch the inc and increment it
alright sorry I'm asking so much but I'm stuck again, I have this string which is either: Counter Stats for <ChampName> or <ChampName> countering how do I "extract" the <ChampName> from those strings?
Is there a way to check for user roles in another server without having server members intents?
Like, the command was invoked on server X, and I want to check if the user has an specific role on server Y, but the bot does not have intents, is it even possible?
discord.py btw
hey so im trying to embed a video onto my bot page but i have no idea how
'User' object has no attribute 'roles' :/
server = client.get_guild("id")
i did it like that
it works
but i cant figure out how to get the user by the server
🤔
ah
you can use await server.fetch_member(id);
you can use get_member() but the member might not be cached
i was trying this one and it was not working
this one works like a charm
thanks
i was using fetch_user and it wasnt working
fetch_member works
kek
ah, I think fetch_user is for client
welp that makes sense
following back up on missing avatar https://top.gg/bot/798271376020340746; I updated the description on discord of my application but it still doesn't seem to be picking it up. I'm running a couple hundred dollars in ads with you starting tomorrow so any help in getting this resolved is greatly appreciated.
just searched through message history
there should be a refresh data button i guess?
How do you do that
?
I think that helped cry, thanks! Avatar is now visible on the link to bot page in my profile + the voting page but still not the main one. Hoping that just takes some time to propogate thru.
console.log
I was referring to the message of discord xd
It's a Markdown lol
a ty
Mhm.
Hello,
I want to install phpmyadmin on my debian 10 (vps) but I don't know which guide to use as there are a lot of guides online. Which one should I use! Thank you
I'd say go for the one that you understand the best
the filter is {} since it doesn't matter and yeah, it increments the value
alr
google what increment means
yep
alr
so if i assigned
Inc to CaseID
would it be 2 the next time it was ran
lemme test
uh
(node:152) UnhandledPromiseRejectionWarning: Error: cyclic dependency detected
whats the issue with it?
let cid = inc.updateOne({}, { $inc: { Inc: 1 } })
data.Punishments.push({
PunishType: 'Warn',
Date: date,
Moderator: message.author.id,
CaseID: cid,
Reason: reason,
});
data.save();```
i think it has to do with how i connect
useUnifiedTopology : true,
useNewUrlParser: true```
am i supposed to add anything else
await it first and see if the error still occurs
updateOne() returns a promise
and log cid after that and make sure cid is a number, not an object
{
n: 1,
nModified: 1,
opTime: {
ts: Timestamp { _bsontype: 'Timestamp', low_: 14, high_: 1617046758 },
t: 4
},
electionId: 7fffffff0000000000000004,
ok: 1,
'$clusterTime': {
clusterTime: Timestamp { _bsontype: 'Timestamp', low_: 14, high_: 1617046758 },
signature: { hash: [Binary], keyId: [Long] }
},
operationTime: Timestamp { _bsontype: 'Timestamp', low_: 14, high_: 1617046758 }
}
(node:251) UnhandledPromiseRejectionWarning: MongoError: The dollar ($) prefixed field '$clusterTime' in 'Punishments..CaseID.$clusterTime' is not valid for storage.```
y i k e s
ok
aha
works
but
(node:354) DeprecationWarning: Mongoose: `findOneAndUpdate()` and `findOneAndDelete()` without the `useFindAndModify` option set to false are deprecated. See: https://mongoosejs.com/docs/deprecations.html#findandmodify```
should i set
useFindAndModify to false
add { useFindAndModify: true } I guess
it says without it set to false
works ty
Any way to check if a user is executing a command and that command is part of the commands that is in an array const commands = ['command1', 'command2'], then I would add an additional code?
Kind of got lost on how to do that.
one quick question
how would i uh
fetch a log with the caseID
and delete it
or list it
confirmed fix. My avatar was not showing up in my bot page after I changed it. It was using the old profile picture link. Hitting 'refresh data' button caused it to propagate through after about an hour; summarizing so maybe someone can find this in search more easily 🙂
use deleteOne() or findOne()
use the case ID as the filter
like const case = await model.findOne({ caseID: 69420 });
o
alr
ty
how would i detect if the message is too long
and then split it into two messages
f(data) {
message.channel.send(new Discord.MessageEmbed()
.setTitle(`${user.user.tag}'s Moderation History`)
.setDescription(
data.Punishments.map(
(v, i) =>
'**__Case ID:__** `' + `${v.CaseID}` + '` | **Moderator**: ' + `<@${(v.Moderator)}>` + '\n**Date**: `' + v.Date + " EST`" + '\n**Reason**: `' + v.Reason + '`\n**Type:** `' + v.PunishType + '`'
)
)
.setColor("BLUE")
.setFooter("Moderation Logs")
)
```
Why does this give 401 error?
I did the Authorization header correctly, right?
Also, the user does have the guilds.join scope
no
its not web dev 🤷♂️
axios.put?
that's a thing?
hmm
never used axios for anything besides get
thats probs why
Authorization header is invalid
How so
Well shouldn’t be hard to figure out
It is
its not lmfao
message.channel.send(abc, { split: true })```
would this even work
splits embed into two embeds because message is too long
i tried it but it just returns object
I mean I could tell you n times it is but you won’t believe it even IF the error says it is
Look at your content header
As tip
smh
Yeah that’s what I’m doing too can’t understand why you don’t fucking able to compare 2 lines or read the axios docs
no need to curse at me
and
the auth is not invalid
I said this before, and saying it again
I know its not.
It's something else.
Alright you still don’t understand
Well then not my issue anymore...
i dont understand, why doesnt the bot send the mesage as a txt file
message*
if it's above 2048 characters
or whatever the limit is
instead it just errors
ah wait its an embedd
ugh nvm
but how would you split it 
A last tip just because I’m nice the object key has to be a string, axios does only convert some known header types to the string format
can someone help me with my code? It doesnt seem to work...
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith('pls rob @shut dragon'):
await message.channel.send("@shut dragon You're being robbed!")
if message.content.startswith('pls rob @shell crest'):
await message.channel.send("@shell crest You're being robbed!")
can someone help me
whats the error??
thats not the issue
still didnt work anyways 🤷♂️

