#development
1 messages ยท Page 331 of 1
really
yes
is that what it says
do you need to register them in events
@shrewd field please your code inside a pastebin, WITHOUT the token.
Paste the pastebin
hastebin > pastebin : ^)
server
.addBlankField(true)```
i don't remember that being a thing
it is a thing
It's a thing
oh
it is
it is a thing
Essentially zws'es for field name and body
huh
Those comments tho
ya
/*``
- Takes a Date object, defaults to current date.
*/
Change that to '// Takes a Date object, defaults to current date.'
Change those const embed things to var embed = new Discord.RichEmbed()
yeah? nvm then
no
๐คข
Welcome to 24/7 Deni tech support help
Why don't you guys help him then
what's the issue again
http://prntscr.com/gwlqwv I think
too many listeners
yes, it's obvious he has a listener per command
nope
if you don't have multiple of the same listener, just ignore it
ok
is there a way to dynamically check what version of discord.js is being used?
dynamically 
require('discord.js').version, but I wouldn't run that on each command call
hmm
have it as a variable outside of your export function/class/module
perfect, thanks!
hey i have pm2 installed and i am wondering how can i make a restart command
have a command what process.exit() is enough since pm2 will auto restart
they mean
use your brain
"have a command what process.exit() is enough since pm2 will auto restart"
this is what they mean
no
why
because you can just do what i told you and has also everything you need to use goole at the same time
heh
make a command that does process.exit() then pm2 will handle restarts for you
^
like this
if(message.content === "restart" ) {
message.channel.send("restarting")
.then(process.exit)```
try it
this is what u mean
shrug
ok i will
Do
try it
worst case scenario your PC will blow up
honestly development is mostly test driven
Lol
huhu
you make something, you test it
i wont then
It was a joke....
So just run that shit
Nothing is going to happen
You only see a error message
if it's wrong then
i did it and i got restarting
Did it process.exit
i can give you a snipped of code what will delete your whole hard drive when executed in js 
have you set up pm2 to do restarts or does it do it automatically @restive silo
no it should auto restart
how
hasPermission 
ikr
you may also wanna limit that command to you only
if(message.content === "restart" ) {
message.channel.send("restarting").then(message => {
process.exit()
})
Try that
Was thinking about a private bot
k
tb!uptime
...
Commands only work inside #commands and #265156322012561408
now what might thta error be
Then put
it literally tells you the line
A )
where you're missing a bracket
it literally tells you the line <---
Ye
lol
And also yes hats pm2
pm2 autorestarts when process.exit is used
Just copy and paste it code from above
Learn js pls
i know js
i know
I don't wanna spoon-feed you
u didnt get what i mean
I recommend learning a language before making a discord bot in it
i have pm2
how can i use it in making process.exit
because i have process.exit for a shutdown command
And I'm telling you if you know js then why is discord.js hard
you know you don't need to send every message in an embed right
Making it all in an embed doesn't look that good
^
I learned that the hard way
Why do you use .then?
Can't you do send message, and then process.exit?
Or is that to fast?
also you maybe wanna make sure the message is sent before killing the client
OK
await it or just use the .then() callback
Or just add a cooldown
You can set a timeout on it to
ok thanks
what cooldown eww
setTimeout(() => {
// command here
}, 2500);
@grave sonnet
@fleet lodge
@sturdy jewel
Ye
just learn how to use promises and there callbacks/await instead adding delays everywhere
Turtlebot is the only one who will stay
delays are the most eww
It's just an option
Quick question
ask away i guess
How do you like make the commands of the bot in a list on the website
Like when writing
an websocket module like express
edit the description
html lists
But it comes out like a paragraph
oh
Forgot totally about that
yea edit the description you can even use html/css and stuff
i think i did it
i did what this says
function win(positions, num) {
console.log("win: " + JSON.stringify(positions) + " (" + (Date.now() - start) + "ms)");
}
var start = Date.now();
for (var col = 0; col < board.length; col++) {
for (var row = 0; row < board[col].length; row++) {
if (board[col][row] !== 0) {
if (board[col][row + 1] !== 0 && board[col][row + 1] === board[col][row]) {
if (board[col][row + 2] !== 0 && board[col][row + 2] === board[col][row + 1]) {
if (board[col][row + 3] !== 0 && board[col][row + 3] === board[col][row + 2]) {
win([[col, row], [col, row + 1], [col, row + 2], [col, row + 3]], board[col][row]);
}
}
}
} else if (board[col][row] !== 0) {
if (board[col + 1] && board[col + 1][row] !== 0 && board[col + 1][row] === board[col][row]) {
if (board[col + 2] && board[col + 2][row] !== 0 && board[col + 2][row] === board[col][row + 1]) {
if (board[col + 3] && board[col + 3][row] !== 0 && board[col + 3][row] === board[col][row + 2]) {
win([[col, row], [col + 1, row], [col + 2, row], [col + 3, row]], board[col][row]);
}
}
}
} else if (board[col][row] !== 0) {
if (board[col + 1] && board[col + 1][row + 1] && board[col + 1][row + 1] !== 0 && board[col + 1][row + 1] === board[col][row]) {
if (board[col + 2] && board[col + 2][row + 2] && board[col + 2][row + 2] !== 0 && board[col + 2][row + 2] === board[col + 1][row + 1]) {
if (board[col + 3] && board[col + 3][row + 3] && board[col + 3][row + 3] !== 0 && board[col + 3][row + 3] === board[col + 2][row + 2]) {
win([[col, row], [col + 1, row + 1], [col + 2, row + 2], [col + 3, row + 3]], board[col][row]);
}
}
}
}
}
}```
connect 4 game win logic if anyone wants it
oh god lmao
lmao
eww
lol
Thonk
lul
Anyone mind helping me?
dude
really
you should be able to use google for that if you wanna call you a "programmer"
._.
How to use a vps: See how to use a command line
How can I loop all guilds and check if they have more then 10 bots?
which lang/libary?
javascript / discord.js
use the filter method for collections and then check the size of the result collection something like ```js
<CollectionOfGuilds>.filter(g => g.members.filter(member => member.user.bot).size >= 10)
on phone pls excuse
client.guilds.filter(guild => guild.members.filter(member => member.user.bot) > 10)
rip
Thanks
you can loop through that collection of guilds with more than 10 bots with an forEach
wat
the code above returns a collection with all guilds with 10+ bots
you can use a forEach on the returned collection
yeah, I need to forEach them right?
if you wanna loop them, yes
depending on what you are doing you could maybe also use map
hmm i guess a map could work there 
@restive silo
why ping 
guild.forEach(function(guild) {
}, this);
}```
what
I'm doing something wrong
Do I first need to loop it and then filter it?
But then it's says this: guild is not defined
client.guilds.filter(guild => guild.members.filter(member => member.user.bot) > 10).forEach(guild => {
//code here
})
Thanks
don't need them in the forEach either, depending on what you're doing
i told that already
368293214530306050
depending on what you are doing you could maybe also use map
๐
was talking about curlies
no
you just dont need any {} there
(only in the forEach needed)
How do I edit my bots message? message.edit?
Cannot edit a message authored by another user
It tries to edit the message that was sended by the user, not the bot
you need to send the message, await the promise (async/await or use .then) and then edit that
message.channel.send('test').then(message.edit('test2'))
because it resolves the promise with the bot's message
nope
you'll want to use a function in there
.then(function(newmessage) {
// do stuff with newmessage
})
function in .then?
okay
Thonk
Was thinking about PHP
make a bot in php
Nah
How do u find roles that includes a name? In discord.js
I mean find all
ah, well you'd probably need some sort of for statement, or map all roles
then iterate through them to find all matching keys
iterate*
Find all roles that includes a sign, ex "$" sends rolea with "$"
how do you wnna handle all of them roles
I want to send a message with the roleS that have a "$"
No
it's definitely doable and shouldn't be hard
but you might encounter guilds where there are so many roles that they do not fit in the character limit
Yea but i made a cmd that is only usable on my server
is this only intended for you?
And thts why i need it to list roles with $
this example uses string concatenation so it may be extremely inefficient and "bad practise"
- Get a collection of all roles that start with $ (Ken showed you how I think)
- Declare a "roles" variable and set it to an empty string
- Iterate (loop) through the collection on each iteration:
roles += role.name + '\n' // presuming this is how you get a role name in JS - You now have a string "list" of roles.
- Check if roles is empty, if it is, assign it to something like "No roles found". Also check if it's longer than > 2000 chars. If it is, then assign it to something like "Too many roles"
- Send roles to the current text channel
@earnest phoenix
K, but who is ken?
K
var roles = message.guild.roles(find out what the object is exactly);
var toSend = "**Roles with $:**\n";
for(var role in roles){
if(role.name.toLowerCase().includes(/([$])/g))
toSend += "Role: " + role.name + " - Colour: " +role.colour + "\n";
}
message.channel.send(toSend);
Obviously it's untested but the idea is obviously there, you'd need to check what message.guild.roles; returns in json object
K
just a little social hint
"K" often seems a little disprespectful especially when someone just send you a block of code
ahh right
well people often use K or OK like
"right I didn't understand anything whatever lemme just copy and paste"
Read 20:23
Is it possible to give someone a rule by using args? (Example: !getrole Rolename) instead of mention?
*role
yes
Cuz when i use args.join(' ') it says its not a role or snowflake
what lib
Discord.js
it needs to be a role resolvable
const role = <message>.guild.roles.find('name', <roleName>)
uhm, no, what you just said needs a name specifically
he could replace <roleName> with args.join(' ') but Idk how well that works kek
So that means thw only say is either specific or mention?
no
*way
if you want to add the role to the person who did the command just do <message>.member.addRole(role)
Yea but i want to find a role by args instead of mention
And someone said it isn't possible
it is
Ok do you know how? When i type rolename it just says its not a role or snowflake
Lizards solution should work
Ok ill see if it works
<message>.guild.roles.find(role => role.name.toLowerCase() === args.join(' ')) could also work if you don't want it to be case sensitive
It works thanks
Real quick what content-type does the sever count API take?
application/json
@timber jungle 
@trail wing
@round bramble
Hm
-bots
@acoustic sonnet
Ughhh
๐คฃ am sorry mods.
I'm so used to going to dev for this
It's a bad habbit
quick question
why doesnt this work
if(banmember.highestRole.position >= bot.highestRole.position) return message.channel.send("I do not have the proper perms to ban this member, move me up in rank to do this");
let banmember = message.guild.members.get(message.mentions.users.first().id);
@earnest phoenix
i wanna check if the person they wanna ban has a higher role than the bot
ik but thats besides the pont
Ye sorry
But idk why it does not know in one of my codes i wrpte this ```if(toMute.highestRole.position >= message.member.highestRole.position) return message.channel.sendMessage("Yutz this person has a higher role");``
But
but thats for checking if the member has a higher role than the mute person
Id recommend u this: ```if (!message.guild.member(banmember).bannable) return message.reply("I can't ban this person!")
Thats if the user is not bannable meaninh they cannot be banned it works if the guybhas righer role
0|TurtleBo | DiscordAPIError: Privilege is too low...
0|TurtleBo | at item.request.gen.end (/root/Bot/TurtleBot/node_modules/discord.js/src/client/rest/RequestHandlers/Sequential.js:68:65)
0|TurtleBo | at then (/root/Bot/TurtleBot/node_modules/snekfetch/src/index.js:257:21)
0|TurtleBo | at <anonymous>
0|TurtleBo | at process._tickDomainCallback (internal/process/next_tick.js:228:7)
0|TurtleBo | Uncaught Promise Error:
0|TurtleBo | DiscordAPIError: Privilege is too low...
0|TurtleBo | at item.request.gen.end (/root/Bot/TurtleBot/node_modules/discord.js/src/client/rest/RequestHandlers/Sequential.js:68:65)
0|TurtleBo | at then (/root/Bot/TurtleBot/node_modules/snekfetch/src/index.js:257:21)
0|TurtleBo | at <anonymous>
0|TurtleBo | at process._tickDomainCallback (internal/process/next_tick.js:228:7)
cause it kept giving me that
havent tried the code yet
but i asked since i wanted to stop this
Heres woth the code i wrote
That means user has higjer role than the bot
Fucking android lags like its running battlefield 1 with 2gb ram
@topaz fjord
it worked ty ๐
ye
How do I count all users with shards? discord.js / javascript
for(var guild of client.guilds.array()){
count += guild.memberCount
}```
Why not?
it doesn't really provide the function to get the shard id afaik
and 1. it's fun to write your own and 2. you know how it works
- I don't know how to write one.
i'll give you mine
yes
const cluster = require("cluster");
const workers = 2;
if (cluster.isMaster) {
var running = {};
for (let i = 0; i < workers; i++) {
cluster.fork({firstShardID: i, maxShards: workers});
};
cluster.on('fork', function(shard) {
shard.on('message', msg => {
if (msg.type == 'alive') {
running[shard.process.pid] = msg.id;
}
});
shard.on('exit', (code, signal) => {
cluster.fork({ firstShardID: running[shard.process.pid], maxShards: workers });
});
});
} else {
... code ...
// to get the shard id, do:
process.env.firstShardID
// shard count is:
process.env.maxShards
this is mine stripped of all of its bells and whistles
obviously your code is there, and the if block is closed correctly
@neon pasture
you can fetch client values with d.js
shard manager?
Already did that with guild.size
then u can do the same thing and client.guilds.reduce((p, c) => p + c.memberCount, 0)
Though I havent used d.js with sharding in months
const guildsizes = result.reduce((prev, val) => prev + val, 0)
})```
swepy
yes?
if you're going to use my shard manager then you'll need to put it in your main file.
and then you just use client.guilds.size (like in a normal non-sharded bot)
So that piece of code inside index.js right?
also hang on
yeah
but you need to do something else
new Discord.Client({shardId: process.env.shardId, shardCount: process.env.maxShards});
Is this good?
no.
I didn't change anything
you need to use the new Discord.Client() line i just posted
oh.
then no it's really not good
That's from the discord.js shard manager
And on the last line you have this: else {
i don't know how d.js' shard manager works
but there is nothing
?
} else {
... code ...
I did
const client = new Discord.Client({shardId: process.env.shardId, shardCount: process.env.maxShards});
yes
above, okay
and then at the bottom of your code put }
because then that ends the block
so it should be
yes
start it now
without the sharder.js right?
The shardCount option must be a number.
wut, where?
in the new Discord.Client()]
The shardId option must be a number.
That's the error
/pepebot/node_modules/discord.js/src/client/Client.js:506
throw new TypeError('The shardId option must be a number.');
^
TypeError: The shardId option must be a number.
at Client._validateOptions (/pepebot/node_modules/discord.js/src/client/Client.js:506:13)
at new Client (/pepebot/node_modules/discord.js/src/client/Client.js:37:10)
at Object.<anonymous> (/pepebot/index.js:22:16)
at Module._compile (module.js:624:30)
at Object.Module._extensions..js (module.js:635:10)
at Module.load (module.js:545:32)
at tryModuleLoad (module.js:508:12)
at Function.Module._load (module.js:500:3)
at Function.Module.runMain (module.js:665:10)
at startup (bootstrap_node.js:187:16)
yeah, i know.
you need to go back to how it was
where it threw shardCount errors
did that
now you see the two process.env.shard[whatever] bits
I don't see them
in new Discord.Client
where?
const client = new Discord.Client({shardId: parseInt(process.env.[blah]), shardCount: parseInt(process.env.[blah])});
with []
run it?
The shardId option must be a number.
and you did parseInt(process.env.shardId)
const client = new Discord.Client({shardId: parseInt(process.env.shardId), shardCount: parseInt(process.env.maxShards)});
and it's throwing that error?
yes
then i recommend you go and talk to d.js in discord-api
because that should work.
sounds like a bug on their end
Okay, thanks for your help ๐
no problem.
if you still get issues, try switching to eris
it's a bit more complicated but when you get the hang of it it's like butter
Going to rewrite to eris

Said that to my self 2 weeks ago
the thing with the shard manager is that it's written with eris in mind
so d.js is fucking up somewhere
works fine for eris
But eris has a buildin shard system right?
Someone told me it was just one line
eris is just a library for making discord bots with sharding support
you write the shard manager yourself
okay.
Hey
Hi
how can i make pm2 to auto restart
My b0t
Bot
Is it like this
If(command === "restart") {
message.reply("restarting" .then(process.exit) .then (pm2 autorestart) });```
u just need the .then statement for process.exit
How do u restart ur bot with node
process.exit and then apparently pm2 will handle it ^^^^
google.com knows
Where can i get it
techically its like node bot.js but
the bot runs when the cmd terminal is closed
but pc has to be on
I use android as host
oh
Even if i dont use my phone
i use a vps
But i have to leave screen on otherwise it loses internet
ok
rip
Should I make it so that some services of my bot cost DCN (Its currency) or should I have it so music is SQ and to get HQ audio it costs X amount of DCN?
guys
@cerulean zinc how does one obtain DCN
i am locally running my bot but
it doesnt seem to appear online and i dont get any errors
Is it in Invisible mode?
yes
Thats why
๐คฆ
imo that sounds reasonable ye, make some services paid
i use node bot.js
and then also make a site where people can manually buy DCN if they're too lazy
is the token correct
yes
are you getting any logging messages
how do i show the logs
you paste the console output (if there is any)
What lib is your bot?
did you log in the bot?
yes
it was working but suddenly it stopped
i was using pm2 start -watch
and kept it working then it suddunly stopped
oh well idk how to help with pm2 sorry
i will try to get any previous screenshots of any logging that i have
Maybe ask the help channel for your lib in Discord API
You just run pm2 start mybot.js --watch
how defuq can you get a syntex error then?
vs code it for C#

