#development
1 messages ยท Page 1432 of 1
read @pure lion
It depends on the block
It should be in the same scope
Do you use {} for your cases?
no
: for a case
Flashbacks to when I used a switch case block for my commands ๐คฎ
case "a": {
}
won't error
switch is gross for commands.
Anyone knows a cheat way to know which property of a channel changed when it is edited ? to just get a list of all edits make in that channel ? cause it takes way too much effort to check every property.
Hey does anyone know how to make the bot send the current slowmode in the channel the command was fired in? (discord.js)
find it using message.channel property
mhm
message.channel.rateLimitPerUser @dull bramble
gives the slowmode
in seconds
ty
@old cliff can ya help me too?
@dull bramble maybe?
Can anyone help?
How to make a welcome code?
You guys, can somebody help me
My friend gave me this code part, but it haves an error
bot.setInterval(()=> { bot.sweepMesages(86400)}, 3600000);```
bot.sweepMesages is not a function
at Timeout._onTimeout
That's part should clear memory cache every hour
Yo, anyone know how I could make a set slowmode command?
Slowmode like with Time out?
Like normal discord channel slowmode
@silent cloud its messages not mesages
U have a typo
use this
bot.setInterval(()=> { bot.sweepMessages(86400)}, 3600000);
setTimeout(() => timestamps.delete(msg.author.id), cooldownAmount);
```
Ohhh rly?
Ty xd
here
{
'rateLimitPerUser': '10'
}
);```
replace 10 with new slowmode
Alright
And in code part you need this:
cooldown: number
Thz jaguar now it workinf
if your bot does logging then removing messages from cache is not recommended
cause then the event will not trigger
if a message is deleted,edited,etc.
@silent cloud
const config = require('../../config.json');
const $ = require("discord.js").MessageEmbed;
module.exports = {
name: 'help',
aliases: ['commands'],
cooldown: 3,
description: 'List all of my commands or info about a specific command',
usage: '<command>',
type: 'info',
permissions: ['SEND_MESSAGES'],
execute: (message, args) => {
const embed = new $()
.setColor(config.color)
.......
}
}
cannot access 'config' before initialization
Guys
when did you load your help command? bcs your config is not aviable when loading the command
const categories = fs.readdirSync("./commands2");
categories.forEach(c => {
const commandFiles = fs.readdirSync(`./commands2/${c}`).filter(file => file.endsWith(".js"));
for (const file of commandFiles) {
const command = require(`./commands2/${c}/${file}`);
client.commands.set(command.name, command);
}
});
thats how im loading them
in your bot on ready event or in your main file?
My log says
UnhandledPromiseRejectionWarning : FetchError: request to discord.com/api/v7/gateway/bot failed, reason: getaddrinfo ENOTFOUND discord.com
main file
What does this mean guys?
is your json static or for god not say it a Database
Me?
its in my main file and not in any event
is your json static or for god not say it a Database
json?
the config you load in your command is a json file
also is the path to the json correct?
static
yes its correct
hm
what is the output if you use a console.log(config) in your command
try using a different variable name
its not logging
did you comment out the error?
module.exports = {
name: 'help',
aliases: ['commands'],
cooldown: 3,
description: 'List all of my commands or info about a specific command',
usage: '<command>',
type: 'info',
permissions: ['SEND_MESSAGES'],
execute: (message, args) => {
console.log(config)
}}``` when i do this config is what config.json is
wired
wtf. lookup how to make a dynamic generated help command
Its doesnt helps me
Was 150mb now 175mb
It rising
without setColor and setThumpnail does it work?
what exactly did you want to do?
I have memory leaks
how did you know this?
I want to fix it or clear memory cache every hour
this doesnt indicate directly a memory leak
did you use stuff that renders to the buffer?
And my friend say about that, he 100% knows
No
what language did you use?
Node js
libary?
Uhhhh
discord.js?
ok. if you have issues with high ram usage maybe look into discord.js-light. your increasing ram usage could be that the bot starts to Cache more and more users, messages and the other stuff
What?
this is a thing i dislike on D.js v12 it caches everything
Change discord.js to discord.js-light?
yes its pretty much the same but with way more control about what is cached
Hmmm
the creator of the lib is also here on the discord server
(node:9432) UnhandledPromiseRejectionWarning: ReferenceError: response is not defined but its defined here const response = await msg.awaitReactions(filter, { max: 1, time: 8.64e+7 });
i think the time is the issue
Sounds good
but with d.js-light you have to code certain stuff differently
not much but its needed to get it to work
@gusty quest show more code
im gonna send u in dm
You have return undefined
Also youre not actually calling the function?
Lets try
Actually just remove the function lol, use the code directly
Oh yea
also tim here is the creator of d.js-light
you can get the ram usage even more down i guess. how many guilds did you use?
Lol ye?
you dont need a shard if you are not close to 1k guilds
ty for help i fixed it ๐
Yep, but im looking in future
i have ~100MB ram usage with ~300 Guilds
the running shards could cause your memory usages
I have 130mb with 6000 guilds
Yep
Maybe create only 2 shards?
you only need 1
Are you using the sharding manager?
Ye
You can switch to internal sharding
What it doing?
Sharding manager is 1 shard = 1 process
So 5 shards = 5 processes, aka, 5 node.js running at once
Internal sharding is 1 process = multiple shards
So you only have 1 nodejs running and all shards are inside it
Delete the sharding manager
And in your main file, put in your client options: shards:[0,1]
For 2 shards
Or [0,1,2,3,4] for 5 shards
Understood
Lets try
And yo
Discord.js-light cool
Bcs now it use onlt 127mb
So cool rly
but then it starts to get annoying
with running a better memory allocator you can also cut down on a bit of memory usage
but yea
if you have a dumb bot with only a few commands or run all configs over a website you could get it to work
It say i have only 1 users
bcs users are not cached
Its written in the readme
I need change false to true?
Users are "all or nothing"
Ohhh
If you want users, you need to fetchAllUsers
Those 40k you had are not all users
Only a part of them
Anyhow having them cached is not needed most of the time
I dont understand what to do
If you can use guild.memberCount for counting users
If you need users, you have to use fetchAllMembers
In your client options
fetchAllMembers:true
But this will make your bot use much more memory
If you need that, better stick with discord.js
You can use guild.memberCount
That will give you the total number of members in a server, including bots and including offlines
You can filter servers by guild.shardID
And add the member counts of each server and each shard id
so i now made to remove users reaction but it removes all reactions here is code msg.reactions.cache.get("๐").remove(message.author.id)
discord bot animated avatar??
uhh does anyone here use discord js?
discord bots can use gifs as avatars
how
hmm
@lusty quest OOO YES THANKS
hey could anybody help me with a heroku problem?
i think remove takes the user object
postinstall script permission denied
heroku doesnt allow all npm modules
one reason more why free hoster suck
can't i just use pm2 on a vmbox to let it run 24/7
where?
on virtualbox
so?
on your pc, a server or samsung smart fridge?
it basically isn't my pc anymore
? you know how discord.js works?
yes
it is a virutal computer basically.
im not good at english
so idk what did u say
bruh
its time for google transtlate
Virtual computer still runs on a physical computer, if the physical one is shut off, the virtual dies as well
buy somewhere a raspberry pi and let it run off there
const canva = require('canvacord');
const Discord = require('discord.js')
module.exports = {
name: "trigger",
description: "Trigegr yourself",
async run (client, message, args) {
if(args[0]) return
let avatar = message.author.displayAvatarURL({dynamic: false, format: "png"});
let image = await canva.Canvas.trigger(avatar);
let triggered = new Discord.MessageAttachment(image, "triggered.gif")
message.channel.send(triggered);
const member = message.mentions.members.first() || message.guild.members.cache.get(args[0]);
if(!member) return message.channel.send(`Please enter a VALID member!`)
let avatar2 = member.displayAvatarURL({dynamic: false, format: "png"});
let image2 = await canva.Canvas.trigger(avatar2);
let triggered2 = new Discord.MessageAttachment(image2, "triggered.gif")
message.channel.send(triggered2)
}
}``` Why is this not working??
did you still havent figured out how to debug it?
owh shit okay,
same goes with pm2 right?
@lusty quest me??
yes
yes i did but now i tried 1 so u can also trigger someone else
like
it worjs
works*
but i want it so u can trigger someone else
your error yesterday stated that trigger where not working, then someone told you that you used an outdated tutorial
yes
but i fixed that
and now i tried to make it so u can also trigger someone else
if you want to use an other user with an mention work with mentions
i just want it so u can trigger someone else
a random user or a spezific one
then learn how to handle mentions
what exactly does your current code?
it sends a gif with you and under that there is "TRIGGERED"
my error
DiscordapiError cant send an empty message
just stated now
define the member on the first line
const member = mention || author
its an example you need change it
if there is no mention it takes the author
ok
he handles the mention later in the code
but in a different way
thats why i told him, he should add it on the first line
your message is empty
but it not
@molten yarrow i used this code
const canva = require('canvacord');
const Discord = require('discord.js')
module.exports = {
name: "trigger",
description: "Trigegr yourself",
async run (client, message, args) {
const member = message.mentions.members.first() || message.guild.members.cache.get(args[0]);
if(args[0]) return
let avatar = message.author.displayAvatarURL({dynamic: false, format: "png"});
let image = await canva.Canvas.trigger(avatar);
let triggered = new Discord.MessageAttachment(image, "triggered.gif")
message.channel.send(triggered);
if(!member) return message.channel.send(`Please enter a VALID member!`)
let avatar2 = member.displayAvatarURL({dynamic: false, format: "png"});
let image2 = await canva.Canvas.trigger(avatar2);
let triggered2 = new Discord.MessageAttachment(image2, "triggered.gif")
message.channel.send(triggered2)
}
}```
and it tells this
if you dont show as your code we cant help you
abort(DiscordAPIError: Missing Permissions) How would I make it say Missing Embed links permission
const member = message.mentions.members.first() || message.guild.members.cache.get(args[0]);
if(args[0]) return
let avatar = message.author.displayAvatarURL({dynamic: false, format: "png"});
you still takin avatar from message.author not member
your avatar = line is wrong
oh LOL
get the image from the member not the author
and you dont need the args[0] line anymore
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
@molten yarrow i have this
const canva = require('canvacord');
const Discord = require('discord.js')
module.exports = {
name: "trigger",
description: "Trigegr yourself",
async run (client, message, args) {
const member = message.mentions.members.first() || message.guild.members.cache.get(args[0]);
if(args[0]) return
let avatar = member.displayAvatarURL({dynamic: false, format: "png"});
let image = await canva.Canvas.trigger(avatar);
let triggered = new Discord.MessageAttachment(image, "triggered.gif")
message.channel.send(triggered);
if(!member) return message.channel.send(`Please enter a VALID member!`)
let avatar2 = member.displayAvatarURL({dynamic: false, format: "png"});
let image2 = await canva.Canvas.trigger(avatar2);
let triggered2 = new Discord.MessageAttachment(image2, "triggered.gif")
message.channel.send(triggered2)
}
}```
and it still gives my image
you dont need avatar2 image2 and triggered2 anymore
ok
const canva = require('canvacord');
const Discord = require('discord.js')
module.exports = {
name: "trigger",
description: "Trigegr yourself",
async run (client, message, args) {
const member = message.mentions.members.first() || message.guild.members.cache.get(args[0]);
if(args[0]) return
let avatar = member.displayAvatarURL({dynamic: false, format: "png"});
let image = await canva.Canvas.trigger(avatar);
let triggered = new Discord.MessageAttachment(image, "triggered.gif")
message.channel.send(triggered);
}
}```
now i have this
alyo your member line is still not completely right
so it should work???
try and see
did you saved the code?
yes
and updated it where every you run the code?
yes
then it should work
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
on wich line is the error?
is it possible to create your own vps at home?
i didnt say the line
yes
wich command did you use?
use a NAS or a Raspberri pi
all my commands
you get it on all your commands?
nas?
network attached storage
yes it just stated @molten yarrow
yeah
gimme a sec xD
const canva = require('canvacord');
const Discord = require('discord.js')
module.exports = {
name: "trigger",
description: "Triggers yourself",
async run (client, message, args) {
const member = message.mentions.members.first() || message.author
let avatar = member.displayAvatarURL({dynamic: false, format: "png"});
let image = await canva.Canvas.trigger(avatar);
let triggered = new Discord.MessageAttachment(image, "triggered.gif")
message.channel.send(triggered);
}
}```
i used this but now it sayss this
```(node:18720) UnhandledPromiseRejectionWarning: TypeError: member.displayAvatarURL is not a function```
how to fix it
r u sure ur on v12
yes
https://discord.js.org/#/docs/main/stable/class/User?scrollTo=displayAvatarURL, tl;dr you need to get user instance of member
ok
yes
const canva = require('canvacord');
const Discord = require('discord.js')
module.exports = {
name: "trigger",
description: "Triggers yourself",
async run (client, message, args) {
const member = message.mentions.members.first() || message.author
let avatar = member.displayAvatarURL({dynamic: false, format: "png"});
let image = await canva.Canvas.trigger(avatar);
let triggered = new Discord.MessageAttachment(image, "triggered.gif")
message.channel.send(triggered);
}
}``` If i use this it works if u try it on yourself but if you try it on someone else it says `member.displayAvatarURL is not a function`
did u find the problem
how to fix it
is your Bot online?
you have 2x ready event and 2x message event, make sure you have only one
you can host it for free on Heroku but free is not really good
or you get the 1 year free credits for AWS or Google Cloud Platforms
@lusty quest do u know a answer on my problem
does member contains a member object?
yes my bot is online
what do you mean
im new to this sorry
contains the member variable a member object? (console.log(member))
if you still dont know how to debug your own code i suggest to learn some more js
ive gave you instructions in what to do
i know
i cannot get my fucking build to start because of postinstall
whta to do?
and i don't want to spend money on a vps.
Avatar is not a property of a guild member
5$/month is not much
never said it was much
bruh im new so idk how to fix that
the message say what you should do
who can help me
yes but i dont know how to do that because im new so i dont have any idea what to do whit that message
Use message.mentions.users.first
i have
oh wait
nvm
i have members
if it will contain a member object then the error is somewhere else
yeah change it
thx @bright crag it worked
ok cool
only my music command is working
you need to clean up your code a bit
your guildMemberAdd event is inside your first message event
and your second message event is inside the first one
i can set gif as avatar for my bot??
i think so, saw other bots using it
i tried but only allows png jpg
i fixed it and i will clean up my coded
nice :3
well then you cant use a gif
is the nekos.life sfw gifs allowed?
the entire api is banned
oh darn but thanks i dont wanna get declined again
how to make a bot know when its disconnected discord js?
Hey, I'm trying to log in with my bot, but I'm getting an invalid token error. I've regenerated the token multiple times but still the same response. Has the bot been compromised? (I've had this bot for some time and I haven't booted it up for quite a bit)
you can pass your token from your json config into client.login. and the bot will run on every message that contains oing
the on ready event is fine
I have 2 places for the Token.
Ik how to get Token.
What's wrong with this?
It looks weird.
So I remove the config.json file?
no keep it
K.
in your client.login add in there your token variable
client.login(token)
this will then load your token from the json
I have added it in the index.js one.
having the token somewhere coded in your files is bad
the only way i can think on rn is looping over each user in the guild
but its not that efficent
so, @lusty quest remember when I asked about multilanguage?
could work
i think
what about module.exports? it won't get the variable that says 'Use this language!'
cuz it'll be above the execute
how is your command made?
bcs everyone does it a bit different
stuff like command names wont work
rn it's in my native language, but you may understand
I didn't set the lang variable for this file yet
you cant reference any guild in there
so you cant load any guild spezific translation
or even use the en.json and create a set of properties for help only
like, delete these
this will break the command
this will break the help command
and then, in the help.js
wait
hold-on
instead of searching the command info in the command
I get them here
would be possible
so it gets the command info from there
yeah, but it's kinda annoying
going through all the 'language.json' to write the info
well you do the initial translation and then the additional ones
ยฏ_(ใ)_/ยฏ
How do I get another command working on it?
get a command handler or use a switch case
command handler > switch, only if you have 10+ commands
How to get a command handler?
nah command handler looks always better
u can always use switch if u want 4 or 5 commands
ikr
https://discordjs.guide/ there are many good guides
I am on that.
but as a beginner, I used switch case until I got 15 commands or so, lmao
then go to command Handling
To this
you'll get in there
Where do I put it?
that's what I did
follow the guide. it will tell you everything
that's an explanation, you shouldn't just cp the code into ya bot without even looking carefully on what the guide tells you to do xD
This does not make sense:
? it makes sense for me
How to fix?
well you try to run a else statement inside a if statement
Where do I put it?
did you know basic js?
?
you ask really basic questions about how to use javascript. i suggest to learn this first
I do not like Javascript.
you try to code a bot with it lol
I using Node.
node is javascript
Oh.
i wont babysit you throu the entire process. learn some basic js.
@leaden cliff smh add a } on the line above the else if statement
And like Super was saying you should learn basic coding languages before using them it will help you alot
Hey guyz could you tell me how to host a java bot for free
or is there any method to get vps for free
You can host it in your code editor
wtf
wdym
You can use your own machine as a host
Example if your using node.js if you do node . in the terminal it turns the bot on
just keep it 24/7 on
^
oh that i know but i cant keep it 24/7
Fancy 
i have bot in java
not in js
I suggest you check pinned messages
^
mathew explains very good "Free Hosts"
free doesnt exist
heroku exist
well
heroku is crap


