#development
1 messages ยท Page 345 of 1
mhm
const channel = guild.channels.find(c=> c.permissionsFor(guild.me).has("SEND_MESSAGES"));```
Hey guys?
How do I make custom VCS errors that end the process
Or well
How can I end the process from within the code
Np
@earnest phoenix Again, we aren't google
how about you actually try, and google it yourself
Boi, whenever I google something
It comes up random form threads
That literally arent helpful in the slightest
I do try :/
@earnest phoenix just ignore him thats why this channel exsist to help people
not be a fucking douche and say Look it up
๐
@sinful meadow tbh this is simple shit, we don't need to spoonfeed everything
mayo
what Yes?
if ur not here to help, just go away.
Thanks @rich kiln Like no joke
๐ค
@earnest phoenix next time check nodejs docs
๐ค
Hahah
nice ping
and no
๐ค
@rich kiln
Wait
There are node.js docs?!
OML
Thank you for telling me this lol
@earnest phoenix plz stop
@sinful meadow cancerous ppl are like this
@rich kiln yep
@The Darkness Soldier#1418 also use mdn
const snekfetch = require('snekfetch');
const Discord = require('discord.js')
module.exports = async(bot, guild) => {
const channel = bot.channels.get('364584124540911619');
const embed = new Discord.RichEmbed()
.setAuthor("Lost Guild", bot.user.avatarURL)
.setColor("RANDOM")
.setTimestamp()
.setDescription(`**I have left:** ${guild.name}\n**Owned by:** ${guild.owner.user.tag}\n**With:** ${guild.memberCount} members!`);
channel.send({embed});
}
anyone have an idea
DiscordAPIError: Missing Access
at item.request.gen.end (C:\Users\Sid\Desktop\BobBot\node_modules\discord.js\src\client\rest\RequestHandlers\Sequential.js:71:65)
at then (C:\Users\Sid\Desktop\BobBot\node_modules\discord.js\node_modules\snekfetch\src\index.js:217:21)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)```
I dont think you can get the member count and/or owner when its left
Not sure you have to test
You can
it wont send the message to the channel
Well its missing access to one of the variables thats why
I have my own lil version of that
@topaz fjord debug your code to see which variable is failing
//sexy embed goes here
//client.channels.get("my awesome join-leave logs id").send({embed});
});
``` 
idk for some reason it works outside of function handler but not inside
@topaz fjord DiscordAPIError: Missing Access
the bot doesn't have permission to send to that channel
doesn't have anything to do with variables
and im making the bot leave a testing server
and on the personal server the bot has the highest role
Hey guys?
Hey guys?
What? @earnest phoenix
Yea what is your question?
Okay hold on
Loading Windows 1997....
I just want to know how to fetch a channel from a guild
Using an ID
Similer to fetchMember
Which lib?
d.js
Have you read the docs?
Yes, but I do not know how to refrence it
Oh
No shit xD
Wait
yes
Dont you mean channels
look through all the servers to find a channel that has that id
message.guild.channels.get("ID");
^^^^^^^
How would I then reference said channel?
message.guild.channels.find("name", "channel name")
message.channel
๐
^
My home server
Wow
Okay
Wait
?
Im trying to get messages from every guild
And send them somewhere
So
How would
That would be api abuse
Wait
Wot
api abuse
dont
๐
cough cough DB logging
deletes entire code
Okay well thank you for telling me that
Lol
Hey guys?
Hi @earnest phoenix
Yes @earnest phoenix
Sure
setTimeout()
nope
Exit is a var
Oh
Rip
Okay from the MDN docs
It says Ill need to create a function
Okay thank you ill try to work at this ๐
Wait
How do I reference the base studio?
Hm
?????
Like
In the MDN
It uses window
But
This isnt a website
Lemme put it like this
The object that the code is run on
So I suppose node 
let exit;
function exitProcess() {
exit = node.setTimeout(exitProcessMain, 2000)
}
function exitProcessMain() {
process.exit(1);
}
client.on("message", (message) => {
if (message.content === '---shutdown' && message.author.id === '376147022660632587') {
exitProcess()
} else if (message.content === '---shutdown' && !message.author.id === '376147022660632587') {
message.channel.send('Only the bot owner may use this command!')
}
});
According to the docs this should work
Nvm
Node isnt defined
Maybe I need a variable defining node
const node = new Node.Client;
Trial and error
I have done it!
Anyone know how you can send Clyde-style pm's within a channel ?
Like, "This message is only visible by you - Delete this message?" thing
ah rip I thought so
How do I create a role with discord.js? And when I have created the role how do I edit it?
Oh. Didn't even see that. Lol thanks!
wait until the Promise resolves and then get the resolved Message object and edit it
use .then() or async/await
await or gtfo
lol
Were awaiting to gtfo
Is it
(statement === true) ? true : false
OR
(statement === true) ? false : true
dont know
oh kk
ty โค
is client.users.size accurate? it doesn't seem to show the right number of users
I mean it displays 4.5k users while this server alone has over 6k
That is the whole bot together @ornate shadow
client.users.size returns the size of all the cached users
Idk
xD
you cant
damn
It updates by itself
rofl
so I guess there's no other way to display the actual member size
user*
and gotta stick with that
the bot ofc
Yea idk a way
basically I wanna get the sum of all the users of all the servers the bot is currently in
the users of the servers xD
^^^^^^ That is the real number of servers
The bot currently loves ${bot.users.size} users, in ${bot.channels.size} channels of ${bot.guilds.size} guilds.
this is my string
xD
That looks fine
well it's inaccurate though :-<
Yep
well thx for cutting my research time I guess ๐
loop through servers and add the users of guilds?
let shite = 0;
client.guilds.forEach(e =>{
shite = e.members.size + e.members.size
})
dont know
that probs wont work
xD
i just threw it together
yeah idk either
but it will surely use more computing power than the standard innacurate one (we have no guarantee it will work either)
x d
How do I make a command that sends a dm to all members of all the guilds the bot is in. Don't worry I won't use it I just want to know the code.
I can't seem to figure it out.
^
Why do you want the code if you won't use it ๐ค

lol
whoops wrong channel
two questions:
how do i lock commands to upvoters/supporters only
how do i add multilanguage to a bot
i use discord.js and snekfetch
^if you answer them please ping me
@neat falcon
Do you really want to lock a command?
@neat falcon You can use my amazing code ```js
snekfetch.get(https://discordbots.org/api/bots/${client.user.id}/votes)
.set('Authorization',TOKENFUCKER).then(e => {
let test = e.body.find(post => post.id === message.author.id)
if(!test){
}else{
}
});
hmm
i dont think patreon has an api
inb4 i lock all music commands on @prime wharf and @crude ginkgo :^)
ik @karmic lake
inb4 luca is locked to upvotes
It had my token thats why i changed it @karmic lake
Does anybody know if Lavaplayer export his Version Number somewhere 
Lol
Hey guys
Im getting an EventEmitter memory leak error ;-;
How would I go about fixing it?
I tried what it said to do but it said emitter wasnt defined
my visual studio code doesnt showe on discord like
thats custom
How do you even do that?
anybody know how to get atom-discord working?
@quiet bobcat ^
@wooden shoal looking at some of the issues open for that owner says they connect through the rpc server but at no point did i get asked to authorise an rpc app so im guessing owner hasent actually shared the rpc invite and thats why everyone saying it doesnt work
yep I saw that too.. thats annoying
70 downloads and 4 open issues those arent good stats
with all issues saying the same thing in various ways
yep.. And I'm pretty sure he isnt even going to try any further
time to make a fork ๐
lol
would make a fork if i knew anything about rpc or atom extensions...
btw I would too but idk anything about how to make them
and then actually getting the discord rich presence working
the rich presens is just normal presense just with more flags
does atom maybe have a debugger to see if anything made errors :/
guess ill just check the electron console
http://can-you-plz.givemefish.com/files/Z0a5qvj4aZpX.png um? thats not my id
um
nah thats fine
that fatal is fine ish
k
im willing to vouch thats his id
ill change it and try
how tf is it going to automatically change to our ids
shouldt it need our token tho
What happens if u share your id
everyone can see it anyway
lol
Ok
k time to fix his code
oh crap no my sensitive id that everyone can see i shared it ๐
:lenny:
I have lots too
normal boot opens sits on grey fan clocks up goes into notreponding about 3 times then finally opens you see code goes not responding then gets hylighted code
oh lol
i think its teeling me ive got to many addons nah probably not
I bet you his token is in the code somewhere
k
k
idek what he was ding tbh
clearly did not want us to install it through atom
but from where should I install it :/
same thing
hm?
yes it is...
what would I put as the redirect url
lol idek what that is
oh
im stupid
nvm
well idk that id isnt registered to an rpc app so....
yup
btw, do you ever install some npm package but it doesnt actually put it in teh folder
because im trying to npm install electron-packager --save-dev but nothing shows up in teh folder
the*
the node_modules folder?
where did you run the command in the folder?
what it say in console?
says it installed?
well it looks like it
npm install
thats what I did..
you shure your in the same file in cmd as you have open?
i didnt even know that was a thing ๐
This happen again and again with no reason any idea?
shift+right click
ok do npm init then
k
i just get open powershell window here :/
what os? @wooden shoal
you shouldnt normally it will more often than not work without
odd
i mean i says a few errors but other than that it works
it always has errors for me lol
other than the fatals it fine
tru
everything is good except for the bad things
is the folder under a parent npm folder?
hm?
as may have installed to parent folder if so
@sick tide this isnt a bott suport server
This is the server i only found in the website of the bot
ye
also
this is a "channel for chatting about bot development"
oh fuck this
npt bot support
doesnt even look like teh bot is in here
i dont see that bot on luca
whatever this isnt suport anyways
why would you point your bots support server to here like no one here but the dev will have ever heard of that bot...
only a few bots here people know but not like the full list...
ya
http://can-you-plz.givemefish.com/files/v5wkKLcupRKt.png jsut the ones online...
i think a few are having connection issues it keeps going upand down by about 3
I'm wondering if there's a way to change the playing status of a bot. I'm using Discord.Net on btw.
um I know there is with discord.js, and .py, and tons of others, but idk about discord.net
aw rip
actually
Game g = new Game("Lemon Party", GameType.Default,"Gamename");
disClient.SetGame(g);
``` If you run this after initialising your client, then the internet says it should work
i'll try
do you have an on ready in discord.net?
?
like is there a function that runs once the bot has connected
i can make that happen yes
ok put this code in that
right
wat is the best bot for protecting a server from a deranged mod mass kicking/banning?
Cant you inspect
i dont know
I just have it sending a png file
The image loads for me
weird
What do you mean its best to link directly to the file
nevermind
I want Kot here but offline
@app.route("/header.png")
def headerimg():
return send_from_directory("/qwerty/app/static","header.png")```
And ok
also, try removing Css data-react-helmet="true"
from the meta tags
https://upldr.me/f/8MYleJw see if this works
my uploader might serve the file differently or something
embed pls
Done
A non biased and fair discord bot listing site to bring good traffic to your bots!
Dang
Maybe the image is just too large?
YESSSSS
A non biased and fair discord bot listing site to bring good traffic to your bots!
That one must be cached still
The problem was
nice
chill
oh

