#development
1 messages · Page 344 of 1
ideally though, I want centered prev/playpause/next buttons
basically how I want it is, sound slider (which opens up vertically on hover) at the far left
then there's a gap until the prev/playpause/next buttons (which are centered)
and then there's a progress bar for the rest of the space until the far right
Anyone knows a way i can track the servers the bot is joining?
guild join event
or i think its called GUILD_CREATE thats i think the event handler for it
Yeah guild create
ok thank you!
the token is no longer valid
but here's an example of how to activate you bot through js
@uncut slate I know bulma
BANDICAM
@uncut slate you can use margin or vertical alignment
you dont need to use X css framework
How do I make a global variable?
Like one that is consistant accross all files
@earnest phoenix Don't use global variables
Just pass it to the next file using functions
And how would I do that
Lol okay okay I get it
Sheesh
Sheesh
Did I do something wrong?
Lol no
I'm redircting to you the correct source
Boi
I didnt mean it literally
Then why did you say it?
I took it literally
🤦
lel
Google says: nothing
Just function parameters
Which isnt helpful lel
Most of it is HTML
Yeah google isnt helpful at all
Im just gonna check the MDN documentation again
Google is very helpful
Boi I ment for what im trying to do
Google is a very helpful tool
Just not right now
Hmmm I see plenty of info on google.
Lol node didnt come up at all on google
All that came up was stack overflow stuff
About function parameters
Which isnt helpful at all
because you didn't search hard enough
Im just gonna search the documentation again
Google just kept getting more and more off-topic the farther in I went
excuses
Lol
\👀
hi\
Hey guys, does require("json-circular-stringify"); lag the bot? I added it because if it's not there, it would make circular reference errors.
a require shouldn't lag the bot
unless the file is extremely big
or has heavy init
Well,thing is, everytime I type a command that edits the database in a way, it makes a long pause then does what it's supposed to do

well this is also a problem
When dyno.coming on
@serene citrus self hosting may lag the bot asf
This isn't the DynoBot support server sorry
yes self hosting is bad
It can cause a lot of lag @AstralProjectionMaster#2171
wew left
yes self hosting is bad It can cause a lot of lag self hosts 3 bots on one PC without any issue 
Can someone help me? I want to search for a role eg Admin on a server, with just writing like !search admin
remove the member.
oof simple mistake
user.avatarURL
Nice indentation
Ok
And the args is like if someone does !search blabakabjakejdisjsi
Ya know what I mean
Yes
If it's not there it returns null
You have a user variable defined
And you dont use it?

