#development
1 messages · Page 186 of 1
but I was wanting to also have my bot automatically respond in certain moments
like, how can i have my bot send a message when a new member joins the server
i was reading that
and i tried to add it based on what i was reading but i guess i was doing it incorrectly
again, i’m very new so sorry if im asking for too much
if you are using discord.js they help you by attaching all these events to the client class.
so say you have this setup:
const client = new Client();
client.on("guildMemberAdd", (member) => {
// do something when the member joins
});
client.login("bot token");
this is a simple way to do it
You can listen for any events by using on method on the client
Note, some events do require priveledged intents to use them fully
Ah, so basically they just tell discord what data or events you are wanting to receive from them.
ohh ok. when i was setting up the application in the portal, there were some “intent” options on there, I just skipped it until i learned what they did
think of intents like choices in a menu at a restaurant
It used to be you never had to tell discord what intents you wanted to give them, by default they just gave you everything. But ofc that was not correct so now they have you specify it.
you place your order (set intents)
waiters bring that food (discord delivers events)
ok i’m following
god i love this analogy
if you didn't order it you don't get it
okay i gotcha
Yea so those are the priveledged intents you have to enable. Now with those intents it doesn't mean you won't recieve those events if you don't have it enabled. You just wont receive certain data from discord.
Those are the "higher costing items" to use brain's anology
so i should go back into the portable and enable them?
oh
For reference - I’m making a custom bot for just my server only
for now at least
Thats fine :D
so to set an intent to do something like sending a message to my mod channel when a new member joins, how would i set that intent?
Well, first off you'd need to set the GuildMembers intent. This allows you to receive the appropriate events.
and i’d have to modify discord.js to do that?
yes, u also need to set the intents for ur client while connecting
that can be done with
const {Client, IntentsBitField} = require("discord.js")
const { GuildMembers } = IntentsBitField.Flags;
const client = new Client({
intents: [GuildMembers]
})
client.login("bot token")
it's a bit weird for privileged intents but the toggles on the portal are for allowing your bot to use the privileged intents
Also you will need to enable this in the bot portal:
As the GuildMembers intent is a privileged one.
ok let me do this now
Also if you are wondering what const {Client, IntentsBitField} = require("discord.js") this part does. I am just doing a thing called "destructuring" which essentially just pulls the stuff I want from the package. This works because discord.js exports those for us
Almost everything can be destructured in js (iirc)
ok gotcha
someone back me up on this I haven't used js in ages
done :✅
is there anywhere specific i need to put this?
well, if you haven't split your code into multiple files then in your main file
oh lord
I assume you haven't since you started 2 days ago
creating modules will be a challenge for someone who just started 
oh no thats node_modules those are the packages you install aha
yea so what does your file structure look like I wonder
for the commands?
for your project
oh cool you do seperate your commands into other files
good
organization is key to keep a sane mind
oh yes i need them all separated lol
anyway, you'd likely do all your events in the index.js for now until you can separate those as well
just modify your client to take in the GuildMembers intent
and then client.on("guildMemberAdd") or whatever event you want to use
a useful tool to learn discord.js is the docs as well
that’s what i’ve been sorta studying to learn all of this 🎉
essentially all events will work the same
client.on("eventName", (args) => {})
replace eventName with the name you want to listen to
and args with the properties the event gives
if it gives multiple do client.on("eventName", (arg1, arg2, arg3) => {})
@sharp geyser You're about to hate me
Whats up
so this is what I am adding?
okay so essentially yes, you just modify your current client tho
also you don't HAVE to do it how I do
its just how i'd recommend
you mean highlighted?
yes
like you did here
mine shows as plain text lol
you need to include the highlight symbol js in this case
js
const { GUILD_MEMBERS } = Intents.FLAGS;
const client = new Client({
intents: [GUILD_MEMBERS]
});
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
});
client.on('guildMemberAdd', member => {
// This is the channel ID where you want to send the welcome message
const channelId = 'your_channel_id_here';
const channel = member.guild.channels.cache.get(channelId);
if (!channel) return; // Channel not found, do nothing
channel.send(`Welcome to the server, ${member.user}!`);
});
client.login("bot token");
its important to use 3 open ticks and 3 closing ticks
const { Client, Intents } = require("discord.js");
const { GUILD_MEMBERS } = Intents.FLAGS;
const client = new Client({
intents: [GUILD_MEMBERS]
});
client.on('ready', () => {
console.log(Logged in as ${client.user.tag}!);
});
client.on('guildMemberAdd', member => {
// This is the channel ID where you want to send the welcome message
const channelId = 'your_channel_id_here';
const channel = member.guild.channels.cache.get(channelId);
if (!channel) return; // Channel not found, do nothing
channel.send(Welcome to the server, ${member.user}!);
});
client.login("bot token");
Oh i see ok
yea
also if you want it highlighted
directly after the 3 first ticks, include the highlighting symbol
which in this case would be js
ok gotcha
sorta cheated here... but if I put in the channel ID and the welcome message.. would this work?
ok so im adding this to index.js
I have a question, i wanna start sharding really soon but how will i be able to manage an express app linked to my bot? How will i fetch specific data from a specific guild?
Pretty sure you just broadcast to the shards idk if this is still a thing
Do u have any good guides to start sharding?
Wanna start sharding soon
Does your bot need it?
Yes, currently at around 500 & growing rapidly
Better start early
And my functions are resourse intensive
So yes i need it
shards usually have a master process that controls them
ie:
shard manager
v
-> shard1
-> shard2
-> shard3
-> shard4
the shard manager can communicate with the shards, and individual shards can communicate with the manager
shards can also communicate with other shards through the manager, also known as broadcasting
you can run webapps on the manager process
requests to the webapp can be broadcast to shards from the manager
ie:
webapp receives request for a specific guild > manager requests data from shard > shard returns guild data > webapp responds with guild data
One message removed from a suspended account.
what is the highlight symbol?
the programming language (for instance js or javascript, both work)
ok gotcha
Thanks alot for the clear info, was really helpful!
once again saving the day 
@sharp geyser
you taught me so much about event thank you!
so I have something I want to try and I think i know what to do based on what i’ve been reading and based on what you helped me with
if i wanted the bot to auto respond to lets say
emoji
like whenever someone uses it, the bot auto responds with a joke of some sort
i would enable the “message content” intent?
yep precisely
ok gotcha
how does this look
client.on('message', message => {
// Check if the message contains the specified emoji
if (message.content.includes(':cryingmo:')) {
// Respond with a random joke about being sad
const jokes = [
"Why did the scarecrow win an award? Because he was outstanding in his field!",
"Why don't scientists trust atoms? Because they make up everything!",
"Why couldn't the bicycle stand up by itself? It was two-tired!",
// Add more jokes here
];
const randomJoke = jokes[Math.floor(Math.random() * jokes.length)];
message.channel.send(randomJoke);
}
});```

I honestly dont remember if you can handle emotes like that
so its best to test it out and see
if it doesn't work come back
Also messageCreate instead of message in client.on
This was changed in v13 if I remember correctly
^^
real question is what version are they using 
14
omg i need this emoji
nynu is a discord bot coding god in my eyes
one of the most patient persons i’ve ever communicated with in my life
i love this
i probably have to input the actual emoji ID, that’s what i had me do with a / command I’ve done
ok i’ll do this

success 🙌🏾🙌🏾🙌🏾
thank you @sharp geyser @deft wolf
this is literally a picture of me crying by the way
Congratulations 
ok another question
is there a way for me to code my ban command to ban a user by ID that is not in the server?
i have a bot that i use to do that but I want to be able to learn how to do that with my custom bot
this is my ban command code
const { Permissions, TextChannel } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('ban')
.setDescription('Bans a user')
.addStringOption(option => option.setName('user').setDescription('The user to ban (mention or ID)').setRequired(true))
.addStringOption(option => option.setName('reason').setDescription('Reason for the ban').setRequired(true))
.toJSON(),
async execute(interaction) {
// Check if the user has the necessary permissions to ban members
if (!interaction.member.permissions.has(Permissions.FLAGS.BAN_MEMBERS)) {
return interaction.reply({ content: "You don't have permission to ban members.", ephemeral: true });
}
// Get the user from the command options
const userOption = interaction.options.getString('user');
const user = interaction.guild.members.cache.find(member => member.user.id === userOption || member.toString() === userOption);
// Check if a valid user was found
if (!user) {
return interaction.reply({ content: "Please specify a valid user to ban.", ephemeral: true });
}
// Get the ban reason
const reason = interaction.options.getString('reason');
// Attempt to ban the user
try {
await interaction.guild.members.ban(user, { reason });
// Prepare information to post in the specified channel
const channel = interaction.client.channels.cache.get('1179382116077809714');
if (channel instanceof TextChannel) {
await channel.send(`Banned User Information:\n- Discord Name: ${user.user.tag}\n- Discord User ID: ${user.user.id}\n- Reason for Ban: ${reason}`);
} else {
console.error("Failed to send ban information. Channel is not a TextChannel.");
}
return interaction.reply({ content: `${user.user.tag} has been banned.`, ephemeral: true });
} catch (error) {
console.error(error);
return interaction.reply({ content: 'There was an error while banning the user.', ephemeral: true });
}
}
}```
I think the only option to ban a user by id (considering that you have never seen this user) is to use guild.bans.create(userId)
I've never used it personally, but it's probably what you're looking for
This relies on the user being in cache
Which means that if they have not shared a server with the bot, then they can't be banned
Best thing you can do is ban them when they join
Which just requires you to have their id and just put that in an array of blacklisted ids that get queried when a person joins. if their id matches any in the array automatically ban them
All these moderation bots must have a very difficult time working because of this cache, and people continue to create more moderation bots 
Ah ok I gotcha
Just want to ask regarding it is worth it to switch from discordpy to discordjs?
I feel that my bot have a bit slight slow response compare to other bot...
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
It might be helpful to do some basic performance checking to determine if it's actual bot performance issues or just a latency issue.
One message removed from a suspended account.
One message removed from a suspended account.
does it?
According to the source code yea
when you call .create it checks for the ID in the users cache, if it doesn't exist it throws an error
actually wait
I might of misread this when tired
yea no it seems to rely on the cache
I need to try this
but it does make calls to the cache manager
which I can only assume will check the cache for the user
Following the rabbit hole
this.client.users.resolveId
Now lets assume the user does indeed not share any server with the bot, none of those checks will even remotely check out
so it will call super.resolveId

