#development
1 messages ยท Page 1835 of 1

py / python is the language. discord.py is the name of the python library to interact with discord

im just using python
hello fellow human
Nope thats a scam
Heya
what u r doing is a scam๐
how?
Learn how to code a Discord bot using Python and host it for free in the cloud using Repl.it. Along the way, you will learn to use Repl.it's built-in database and create a Discord bot that uses webhooks to connect with GitHub.
Need help with this tutorial? You can ask questions here: https://forum.freecodecamp.org/
This course was developed by...
take this and watch some similar stuff
in run the bot in replit\
this guy is using reptil
Imma go cry in a corner now
does your python code have "import discord"?
or similar
Were u crying too, when I was asking dumb questions couple of hours back 
yes it has import discord
@fresh bluff try this won't take more than couple of hours but will enlighten you a lot
No. There are no dumb questions. Just at least you listened to the answers we gave you.
then yes, you are using discord.py
so go read the discord.py docs
if you do anything, dont follow that tutorial
that tutorial
I've said this about 5 times already
and it amazes me how badly its done
post the link 5 times too
god
does anyone here know how deletes in interactions work
does delete delete the latest reply
since you can apparently post multiple replies
in 15 mins
Umm, so I have now been able to fetch the webhook and confirm whenever someone votes and send thier id in console. Now I want to send a message to specific channel, I read the docs and googled and found out that client.channels.cache.get('CHANNEL ID').send('Hello here!') sends the message, but I don't have client declared in my server.js, so my doubt is do I need to write ```const Discord = require('discord.js');
const client = new Discord.Client();``` once again in server.js or there is some other way ?
What I have written in server.js -->
const server = express();
//for top.gg
const Topgg = require('@top-gg/sdk');
const webhook = new Topgg.Webhook("4N8eXCvZHjpfwt");
server.all('/', (req, res)=>{
res.send('Your bot is alive!')
})
function keepAlive(){
server.listen(3000, ()=>{console.log("Server is Ready!")});
}
server.post("/dblwebhook", webhook.listener(vote => {
// vote will be your vote object, e.g
console.log(vote.user) // 395526710101278721 < user who voted\
user=client.users.cache.get(vote.user);
client.channels.cache.get('766908428411994134').send('Thank you ${user} for voting!!');
// You can also throw an error to the listener callback in order to resend the webhook after a few seconds
}));
module.exports = keepAlive;```
Is other things right beside that client thing ?
you can delete followup messages by id
discord js says no
unless theres some other method to do it
man fuck djs lol
im just doing it to test out interactions
InteractionWebhook#deleteMessage(id)
reply is the original message
so you use @original as the message id
for followups you use CommandInteraction#followUp
oh i see
they return message objects
so yes
be it following up, editing or deleting
i saw it in api docs
offtopic: rate my code
this.properties = options.properties && typeof options.properties === "object" && [options.properties.$os, options.properties.$browser, options.properties.$device].every(x => typeof x === "string") ? options.properties : {
$os: process.platform,
$browser: "test",
$device: "test"
};
:^)
how did you color this ?
maybe if you indented properly i'd give it a 10
it is indented
its just the first line is super long
thats your queue to press enter
xD
if it does the job it does the job
Ok im getting a error
though as an easter egg the os, device and browser should be "amogus"
File "main.py", line 7
print('we have logged in as {0.user}
^
SyntaxError: EOL while scanning string literal
you can use modules to seperate your bot and webhook into different files then when run them together at once
```js
console.log("lol")
```
hey Guys i need help
```rs
wait i dont know rust
```
im getting a error
File "main.py", line 7
print('we have logged in as {0.user}
^
SyntaxError: EOL while scanning string literal
what does that mean?
```detritus
type djs = dumb
are you sure you closed the quote
it means you have no idea what you're doing
do you know what a string it?
i can see
man
@quartz kindle this is the line im getting the error at
print('we have logged in as {0.user}
'.format(client)')
just use f strings they're a lot easier to use for beginners
if you check your quotes, you will see they are in the wrong place
the string is malformed
uh
im getting a error bc of }
that
no you arent
3/10 because you didn't use typeof (JSON.stringify(Object.getPrototypeOf(options.properties)) === JSON.stringify(Object)) === "boolean"
lmao
Oh wait im dumb
which is why ill make it worse
File "main.py", line 7
print('we have logged in as {0.user}
^
SyntaxError: EOL while scanning string literal
but i still get this after fixing the error
again, do you know what a string is?
then learn what a string is
im so confused
because you dont know how programming works
You may want to start with learning python.
ima keep this bot on hold and learn more about python
good idea
Separate message in different file than server.js and call the function here ?
I'm planning to add a very basic command handler too
// bot.js
//do your bot stuff here
//DONT run client.login
module.exports = client;
// server.js
const client = require("./server.js");
// do your webhook stuff and send messages with the bot
client.login(token);
manga search and anime search done, now need to fine tune, then my bot is finished? lol
process.memoryUsage()
process.memoryUsage.rss()
Thanks for detailed explanation but I already have const keepAlive = require('./server'); to keep bot up 24/7 on reptil so do I need const client = require("./server.js"); ?
main one, index.js
and where is your bot code?
Well I'm plannning to use command handler(did in previous code of a basic bot) so in commands folder
command.js and server.js are in root
ok cool
damn, didn't expect flashbang
lmfao
Can't find dark on reptil, I prefer it too
anyways does your server.js file need to access the client variable?
reptil has dark
go to settings tab on left
Dark Theme has long been one of the most highly request features on Repl.it. We introduced a dark theme editor some time back, butโฆ
me and the bois reading the article on light mode
now this white patch feels more weird and bad
Lol
So does your server.js file need anything that requires the client variable?
Well I tried sending message of vote confirmation from server file, is that wrong way to go ?
just close it, you don't need that tab at all
It will stop your bot
really?
yeah
Is there any official date when v12 will be depreciated ?
dat sucks
And it'll reopen when you run the app again because it reopens if the app is listening on a server
just create a css file then and add body { background-color: black }
like this
const express = require('express');
const server = express();
//for top.gg
const Topgg = require('@top-gg/sdk');
const webhook = new Topgg.Webhook("4N8eXCvZHjpfwt");
server.all('/', (req, res)=>{
res.send('Your bot is alive!')
})
function keepAlive(){
server.listen(3000, ()=>{console.log("Server is Ready!")});
}
server.post("/dblwebhook", webhook.listener(vote => {
// vote will be your vote object, e.g
console.log(vote.user) // 395526710101278721 < user who voted\
user=client.users.cache.get(vote.user);
client.channels.cache.get('766908428411994134').send('Thank you ${user} for voting!!');
// You can also throw an error to the listener callback in order to resend the webhook after a few seconds
}));
module.exports = keepAlive;
uh oh
too lazy to do that
the error should be client is undefined
keep your webhook auth secret
Gotta regen that now!
no error ๐
The error will only happen when a user votes
well I'm gonna add to secret keys later, thanks for reminder
Because it will try to send a message to vote.user
ohh that's why
remember to change it
Will do rn
You need to pass the client variable to server.js
lazy approach:
module.exports = client => {
keepAlive();
the rest of your code in server.js
}
// index.js
keepAlive(client);
Hmm
Will do rn
Ll
sussy baka above
this whole is in index.js or top one in server.js
user=client.users.cache.get(vote.user);
client.channels.cache.get('766908428411994134').send('Thank you ${user} for voting!!');```
this, right ? or whole ?
won't it make server.js useless ?
Well the basic intention of server.js was to reduce the clutter in index.js but it's opposite now๐
ikr
code splitting with module.exports makes it easier to read and debug but it adds two extra lines to every file
if the cost for easier debugging is 124192804 extra lines it's still worth it
and then we have this:
const thing = require("./../../../../../components/path/to/smth/aaaaa/got_the_file.js");
i still dont know how to use absolute imports in esbuild
LETS GO!
just put the full path
like C:/files/more files/da files/file.txt
So
index.js
console.log('Beep beep! ๐');
const keepAlive = require('./server');
const Discord = require('discord.js');
const client = new Discord.Client();
module.exports = client => {
keepAlive();
const express = require('express');
const server = express();
//for top.gg
const Topgg = require('@top-gg/sdk');
const webhook = new Topgg.Webhook(process.env['WEBHOOKAUTH']);
server.all('/', (req, res)=>{
res.send('Your bot is alive!')
})
function keepAlive(){
server.listen(3000, ()=>{console.log("Server is Ready!")});
}
server.post("/dblwebhook", webhook.listener(vote => {
// vote will be your vote object, e.g
console.log(vote.user) // 395526710101278721 < user who voted\
// You can also throw an error to the listener callback in order to resend the webhook after a few seconds
}));
}
keepAlive(client);
client.login(process.env['BOTTOKEN']);
client.on('ready', () =>{
console.log("Bot is ready !!");
client.user.setActivity('Tracking Votes', { type: "LISTENING" }).catch(console.error)
})
const commandHandler = require('./commands');
client.on('message', commandHandler);```
> server.js
```module.exports = keepAlive;```
this is an absolute path
it's in root ๐ค
show server.js
bottom
i like to keep my stuff on desktop
entire file
anyways i think that should be good
I have always used it in root
just put the keepAlive(); after function keepAlive() {}
also keepAlive functions dont work anymore
try uptimerobot
yeah i have linked to it
It feels wierd server.js is empty and index.js is cluttered
it's not working, issue already with support
waaaa
server.js is empty

lmfao
this was what your code was supposed to be
server.js
module.exports = client => {
anything and EVERYTHING server.js does and is supposed to do pls put it here i beg you
}
im off to sleep rn bye
gn 
index.js
console.log('Beep beep! ๐');
const keepAlive = require('./server');
const Discord = require('discord.js');
const client = new Discord.Client();
keepAlive(client);
client.login(process.env['BOTTOKEN']);
client.on('ready', () =>{
console.log("Bot is ready !!");
client.user.setActivity('Tracking Votes', { type: "LISTENING" }).catch(console.error)
})
const commandHandler = require('./commands');
client.on('message', commandHandler);```
> server.js
```javascript
module.exports = client => {
const express = require('express');
const server = express();
//for top.gg
const Topgg = require('@top-gg/sdk');
const webhook = new Topgg.Webhook(process.env['WEBHOOKAUTH']);
server.all('/', (req, res)=>{
res.send('Your bot is alive!')
})
function keepAlive(){
server.listen(3000, ()=>{console.log("Server is Ready!")});
}
server.post("/dblwebhook", webhook.listener(vote => {
// vote will be your vote object, e.g
console.log(vote.user) // 395526710101278721 < user who voted\
// You can also throw an error to the listener callback in order to resend the webhook after a few seconds
}));
}
module.exports = keepAlive;```
Final, right ?
imo depends on how proficient are you in discord.py
I've gotten to where I am pulling my commands, but I am only trying to pull certain ones, should I be filtering my commands instead of immediately mapping? Or is there a way I can do this? I am working on pulling certain commands from one category or location, which is administration commands, but instead I get all commands, and I am pretty sure I am just doing it wrong.
const response = [...client.commands].map(
(value) => value[0].toString().toUpperCase() + value.slice(1).toString().toLowerCase()[
client.commands.filter(
(cmd) => cmd.location == 'Administration'
).size
]+`\n===\n ${client.commands
.filter((cmd) => cmd.location == 'Administration')
.map((value) => value.name)
.join(', \n')
}`
);
Thanks in advance.
I MADE A WORKING BOT
djs is typically known for being behind tbh
Good for you.
congrats, you found 1 out of 7 issues regarding free hosts
6 remaining

Accurate
nah u don't 
code is public, less resource and ?
Paid hosting will always be better, I personally recommend Contabo but that is up to you who you go with, if you're just starting out try IcedHostLLC, very professional team and very very cheap.
THAT'S more like it
Just one line to change
Remove the second module.exports = keepAlive on the last line
Limited uptime
Free host scavenger hunt
double contabo
How do i make my bot stay on always
4 remaining
pay for a host
I don't have money ๐ฆ

Get job
can't
This ain't for you without money
personally I use Oracle as a free host
Oracle 




does it work good?
Oracle bad
Granted it's not a lot of resources
๐คฆโโ๏ธ
Well for starting out free ones are great
Oracle works fine for a small bot
try gcs or heroku, free but good
oracle is the total inverse of "customer friendly"
if with contabo you can call em for a pizza party
I chose Oracle because it was a host with 24/7 uptime and I won't get charged unless I upgrade my account
The opposite actually for oracle
Using Java creators' platform to host JavaScript nodejs 
Whereas with AWS and stuff they might slap you with a bill if you have overages
oracle is that guy who'll take the whole pizza box, throw into ur face and run to the street freaking out
My website is built in javascript
AHAHAHAHA
New error coming now
at checkListener (events.js:110:11)
at _addListener (events.js:347:3)
at Client.addListener (events.js:405:10)
at /home/runner/AS-bot/index.js:18:8
at Script.runInContext (vm.js:130:18)
at Object.<anonymous> (/run_dir/interp.js:209:20)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)```
um every website is
It works fine for now

I'll eventually upgrade to a paid host once I need to
check line 18 of index.js
No they aren't, they are built in HTML and CSS AND javascript, my website is mainly javascript lmao
What
hm what?
Legit.
Oh you meant this message
all sites have all 3 elements
it's like the holy trinity of webdevving
js handles the backend logic, CSS and HTML are for frontend development
js also for frontend logic
It's client.on('message', commandHandler); for command handler , would I really need to remove this ?
you can serve zero html css js or anything to user yet still add interactivity by using a deprecated http header
Yeah, mine is literally written in js, since I made it with EJS and I'm having so many issues with it.
That is true
your command handler is an object not a function
that's a you problem
the site can be made with anything, but will be presented to the user as a html/css/js site
i haven't done a command handler for 4 months
I had to learn how to make mine, and I had to make it better because I wanted everything organized because OCD
Which I still need help on my problem
Obsessive Compulsive Disorder,
HOW DO I HOST MY BOT 24/7
ohh ok
BUY A HOST
๐ฆ
pwnfunction on youtube found an http header that can serve as an equivalent of the link tag in html but there is no html served in the response body
dude used some nasty css to rickroll people
here's the header name: ||never gonna give you Link||
Pay for a host!
Paid hosts are always gonna be better than free hosts
Free hosts have strings attached
is there a simple way to detect if there is "Missing permission" error in your code in your index and then simply make it do something like return; ?
Pay for a freaking host or leave your computer online 24/7
(Discord.js v12.5.6)
@earnest phoenix it's stopped working now, earlier it was registering userid on console but that too ain't happening 
contabo is like 6.99
Ah yes Discord.js v125.6 the version we finally get slash command support
lol
show your code for command handler
I removed it for now
alr
if(!message.guild.me.hasPermission('PERMISSION_HERE')) {
// Function
}
well did you try to use a test vote
for a coffee thats a bit expensive lol
From what I've heard, hetzner gives the most raw specs for the price, never used it though.
test vote is down so i tried with alt account
it should log smth on test vote
Welcome to starbucks
Bruh coffee is expensive? Try subway! I have enough dirt on my subway location to possibly get a management change.
i can make a one time investment and buy a small express and get some coffee beans and cream and im all set
well, Ik that, but like the error it self fully? Like not only that specific perm
like client.on('MISSINGPERMISSIONS', () => {
}) ?
In your event file try unhandeldRejection or uncaughtException.
index.js
console.log('Beep beep! ๐');
const keepAlive = require('./server');
const Discord = require('discord.js');
const client = new Discord.Client();
keepAlive(client);
client.login(process.env['BOTTOKEN']);
client.on('ready', () =>{
console.log("Bot is ready !!");
client.user.setActivity('Tracking Votes', { type: "LISTENING" }).catch(console.error)
})```
> server.js
```javascript
module.exports = client => {
const express = require('express');
const server = express();
//for top.gg
const Topgg = require('@top-gg/sdk');
const webhook = new Topgg.Webhook(process.env['WEBHOOKAUTH']);
server.all('/', (req, res)=>{
res.send('Your bot is alive!')
})
function keepAlive(){
server.listen(3000, ()=>{console.log("Server is Ready!")});
}
server.post("/dblwebhook", webhook.listener(vote => {
// vote will be your vote object, e.g
console.log(vote.user) // 395526710101278721 < user who voted\
client.channels.cache.get('766908428411994134').send('Thank you');
// You can also throw an error to the listener callback in order to resend the webhook after a few seconds
}));
}```
DuckDuckGo exists because people are too lazy to turn off personalized ads on myaccount.google.com
Starbucks exists for a similar reason
I say event file, every file of mine literally has its own purpose
though in the uk its a little cheaper
you are not running keepAlive in server.js
Keep the following in mind, just because you have those two things does NOT mean that you will be able to figure out the permission instantly, figure out what permissions your bot needs, and tailor error messages to such, I will give you an example from my code.
It is meant to be run in index.js , right ?
That's what I learned from tutorials
detritus moment
ts onPermissionsFailClient(context: Command.Context, failed: bigint[]) {}
Hey guys I need some help again
Where do i put this code in
@bot.event
async def on_ready():
change_status.start()
print("Your bot is ready.")
Wait i thought you went to learn python about an hour ago?
From Message.JS for The RP Bot
//If the permission for sending messages is denied for the bot, alert the owner, if can't alert owner, leave
if(!message.guild.me.hasPermission('SEND_MESSAGES')) {
const owner = await client.users.cache.get(message.guild.ownerID);
return owner.send(`Hey <@${message.guild.ownerID}>! I am missing permissions in \`${message.guild.name}\`! I need the "Send Messages" permission please!`).catch(() => message.guild.leave());
};
//If the bot is requested to embed things but can't due to 'EMBED_LINKS' being denied
if(!message.guild.me.hasPermission(`EMBED_LINKS`)) {
if (embeds == 'no') {
//
}
else {
return message.channel.send(`Hey! Embeds are enabled for this server, but I can't \`Embed Links\`!`);
};
};
//If the bot is requested to delete commands after running them but can't 'MANAGE_MESSAGES'
if(!message.guild.me.hasPermission(`MANAGE_MESSAGES`)) {
if(messagedel == 'no') {
//
}
else {
await message.channel.send(`Hey! Message Deletion is enabled in this server! But I can't \`Manage Messages\`!`);
};
};
Just as an example.
i did but i need my bot link
this is a golang question
i have a set list of structs that follow a specific interface as follows:
type A interface {
...
Configuration() B
}
type B struct {
...
Configuration T
}
type StructOne struct {
Configuration B
...
}
(s *StructOne) Configuration() {
return s.Configuration
}
the problem is that the configuration is set as a config value, and if left empty, the Configuration field on StructOne will be nil, and i don't think i have to check for a nil value every time, so is there a better way to do this? (essentially StructN all have the same field, Configuration, but they each have their own unique fields as well)
@rose warren can you please look into this once ?
I am trying to send a message whenever someone votes
@quaint wasp
Replied to the wrong person. Sorry Rimuru.
But yeah thats just some of my error catchers for the server itself on the message, that's what I can handle.
missing )
hello everyone
What is my Error? I am trying to get .ping .
You're not passing db to your command
???
In index.js where you have the execute() call
You're not passing the db to the command
it's not that they didn't pass it, they didn't define it in the index file
OK Thanks
Let me do it now
What is this File:
json.sqlite
I ran my code for my tenth time and just got that
that file is created by quick.db
its where all the data you save with quick.db is stored
alr
What is my Error for this Clear Command?
Promise { <pending> }
Hint: hit control+c anytime to enter REPL.
MythicalBot is online
/home/runner/MythicalDreams-Bot/index.js:35
client.command.get('clear').execute(message, args);
^
TypeError: Cannot read property 'get' of undefined
at Client.<anonymous> (/home/runner/MythicalDreams-Bot/index.js:35:19)
at Client.emit (events.js:314:20)
at Client.EventEmitter.emit (domain.js:483:12)
at MessageCreateAction.handle (/home/runner/MythicalDreams-Bot/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (/home/runner/MythicalDreams-Bot/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (/home/runner/MythicalDreams-Bot/node_modules/discord.js/src/client/websocket/WebSocketManager.js:384:31)
at WebSocketShard.onPacket (/home/runner/MythicalDreams-Bot/node_modules/discord.js/src/client/websocket/WebSocketShard.js:444:22)
at WebSocketShard.onMessage (/home/runner/MythicalDreams-Bot/node_modules/discord.js/src/client/websocket/WebSocketShard.js:301:10)
at WebSocket.onMessage (/home/runner/MythicalDreams-Bot/node_modules/ws/lib/event-target.js:132:16)
at WebSocket.emit (events.js:314:20)
repl process died unexpectedly: exit status 1
๎บง ```
You're missing an s on commands
index.js line 35
I will
i am
can someone help with this error tho?
umm
BREH
I forgot how to turn json thing "[object Object]" to string ๐
.. I tried .toSting() but no work
It's better than cloning a GitHub repo
lol
thanks
Can you help??
It says your clear command isn't defined in commands
Fixed. I reloaded the page lol
. . .
do you have to ask about every single error you get?
if something is undefined, it means it doesnt exist or your code cant find it. so look for typos, then look for mistakes
@quartz kindle where the Error Here? I dont see it.
I am confused
I have a line there tho
await message.channel.messages.fetch({limit: args[0]}).then(messages =>{
message.channel.bulkDelete(messages);
So go from that to this?
message.channel.messages.fetch({limit: args[0]}).then(messages =>{
message.channel.bulkDelete(messages); ```
New Error:
Promise { <pending> }
/home/runner/MythicalDreams-Bot/commands/clear.js:11
await message.channel.messages.fetch({limit: a
Promise { <pending> }
Hint: hit control+c anytime to enter REPL.
MythicalBot is online
@swift umbra
No it is not lol
I copied the Con
I just got that Error
I dont
ReRunning ^
@swift umbra ^^
Yeah
I reran it too
After a while it says it is online.
It is online but the code is broke LOL
Let me test
yes LOL.
I need this fixed with the error
Because it will Confuse me
I did.
After i run it, it is taking a minute to show that it is online.
markdown or html?
<img src="" />
How do I edit the script args for a pm2 process?
And/or get rid of the script args entirely
cli or ecosystem file?
cli
wait, what cli args exactly?
I accidentally put some extra args on the pm2 script earlier, all I'd like it to run is npm start but I accidentally added args after that
well you can always delete + start again
I suppose
besides that, it should be --node-args=
or something
--interpreter-args <arguments> interpreter options (alias of --node-args)
--node-args <node_args> space delimited arguments to pass to node in cluster mode - e.g. --node-args=โ--debug=7001 --trace-deprecationโ
Just got it
thanks guys!
111mb of RES usage upon startup (using top). Does that seem about right for 17 cached guilds with ~40 members and users cached?
how do i make a request in html inside
<script> tag
const express = require("express")
const app = express()
//app.use(express.json())
app.use("view engine","ejs")
app.get("/",(req,res)=>{
res.render("home")
})
app.listen(2000,()=>{
console.log(`Listening to port 2000`)
})
?
How
you replace it
Ok i well dot it naw
XMLHttpRequest with native JS
or the native fetch api
or by selling your soul to the devil
nvm its app.set
??
lol
I still need help with this, I have been slaving over this for literal hours today but to no avail.
that code makes 0 sense
what are you trying to do?
I am trying to pull literally only 2 commands from one folder and I can't for the life of me.
I pull them from the cache so I have to use the collection.
But I am also updating my DJS so until then I'm not looking for help atm.
Just to make sure, these intents aren't privileged, right?
GatewayIntents.GUILDS,
GatewayIntents.GUILD_MESSAGES,
GatewayIntents.GUILD_MESSAGE_REACTIONS,
GatewayIntents.DIRECT_MESSAGES,
GatewayIntents.DIRECT_MESSAGE_REACTIONS,
if client.commands is a collection of commands, you can directly filter it
client.commands.filter(something)
nope
Alright, time to disable those switches on the prod bot then 
I tried that.
No, the only ones that are is GUILD_MEMBERS and GUILD_PRESENCE.
${details.description ??= 'Not Available'}`.replace(/<br>|<b>|<i>|<\/b>|<\/br>|<i>|<\/i>/gm, ' ').slice(0, 1600) Any idea how can I make it instead of cut of because of the length, and become hanging, I want it like (...more) at the end of sentence. I can see padEnd, but not sure how to implement it
Can you provide a screenshot to see what you mean by "become hanging"?
2 possibilities:
- cutting of the last sentence (match ". ")
- splitting your already cutted text by / +/g
to replace the last item of the array (in your case "Worki) by a โฆ for example
Anyone now how; When the bot would restart, it would check if the user has a role, in a preset embed, if a user was removed from a role, it would update the pre-sent embed?
if that makes sense
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/at Is this possible solution too? Have not tried it , but look ideal, oops only 1 word. nvm lmao
how to fix dis
Question for Namecheap domain owners:
do I need to buy the Web Hosting package in order to get access to FTP?
I mean yeah
why else would you need ftp
if you're not gonna host
in namecheap you need to pay extra for hosting
Show your code at the place itโs throwing the error at
(Index.js at line 187)
why es5, why not es6 ๐
@waxen bough install my packages and config above
you have to install the plugins too
plugin for smallest thing 
It a right click menu basically
damn
The few last thing I need to clean up my codes I guess. @ts-expect-error go brrrr
Inconsistent casing go brrrrrrr
Can I change order of keys in an js object?
So that when I do Object.values() it gives different result
Sort them
Use Object.entries(obj), sort the entries and turn it back to an object by using Object.fromEntries(entries)
EnmapPathError: The Key "86550994630193664" does not exist in enmap "settings" at Map.get
How to solve
https://sourceb.in/rHcJdOhE5b Anyone can redirect me how I can get the commandName and customId without resorting the use of ts-expect-error in this code?
Whatโs the warning itโs producing without ts-expect-error?
property commandName does not exist on interaction, well because it exist when the interaction is interaction.isCommand()
anyone knows about enmap database
interface Command {
name: string,
run: (interaction: Interaction) => Promise<void>
...otherProps
}
module.exports = {
...theObject
} as Command;
Forgot to mention, it is js I only have jsconfig.json for typechecking
then you can't
oh, just leave it be then, aight
You can also just use ts
https://discord.evie.dev/ can ask at enmap discord server itself
Evie, the creator of the lib is there too
thanks
How would I display all the users in a role?
Perhaps I am truly an idiot, but discord.js doesn't seem to be sending my command options properly (slash)
Is there some sort of bizzaro reason that it does this? I don't handle my commands via their "command register" garbage, so if I am being forced to get the options by using their system I will be angry
It should just send me the websocket data- but it isn't, I tested it myself, I can get the command options data without the library just fine
I register from message command last time, and now registering via slash command itself
Not too sure what you mean by that
I don't use message based commands at all and don't plan to
I only used it once to register my deploy command
module.exports = {
name:'deploy',
description: 'Deploy global slash command(s)',
guildOnly:true,
owner:true,
/**
* @param {import('discord.js').Message} message
*/
async run(message) {
// @ts-expect-error
const { SlashCommands } = message.client;
const guildCommand = await SlashCommands.get('deploy');
await message.client.application.commands.create(guildCommand, guildCommand.guildId);
message.channel.send({ content:'Done' });
},
};```
then the rest, I register from the slash command deploy
Yes but I already have slash commands registered with the api, I did it myself without the library- that's not my issue
no idea then
how to check which subcommand group was used?
Update: Found out my answer
2 things: discord.js is stupid, and if you want to get command options you must use their command registry system 
With upcoming api changes how are we supposed to the server owners to re invite the bots to support the new interactions
i know some bots automatically got the permissions, like groovy and dank memer
The server owner don't really need to reinvite, just need to reauthorize with relevant scope
yeah but how am i supposed to get hem to do that
i wouldn't trust server owners to actually do it
how to check which subcommand group was used?
anyone?
they'd kick the bot and forget about it
How would I display all the users in a role?
On your command handler, attach button link with the relevant scope you needed
well good thing my bot is already verified, because I am deffinitly going to drop below the 75 server mark
try {
// The function to run your bot
command.run(message, args);
// message attachment to send the button link
message.channel.send('Hey click this suspicous link')
console.log(`${time}: ${message.author.id} used command: ${command.name}`);
}
catch (error) {
console.error(`${time}:${error}`);
}``` this what I did, well am js user
speaking of suspicious links
haha, lmao
perfect timing
wait how did he at everyone
you can type @ everyone but they cannot be pinged
or did a user name themselves everyone
how to check which subcommand group was used?
Code:
let owners = message.guild.roles.cache.get('871584074937028648ID').members.map(m=>m.user.id);
Error:
(node:3419) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'members' of undefined
bruh im getting ignored 
Same lmao
log the role part
Wym?
No love for appleduck

Im trying to see who is in the role lol
That's not why
just checking if the role exist
let owners = message.guild.roles.cache.get('871584074937028648ID').members.map(m=>m.user.id);
^^
Why is there an ID at the end?
That's why it doesn't work
ITs trying to @ the user .
can anyone help
nope thats not it look at the string
numbersID
remove the ID part from .get()
Its trying to do this.
remove the ID at the end of the role id
That's exactly what I was pointing out
?
Yeah, you're on mobile so it's different
So remove .user.id?
No...
Neither...
for ex.
/command create ....
i want to get the subcommand group that was use which is create how would i do that?
I haven't made a Staff List in like a year now.
You're not passing in a valid id as your role
The Role ID is not valid?
You're passing in '871584074937028648ID'
remove the the ID part at the end of the role id
The 'ID' at the end makes it invalid
PFFFT

can anyone help?
@wheat mesa It does not error no more, but it doesn't display the Users in the role...
let owners = message.guild.roles.cache.get('871584074937028648').members.map(m=>m.user.id);
const embed = new Discord.MessageEmbed()
.setAuthor(message.author.tag, message.author.displayAvatarURL({ dynamic:true }))
.setDescription(`**Top Brass** - <@&871584074937028648>\n> - ${owners}`)
message.channel.send(embed)
```
owners is an array of user IDs
So its a map within a map is what I am doing O_O
Log owners and see what shows up
[]
Does anyone have the role?
Yes
4 People
I tried this: ```
.setAuthor(message.author.tag, message.author.displayAvatarURL({ dynamic:true }))
.setDescription(**Top Brass** - <@&871584074937028648>\n> - ${message.guild.roles.cache.get('871584074937028648').members.map(m=>m.user.id)})
Doesnt work
Well, you have nothing in your array of members to begin with
eh?
You logged the value of it, and it came out to be an empty array.
Try logging the value of message.guild.roles.cache.get('roleid')
},
id: '871584074937028648',
name: 'Alena Black Ops',
color: 1315860,
hoist: true,
rawPosition: 144,
permissions: Permissions { bitfield: 2146959359 },
managed: false,
mentionable: false,
deleted: false
}```
I don't see any members property there
I'm not sure if you need a certain intent to access the roles or not, but what intents do you have enabled?
0
its not showing the member bc probably there rnt cached
^^
Whats da fix to that then?
use MEMBER partial/fetch the member

When I log it, it says it got 0 people with the role
When I do other roles, its says it got 1 person with them.
How can I fix this?
for the user to re auth the bot they need to kick it right?
ok ty
let messages = await message.channel.messages.fetch({limit:100});
messages = messages.values();
messages = messages.filter((m) => !m.pinned);
Why i have a error in messages.filter discord.js v13
console log messages
Ok
This is the error
log messages
Ok 1 sec
When i run it my console well be lag and stopped ๐ฅฒ
I am trying to export the client constant from my index.js to server.js to be able to use client.channels.cache.get('766908428411994134').send('Thank you'); but my keepalive(); function is giving error TypeError: keepAlive is not a function , these are my files 
index.js
console.log('Beep beep! ๐');
const keepAlive = require('./server');
const Discord = require('discord.js');
const client = new Discord.Client();
module.exports.Gclient = client; // Exporting client
keepAlive();
client.login(process.env['BOTTOKEN']);
client.on('ready', () =>{
console.log("Bot is ready !!");
client.user.setActivity('Tracking Votes', { type: "LISTENING" }).catch(console.error)
});```
> server.js
```javascript
//Importing client
const index = require("./index.js");
const client = index.Gclient ;
//Importing express and making express
const express = require('express');
const server = express();
//for top.gg
const Topgg = require('@top-gg/sdk');
const webhook = new Topgg.Webhook("4N8eXCvZHjpfwt");
//Keeping bot always on
server.all('/', (req, res)=>{
res.send('Your bot is alive!')
})
function keepAlive(){
server.listen(3000, ()=>{console.log("Server is Ready!")});
}
//Vote confirmation
server.post("/dblwebhook", webhook.listener(vote => {
// vote will be your vote object, e.g
console.log(vote.user) // 395526710101278721 < user who voted\
client.channels.cache.get('766908428411994134').send('Thank you');
// You can also throw an error to the listener callback in order to resend the webhook after a few seconds
}));
module.exports = keepAlive;
When I wasn't using the client it was working fine, happened only when I imported client , can I get some pointers ?
PS: I'm using repl.it
Replace keepAlive() to keepAlive.execute()
in index.js ?
Yes
Getting this as error TypeError: keepAlive.execute is not a function
Do you use discord.js v13?
Also one more thing the top console.log('Beep beep! :wave:'); is logging in console twice, I dunno why 
Nope, I am using the previous version, since I installed before v13 released
It's 12.2.1, checked rn
You need to use this const { keepAlive } = require('./server.js')
Replace this back keepAlive()
still TypeError: keepAlive is not a function
I have another bot which I made after learning the tutorial it has this code
index.js
console.log('Beep beep! ๐');
const keepAlive = require('./server');
const fetch = require('node-fetch');
const Discord = require('discord.js');
const client = new Discord.Client();
keepAlive();
client.login(process.env['BOTTOKEN']);
client.on('ready', () =>{
console.log("Bot is ready !!");
client.user.setActivity('Prefix is: `&`', { type: "LISTENING" }).catch(console.error)
})
const commandHandler = require('./commands');
client.on('message', commandHandler);```
> server.js
```javascript
const express = require('express');
const server = express();
server.all('/', (req, res)=>{
res.send('Your bot is alive!')
})
function keepAlive(){
server.listen(3000, ()=>{console.log("Server is Ready!")});
}
module.exports = keepAlive;```
Here keepalive is working fine, I guess in the new bot there is some issue with importing client, I think I messsed up there but can't figure it out .
@winged juniper
yes check pinned post of #topgg-api
@errant forge
fuck wrong one
@slender thistle
i hope you liek my code
because "organization"

Hello shiv
Hello Mist
Can someone help me with this ?
keepAlive() -> keepAlive.keepAlive();
Still same error 
keepAlive.keepAlive is not a function
then console log keepalive
Will it still call keepalive ?
just do it and tell me what did it log
this
weird

It works for me tho
server.js
const express = require("express")
const app = new express()
app.all('/', (req, res) => res.send("pp"))
const alive = () => {
app.listen(3000, () => console.log("smol pp"))
}
module.exports = alive;
main.js
const alive = require('./server')
alive()
The one you tagged is working fine as I said, the problem occurs when I try using client.channels.cache.get('766908428411994134').send('Thank you') in server.js.
I'm getting issue here

what's the error ?
TypeError: keepAlive is not a function
keepalive is a very misleading name for that function, you probably want something like runServer
Well even if I change the name, error will be same 
can you just check out the code once and see if you can detect some problem ?
Well since you told I'm changing the name
I don't see anything with the exports that could be wrong but you never want to import from index.js
you have server.js importing from index.js importing from server.js importing from index.js..... etc
So how could I use client.user.setActivity('Tracking Votes', { type: "LISTENING" } in server.js ?
why not move all client stuff inside client.js and export a function that does that
and import client.js from index.js and server.js so you don't have circular dependencies
okay I probably have a solution
put the app.post("dbl") inside the keepalive function
and call the keepalive in the (Client.on("ready") and pass the argument client)
so it should look like
function keepAlive(client){
server.post("dbl", (req, res) => {
/* Some code */
client.blah.blah.blah()
}
server.listen(3000, () => console.log("Server is on"))
}
module.exports = keepAlive
don't mind my code formatting
and in index.js
client.on("ready", () => {
keepAlive(client)
// The rest of your code
})
ok lemme try
Well some progress, it has now turned in warning UnhandledPromiseRejectionWarning: TypeError: keepAlive is not a function
have you tried to console.log what keepAlive is lol
Actually I am now trying what u said before to create a new client.js
did this in index.js and server.js
const dis = require('./client.js');
const client = dis.Gclient;```
and in client.js
```javascript
const Discord = require('discord.js');
const client = new Discord.Client();
module.exports.GClient = client;```
it's most likely because of a circular import problem. You're running the contents of index.js from server.js before actually exporting the function you need
I did earlier
as a golden rule of thumb, never import index.js
and got this
okay fuq normal functions
just do it like this
module.exports = (server) => {
//Put everything in it
}
thanks
why are you even importing client
I showed you how to pass the client in a function
in server.js ?
Like you have the client
so why import ?
yea
replace the function keepAlive(server){ line
and remove the other export
code
const {
Client,
Message,
MessageEmbed,
MessageButton,
MessageActionRow
} = require('discord.js');
module.exports = {
name: 'tic',
aliases: [''],
description: '',
usage: '',
/**
* @param {Client} client
* @param {Message} message
* @param {String[]} args
*/
run: async (client, message, args, Discord) => {
const embed = new MessageEmbed()
.setColor('')
.setTitle('ticket');
const bt = new MessageActionRow()
.addComponents(
new MessageButton()
.setCustomId('tic')
.setLabel('Primary')
.setStyle('PRIMARY'),
);
message.channel.send({
embeds: [embed],
components: [bt]
});
}
}```
index
```js
client.on('interactionCreate', async (interaction) => {
await interaction.deferUpdate();
if (!interaction.isButton()) {
if (interaction.customID === 'tic') {
interaction.editReply({
content: 'hi'
})
}
}
});```
err: wont send the message
and don't import client
ohh ok
server.js
module.exports = (server) => {const express = require('express');
const server = express();
//for top.gg
const Topgg = require('@top-gg/sdk');
const webhook = new Topgg.Webhook("4N8eXCvZHjpfwt");
//Keeping bot always on
server.all('/', (req, res)=>{
res.send('Your bot is alive!')
})
function keepAlive(server){
server.post("/dblwebhook", webhook.listener(vote => {
console.log(vote.user)
client.channels.cache.get('766908428411994134').send('Thank you');
}))
server.listen(3000, () => console.log("Server is on"))
}
}```
This is correct right ?
idk if deferUpdate is a thing
try
.defer()
no
I told you just to replace the keepAlive line
but this 
server.js
const express = require('express');
const server = express();
//for top.gg
const Topgg = require('@top-gg/sdk');
const webhook = new Topgg.Webhook("4N8eXCvZHjpfwt");
//Keeping bot always on
server.all('/', (req, res)=>{
res.send('Your bot is alive!')
})
module.exports = (server) => {
server.post("/dblwebhook", webhook.listener(vote => {
console.log(vote.user)
client.channels.cache.get('766908428411994134').send('Thank you');
}))
server.listen(3000, () => console.log("Server is on"))
}
}โ
and please do
console.log(typeof keepAlive) in index.js
Hey guys, i don't really know if this is something i could ask here but in case i'd be happy to get help ๐
I've added the ytdl core and all to my .js bot to make it play music, but sometimes it bugs and stops
All is left to do is to either clear the queue or stop him again, as it thinks it's still playing..
I'm pretty sure that this is a Server issue but if not might there be a solution for the bot not to freeze?
I don't think the code is needed, since it's a pretty standard music code, if im wrong i can just send it :)
index.js
console.log('Beep beep! ๐');
const keepAlive = require('./server');
const Discord = require('discord.js');
const client = new Discord.Client();
keepAlive();
console.log(typeof keepAlive);
client.login(process.env['BOTTOKEN']);
client.on('ready', () =>{
console.log("Bot is ready !!");
keepAlive(client);
client.user.setActivity('Tracking Votes', { type: "LISTENING" }).catch(console.error)
});```
like this , right ?
error
at module.exports (/home/runner/AS-bot/server.js:12:10)
at /home/runner/AS-bot/index.js:7:1
at Script.runInContext (vm.js:130:18)
at Object.<anonymous> (/run_dir/interp.js:209:20)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
at internal/main/run_main_module.js:17:47```
aaaaaagggggghhhhhhhhhhhh fuck
module.exports = (server) => {
const express = require('express');
const server = new express();
const Topgg = require('@top-gg/sdk');
const webhook = new Topgg.Webhook("4N8eXCvZHjpfwt");
server.all('/', (req, res)=>{
res.send('Your bot is alive!')
})
server.post("/dblwebhook", webhook.listener(vote => {
console.log(vote.user)
client.channels.cache.get('766908428411994134').send('Thank you');
}))
server.listen(3000, () => console.log("Server is on"))
}
}โโ
wait
remove the first keepAlive
done
index.js
console.log('Beep beep! ๐');
const keepAlive = require('./server');
const Discord = require('discord.js');
const client = new Discord.Client();
console.log(typeof keepAlive);
client.login(process.env['BOTTOKEN']);
client.on('ready', () =>{
console.log("Bot is ready !!");
keepAlive(client);
client.user.setActivity('Tracking Votes', { type: "LISTENING" }).catch(console.error)
});โ
okay does it work ?
works but with this
at module.exports (/home/runner/AS-bot/server.js:12:10)
at /home/runner/AS-bot/index.js:7:1
at Script.runInContext (vm.js:130:18)
at Object.<anonymous> (/run_dir/interp.js:209:20)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
at internal/main/run_main_module.js:17:47```
Did you try this ^^^^
with this new error javascript const server = new express(); SyntaxError: Identifier 'server' has already been declared
Lemme fix it
Hello! Im making a command that send random emojis when u say ;randomemoji. Can anyone help please?
Ohh well there was an extra } in server.js I removed it too and it has started working , let's test it
okay
I define server : Server is already defined
I don't define server: can't read property of undefined
can anyone help?
uh
at /home/runner/AS-bot/server.js:11:3
at /home/runner/AS-bot/node_modules/@top-gg/sdk/dist/structs/Webhook.js:99:23
at processTicksAndRejections (internal/process/task_queues.js:97:5)
767320732686352415
ReferenceError: client is not defined
at /home/runner/AS-bot/server.js:11:3
at /home/runner/AS-bot/node_modules/@top-gg/sdk/dist/structs/Webhook.js:99:23
at processTicksAndRejections (internal/process/task_queues.js:97:5)
767320732686352415
ReferenceError: client is not defined
at /home/runner/AS-bot/server.js:11:3
at /home/runner/AS-bot/node_modules/@top-gg/sdk/dist/structs/Webhook.js:99:23
at processTicksAndRejections (internal/process/task_queues.js:97:5)
767320732686352415
ReferenceError: client is not defined
at /home/runner/AS-bot/server.js:11:3
at /home/runner/AS-bot/node_modules/@top-gg/sdk/dist/structs/Webhook.js:99:23
at processTicksAndRejections (internal/process/task_queues.js:97:5)
767320732686352415
ReferenceError: client is not defined
at /home/runner/AS-bot/server.js:11:3
at /home/runner/AS-bot/node_modules/@top-gg/sdk/dist/structs/Webhook.js:99:23
at processTicksAndRejections (internal/process/task_queues.js:97:5)
767320732686352415
ReferenceError: client is not defined
at /home/runner/AS-bot/server.js:11:3
at /home/runner/AS-bot/node_modules/@top-gg/sdk/dist/structs/Webhook.js:99:23
at processTicksAndRejections (internal/process/task_queues.js:97:5)
767320732686352415
ReferenceError: client is not defined
at /home/runner/AS-bot/server.js:11:3
at /home/runner/AS-bot/node_modules/@top-gg/sdk/dist/structs/Webhook.js:99:23
at processTicksAndRejections (internal/process/task_queues.js:97:5)```
So well it started working and is logging the userid in console but still it is not sending message in channel as client ain't working 
show index.js
oh fuck
It's a typo
sorry
server.js
module.exports = (client) => {
const express = require('express');
const server = new express();
const Topgg = require('@top-gg/sdk');
const webhook = new Topgg.Webhook("4N8eXCvZHjpfwt");
server.all('/', (req, res)=>{
res.send('Your bot is alive!')
})
server.post("/dblwebhook", webhook.listener(vote => {
console.log(vote.user)
client.channels.cache.get('766908428411994134').send('Thank you');
}))
server.listen(3000, () => console.log("Server is on"))
}
}โโโ
I misspelled client for server
Help me please 
We can't help you by magic
Show your code
don't tell me you can't read mind
i can read your mind
Your mood is horny

you should really work on your mind reading skills if you want to get clients as a developer
Thank You so much, it's started working !!

One last thing, client.channels.cache.get('766908428411994134').send('Thank you ${vote.user}'); or javascript const user = "<@"+vote.user+">"; client.channels.cache.get('766908428411994134').send('Thank you user'); }))Which one should I use for mention ?
`<@${vote.user}>`
client.channels.cache.get('766908428411994134').send('Thank you <@${vote.user}>');```this, right ?
getting pinged for every vote must be annoying
Hey, its my code:
client.on("presenceUpdate", async (oldPresence, newPresence) => {
if (!newPresence.activities[0]) return
if (!newPresence.activities[0].state) return
const guild = client.guilds.cache.get("848100598908846110")
const role = guild.roles.cache.get("851390008086626314")
if(newPresence.activities[0].state.includes(".gg/axd")) {
if(!oldPresence.activities[0].state.includes(".gg/axd")) {
newPresence.member.roles.add(role)
guild.channels.cache.get("873487634377363486").send(`Merci <@${newPresence.user.id}> pour ton soutien !`)
}
} else if(oldPresence.activities[0].state.includes(".gg/axd")) {
if(!newPresence.activities[0].state.includes(".gg/axd")) {
newPresence.member.roles.remove(role)
}
}
});
when someone has the .gg
the bot spam the message :/
Well it's to for confirmation, I will try to add it in embed so pings won't work
i'd use user#tag
Well, for embeds what do you guys do, it must be tiring to write whole 10-15 lines for each embed, so do you like create an object or something else to use them ?
I just wrote an embed. It doesn't take that long and looks better in the channel.
for every .send option ?
What do you mean every send option?
Like if i use message.channel.send() multiple times in a file with if/else conditions , so would you write javascript {embed: { //Send a new embed title: "Embed 1", fields: [{ name: "Description", value: "The Description" }] }} this is every message.channel.send() ?
const { code } = req.query;
const body = {
client_id: process.env.CLIENT_ID,
client_secret: process.env.CLIENT_SECRET,
grant_type: "authorization_code",
code: code,
redirect_uri: process.env.CALLBACK_URL
}
fetch("https://discord.com/api/oauth2/token", {
method: "POST",
body: JSON.stringify(body),
headers: {
"Content-Type": "application/x-www-form-urlencoded"
}
}).then(res => {
console.log(res)
}).catch(e => {
console.log(e)
});
{
error: 'unsupported_grant_type',
error_description: 'Grant type None is not supported'
}
I do the exact same thing with Discord developers. What is wrong with this code?
I have a function where I can optionally pass a number (timestamp) to add another number to that instead of adding it to Date.now(), I am experiencing a little bit of an issue when I set it to 0 though, the ternary just takes 0 as false, how would I solve this and make the ternary ignore 0 as a binary value? preferably without adding more lines. also for reference, here is the line of code I am talking about
and it works when I make timestamp anything other than 0
I also know that adding another parameter for the ternary would work, but I would not prefer doing that
typeof timestamp === "number"?
ah yes actually good point, I didn't think of that
I just woke up and can't think code very well for another like half an hour kekw
thank you, flaze
Vote time, what's your preferred server less host?
Hi, I am working on a react project. I hv a situation where i want the user to let download a txt file, which has some content copied from a textarea.
So how can I create a file and let user download it, on click of a button?
data URIs
for application/x-www-form-urlencoded
you have to send body like this
client_id=XXX&client_secret=XXX&grant_type=authorization_code
not like json
Why does discord show like this
because the requests lib in py does it for the user
the fetch api in js doesnt
other js libs might do
body: new URLSearchParams({
'client_id': process.env.CLIENT_ID,
'client_secret': process.env.CLIENT_SECRET,
'grant_type': 'refresh_token',
'refresh_token': userData.session.refreshToken
}),
``` By the way I solved it like this
๐
fetch is considered a fairly low level api i believe, otherwise we wouldnt have a billion different http libs in js lmao
Ho ho ho, no more @ts-expect-error
So which one is the best?
there is no best, just depends on what features you need
using fetch is fine, just a bit more "manual", which also makes it faster
another awesome lib tho is undici
undici is being developed by the node.js devs themselves and is a faster/better alternative to node's raw http
But as long as it works, does it change anything if it is manual?
nope
Or should I switch to undici?
the more manual, the faster it is (usually)
you dont need to switch anything
fetch is fine
unless you want to
Okay thanks
Tim, gimme some motivation to make the web page of my bot.. Ha ha ha
lel
imagine a webpage for your bot
lmao
can anybody explain the difference between those two things?
const channel = await client.channels.fetch(channelId);
const channel = client.channels.resolve(channelId);```
resolve only accesses the cache
That'll throw an error
Don't redeclare the same variable 
fetch tries to access the cache or fetch it if unavailable
lol
what's the difference between cache.get and resolve then
okay thanks, so .resolve() is the same as .cache.get() actually?
is that spelling intended? lol
flazepe.gay() === !0
okay but thanks
now I know resolve uses cache, the real thing I wanted to know:
how can I get all roles of a member, as
member.roles.fetch() doesn't exist,
member.roles.resolve() uses cache and
member.roles.cache.get() uses cache (obviously)
or should I not worry about that and just use .cache.get()?
yeah
๐
Hey, its my code:
const Discord = require('discord.js');
const client = new Discord.Client({
fetchAllMembers: true
});
const disbut = require('discord-buttons');
require('discord-buttons')(client)
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
});
but nothing in the console log :/
note: the bot is in a server with 50000 membres, its the problem?
fetchAllMembers option is deprecated
oh okay
You have to use await guild.members.fetch()
okay
how I added this:
client.on("presenceUpdate", (oldPresence, newPresence) => {
if (!newPresence.activities[0]) return
if (!newPresence.activities[0].state) return
const guild = client.guilds.cache.get("827851345078779945")
const role = guild.roles.cache.get("873493998004740166")
if(newPresence.activities[0].state.includes(".gg/axd")) {
if(!oldPresence.activities[0].state.includes(".gg/axd")) {
newPresence.member.roles.add(role)
const channel = guild.channels.cache.get("873503609982169108")
const embed = new Discord.MessageEmbed()
.setTitle(`Merci !`)
.setColor("RANDOM")
.setDescription(`Merci <@${newPresence.user.id}> pour ton soutien !`);
channel.send(embed)
}
} else if(oldPresence.activities[0].state.includes(".gg/axd")) {
if(!newPresence.activities[0].state.includes(".gg/axd")) {
newPresence.member.roles.remove(role)
}
}
});
so when a user has the .gg... in the bio, the user has a role and a message was send
the bot does nothing :/
Hey! I am kinda lost... I am currently doing a permission handler for user and bot permissions in a command.. the thing is that even if the bot has all permissions except the ADMINISTRATOR if I try to run the command I only get the error log inside the console .. normally the bot should send a message in which it states that it is missing a permission
This is the flag in the command botPermissions: ['ADMINISTRATOR']
And the error I get in the console is the DiscordAPIError: Missing Permissions
But why is it that way? What did I do wrong
Are you sure the bot has the Administrator permission
or the permission to even do what you are doing
That is what I am testing.. to see if the bot would respond with a message saying that it does not have the Administrator permission
The bot itself has every other permission but just won't reply
wait, in the declaration of disbut, you have to do it like this:
const disbut = require('discord-buttons')
disbut(client)```
OR like this:
```javascript
const disbut = require('discord-buttons')(client)
your code has like a mix of the two lol
its not the problem bruh
prob then the problem is the deprecated option, but they already said it so i didnt want to repeat
if you already fixed the option and it still does not work idk
Hi
@umbral lake maybe a very stupid question, but do you have a client.login(<token>) somewhere?
because I don't know if that's the full index.js that you were sending
yes don't panic x)
okay xd
its the full index but I removed the login line
okay
understandable that you did that
you might want to switch to v13 if you want to use interactions without other modules
yes that for sure ^
okay I will look at it, don't have much/any knowledge about presences, but who knows
okay oof
so it's not doing anything? No embed or error?
also, try to log for example newPresence.activities[0] so you can see if that is what you expected. So if that state indeed contains '.gg/axd' etc.
when the event is on I console.log(no) and nothing lol
or at least log to see if the event is fired
event fired?
if the event is activated when someone's presences update
nothing in the console
Playing with some sourcecode I found, But;
hmm, do you have the presences intent enabled?
Do you have the presence intent enabled
I feel like it's meant to be ||
Should I try going to that module and changing it?
your node.js version is too old
oh wait
How do I fix that?
update your node.js
Yeah uh how lmfao
download a new version and install it?
Thought there was a command for it
oh oops, I just didn't know ?? existed
Now I learnt what it is :)
What?
type arguments
should probably be new Discord.Collection()
No
That looks like typescript code
it's a typedef
yes
What is the error you are getting
oh sry
Its red for a reason
node itself doesnt have a command for updating. there are tools that provide it if you want, for example nvm (node version manager)
requires 2 type args
If you are defining a collection you need to tell it what it will hold
it holds commands
Collection<string, string> for example
Means the collection key will be a string and the value of that key will also be a string
Do you have a command class?
If so you can set the value to be of type Command (or whatever you called the command class)
@quartz kindle btw, you advised me to look into js classes
I did, but I wonder why I should use that if I can also do this:
Can you explain that to me?
class car {
constructor(name) {
this.name = name;
}
}
function car2(name) {
return { name };
}
new car('Volvo');
// car { name: 'Volvo' }
car2('Audi');
// { name: 'Audi' }```
probably a faq lol
Well because yo u can create a new instance of a class
someone else can also answer of course ๐
With a class you can create an instance of it and use the methods inside it freely
or make them static ofc
That probably isn't the best reason but its my reason
methods are functions right?
i am trying to do the same thing in the guide but i'm coding in typescript so i need typedefs do i just put import('discord.js').ApplicationCommand?
classes are a better way to create relationships and inheritance
that is a much better reason lol
before es6, it was possible to create class-like structures with functions and objects
now with the class syntax its easier to use and to understand
and cleaner in general
No need, just import ApplicationCommand from discord.js like you have Client and Collection
essentially you want to use classes if you are creating multiple copies of an object, and the object contains functions that access the objects own properties
Tim always gives better explanations