@median lintel no
thats VS
not VSC
Visual Studio is not Visual Studios code
that are 2 programms

i have vsc
Anyone know how to resample audio in ffmpeg and have it play at 48K for discord still?
@shrewd field Install the ESLint extension
then that wont happen
iirc VSC already alerts you when you're missing a )
@restive silo Check your dms
@sinful meadow wrong channel
how?
this is dev
Ik
not general
but what you said does not relate to development
also, stop telling people to check dm's, if they cared enough, they would reply in DM
incoming stupid question: when we upload info to the discordbots.org api what is the token that we have to include in the header? is that our bot's token?
just asking before i go throwing my bot's token all willy nilly 
The discordbots API token is not your bots token, it's a different one generated by discordbots.org
At the bottom of the API page, 'Select a bot to see the token'
No problem
Do you guys know in js if its possible to end an argument? Like for ex if i wirte "a b" then the b will not be included in the args? Soz if its hard to understand i sux at explaining
well you could do "a b".replace("b","");
probably a better way of doing it but ye
Cuz im making a create role cmd, and the name & color gets included
Instead of only one of em
yeah now you got me lost
If i do "args.slice" it then skips the first thing but on the first thing i have args.join
So if i write name: dd color: red output comes "dd red" as name
why not just
//newrole <name> <colour>
that way all you gotta do is
//newrole New_Role_Name BLUE
๐
well then if someone doesn't add colour? just ignore it?
nobody wants to write an entire name: soguhasoeughaoue colour: oaughseoguaeh
thats so much effort
and it makes it harder for you
And i also have a cmd called "rolecolor" which chabges the role color of a role but i wanna do it withoutbhaving to mention a role
Makes sense
then how are you going to change a roles colour without specifying what role?
I just used "name" the cmd add someone to a role works without mentioning it
Omg my keyboard is pure shit
Its hard to explain but if i have 2 args.join in my code, one is supposted tp ignore the other one that comes after the first onw
๐
Idk how to explain it
Hi help me for java script start my bot
the bot is open source
lmao