@earnest phoenix member.user.displayAvatarURL
Yeah that too
Its not message.mention
Its message.mentions
I would do
var mention = message.mentions.members.first();
if(!mention) mention = message.member;
message.reply(mention.user.displayAvatarURL);
:P
So if no mention is delivered it gives you the author's avatar
wew
I keep forgetting that const cant be redefined
Lmao
But yes it still gives the avatar of a mention
It just gives you your avatar if no mention is provided
Change const to var
or whatever
Because const cant be redefined
lul
@earnest phoenix http://ovh-is.a-shit.host/v70068
const idk = await sql.get(`SELECT FROM something WHERE something = something`);
return idk.something;
}
This doesnt return the value
and I havent done async functions in a while btw lul
You have to await something() or .then it
return await something()?
Wait what
something().then(console.log)
Or wrap it in an asynchronous function and await it
Someone developing in Ruby or crystal?
If yes, please contact me if you're up for a collab
Thats too easy 🤦
In what language?
probably js 
Anyone knows how to convert my Discord4j (java) bot to a webapp so I can host it on Azure? (memory quota exceeded in Heroku, using worker role :()
Host it yourself
My internet won't do the job o-o
Vps
any free?
helppppp
Screaming help wont get you help
ok..? did it in the past and it did mate
Bad rar file then?
Its Winrar the good one everyone says they use
can someone halp me add a bot to my server? PLZ I NEEEEED IT
did you check invite?
?
ok.
You know how to make an bot^
no. i know bots i like though
lol no help :/
k
the quality of the .rar file doesnt depend on the extractor
@solar zephyr dm plz
async function getPrefix(){
var foo = await sql.get(`SELECT * FROM prefixes WHERE guildId = ${msg.guild.id}`);
return foo.prefix;
}
Ive console.logged await getPrefix() and I get the right prefix but when I do console.log(await getPrefix().length) I get undefined 
sendMessage is deprecated btw
And theres no reason to have the
(message.mentions.members.size === 0) part because the part above covers it ;-;
@thorny hinge (await getPrefix()).length
console.log((await getPrefix()).length)
I think it's a good idea
@thorny hinge you can't do that
because
You aren't waiting for the "await" to finish before you get the "length" property
const a = await myFunc();
console.log(a.length);
I removed that
(message.mentions.members.size === 0) is redundant
(message.mentions.members.size) is enough
because 0 is falsy in javascript
@solar zephyr If the compared value is always a number, I use an integer comparator sign (>, <)
I prefer it that way
lol
i usually go x.length < 1
it doesn't make sense but it's become a habit
ok that one I don't do lol
-
Hey uh I have a question
How do I get the time a message was created outside an embed?
Nvm
👀
👀

Why am I getting this error?
fs.readdir("./commands/", (error, commands) => {
fs.readdir("./events", (error, events) => {
fs.readdir("./schedulers", (error, schedulers) => {
for (let i = 0; i < commands.length; i++) {
bot.commands.push(require("./commands/" + commands[i]));
if (i === commands.length - 1) {
log("Loaded " + commands.length + " commands!");
for (let i = 0; i < events.length; i++) {
require("./events/" + events[i])(bot, r);
if (i === events.length - 1) {
log("Loaded " + events.length + " events!");
for (let i = 0; i < schedulers.length; i++) {
const schedule = require("./schedulers/" + schedulers[i]);
setInterval(schedule.execute, schedule.interval);
if (i === schedulers.length - 1) {
log("Loaded " + schedulers.length + " schedulers!");
bot.connect();
}
}
}
}
}
}
});
});
});```
/Users/jacobgunther/Documents/Starboy/src/index.js:26
for (let i = 0; i < commands.length; i++) {
^
TypeError: Cannot read property 'length' of undefined
at fs.readdir (/Users/jacobgunther/Documents/Starboy/src/index.js:26:32)```
I don't get why, it's defined in the first line of that code
nvm figured it out
no u need more
LIZARD, DONT ENCOURAGE THEM
yes you can
how so
let dirs = ["./commands/", "./events", "./sched..."];
for(var i=0;dirs.length>i;i++){
fs.readdir(dirs[i], (err, res)=>{
// do stuff with res
});
}
something on the lines of that
you're technically still calling readdir the same amount of times
nothing changes
that wont work anyway
lul
this is harder than i imagined, considering i have no context lel
let dirs = [ "commands", "events", "schedulers" ];
let bot = { "commands":[], "events":[], "schedulers":[] }
for(let i=0;dirs.length>i;i++){
let complete = 0;
fs.readdir(__dirname+"/"+dirs[i]+"/", (err, res)=>{
for(let x=0;res.length>x;x++){
bot[dirs[i]].push(require(__dirname+"/"+dirs[i]+"/"+res[x]));
if(x === (commands.length-1)) log(`[${dirs}] => Loaded.`);
if(dirs[i] === "schedulers") setInterval(bot[dirs[i]][x].execute, bot[dirs[i]][x].interval);
if(dirs[i] === "events") bot[dirs[i]][x](bot, r);
complete++;
if(x === (commands.length-1) && complete === 2) bot.connect();
}
});
}
LMFAO
oh my
I believe my code is more optimized
took you 5 minutes...
what
i was talking to my peers as well
wys
this gave me an idea for my project though, so thanku xox
lol
const module = require('module');
module();
const module = require('module')();
how do this pl0s
what
dont understand?
How would i write it in a command.js
so that executing would allow me to simple just write
const module = require('module');
module();
I want to execute ping.js
I don't want to execute it like this
const ping = require('./commands/ping.js');
ping.Execute();
I want to run it like this:
const ping = require('./commands/ping.js')();
OR
ping();
understand what i want?
Then use the bottom option
You're confusing
gfhdiugfgbdfhgfhfgd
im googling this
nah
idk
objects
no dude
chaining functions?
ken you're bad
you're bad
lol this is a way to make someone mad...
ok
lol
calling a module object?
reee\
I can not install anything with npm install https://gyazo.com/b12d559b5880bb50b60dedf8ed540bc3
why?
?
it does not work to install anything!
@earnest phoenix It wants python to be installed
(╯°□°)╯︵ ┻━┻
@earnest phoenix it's installed
Make sure it's added to PATH
for(var guild of bot.guilds.array()){
count += guild.memberCount.size
}```
Why isn't this working?
Using eris btw
for(var guild of bot.guilds.values()){
count += guild.memberCount
}```
Already found a way
@neon pasture no please
some people are in multiple guilds with the bot
that will be inaccurate
lol
msg.mentions[0].joinedAt It's undefined, but I really don't know how to fix it.
Using Eris / Javascript
So I need to make it as a variable?
what
msg.mentions[0], it's now a array
noo
mentions is the array
and you are getting a user object
not the guild member one
guild has a collection of members
Isn't it possible to make from User object a Member object?
But then I need to make a map and shit
what the hell
it isnt even difficult
im not spoonfeeding you, but you literally just have to use .get with the user id as the argument
thats what i meant about the collection
bot.guilds is also a collection, you should know how to operate one by now lol
https://ale32bit.me/i/g9Dat.png
absolutely not a copy pasta
or just downloaded the source code, put a token key and let the bot run
kek
"i made a bot"
they'll never have the feeling to get shitpost muted
just like my bot
cries
cries too
cries more
cries even more
cries the most
cries even more then the most
nah
lol
cries
How to POST / GET datas to your own website with Discord JS?
@tawny geode how many modules do you use?
i use superagent to POST stats to discordbot list
eww
Hey
Would it be possible to in a way have unlimited upload emojis? Doesn't have to be in 1 guild, I've been thinking like, use a user token to create guilds if needed, then auto invite the bot, but thats impossible seeing as the bot oauth invite thing has captcha
yes
hi
NOPE
Well

I suggest watching a tutorial of first learning some programming languages
discord bot maker on steam

discord bot maker sucks
🤔
I learned python/discord.py by reading the source of a redbot cog that was outdated and broken and messing with it to try learning why it was broken
i learned javascript by making a discord bot in discord.js
me too
gg man
I wonder how that will look in gource
Net neutrality is under attack, so I put this in the footer of almost every bot command
👍
yeah
(although you have to do it before you get any real guilds)
yeah
or 8=Dhelp
8====Dhelp
lol
@earnest phoenix what theme is that?
@earnest phoenix https://betterdocs.net/themes/beardsmaterialtheme.html
lol
NIce
@cosmic plover nice catch
Hey guys! How can I add reactions to message with jda?
Docs cant help me
message is not defined :^]
i think you should take a few steps back, read some documentation and try again
theres a few things missing/wrong with your code
your exported function is a void
client.on('message', msg => {
sure you're passing (client, message, args) ?
im assuming this isn't your "main.js"?
alright, was gonna say
/warn
xD
@earnest phoenix .-.
u failed at life
if(!mention) {
mention == message.member
}
.-.
yes
xD true
what he had previously was fine
he just had it organised in all the wrong ways
and @earnest phoenix i think the issue is that you're not actually passing the message event through the function
i just realized
try checking your command handler is written up properly
and if you didn't make the CMD handler urself
you should check up on the documentation a little more
show me the command
and the handler
okay for starters
=>
goes nowhere
wrap everything in {}
for example
((function) => {
//code
})
get me?
as you've done with your other command
basically just forgot some brackets
if you don't want help? 👀
do the same as you've done with other commands 👀
so yes.
np
ye
[2017-11-22 18:26:29] Error: val is not a non-empty string or a valid number. val=undefined
[2017-11-22 18:26:29] at module.exports (C:\Users\JBeda\Desktop\Immortal\node_modules\ms\index.js:33:9)
[2017-11-22 18:26:29] at Object.exports.run (C:\Users\JBeda\Desktop\Immortal\commands\mute.js:13:66)
[2017-11-22 18:26:29] at msg.validateArgs.then (C:\Users\JBeda\Desktop\Immortal\node_modules\komada\src\events\message.js:73:15)
[2017-11-22 18:26:29] at <anonymous>
[2017-11-22 18:26:29] at process._tickCallback (internal/process/next_tick.js:188:7)
const ms = require('ms')
exports.run = (client, msg, args) => {
let member = msg.mentions.members.first()
if(!member) {
msg.channel.send('**NO MEMBER**')
}
let muteRole = msg.guild.settings.muteRole
if(!muteRole) {
msg.channel.send('**NO MUTE ROLE**')
}
let time = args[1]
member.addRole(muteRole)
msg.channel.send(`${msg.author} has muted ${member} for ${ms(ms(time), {long: true})}.`)
setTimeout(function() {
member.removeRole(muteRole)
msg.channel.send(`${member.user.tag}, you have been unmuted. The mute has lasted ${ms(ms(time), {long: true})}.`)
}, ms(time))
if(!time) {
member.addRole(muteRole)
msg.channel.send(`${msg.author} has muted ${member}.`)
}
}
exports.conf = {
enabled: true,
runIn: ['text', 'dm'],
aliases: [],
permLevel: 1,
botPerms: [],
requiredFuncs: [],
requiredSettings: ['modRole', 'adminRole', 'modLog', 'muteRole']
}
exports.help = {
name: 'mute',
description: 'mute users',
usage: ''
}
I have a question about json web apis
where do I put the api key in the url?
please tag me in your responce
I has a question too
How would I make an event listener for when my bot joins a server?
Please tag me too
Read the docs for your lib
@earnest phoenix whatever you gave to the ms module was undefined
@undone plover depends on the API
^
usually the API key goes in an Authorization header
or even the body data
sometimes even the URL query params
hey kiddies
no
because it's probably one of the easiest things to find
But its for literally everything I ask for help with
and he helped by telling you how to find it :D
But logic: If I came here, it means I already googled it, searched the docs, and tried almost everything I know
Then you dont know how to use google properly
Boi I do
what lib do you use
what lib
d.js
Look at the docs under the guildCreate event
Okay thank you

That literally helped more then just telling me to "google it"
I just googled
and found it within the top 3 results
the documentation
Google comes up with unrelated topics
unless d.js isn't discord.js
Oh okay I get how to do it now!
It is
Alright thank you for pointing me in the right direction
🤔
Okay wait
As my event perameters
Nvm
Okay yea
For my event perameters
Should I use member or client
You use that what the event emits
Look the docs up
I am currently
Everything is documented in there
@earnest phoenix which lib
d.js
client.on
This- this isnt working
hopefully someone that knows d.js will come save the day for you
Hopefully
Because I think I know how to refrence the bot
Okay yes I do as a member
But im not sure what to put as the perameter
Member, message, client
Which client event emitter are you looking for?
Yes
Example
<Client>.on('guildCreate', guild => {
console.log(guild.name);
});
Useless code
But you can understand how it works with it
And make it useful
And i did not close the method, good job me
Okay lol
The callback variable name does not matter codewise
You just need to know what it returns to you
in this case a Guild instance
You are welcome
Okay wait
Sorry to bother
But if your willing to answer 1 last question?
Nvm
I was gonna ask how to refrence the bot member
Since theres no message
But its just guild.me
I believe
Yep
Aghhh
I keep getting all sorts of errors
How do I make my code find a guild's default channel in a .find() method?
Anybody know?
It comes up as an unspecified value
Nvm
Does anyone know how to get bitbucket webhooks into discord i found a site ages ago that could send to that webhook and it would format and foward but ive seemed to have missplaced the bookmark
I apologise sir, I do not know
0-0 omg yes after 3 hours of searching and the 46page of google i has found it
Lol nice bruh
I have a question too
If anybody is around
How do I reference the defaultChannel of a guild in relation to the methods before it
Because I keep getting "cannot read name of undefined"
As an error
cause there is no longer a default channel in all servers some have it some dont its optional now
easy way to tell is if discord sends its welcome message
i ask my self that all the time ¯_(ツ)_/¯
Easiest way would actually to send the message on the first channel you have Send Messages permission
as im sure many other devs do
Oh
Wow k
So the find perameters would be 'permission', 'SEND_MESSAGES'
How do we use the api on the site
Iterate through the <Guild>.channels using on each Channel instance the permissionsFor() method and check if it haves SEND_MESSAGES
👌
How would I turn permissions into a string
I was thinking of a .includes() method
Nvm
client.on('guildCreate', guild => {
const channel = guild.me.guild.channels.permissionsFor(guild.me);
if (!channel) return;
if (channel.has('SEND_MESSAGES')){
channel.first().send(`Hello!`);
}
});
I think this should work
On a website?
yes
In which way
the button is in 1 file
Oh!
the thing is in another
Use an image link
I’m too lazy to make my own website lol
To the other webpage
Lol k
and there are multiple sections in the file that has the section
XDD jk
Just link the image to the major fun-commands section
As the website URL
Of that section
Hold on
how would i do that
Ill show you
cause i still want them to be able to use that section of the web
<a href="section_link_here"><img src="Image_name_and_extension_here"></a>
When they click it, it will act as an image link
so if i do that
and i want it to scroll to utility commands when i click the button?
yes
Im not sure about that
auto scrolling to the section
i know how to do the auto scrolling in the same file
but not auto scrolling to divs in other files
@earnest phoenix https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach
@topaz fjord ```html
<a href="/commands#utility"><img src="img.png"></a>
hi
@earnest phoenix codecademy is your friend
@rich kiln It's not your friend...
@Jeffrey#7936 it is.
Back in the days, it was okay. but now..
true'
mdn wont help too much as ppl expect
mdn?
consider suggesting stackoverflow 4 spoonfeed
👆
Mdn is great
no one said it isnt.
codecademy doesn't compare to mdn
who said it does.
How to convert Timestamp to human readable form date? Javascript
who the fuck knows
someone
Already got it, just timestamp*1000
Hey guys! How can I add reactions with jda?
I tried some ways of it:
event.getMessage().addReaction(event.getGuild().getEmoteById("2639")).queue();```
But JDA always throw on second string
```java.lang.IllegalArgumentException: Emote may not be null```
or
```[JDA-Thread JDA] ERROR RestAction - RestAction queue returned failure: [ErrorResponseException] 10014: Unknown Emoji```
most random
i forgout how to react to the authors message
Nvm
it works
but it didnt work here
thanksgiving stream starting soon ™
You mean bot page?
I cuted a lot of thing but, someone know why https://hastebin.com/orewenigaw.xml I get that: https://screenshots.firefox.com/VVo4LTDzsnGS0aBJ/localhost
But when I capture with "the full page" I see that: https://screenshots.firefox.com/DZNFrTDxXesEiaVt/localhost
what is that
@earnest phoenix Eww, PHP
u'm fixing something for a friend
I do only JS
same
Hopefully
@earnest phoenix leave him alon
we use what we want to.
no one cares if x user is user .xshit
i have a problem in discord.js, i write:
if(msg.member.roles)
i get this error:
Cannot read property 'roles' of null
can anyone help please?
A list of roles that are applied to this GuildMember, mapped by the role ID
You sure it's a GuildMember object?
Returns the GuildMember form of a User object, if the user is present in the guild.
.member(user)
So it returns the GuildMember object, that's good
itll not get the user. it will get the member.
.author is the user
but stikl you can .get() it
.member is the guildmember
.id
His way is fine?
that's another way as well
It's not, why would it return a error then?
Member is a valid property though
i dunno
Okay
if(msg.member.roles), but .roles is a array right?
Wait what guild.member?
Roles is a collection in discord.js
yeah, can you even put it inside a if statement?
lol
Unless they changed it, i havent used discord.js in a while
why would they change it?
Pfft im on the developer
They do random shit that breaks code all the time
They might have changed this, or it’s just a bug with your code
send all your code
function userRole(msg, role) {
console.log(msg.member.roles)
if(msg.member.roles !== "")
if(msg.member.roles.find("name",role)) return true;
return false;
}
i tried !== "" now
still not working
@earnest phoenix if (msg.member.roles.size < 1) return;
.roles isn't a string, it's a Collection which extends a Map
Hey guys?
How do I make my bot interact with VCS
Like for instance
If I make a restart command
It automatically stops the running process and does it again
let me try it
didn't work
Did you put a space after that comma?
@earnest phoenix What is your goal?
Like what are you trying to do
Also I would recommend putting the "return false;" next to the first if statement
Okay it looks like your making a role checker
my brother asked me to make a bot, and i'm trying to check a member has a specific role through a function
Okay
Hm
Im trying to reference specific things too
But
Might be able to help you here
First off
You need a string value instead of "role"
I would also recommend putting a space after the comma
why?
Because its just how it seporates
The values
If your asking for the string value
Well, you dont NEED a string value
You can get like a list of roles
And reference that there
Hm
Like
ok
Wait can you show your current code?
Please
function userRole(msg, role) {
console.log(msg.member.roles)
if (msg.member.roles.size < 1)
if(msg.member.roles.find("name",role)) return true;
return false;
}
Hm
Okay so suggestion: move the return false; next to the first if statement
Like this
if (msg.member.roles.size < 1) return false;
Also
You need a space serporating the second if statement with its perameters
So like this
if (msg.member.roles.find("name",role)) return true;
i see your point, but it's more like if the first if isn't triggered, the second one doesn't as well, which won't trigger the return true and it will go to return false
Oh
no
Then use brackets and some else statements
doesn't matter
From the ac-
it won't change what it does
Oh
when running
you could even do ```js
if
(a
) {
}```
And brackets for what your trying to do
Because like if everything else is wrong
Or not according to
Alright, BASICALLY
if (!msg.guild.roles.find("name", "rolename") {
return false;
} else {
return true;
}```
^
Ik
I suggested he move that
But he needs brackets and else statements for what hes trying to do
if(has no roles) {
if(has role named that) {
return true
}
}
return false
that's what that means
function userRole(msg, role) {
return msg.member.roles.size > 0 && msg.member.roles.find("name", role)
}```
function userRole(msg, role) {
if (msg.member.roles.size < 1) return false;
if (msg.member.roles.find("name", role)) return true
}```
^
it doesn't know what roles mean
that's the problem
Oh
it says cannot read property roles of null
Yeah I get the same thing when I try
I have code too that does the same
Idk why either
@earnest phoenix Dis guy seems to know a lot about dis: @inner jewel
So try talking to him
ok, thanks
Np
Im talking to him rn
Lol k
Hey guys
Same subject
Agh
How would I reference
If I have an array
How would I check each value for a permission
Then on the first one that has it
wdym
Do something
Like
Say for channels
guild.channels
How would I check each channel for permissions
all at once?
for ex <>checkchannel [channelname] and it says the perms?
I only use d.js
Same
But
What
Ill show you my code
Hold on
const Discord = require('discord.js');
client.on('guildCreate', guild => {
const channel = guild.me.guild.channels.array()
if (!channel) return;
});
I have the channels going into an array
client.on('guildCreate', guild => {
const channel = guild.me.guild.channels.permissionsFor(guild.me);
if (!channel) return;
if (channel.has('SEND_MESSAGES')){
channel.first().send(`Hello!`);
}
});```
oh
I dont know about that xD
I tried that
what error was there
An array is this: ```js
const myArray = new Array(["one", "2"]);
👌
Ik what an array is lol
I know Rem, but I don't know how to do what he wants is what I meant.
guild.me.guild is the same as just guild
Ik
Says its not a function
TypeError: guild.me.guild.channels.permissionsFor is not a function
same logic
Okay
Channels is Collection Yes
it doesn't have a permissionsFor function
But then how would I do this 😐
Ah okay
const Discord = require('discord.js');
client.on('guildCreate', guild => {
const channel = guild.channels.first().permissionsFor(guild.me);
if (!channel) return;
if (channel.has('SEND_MESSAGES')){
channel.first().send(`Hello!`);
}
});
My origional code said hello too lol
Not saying this is it tho
This should work
Or not
Agh didnt save it
🤦

FACEPALM
client.on('guildCreate', (guild) => {
const channel = guild.channels.first().permissionFor(guild.me0;
if (!channel) { return false; }
if (channel.has('SEND_MESSAGES')) { return channel.first().send("henlo."); }
});```