still useful for beginners
they dont support a large amount of stuff
can u teach me how to host java bot there
lol grab 5$/Month and you start with a way better platform to grow
heroku wont get you past 1k
my bot is just like 40mb
maybe even not past 500
including all the files, apis, and all stuff
i searched for glitch but i didnt found it cool cause you have to start your bot again and again after every 5 mins
or so
You could use uptime manager for glitch
But I wouldn't recommend using glitch to code a bot
why tho
uptime manager will get you banned from glitch bcs it violates the TOS
- you need to push your bot to github
- Make
Procfilefile and fill it withworker: node <your_main_file> - Open heroku, make account if not exist, and create new app
- Go to deploy section, choose github for deployment method, find your repo and connect it.
- Click on deploy branch
- If success, refresh page, and go to resource section
- Disable
weband enableworker
Ah last I heard glitch allowed it 
Indeed
sure dm me this so i coulnt loose it
Self host like a normal guy 
buy a Raspberry pi or banana pi if you dont want to get a VPS
my one bot got declined because of that
I self host and mine didn't get declined
self host in a VPS lol
Yours was probably just offline
ya at that moment
Lmao
Self host is both a blessing and a nightmare
Its easy to fix errors but if you get one the project is offline
there is a easy way to prevent this. Dont develop on a working system
True
I'm looking for a method to split a string into multiple parts, based on a maxLength, but not just using a simple substring, but cutting at the end of a word
I don't know if I explained it correctly
is it possible to pass a parsed .json to another command?
how to make a bot know when its disconnected discord js?
iirc there is a event
@cursive forge what?
client
I need it to know when someone disconnects it manually
so it clears the queue
Yeah it crashes but instead of crashing I want it to queue.delete(guild.id)
but I need to know what can detect if the client is in the vc or not
is it right to say codes are?
ditch discord.js and use a microservice structure. then your bot can be shown as online but no command will work bcs there is no api client aviable
how to make a bot know when its disconnected discord js?
look into events
@sharp birch send the error here
wait I'ma screen shot for error
You could just copy and paste it 
I have that bruh
@earnest phoenix Then how would I use that to make it where if someone disconnects it it returns queue.delete(guild.id)
only one problem
Did you install it in the project then @sharp birch
In the terminal do npm i discord.js
uh
npm discord.js?
^
alr
@earnest phoenix So how would I do and if statment with it?
i is short for install
it's still error
@sharp birch then you don't have the discord api
I have
Are you trying to use node.js?
yea
Did you Install it from the site?
yes
Did you do npm init?
alr it's work thx
Lmao that was fast
yay my bot working
Lol
No idea what that is 
and now we wait for him to get roasted
Yes
oof
Oh well it worked for my old bot 
I have one question
Once I have a job ill buy a vps
what is that "package-lock.json"?
@sharp birch just information on your js version, discord version all that fun stuff
Nothing you'll ever need to mess with
hey guys
ฦฐhat
Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien
what
why does these stats: not update
Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien
shuit the fuck up
Should we get a mod?
bcs these are only updated when you start a bot
A mod
-atmods @eternal osprey
@eternal osprey
Please do not mention (ping) more than one or two moderators for help, unless there is an emergency.
Here are some examples of emergencies:
- Raids / Multiple members mass spamming.
- Severe disruption of Discord's ToS (NSFW content, etc)
- Anything that requires more than 2 moderators to handle.
person
fuck sorry
not 25
Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien
sorry
rip @fallen oak
-m 417624128120684544 spamming | 2d
๐ค Muted Witrold#8598 (@fallen oak)
sorry mods!
@eternal osprey whats are you trying to do with the stats?
i am ust tryingg to show the stats
@eternal osprey did you tried
setInterval()
but it does not update.
If you want it to update use a interval
`` js
setInterval(() => {
//your function
}, 15000)
client.user.setActivity(`!help || Serving on ${client.guilds.cache.size} servers, for a total of ${client.users.cache.size} users`);
``` this is that code
aha okay.
Mine updates every 2 min
i recomend 5 minutes
setInterval(() => {
client.user.setActivity(`!help || Serving on ${client.guilds.cache.size} servers, for a total of ${client.users.cache.size} users`);
}, 60000)```
like this right?
Now the bot will not have a status until it reaches the specified time btw
client.user.setActivity(`!help || Serving on ${client.guilds.cache.size} servers, for a total of ${client.users.cache.size} users`);
setInterval(() => {
client.user.setActivity(`!help || Serving on ${client.guilds.cache.size} servers, for a total of ${client.users.cache.size} users`);
}, 60000)
done
Lmao
i am still flabbergasted about how the fuck i got 605 users to use my bot
that's hot asf
so I did this in bot.js
const lang = require('./languages/en.json');
and then tried to pass lang to the commands
command.execute(bot, message, command, args, db, await prefixDev, lang, supportServerEmojis);
but lang logs [] in the other commands
Whats lang supposed to do?
605 is easy. if you get like one or two larger servers
^
it's a json file with all possible messages the bot can send in order to answer a user
that's a snippet
Interesting
So it just changes the language depending on the user?
*server
I am using only en.json just for testing
so i can know if the commands are reading the object
Ah sounds like a neat feature
but I need an answer for my problem
how did you define what language file gets loaded?
??
it's dynamic in the bot
in the dev one, it's just like this
I just want to pass the object to the other commands
oh, you're saying I'm only using one programming language?
no....?
the code you showed does it
I know it does @lusty quest
but that's not the issue, it's for testing
I just want the object in the other commands, but appears as [] @lusty quest
I'm starting to learn JS again as I forgot about most of it yet I'm just getting an error when I try to npm i dotenv/types
(it didnt already install that alongwith dotenv)
#development i thought we are in #general
Not really sure
could be an async issue, or connect it with your command loader
I have code referencing to dotenv/types but that throws an err trying to install it
try dotenv-types
this package exist
or @types/dotenv
but later one is deprecated
i previously used dotenv to actually turn on my bot as i dont know any other way
ill just try to use .json then i didnt realise they deprecated it
lol dotenv still is a thing
but not really for turning on bots, it provides a file that will be loaded into the enviroment
yeah
wdym they deprecated it
@types/dotenv is deprecated bcs it got merged with dotenv or so
Hello
hi
how can i get user info with discord api?
Hey, I'm trying to get the milliseconds of when the bot starts listening for a message and when the user types in the correct message. But it sometimes goes -. I'm using datetime
you mean id username joindate and stuff
Check the docs
yeah
๐ read ๐ the ๐ docs ๐
@fallow agate read the discord.js docs
stop spamming messages, write them in one.
Or whatever language docs you're using
Azy what library are you using
now nobody gonna see what i asked for 
i read it