now UserManager extends CachedManager which extends DataManager which finally has this resolveId method
this is weird, if you have an id you don't need cache
that's how discord API works
now as NyNu seems to point out it does still work
which leads me to believe its not actually relying on cache, but for some reason the methods they have to check its a valid id or whatever exists on the CacheManager or whatever CacheManager extends which is whatever that extends
😔
Typical discord.js moment 
Djs code base is basically 1 class extends another, which that class then extends another and that class also extends another
By the end of it 1 class has 4 extensions
not even kidding you
GuildBanManager extends CachedManager extends DataManager extends BaseManager
BaseManager is literally just a class that defines client
💀
discordjs just has a messy code base
im surprised anyone can commit to it
discord.js moment
it's just way too overengineered lmao
Don't forget how half the features get deprecated from one version to the next
this is the JavaScript way! change it every month to keep people re learning
I agree
I wish there was a better alternative for js developers
but djs is just too deeprooted

what does the implementation language have to do with it
Now I dont mean to self advertise - but using libs that interact with the raw api like SnowTransfer and CloudStorm are literally amazing
they have better libs
Im starting to pick up go myself tho I still dk if I want to use go or rust for my api

dk yet
discordgo ig
disgo seems more up to date
steer away from managed libraries
it's also the only one using API 10
idk I feel like go's reliablity when it comes to building an api is better, but rust is also so nice in its own way