ibn4 its not his bot
but i don't understand
then download the bot
i think ๐ ....
because its not yours
after have a discord server to "be used as the modmail inbox"
i have completed config.example.json with token and id
then open command prompt
this ?
aahh cmd ?
yes type in cmd
it opened?
yes
go to the directory u downloaded the bot from
no
yes and after ? ๐ฎ
invite the bot to a server
it's craaazy
eris just fucking up
how ?
idk
It's what eris ?
eris is library for the bot
Ohhh ๐ฎ
idk ask someone else
So the bot can not work?
How do I fix the Error: Still spawning shards?
You're probably doing something on ready that requires all clients to be ready
I send the server_count to the discordbots API
@tawny lava you must get first the invite Object you can do that with <Client>.fetchInvite() (it returns a promise btw) and then it resolves with an invite object what has a guild property (normal Guild or PartialGuild)
np 
wrong.
any1 got a code to post a random picture
Yes, but I tried to add this https://please-fuck.me/1fb20a.png..
everytime you post the command it posts a random picture?
oh you need to put it in an event @earnest phoenix
you defined that outside, im pretty sure
@restive silo Oh, ๐ฆ .. I need to make a event.. Uh
Yeah, I did.
like guild create
or guild delet
I know where to put it!
^
wat
How do I use options when I register a new command?
hmmm should i put my bot back on this list?
its alot better, more fetures and i think i fixed the issue of why console got spammed when it got here.
Jeffrey are you using commando?
thumbnail: {
thumbnail_url: 'image'
}
Is there a way to add a thumbnail to an rich embed?
yes
is the image a url
yes
Thank you
@neon pasture that means you're using bot.shard.broadcastEval or bot.shard.fetchClientValues before all shards have finished spawning
For that error: Still spawning shards
I used to get the same error, but I fixed it
I fixed the problem
ok
yeah
ready doesn't mean all shards are done, sadly :/
I wish that was a feature
That would be cool
I'll suggest it in an issue on gh
console.log('all shards are launched.')
lol
xd
@neon pasture https://github.com/hydrabolt/discord.js/issues/2031
sharing manager, isn't it sharding manager?
typo
Nice
hey
hey
i have something i opened my bot today and i wrote this and it kept giving me the loading bar and no result
what does this mean
anyone
hey my code
read the error message
what it means
"something took too long to do"
what is the something
any1 got a code when the bot is added to the guild it gives you a message
@uncut slate?
nvm i got it
With?
I have something i opened my bot today and i wrote this and it kept giving me the loading bar and no result
http://prntscr.com/gxeq39
Lightshot
Screenshot
what does this mean
anyone
hey my code
https://github.com/Deniernal354/discordapp-heroku/blob/master/mybot.js
if you search it up theres something online
@shrewd field maybe if you try searching online
we won't always be able to help you
be smart and google it yourself
also "Something took too long to do." means you tried to use a promise but it didn't return anything back within the max amount of time
@shrewd field you are sharing the bot token '-'
in the github
i used heroku cli
to host
eww
Oh god he leaked his token lmao bad
Guys do you know in js how to get uptime by minutes?
math
@earnest phoenix you can do: var botuptime = bot.uptime; x = botuptime / 1000 seconds = Math.round(x % 60) x /= 60 minutes = Math.round(x % 60) x /= 60 hours = Math.round(x % 24) var uptime = hours + ' hours, ' + minutes + ' minutes and ' + seconds + ' seconds.'
But it comes with dots
u dont just
dont use var 
yea but YOU DONT HAVE TO USE FUCKING MILIONS IF YOU CAN DO THAT YOURSELF WITH 1 FUCKING FUNCTION
Jeez
Lol wut
Humanize-duration is nice.
very nice its sexy
well but if you only need the format in 1 thing you dont have to use a dependency tbh
its 1 fucking function
In my eyes it offers way more than a simple milliseconds to days+hours+min+s or whatever, it offers different styles or writing, languages and everything
with 10 lines of codes
hmm 
point is, I get where you're coming from
I wouldn't recommend HD for parsing uptime, way better in dd:hh:mm:ss
it is a useful lib, but I wouldn't use it for bot uptime
i recommend it for how much weeks of free memory you have 
๐ค
its dam usefull but if you use it 1 time only for uptime and can do that yourself with 1 function its just not needed at all
ยฏ_(ใ)_/ยฏ
ye
How is giving away code considered spoon feeding?
instead of learning how to code, they just take the code and plop it in
that's not helping
How is it not considered spoon feeding?
Ok
@earnest phoenix Who even are you do you even know how to code?
Im learning how to
Mkay
And to answer your question @earnest phoenix Deni has been constantly asking and pinging people in this channel for tiny little things that are clearly explained in the docs
Its ok to ask for help but if you are pinging people everyone 1 minute for it then no
What?
Deni has been constantly annoying people in this channel with lack of common sense and pings
What more can i explain? @earnest phoenix
@wide totem ?
Shard 9/11 oh god
If so, you need to go to their support server or ask the owner
We cant help you
i see 2/11

For support on that bot, find their support server