Uhm how do I get the unicode code of 1โฃ 2โฃ and 3โฃ emoji's?
Yes but to make the bot write it you need to copy the id
And do <1โฃ383929327386886145>
Think that should do it
ohh?
built in discord emojis don't have ids
ah yeah
So just do "1โฃ"
As simple as that
"Unknown emoji"
What
message.channel.send(":one:") that sends a one
and then change it
to whatever
How do I make so if the bot uptime is more than 60 minutes it turns into an hour?
So like if(bot.uptime = 60000) {}
How do I make it so if its more than 60000 ms
it turns into hours
> ๐
Well there's no need for any =
is it if(bot.uptime > 60000)
Oke
if(bot.uptime >= 60000)
Is there any way to do hours and minutes?
Wat
If I do Math.round I will get a round number (duh) but how do I make it so it splits into two

And not just eg 3.22 hours
You have to divide
Isn't that simple math 
Rip
How do I divide it?!
lol
This is what I got so far Math.round(bot.uptime / 600000)
There are 3600000 in an hour so
idk why its 600000
But thats only hours
How do I get the minutes in between
So like 2 hours and 24 minutes
60000ms in a minute
I know
But you cant do Math.round(bot.uptime / 3600000) and Math.round(bot.uptime / 60000)
You can
You have to find out how many minutes are in those hours
Then subtract that
From the minutes thing
What
So like Math.round(bot.uptime / 3600000) and Math.round(bot.uptime / 60000) and then Math.round(bot.uptime - Math.round(bot.uptime / 60000))?
That doesnt look valid
Math.round(bot.uptime / 60000 - bot.uptime / 3600000 * 60)
Will be your minutes
ez math 
oke
Why do I start projects like these tbh it's only good you do the more you learn now the easier it'll to add more stuff like this later on also helps you understand coding in your current lang a lot more
Everyone starts somewhere xD
Yeah I guess
How do I make so if it's under an hour it will post the minutes one and if its over an hour it will post hours and minutes?
Yes
I know that ```javascript
if(bot.uptime >= 60000)then =>(addField("Uptime:", Math.round(bot.uptime / 3600000) + " hours and " + Math.round(bot.uptime / 60000 - bot.uptime / 3600000 * 60) + " minutes"))
if(bot.uptime <= 60000)then =>(addField("Uptime:", Math.round(bot.uptime / 60000) + " minutes"))```
I got those
But I dont know how to use then ๐
If I remove then, then it just says that addField is undefined
What?
I made it work kind of. I now get the problem that it changes to hours after a couple of minutes
fuck, buidlding electron packages is hard
?
Does anyone know how to delete a users ID from a json file database?
Yay that's awesome
ikr
Wolfie.js I wouldn't use json if your bot uses multiple servers
What doge said ^^^^^
@earnest phoenix if you plan on using any sort of simple db use sqlite
Ah, alright man. I'll look into sqlite.
Its stable
Fast and good
Well for small bots its good
Or storing simple things
I mean, I use json databases for my warn, level, custom guild prefixs, and soon for an afk command.
Use sqlite for that
Alright.
How do I cap a value at 60. I did math round to get minutes, and I want to cap them at 60 so they dont go over to like 120 ect
if(value > 60) value = 60
That doesnt work @inner jewel , I cant use if in a .addField
value > 60 ? 60 : value
Ill try that
thanks
I dont know what I did but it removed hours
I had hours and minutes
<i class="fa fa-clipboard" onclick="document.execCommand('copy')" aria-hidden="true"></i>
not working thonk
also this doesn't work either
<i class="fa fa-clipboard" id="toggle" style="cursor: pointer;" onclick="copy()" aria-hidden="$
function copy() {
var copyText = document.getElementById("message");
console.log(copyText);
copyText.select();
document.execCommand("Copy");
}
help?
What are you trying to do @earnest phoenix
Is there any way to get the same effect as message.mentions.members.first(); without using mentions?
yes @quiet bobcat
get the first mention
replace the <@> with nothing then use the id to do something
But like if I do eg !kick @quiet bobcat is there any way to make so I only need to do !kick
or to add or remove roles
bc I need to define member
That would make no sense
But idk what to define it as
You mean name fetch
That is probs stored inside of a database on who is hidden and who isnt hidden
bc it has member defined and its not based on mentions
So I should define member as message.member 
this is how it works
message.author is the user
message.member is a guild object of author is another wise know as member
omg what have I just read
You dont make sense @quiet bobcat
I know
Please read apon the docs
Im trying but I dont understand anything
That isnt a good sign
I know
if message member has role > gib the role else take it
^^^^^^
Nope
You dont?
message.member is already a guild object
guild object, wut
GuildMember object != Guild object
Oke
it's almost like d.js doesn't have really friggin easy docs to read
then you should probably give up, they're the easiest docs you'll come across
Yes
yeah
how could i make my command handler load each file in those folders?
like i have command handler that loads all my commands but i want to modify it so i can load commands in folder
s
fs.readdir("./cmds/", (err, files) => {
if (err) console.error(err);
let jsfiles = files.filter(f => f.split(".").pop() === "js");
if (jsfiles.length <= 0) {
console.log("No commands to load!");
return;
}
console.log(`Loading ${jsfiles.length} commands!`);
jsfiles.forEach((f, i) => {
delete require.cache[require.resolve(`./cmds/${f}`)]
let props = require(`./cmds/${f}`);
console.log(`${i + 1}: ${f} loaded!`.green)
bot.commands.set(props.help.name, props);
});
});