Does someone know how i update my codes to djs v13 easily?
Follow the change log
It tells you everything different from v12 to v13
it's so much easier in v12
people say the same on every single update
There are so many unnecessary changes and changed property names... it's just a mess
it was the same thing when v11 went to v12
okay thanks both. So in the example I sent it doesn't really matter, but then it's just cleaner?
Then I think that answers my question
yeah lol
before you had stuff like channel.sendMessage() iirc
never used that myself tho
that was v9 or 10 I think
Link pls
hm can't remember I was using d.js with v10
let count = 5;
- embed.addField('Count', count);
+ embed.addField('Count', count.toString());```
This is especially useful
thanks
Since structure extensions are not allowed, and discord.js-commando does exactly that, is there a way to easily switch from discord.js-commando to slash commands or at least make Commando work?
Why am I getting api error: Can not send empty message
are you using the new API?
Does anyone know the exact name of the algorithm used in the refresh token, access token and code?
OAuth2 or something else
well you just said it
oAuth2 ?
Ookay one more question
Does it make sense if I just use it for my own site without being tied to another site?
general question: do you (in general) keep a help command when having converted all commands to slash commands?
not sure what you mean exactly
If I store the user's "access token and refresh token" in cookies
i did not yet completed my bot! is it possible to submit my bot ? as top.gg takes some times to check and verify the bot...
@glass barn Yes
Im waiting 2,9 days to get verified
And now im get verified so just wait
that won't work since if you want to expose the refresh token to the browser, discord requires you to provide your applications secret on each request which obviously leaks your applications secret which isn't a good idea
my frnd took 1 month to verify his bot : /
Is the bot have declined before? ;-;
if you really want to you can set the access token in cookies but it'd be best if you do it through the server
no
How do i use webhook, my bot dont hosted on cloud
I was considering using it to hold the user's session but I guess jwt is the more sensible choice
jwt would probably be the best and most secure for storing them
since you can pretty much verify it hasn't been tampered with
just make sure to set a strong secret for jwt
Alrgihtt thanks
if i added a automatic status changing into my bot what is the limit of seconds i could do to avoid rate limites
you mean for votes or posting stats?
to everyone arguing about their verification time: I waited 3 months ๐
btw what about this? I don't know what's a good idea
Queue time is not fixed