I will think about programming language later tho
discord is one of those weird things where it's very much a thing to choose your language based on the quality and maintained state of its discord libs
only that could explain why so many dpp users these days lol
If you interact with the raw api, not really
the vertically integrated libs all mostly suck
if you must interact with raw API the lib is missing features
One of the main reasons I stick with node and really can get great cpu and memory stats is because of proactively removing bloat
and if it's easier to interact with raw API than use the lib the features are badly made (d.js)
such as? I can't see anything where you'd HAVE to have a library
do you enjoy reinventing wheels then?
You're yet to give me an example
if you're doing raw API calls how do you deal with rate limits
I see no problem with wanting to interact with the api in your own way.
That is included in the lib I mentioned and maintain lol. Just raw dogging fetch isnt the way
Technically every lib is just reinventing the wheel in their own language
Implementing rate limiting is trivial though so that's such a weird example
in C++ all other wheels were broken or square
not as trivial as you think, because you got IP based cloudflare rate limits on top of discord, and then webhooks use two different types of rate limit depending on if they have a bot token or not
It is quite trivial to me
Though I guess it depends on your architecture sure
what the fuck my phone tries to play .TS as a video
There are ts videos
how do shards work in this lib
This is just a rest client
yea
You can daisy chain proxy
or spread the proxy if you have a special way to get bucket info
just wondering how different shards share global rate limit info
if you had cloudstorm doing sharding
cloud uses snow for get /gateway/bot so you can pass a modified snow instance that has refs to the proxy
both go and rust are good for APIs
indeed
its just which is more appropriate for my use case 
what's your use case?
hm well, i'd rather not get into that here as its personal but I can dm you about it
sure
20|Koopapi | Error: listen EADDRINUSE: address already in use :::4434
20|Koopapi | at Server.setupListenHandle [as _listen2] (node:net:1751:16)
20|Koopapi | at listenInCluster (node:net:1799:12)
20|Koopapi | at Server.listen (node:net:1887:7)
20|Koopapi | at Object.<anonymous> (/root/site/koop.js:640:13)
20|Koopapi | at Module._compile (node:internal/modules/cjs/loader:1256:14)
20|Koopapi | at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
20|Koopapi | at Module.load (node:internal/modules/cjs/loader:1119:32)
20|Koopapi | at Module._load (node:internal/modules/cjs/loader:960:12)
20|Koopapi | at Object.<anonymous> (/usr/lib/node_modules/pm2/lib/ProcessContainerFork.js:33:23)
20|Koopapi | at Module._compile (node:internal/modules/cjs/loader:1256:14) {
20|Koopapi | code: 'EADDRINUSE',
20|Koopapi | errno: -98,
20|Koopapi | syscall: 'listen',
20|Koopapi | address: '::',
20|Koopapi | port: 4434
20|Koopapi | }```
i already tried finding the process and using kill pid
but port is still in use..?
how can i fix that
by waiting
when you close a port of you don't close it properly e.g. you kill the process the port changes to FIN_WAIT state and can stay open in that state for ages, like minutes
it's to stop a new process immediately sniping the port, it's a security feature
it's basically because TCP expects a proper close() to be a 2 way thing like connecting
i see
thank you!
Each day a new day to learn ig!
are you sure it won't take hours/days of waiting?
cuz then i'll just switch to an alternative https port
no 6 mins 45 secs apparently
or a reboot
if it takes longer you got a process still open somewhere
yeah i used the lsof with root access and it showed no open processes though
so ig we just wait 🙂
also another question
root@awsomecordServices:~/site# sudo netstat -tuln | grep 4434
root@awsomecordServices:~/site#
though it still says port already used...
root@awsomecordServices:~/site# ps aux | grep Z
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1030251 0.0 0.0 8900 732 pts/1 S+ 13:10 0:00 grep --color=auto Z
aha
it became a zombie process
what the fuck can i do
wait a minute… did you do this with my ban js code that i posted here?
No, I used my eval just to check how this function works
ohh ok gotcha
is anyone here and have some time to help me out with something 👀
it's better to just ask so that anybody could just answer if they saw
true
I’m just trying to move my project over from my macbook pro to my windows pc desktop
writing a discord bot with discord.js slashcommandbuilder in virtual studio code
i uploaded the entire project folder onto google drive and downloaded it to the desktop on my pc
installed node
yeah no you can't do that
is there any reason u don't use git?
just copy all of the files without node_modules
Then run npm i in the command line
and yeah ideally you should use git but if this is just a fun project then it's probably not fully necessary
so if i download the files to my pc desktop, can i just delete the node modules
& im creating a custom bot for just my server
yes, then when you run npm i, it'll install the proper node modules you need
ok i got you
and i’d have to re-create the .env file? cause i don’t see where it copied that file
I mean if you used an env file and didn't copy it over then yeah
ok i’ll try this really quickly
it was suggested that I use google drive since my discord token was in the .env
it appeared after i deleted the node modules
ok got it going!
thank the lord
You can load env files into node using dotenv
and you just transfer your env file to whatever server you want
gdrive isnt a good place since people have found ways to bypass google 2fa last I heard
And plus having a secure server you login with private public key pairs means hackers can get on unless they have your private key which means physical machine or they take the files off your machine and know where the keys go to.
Does anybody have any feedback if this would be consdereed a privacy concern?
specifically the guild name part of course
For those who can't be bothered to read (dont blame you)
- card collecting game, when somebody claims a card that is of the super duper rare rarity, it announces it in our "hub" discord.
is it a privacy concern to say "@user claimed a cursed card >> in guild_name << ??
Yeah do not post guild names in other guilds unless its for your eyes only
Just say that a user claimed it
what you do with all zombies
sudo kill -9 1030251
anyone have experience with SQlite?
alias fucking="sudo"
fucking kill -9 1030251
what should I do to get the bot to recognize button interactions?
is that considered an event that needs to be added to the index.js? or is that something in the actual code that i need to add?
Buttons are a collector. And you do a .on('collect') event and check the condition when clicked on.

@green kestrel i have finally finished the tcp parser
listen i was struggling
like fr
using this protocol i could make it happen
i used this Go Back N, i basically setup a connection in the form of a window and kepy sending packets until the queue was full. I then labeled each sent packet, and waited until i received an acknowledgement. iF IT WAS duplicate, it means it wasn't received properly and i resent all the packets. Hardest part was figuring out how to delete all received packets if a duplicate was found at the receiving end (as the will receive all packets again anyways, hence i had to try to be efficient).
I thought first, maybe i can just resend the 1 failed packet. But if one packet errored we have no guarantee that the rest of the packets will be sent properly, nor will the output be sorted. I could maybe have sorted it receivingend
I’m very new to this, like I started this project maybe 3 days ago so I’m learning all of the terminology!
thank you!
🤓
all i am saying
J’ai votre adresse
Envoi d’une bombe à l’endroit où vous vous trouvez
ok just want to make sure i’m understanding correctly
who is the owner of this server
@pliant gorge
they r definitely in a basement
ok
?
is this supposed to be some type of insult?
she said they would bomb me or sum
random
i saw that
hey guys, what price is an ecommerce website usually?
7 maybe 8
high enough if its fully fledged and fully custom
it has payments using stripe, good assortiment with products, emailing system.
what would be the minimum for such sites.
would the range be 700$>?
I offer a bread slice
can I bid plss
-m @earnest phoenix idk what you're doing here, but you're speedrunning a ban here. Gonna slow you down for a bit | 3h
happybaka#0 was successfully muted
bro just trolling
she's in that life phase where she tryna be funny for validation
really thought they were doing msth
thank god you muted
wow this is such a smooth way to mute someone. your point AND the command all in one post. beautiful
@wheat mesa Low Level Learning's video on switch statements is so confusing 
ok so if i’m understanding correctly
i need to add an event listener to my index.js for button interactions
create the buttons in the /command.js code
send the buttons in a message
and add handle button interaction in the event listener that i put in my index.js file?
yep
though djs has a way to do that in your code as well if you wanted.
You don't necessarily need to do an event listener for it
will that be easier?
yes
@cyan lake for reference, I’m trying to get this tic tac toe game to work
If you do it in your command code you can handle the data you need in the code itself.
you can also disconnect the handler anytime you want
let me find the docs for it
I haven't done this in a while
okay
yea so it seems you can use InteractionCollector
Collects interactions. Will automatically stop if the message (messageDelete or messageDeleteBulk), channel (channelDelete), or guild (guildDelete) is deleted. Interaction collectors that do not specify time or idle may be prone to always running. Ensure your interaction collectors end via either of these options or manual cancellation.
lord
essentially its just
const { InteractionCollector, Client, ComponentType } = require('discord.js')
const client = new Client({intents:["WhateverIntents"]})
const collector = new InteractionCollector(client, {
componentType: ComponentType.Button,
interactionResponse: the interaction
})
collector.collect((interaction) => {
// do something with the button
})
at least I think, based off the docs
actually wait
there might be an easier way
This is one method, it just gives you more control over the collector
https://discordjs.guide/message-components/interactions.html here is an easier method
It allows you to do it based off the interaction response without the need of using InteractionCollector, unless you need find control over where to use the collector in case you need to do so in a specific guild, channel or on a specific message
would you mind taking a look at the code? 👀
i might be able to see what you mean better in real time
no offense if you say no lol i know that’s a lot to ask
I can take a look if you post it here
idk about the validity of the functions, but that seems correct in handling button interactions
ah
that is suppose to display in the embed whose turn it currently is and only let that player play the turn
yes but the thing is
currentPlayer is simply nothing
it isn't defined
at least not in this code, and you don't import anything about it either
ok idk how to fix it lol
well you just define the person's whos move it is
typical rules of tic tac toe is X goes first
whoever is X set them to be the current player. then when they make their move set the currentPlayer to be the other person.
ok so it looks like it functioning the way it’s supposed to, it’s just giving the “interaction failed” message.. but the buttons are working fine, it’s switching turns, everything is working.. just giving interaction failed with each button tap
its because you didnt reply to the interaction
discord requires a response within 3 seconds
you could send an ephemeral message saying that their move was recorded
for reference this is what a ephemeral response looks like
better check that garage door 
but yea what sam said
each button is also considered an interaction. So you have to do something when its actioned
You can either defer the reply and edit it later, or respond to it immediately
Also one thing i'd do is send an ephemeral message to the other player when its their turn
that way you are doing something and notifying them
ahhhh ok got it
😂😂 i did too while i was recording that
good idea
ok this taught me a lot
@sterile lantern thank you so much as well
np
I recommend you watch some tutorials on discord js as they definitely helped me understand how it works a lot better
It’s nice to have someone explain it to you step by step haha
it is lol
i didn’t even think of this!!
whatis wrong with topgg?
people are not able to vote for the bot
its been like this like amost everyday
@warm surge
I’m following this but my question Is why is there so many frequent issues
We know exactly as much as you... which is nothing. We have to wait and that's it
So I am having issues with my db
Error
MongooseError: Operation `autodeletes.findOne()` buffering timed out after 10000ms at Timeout.<anonymous> (C:\Users\alban\documents\github\autodelete-v14\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:186:23) at listOnTimeout (node:internal/timers:573:17) at process.processTimers (node:internal/timers:514:7)
What I've done after research :
- Restart my vps 🤡
- Give access to my IP separately than just have the 0.0.0.0
- Try to connect via compass and check if there is any issues (no issues)
- Try to find different ways to connect but nothing seemed to do anything.
Right now, I am using mongoose on node.js , I havent touched the code for a while and this cam up yesterday, as a result my app will not work.
that is very weird
im not sure what buffering means in this context
mongodb terminology
you can do findone queries normally in other places though?
@thorny cargo sounds like you just need to do an await on your model connection or something of that sort
async connect() {
if (mongoose.connection.readyState === 0) {
try {
console.log(`${ChalkAdvanced.blue('Database: ')} ${ChalkAdvanced.gray('>')} ${ChalkAdvanced.yellow('connecting...')}`);
await mongoose.connect(mongoUrl)
if (mongoose.connection.readyState === 1){
console.log(`${ChalkAdvanced.blue('Database: ')} ${ChalkAdvanced.gray('>')} ${ChalkAdvanced.green('Successfully connected')}`);
} else {
console.log(`STATE OF THE DB HEREEEEEEEEEEEE : ${mongoose.connection.readyState}`)
}
} catch (err) {
console.error(err);
}
} else {
console.log('Already connected to database.');
}
}```
so the connection is successful in the end, thats why it gets me confused , even tho it connects, it doesnt work, and it throws me those errors
guys what intents must be given to a chat bot??
privileged intents? message content
The ones your bot will need
although if u use slash commands u don't need that
whos managing the top.gg python library
can we exclude discord.py from pip because theres many other good libraries out there and discord.py isnt the one always being sued
But what should we help you with? This is an error that usually means that your bot took more than 3 seconds to respond to the interaction
Either your bot is terribly optimized or it performs a database query or some other action that takes more than 3 seconds
how to fix it could u please take a look on my code and say what is the problem ,it it means alot to me if u did that code link: https://sourceb.in/PJWZBSBlmb
You use fetch in your command which pretty much means directly querying the api (if guild and channel are not in the cache). The best solution would be to use .deferReply() first and then .editReply() instead of .reply()
Also your interaction handler violates discord's developer guidelines. Your bot cannot create an invitation to the user's server without the user's knowledge. This is considered a privacy breach
^ we deny bots for doing that if we find them during testing and ban if we find it after the bot has been approved unless mentioned in the privacy policy
I strongly recomend not doing that
i am sorry but it will be only in admin dev bot channel not a puplic channel
even still it's considered privacy invasion to generate an invite to a discord server without prior consent (such as a privacy policy)
got it! ty
ok question
let’s say i have my tic tac toe game set up to send an ephemeral after each turn - to have a response to the interaction button. instead of sending a new ephemeral everytime, i want it to just edit whose turn it is in the ephemeral.. would that edit be considered a response to the button interaction of the game?
this is what the game looks like for reference
you'd have to save the message/message id of the first ephemeral response and edit that instead on later turns
assuming they don't dismiss that one ephemeral response though
you could probably have a regular msg (non-ephemeral) that edits each time
but im not quite sure if that counts as a 'response' to an interaction
you dont have to send a reply
you can defer button update
which would prevent the need to send an empheral response every time
yeah but after 15 minutes it'd show 'this application did not respond'
nope
really?
yes
for discord.js, its js await <ButtonInteraction>.deferUpdate()
then you can edit yeah