you want to load commands into folders?
I believe readdir returns folders too
so you could get the folders with readdir and then for each one of those do readdir again to get the command files
no i want to load to commands from the folders @pale light
I just explained
fs.readdir("./cmds/", (err, files) => {
})
[ 'Fun', 'Moderation', 'Music', 'Utility' ]
Ive tried this
fs. readdir(`${files[0]}/`, (err, files) => {
console.log(files)
})
but i get undefined
add the ./ before files
How do I make so / is only one decimal? Lang is nodejs
Sorry for this...
Hey @here, @gritty dirge is finally back with us again! @earnest phoenix let us use his server to host it ๐ Thank you Emma! โค https://discordbots.org/bot/373542693453824010
@crystal void you cant tag here lul
๐
@quiet bobcat what do you mean
I want to see uptime but I'm currently using math.round
And it rounds up after half an hour
I dont want that
I want it to show one decimal
Like 2.6 hours
Instead of 3
Any good online hosts?
Get a VPS
Yeah VPS are the only good hosts
Mk
Scaleway is cheap for a lot of RAM but CPU performanc is lacking
@quiet bobcat .toFixed(1)
Number.toFixed
?
So eg Math(bot.uptime / 3600000).toFixed(1)?
let number = 725.8291938
number.toFixed(1) // '725.8'
ok thanks
actually now that I think of that it might not round
like 725.86 would give the same result
but idk if that matters for your uptime lol
fs.readdir("./cmds1/", (err, files) => {
files.forEach((cmd) => {
console.log(cmd)
fs.readdir(`./cmds1/${cmd}/`, (err, files) => {
let jsfiles = files.filter(f => f.split(".").pop() === "js");
if (jsfiles.length <= 0) {
console.log("No commands to load!");
return;
}
console.log(`Loading ${jsfiles.length} commands!`);
jsfiles.forEach((f, i) => {
let props = require(`./cmds1/${cmd}/${f}`);
console.log(`${i + 1}: ${f} loaded!`.green)
bot.commands.set(props.help.name, props);
delete require.cache[require.resolve(`./cmds1/${cmd}/${f}`)]
});
})
})
})
i did this and it works
sigh
In short, maybe, maybe not, wouldn't wanna find out
xD
Automating normal user accounts (generally called "self-bots") outside of the OAuth2/bot API is forbidden, and can result in an account termination if found.
there is my answer
I think
idk whats the error
LINE 1: const Discord = require('discord.js');
LINE 2: const boy = new Discord.Client();
LINE 3: bot.login('MyToken');
Why doesn't it do anything when I do node .
because you called it boy ?
o
Im fucking stupid
Still doesn't work
LINE 1: const Discord = require('discord.js');
LINE 2: const bot = new Discord.Client();
LINE 3: bot.login('MyToken');
Is the new code
๐
How can i load more then 1 function from a seprate file and not have the issue of https://i.imgur.com/52EOtG7.png Or giving it extra args that it doesnt need
That is from functions.js btw ^^^^^
`const Discord = require('discord.js');
const bot = new Discord.Client();
bot.on('message', (message)) ; {
if(message.content == 'ping') {
message.reply('pong');
}
}
bot.login('Token');`
Wuts my error?
function showModal() {
modal = document.getElementById("modal");
modal.className += ("is-active");
}
function hideModal() {
modal = document.getElementById("modal");
modal.className -= ("is-active");
}
</script>
<div id="upload">
<form method="post" enctype="multipart/form-data">
<p><input type=file name="file" multiple>
<input type=submit value="Upload">
</form>
</div>
<div class="modal" id="modal">
<div class="modal-background"></div>
<div class="modal-content">
{% with messages = get_flashed_messages() %}
{% if messages %}
{% for message in messages %}
<i class="fa fa-copy" id="toggle" style="cursor: pointer; float: right; font-size: large;" onclick="copy()" aria-hidden="true"></i>
<strong>SUCCESS!</strong> {{ message }}
{% endfor %}
{% endif %}
{% endwith %}
</div>
<button class="modal-close is-large" aria-label="close" onclick="hideModal()"></button>
</div>
<div id="snackbar"></div>
the <button class="modal-close is-large" aria-label="close" onclick="hideModal()"></button> doesn't close
the thingy
'the thingy'
function showModal() {
modal = document.getElementById("modal");
modal.className += ("is-active");
}
function hideModal() {
console.log('Hiding Modal');
modal = document.getElementById("modal");
modal.className -= ("is-active");
}
``` showModal works but hideModal doesn't
ok
rubs back
`const Discord = require('discord.js');
const bot = new Discord.Client();
bot.on('message', (message)) => {
if(message.content == 'ping') {
message.reply('pong');
}
}
bot.login('MyTokenWuzHere');`
Idk wuts wrong with it
Visual studio gives me this error
Thanks
My question is.
why you define it as boy
Did you asume your bot's gender or did you simply make a typo

^
How can I test for a @mention in a string taken from a message sent by a user?
@naive stag : @dense quiver
the thing on the left is the string extracted from my message saying: @naive stag, and the string on the right is .mention() ran on my IUser account. They don't match, how can I get something that will match without trimming the ! coz that seems like a pretty bad solution tbh
The ! means the bot has a nickname set
the... user has a nickname set on the guild? or, the bot has a nickname in the guild?
Cuz the bot has a nickname but not the user, i dont see why the bot having a nickname should affect the @mention string for a user that isnt nicknamed
what library are you using
discord4j
you want to see if both mentions match?
i just want an easy way to turn @naive stag from a message from a user into the users IUser object, so I'm just looping through the guild's user list and trying if (user.mention().equals(string)), where string is the thing the user typed
you got me lost lmao ยฏ_(ใ)_/ยฏ
but as you can see that dosent work coz it has a ! in the mention string that the bot generates for some reason
yea my explanation wasnt great lol 
if <@!> and <@> is an issue
use regex to remove them from the string and just test ID's
I guess ill just do that
;-;
Can someone explain to me what .guildShardMap does, talking about Eris. (Object mapping guild IDs to shard IDs)
"Object mapping guild IDs to shard IDs" that says what it does 
Yeah, what means mapping...
@umbral pelican discord.js looking ass nah jk bb
an object with all guild ids along with the shard they're on
correlating @neon pasture
lets say u have guild 27462727457 and 30 shards
well if that guild falls into shard 20
it will return an object like
guild id -> shard id
in this case it would correlate that guild id into shard 20
you can do that manually too if you want
there's a formula to get the shard of a guild
Thank you
Who Can Help me with .js Help Command on My Robot Does Not Work
const request = require('request-promise-native');
function postServerCount() {
return request.post({
uri: `https://discordbots.org/api/bots/${bot.user.id}/stats`,
headers: {
Authorization: "token in here", // Insert token here
},
json: true,
body: {
server_count: bot.guilds.size,
},
});
}``` why didint this work
shit
Use the one in #312614469819826177 and its the one with snekfetch
Sup @topaz fjord
The first can be an arg and the second would be a slice
@earnest phoenix robot? um theres a difffrence between a robot and a bot
its not the same sir
`const commando = require('discord.js-commando');
const bot = new commando.Client();
bot.registry.registerGroup('random', 'Random');
bot.registry.registry.registerDefaults();
bot.registry.registerCommandsIn(__dirname + "/commands");
bot.login('TOKEN');
`
um
u shoud change that
wut about that code
cute
yup
registry.registry 
idk how to use commando
readdddd
It's very simple
Last stack trace
@compact cairn pls use proper codeblocks too
I^
wut
whats wrong with these
oops
idk
@earnest phoenix
console.log("these are way better");
Kek
can we ban mayo yet
yes
oof


When it says ',' expected. for my error
Do I just replace it with a ,
๐ฎ
fixed it
y'all make bots?
Cool
ban all commando users
why tho
๐ฆ
message.reply("You rolled a " + roll,"!"); Why does it leave out meh "!"
I'm new to here so forgive me if i mess up
@compact cairn string literals pls
it's ```js
message.reply(You rolled a ${roll}!);
lol
message.reply(`You rolled a spliff!`);


