#development
1 messages · Page 1909 of 1
okay... what are options?
Or just show me code how you would add a slash command
I showed
You have like multiple files my bot is one file
And ?
I have those
And what you are trying to do
^ "options": [...
Just figure out how to make a slash command
I have a json string how do I upload it to discord?
With that way
that doesn't make any sense to me
You dont need slash command builder thing
Check this for example
Or nwm this is more complicated
anybody else getting timeout when logging in their bots?
No need to deal with timeouts when you use a webhook for interactions 
it's my legacy commands
april needs to happen now
why is it timing out!
some hacker guild downloaded my bot with 20k other bots. maybe that is causing issues some how
lol
"downloaded my bot"?
you know
i only cache roles and guilds
is anyone else able to login with their bots now?
it just sits at await client.login(token); until it times out
my unit test cant login either
i can login with my test bot token
it's the hacker guild messing with me
how can a guild prevent my bot from logging in?
it cant unless you broke something
i can login with my test bot token. my prod bot token cant login
what's the point of doing this
are there any errors?
just a timeout
my legacy commands use the roles
i think i fixed it by increasing the timeout
i'm running a unit test now that it still trying to connect
but why? this doesn't prevent the client from being created
it will usually timeout on slow servers
it has a 999999 timeout
Promises are eager, they're run when they're created, not when they're awaited
also you probably don't want to connect to discord if you're doing unit tests
i wrap promises in functions to deal with that
i am testing connection to discord
it's still trying to connect
yeah but in this case
module.exports = new Client()
and
module.exports = Promise.resolve(new Client())
are basically the exact same thing
hanging
oh yeah, ignore that. this code will all go in the garbage soon
still logging in...
5 minutes so far
is it also not working outside of the unit test? Does logging in return a promise in discord.js?
jest will time out before that can complete if it's taking a long time though
you can perform a rest call to leave that guild without logging in can't you
i might need to do that
someone else from yesterday had this guild invite their bot. i wonder if they are having the same issue
just react to the guild create event with a leave I guess
are you having any issues logging in with your bot today?
i cant login to get the guild create event
i'll need to use the api directly
still logging in btw
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
you win
strange that you would be blocked from logging in when that's happening though
that guild was doing strange things. they probably found a bug with discord and are exploiting it

it logged in after deleting that guild...
DELETE
https://discord.com/api/v8/users/@me/guilds/901538946222293002
Haven’t restarted my bot today, not having any issues atm though
can you try logging in on a test machine? i wouldn't recommend stopping your server
I had to 6 hours ago
Took like a minute until I receive the ready event even tho it usually takes a few seconds
do you have these guilds 898782595750428712, 901538946222293002?
probably not a good time to check
Oh that’s interesting
898782595750428712
Previously called "Funnying the API"
Has kicked my bot out a few days ago
But still took me a while to login even if im not part of it anymore
If you’re still in you should probably log the message event just for fun to see what’s going on in there, incl. bot messages

i left, i couldn't login
Oh ok
but they have 23k bots and are just sending the !help command to all of them
slash commands will fix that
maybe my bot was trying to get the 23k messages from all the other bots before initializing
23k?
how are they inviting 23k bots. Selfbot?
don't you have to pass a captcha to invite
It has kicked out my bot with ~ 7k members
Probably because I completely disabled regular commands a few days
After sending a notice to use slash commands for a few months now
good point. they'd have to get past captcha
maybe they have a human farm
I just forced my bot to leave that
you mean like 1000 north koreans to fight the western capitalism by trying to take down the Discord API?

i opened a ticket with discord about those guilds
god how can you guys program in javascript
c# gang
i moved to python again for the dbl.tf api
instead of making like 3 requests using JS, it just uses python
js stinky
use typescript?
too much trouble at this point. All of this is already written in js

be smart bois don't start new projects in js
that's what happens when you inherit a codebase that isn't yours
literally my entire life for the past year
did xig give up on it or what
i'd prefer JS over Python lol
they're both awful
they're awesome to prototype in. I love python syntax but it's just not worth making a project that has more than 2 files in a dynamically typed or "type hinted" language
i'm pro procrastinating python coder
Join the strongly typed side 
i start coding and realise how useless what i'm coding is
i'm trying js
but i'm hating it
I accidentally deleted all my fucking code
go go gadget version control
I spent the weekend working on a haskell project and it was blissful. I barely had to run my code let alone turn on my bot to test its commands
this is why you use version control
so who here has already applied for message intent
when the types fit together you know you're golden
yeah but i merged two files
so no version control
god damn cpanel
commit regularly ez 🙂
i simplified my code now tho
instead of making like 5 api requests just go direct to the api
instead of submit.dbl.tf doing api.dbl.tf/validatebot /validatename and /create and then getting the info back from api
it now just posts direct to api.dbl.tf
I haven't heard about CPanel in a long time
i'm a fan of using Dokku for personal stuff and Azure for production stuff
not much wrong with cpanel, not much right either
but only Azure b/c I work with a lot of Azure stuff at work
i'm quite new to the hosting stuff
dokku is cool
so i have little to no experience
Dokku is really cool
looks good
makes moving apps into production stupidly easy
it's heroku but it only costs 1 million dollars instead of 10
not sure why you'd use cpanel in this day and age
and then i have directadmin reseller hosting for hosting others sites
simple for me to understand 
i'm starting to move away from it
nab a decent but inexpensive VPS and throw dokku on it. you wont regret it
my only problem with dokku was it can't be scaled horizontally
or it can but I think it was super confusing
yeah you aren't wrong, but for most things it does pretty well. Just ensure you put it on something with enough resources. Most of my personal projects don't demand a ton of resources, so it makes a lot of sense.
I'd say most people are in the same boat
neither do mine, I just love spending time worrying about meaningless stuff instead of working towards releasing a usable product
yeah.. 
when you build your product around a tech stack vs. tech stack around the product type beat lol
Architecture for a 0 user website btw
felt. But drawing up the architecture stack can be so fun sometimes 
more fun than actually working on the app sadly
hopefully I'll have chance to finish up image discovery next month if I ever get a breather from topgg
why do you have a rabbit (bunny) in your architecture
the labeler is really slow and can't be scaled up easily. I don't want to queue requests in-memory for each webserver since they're meant to be ephemeral so rabbit is the correct choice for that
if the site goes down the queued images don't get lost
any ideas for a bot?
It just won't work
message queues are also good at decoupling things. If I get an error processing an image I can just put it in the dead letter queue and try again after 30 minutes or whatever while being able to restart the as I want
wait xet - is server counts not showing correctly on the site a caching issue?
just wanna check i'm correct
probably a caching issue
it's not exactly crucial for that number to be 100% correct
accept the future of programming languages
the future of 1964
Douglas Crockford says class free oop is javascripts gift to the world
js has its uses
oh yeah this dude clearly has a lot of wisdom
But it’s outclassed by other languages in OOP imo
You can be a good programmer by practicing a lot.
- Killer Fish. Killer Fish from San Diego
water is wet
- me
I think rust is going to be more and more popular in the future for performance-heavy applications
Js will never replace compiled languages
I hope JS will continue to be a compilation target for the browser like assembly is right now
like we've basically universally agreed that assembly is just not a very productive tool for most usecases
so we compile to it instead. I think we're going to be seeing more and more of that in the future
more typescript and wasm, less js
Adding strict types to a language that transpiles to dynamic types makes no sense.
Just because it’s dynamically typed doesn’t make it immune from issues with types though
Still need to test
Under the hood everything gets a type
water is wet
- me
I keep enjoy this conversations 
Help
That Douglas Crockford guy says we need to wait for the previous generation to die before we move on from strict types.
He says some funny things.
You need to get the guild object from your cache
how to?
Or simple add the guild ID as argument to what Tyrone wrote
client.application.command.create({ … }, "guild ID");
There’s an optional guild ID parameter
What happens if I don't specify the guild id?
Not especially needed to get the guild from your cache tho
It will get a global command
But it did not show up
Yeah because it takes up to 1 hour until it’s being deployed in all guilds
But I waited for an hour does the bot have to be on that whole time?
No once the registration was successful it’s available no matter what your bots status is
😕 then why isn't it showing up?
But if you register the command over and over again it may gets overwritten causing another delay until it’s deployed (again)
Does your bot has the right scope to register slash commands?
Idk tell me how to check
You have to add the right scope to the invite link
There’s a guide available somewhere explaining you how to do it.
You can check if the registration was successful by fetching the commands
client.application.commands.fetch() return a collection of the registered commands
(It’s a promise)
But still even if they’re registered, you need that scope in the guild you wanna use slash commands, no matter it’s a global or guild command
the command is still visible here but not usable
Yeah it will be replaced by one with the same name but different app ID
In the beginning it happened quite a lot these commands appeared twice or more
also I don’t understand why Discord allows to register the same command multiple times
Updating or delete yeah but not registering the same command causing a replacement
That should return an error in my mind
To force the user using he proper methods
people die when you kill them
- idk, some random anime guy
true
similar to swr too
Anyone have a good way to make a lightweight API endpoint for returning stats about my bot?
I'd use express but I'm not sure if that's the best option for something as simple as this
http's createServer() will just do
Alright, I'll look into that
I would recommend posting the stats into a database frequently, which data you can access directly or cached later on, instead of creating an access point in your bots code
Ah, that's probably a much better idea
If you don’t need a history of your status, we’re going to speak about static data.
Even putting that stats in a JSON file ever few minutes and accessing that file each hit on your site is okay
Much more easier
And static content in a JSON file is okay
Not looking to store graphs of anything, but it just needs to be able to be accessed remotely
You gonna overwrite the file over and over again
Db is gonna be the way to go for this one
Not reading and updating its content
Yeah a database or a public available data file like a JSON file
Especially if you have a database already in place
Put them into div tags and display them as table and table-cell, set the images as inline-block or use float
Starting with electron for the first time. How do I access an element by ID? I'm going to assume that it's not the same way you would do it with raw html, since I keep getting document is not defined when I try to use document.getElementById()
sounds like you're trying to get the document inside node
which doesn't exist
would honestly recommend using a framework, raw js website is probably going to be a nightmare with electron
Yeah, I'll probably look into jquery or something
Just trying to get this up and running
Which I'm now following a tutorial instead because apparently getting electron to work with ts is a little more work than I thought
index.js https://sourceb.in/305h9XoY3n
deply-commands.js https://sourceb.in/b7jINAq6Ra
avatar.js https://sourceb.in/F5ICVujkTE
My issue is that the bot comes online but doesnt reply nor does it show an error and yes while inviting the bot I made sure to enable bot and applications.commands in scopes
How can I keep a nodejs process running in the background? For context, I want this program to run until I manually close it (For a custom RPC)
Nevermind, for my purposes using setInterval should work perfectly
RPC already starts a node process
The way I had it set up, it was destroyed whenever the process had gone through all the lines of code, though that was my fault for automating that not realizing that it would kill the client after the code finished executing lol
@radiant reef hi bro im so sory can you review my bot again
queue
If your bot got declined you have to fix the issue and resubmit
Sure you can.
But you still require 300 chars as description of your bot.
Use aaaaaaaaa url lengethener so the src attribute makes up for it
<video
aria-label="boot videro" src="AAAAAAAAAAAAAAAAAAAAAAAAAAAAdeeznuts" />
You can simply fill it with placeholder comments or CSS… whatever
Which will be considered as spam
ok how
Don’t need an URL lengthener
lol idk
;-;
How can I know which source the video comes from
Upload it somewhere and post the link
Also you can't just link to a YouTube video because their API has extra steps for embedding videos
You can do anything
As long as it follows rules
Yeah you can add images
Your bot @POKE_Namer was declined by reviewer Nekomaki.
Reason: Your bot doesn't have a (working) help command or obvious point of entry. Please make sure your bot has a help command or has an explanation in the bot description.
If you would like to dispute your decline, please DM Nekomaki.
Today at 05:37
Tim has one of the longest bot descriptions on top.gg for astrobot
How does he sleep with the fact that a single site issue can delete it all
Your bot's help command doesn't work or doesn't exist
,help
Older people always have a backup
dm nekomaki if you think they did smth wrong
@ripe prairie this person
yes
oh i ping
*this weeb
hi
sorry
ohk
i submitted the bot but i cant see were it is
guild.channels.cache.find(ch => ch.type == "text" && ch.permissionsFor(ch.guild.me).has("CREATE_INSTANT_INVITE")).createInvite({
maxAge: 0,
maxUses: 0,
})```
cannot read property 'createInvite' of undefined
DiscordAPIError: Invalid Form Body
embeds[0].fields[0].value: Must be 1024 or fewer in length.```
idk how tf it is soo long
in v12 it works
but in v13 it doesnt
bruh
And channel type must be GUILD_TEXT
o
DiscordAPIError: Invalid Form Body
embeds[0].fields[0].value: Must be 1024 or fewer in length.```
idk how tf it is soo long
in v12 it works
but in v13 it doesnt
bruh
Every type has ids
ic
0-13
oo
0 is text channel
kk
@sterile brook 😅
You better take a look at that source bin link
Interaktion.followUp()
What does the followUp method do?
It’s basically a reply to the original interaction response
Like ping
Pong
Double pong
Pong pong? 
Can’t see shit in your source bin. 
😅 srry!!
i fixed it now
xD
just some smol bug
Ah ohh nvm then
https://media.discordapp.net/attachments/826774809404112897/902477751234224138/unknown.png
https://srcb.in/pShfD3ZQCt
see line 20
@lethal troutuse await
How come you can't?
I used my client ID then clicked on "FIND BOT" but nothing happens, no errors and i cant type anywhere
All the labels are disabled
Oh that's a new button
Works for me
My bot isnt verified
Neither is mine
Ook
ty

it didn't work
ru using djs
ignore it
the 0 will automatically change the undefined value
its up to you if you wanna remove || 0
i'm using replit but discord.js is on it so idk what's the prob
wydm
message.channel.send(client.guilds.cache.size)
done
what is it
must be replit bug
hm
DiscordAPIError: Missing Access
at RequestHandler.execute (/workspaces/52859033/node_modules/discord.js/src/rest/RequestHandler.js:298:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RequestHandler.push (/workspaces/52859033/node_modules/discord.js/src/rest/RequestHandler.js:50:14)
at async ApplicationCommandManager.create (/workspaces/52859033/node_modules/discord.js/src/managers/ApplicationCommandManager.js:117:18) {
method: 'post',
path: '/applications/<bot id>/guilds/<guild id>/commands',
code: 50001,
httpStatus: 403,
requestData: {
json: {
name: 'log',
description: 'logs some info.',
type: undefined,
options: [Array],
default_permission: undefined
},
files: []
}
}
so can't fix it?
can i see your .replit file
why does it say nodejs if i installed djs?
because we cannot call djs as a language
i see
djs uses nodejs so thats why
That means your bot is missing the application.commands scope in that guild
so is there a wau to fix it
how do i fix?
wym
the error
oka
Add the scope to the bots invite URL and reinvite it into that guild
do you have your first command already?
nice
oh i see
https://url…&scope=bot+application.commands
yes i see now
message.channel.send(client.guilds.cache.size)
send the whole command
in the server the bot is in?
no the command that counts the guild
yes
message.channel.send(client.guilds.cache.size.toString())
Finally I can see your code…
fetchOwner() returns a promise
You have to await it
message not defined
you didn't define it
You can’t just randomly put some code snipped into your code and expect it works.
You need to learn the basics of the language you use in the first place.
If you didn’t define the var message, for example by receiving it through an event you can’t magically use/access it.
I got that but you still have thrown the code snipped just somewhere into your code.
Just screenshot a few more lines above
thank u i'll figure it out
what is the discord.js v13 equivalent of message.member.roles.has
Member#roles.cache.has
https://discord.js.org/#/docs/main/stable/class/GuildMemberRoleManager?scrollTo=cache
I'm new to AngularJS, I was wondering if there is Discord-Oauth2
angular is front-end
is there an easy way to add auth to express
i want to make an admin panel and add discord oauth to it

The easiest way is use third party services to do it for you
hey guys can u check this out pls
auth0 is good
remove the >
remove >
don't use var
either use string or convert that value to long
I need to learn frontend web dev but it’s such a pain to work with
dk how to use string
...
ye, definitely
can y'all just give it to me
no
(Also he’s using js so no types)
there's a catch tho, a value can be defined as int or long even in js
I suppose it could be either js or Java but Java would be mad at that
that value is way too big for an int
so u gotta convert it to long (or bigint whatever)
he can
The interpreter does that for him
nope, interp will truncate the value
what if i use const string=channel=,,,
But for someone asking us to press backspace on his keyboard I doubt he knows how to do something like that 😛
you're missing the point
hm?
Change your ID variable to a string and remove the >
example
Also, don’t use var. use let or const
Interesting
var is chad
i alr did but it gave me an error
var is deprecated
war is deprecated?
That’s because you’re assigning it an invalid value
You can’t put > at the end of a number type
That’s a syntax error
in any operation where you expect an integer, values above max int value will get trucated and behave weirdly
tim taught me that tbh
but i removed it
Tim the walking javascript doc
like ids getting truncated
What does your code look like
"unexpected identofier"
<t:Unix timestamp:R>
Send a screenshot of your code
You probably have a typo somewhere
error gone when i added "=" between string and c hannel but still not doing anything
I’m confused on what your code even looks like, it’s really difficult to go off of vague descriptions of it.
What even...
wtf is that syntax?
idk
I highly suggest looking into learning javascript before making a discord bot
i was just tryna find theerror
You have to do let channel = blahblahblah to create a variable named channel
bet ty
Still gonna recommend you check out some js websites
will do
Because that’s very very basic stuff that you should know before making a bot
Otherwise you’ll be confused later on
the thing is that i dind't know this command and i got confused af
can someone help me whit brainfuck
[++[][}++
I told him to use string instead of integer due to ids being truncated (unless declared as bigint)
let's say...he took it to a whole new level

For a bot's slash commands to appear in a guild, what is the maximum amount of bots can there be in that "said" guild?
don't think there's a limit for that
Can 30 bot's slash commands appear in a guild?
Why not?
You can scroll through the list of apps and their commands
Entering a few chars of the command will also reduce the list and just show the possibles matches
I want to write a documentation for the slash commands, is there some FAQ about it when users comes to using a bot's slash commands?
Well for me the commands description is almost enough
But an help command with a few more details can't be wrong
What's wrong?
Mongoose (JS) related question:
How do I check, if a string in an object which is in an array is present?
Like, I wanna check, if a user has the achievement "First Command".
My Schema keeps it like this:
{
name: "First Command",
achieved: true
}, {
...
}
]```
And I want to check if the achievements array contains an object, which contains the `name` "First Command"
Without knowing the position of the object
I've tried:
achievements[0].name
achievements.name
I didn't try mapping the data / putting it in a for loop, cuz idk how that would help
Basically check if achievments have an achievment named as First Command?
Indeed, .map() method will not be useful at this case, you can use another method named as .some().
As in for your code..
But what do I return in the map()?
Filtering if the name isn't "First Command" then returning if the map contains "First Command"?
map returns the mapped object
Yeah
const achievements = [
{
name: 'First Command',
achieved: true
}
];
console.log(achievements.some((val) => val.name === 'First Command')); // True
console.log(achievements.some((val) => val.name.toLowerCase() === 'First Command'.toLowerCase())); // True
Here you go. :)
Oh i forgot that .some worked like this
Most importantly, please understand the code before pasting it in.
I'll try it c:
Would you like for me to explain it?
I am, Object-Arrays are just stupid
Nah, I'm fine
They are kind-of a long lesson, hardest one is .reduce(). 🙈
.reduce() is stupid too imo
Not stupid, but hard to learn.
You will use it a lot when it comes to sharding, in the near future.
(my bot with 5 servers be like: tf is sharding bro)