https://youtu.be/WshG9kE_mrI
What do you think of this ticketing system? I'm still developing it
Do I understand correctly that your bot creates a channel only to set up a ticket system there?
And then deletes it?
is it better to await deferUpates? I use them a bit in my current project but I dont await them.
await just means it waits for that action to finish first
in some conditions it can cause a broken race condition
for example, ```js
interaction.deferUpdate()
// maybe edit msg or smth
message.edit(/something/)
interaction.edit(/something/)```
it can cause errors saing interaction already deferred etc
In my cases my deferUpdates are used mainly to do a function without directly replying to the user back but also letting them know the button press worked.
I assumed so. Thanks for the insite.
i just await stuff by default at this point lmfao
lol same
yes
hm. i’ll have to try this
Ok so I’ve decided to dedicate myself to creating a bingo game… I started today with simple creating button interactions for people to join the lobby and for the host the start the game and cancel the game
how can we report a bot doing this? i invited a bot from top.gg and uh as soon as it joined the server it generated a invite. 💀 idk what its doing with the invite im assuming its feeding it to the developer of the bot
Yeah absolutely report it
this is what it does
this is the code, if anyone has a moment to look over it and tell me what I’m doing wrong 😭 that cancel message is supposed to be an ephemeral
Isn't that a bit over complicated? The same thing could be done on the same channel. There is nothing wrong with it, but personally I prefer to do everything on one channel instead of switching, especially since sometimes the bot may fail when creating a channel
you cant send ephemeral messages
they must be part of a interaction reply
you should do i.reply
instead of interaction.channel.send
i dont think you can show an ephemeral message to everyone in the game, only to the person who interacted with the button
this is correct
although discord should support ephemeral msgs outside of interactions cuz they r cool
idk why they dont
🤷♂️
ooohhhhhh
in terms of your game (bingo), you could probably just edit the embed
stating that the person ended the game
you could also disable the buttons which shows that it was canceled
basically updating the message with new components, where the buttons are set as disabled
what does i.reply do?
Create Interaction Response
where would the response go?
ohhhhhhhh ok i see
and everyone who interacted with that button will get that reply
that’s what i was trying to get it to do
i thought setting it up with ephemeral true would do that lol
ok learning moment
ok so ephemeral for the interaction response to the host, i.reply for response to everyone?
ephemeral is an option you choose for i.reply
i.reply is a response to the interaction
ohhhhhhhhh
whereas interaction.channel.send is a regular message sent by the bot in that channel
youre still not replying to the interaction for the cancel button
yeah i just realized
await i.reply({ content: 'You have canceled the game.', ephemeral: true });
something like that
what's not working?
i’ll screen record, 1 sec
i would probably edit the message at once:
// Disable only the cancel button
cancelButton.setDisabled(true);
row.components = [joinButton, startButton, cancelButton];
embed.setDescription("The game has been canceled. Sorry!");
await message.edit({ embeds: [embed], components: [row] });
just for the sake of efficiency lol
ok lol
oh wait it’s working
but i just tried it with about 10 ppl in the lobby and the cancel button failed again 😭
any errors in your logs?
let me try again, i just made this modification to it
oh it works!!!!
ok now i need to add a button to give people the option to leave the game before it starts if they want to
@oak cliff you were the only open source contributor online, you can ping someone else who might be more relevant. The python sdk has malware on it I believe. This commit was covered by 19 other junk commits: https://github.com/top-gg/python-sdk/commit/ecb87731286d72c8b8172db9671f74bd42c6c534
The base58 package has something to do with crypto currency and the DateTime package has something to do with APIs
do you know who does? Im not sure who to ping
I would escalate it to @harsh nova (leader of the external dev team) and he can escalate it further internally appropriately

