#development
1 messages · Page 1053 of 1
but
instead
I did a bunch of regex
to make case-specific errors
that people wouldn't normally do
since the word "character" would typically include emojis, letters, unicode characters
but, its sans
so I gotta be really specific
Omg
ah
it takes a bit of extra work but
it just puts your bot at a bit of an edge
over other ones lol
idk exactly how many but
I've got a .drumroll command
which will join your vc
and play mus_rimshot.ogg
O-
also, a .playall command
which will play the entire undertale ost
one by one
and .playrandom which will play a random track from the undertale ost
Loop?
Do you know frontend, backend and data shit?
@gilded ice idk anything about that :(
yep I've got loop
.loop
and .disconnect
I've also got a TON of aliases
for each command
lol
@subtle osprey okay so what you wanna learn is react, HTML and how to use and link your database to your bot and website
you loop the playing song or the all songs in queue?
@JustAPie okay so what you wanna learn is react, HTML and how to use and link your database to your bot and website
Shit double sent
just the current song, I haven't even implemented a proper queue yet, but it wouldn't be hard to make
Queue ez
"that's a skele-ton!"
queue ez
Omg I'm dead
and have it delete the first item from the array when its done playing
huh
and have it delete the first item from the array when its done playing
@mental oracle well that thing actually make it hard to loop the queue
@mental oracle missed your queue construct
@gilded ice we just need to push data to the queue
Queue loop hard, song loop ez
I'll try to do it rn lol
Queue is a map of the guild ID and the server queue
The server queue is an array holding the queue construct
Hello guys my bot cant add something under the text
Epic
wdym?
queue looping doesnt sound that hard
Mkay
queue looping doesnt sound that hard
@mental oracle so, do u have anything to loop the queue but dont have to delete the first element?
There's probably a way to push it to the back
is to delete it and push the finished song to the end of the queue
but that's not effective
Ol
i will tell u why
each time u push the song to the end of the queue
but if there anyone add anothe song
var vc = vcs[voiceChannel.id];
if (vc.looping = true) {
vc.dispatcher.removeAllListeners("finish");
vc.dispatcher.on("finish", () => {
if (vc.queuePos == vc.queue.length) {
vc.queuePos = 0;
}
if (vc.queue.length > 1) {
vc.queuePos = vc.queue + 1;
playAudio(voiceChannel, vc.queue[vc.queuePos]);
}
}
}
serverQueue.songs.pop()?
thats my pseudocode
that song will be at the back of the queue
so when loop the queue
it won't loop the queue by the wanted pattern
Whats your db @mental oracle?
I just have a dictionary
What
var vcs = {};
//when join vc for the first time
vcs[voiceChannel.id] = vcs[voiceChannel.id] || {};
vcs[voiceChannel.id].connection = connection;
vcs[voiceChannel.id].dispatcher = dispatcher;
vcs[voiceChannel.id].sound = sound;
vcs[voiceChannel.id].looping = vcs[voiceChannel.id].looping || false;
vcs[voiceChannel.id].leave = leave;
thats it rn
how do I make a discord bot.
I'll add queue looping later
I want to focus on more functionality than small things like that for now
who can send simple discord bot script
Do it yourself
Y not
pls

Just look it up on YouTube or something
:PG_pikachuuwu:
@earnest phoenix can you send this emoji's link?
Umm it's in my server

partyDisplay = "";
accepted.forEach(x => {
players.forEach(p => {
if(!players.includes(x)) partyDisplay += `**${client.users.cache.get(x).username}** 💀 DEAD\n`;
else partyDisplay += `**${client.users.cache.get(p.userid).username}** ♥️ ${p.health}/${p.maxhealth} HP\n`;
})
})
I am confused this makes it display like this:
what's inside accepted?
Wdym?
let x = 0;
for (; x < accepted.length ;) {
//do something
x++;
};```
wtf
lmao
why
helo
does anyone know how I can make the text go up instead of down?
i mean like, my socket.io chat thingy automatically goes down like:
but i want it to go 🆙
instead of down
are you using flexboxes?
im not
maybe you should
Tim the dungeons are fully working 😄
oh ok
or ```css
display: flex;
flex-direction: column;
justify-content: flex-end;
depending on how you want to order the items
the first one doesn't work, this is what i donejs msgElement.style.display = 'flex'; msgElement.style.flexDirection = 'column-reverse';
i'll try the second
o ok
not the messages themselves
quick question
WOO used incompetence
im doing it like this, ```js
const msgElement = document.createElement('div');
lmao woo
It works wiyth up to 4 players
the wrapping happens when you add the element to the parent
Well I haven't tested it with 4 yet only with 3 players
H e y
how do you add the message to display it?
who are you talking to?
lost
ah
but seems he got it already
elemnet styel backgrun
10/10
now its movign the 'Send Message' and the input bar down with it?
thank
how can i make the send message and the input bar stay in one place?
the flexbox controls everything inside it the same way. if you want the send message bar to be unnaffected, you need to move it out of the flexbox
o ok
for example
<send message>
<messages>
<msg>
<msg>
</messages>
i just make a form that sends a post request
ook
thats smol brain
thats not the point tho
you've got to refresh the browser everytime
i mean, this is just user interface
doesnt matter where or how the messages come from
what is the user making
its also slow though, you're better off just making ajax requests then
if you want a live chat app, use websockets
yeah, i am
is decent
everything works, but im just trying to make it look nice now
make it
tim, do u know how i can make it so u can press enter? bc u've got to press the green button
use JavaScript
minimist is js lol
Well
wdym?
on which line?
Did you r e a d the error?
show the full error
whats mute.js line 12?
u just need to show l12
I would tell you to use aa!bin but it's not verified yet
of mute.js?
Send mute.js
i would guess this is the errorif (user.roles.cache.some((r) => r.name === args._[1])) {
users have no roles
members do
member and user are different things
yes, you're getting it as a user
your user holds the user object not the member object
members
members not member
Idk if you're trolling
the code where you give the role?
you're not picking a role
var role = message.guild.roles.cache.some((r) => r.name === args._[1]);
this is for checking if a role exists
not for selecting a role
to select a role its ...cache.find(...)
thats what hes doing
wait this exist? and i made a stupid workaround
Stupid workaround for?
the stuff minimist does
uninstall?
hai quick tiny question, if i had a list list = ["a", "b", "c"], and i wanted to check if any of the strings in that list are in a message sent, how would i phrase that?
i think message.includes(list) could work
oooh that sounds good
One way of doing it is using any on [(x in message.content) for x in my_list]
Are we talking Python here?
yea
message.content.includes is JS
i used a for statement previously for s in ["a", "b", "c"]: if s in message.content: but that ended up making messages send for each item in the list lol
yeah my method might work
>>> content = "EEEE a a e"
>>> l = ['a', 'b', 'c']
>>> [(x in content) for x in l]
[True, False, False]
oki :0 sorry at first galnce i thout it was the same as what i'd had
>>> result = [(x in content) for x in l]
>>> result
[True, False, False]
>>> any(result)
yea just realized it needs a sting
well how the table
wot
@rigid maple use a role for muting users. also store the userid of muted users in best case together with a timestamp for automatic unmuting
as datastorage use a Database
language?
Turkish
bruh
without any type of persistent storage it makes no sense
create a cron job for checking mutes which date same with current date
quckk question
create a cron job for checking mutes which date same with current date
@summer torrent I couldn't understand because I used translation 😦
¯_(ツ)_/¯
i've got this: css input :hover { cursor: not-allowed !important; } when i hover over the input, it doesn't change the cursor, any ideas?
css ^
Try pointer sir
I mean
cursor: pointer;
I'm trying to collect multiple rows and put them in a new Array i can use later.
My attempt is to do it like this but the dbPlayerData is not containing any information after this point in the logs.
let dbPlayerData = [];
db.query(`SELECT * FROM playerdata WHERE account_id = ${b}`, function(err, rows) {
if(err) throw err;
if(rows) {
rows.forEach(function(item){
dbPlayerData.push(item)
})
}
})```
Anyone an idea what i did wrong?
Which db is that
mysql
oof
use a for loop
for loop had the same output though
ye but for some reason i had the same issue with mysql
and with a for loop you can use rows[0],rows[1]....
this worked for me
may I ask u, why do you do this?
@lyric mountain to build a new Array to use later?
why not just unload the rows inside the array?
if i think about it it makes no sense, since the db already returns a array
@lusty quest
let dbPlayerData = []
db.query(`SELECT * FROM playerdata WHERE account_id = ${b}`, function(err, rows) {
if(err) throw err;
for(let i = 0; i< rows.length; i++) {
dbPlayerData.push(rows[i])
}
})```
no
this makes no sense
Mmm learning time
🍿
mysql returns a array
what do we do to show badges
👌 question though; how come it doesnt log like that?
message.author.?
its like getting a box empty it and put the stuff back into the box
@earnest phoenix flags
@earnest phoenix message.author.flags.toArray()
👌 question though; how come it doesnt log like that?
@peak venture because ur sql is broken maybe?
@peak venture blame the node console parsing for it
oh thanks
🤔
it shows rawDataPackage or something like this right?
keep in mind that the query returns a callback
if it shows nothing, maybe ur query ain't returning any value
got me confused first time too until i found a old stackoverflow post about it
the value returned is only available inside the callback, not outside, because by the time the callback arrives, any code outside is already long gone
^
^ that too
That's basically what i see indeed
so await it
can i await this somehow?
yes
you can wrap it into a promise
await new Promise(resolve => {
...query(..., result => {
resolve(result)
})
})
you can also handle all the processing inside the callback
if you don't want to use await
@quartz kindle resolve(dbPlayerData) in that case?
you can use util for enabling promises for mysql
@earnest phoenix writes undefined
const util = require('util');
const query = util.promisify(connection.query).bind(connection);
const data = await query(`SELECT `+table+` FROM Serverconfig.config WHERE serverid = ${database}`)
```then you can do this
@earnest phoenix v11?
(i had it wrapped inside a function)
@peak venture you can chose what to resolve. if you resolve rows, you can directly do dbPlayerData = await new Promise(...)
doesn't it happen in v11
user flags is in 12
Is there anyone who uses postgresql database here?
ok
let dbPlayerData = []
dbPlayerData = await new Promise(resolve => {
db.query(`SELECT * FROM playerdata WHERE account_id = ${b}`, function(err, rows) {
if(err) throw err;
rows
resolve(rows)
})
})```
Would be the thing the most likely @quartz kindle
My postgressql is only listening on tcp6 not on tcp.
@plucky harness did you got something like ufw running?
you dont need to define dbPlayerData separately
It disabled
and you dont need that rows doing nothing in the middle
just let dbPlayerData = await new Promise(....
yes
👌
@plucky harness did you bound any ip to your db?
ok
Local address you mean right?
dies netstat -a -n | findstr [Yourport] return something?
hmm start postgres with -h parameter
I get a error
`Here is ${user1}'s avatar. ${message.user1.displayAvatarURL()}`
^
TypeError: Cannot read property 'displayAvatarURL' of undefined``` but it works on my code above
```js
`Here is your avatar ${
message.author
}. ${message.author.displayAvatarURL()}`
);```
with this you can force to use ipv4
sudo service postgresql start -h?
ohh you run it as service.
no its fine
@still merlin message.user1 is not a thing
does sudo service postgresql status return any error?
I defined .user1 though
I didn't even change anything. I installed postgresql and it's only accepting tcp6. On my port
Idk what's wrong
then it can be user1 only
o
i never used postgress bcs it can be a pain in the ass to configure
What do you use
rn MongoDB used before it Mysql
Mongo db us hard 8 think
also a last resort would be installing docker and run postgress in a docker container
? i switched entirely to Mongo
Oh
but before just mysql
I c
Mongo is not this hard if you get into it. i like the ability for horizontal scaling
Am figuring out and still haven't found a solution for whole day

Yeah I'll look into it
if you want to use Postgres install docker and run a postgres container
its probably way faster
could also settle for sqlite if you dont need an actual server
had initially also issues with installing MongoDB. after a hour i was just fuck it i install docker
waiting for appproval day 2
since then it works like a charm
Is sqllite good for bots with big servers
not really
is mongo good?
depends on what your use case is
That's why i don't want to use sqllite
sqlite works very well for me
if you store only a few things its fine
I store lot of things
if you store more complex stuff get a external DB
people tend to underestimate sqlite
aiosqlite?
Depending on how it's handled
i started with Enmap but ran into the issue that enmap needed 1GB ram for "only" storing a little bit of data for 8 servers
Shivaco, any idea why my postgressql is only listening on tcp6 ipv6
idk which sqlite libs there are for python, since i use js
sqlite3 and aiosqlite
aiosqlite apparently only pretending to be async or something, don't remember what was wrong with it
@plucky harness like i said try it with docker, i dont know many here that use Postgress
Alright I'll try with docker
better-sqlite3 for node.js kinda proves that sqlite is better sync than async
the author has a whole explanation about it
My sqllite3 is like this
Database is locked
Because i store too many things in the database
if you need write performance, use WAL mode
maybe you store them inefficent
and disable synchronous queries
so uh, does anyone know how to make the cursor thing work?
input :hover {
cursor: not-allowed !important;
}``` ^
it doesn't change the cursor when u hover over it btw
the sync/async is not the problem. you need to toggle the synchronous option in sqlite itself
I'm just fine with mongodb and the way data is stored so shrug
same shiv
the library that runs sqlite should be sync, the synchronous option in sqlite itself should be set to off via a pragma command
although when running in WAL mode, setting synchronous to normal is also fine
How come that as soon as i parse my data into a function the time(ms) turns into a date in the function?
@peak venture you need to show code
//console.log(`Controller: ${dbPlayerData}`) // [object Object], [object Object] etc etc
let apiData = await CollectPlayerShips(client, aNew, a, b, c, cache, start, dbPlayerData)```
Maybe it's because i open database on every command and close it
and then in CollectPlayerShips i console.log(dbPlayerData)
if you log bla ${obj}
the object gets stringified
the same as doing obj.toString()
Tim. Can you DM me 2 lines for your boss?
Like 2 lines your boss should say before the battle starts
please approved my new bot
huehuehuehuehuehuehuehuehe
uvuvwevwevwe onyetenyevwe ugwemubwem ossas
@tulip ledge
Ok lmao
long time ago?
Oh and a type for your boss you can choose between
- None
- Undead
- Dragon
- Cube
- Spider
And Ender
(Certain enchants deal more damage depending on the type)
whats the strongest lmao
Well it's not really strongest
@quartz kindle i understand that blabaa.toString() part however i don't get why i dont see all the [object object] from dbPlayerData but i get to see Mon Jul 13 2020 15:15:14 GMT+0000 (Coordinated Universal Time) instead
It's just certain enchants deal more damage if used on an undead mob for example
@peak venture
@tulip ledge none then i guess, that would be no weaknesses and no resistances right?
😛 that part = 👌
But why do i only get to see 1 part of 1 object isntead of all the objects in the array
which part
you should be able to see everything if you do console.log(dbPlayerData)
instead of console.log("Controler ${dbPlayerData}")
Controller: [{"account_id":"500370681","yr":1222,"winrate":64,"date":""},{"account_id":"500370681","yr":1222,"winrate":64,"date":"Fri Jun 19 2020 15:19:09 GMT+0000 (Coordinated Universal Time)"},{"account_id":"500370681","yr":1222,"winrate":64,"date":"1592580980151"},{"account_id":"500370681","yr":1222,"winrate":64,"date":"1592581051477"},{"account_id":"500370681","yr":1222,"winrate":64,"date":"1594628974000"},{"account_id":"500370681","yr":1222,"winrate":64,"date":"1594628974000"}]
Mon Jul 13 2020 15:20:30 GMT+0000 (Coordinated Universal Time) ```
so in Controller is the input into function>
And below that, the actual date of this midday is inside the function after being parsed with
let apiData = await CollectPlayerShips(client, aNew, a, b, c, cache, start, dbPlayerData) ```
though i'd wanted to have all information rather than only 1 date (which is the latst part of dbPlayerData)
you mean you want Fri Jun 19 2020 15:19:09 GMT+0000 (Coordinated Universal Time) instead of 1592581051477 in all of them?
ahm. No, im fine in having 1592581051477 there.
Just the entire array is what i want to parse.
not just the last datestamp
then show code
In the controller: ```js
let dbPlayerData = await new Promise(resolve => {
db.query(SELECT * FROM playerdata WHERE account_id = ${b}, function(err, rows) {
if(err) throw err;
resolve(rows)
})
})
var cards = new CardCollection();
console.log(`Controller: ${JSON.stringify(dbPlayerData)}`) // [object Object], [object Object] etc etc
let apiData = await CollectPlayerShips(client, aNew, a, b, c, cache, start, dbPlayerData) //CollectAPIPerson
In the function:
```js
const CollectPlayerShips = async function(client, tld, region, account_id, cache, start, dbPlayerData) {
// --------------------------------------
// Syntax Checking
//---------------------------------------
console.log(dbPlayerData.toString())
so uh, does anyone know how to make the cursor thing work?
@digital ibex try pointer sir
kk
Not 100% certain but this:
SELECT * FROM playerdata WHERE account_id = ${b}
I'd think account_id is like a TEXT or a VARCHAR so you'd have to do "${b}"
dbPlayerData.toString() will only show [object Object]
@tulip ledge i do get information back form there though. the 6 rows in this case are resembled in the 6 [Object objects]
also, you're missing a parameter
Oh ok thats odd but it works
nope

doesn't change, @pallid zinc
@peak venture
@digital ibex what u did ?
input :hover {
cursor: pointer;
}```
Dont hover
@quartz kindle didnt notice that. thnk that will prolly fix it
U should remove :hover
huh
its redundant
how will it even change without hovering lol, you don't have two cursors
how will it even change without hovering lol, you don't have two cursors
....
since the target is the cursor, it will only be targeted when hovering regardless
o
yeah it works when i remove the :hover :D
Yup
um
So I have this "player" class and it cotains a propertie totaldmg I have a total of 4 objects constructed with that class now is there a way to sort the array where alle the player objects are stored in to go from totaldmg > totaldmg
array.sort?
swap a and b to invert order
Ok
@elfin kiln do you have any experience with programming/coding? have you ever user a coding language before?
ah good
then look into discord.js
they also have a pretty good guide
quick question
.updateOverwrite (on a channel object) doesn't change it to that, just adds the overwrite for the role?
and has the same syntax as .overwritePermissions
the syntax is different
overwritePermissions([overwrite1,overwrite2])
updateOverwrite(userorroleid,permissions)
Ah thanks!
for (category in folder) do require
can someone explain this fully?
i need help with sharding in discord.js v11.5.1
what i am trying to do is i have a mongodb database.
i am fetching IDs of users from them and i wanna show their username in leaderboard.
so, how can i convert this code in sharding :
if(res.length > 100) {
for (i = 0; i < 100; i++) {
let member = client.users.get(res[i].userID) || "Invalid User#0000"
if (member === "Invalid User#0000") {
lb.push(`**${i + 1}.** ${member} • ${res[i].coins.toLocaleString()} Fren Coins`);
} else {
lb.push(`**${i + 1}.** ${member.tag} • Fren Coins ${res[i].coins.toLocaleString()}`);
}
}
}
i tried almost everything. idk how can i convert this now. even when trying only client.shard.broadcastEval("this.users.get('my-id')").then(u => console.log(u.username)) it shows nothing.
you cannot transfer complex data structures across shards
you need to extract the values you want and/or convert them to primitives, such as strings, numbers, etc
Mhm..
for example, for a username, eval this.users.get(id).username
that way only the username string is transfered not the whole user data
client.commands = new Discord.Collection();
const commandFiles = fs.readdirSync('./commands/').filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(./commands/${file})
client.commands.set(command.name, command);
}
How can I have it require more folders then just the folder named commands
for each folder that you want to require, you need to readdir it and loop over its files
oh
is dotenv flow easier to use than dotenv
I have this array: [50, 20, 10]
Now I want to map or join it like this: 1 - 50\n2 - 20\n3 - 10 I tried some stuff but none worked
My code keeps changeing when I save it, so my .then becomes undefined.
my code is
message.channel.send("``:white_check_mark: Restarting!``");
client.destroy()
.then(() => client.login(token));```
basiclly my .then goes onto the client.destroy() making it client.destroy().then
how can i prevent that
@tulip ledge
Oh
Cuz I first tried this:
let leaderboard = players.map(x => {
if(players.indexOf(x) === 0) `🥇 ${client.users.cache.get(x.userid).username} - **${x.totaldmg}**`;
else if(players.indexOf(x) === 1) `🥈 ${client.users.cache.get(x.userid).username} - **${x.totaldmg}**`;
else if(players.indexOf(x) === 2) `🥉 ${client.users.cache.get(x.userid).username} - **${x.totaldmg}**`;
else `${players.indexOf(x) + 1} ${client.users.cache.get(x.userid).username} - **${x.totaldmg}**`;
})
So I can just do (x,i)
OHMYGOD HI
[ undefined, undefined ]
AAAAAAAAAAA I CAN SPEAK
for each folder that you want to require, you need to readdir it and loop over its files
@quartz kindle
fs.readdir('./commands/', (err, files) => {
if(err) return console.error(err);
console.log(files.join(' '));
});
i got the folders in in commands what do i do next?
@stark abyss set them in a discord collection
@still merlin client.destroy() returns void which is basically undefined. What exactly do you want to "prevent"?
Nvm I forgot the "return"
fs.readdir('./commands/', (err, files) => {
if(err) return console.error(err);
client.commands = new Discord.Collection();
console.log(files.join(' '));
});
i fixed it
like that?
:>
It's really easy, trust me. I will break it down for you then help you write the code, alright?
ok thank you, you are really nice
:> you're welcome

I'm getting a head ache from my code lmao
*hug* c h i l l o u t t i m e
alright so i am loading all folders in this folder
fs.readdir('./commands/', (err, files) => {
if(err) return console.error(err);
console.log(files.join(' '));
});

@stark abyss I'll help you write it from scratch
I'll help too
ok
I'm gonna take a break from my dungeon command lmao
Send me the inside of one of your command files
module.exports = {
name: 'server',
description: 'Display info about this server.',
guildOnly: true,
cooldown: 5,
execute(message) {
message.channel.send(`Server name: ${message.guild.name}\nTotal members: ${message.guild.memberCount}`);
},
};
Okay cool
that's one file
Alright, do 'name', 'description', 'guildOnly' and 'cooldown' appear in all of your command files?
yes
tf is an aforementioned DBL member
Okay good, thats good
there is also aliases: ['name2', 'name1'],
Oh okay, that's good too
In your index you wanna make a new collection and call it command
Wait I'll go to my pc so I don't fuck up
ok
Alright
const command = require(./commands/${file}) is what i had before
Yeah that's good too, but what you wanna do is make a new Discord.collection()
@quartz kindle any idea what is wrong in this code?
the leaderboard embed is empty.. and sorry for the ping... u r the only one who replied to my issue xD not even in Discord.js web i got any help xd
if(res.length > 100) {
for (i = 0; i < 100; i++) {
client.shard.broadcastEval(`this.users.get('${res[i].userID}').tag`).then(u => {
//let member = u || "Invalid User#0000";
if (u === undefined) {
lb.push(`**${i + 1}.** Invalid User#0000 • ${res[i].coins.toLocaleString()} :frencoin: Fren Coins`);
} else {
lb.push(`**${i + 1}.** ${u} • Fren Coins :frencoin: ${res[i].coins.toLocaleString()}`);
}
})
}
}
E.g
i wrote that why i pinged him xd
You can't just randomly go ping people
he replied to my same question a few min ago
client.commands = new Discord.collection()
Client relates to the client, it's where you're assigning the collection and commands is the name of the collection @stark abyss
oh
bruh i didn't ping RANDOMLY
so what do i do next
Wdym chill? I just read out the rules
Discord.Collection()
Why do u always say chill to me? xD
if u run the command, what does it respond with?
this.users.get('${res[i].userID}').tag
Would that not throw an error if the user is not cached?
Then you wanna read the dir (fs.readdirSync('dir name').filter(f => f.endsWith('.js'))
cuz u do need to chill 
I think so
when i run the cmd, the embed of leaderboard is empty
I just read out the rules 🤷♂️
Would that not throw an error if the user is not cached?
@sudden geyser how can i prevent this ._.
how r u getting the members?
this sharding is just frying my brain... :/
const commandFiles = fs.readdirSync('./commands/').filter(file => file.endsWith('.js'));
yeah? @pure lion
and cache all users in the client options
There are many ways you could avoid it. You could remove the .tag part, or use the optional chaining operator if you're on Node.js v14.
Is res.length > 100 true in your if condition?
Can you upload more of your code to a site like hastebin
well, the other part is of just sending embed by joining the lb arrays.
Discord.js is fine.
should i send it completely still?
how r u getting the members, ronak
oh
MongoDB database has User Ids... i am just importing the User IDs... res is the value containing the db...
just a sec... lemme send the upper portion of the code
Money.find().sort([
['coins', 'descending']
]).exec(async(err, res) => {
if (err) console.log(err);
let lb = [];
if(res.length > 100) {
for (i = 0; i < 100; i++) {
client.shard.broadcastEval(`this.users.get('${res[i].userID}').tag`).then(u => {
//let member = u || "Invalid User#0000";
if (u === undefined) {
lb.push(`**${i + 1}.** Invalid User#0000 • ${res[i].coins.toLocaleString()} :frencoin: Fren Coins`);
} else {
lb.push(`**${i + 1}.** ${u} • Fren Coins :frencoin: ${res[i].coins.toLocaleString()}`);
}
})
}
}
wait how do u get ur message like that
I'm just struggling to focus and compose myself 😅
js
Seeing this get's me scared for whenever my bot requires shards
It's already hard enough to make my bot function lmao
._.
@earnest phoenix
alr
broadcastEval also returns a promise, so there's no guarantee the array will have the exact content you're looking for on time. Also, do you really need to broadcast over 100 times
markdown is cool

how will i get 100 users then :p
@earnest phoenix afaik, u can't use .sort like that, but... log Money.find().sort(['coins', 'descending']);
runs an eval on every shard and returns an array of the result
it runs a script in all the shards
oh right
👀 its tim
@earnest phoenix you can just do if(res.length > 100) { res.length = 100 }
even in Discord.js official servr i got no reply for my prob -_-
and dont use a for loop
...broadcastEval(`
let users = ${JSON.stringify(res)};
users.map(t => this.users.has(t.userID) ? this.users.get(t.userID).tag : null).filter(Boolean)
`).then(results => {
let tags = [...results].filter(Boolean)
})
hmm
thats better
lemme try it
Hey weird question but not sure if this goes here.
I use the Remote development extension on VSCode for connecting over SSH to my server to edit files and code, however as soon as I save a file using this extension (it seems like), the bot will start replying 3-5 times in one command, however another node instance cant be found in my htop or process list.
Has anyone experienced this before?
did you start them with nodemon or something like this?
maybe a login loop?
i could understand it could be a ssh issue if you get 2 instances running but 3-5 sounds like a duplicated login
its strange because even if I dont start the bot or even change anything, it still happens
if you run it without the remote development it just starts 1 instance?
Hello, i have a little issue with my discord bot: after some time, my bot user goes offline while no issue is reported by visual studio code... Can someone help me ? (I'd rather to discuss in dm)
It seems like so @lusty quest
thats strange
But then again could be my VSCode install, is there any way to see what it's using for commands?
maybe but idk
Yeah it just did it again, must be the way it saves files
it has to be this extension
no other way I can think of it
font registering isnt working for some reason
Canvas.registerFont('BebasNeue-Regular.ttf', {family: 'Sans Serif'})
im getting the couldnt load font err
bot.on("message", message => {
if (message.channel instanceof Discord.DMChannel)
return;
let args = message.content.substring(PREFIX.length).split(" ");
switch (args[0]) {
case `help`:
message.channel.send("help")
break;
)}
}```
PREFIX = "-"
but it responds to other prefixes like
?
add something like this ```
if (message.content.indexOf(prefix) !== 0) return;
you are only checking the length
aaaaaaaa
nice switch/case
i have a hard time explaining things
Canvas.registerFont('BebasNeue-Regular.ttf', {family: 'Sans Serif'})
hep
show full error
i need a api for a random cat image
thx
(process:25904): Pango-WARNING **: 18:08:22.528: couldn't load font "Bebas Neue Not-Rotated 50px", falling back to "Sans Not-Rotated 50px", expect ugly output.
@quartz kindle
x)
yo
is the font in the same folder as your bot?
Why do people always ping Tim?
it did not work for this code @misty sigil
cuz tim is good
client.on("message", async(message) => {
const command = message.content.toLowerCase();
if(command === Prefix + 'cat') {
let msg = await message.channel.send("**Fetching...**");
fetch('https://aws.random.cat/meow')
.then(res => res.json())
.then(json => {
let embed = new Discord.MessageEmbed()
.setTitle(json.title)
.setImage(json.url)
.setFooter(`Link: ${json.postLink} | Subreddit: ${json.subreddit}`)
msg.edit(embed)
}) //this is for ending the .then code
}
});
ye
@misty sigil
But still you shouldn't randomly ping people tho
its not a reddit thing
did you even look at it's output?
it outputs
{"file":"https:\/\/purr.objects-us-east-1.dream.io\/i\/O376H.png"}
thats your code problem
o ok
you dont have a title and only a file key that contains the url
that error is not even from there
:o
@pure lion show code
it worked in my other project
i see why
the ttf was moved too
you need to load it before creating the canvas
oooooooooooooooooo
@pure lion
also, you set the family as Sans Serif but you used "Bebas Neue" in code
could someone help me please ?
tell us what you need help with
anyone know a place to host a bot or should I just keep self hosting
free or paid?
either works
vps
get a vps
from where
anywhere
digitalocean as example
ok
thats not bad
yea
amazon aws / google also offers vps (both need a valid credit card)
doesnt aws have a free vps?
Hmm
nothing to expensive
Ye ok.
Any idea why my botstats command sais this:
Process memory: 88.28MB
But in the panel it shows that it only uses 28 MB ram?
what panel
i have also differences between PM2 and the command
pte panel
let processMemory = 0;
let used = process.memoryUsage();
for (let key in used) {
processMemory += Math.round(used[key] / 1024 / 1024 * 100) / 100;
}
This is how I'm calculation the memory
hi discord bot list famly
thats wrong lol
tell us what you need help with
@misty sigil my bot goes offline for no reason and in VSC everything is like if it's running correctly
oh
you're not supposed to join all the memory usage
oh
they represent different things
what do I do then?
pm2 reports me 90MB while my command reports 250MB.
.rss would be the most accurate measurement on linux and non-swapped systems
.heapUsed is the memory your actual code and libs are using, without counting node.js and the process itself
in most cases .rss is good enough
except in weird situations when rss gets swapped out
so process.rss
process.memoryUsage().rss
you are use 25 ram
@lusty quest how does your command report it?
i used the os-utils package
const mem = Math.floor(os.freemem())+"/"+Math.floor(os.totalmem());
yes
rip
the downside if you lurk around stack overflow and dont check the age
and kernel, and os, and shit, hence why its much higher than what pm2 reports
It's funny how my bot's CPU usage spikes up to like 20% when doing botstats command but my dungeon command only uses like 1-2% CPU
okay so does anyone know which is faster?
guild.members.fetch({ user: "123" })
// fetch one member, open to errors (which i can catch and handle but still
guild.members.fetch({ user: ["123"] })
// fetch one member, returns an empty collection if not found instead of erroring
I don't think there's really a difference but maybe like a 0.001 second difference
Like you're not gonna notice it
it's also the answer that error on line 32
Lol
I mean if wasn't saving for a PC I'd prob get it for at least a month lmao
interestening process.memoryUsage().rss returns 0 while process.memoryUsage() returns 170MB used Vs Pm2 reporting 80MB
Tim already helps all programming issues
lol
yea found the issue
from my tests not really
Oh btw the font thing works now thanks Tim and flaz
the gateway should be slightly faster
but discord.js uses the rest endpoint by default when doing .members.fetch(id)
I keep on getting errors "../config.json") I keep on changing the quantity of “.” But it is still not working
they must have a reason for that
@marble scaffold show me your file structure/code
fs.readdir('./commands/', (err, files) => {
if(err) return console.error(err);
console.log(files.join(' '));
for (const file of files) {
const command = require(./${files}/${file})
client.commands.set(command.name, command);
console.log(./commands/${file})
}
Error: Cannot find module './classic,gambling,ping.js/classic'
classic and gambling are folder ping.js is a file
i am not sure how to fix this error
Always use /
files is an array of files, ["a.js", "b.js"]
Dont use commas
yo, question
right
Does anyone know how to fix this? I added my bot scripts and folders and stuff to github and then to Heroku. Everything works when i run it there except one thing
msg1 = message.content.toLowerCase()
if(msg1.startsWith (`${prefix}stonks`)) {
message.channel.send ('Who said Stonks?', {files:['./assets/Stonks/stonks.png']} )
}
}`)``` thats the script. The thing that does not work is that my picture doesent exist when it starts in heroku. Its the exact same files except its in a github folder instead of on my desktop. If anyone would know pls help! The error is the error is ```(node:4) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, stat './Assets/Stonks/stonks.png'```
can i do functions inside classes?
aren't those methods?
/classic,gambling/ping.js is not a valid path
unless you have a folder named "classic,gambling"
then the answer is obvious
the error is (node:4) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, stat './Assets/Stonks/stonks.png'
i tried replacing the first files with commands
but it still didn't work because of classic,gambling
@quartz kindle Can you add me real fast?
/**
* Does Something.
*/
be: (something: string, message: string + function a() {}) => Promise<any>;
adding a function in the middle of a class is fine?
i need like helpp rn plz doesent anyone know
path error, likely
hm
@opal plank it does
code?
client.commands = new Discord.Collection();
fs.readdir('./commands/', (err, files) => {
if(err) return console.error(err);
console.log(files.join(' '));
for (const file of files) {
const command = require(./commands/${file})
client.commands.set(command.name, command);
console.log(./commands/${file})
} @opal plank
code blocks
client.commands = new Discord.Collection();
fs.readdir('./commands/', (err, files) => {
if(err) return console.error(err);
console.log(files.join(' '));
for (const file of files) {
const command = require(`./commands/${file}`)
client.commands.set(command.name, command);
console.log(`./commands/${file}`)
} ```
let dir = './commands'
readdirSync(dir).forEach(sub => {
const commands = readdirSync(`${dir}${sep}${sub}${sep}`).filter(f=> f.endsWith(".js"));
for (const file of commands) {
const call = require(`${dir}/${sub}/${file}`);
//rest here
sep sub sep lmao
okay
nice
wat wit wit wat
trying to think of a clever way to change a method in a class extension to bypass something
without having to add it myself in every call
developers that have 100 users or more on their bot, how did you do it?
say: (maybeChannel: string, message: string, ...messageArgs: string[]) => Promise<any>;```
what i was thinking of would be doing a function onto message: string + function() {
generates between 1 and 10 CharCode 8203
}
then append it in the end
its basically a cheap bypass to repeated messages to prevent blockage with spam flags
i dont get it
say() => method
param message is a string
client.say('this') => message = 'this'
what i was trying to do is
instead of
client.say('this' + N char8203)
was change the method to append it for me
how are you extending it?
im not, im hardcoding it
you're not doing a class extension?
im changing it on the declaration instead of extending
declare class Chat extends EventEmitter<EventTypes>
well, thats what i was trying to do at least
not sure thats a good approach now
the say method belongs to event emitter?
or to the chat class?
i mean, i dont even use ts
if i was already extending something, i'd just add it there, otherwise i'd add it to the prototype
hmmm not sure i get it
show your code
technically not mine, im patching it, here here it is
cropping it due to length
what im trying is patch that say method to append those extra chars before it gets sent out
pretty sure you cant do anything on declaration
you have to change it in the actual extension
hmmm thats gonna be a pain, but i think i can pull it off
yeah the declarations file wont do
it needs to be the actual index file
if you wanna extend it yourself: ```js
class newChat extends Chat {
say(channel,message,messageArgs) {
return super.say(channel,message + "hue",messageArgs)
}
}
but then you need to make sure the extended class is used everywhere instead of the original.
if you cant guarantee that, you can hack the prototype