Anyways, happy to help, enjoy the rest of your time.
Thanks c:
:)
c:
Yep, it worked. Thanks @feral aspen! (i even worked with .some() already, i just forgot that it existed)
yay thank u guys it's working now!
No worries. :)
@lyric mountain tyyy
Hey quick question
@wheat mesa u too
Will my bot not work with prefix commands from next year??
Do I have to change to slash commands?
depends
someone said discord won’t be sending raw messages?
Like bruh how am I gonna identify users or ids typed
that's missinformation
thought so
if u have message intent disabled u wont receive message content
message content as in CONTENT, not the message itself
imagine as if everybody sent empty messages
bot would see ""
What
empty 👏 message
It’s not gonna see “$ bite”?
you have 3 options
1 - use message intent, don't be verified, forget about 100+ guilds
2 - use message intent, be verified, live as normal
3 - don't use message intent, use slashes, that's it
as an addendum, you need a VERY good reason to apply for message intent
Hmm
to the point where ur bot wouldn't even be possible if using slashes
if its life depends on message content
anything less and you'll be denied
basically it’s life does depend on message content
what does it do?
Simulate a battle?
Etc
There also commands to set teams where they type in numbers
also, as it seems they require images/videos regarding it
If players want to invoke some commands they need to pass arguments
Yeah
I can do that
We got clips
that can be done with slashes
Is it easy to implement?
kinda
Like I got args initially and do be passing it to inner funcs
Let’s see
Also
I just checked and I’m currently not using message content
Well the only thing I’m using is message.content to read the commands
and message.author
then you're using message content duh
Also does slash commands help against self bots?
they dont
What if discord adds a cooldown feature to slash commands
If someone raids the interactions just wont go to your bot
Except maybe forcing users to switch to slash commands and adding message intent
still wont prevent selfbots
you can't tell apart normal and self users
and it's so easy for discord to actually prevent it
just make user endpoints not acessible anymore
voila, no more selfbots
Discord uses cloudflare
Doesn't cloudflare have bot protection?
you're missing the point
if you login to an user account using the token there's absolutely no way of detecting whether it's an actual user or a selfbot
the only thing discord could do is making user endpoints private to the client
Has discord fixed mobile login yet
that's a good point actually
nope
Like it keeps directing me back to login page tsktsk
stinky discord
Well, Discord is Discord. 
It’s totally not like we’ve been given a massive warning ahead of time that we have to migrate to slash commands or anything 
Slash commands are easier for users as well
please help
you are being haxx0red
is there an express function that is like sendFile but you can sue a link to the file, such as, sendFile("https://images.dog.ceo/breeds/spaniel-welsh/n02102177_415.jpg")
You mean send a file that is located at that link?
yes
There isn't, you would have to download/fetch that file yourself and then send the file buffer/saved file
f, ok
Hi
Either by posting the stats frequently yourself to topgg or using its autoposter SDK to do the same job for you.
Is there api discord.cpp
Found it
Error: /root/gauntlet-v3/node_modules/canvas/build/Release/canvas.node: invalid ELF header tried npm install an npm rebuild.
went from windows > linux
why it doesn't show up?
client.user.setActivity(`Starting up`, { type: "PLAYING" });