Honestly dont see how that is malware
but likely not needed depending on what the use case is
ones just an encoding library the other is just a date time library that depends on a 3rd party api, both are likely not needed but without looking at where those libs are used its hard to say
Idk, im just assuming as there is bitcoin related packages as well as API stuff and constructs that i forgot to mention is binary encoding
it is also the 19 junk commits that makes it interesting. It looks botted as the commit names are copies of other commits on the repo
it breaks the library anyways an needs to be fixed
just make a pull request then
Yeah this does sound a bit sus. I'll take a look tomorrow but as I'm not that well versed in python it might take a sec or two
to clarify the 19 junk commits were just spaces being added and removed
Idk the python package ecosystem but it seems weird to remove a package listed by name and change it to links
it is not normal, also the packages are not needed. I am also curious how they were able to commit directly to main as they have no prior commits or anything
Is there any Discord bots around there that will let me host predictions and then reward the people who picked the winning option. With a leaderboard? I run a eSports server to am wanting to do predictions on games
Yeahhh that's a really good question I'll look into
Afaik I don't have admin perms for the repo(s) but I can escalate to the people who do
Could you give me an idea of when someone with the ability to make changes will be able to fix it? My users are counting on it, and it would be really helpful to have an estimated timeframe.
You could just install to the commits before. I forgot how but I know it possible
hmm ill see if i can find anything on it
you just use the commit has
pip install git+https://github.com/top-gg/python-sdk.git@bc3c062018cd951c7b51cf82b61681fdd2dde88a
That will install the python-sdk prior to all those junk commits
Here's a reference to what I am talking about https://stackoverflow.com/questions/13685920/install-specific-git-commit-with-pip
I'm developing a django app and I'm using pip to manage my requirements. How can I do to install a specific git's commit?
In my case I need to install this commit:
https://github.com/aladagemre/dj...
Simple google search
Awesome thank you
With BDScript
with pyhton
python code
@bot.command(name='memberCount')
async def memberCount(ctx):
await ctx.send(len(bot.users))
BDScript command
$membersCout
Why there is huge difference of member count?
It probably depends on how each language defines "users". Maybe the Python code shows the number of "unique" users and the BDScript code shows the overall number of users in the cache from each server where if someone is on two servers, it is counted as two
I have no experience in either
yeah this makes a lot of sence but also there is one small issue and that is bot is in 16 server only and 5,257 users shares same server?
Thanks for helping
@bot.command(name='mc')
async def mc(ctx):
total_members = 0
for guild in bot.guilds:
total_members += guild.member_count
await ctx.send(f"{total_members}")```
This command will show you all members put together, but if a user is in 2 guilds it will count as 2
here is how you can do it when the user is in multiple guilds, but you want to count them only once
@bot.command(name='mc')
async def mc(ctx):
unique_members = set()
for guild in bot.guilds:
for member in guild.members:
unique_members.add(member.id)
await ctx.send(f"{len(unique_members)}")```
worked for me
if you are putting it into a cog, don't forget to pass the self
And reload it
Check if the command is not a duplicate of another async def "mc"
dumb me using command without perfix

