#development
1 messages · Page 611 of 1
Herm
You are not allowed to advertise your bot
Really? I thought the rule was no server invites? Lemmecheck
Rule 4 says 'no self-promotion'
I created a bot, added it to my server, and I have the code setup like my other bot that is perfectly fine.
It isn't online in my server though. Why? The token is correct.
Ping me with response please
😦
@floral bloom any errors in the console?
Make sure you copied the bot token, and not the client secret
@mossy vine I copied the token, even regenerated it multiple times.
As for errors... let me reload and check.
(node:6140) UnhandledPromiseRejectionWarning: Error: Something took too long to do.
at timeout.client.setTimeout(/rbd/pnpm-volume/8a466edf-34ca-4883-82c6-36d85ce7283d/node_modules/.registry.npmjs.org/discord.js/11.4.2/node_modules/discord.js/src/client/ClientManager.js:40:57)
try to do client.login('token').catch(e => console.error(e))
@lament meteor Well, I made a new program...... it works now. Maybe it was a bug on the programs side...
const YouTubeWatch = require('youtube-watch')
const client = new Discord.Client()
const yw = new YouTubeWatch({
secretKey:
hubCallback: 'http://your-ip-or-domain/',
hubPort: 9001,
});
yw.on('start', () => {
let channels = ['https://www.youtube.com/user/ROCKSTARvvk',
'UCGY2w6hIZWwyxasBUN7wbaQ'];
yw.watch(channels);
});
yw.on('notified', video => {
console.log(`${video.author} just uploaded a new video titled: ${video.title}`);
client.channel.get(547065494507749396).send(`${video.author} Just uploaded a video ${video.title}`)
});
Is it ok?
missing the private auth tokens uwu
Why in a message that a bot sends, its puts rhombuses with a question mark instead of a letter with an accent:/
Discord does not support baguette language
no? áéúíóôêâàè?
Your device might not support some Unicode characters
I’d check if a) you can send those characters somewhere else like notepad and b) if there are issues on either Chromium or Electron’s github repo about this
or whatever library he's using does not support unicode strings?
or his code editor is not in unicode mode
CREATE TABLE IF NOT EXISTS RandomQuotes (QuoteID INTEGER PRIMARY KEY, Author INTEGER, Category TEXT, Quote TEXT, Approved INTEGER)
sqlite3.OperationalError: table RandomQuotes has no column named Author
this messes with my head
ok nvm, apparently there's a column that's called AuthorID, which is weird because I never ran the program when it was like that 
does anyone know how to fix this error?
does the file exist?
rebuild it
If a person makes an order, how do I make the bot change nickname in the server once the command is made?
I do not know if it works:
message.delete();
message.guild.members.map(async (member, id) =>{
member.setNickname("NICKNAME");```
change whos nickname?
are you trying to change all member nicknames?
Ah I got it wrong, I just want to change the nickname of the BOT
message.guild.me.setNickname(nick)
thx
vps
dont turn it off
But
lmao
When I make the command set prefix, it changes the prefix but here is the error in the console:
(node:8302) UnhandledPromiseRejectionWarning: DiscordAPIError: Missing Permissions
at item.request.gen.end (/storage/emulated/0/Bot Discord/bot/node_modules/discord.js/src/client/rest/RequestHandlers/Sequential.js:79:15)
at then (/storage/emulated/0/Bot Discord/bot/node_modules/snekfetch/src/index.js:215:21)
at processTicksAndRejections (internal/process/task_queues.js:86:5```
have you tried reading the error 👀
Change the nickname of the BOT
What’s your prefix command
t/
The code?
You want me to give it here?
Sure
const Discord = require("discord.js");
const fs = require("fs");
exports.run = async (bot, message, args) => {
if(!message.member.hasPermission("MANAGE_SERVER")) return message.channel.send("Vous ne pouvez pas effectuer cette commande car vous n'avez pas la permission de gérer le serveur.");
if(!args[0] || args[0 == "help"]) return message.reply("Utilisation : t/setprefix <Prefix voulu>");
let prefixes = JSON.parse(fs.readFileSync("./prefixes.json", "utf8"));
let newprefix = args.join(" ")
prefixes[message.guild.id] = {
prefixes: args[0]
};
fs.writeFile("./prefixes.json", JSON.stringify(prefixes), (err) => {
if (err) console.log(err)
});
let sEmbed = new Discord.RichEmbed()
.setColor("RANDOM")
.setTitle("Prefix changé avec succès")
.setDescription(`Nouveau prefix : ${args[0]}`);
message.channel.send(sEmbed);
message.guild.me.setNickname(`[args.join(" ")] TheKıng`);
}
exports.help = {
name: "setprefix"
}```
does the send the message
You can make the prefix a const
Awwwww
@earnest phoenix t'as une erreur ?
I put args join, I'll try args
oe @earnest phoenix
Does it work if you give the bot admin
@earnest phoenix j'ai lui est mis les perms admin pourtant
Yes, me, i don't speak good english
🤔
😔
I've solved the problem. I had put args. join while the args I had already defined by args [0]. All right. Thank you all.
👌
on parle français ici ? :p
ouep @glass spruce
Certains ouaip
j'ai une question
C'est triste, ils prennent plus de temps qu'avant pour vérif les bots
Pourquoi quand le bot répond à un message, à la place des accents il met un losange qui a un point d'interrogation à l'intérieur ?
encoding
je sais pas ce que tu utilises, je viens d'arriver ici mdr
des fois il semble que les français se souvient pas les mots et ils utilisent les mots anglaises (je look ça)
X)
@earnest phoenix Merci ça a fonctionné
He finds an error but I don't know which
.setDescription(`Nouveau prefix : ${args[0]} || Je me suis rename en `[${args[0]}] TheKıng` pour vous aider si un jour vous avez oublié mon prefix.`);```
peux-tu utiliser ` en place de ' ou " ? quelle langue est ça ?
En js mais j'ai mis ` car il y a [{$args[0]}]
sinon sa affiche pas correctement et sa affiche pas le args
soucis réglé enft xD
mais c'est pas .setDescription('Nouveau prefix : blah blah `[blah blah]` blah ');
'' pour le paramètre de setDescription, et les ` pour le message
If you're trying to put that bit as an inline code block
Just escape the ` characters
using a \
\` \`
In the code it'll work
in the block yea, not in the inline code block
you can't escape it there apparently
gamer
wait ah you're talking about the javascript code
can someone help me with something ive never seen in any other bot and im having difficulties trying to add it
sorry sorry
yes
but i'm not sure if you can use ` in javascript at all rather than '
you can
fair enough
` are template literals, not string literals, but they work the same way
Genesis what something 👀
ok im doing a module loader, mainly to bind guidebot's stuff like functions and Logger to the client so its exportable on any command or anything else. basically i accomplished it, works just fine with guidebot's Logger module. but with functions.js not so much
i always get a client.modules["functions"].loadCommand is not a function
// module loader
// Loading modules
const mdlFiles = await readdir("./modules/");
client.modules = {};
const mdlOpsStarted = process.hrtime();
console.log(`[Client] : Loading ${mdlFiles.length} modules...`);
mdlFiles.forEach(mdl => {
const mdlName = mdl.split(".")[0];
console.log(`[Client] : Loading module: ${mdlName}`);
const mod = require (`./modules/${mdl}`);
client.modules[mdlName] = mod;
});
let mdlOpsEnded = process.hrtime(mdlOpsStarted);
console.log(`[Client] : Loaded ${mdlFiles.length} modules in ${mdlOpsEnded}ms`);```
//where im trying to use functions.js
const res = client.modules["functions"].loadCommand(command);
if (res) console.log(command);```
error
you have an error inside an async function
if you're using .then() add a .catch() to it, if you're using async await, put it inside try/catch blocks
i asked in the idiotsguide server, got kicked because evie refuses to help and i said now i know why i dont use this server for questions
asked in d.js, got bullied by every js script kiddo
im not using .then()
the full command loader is
// Loading commands
const cmdFiles = await readdir("./commands/");
let cmdOpsStarted = process.hrtime();
console.log(`[Client] : Loading ${cmdFiles.length} commands...`);
cmdFiles.forEach(command => {
if (!command.endsWith(".js")) return;
const res = client.modules["functions"].loadCommand(command);
if (res) console.log(command);
});
let cmdOpsEnded = process.hrtime(cmdOpsStarted);
console.log(`[Client] : Loaded ${cmdFiles.length} commands in ${cmdOpsEnded}ms`);```
post the contents of functions.js module
let me put in a pastebin
want logger.js to compare the structure of both?
oh wait nvm, you can check guidebot's repo since the only thing im using from it are those 2 unedited modules
also, try putting the require(module) inside try/catch blocks
try catch clauses are very basic and fundamental
try {
const mod = require(...)
} catch(e) {
console.log(e)
}```
if you don't know how to use them, take a step back and learn what you're missing out on
i added the catch/try and ran the bot again still same error
why are you always on development only to tell beginners to go learn something
"i don't know how to X"
"to do X you need to know how to do Y first"
"oh"
for a comparison it's like trying to learn how to use the pythagorean theorem without knowing what a triangle is
if anyone has vsc and vslive-share and is willing to help let me know
i just want to fix this
you can try basic debugging, like console.log(client.modules,client.modules["functions"])
when i log the client.modules[mdlName]
so you can actually see whats going on
is it because Logger.js uses switch cases?
maybe i should adapt functions.js to be the same?
since also every function inside functions.js has client.functionName
looks like your functions.js is outputting an empty object
you still didnt post the contents of functions.js
quick google search: ```bar.js
exports = { "a": 1 }
foo.js
var bar = require("./bar")
console.log(bar)
then
node foo.js
will log an empty object, {}
In CJS the module wrapper passing in module.exports as exports.
So reassigning exports =... severs the association with module.exports.```
replace exports with module.exports
no more empty objects BUT still doesnt work
instead of {} like before, i get [Function]
modules[mdlName] = mod()
remove client from the function, and replace all client. by this.
ok
its almost working thats good progress
now in the file i just need to use the client module importer for a couple of things that need the Logger module
ok i removed the all the client from the functions.js, replaced the module's handler logger with a simple console.log and now it says mod() isnt a function
but if i remove it i get the error i had when i first asked my question
im probably just gonna re-write functions.js
How do I make a picture appear in a channel send message?
message.channel.send("image link") or an embed with .setImage()
And the image comes out in an embed but the worries is that I do not want the link this see
well in an embed it wont show the link
Yes, but the embed does not mention a user, and I want his for the welcome command
well then its not possible because sending images in messages will show the links
you can upload it as an attachment
oh true
or send it in an embed + regular message content
@inner jewelI want to Yes
oh yes also works
Attaches a file, but how do we do xD?
a message with the mention and embed with the image
but why are you going to be annoying and mention the user when he joins
like, there's already mee6 for that
Its not going to be automatic
@lost swallow to initialize it that way, you need to use new mod()
@inner jewel Yes like her, I do how?
depends on your library
Javascript @inner jewel
this is getting on my nerves its only this one file that screws the execution
javascript is not a library
d.js is
- no need to ping on every message
- js isn't a library
discord js
then rewrite it into something simpler, like an object of functions
Discord js Natan
thx
natan, that .build() is something that you coded yourself or already a function/property of d.js/js?
lul
@lost swallow module.exports = function() instead of () =>
mod is not a function omg
ill just rewrite it with fricken switch cases ig and see if that works
what is straight from guidebot
are you blind
guidebot doesnt have a module handler
basically loads modules
binds them to client
and voila
works with guidebot's Logger
but not functions.js
they should already be bound because theyre named client.someFunctionName
yes but
you have to do require("functions.js")(client)
so im having a rough time trying to load it and use its functions with my module loader
i just want to do this so i dont have to require everything, which tbh, is kinda lame since it isnt that hard to do
its just finicky with the module.exports and all that
how is your module.exports?
i really do have to work harder on this to make it compatible with basically everything
there's a gazilion ways to use module.exports
module.exports = function() {}
module.exports = { a() {} }
function a() {}
module.exports = { a }```
oh
damn
function permlevel (message) {
let permlvl = 0;
const permOrder = this.config.permLevels.slice(0).sort((p, c) => p.level < c.level ? 1 : -1);
while (permOrder.length) {
const currentLevel = permOrder.shift();
if (message.guild && currentLevel.guildOnly) continue;
if (currentLevel.check(message)) {
permlvl = currentLevel.level;
break;
}
}
return permlvl;
};```
so like this, and at the end module.exports = { permlevel }; ?
so with one module.exports i could export all the functions instead of exporting them line by line
ill adapt the whole code and see if this works
you can also only import the ones you need using let { permLevel } = require(functions.js)
thats the thing the module loader SHOULD import the modules and let me use them within the code by using the client.modules.x.x
Code:
const Discord = require("discord.js");
const fs = require("fs");
let mod = JSON.parse(fs.readFileSync("./mod.json", "utf8"));
let modd = [560511965177446407, 186895347409354752]
module.exports.run = async (bot, message, args) => {
let user = message.guild.member(message.mentions.users.first()) || message.guild.members.get(args[0]);
if (message.content.startsWith("-addmod")) {
if(message.author.id.modd) {
if (!mod[user]) mod[user] = {
id: user.id,
};
//let userData = pre[message.author.id];
message.channel.send(`${user} Was added as \`Globan\` mod!`);
}
fs.writeFile("./mod.json", JSON.stringify(mod), (err) => {
message.channel.send(`Sorry but you are not owner of the bot!`);
});
}
}
Need help its says Sorry but you are not owner of the bot! but i am mark as owner
Ok with nginx is there a way to use the basic authentication yeah but then store like some sort of token or SOMETHING the information of the user idk, but store it somewhere so I can authenticate requests from unlocked websites as well
I coded a system that when a member joins a server, he MP the Member by wishing him welcome. But the console tells me that Member is not defined:
bot.on('guildMemberAdd', guild => {
var joinEmbed = new Discord.RichEmbed()
.setColor('00FF00')
.setDescription(`💼 • Bienvenue dans le serveur ${member.guild.name} - Respectez le règlement et le staff - Bonne continuation.`)
.setTimestamp()
guild.member.send(joinEmbed).catch((err) => message.reply("Mon système n’est pas en mesure d’autoriser la demande car l'utilisateur venant de rejoindre le serveur n'a pas ouvert ses mp"))
});```
if someone reports your bot for dm abuse it can get banned. you know that right?
why dont you like do something basic without mentions or dm's when the user joins
Why would he postpone me? It's OK, right?
He's going to send him the welcome message once. Do we have the right to do that?
i mean you can. but people can report it for mass dm's
and for the purpose of mass pinging we have the lord mee6
@earnest phoenix guildMemberAdd passes through a member.
OwO fyko
How do I do it?
<client>.on('guildMemberAdd', (member) => {})
but do not do that part with dmming every member.
yea its not guild its member lol
Mass? @lost swallow, it's just a message. I don't see why someone complains about my bot to discord!
thx
It is against the rules in this server
Discord does not refuse to send a message privately to welcome privately. Discord will punish me?
so take your dm-ever-member-message bullshit elsewhere if you plan on doing it
just not in this server 
@flint trellis How do I do it so he doesn't just put it in this server?
database
dont mention people if they are active in the chat its annoying
you can check if the guild id is dbls, and just return
what I do is check my settings to see if the guild has welcome_toggle turned on
it's all up to you
Using a database would allow you to dynamically enable and disable it on any server
something like that, yes
Useful links for learning JavaScript and Node:
CodeCademy online course: https://www.codecademy.com/learn/javascript
Eloquent Javascript, free book: http://eloquentjavascript.net/
MDN's JavaScript guide: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Introduction
You Don't Know JS (free book series): https://github.com/getify/You-Dont-Know-JS
Some Node: https://nodeschool.io/ https://www.codeschool.com/courses/real-time-web-with-node-js
Javascript reference/docs: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference
i also have a welcome toggle switch
So it's not totally its, though?
please learn javascript before you try to make a bot.
and learn proper english
*proper. how ironic
please make a bot before learning javascript
xD
so i can see you suffer
@earnest phoenix thats not how you check for server owner, .id.modd doesnt exist, unless you're doing something weird
@quartz kindle no i want to define owner of bot id
uh
that bot owner is just allowe to use that command
add a ownerID line to your config file followed by your id?
to check for bot owner, just get the owner user ID
and compare it
if(message.author.id === "YOURIDHERE")
if (x.ownerID === message.author.id) {}```
why would you ever need to make ownerID a customizable value?
are you gonna sell your bot? lmao
then put them into an array and use .includes or .indexOf
k
if(["OWNERID1","OWNERID2"].includes(message.author.id))
i add if(message.author.id === "560511965177446407") should i add else to include error?
yup
and yes, you can add an else to define what happens if the ID is not an owner
k thx
urgh
if guild.id = "264445053596991498" return;
SyntaxError: Unexpected identifier guild.id ```
thats not how you use if in javascript
youre also missing ()
No, it is so that the bot does not MP in this server (welcome message)
still, thats not how you use if in javascript
both things i said are correct for what you wanna do
if you're using javascript, the correct way is if(condition) {action}
Well I put what instead!?
do us all a favor, and check something like guidebot
OK
and stop asking so many questions like
its actually dumb when someone with barely any js knowledge just asks for help
Code:
if (message.content.startsWith("-addmod")) {
if(["560511965177446407","186895347409354752"].includes(message.author.id))
if (!mod[user]) mod[user] = {
id: user.id,
};
//let userData = pre[message.author.id];
message.channel.send(`${user} Was added as \`Globan\` mod!`);
}
fs.writeFile("./mod.json", JSON.stringify(mod), (err) => {
} else {
message.channel.send(`Sorry but you are not owner of the bot!`);
});
}
Error:
} else {
^
SyntaxError: missing ) after argument list
His:
bot.on('guildMemberAdd', member => {
if guild.id = "264445053596991498" return;
```
?
What do I replace?
guildMemberAdd doesnt give you a message
@lost swallow dont answer if you dont know the answer lmao
Integer coding ^^
bot.on('guildMemberAdd', member => {
if guild.id = "264445053596991498" return;
var joinEmbed = new Discord.RichEmbed()
.setColor('00FF00')
.setDescription(`💼 • Bienvenue dans le serveur ${member.guild.name} - Respectez le règlement et le staff - Bonne continuation.`)
.setTimestamp()
guild.member.send(joinEmbed).catch((err) => message.reply("Mon système n’est pas en mesure d’autoriser la demande car l'utilisateur venant de rejoindre le serveur n'a pas ouvert ses mp"))
});```
still if he wanted to check the guild id it would be message.guild.id lol
no, because guildMemberAdd doesnt give you a message
Why message?
@quartz kindle i add else and i go this
} else {
^
SyntaxError: missing ) after argument list
Ok
@earnest phoenix you forgot an opening {
at the end of your if(ids)
@earnest phoenix which part of if(condition){action} didnt you understand?
the brackets/parenthesis are important
where did you add it? show code
module.exports.run = async (bot, message, args) => {
let user = message.guild.member(message.mentions.users.first()) || message.guild.members.get(args[0]);
if (message.content.startsWith("-addmod")) {
if(["560511965177446407","186895347409354752"].includes(message.author.id)){
if (!mod[user]) mod[user] = {
id: user.id,
};
//let userData = pre[message.author.id];
message.channel.send(`${user} Was added as \`Globan\` mod!`);
}
fs.writeFile("./mod.json", JSON.stringify(mod), (err) => {
} else {
message.channel.send(`Sorry but you are not owner of the bot!`);
});
}
if (member.guild.id = "264445053596991498") {return} ;
@earnest phoenix == or === not =
@earnest phoenix your code is very weird... lets see what happens if you at least format it correctly js if (message.content.startsWith("-addmod")) { if(["560511965177446407","186895347409354752"].includes(message.author.id)){ if (!mod[user]) mod[user] = { id: user.id, }; //let userData = pre[message.author.id]; message.channel.send(`${user} Was added as \`Globan\` mod!`); } fs.writeFile("./mod.json", JSON.stringify(mod), (err) => { } else { message.channel.send(`Sorry but you are not owner of the bot!`); });
you can already spot a few problems
hmm no i think
Does it work or not?
bot.on('guildMemberAdd', member, guild => {```
i know some things are not define but i did define them
i could spoonfeed you but like, just learn js pls
const Discord = require("discord.js");
const fs = require("fs");
let mod = JSON.parse(fs.readFileSync("./mod.json", "utf8"));
module.exports.run = async (bot, message, args) => {
let user = message.guild.member(message.mentions.users.first()) || message.guild.members.get(args[0]);
if (message.content.startsWith("-addmod")) {
if(["560511965177446407","186895347409354752"].includes(message.author.id)){
if (!mod[user]) mod[user] = {
id: user.id,
};
//let userData = pre[message.author.id];
message.channel.send(`${user} Was added as \`Globan\` mod!`);
}
fs.writeFile("./mod.json", JSON.stringify(mod), (err) => {
} else {
message.channel.send(`Sorry but you are not owner of the bot!`);
});
}
But in the console it puts me "Guild" is not defined, it is you who told me to put Member in place of Guild @lost swallow
for example: you need to use an if with {} if you're going to do something in multiple lines, so if (!mod[user]) mod[user] = { is wrong, you cant add a comma to the last value of an object, so id: user.id, is wrong. you dont have an opening parenthesis anywhere, so }); is wrong, your else is in the first if not the second one, so the message about you not being the owner only appears if the message does not start with -addmod @earnest phoenix
i told you to do member.guild.id not to do member, guild in the event
but when i add else the is 4 errors
json database 
In the doc I get lost so..
i use json because i just add 6 mods and that all
anyway, fix the problems i told you about
Any last help?
here: it tells me "Member is not defined"
bot.on('guildMemberAdd', guild => {
if (member.guild.id === "264445053596991498") {return} ;
var joinEmbed = new Discord.RichEmbed()
.setColor('00FF00')
.setDescription(`💼 • Bienvenue dans le serveur ${member.guild.name} - Respectez le règlement et le staff - Bonne continuation.`)
.setTimestamp()
guild.member.send(joinEmbed).catch((err) => message.reply("Mon système n’est pas en mesure d’autoriser la demande car l'utilisateur venant de rejoindre le serveur n'a pas ouvert ses mp"))
});```
For the record, I just looked in the doc, but I got lost ^^
bruh momento
omg are you a retard
I just want this info!!
bot.on("guildMemberAdd", member => {```
not guild
But when I put Guild it tell me, Guild is not defined
I literally googled your answer and I don't even do js
@lost swallow hey, no need to call people retarded
THEN READ DOCS

lmfao
good lord
I gave you an example earlier and you still mange to be ignorant enough to ignore that, ignore what other people say, and repeat.
if someone is a help vampire then tell them nicely dont shit on them just because of their ignorance
Vinx, we all start from somewhere
Documents are here for a reason
They are not a scary monster they just want to help
calling people retarded or telling them to learn js helps no one
STOP YELLING AT ME, I JUST TOLD YOU THAT I READ THE DOCUMENTATION AND THAT I GOT LOST. I WAS JUST ASKING IF SOMEONE COULD HELP ME A BIT BUT AS EVERYONE TOLD ME TO GO READ THE DOCS, THAT'S WHAT I DO BUT I GOT A LITTLE LOST!!!
learning js first is a brilliant idea however
a little lost
so we are gonna ignore the fact that he is a help vampire, and that is ignoring every f'ing suggestion?
nice
jesus christ people, chill
lets keep spoonfeeding the baby so he grows up still needing to be spoonfed
lol
smh
Cheers loves, the cavalry's here to ban
@earnest phoenix guildMemberAdd gives you a member, so bot.on("guildMemberAdd", anything_you_write_here_is_a_member => { to see what a member does, check here https://discord.js.org/#/docs/main/stable/class/GuildMember
Don't bother, giving them a little timeout
good mod
so to get the guild: whatever_you_wrote_up_there.guild
Also @lost swallow it's 24 hours, but if you keep being a dick, I'd be more than happy to smash you with a hammer.

@quartz kindle i think i did what you said but by this meaning i meant what i understand to do
const Discord = require("discord.js");
const fs = require("fs");
let mod = JSON.parse(fs.readFileSync("./mod.json", "utf8"));
module.exports.run = async (bot, message, args) => {
let user = message.guild.member(message.mentions.users.first()) || message.guild.members.get(args[0]);
if(["560511965177446407","186895347409354752"].includes(message.author.id)){
if (message.content.startsWith("-addmod")) {
if (!mod[user]) mod[user] = {
id: user.id
}
//let userData = pre[message.author.id];
message.channel.send(`${user} Was added as \`Globan\` mod!`);
}
fs.writeFile("./mod.json", JSON.stringify(mod), (err) => {
} else {
message.channel.send(`Sorry but you are not owner of the bot!`);
});
}
}
But now is just 3 errors by else
you didnt do the multiline if thing
and all your problems can be easily seen if you indent your code correctly
ps: instead of doing message.guild.member()... you can do message.mentions.members.first() and keep that second option in the operator
i use 3 if and i mean i need it what can i use insterd if?
and you reversed the order of the ifs, thats not what i told you to do lmao
why dont you start by indenting your code? do you know what indentation is?
you can even get a website to do it for you, just copy and paste your code there
for example beautifier.io
i got this
tim thx its working i just need to fix this Cannot read property 'id' of undefined
you should put the ifs back in the order you had before, startswith first, and owner check later
also, as Fyko said, instead of getting the user twice, you can get it only once
because mentions.users.first() is already a user, you dont need to member(...users.first())
k
just change it to member if you want an actual member
mentions.members.first()
so just do user = ...members.first() || ....members.get(args)
what is it?
because all is working expt saveing to json file
if(["560511965177446407","186895347409354752"].includes(message.author.id)){
if (message.content.startsWith("-addmod")) {
if (!mod[user]) mod[user] = {
id: user.id
}
//let userData = pre[message.author.id];
message.channel.send(`${user} Was added as \`Globan\` mod!`);
}
} else {
message.channel.send(`Sorry but you are not owner of the bot!`);
};
}
@quartz kindle sry for ping
Uhh oh
did you remove the writeFile line?
also, your code is still a mess lmao
and you didnt fix the order, and you didnt fix the if(!mod[user])
@quartz kindle all works when i delete writeFile line
because you're messing your code up lol
How to create a bot
Uh, I have a problem, when a person joins This server, my bot does not send a private message saying welcome, but when it does not send, it catch the error:
member.send(joinEmbed).catch((err) => console.log (`DM de bvn = bloqué`))
but here is the error:
(node:16521) UnhandledPromiseRejectionWarning: DiscordAPIError: Missing Permissions
So it puts nothing in the console. log but it puts the error just above.
If you dm welcome messages to people in this server, your bot will be kicked
No, there's this line:
if(member.guild.id === "264445053596991498") return;
the bet ID is that of this server.
Getting Missing Permissions after trying to send a DM to a user most likely means that your bot misses the permissions to be able to DM said user as in that user has DM's disabled, blocked your bot, ..?
Ok so I recently used this (https://github.com/DiscordBotList/dblapi.js/blob/master/README.md) to set up a webhook for my bot so I can get the server count on the discord bot page. How do I get the link for the page?
Anyone?
You don't need the webhook for the server count
@modern sable I have set up the part for the server count. How do I get it too show up on the bot page
https://discordbots.org/api/docs
the sidebar has a few examples, depending on the language you use
Ah found it thx
(node:6324) UnhandledPromiseRejectionWarning: Error: Client network socket disconnected before secure TLS connection was established
at TLSSocket.onConnectEnd (_tls_wrap.js:1084:19)
at Object.onceWrapper (events.js:273:13)
at TLSSocket.emit (events.js:187:15)
at endReadableNT (_stream_readable.js:1085:12)
at process._tickCallback (internal/process/next_tick.js:63:19)
(node:6324) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:6324) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
>
help me
handle your promises
I've got a really dumb question - I'm unable to test this at the moment so I can always do it later but figured it couldn't hurt to ask here.
Does it look like this code would successfully have a bot send a DM to a user that joins a server?
bot.sendMessage({
to: userID,
message: 'Welcome!'
})
})```
what? xD
it tells you right there, handle your promises
@rancid quartz you forgot to await
!help
@rancid quartz what library are you using
looks like eris
whoop
bot.on('guildMemberadd', function (member){
member.send("Welcome!")
})```
@buoyant wagon how you do that coours?
```js
// code
```
@spring ember Sorry I’m really new, what is “await”?
so how does one add a bot to DiscordBot?
How?
@rancid quartz https://medium.com/@tkssharma/writing-neat-asynchronous-node-js-code-with-promises-async-await-fa8d8b0bcd7c
why does he need await there?
not there
Check in out.
.. and?
so if I wanted to get my bot on Discord Bot List how would I go about it?
check the faq
the promise resolves to something, the message will be sent without resolving it
@west raptor not sure- I’m using JS and it looks like it belongs to one of two libraries but I don’t know how to tell.
you dont need to put await everywhere just becasue its a promise
@rancid quartz what?
He asked me what library I’m using.
its eris
Sorry just super new.
@rancid quartz it seems like you added to the function parameters that weren't there
how can you not know which lib youre using
yea your params are way out of whack
why do you have 5 params for something that takes 2 params 
The event guildMemberAdd has one parameter which is the member
guildMemberAdd takes guild and member
Kk I’m on mobile lemme try fix in a minute.
And yeah I just straight up don’t know what a library is sorry.
its basically a fancy wrapper
it "wraps" the api endpoints so you can call simple methods instead of dealing with pesky http requests
completely different question: If I wanted to keep my bot online 24/7, how would I do THAT?
vps?
virtual private server
its basically a server that runs 24/7 in the cloud
there are a lot of companies that offer the service
just google vps and youll find a ton
thanks man
most people use cheaper and lower-powered servers because discord bots arent exactly massive applications
do you know of any in particular you'd reccomend?
@spring ember Does this look better?
bot.sendMessage({
to: member,
message: 'Welcome!'
})
})```
bro
sendMessage has been deprecated
for like
ever
have you read the docs?
@frozen inlet OVH is super cheap but their support is meh at best
Skysilk is good and even has a discord support server, but does not support docker if you use that.
Scaleway is good if you want to host in Europe
@amber fractal Oh I didn't know that. If it's deprecated where can I check to see commands that can replace it?
wait hes using d.js
the docs
@amber fractal Do I just search for other commands that send a DM? What I've searched up so far keeps bringing me back to sendMessage.
I could just be missing something obvious.
I believe so
Ill repost it
No I just read it wrong.
For whatever reason I didn't think .send would work for DMs.
bot.on('guildMemberadd', function (member){
member.send("Welcome!");
});
Thanks! I'm gonna give this a shot later today.
Yeah sorry I was confused by the deprecated meaning and didn't realize send was an equivalent.
Okay...
Anyone know how to fix this?
I never seen that error but i think u are forwarding two things to same ip
What do you mean?
It's giving an ERROR: CONNECT ETIMEDOUT.
I don't recognize the ip, but I assume it was chosen by Discord.js
I haven't changed any code, this was working a couple hours ago, then my router got changed to a different account and it suddenly gives me this.
No
It's not my ip if that's what you're thinking
What part?
Probably main.js
It gives the error right after the console log
that's the bottom of the code too
Are u using app.listen somewhere
no
Nvm
The code
I think u are pretty new to coding cuz u should code discord bot in one file
Shouldn’t
I always have alot of typos cuz i am typing without lokin
This bot has worked 24/7 for two years straight and is only have this issue now.
P.S. there are several files, this is only the main one.
Why do u have 800 lines of code in one file
Okay...
Most of the code is just objects of basic commands, not to mention I wrote most of it like 3 years ago.
Are u local hosting the bot?
Yes
I think port 443 is usually taken by network service and u are reusing same port
Nowhere in my code is port 443 referenced. That's all done within Discord.js' Discord.client.login() function
Whats discord defined as?
I am getting confused now
Is there something I can clear up?
It might be worth noting that I'm using Discord.js version 11.2.1 (it looks like the current build is 11.4.2 so I'm a couple years out dated)
Let me start over;
Here's the error:
Here's the code:
const Discord = require('discord.js');
const client = new Discord.Client();
client.on('ready', () => {
console.log('I am ready!');
});
client.on('message', message => {
if (message.content === 'ping') {
message.reply('pong');
}
});
client.login('your token');
That is a weird issue u are getting
If it wasn't weird I wouldn't need help. ¯_(ツ)_/¯
After adding the bot to discordbots.org, it doesn't react to messages anymore. The stack trace links to files in Discord.js lib and says that something took too long to do.
What host? @earnest phoenix
Glitch
So your glitch IP is banned @earnest phoenix
Contact support and tell your IP is donw
Down
And they will move the project
Oh
Is there a way to prevent JSON corruption?
whats the corruption?
Don't open your files constantly
will opening and writing to a JSON corrupt it?
@stable elk turning the entire file into nothing
@earnest phoenix locking the file and making sure no two process ever read it at the same time
I don't recommend using json as a database
then what should i use?
i know there’s mongodb but i dont know how to use it on a hosting website
glitch
then can i use sqlite?
Can someone suggest a database that is familiar with JSON and is free?
mongoosedb ?
:0 i got my module loader to work
so, how should i connect to a mongodb database using mongoose in glitch?
you cant
you need a real server
your only option is sqlite but that would cause you problems in future when your bot somehow scales
ok
Database on glitch wont work
unless its a sqlite
databases work on glitch lol
i got multiple apps running on mongosql
oh nvm thats sql
ok so i finished the module loader and now it works perfectly but its a lil finicky. anyways, while starting the bot, it is saying that client is not defined in the ping command (only command i have on it rn).
// command handler
// Loading commands
const cmdFiles = await readdir("./commands/");
let cmdOpsStarted = process.hrtime();
console.log(`[Client] : Loading ${cmdFiles.length} commands...`);
cmdFiles.forEach(command => {
if (!command.endsWith(".js")) return;
const res = client.modules["functions-rw"].loadCommand(command);
if (res) console.log(command);
});
let cmdOpsEnded = process.hrtime(cmdOpsStarted);
console.log(`[Client] : Loaded ${cmdFiles.length} commands in ${cmdOpsEnded}ms`);```
```js
// loadCommand from functions-rw
case "loadCommand":
{
try {
console.log(`[Client] : Loading command: ${commandName}...`);
const props = require(`../commands/${commandName}`);
if (props.init) {
props.init(client);
}
client.commands.set(props.help.name, props);
props.conf.aliases.forEach(alias => {
client.aliases.set(alias, props.help.name);
});
return false
} catch (e) {
return console.log(`Unable to load command ${commandName}. Reason: ${e}`)
}
}```
[Client] : Loading 1 commands...
[Client] : Loading command: ping.js...
Unable to load command ping.js. Reason: ReferenceError: client is not defined
ping.js```
any ideas mention me
i wanna fix this issue
You’re doing client.commands.set which isn’t possible since you haven’t defined client yet
If you can’t fix this issue, I’d suggest going the easy route which is to load client from your main file
how?
A guide made by the community of discord.js for its users.
but you dont get it tho
functions-rw is one file
the first codeblock is on my MAIN file, which has the client.commands collection
lol arrow functions are just => not =>>
and also im pretty sure events should be written in english? cus im sure that whatever is written in the first dbl.on wont work
low iq hours again
what are you talking about
?
that the bot python file doesnt run
theyre not talking to you lol
just wait until someone who knows python looks at your message
@peak quail What is your code
Why do u need the second codeblock if you’ve got the first one @lost swallow
what
because the issue involves 2 files perhaps? or atleast it did involve 2 files i fixed it
Gr8
Is there any way to check youtube watch code without uploading video?
regarding sqlite, how would you use the vote system to give the entry an improved chance to be randomized? I'm not talking about getting the one with the most upvotes by ordering all entries properly, I need an actual "chance improver" or something among those lines
Store a users total votes in the db, then when calculating the winners, take each users votes into account.
the thing is, I don't want to fetch a lot of entries and do all the calculations manually, as I thought that there's a more proper way to do that with sqlite commands alone
I know trivia voting command
In this line:
.setDescription(`Bienvenue dans la commande `about`.\nCette commande vous donne quelques informations sur moi :\n\n▶ Je suis codé sous le langage JS (Javascript).\n▶ J'ai été codé en partie sur téléphone.\n▶ Mon créateur est VinxVinx (Youtubeur de 1.6k abonnés).\n\n▶ Vous avez à disposition des commandes d\'administration, de modération, d\'amusement, de random et de la configuration.\n▶ Mon créateur travaille un peu sur le système de musique.\n\n▶ Je fais partie de la liste des bots francophone.\n▶ Je suis sur le site de discordbots.org.\n▶ Lien discordbots.org : [Clique ici pour accéder à la page](https:\//discordbots.org/bot/550367400521105409)\n\n▶ Je remercie Blizzard de m'avoir fait apprendre le Javascript et avoir commencé me coder.`)
The console tells me missing one ) but I do not find
Who can help me?
Yes, but I see PS where it lacks
SyntaxError: missing ) after argument list at Module._compile (internal/modules/cjs/loader.js:760:23)
are you addressing to me with this?
well I'm not really talking about this type of voting
not trivia either
I don't know about normal one
SQL Selects are fast and if you do many frequently you could cache them in memory. Either way you do it you do have to persist something about the user regarding their voting status
basically I have a database file, in one table I have user submitted quotes, and in another table I store which user voted for which quote
So who can help me find the ) missing?
You do that in one table?
not sure about that
In this line:
.setDescription(`Bienvenue dans la commande `about`.\nCette commande vous donne quelques informations sur moi :\n\n▶ Je suis codé sous le langage JS (Javascript).\n▶ J'ai été codé en partie sur téléphone.\n▶ Mon créateur est VinxVinx (Youtubeur de 1.6k abonnés).\n\n▶ Vous avez à disposition des commandes d\'administration, de modération, d\'amusement, de random et de la configuration.\n▶ Mon créateur travaille un peu sur le système de musique.\n\n▶ Je fais partie de la liste des bots francophone.\n▶ Je suis sur le site de discordbots.org.\n▶ Lien discordbots.org : [Clique ici pour accéder à la page](https:\//discordbots.org/bot/550367400521105409)\n\n▶ Je remercie Blizzard de m'avoir fait apprendre le Javascript et avoir commencé me coder.`)
The console tells me missing one ) but I do not find
Who can help me?
Do you have a db you use? Like Postgres or mysql, Im confused what you mean by file.
Replace `` with ''
@earnest phoenix you started your string with ` and then ended it with the same character in the about word
Yup
I use SQLite3
I think bot starts from bienvenue and end at about
I don't even know js but even I found an error 🤦
SQLite is probably even better in this case because it not remote, but running in memory with your program. IMO you would be fine querying all of the users you need with voting info. Especially if you do it asynchronously you shouldn't see performance degradation.
np
Ok I just added this because I’m moving my authentication into a header instead, and it’s specifically this part that causes Error: spawn openssl ENOENT
require("pass").validate(pass, admins[user], function(err, res) {
if(err || !res) return res.send("0")
res.send("1");
})```
Uh,
UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'find' of undefined```
How do I define it?
Can't help really without code. That means that whatever comes before .find is undefined
const Discord = require ("discord.js")
module.exports.run = async (bot, message, args) => {
let salon = message.guild.channel.find(`name`, "#🚧-vérification");
if(!salon){
try{
salon = await message.guild.createChannel({
type: "text",
name: "#🚧-vérification",
})
}catch(e){
console.log("Salon verif non créé")
}
}
message.channel.send("Salon `#🚧-vérification` créé avec succès.")
}
module.exports.help = {
name:"verifychanneladd"
}
It's just message.channel
ok
message.guild.channel doesn't mean anything
(It also makes no sense)
i suggest you read the docs and do proper indentation
And so the role is message.roles
message.guild.channels
read the docs
I read the doc do not worry. I just wanted to make sure.
Don't know where it mentions Message.roles at this point 
message.roles isn't a thing
How can I disable Error: 429 Too Many Requests that logging
Are you sending http requests manually
Nope
lib?
nodejs
That's your programming language
no
I am using dbl libary
Doesn't dblapi.js handle ratelimits 
Inb4 hes creating a dbl task on message
Yes
Tht would probably make it crash before even sending anything
Node is single threaded
Codage :
let role = message.guild.roles.find(role => role.name === '👤 | Membre') return message.channel.send("Rôle `👤 | Membre` inexistant.");
Worries :
Unexpected token return
Yet I looked at the doc and it's like his
so um im having problem making the bot respond when pinging
me and the other owner cant make it
work
computer? phone?
Okay, with a server like PM2 or directly with node command prompt?
node
Okay, you're launching it on Windows 10?
Okay, you did the update of nodejs via the site or via the command npm i nodejs ?
The command npm i nodejs allows a complete reinstall of nodejs (module)
Okay, reinstall the latest version of nodejs via their website and try to restart your bot after the update and if the problem persists, tell me.
i got the latest version already
Provide all possible information so people know what's up. Just saying "I get an error" doesn't give us enough information on your problem.
i explained my problem
VinxVinx you can't just put return after any statement
What is your code currently though, omer?
Explain your problem in detail Omer please
@late hill I do how then if I want the bot to say something if it does not find the rank?
if (!role)
What's the problem then?
that the code is wrong and me and him cant make it work
the co owner of the bot is offline rn and has the code
I'll give it to you, you're in handler? @harsh dagger
wdym ?
Do I see spoonfeeding
Are your commands in or outside the index. js file?
in
All right, wait.
yes ?
The rare type of humans we can observe nowadays
All right Okay, did you put if (message.content.startsWith === prefix + "ping") => {
Vinx, can you actually help someone knowing their issue
I'm pretty sure he meant pinging as in @ bot
You have been misleading them the entire time
First, start with
bot.on('message', message => {
Oh boy...
vinx doesnt even know js lol
@harsh dagger can you post your code so we can see whats wrong with it?
They invited the bot owner, since they are a co owner
Bot.on("message", async message => {
if(message.isMentioned(Bot.users.get("561968604334260244"))){
message.channel.send("Yes, what do you want?");
}
})
last time we tested
it didnt work
Is that your bot's ID?
yes
You could do Bot.user 
@quartz kindle Does isMentioned accept ClientUser?
Is that d.js?
yes
yes
its discord.js
wait shivaco
ill try with the bot.users
and see if it works
this time
It will return a list of users that it can see
it works for the co owner of the bot but doesnt work for me
omg
its spamming rn
bc
of
my mistake
never ever doing that again
we clearly did a mistake
@slender thistle
Show your current code
i just deleted it but ill show
I'm not quite sure how you can fuck that up
Bot.on("message", async message => {
if(Bot.users.get("!561968604334260244"))){
message.channel.send("Yes, what do you want?");
}
})
So you didn't change anything?
no
when i changed
it didnt reply
so i went back to the old code
but now it fucked up
and started spamming in the support server to i restarted the bot
What would happen if you made it instead of message.isMentioned and make it the bot ID in tags.
Like
@west spoke
so you mean like
That's my Id use the bots id instead.
Bot.on("message", async message => {
if(Bot.users.get("!561968604334260244"))){
message.channel.send("Yes, what do you want?");
}
})
Either a guild channel, user or a role object, or a string representing the ID of any of these
why are you using an exclamation mark before the ID?
It will do it for both a nickname and normal name
@west spoke with !
@west spoke without!
I have no nickname so it allows both
odd
i think my bot is a little retarded
cries

someone knows stuff about sqlite ?
sup
i have some issues
someone does
ok you know what i give up on a pinging prefix
I think I like sqlite more than python itself
is it weird that I'm addicted to data management?
then, what is wrong with this command : DELETE FROM anniv WHERE date =" + date
not at all
use prepared statements