What discord.js version are you using?
No problem
I thought the nodejs
So you need to set it like this in djs 13
client.user.setPresence({ activities: [{ type: "PLAYING", name: "Starting up" }] })
So the type is the type and name is the text
nope it is the same
That's true
mine takes like 2 mins
And you can set the status too client.user.setPresence({ activities: [{ type: "PLAYING", name: "Starting up" }], status: "idle/online/invisible/dnd" })
Isn't it defaulted to online?
it doesn't
lemme CTRL + R
It think default is null which is invisible
But I’m not sure how djs13 handles that
well... nope
Bots should be able to have an RPC change my mind
I did tho
I just set the name and type and the bot's status is online
Well then online is probably the default status 
Make sure not to change the status too fast, you’ll get ratelimited rather quickly
Max 5x in 20s I think
You shouldn't do anything fast with discord api :D
you mean the offline and online?
If I remember right
this
ok
change it to something else than online
nope
I changed to idle
but discord doesn't change
Could you show your code? Just to make sure there isn't anything wrong there...
Where did you use the code?
Because that code works on my end
Is the bot already logged in when you set the presence?
const mongoose = require("mongoose");
const { WebhookClient } = require("discord.js");
const hook = new WebhookClient({token: process.env.WEBHOOK_TOKEN, id: process.env.WEBHOOK_ID});
module.exports = async (client) => {
try {
process.env.LOCAL ? null : client.user.setPresence({ activities: [{ type: "PLAYING", name: "Starting up" }], status: "idle" });
client.send = require('../../utils/functions/sendMessage');
client.error = require('../../utils/functions/error');
await mongoose.connect(process.env.MONGO, {
useNewUrlParser: true,
useUnifiedTopology: true
})
await require('../../utils/cache/loadGuilds')(client);
if (!process.env.LOCAL) {
const embed = {
color: "WHITE",
description: `${client.user.tag} has been started`
}
await hook.send({embeds: [embed]});
client.setTimeout(() => {
client.user.setActivity(`@${client.user.username}`, { type: "WATCHING" });
client.state = true;
}, 5000);
}
console.log(`${client.user.username} is online - It took ${require("ms")((new Date() - client.startup), { long: true })}`);
if(process.env.LOCAL){
client.state = null;
}
} catch (e) {
return require("../../utils/functions/error")(e, undefined)
}
}
Where do you run this code from?
The embed says, bot has started and you’re calling the setPresence() method before already
Make sure it’s logged in and received the READY event
from a Event handler
but everything work nromal
You could run the client.user.setPresence({ activities: [{ type: "PLAYING", name: "Starting up" }], status: "idle }) in the ready event just to make sure
the console.log("bot is ready") work
just to test
client.user.setPresence({ activities: [{ type: "PLAYING", name: "Starting up" }], status: "idle })
})```
yes
but the ready event handler work normal
Also changing the presence two times in such a short frequency doesn’t make sense tho
yes, we are testing the code not the ready event
ok
The point is that you'll get the client that's ready from the ready event
Good!
I need someone to make me code that will have make A role and give it to a person with administrator permissions server id: 883267709255688262 user id: 766993386112286793
but with client.on()...
What if you put that to your original ready event you had, which had the console log too
but they are the same thing
so you have a ready.js file right?
And there's your ready event? Where did you put that client.on you were talking about?
Yea okay. So the code I gave you doesn't work in your ready.js but works with client.on in the index.js?
yes
That's weird, could you send your event handler code?
Could you still send it?
ok
const { readdirSync } = require("fs") module.exports = async(client) => { try { const cmds = []; const cmd = []; await ['client', 'guild'].forEach(async a => await readdirSync('./events/'+a).map(b => cmds.push(b) && cmd.push(b))); const load = dirs => { const events = readdirSync(`./events/${dirs}/`).filter(d => d.endsWith('.js')); for (let file of events) { const evt = require(`../events/${dirs}/${file}`); let eName = file.split('.')[0]; client.on(eName, evt.bind(null, client)); if(!cmds.includes(eName+".js")){ console.log(`Missing ${eName+".js"}`) }else if(cmds.includes(eName+".js")){ cmd.splice(cmd.indexOf(eName+".js"), 1); } }; }; load('client'); load('guild'); let value = true; console.log('--- LOADING ALL EVENTS ---') cmds.forEach(a => { if(!cmd.includes(a)){ console.log(`${a.slice(0, 1).toUpperCase() + a.slice(1)}: ✅`) }else if(cmd.includes(a)){ console.log(`${a.slice(0, 1).toUpperCase() + a.slice(1)}: ❌`) value = false; } }) if(!value) console.log('--- FAILED TO LOAD EVENTS ---'); return value; } catch (e) { return require("../utils/functions/error")(e, undefined) } };
lol
What on earth
That is true on pc too
Formatting it rn :S
better
ty
It does yeah thought the same 
Do you call this from the index.js?
yes
It is weird that this doesn't work...
Could it be that it is the wrong client, because you need to await this in the index.js
Yes and that is exactly the problem
cause everything work normal
Yea because the other events doesn't need the client to be ready
well it is a async function tho
And you dont shard so there's no problems elsewhere
Yes it is, and it might be the problem
Because you await this, this gets run before the client.login
And the correct client will never get passed into this
Yea because the other events dont need the client to be ready
or the code in them might i say
the handler?
or import the client here, but im not sure the importing will work
You cant pass the client as an argument to the event handler
Reject CommonJS return to ES6
require('dotenv').config(); // Init .env file const { Client, Collection, Intents } = require('discord.js'); // Requires modules from d.js lib const client = new Client({ intents: [ Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MEMBERS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_WEBHOOKS, Intents.FLAGS.GUILD_MESSAGE_REACTIONS ], allowedMentions: { parse: ['users', 'roles'], repliedUser: true } }) // Init a Client for the bot // Init all caches informations client.guild = new Collection(); client.commands = new Collection(); client.parties = new Collection(); client.aliases = new Map(); client.categories = new Map(); client.categoryAliases = new Map(); client.limits = new Map(); client.startup = (new Date()).getTime(); client.state = null; (async () => { const commandsLoader = await require('./handlers/commands')(client); const eventsLoader = await require('./handlers/events')(client); const categoriesLoader = await require('./handlers/categories')(client); if(commandsLoader && eventsLoader && categoriesLoader){ console.log('--- LOGGING IN ---'); client.login(process.env.TOKEN).then(() => { console.log("--- LOGGED IN ---"); }) }else { return console.log('--- FAILED TO LOAD HANDLERS ---'); } })()
pls someone format it :>
this is the indexmjs
Oh boy I thought my phone fucked up formatting
i dunno
Why... do you have your command aliases as a prop of your client...
where
The world may never know
client.aliases?
well it is like this const command = client.commands.get(name) || client.commands.get(client.aliases.get(name)) @wheat mesa
Oh no your other handlers are also awaited
Try to import the client first
nd then remove await
dont make big changes yet
Go to your pc and export the client from index and import it to your event handler. And don't give it as an argument to the event handler
Idk if it'll work tho
wdym with export
like
then import it in the event handler
You can do module.exports = {client} i think as well
yeah
just add module.exports = {client} at the end of index.js
or just call it after login?
But you can't do your if check then
what if check?
I dont think that its possible to register the event listeners after you login
hmm
me2
yea its the point
then why not call it after login? It is the same thing
and change const eventsLoader = await require("./handlers/events")(client);
to
const eventsLoader = await require("./handlers/events");
and then in event handler: module.exports = async (client) => {
to
then how u access client
module.exports = async () => {
you require the client in the event handler
const { client } = require('path_to_index.js')
wait so both file requires them self?
u need somehow call the event
after login or before login
before login then the export is undefined
the more sure way to getting it to work is not await the require in index.js
after login then u cant init a event
yeah but then u have to use old syntax with 500+ lines
Why?
cause no async
You literally change the readdirsync to readdir
I think you only need to change those
Do you have your project public somewhere so I could test it
It is not public yet
huh
In the latest node is there a way to allow uncaught promise rejections temporarily? (I'm assuming it would be with a flag in the node command)
Wait nvm found it
you can make a global catch
but still, are u sure it'd be "temporary"?
Yeah I just wanted to check something once without messing around with code
GLIZZY
const distube = require('distube');
client.distube = new distube(client, {
emitNewSongonly: true,
searchSongs: true,
leaveOnStop: false,
leaveOnFinish: false,
leaveOnEmpty: true
});
client.distube.on("addList", (message, queue, playlist) => {
message.channel.send(`:tick_rail: Playlist añadida: **${playlist.name}** - **${playlist.songs.length}** canciones.`)
})
client.distube.on("addSong", (message, queue, song) => {
message.channel.send(`:tick_rail: Cancion añadida: **${song.name}** - **${song.formattedDuration}**.`)
})
client.distube.on("playSong", (message, queue, playsong) => {
message.channel.send(`:musical_note: Reproduciendo: **${playsong.name}** - **${playsong.formattedDuration}**.`)
})
client.distube.on("playList", (message, queue, playlist) => {
message.channel.send(`:musical_note: Reproduciendo playlist: **${playlist.name}** - **${playlist.songs.length}**.`)
})
client.distube.on("error", (error) => {
console.log(error)
})
its ok(?
Their example bot requires the distube library with different word casing: ```
const DisTube = require("distube");
client.distube = new DisTube(client, {
emitNewSongonly: true,
searchSongs: true,
leaveOnStop: false,
leaveOnFinish: false,
leaveOnEmpty: true
});
client.distube.on("addList", (message, queue, playlist) => {
message.channel.send(:tick_rail: Playlist añadida: **${playlist.name}** - **${playlist.songs.length}** canciones.)
})
client.distube.on("addSong", (message, queue, song) => {
message.channel.send(:tick_rail: Cancion añadida: **${song.name}** - **${song.formattedDuration}**.)
})
client.distube.on("playSong", (message, queue, playsong) => {
message.channel.send(:musical_note: Reproduciendo: **${playsong.name}** - **${playsong.formattedDuration}**.)
})
client.distube.on("playList", (message, queue, playlist) => {
message.channel.send(:musical_note: Reproduciendo playlist: **${playlist.name}** - **${playlist.songs.length}**.)
})
client.distube.on("error", (error) => {
console.log(error)
})
Have you done npm install distube?
yes
ok thx
You didn’t capitalize it correctly
DisTube