@fallow agate https://discord.dev
Integrate your service with Discord โ whether it's a bot or a game or whatever your wildest imagination can come up with.
Ah yes dev portal
is there a way to fix this?
cant see in it aw
at all*
also discord.dev link not works?
@fallow agate its a issue with your discord app settings
So what i'm trying to do is this, basically @earnest phoenix https://im-a-dev.xyz/zu3YyYf0.gif
but sometimes, shows - 
But it sometimes goes -. I'm using datetime
What is-? I don't think you should even be usingstrftimefor this.
could be also a bug with the api or your code
probably not
yea probably not xd
well, my code yes.
all i'm doing is getting a starting point, then getting the end point
but sometimes one is larger than the other maybe?
and that's why it goes -
@leaden cliff example
If {
Command 1
} else if {
Command 2
}
try doing seconds instead of ms
Or use a switch statement
aight.
But honestly learn basic js first
@earnest phoenix Welp. That worked! Thanks.
I don't exactly think using datetime.now().strftime(...) for this situation is appropriate, but this is how I did it in one of my bots: ```py
from time import time
milliseconds = lambda: int(time() * 1000)Then I could call `milliseconds` to get the current time in milliseconds.py
start = milliseconds()
... wait a bit ...
elapse = milliseconds() - start```
Isn't time() already in ms?
It's in seconds, but uses decimal points
yes lol
ends up looking like this
@sudden geyser Works, Thanks! I got both times by just doing elapse/1000!
/ obviously meaning divide.
could this get me rate limited?
@tasks.loop(seconds=300)
async def cpucheck(self):
print(self.bot.index)
self.bot.index += 1
cpunorm = 10.0
cpuhigh = 20.0
if psutil.cpu_percent() < cpunorm:
await self.bot.change_presence(status=discord.Status.online,activity=discord.Game(name=status))
elif psutil.cpu_percent() > cpunorm:
await self.bot.change_presence(status=discord.Status.idle,activity=discord.Game(name=status))
elif psutil.cpu_percent() > cpuhigh:
await self.bot.change_presence(status=discord.Status.dnd,activity=discord.Game(name=status))
else:
print("Error")
well you're only going it once every 5 minutes
Status change?
I wouldn't say so
it changes state based on the cpu load
i always wondered: why do we need the client secret and the public key?
high load dnd
ah ok, thanks
5 times per 20 seconds quoting Discord docs
Hello can we use a multi language for the bot? For coding
in the ping command, you need to have a ( before the '
These are the only problems now.
Like... multiple programming languages? You can do that, but it would be easier and more efficient if you just write the whole bot in one language.
you have to add === and remove ) at if(command**)**
How do I fix these:
oh.
Last problem:
It's possible ah okey thanks
its just (command == 'ping')
Is it?
ya
I don't do else if statements so I don't remember how they work
If I remove the { it makes it fail.
Then don't remove it
how to add role for a user only sing tis username and discriminator
Like nandan#8628
Id say rey adding a third = to see if that helps
With it:
@atomic vault you canr really since the bot needs to find a user in the guild
Without it:
@leaden cliff take away ( then add the { back
dude dont make it even worse xD
Omfg
Like that?
if(command == 'ping') {
message.channel.send('pong!')
}
^
i cant look at this...
I now see why I switched to command handlers
try this
if(command === 'ping'){ message.channel.send('pong!') }
) missed
if(command == 'ping') message.channel.send('pong!')
would also work
@atomic vault Yay!
yeah added ๐
@leaden cliff I'll just say this again you should really learn basic js first man
It will make your life so much easier
yep

The terminal won't work.
@main trench ya
Did you do "node ."
F me.
Smh
Now to add another command do else if under the last } for the ping command
And repeat the same process
K.
message.channel.send('pong!')
} else if(command == 'name 2') {
Code here
}```
It should be like that
I miss the mobile code blocks ๐
um ReferenceError: Intents is not defined``````const intents = new Intents(); intents.add( 'GUILD_MEMBERS', 'GUILDS', 'GUILD_MESSAGES', );
but its defined
dont define them, pass them to your Client
?
i have that
const client = new Discord.Client(config, { ws: { intents: intents } });```
how can i get user id and give a role to user
@atomic vault discord.js?
ya
and mysql
client.fetchUser ?
I'm gonna make a discord bot in note pad
i cant get opting
I made my first one in terminal with nano
Not even notepad
0_0
What opting ?
client.fetchUser
then try this
client.users.cache.find(user => user.id === 'ID_Here')
if it doesn't work I don't know what will
it works
i will try by mysql
I think he is making it so you mention a user
mentions.users.first like this ?
i am making a bot which gives a role for a member how enter his username or id or anything by that my bot can give a role with mysql
you dont need mysql to give a role
Message.mentions.members.first()
i know
how do you want the commands to be ?
like
!give @user @role ??
no it will give role when he registers in that site
depends how u build your site...
What does the site take as input ?
Id or name ?
also is the user already in your server ?
You might need an api
site is simple with php and mysql
than use oauth2 to login with discord
how to make it
google it
We're not supposed to spoonfed codes
thanks i will try it
What is wrong with this?
I have fixed all the other errors.
Except from this.
@main trench
DiscordjsError: Request to use token, but token was unavailable to the client. what to do? this is code: ```
const Discord = require('discord.js');
module.exports = {
name: 'die',
description: "this is a die command!",
execute(client, message, args){
const ownerID = '735890738721718363'
if(message.member.id === ownerID) {
const kurac = new Discord.MessageEmbed()
.setAuthor('Among Bot', 'https://i.imgur.com/ti8MDoI.png')
.setDescription(':tam: This is my last message before die, sorry i must go for some time! :Yes~3:')
message.channel.send(kurac);
client.destroy();
} else {
message.channel.send('Only bot developers can do this command. :No~3:')
}
}
}```
message.channel.send() doesnt have .execute() function
When I say ping it says ping instead of pong.
Send your code
It is copying this:
I am trying to get it to do it from this:
When it was like this it would not work:
I got it to work but it was not doing the thing from ping.js.
that doesn't make sense
Does.
doubt
How to do it then?
learnjavascriptplzplzplz
please someone? ๐
we told him already, but he dont like javascript because he using Node
LearnNodePlzPlzPlz
No. Go learn the language
by learning node
it's not our job to hand hold you through every single line of writing your bot
Nobody wants to do that.
I have fixed many errors on my own.
ping.js is a file in commands/ping.js. You want to call the execute function defined in the exports. message.channel.send(...) has nothing to do with it, so what you're really looking to do is require commands/ping.js and call execute(...).
You'll need to learn the language & Node because you can do this.
just use old good yanderdev way instead
@tasks.loop(seconds=300)
async def cpucheck(self):
print(self.bot.index)
self.bot.index += 1
print(psutil.cpu_percent())
if psutil.cpu_percent() == None:
cpuuse = 0
elif psutil.cpu_percent() != None:
cpuuse = int(round(psutil.cpu_percent() / 10))
print(cpuuse)
cpunorm = 10
cpuhigh = 50
if cpuuse ==None:
print("Waiting for cpu reading")
elif cpuuse < cpunorm:
await self.bot.change_presence(status=discord.Status.online,activity=discord.Game(name=status))
elif cpuuse > cpunorm:
await self.bot.change_presence(status=discord.Status.idle,activity=discord.Game(name=status))
elif cpuuse > cpuhigh:
await self.bot.change_presence(status=discord.Status.dnd,activity=discord.Game(name=status))
Everytime the bot start i get an exception
idk whats wrong
could i do smth likes this before it starts the loop?
Yes
let isUser;
pool.query(`SELECT * from lotterystats WHERE id = ${message.author.id}`, (err, res) => {
if(err) return console.log(err);
if(!res.rows[0]){
console.log("false")
isUser = 'false'
return;
}
console.log(res.rows[0] + " res 0 ")
isUser = res.rows[0].id
})
return console.log(isUser + " is user last");
so it's console logging is user last first and then false for that reason isUser stays undefined 
i did try doing await pool.query but it doesn't work
module.exports = {
name: "ping",
description: "this is a ping command!",
execute(message, args) => {
message.channel.send('\:ping_pong: Pong!'
}
}
Does anyone know the error?
anyone know what the best db to use for nodejs is?
There is no "best" DB.
Well, most popular db?
There are local dbs, server dbs, sql, nosql, etc

i like MongoDB
What do you need to store, aakhilv?
Then you could just use my enmap module, it should be fine for you
even got a per-server configuration example in the docs ๐
Alright, do you mind linking it?
thx
Such as?
until it used 1 GB ram
Well it does store things in memory so yes. And it can't scale to sharded bots. but it's good for starters.
thats true
1gb
I put ping where the pong is without noticing it...
What's the problem with it though? do you get an actual error message or something?
go learn javascript.
I am learning it!
No you're not, you're struggling to make a bot , not learning javascript.
let isUser;
pool.query(`SELECT * from lotterystats WHERE id = ${message.author.id}`, (err, res) => {
if(err) return console.log(err);
if(!res.rows[0]){
console.log("false")
isUser = 'false'
return;
}
console.log(res.rows[0] + " res 0 ")
isUser = res.rows[0].id
})
return console.log(isUser + " is user last");
so it's console logging is user last first and then false for that reason isUser stays undefined 
I did try await pool.query same response
That's because pool.query isn't a promise so you can't await it.
It's clearly a callback method, not a promise one. You'll have to use a better module that uses promises
Better yet, don't use mysql, it's crap ๐
Ah! nevermind then, pgsql is fine
yeah
But find a pgsql module that supports promises