Thanks!!! it worked

we need more ppl like you
Glad i could help, even so, you gave me an idea to put the number of ppl in the presence 
Thanks again for helping...im kinda dumb, maybe I will be back
there is space for "le"
Well, i have to think to something else
wouldn't len(bot.users) achieve the same thing without the loop?
Actually, yeah
You could do it like this
@bot.command(name='mc')
async def mc(ctx):
members = len(bot.users)
await ctx.send(f"{members}")```
never cared about members count in guilds 
keep in mind that bot.users and guild.members rely on the cache
while guild.member_count doesnt
i know
realised that when i was starting the bot
if i was too "fast" it would show me less users
do you fetch all members at start?
That's what the bot is doing at startup, yes
thats unmanageable for most slightly larger bots
takes way too long to fully start and consumes huge amounts of memory
so once you get past a couple thousand guilds, you might wanna turn that off
I will always be pretty comfy
Sure i can store them elsewhere without getting them at every start-up and only read them. Or just approximate. Even so, the command wasn't for me, it was for Guy.
*ignore the music, too lazy to pause
*
i did it into a cog
from discord.ext import commands, tasks
import discord
class Presence(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.update_presence.start()
@tasks.loop(minutes=30)
async def update_presence(self):
total_users = sum(len(guild.members) for guild in self.bot.guilds)
await self.bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name=f"{total_users} gacha addicts"))
@update_presence.before_loop
async def before_update_presence(self):
await self.bot.wait_until_ready()
def setup(bot):
bot.add_cog(Presence(bot))```
keep in mind that this method gets the same user for every guild because "bigger number looks better"
I guess I'm the only one who doesn't care how many users "use" my bot 
if you want a big number then track VC time 
15 thousand days geez
now that's a cool idea 
this is how i am loading my cogs
cog_path = 'cogs'
cogs_list = [
'ask',
'askevil',
'avatar_banner',
'banners',
'calculator',
'cute',
'edit',
'feedback',
'gacha_genshin',
'gacha_hi3rd',
'gacha_hsr',
'help',
'manage_gacha',
'music',
'mute',
'nsfw',
'ping',
'presence',
'prison',
'raspunsuri',
'reddit',
'reminders',
'say',
#'topgg',
'usage',
'webhookmanager',
'welcome',
'wiki',
'yande',
'yandesafe',
]
for cog in cogs_list:
bot.load_extension(f'cogs.{cog}')
i am still using a list because sometimes i just want to disable them
you should have
│
├── main.py
│
└── cogs
│
└── presence.py
Do you have a cog per command?
That’s an interesting approach
it's nice when you can just reload the cog
Typically cogs are made to group commands
Well, it depends per use case
I find it more suitable like this
In my case ask and askevil are kinda the same command but i preffer them to be separate, where
banners - 2 commands
calculator - 2 commands
every gacha has 4 commands etc
Hey whatever works for you
yup
https://www.youtube.com/watch?v=lOv8oAU-KfE
like this?
Montage by EazY.
Visit discord now https://discord.gg/X7KPcynxfB
❤️
I meannnn
Technically you could
If it’s message commands
But it’s not viable at all
In the app commands? Use subcommand groups and sub-groups
That's how you do it in py-cord
and for subcommands only
question
with virtual studio code
if i have the terminal open and running my bot on my pc
what would happen if i open it and run it on my macbook at the same time?
i’m not going to, i’m just curious lol
Your bot will most likely start responding twice
Ah ok gotcha
In the case of slash commands, you will most likely receive an error that this interaction has already received a response
ohh ok gotcha
thank you!
So I was looking into what all is involved with having like server levels and server economy and all that and I read that there needs to be a database connected to the bot. I see that SQLite is a good one… is this information accurate? and if so, is SQLite good to use?
SQLite is perfectly fine for moderately sized databases.
It stores all of the database in a single file though, so its a bit more limited in capacity and growth. If you expect the bot to grow its better to use something intended more for larger production things.
I'd recommend using SQLite for now, once you're comfortable, or feel a need to you can move to something better.
Perfect! Right now I’m coding a bot for my server only.. right now it has 900+ members and I’m using Maki as a the bot to manage the server levels and server currency and stuff. Would that be too big of capacity with SQLite?
With sqlite you should be able to handle thousands of servers, possibly up to a few hundred thousand... So I think so ^-^
Ok perfect!!! Thank you
man
yall are teaching me so much
So this is another question and I’m sure the answer is loaded af
It helps because you're asking good questions, and genuinely want to learn.
Is there a way to transfer the data from maki to my database in sqlite?
if you host your bot on cf workers, I’m p sure you can’t use sqlite
There is mongo http though
but yeah if u use slash cmds only cf workers are pretty nice
Yes 1 sec
cf workers? is that another database manager?
cf workers are amazing, but you dont need to worry about it for now.
lol yeah don’t try using those now
they are sooooo painful
but something to look at down the road when you have more experience
Did you ever get waituntil working?
yep
ay
it needed to be a IIFE
I'm going to have to look into cf workers again sometime, I'm sure I'll have a use for them again soon.
I think my bot won’t require any updates until discord api v10 is deprecated
Oh, intresting
Just dont update it until its discontinued kek
Will give you another 4 years
v6 is still something you can use technically, its up, just not maintained.
Right? I forget
is v6 still the default?
Last I saw yeah
rofl yeah
I should be fine for a while
will i get kicked or anything if I post Maki’s link?
i don’t think so
@solemn latch vote isnt working
why 
oh
did u guys loose sponsers or smtg
Not that I'm aware of, I'm not sure why its down, us volunteers havent been told.
Hey @solemn latch is the site down?
Oh
2.5 days ago i think
ok lol, it’s https://maki.gg
ah, maki probably wont let you export stats for users.
You'd have to probably make a pretty complex piece of code to scrape all the data when someone checks their stats.
Its realistically probably not worth it.
Just listen for messages and read the content of any embeds from maki that matches the stats thing if its an embed
then parse that data into json
:)
Though its really not worth doing
dang it
ok another question
i’m not in any way trying to do this now, i’m just curious
but bots that have dash boards on a website… how exactly is that set up????
is that a loaded answer?
It all comes down to a database. That is the link between the bot and the dashboard
The dashboard is a separate instance to the bot, and the dashboard shows you stuff from your bots database.
is that something sqlite can handle as well?
so SQLite is serverless, meaning its not hosted in such a way that it can be remotely connected to. So unless you're hosting the dashboard and bot in the same directory, I'm going to say no.
good beginner for people is mongodb
its a nosql database that has some pretty good libs for it
why did i sit here reading mongodb as mysql for what felt like 5 minutes
lol
then reading nosql and thinking tf
lmao
Also in case you wonder mo, nosql just means non-relational. It doesn't follow your typical db structure that a sql database like postgres or mysql follows
Imagine not just symlinking your database file 
ah ok ok
i’m not familiar with terminology as far as database yet but i will research and this will make more sense to me as i learn lol
Its fine to ignore it for now
Mongodb is easier for beginners simply because it doesn't require raw sql queries
also using https://npmjs.com/package/mongoose
is helpful
hey guys is it actually possible to set guild settings through the bot assuming it has admin perms?
like mfalevel, nsflevel, icons, banners, timeouts etc etc
this is the full list of settings that i am trying to set by bot.
Technically yes, though I have no idea if bots ignore the 2FA requirement discord puts into place if they are set as onboarding.
the moderator 2fa req?
This applies to anyone with any management perms such as Manage Roles, Channels, Server etc
yeah bots can bypass that
otherwise they wouldnt be able to ban/kick etc
discord released a cool mod view
on canary at least
right click -> mod view
super useful
i think it was originally acesssible through members tab
but now you can just click on a user and view it which saves a lot of time
I wouldn't be surprised if they have the bot owner have to 2FA enabled for banning or kicking to be possible on their bots

