#development
1 messages ยท Page 856 of 1
ive seen in another bot once
can he use glob wildcards for windows ?
this is what i need
wat dafuk
turn bruh.exe into okay (just make shortcut of it in the same folder)
impossible

okay shortcut can execute bruh.exe
If that's what you're looking for
but bruh.exe can't turn into okay or make sh
Why do you need that tho ?
-bots
My custom bot wont go online / start ? any advice?
Try this @terse trench https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/resolve-path?view=powershell-7
Then you can get the location of bruh.exe within the same directory or other
./bruh.exe
And do whatever you want from there.
its ait i found another way
@agile dew did anything log ?
@valid holly Nope
client.on("message", message => {
if (message.content.startsWith(PREFIX + "dice")) {
let fish = Math.floor(Math.random() * 6) + 1;
let fish2 = Math.floor(Math.random() * 6) + 1;
let result = `${fish}-${fish2}\n`;
if (fish == 1 || fish2 == 1){
result += "Snake eyes";
}
message.channel.send({
embed: {
color: 12745742,
title: "Dice " + message.author.username,
fields: [
{
name: "Dice game",
value: result
}
]
}
});
}
});```
token: auth.token,
autorun: true
});
console.log(bot)```
presenceStatus: 'offline',
connected: false,
inviteURL: null,
connect: [Function: bound ] }```
^wat
how could i make it so if they both are equal to 1 it says snake eyes
๐ค
fish1 === fish2?
&& operator
but then if they are 2 and 2 3 and 3 4 and 4 5 and 5 it would say snake eyes
if(x && y == 1)
i am now thank you desu
@agile dew any entry where your bot connects to the websocket ?
,
Or you just listed the client options ?
Np @queen needle
Can you also mention your lib version that you're on
logger.info('Connected');
logger.info('Logged in as: ');
logger.info(bot.username + ' - (' + bot.id + ')');
});
bot.on('message', function (user, userID, channelID, message, evt) {
// Our bot needs to know if it will execute a command
// It will listen for messages that will start with `!`
if (message.substring(0, 1) == '!') {
var args = message.substring(1).split(' ');
var cmd = args[0];
args = args.splice(1);
switch(cmd) {
// !ping
case 'ping':
bot.sendMessage({
to: channelID,
message: 'Pong!'
});
break;
// Just add any case commands if you want to..
}
}
});```
Just copied this off somewhere :p
lets try discord.js :p
I though discord.io was abandoned
well looking at how you wrote your code I guess 436 is a small number
@valid holly discord.js worked Thanks
np
@queen needle
you can start with saving actual information you'll reuse into let
Like:
let cmd = message.content.trim().toLowerCase().startsWith("your_prefix");
if(cmd + "command") { // bool
}
@agile dew to run a bot in d.js you gotta use client.login()
passing the token as an argument doesn't work iirc
yeah did that, Thanks @copper cradle
can I get a link to it?
I assume you can use Node's FS and console class
ยฏ_(ใ)_/ยฏ
For logs that would suffice for me.
i cleaned up my code and got it down to 390
yeah, there are a lot
oh it's Tim ! 
Anyone know some good API's I could use for my bot.
what do you want to use 'em for?
Just make my bot better that is all.
Like statistics. My bot is more of an information one.
hmm
Really broad question tho
Anyone know good APIs for images or memes
Idk how to is the problem and when I tried I could find s video or article or sub reddit or anything
Find restful API's
Use HTTPS's GET method
Giphy has restful api's
Here is a response to query search "meme"
Okay I'll try that and up date you
๐
wish me luck, 6 months of not coding in discord.js and now making a discord bot...
good luck
[D.js v12] anyone know how to handle sending dms to user using shardingManager and dblapi webhooks? I tried broadcastEval but it ends up sending duplicate dms.
Essentially I want to send a dm to a user after they vote but with shardingManager I'm not sure how it would work without the client.
how would i make a command where its like !thanks @ a user thenit would say auser was thanked by my username
@queen needle discord.js?
yes
Version?
11.5.1
Hmm... I'm not sure it would work but are you interested on updating to a newer version of discord.js?
@queen needle
now its 12.1.1
@wide ridge send it only to shard 0
send the dm to shard 0?
send the vote to shard 0, and send the dm from there
hmmm
module.exports = function(controller) {
controller.hears("!thanks", ["direct_mention", "mention"], (bot, message) => {
let response;
let sender = message.user;
// Many bots use the this method but sometimes it doesn't work, for example if you mention more than one person
//let recipient = message.mentions.users.last();
// this method filters out any users that aren't bots
// if you have a bot that does more administrative things like blocking people, you might want to filter even more
// like filter out admins or the person sending the message
// it's using Discord.js for all this, yep that's right you have access to everything in Botkit AND Discord.js
// https://discord.js.org/#/docs/main/master/class/User
let recipient = message.mentions.users.filter(user => user.bot === false).last();
// this is a list of potential responses, it chooses from them randomly.
// Try changing them or adding your own.
let responses = [
`${recipient} got kudos from ${sender} ๐`,
`${sender} thinks ${recipient} is awesome! โจ`,
`Hey ${recipient}! ${sender} appreciates you! ๐`,
`Hey ${recipient}! ${sender} thinks you rule! ๐ช`
]
response = responses[Math.floor(Math.random() * responses.length)];
bot.reply(message, response);
});```
like that but i dont want to have to mention my bot
let Muser = message.mentions.users.first();
if (!Muser) {
return message.channel.send("You thanked yourself...")
} else if(Muser){
return message.channel.send(`${message.author.username} thanked ${Muser.username}!`)
}```
@queen needle
This would work...
ye gopi
yeah cause I'm trying to emulate this behavior:
hmm ok I'll try it out!
thanks a lot man, appreciate the response
parrsing error return out of function
can anyone help me with sql
potato I can try? what's the question
@queen needle huh?
Screenshot of your code...
im watching a video im doing it just like him but its not working
it doesnt make a table when i run the bot
what language are you using?
py
can you post some of the code and maybe the link to the video you're viewing?
My discord server โบ https://discord.gg/BN6WaDs
(If you have any questions or just want to have a chat with us)
(Some Cool Stuff)
Nertivia โบ https://nertivia.supertiger.tk/
My server in Nertivia โบ https://nertivia.supertiger.tk/invites/B4tMwO
Install discord.py โบ pip install...
thats the link
@queen needle yea that's the code but what does the error say?
@bot.event
async def on_ready():
db = sqlite3.connect('main.sqlite')
cursor = db.cursor()
cursor.execute('''
CREATE TABLE IF TABLE NOT EXISTS main(
guild_id TEXT,
msg TEXT,
channel_id TEXT
)
''')```
Yup
@wide ridge the user wont necessarily be cached in shard 0, but you can fetch it from any shard and create a dm channel from any shard
alternatively, you can broadcastEval to all shards and find which one has the user cached
Parsing error: 'return' outside of function
@smoky matrix what is you trying to do
still have error
I dont know what lang you're using cinnamon
im trying to make a table for the database
that's js
alternatively, you can broadcastEval to all shards and find which one has the user cached
@quartz kindle but there can be multiple shards that cache the user right?
they're using js
@queen needle wait... How's return outside of a function...
@wide ridge yes
cinnamon roll
idk
thank
if you get an error that says return outside of function
then what do you think you have to do?
happy birthday @west spoke lol
oh so for the broadcastEval I'm just looking to return the user object?
check your code and see where you have a return statement outside of a function
Ty tim
cinnamon roll, you have a return statement at the very end of your code
and that is outside a function
you can't use return outside of functions
I recommend learning the basics of functions and the language you're using before attempting this
@wide ridge i see what you mean now, if the user is cached in more than one shard, it will send multiple dms. so then you have to fetch the user instead
yeah
do the shard 0 method
manager.shards.first().eval("client.users.fetch(id).then(u => u.send('voted'))")
i got rid of the error but when i do the command nothing happens
I'll try it out, thanks so much Tim!
stuck on fetching banned users
@queen needle... It doesn't even give any errors?
no
client.on("message", message => {
if (message.content.toLowerCase().startWith === "!thanks") {
let Muser = message.mentions.users.first();
if (!Muser) {
return message.channel.send("You thanked yourself...");
} else if (Muser) {
return message.channel.send(
`${message.author.username} thanked ${Muser.username}!`
);
}
}
});```
code
@queen needle that code block is outside of the message event callback, holy cow, don't you see it? the underlined brackets are the ending of the message event, you literally tried to put code outside of it and you're still hoping it works
@queen needle why do you have that ); there?
channel send
Hmm yea like creating a message event for each command is not a good thing...
@copper cradle also he put a ); there which shouldn't be there(under the last code line)
lemme see
i got rid of that
where
Oh nevermind...
that? that's ok, that's the ending line of client.on
today we may see snails getting mad v8
Hmm that code should work tho...
yes that one should work
I gave him that code but he says it doesn't work...
@copper cradle also he put a ); there which shouldn't be there(under the last code line)
@earnest phoenix which one?
nono
it's correct
i was making sure
@pale vessel nevermind i thought it was a mistake
cinnamon roll, if it doesn't work
k
send the error you get
so if the ); isnt there i have an error
Add that back...
and that's it
Lmao
i added it back testing that code rn
reminds me of that cat loading picture
Cinnamon roll, I recommend you learn the lang first
english language
no
still didn't give a output
just show us the whole file lol
this is an obvious case of "I watched TSC's tutorials, and now I think I'm a programmer, now I gotta start on a big project without knowing that I'm doing, encountering thousands of errors which I don't know how to fix"
@queen needle do you store your commands in one file or make command handlers?
or do you make a message event for each command?
if he does that he has a small brain
how do i something like
if (message.channel.typeof == "DM") return;
type
if (!msg.guild)
and also
I cannot install any modules, Everytime i try doing it it sends a red ERR, help?
or message.channel.type == "dm"
@earnest phoenix show the err duh
Literally one message event in the first part of the code is enough...
just show us the whole file
but not the token
@earnest phoenix show the err duh
@copper cradle https://hastebin.com/vorijatuqo.sql
install node-gyp
so python and vs stuff
alright
you need python for that
also
stop transforming your strings in your command handlers ๐
it's slower and you're wasting resources
use localeCompare
oh damn he bought nitro
i just wrote some random shit in bot description lol
idk what to write for 300 characters oof
yeah you'll get declined
RIP the dream
it basically is nothing
but that's a very common issue here
check #mod-logs and see how many bots get declined for having random stuff in their long desc
so no problemo