lol dont you need 2fa now to create a discord app anyways
idk
it asks me for my 2fa code to reset a token
I never had 2FA turned off
so im assuming they do require it now
That's assuming you don't already have it on
ofc it will ask for one if you have it enabled
dont think they'll allow you to perform an action like that w/out 2fa
idk if it will or not if you disable it tho
idk who knows 🤷♂️
oh really??
ofc
damn
all those who don't have 2fa enabled they can just delete their servers
yeah then you probs dont need 2fa for creating bots then
2FA is just an extra check to make sure you are the one making the request
loooooooooooooool
it would be funny if they required the bot owner to have nitro for animated bot pfps
I would not be surprised
Don't give them any ideas
they listen to messages

actually idrc
I dont make bots anymore
do what you will
yeah tbh most bots wont really have a good gif to use anyways
No one is going to be spending the money it requires to get an animated pfp made
unless they are a recognized bot
yeah lol
Does anyone know how to make it to were when u use crime make the fines lower
Hey! We think you have our server mistaken. We do not provide support, help, or advice for any bot. You need to click on the "Discord Support Server" button on the bot's page of the bot you need support for. If there isn't a button that says "Discord Support Server" or nothing else mentioned about a support server, the server invite is invalid or you were banned from the bot's support server, then we can't help you. Sorry :(
what do you do now 👀
apis, applications, even games
outside of discord?
yes
got any mobile games? 👀
lately I have been more focused on learning C++ and other low level languages though.
I am interested in embeded programming
oh
too much shit to deal with
i feel that lol
with this you have to buy a license per game you make
and get it signed
which is like 100$
They also reserve the right to unsign your app
android apk’s are unbelievably easy to modify i’m learning
Without warning
I'd rather make games and put them on steam or itch.io
Even though steam charges the same 100$ fee their support for devs is much better
Oh ofc
link me to one of your games 👀👀👀👀👀
android is the definition of unsafe
ohh ok i gotcha
nothing wrong with it
@sharp geyser you should make a game with my game engine
WaffleEngine coming soon (never)™️
sure
I'd love to
you ever use the canvas node module?
yes and no
btw waffle
low level learning is very interesting
but some of his stuff is still confusing

you'll get used to the fast paced style
mainly when it gets down to him talking about the asm side of things
i bet the stuff i say and ask about don’t even make sense half of the time LOL
assembly is pretty easy
I know I just have never looked into it
it's just a matter of "know what this instruction does and what the point of it is"
so its confusing just watching about it
yea
man
so i got the lobby and buttons and everything for my bingo game functioning properly and perfectly
now idk where to start in coding the actual game 😂😂😂
if there’s enough players, run the function startGame() or something
you’d have to check based on the amount of ppl in the game which i think u already do
so from there you can have a condition to start the game, which can be its own function
then in start game you send new buttons and stuff and you go back to the collector and code there
ok that’s a good start
i was also thinking about the bingo boards
planning to use node canvas to generate numbers on a jpg that i’m gonna have in the project folder
@wheat mesa what exactly is a void *
I can sort of guess that it is a way of saying you don't know what the type is, but that can also cause issues when referencing stuff from memory no?
void* is just a pointer to any data type
int x = 5;
void *pX = &x; // will error because it doesn't know what type to try and reference
at least thats my understanding
void* is C's solution to generics
Since C didn't have a concept of generics, it's just a way of representing a bag of some runtime data
I see
For example, malloc returns a void*
I notice most of the memory allocator methods use void pointers
The point of a void pointer is so that you can cast it to whatever you want
I see
so
int x = 5;
void *pX = (int)&x; // will error because it doesn't know what type to try and reference
I guess there is no reason for it to do so for ints
You know how in your vector implementation you used T*
You could replace it with void* and it would be mostly the same
(And you would no longer need the <T>)
but say you had a struct
typedef struct {
char name[64];
int age;
} Person;
int main() {
Person *pPerson = (Person*)malloc(sizeof(Person))
return 0;
}
Yes
I recall watching something like this in low level learning video
That's very C-like though and usually you refrain from malloc in C++
that casts person to malloc and returns the person struct after its allocated no?
yea, low level learning does all his videos in C for the most part
That's why it returns a void*
Because you can just cast that void* to whatever you want those bytes to represent
so whats the point of casting to malloc?
I took this off memory from low level learning. He casted Person* to the return type of malloc
I was wondering why thats a thing



i cannot help with this