yes
you do you
XD
how do u get user's voice channel id?
in discord.js v12 its member.voice.channel.id
@quartz kindle Thanks
what is what?
ok
who me ?
yes
just trying to add now for fun
py
thats 40% of mine
eh whut lol
yeah
bc there have been people that think that by creating a bot account in the dev portal you have a fully functional bot
Why am i having such a hard time finding the code to do something for say "!countdown 24h" and the bot to have it shown on the server?
move to #memes-and-media this isn't a channel for conversations
for say
what
why do you want to find the code
just code it yourself
code is not something you find, its something you do lol
wait a minute my bot has to be online when they review ?!
oh yea right
bc of your description
after the description right ?
how else would they test the bot

yeah
i cant find how to code it lol #nub
and copying them only makes u dumber
^
yeah they just give you the code with no explanation of concepts and lol hf bothering others with that shit
take a sheet of paper
they are not coders , but common men trying to get a bot
and do the following
"what do I want to do?
what's the logic behind it?
If I want to do this, how can I do it?"
u seem to over simplify coding xD
lol
it requires knowledge and common sense
well, you do have to learn some stuff, its a language after all
yea lol
yeah
Honestly, learning is the way to go
what "complex problems"
writing code is easy. solving problems with code is not
the hardest problem I have had with coding is trying to make a circle with the top up and the amount filled as a percentage
that is what i said
but I small brain and only needed to remove .5 PI from each and a little other shit
radeons are confusing tbh
radeon ?
radians*
hmm
convert them to degrees then convert them back lmao
hehe
im not big brain enough for that
ye ik
Tim I was wondering for the method you mentioned earlier
manager.shards.first().eval(`this.users.fetch(\`${userId}\`).then(u => u.send("voted"))`);```
This method would only check shard 0 for the user wouldn't it? How would it find users that are not on shard 0? Do all users get cached on shard 0?
I know math
just change it
this.users.fetch(\`${userID}\`).then(u => {
if (!u) return;
u.send('voted!')
})```
@wide ridge fetch gets the user from the API if not cached
thats why its a promise
wait now im confused wut
I'm gonna try to push my shard voting tonight, and I'll see how it goes. You will not be forgotten Tim โค๏ธ
does users.fetch() get a user no matter what shard its on?
oh got it
yeah
pretty useful
once I learned to use docs, js came really easy to learn
Theres a difference between following tutorial to copy it and have vs watching a tutorial to learn and understand it
then there are languages like rust where docs make it harder
ye I never watched tutorials :D
TypeError: prefixes.findOne is not a function
at Object.code (/app/commands/botinfo.js:15:13)
at /app/index.js:117:17
at /rbd/pnpm-volume/034599ea-c1c3-422b-9783-c3b2bb2163b1/node_modules/.registry.npmjs.org/mongoose/5.9.7/node_modules/mongoose/lib/model.js:4837:16
at /rbd/pnpm-volume/034599ea-c1c3-422b-9783-c3b2bb2163b1/node_modules/.registry.npmjs.org/mongoose/5.9.7/node_modules/mongoose/lib/model.js:4837:16
at /rbd/pnpm-volume/034599ea-c1c3-422b-9783-c3b2bb2163b1/node_modules/.registry.npmjs.org/mongoose/5.9.7/node_modules/mongoose/lib/helpers/promiseOrCallback.js:24:16
at /rbd/pnpm-volume/034599ea-c1c3-422b-9783-c3b2bb2163b1/node_modules/.registry.npmjs.org/mongoose/5.9.7/node_modules/mongoose/lib/model.js:4860:21
at /rbd/pnpm-volume/034599ea-c1c3-422b-9783-c3b2bb2163b1/node_modules/.registry.npmjs.org/mongoose/5.9.7/node_modules/mongoose/lib/query.js:4370:11
at /rbd/pnpm-volume/034599ea-c1c3-422b-9783-c3b2bb2163b1/node_modules/.registry.npmjs.org/kareem/2.3.1/node_modules/kareem/index.js:135:16
at processTicksAndRejections (internal/process/task_queues.js:81:9)
what did you define prefixes as?
as a Schema table
what DB?
wait I see its mongo
show where you call code()
this?
I got a problem when typing node .
at Module._compile (internal/modules/cjs/loader.js:1158:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
at Module.load (internal/modules/cjs/loader.js:1002:32)
at Function.Module._load (internal/modules/cjs/loader.js:901:14)
at Function.executeUserEntryPoint
[as runMain] (internal/modules/run_main.js:74:12)
at internal/main/run_main_module.js:18:47
hmm
@woeful fractal you didnt show the error
I reinstalled it
congrats u managed to show everything but the error
Is it not an error?
wut
you switched them around
@woeful fractal thats not the complete error
there is likely more information before that
node .
C:\Users\skybl\Desktop\Discord Bot\index.js:2
const bot = new Discord.bot();
^
TypeError: Discord.bot is not a constructor
at Object.<anonymous> (C:\Users\skybl\Desktop\Discord Bot\index.js:2:13) at Module._compile (internal/modules/cjs/loader.js:1158:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
at Module.load (internal/modules/cjs/loader.js:1002:32)
at Function.Module._load (internal/modules/cjs/loader.js:901:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12) at internal/main/run_main_module.js:18:47
Discord.Client()
there's so much wrong with that
Its in there
const Discord = require('discord.js');
const bot = new Discord.Client();
?
find line 13
?
show your code
ok
why don't people learn to code before attempting on such a project
idk, desperate?
lmao I didnt learn to code
me too
bad
but i ended up fine

ive know js for a while im just bad with it
my js skills are like maybe 30/100
- Create code
- Make a mess of your code
- Fail at making a bot
- Spend hours trying to fix a simple issue
- Accept that your code is bad
i accpeted my code was bad before i coded
your code never stops being bad
no matter how many times you improve it
my code is still bad
yeah
but it'll never be worse than before
what?
I learned js from trying to make a discord bot ๐คท
Thatโs how I was introduced to it
so in jsdoc how would i define what a different instance of each value would mean?
so i have this typedef that is something that can be a 0, 1, or 2, each meaning like
0: mute
1: kick
2: ban
how would i document the meaning of each of those?
wdym
ber is drunk
I didn't understand what you're trying to do
Document? What?
send a screenshot or something
so i have the @typedef {Integer} Name
i want the jsdoc to be able to tell the dev what each instance of its value means
so if that Name = 0 it means mute, 1=kick, 2=ban, etc. but i want that to be included in the documentation
with discord.py how do you set a variable like "playing" to 0 in the after kwarg with voice_client.play()?
client.voice_clients[0].play(discord.FFmpegPCMAudio(str(message.id) + ".wav"), after=*SET PLAYING TO 0*)```
wouldn't @twilit halo work? @slim heart
@slim heart not sure about this, but maybe a typedef line followed by param lines
for each possible param
o alright that might work ok
or some combination of that
that's what I said
another jsdoc question as well is how can i set the default of a @property ?
/**
* @typedef {object} E
* @property {string} dow
*/
isn't there a docs
@copper cradle no that wasnt the thing i was talking about lol
sorry default
@property {Type} name=[default] blah
wait whot
jsdoc is weird af
yeah
i cba using it lmao
i need it for good resume 
tbh i dont even comment my code
hmm
commenting your code is always a good practice imo
unless you're the only one who uses it
but you know, cba...
lmao
nope param doesnt work oof
semi-ghost ping bad
yeah
Glitch is down, rip my bots
same
well it's fReE
if you do ```js
let val = promise().then(x => x)
// will it be the same as
let val = await promise()
I don't think so
why wouldnt it be
what would
ok it seems to just be when you return with .then, like ```js
return promise.then(val => val) // returns whatever the promise resolves
ok
The then() method returns a Promise
await promise() returns the result of the promise
promise.then() returns the unresolved promise, and the result inside the callback
oh ok
but when you do return promise.then(v => v), it returns the result of the promise, right?
no
ohh wait
the result is only available in the callback
but if you do await promise.then(val => val), it will return the final result of the promise chain
so you can for example modify the result of the promise before returning it
yeah i see
but if you await a promise and catch it with .catch, will the .catch do nothing much?
the catch will catch the error, and the await will receive the result of the catch function, if any
oh
just thought i was still recieving errors because i catch a promise that gets awaited
but nvm thats just me
essentialy, await something.catch(e => false) is the same as return something || false in promise form
oh okay
What Linux distro is good for NodeJS discord bots?
ones that supports NodeJS I guess?
ยฏ_(ใ)_/ยฏ
ubuntu
very easy to set up and manage
Ok
otherwise it literally doesnt matter
There no best distro, you could probably even run it on Alpine
run it on DaveOS
run it on gparted live
OpenBDS
how would I check
if user is not banned
and if they arent banned
then return
in v12
?
d.js?
yep
fetchBan()
why are you even asking this
don't ya know how to use if statements and expressions?
it sends the ban reason and all that in logs
Can you help me #topgg-api
Have been waiting. Still no response
it takes up to two weeks afaik
Hey van you help me #topgg-api plz
@lean pumice you'll be accepted or declined maybe like tomorrow because i added my bot same day
mods will get to your bot eventually
its in a queue
How can i add a image in background just like that ? Do you know ?
that is for certified devs
You need to be cert
okay thanks
Only cert
https://nmw03.is-inside.me/TK3MceTK.png
https://nmw03.is-inside.me/zyTSQlQF.png
What can cause it to send multiple different messages
Is it normal that my command sends an error message but still works fine?
@summer torrent are you trying to make it restart itself, or are you restarting another process?
itself
impossible
maybe pm2 restart 2 ๐ค
@summer torrent Try this; exec("pm2 restart app"โ, async(err, res) => { if (err) m.edit(...) else { ... } });
that shouldnt even be working, but i think pm2 gives you a grace period before killing the process, thats why it works
are you promisifying exec?
i believe exec can return both stderr and stdout at the same time, so maybe the promise is resolving with both lol
idk
Hey, so i made this prefix command using quick.db, when i execute the command it sends me a error message but the prefix still changes. Should i be worried?
what is the error?
guys, hello, i need some help here!
i'm trying to make a command that stores a to-do list in a .json file, i'm using fs, but when i run the command fs.writeFile it overlaps the already created info!
json cannot be partially edited
you need to load the entire json file, modify it, and save the entire json file
json is very inefficient for storing dynamic data for that reason
how can i create a efficient way to do it?
by not using json
are there to-do lists editable by users? can anyone create them?
i just need to him add to storage and send to chat from storage
yep
is free to use
then ideally you should use a database
what's the difference?
they are very different
SQLite is an embedded SQL database
mongo is a server NO-SQL database
SQLite is integrated into your bot. mongo needs to be installed separately and run as a server in your vps (or if you use a remote mongo service)
SQLite uses the SQL language to move data
mongo uses a different style, with documents, promises and chains
let filter = m => m.content.toLowerCase() === "accept" && msg.author.id == invm.id || m.content.toLowerCase() === "deny" && msg.author.id == invm.id
So does the && not apply in this type of filter?
This is for awaiting messages.
I am stupid!
Lol, it's m.author.id, not msg.author.id

you can simplify that even more
yeah
anyone here uses quick.db?
Welp, I am trying to make a bot that use a database with MongoDB on Python and I need a little bit of help. I am making a bot where it does boxing matches and depending on who wins or loses the wins get a +1 in the wins column and the loses +1 in the loses column and I am also calculating a percent for wins/total matches. My only issue is that in the dictionary keys cannot equal 0 and so I had to make them strings, but there really is no way to divide a string by a string, I've read the docs and have a decent understanding, but yeah
When i print the votes in console i get a number, but when i put it in the embed, it shows up undefined
var votes = await vote();
const embed = new Discord.RichEmbed().addField(`Votes`, votes, false);
await message.channel.send(embed);
async function vote() {
request(`${url}`, { headers: { "Authorization": `${config.dbl_api}` } }, function (err, response, body) {
let bot = JSON.parse(body);
votes = bot.monthlyPoints;
})
}
nvm.. i got it
@past trail turn the strings into integers do the math and then turn back into strings
@visual sandal do you know what a return keyword is?
learn the basics of functions
you need to return votes duh
@visual sandal
inside the callback for request return votes
oh sry.. i was doing it a different way and sent the wrong code
this is the original
var votes;
request(`${url}`, { headers: { "Authorization": `${config.dbl_api}` } }, function (err, response, body) {
let bot = JSON.parse(body);
votes = bot.monthlyPoints;
})
it's fine.. i got it working https://discordapp.com/channels/264445053596991498/272764566411149314/696940697030230098
I need help.
How would you get your socket less hung up?
To where it dosen't get hung up^ or fix it
alright
thanks
!level
!level
That's not even a command.
!rank
..
!leaderboard

how come green names are doing this...
Hey! what do you guys think is better?
https://titandev.is-inside.me/QKDN0z00.png
Ye
thanks
hey dm me i need some bots im willing to pay
Hm
In js if you use setTimeout, say as a timeout, would that use of lots of ram?
@copper cradle like setTimeout function
he knows, he answered the question
yeye
@worthy narwhal can you not randomly tag me for no reason 
Idk what you're taling about
about:blank
Your link is literally
lliterally a blank page
so why would it be a valid page
how come we can't perform async actions in
console.log(`User with ID ${vote.user} just voted!`)
}
I tried to use async and await but it crashes or gives me errors when I try to fetch something from my db
hmm
show your code, where exactly are you awaiting
rip
GG
idk even was my bot running or no when i applyed becosue i used garbage 24/7 host
is x! a common prefix?
Oof
Hi, stupid question here but have to know. Anyone knows since when (approximately) search for mentions using like mentions: Menno#0985 instead of using your id to search a mention? Is it like a couple of months (I guess that)?
yea, some months
I thought it was forever
@crimson vapor well I have not seen it before at least this year, I thought
idk then
Just searching for the id is usually enough to find all mentions of that person, so instead of mention: 481031493490049044 you can just do 481031493490049044
how do i check for a set if it haves something in it
im basically doing this
const myVariable = new Set();
const myVariableSeconds = 5
myVariable.add(msg.author.id)
setTimeout(() => {
myVariable.delete(msg.author.id)
}, myVariableSeconds * 1000)
```but i want to check if ((myVariable)) has anything in it
myVariable.has
okay thanks
Just searching for the id is usually enough to find all mentions of that person, so instead of
mention: 481031493490049044you can just do481031493490049044
@blissful scaffold yeah I know, but that was not my question
The bot write [object object]
@earnest phoenix How do you saving to database?
how do i specify only specific roles can perform a command?
is it possible to make a rich presence in discordjs?
@plush remnant something like this:
if (!member.roles.has(roleid1) && !member.roles.has(roleid2)) return;```
ok ๐
if you have a lot of role id's you should make an array of it. But I don't know the code to check that correctly out of my head
i will try it
๐
Does role.managed automatically mean the role is not possible to obtain for server members?
.managed
Whether or not the role is managed by an external service
Type: boolean```
So, I'm gonna ask something I'm sure is completely noob, but how am I supposed to send the 'config.json' with client id to, say, top.gg? I thing I am missing something and I can't find it.
what?
Could you elaborate please?
please help me console error ```
uncaughtException: ReferenceError: guild is not defined
Code```js
const client = new Discord.Client({autoReconnect:true});
//MYSQL START
client.con = mysql.createConnection({
host: "*****",
user: "******",
password: "******",
database: "*****",
});
client.con.connect(err => {
if(err) throw err;
console.log("Connected to database!");
});
var con = client.con
con.query(`SELECT * FROM prefix WHERE sid = ('${guild.id}')`, (err, rows) => {
if(err) throw err;
//MYSQL STOPED
client.on('error', helper.error);```
I don't think you need ID
All you need is your bot's token to connect to Discord
but more than one server requires the server ID for a unique prefix and commands
so here's how I could access the guild id
Either way, this is not supposed to be in github, right?
Yeah, you must not expose your token
It's basically password for your bot's account and anyone who has your bot's token can do anything as your bot
I mean you can if it's in a private repository ig
That's my doubt, how will this work after publishing, the code expects to read this from a file that is not there
Hedi, you need to define guild?
but how do we define it?
usually, const guild = something, but in your case, your code needs to be put somewhere where a discord guild object is present, for example, guildCreate
Where is this Heidi?
discord js
index.js
Is it inside bot/client.on("something" ?
no
server pc
yes
where?
Ok, so I thing a config.json file at root folder with a 'token' key is a convention, the publisher will create it for me.
index.js
const Discord = require('discord.js');
const fs = require('fs-extra');
const path = require('path');
const objectPath = require("object-path");
const chalk = require('chalk');
const mysql = require('mysql');
const osu = require('./osu.js');
const helper = require('./helper.js');
const client = new Discord.Client({autoReconnect:true});
//MYSQL START
client.con = mysql.createConnection({
host: "****",
user: "*****",
password: "******",
database: "*****",
});
client.con.connect(err => {
if(err) throw err;
console.log("Connected to database!");
});
var con = client.con
//MYSQL STOPED```
ok?
but
why is guild.id defined?
con.query(SELECT * FROM prefix WHERE sid = ('${guild.id}'), (err, rows) => {
you're looking for a prefix right?
This would be in the bot.on('message' right?
yea
you need to con.query inside the bot.on message event
and then look for ${message.guild.id} instead
okey
- you would need to define
let guild;beforecon.query => {}
then guild = (prefix from db here) inside con.query => { /* here */ }
is messageReactionRemoveAll only emitted when every emoji is removed at once, or at the point where every emoji gets removed
correct
messageReactionRemove is for removing a single reaction, messageReactionRemoveAll is for removing all reactions on the message, messageReactionRemoveEmoji is for removing all reactions of a single emoji
oh i didnt know users could do that
never actually saw that button xd
but thanks
no actually it doesnt show up for me

@grizzled raven you have to have the manage messages permission for that
huh that's weird
but the button is only there if there are reactions (of course ;))
Hi! I have a little problem. I have, to make it simple for now, two events: guildDelete and guildMemberUpdate. When my bot leaves a server, guildMemberUpdate is emitted before guildDelete. guildMemberUpdate starts executing a function, but that function should not be executed when the guild is executed. Unfortunately, the event is before guildDelete. I can't stop the function by doing things like this:
if (guild.deleted) return;
// or
if (client.guilds.get(guild.id).deleted) return;
// or
if (!client.guilds.get(guild.id)) return;```
A thing I don't want is using a setTimeout, as that can produce errors if the function after guildMemberUpdate will be executed **without** a deleted/left guild.
Question (in short): Is there any way of detecting a deleted guild in an event that's emitted before guildDelete, without having a noticable delay?
how can i fix this
does .then and .catch always apply to the original promise?
Afaik they both return the original promise, so yes
@earnest phoenix ow this sounds really good! Can you tell me what you think my problem is?
so we know we're talking about the same thing
promise().catch(() => null).then(p => p) // will p be null or the resolved result?
nvm ill just
https://tryitands.ee to myself
yep p is null
only if the promise errors
that makes sense
@earnest phoenix guess I know what you mean. When my bot leaves, it shouldn't trigger the events that delete the role etc. from my bot
right?
no that's not what I mean
hmm
Do you still have any other idea? I was excited for a moment but nothing to blame you for
hmm is that possible?
I mean, I have no idea how to do that other than something like if (!client.guilds.get(guild.id)) return;. But that doesn't work
How do you send a request to a http/https website using node and check if it returns?
if(!guild.available) also doesn't work. However, first time I tried it, it said 'Cannot read property 'available' of undefined'. So I can conclude it's very random
I mean, that time client.guilds.get(guild.id) was undefined, and sometimes it's not
ohh okay
I'm totally confused now btw not by you
is there a specific button or x to remove reactions from a single emoji for the messageReactionRemoveEmoji event
On discord js v11.6.3
bot.users.size not showing the correct number why ? Help me
Can i fetchAllMembers ? If yes how to ?
Tu devrais utiliser la derniรจre version et regarder la doc
Noc you good?
He speaks french and doesnt seem to be that good with english
o
Le problรจme c'est que mon code n'est pas pour la v12 et je n'ai pas envie de le changer pour la v12 car c'est complexe pour moi
@earnest phoenix bot.on('ready', () => { setInterval(async () => { let users = 0; for (let g of bot.guilds.array()) users += (g.members.size - 1)); await bot.user.setActivity(`${users} user${users !== 1 ? 's' : ''}`, {type: 'WATCHING'}) .catch(err => console.error()); }, 15000); });
If you want to show in status
to edit?
is there a specific button or x to remove reactions from a single emoji for the
messageReactionRemoveEmojievent
i meant, what do you do to trigger the event, like clicking the remove all reactions button to trigger themessageReactionRemoveAllevent
client.users?
No leny i make an embed with bot.users.size but it not showing the correct number
Can you explain
I have code an RichEmbed for see the total users of any server (bot.users.size) but bot.users.size not showing the correct numbers of members
When you update packages, you should consider checking the documentation to see what has changed
Me?
Le problรจme c'est que mon code n'est pas pour la v12 et je n'ai pas envie de le changer pour la v12 car c'est complexe pour moi
you, yes
Yes
yes
Erm so I am using Glitch and discord.js and I cannot add anymore command files (we are using shards and a command handler), otherwise the bot goes offline or the bot doesn't respond to other commands.
I am having this error:
/app/bot.js:25
console.log(Command ${props.config.name}.js (#${props.config.id}) loaded!);
^
TypeError: Cannot read property 'name' of undefined
at files.filter.forEach.file (/app/bot.js:25:49)
at Array.forEach (<anonymous>)
at fs.readdir (/app/bot.js:22:78)
at FSReqWrap.args [as oncomplete] (fs.js:140:20)
guild.members.filter(member => !member.user.bot).size; @earnest phoenix
Ok il going to test
Bots Not included
It's only count members
You can count members for each guild
that won't give an accurate count unless you have all members cached
It will
no, it won't
let members = 0
client.guilds.forEach(g => {
members += g.memberCount;
});
members
I need help asap
It will
then filter out bots?
just -the bot count
jesus christ what is up with the moronic behaviour
for each guild
yes, but you need to have all members cached to know how many bots there are in the first place
idk probably wont work
@earnest phoenix hmm that's not hopeful. And I don't think it's better than just a loop over everything, or is it?
Erm so I am using Glitch and discord.js and I cannot add anymore command files (we are using shards and a command handler), otherwise the bot goes offline or the bot doesn't respond to other commands.
I am having this error:
/app/bot.js:25
console.log(Command ${props.config.name}.js (#${props.config.id}) loaded!);
^
TypeError: Cannot read property 'name' of undefined
at files.filter.forEach.file (/app/bot.js:25:49)
at Array.forEach (<anonymous>)
at fs.readdir (/app/bot.js:22:78)
at FSReqWrap.args [as oncomplete] (fs.js:140:20)
You probably forgot to add a config property to one of them
Name is undefined
ok
Hey, I my bot is on github because I use Heroku to run it, but how I can link the .json file to the os-Command?
os.chdir(r'officialyr9/adbotupdate')
Because I would create a .json data
Look @opaque kite
Not work
I have defined guild
oh okay
well thanks for the help, and Tim too! Sadly the problem is not solved yet (I give up for today xd)
What's the issue Menno?
No
It's works fine for me
I'll see if it works for me?
Yeah create a variable of it
.addField("Utilisateurs ๐ถ ", `${guild.members.filter(member => !member.user.bot).size}`, true)
```
I use an handler
;) I know right
Commands hanler
.addField("Utilisateurs :baby: ", ${message.guild.members.filter(member => !member.user.bot).size}, true)
Is it in a command?
where is guild defined?
Look my code
What's the issue Menno?
@elder vine I want to stop code from executing when a guild is deleted. For example, when my bot is kicked, the guildMemberUpdate event (which takes away the roles) is before the guildDelete event. But the code in the guildMemberUpdate event should be stopped when the guild is not available anymore. Things likeif(!guild.available) return, !guild.deleted, !client.guilds.get(guild.id), !client.guilds.get(guild.id).available or !client.guilds.get(guild.id).deleteddon't properly work. And I am not a fan of using setTimeout as that can cause new errors
const Discord = require("discord.js");
const config = require('../config.json');
const moment = require("moment");
require("moment-duration-format");
const cpuStat = require('cpu-stat');
const os = require('os');
module.exports.run = async (bot, message, guild, filter, args) => {
message.delete()
let { version } = require("discord.js");
const ram = bot.emojis.get("684502896758358116");
const cpu = bot.emojis.get("684503576046862436");
const node = bot.emojis.get("684505660167422155");
const server = bot.emojis.get("684509665169899619");
cpuStat.usagePercent(function (err, percent, seconds) {
if (err) {
return console.log(err);
}
let duration = moment.duration(bot.uptime).format(" D [days], H [hrs], m [mins], s [secs]");
let embedStats = new Discord.RichEmbed()
.setTitle("__**Informations du bot**__")
.setColor("RANDOM")
.addField("En ligne depuis โฒ", (Math.round(bot.uptime / (1000 * 60 * 60 * 24)) % 60) + " Jours, " + (Math.round(bot.uptime / (1000 * 60 * 60)) % 60) + " h, " + (Math.round(bot.uptime / (1000 * 60)) % 60) + " min, et " + (Math.round(bot.uptime / 1000) % 60) + " sec", true)
.addField("Utilisateurs ๐ถ ", `${guild.members.filter(member => !member.user.bot).size}`, true)
.addField("Serveurs " + server, `${bot.guilds.size.toLocaleString()}`, true)
.addField("Discord.js ๐ ๏ธ", `v${version}`, true)
.addField("Node " + node, `${process.version}`, true)
.addField("CPU " + cpu, `\`\`\`md\n${os.cpus().map(i => `${i.model}`)[0]}\`\`\``)
.addField("Utilisation du CPU ๐ ", `\`${percent.toFixed(2)}%\``, true)
.setFooter("BryXou - Twixty")
message.channel.send(embedStats)
})
};
module.exports.help = {
name: "bot"
};
yeah, thanks. And I want to know the guildDeleted first
Ahhh
?






