#development
1 messages · Page 1865 of 1
You don’t have to take advice from me, but I know for sure that Papi knows what he’s talking about
wait how do u get the role name again if u have the role id?
Nah. I'm dumb
Get the role from cache and use the .name property
(Unless you already have the full object in which case you can skip the getting from cache part)
reaction.message.guild.roles.cache.find(role => role.id === rolereacts[i]).name?
I believe so

Huh?
He handled that already
I just made the stupid mistake of trying to add a certificate to my server using brute force
At the end, the server was down for 30 minutes
Hi again, I have some questions (discord.js)
How can I make my bot count all the reactions from a message?
For example if two people reacted to this message with 2️⃣ and 1️⃣, the final count would be 4. Apart of that, I'd like to know how it'd be possible for the bot to do something like:
- Check if the user reacted to a message
- Check if the user reacted to the message with another reaction
- If this happened, then delete the user's previous reaction and leave the most recent one
(Please ping when answering, thanks!)
Either use a reaction collector or the messageReactionAdd/messageReactionRemove events
@alpine lagoon
stop deleting message
ask someone for help here
all are know to tech
Pycord or Nextcord?
How to do this
you defined it as discord not Discord
It said discord has been declare?
How to do this?
{
"data": [
{
"id": 2712722,
"rootPlaceId": 75743778,
"name": "kniterider11's Place",
"description": ""
}
]
}
can anyone tell me how to get the "id" i tried JSON.parse but no wok
data[0].id
Help
what help do you even need
GuildCreate does not work
can you show where does the event get fired
I've heard good things. Fine if you're not planning to scale.
"to scale"
wdym by that
It's a proper VPS not a container like replit so it's good to learn how to use one. By "scale" I mean if you're not planning on growing your bot to thousands of servers.
ah
But replit isn't good for that either so...
wonder if Google Cloud free tier has some catches :monkaHmm-2:
If you're planning to grow, plan to pay
Oh yeah that was me! 
It's refreshing to see a bot that isn't a clone when doing queue 

- Mac 2021
the only catch is that after 1 year it starts charging you for bandwidth
but its like a few cents per month
my bot was in there until around 1k guilds
ah
ill probably move to google cloud when my laptop is feexed
I found a pretty dumb codewars kata (convert a number to a string) and I made it worse:
function numberToString(num) {
const str = String(num);
delete str; // cuz yes
return Array(String(num).length).fill(i => String(num).charAt(i)).map((x, i) => x(i)).join("");
}
how do i setup a google cloud project for my djs bot?
just start a compute engine instance
chose the free one, the f1-micro
then install some linux on it, like ubuntu or debian
then login with ssh
Does someone knowns a fontawsome icon for this /?
Cant find one
tried using the ascii character, but is not bold enough. Changed the font-weight to a higher one, but it doesnt make any difference
slash commands are much easier to use, you can have proper error handling and it is faster..
no
then skill issue
then skill issue
lol
Is it my internet or are github and npm dead
then what?
It's me
📣 The August release of VS Code is here! 🆕:
🖇 Inlay hints for JS/TS
🪄 Auto language detection with local ML model
🎨 Bracket pair colorization built-in
📝 Author guide for web extensions
…and more!
Release notes: https://t.co/v2rKREhBEU
Download: https://t.co/rLDTD8Hj2J
153
554
why is repl's typescript always high
why do people use repl instead of a local environment
he explained why
wtf is this
let user = inter.options.getUser('user');
let member = await inter.guild.members.fetch(user);
member.ban({ days: 7, reason: reason })
When the member is banned ( member is not longer on the server), you can still select him in the user options in the slash command. I guess because the user is still cached. So it will give an "Unknown member" error when executing the command. I tried if(!member) return but it doesnt work. So anyone knows how to catch this error?
use try catch?
you said so
catch
you can use if (!member) return if you use await inter.guild.members.fetch(user).catch(() => null);
or even better, why not use getMember? https://discord.js.org/#/docs/main/stable/class/CommandInteractionOptionResolver?scrollTo=getMember

?
Garbage collection completed on ThreadManager, which had a LimitedCollection of the ThreadChannel.
What's the context anyway
it spammed my console so i wonder what it was
my linux broke that's why
Ah i didn't know that
nvm
I got my slash commands to finally work
turns out I needed to run client.run() in an async context
so it wasn't lib issue was it
i mean if it is djs very well still may be 
i use detritus soooo
um guys
I need help w loading my commad in my main index.js file
I dunno how to load commands so can anyone teach me
I am trying to filter the files for the command name:
const fs = require('fs');
module.exports = {
name: 'interactionCreate',
async execute(interaction, client, con) {
if (interaction.isCommand()) {
console.log(interaction.commandName)
fs.readdirSync('./slashCommands/').forEach(dir => {
fs.readdir(`./slashCommands/${dir}`, (err, files) => {
let filter = files.filter(file => file.name === interaction.commandName + ".js")
console.log(filter)
})
})
let slashCmds = client.SlashCmds.get(interaction.commandName);
if (slashCmds) slashCmds.run(interaction, con)
}
}
}
What I get is this:
ban
[]
[]
[]
Anyone knows why there are just 3 empty brackets?
If I do console.log(files) It will log all files who are in the dirs (ban.js is there, too). I cant just filter them idk why
read dir return an array of string isn't it
so you don't need to file.name
why are you combining sync with callbacks
Use readdirSync on both or even better fs/promises
you're confusing yourself
weakly typed moment
can I have a simple command loading thing in js
im tryna do this since 10 mins
and can't figure it out
Naw
yay
How to update nodejs to version 16.6.1 (or higher) in termux? It's possible?
well, it's a normal terminal so yes
I already have it setup on my server with the correct SSL same as all my other sub domains for this domain
Could it just be that cloudflare is taking its sweet time updating the dns route?
No
I’m doing the same methods I do for all my other subs
Same ssl and everything
And same settings on cloud flare
Do I need to regen my ssl when I add a new sub? I don’t think I do atleast
each sub has its own ssl
you dont need to do anything to others
how did you create the ssl for it?
tim do you have any tips on checking if a key exists in a map? other than checking every bucket individually
Fontconfig error: Cannot load default config file```
why problem here
client.on('interactionCreate', async interaction => {
if (!interaction.isCommand()) return;
const slash = client.slashCommands.get(interaction.commandName);
if (!slash) return;
try {
await slash.execute(client, interaction);
} catch (error) {
console.error(error);
await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
}
});
Why not working in the dms?
what happens when you try to use it in a dm
Also I'd advise against sending an error reply since Discord will for you
Gives This interaction failed
But in the guild it working
@sudden geyser
2021-09-03T14:14:16.453546+00:00 app[Worker.1]: TypeError: Cannot read property 'me' of null
I don’t remember, all I know is I use all the same for all my subs on nginx
So you're trying to get the .guild somewhere
even though you know it wasn't sent in a guild
if(!interaction.guild.me.permissions.has('SEND_MESSAGES', 'EMBED_LINKS', 'READ_MESSAGE_HISTORY')) return interaction.editReply({ content: ' The bot is missing \`SEND_MESSAGES,EMBED_LINKS,READ_MESSAGE_HISTORY\` permission(s)!'})
You should account for that
.guild is may be undefined which is your indicator
If you need a guild, check if the guild is there beforehand.
There's no option to restrict a command to guilds.
@sudden geyser Sorry but this permissions working for slash commands?
if (cmd.clientpermissions) {
if (interaction.guild) {
const clientPerms = interaction.channel.permissionsFor(interaction.guild.me);
if (!clientPerms || !clientPerms.has(cmd.clientpermissions)) {
return interaction.reply({ content: ` The bot is missing \`${cmd.clientpermissions}\` permission(s)!`, ephemeral: true });
}
}
}
try it out and see
There are differences between guilds and DMs, so it's up to you to decide what permissions you need to check in the guild and what you can do in a guild you can't in a DM and vise versa
hash the key and check the index
but then some keys get relocated due to collisions
to effectively check i'd have to iterate over the whole map
if one isnt present that could cause performance issues
you follow the same relocation strategy
in case of robin hood, you do the same, linear search starting from the hashed index
until yiu find the value, or find an empty value, or find a value with lower relocation count
const discord = require('discord.js');
const { SlashCommandBuilder } = require('@discordjs/builders');
module.exports = {
clientpermissions: ['SEND_MESSAGES', 'EMBED_LINKS', 'READ_MESSAGE_HISTORY'],
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Replies with bot ping!'),
async execute(client, interaction) {
},
};
?
Hello... do yall know how to send over like a whole folder over with express js ?
zip it
or display it like a file explorer
no like then using the folder
wdym
OOK
like I would send a folder, then user the index in it, and be able to use to get like other files such as css
and stuff
bc zip makes u download it
yea
Hello, I'm a mmorpg player and I'm managing a guild. I want to hide the level and items of my players with bots. Me and my players need to see these whenever I want. How can I do it
My bot loaded slash commands 2 times Why ?
did you load them twice in code?
no
ask bot ALERTA veld to compress 
i've got a css question:
is there a selector for when an element enters the viewport (when i scroll to it)
I dont think one exists, youll likely need javascript or jquery
DiscordAPIError: Unknown Message
It occurs when the code inside the else { ... } runs.
you dont have permission to do something
idk
what line of code caused that error
youre missing an authorization header
looks like dblapi
did you pass your token correctly
well
then you tried to send something to discord without permission
its not discord, its dbl
bottom.gg sdk when
that's not official
we cannot guarantee it wont steal your token
but it wont probably
try {
const embedA = new MessageEmbed()
.setColor(black)
.setDescription(`Successfully deleted **${amount}** messages!`)
await interaction.channel.bulkDelete(amount, true)
return await interaction.followUp({ embeds: [embedA] });
} catch (err) {
embedError.setDescription(tryError)
return await interaction.followUp({ embeds: [embedError] });
};
Unknown message at interaction.followUp({ embeds: [embedError] }).
It's because I deleted my own message.. but how can I fix so?
check if interaction.message.deleted is true
Well.. it is according to me.
but the interaction object is the same 
I can do .catch(err => interaction.channel.send({ embeds: [embedB] }));
... but that leaves it unfollowed up.
NVM DIDNT WORK
Cannot read property deleted of undefined
7393988102/4xa94xl5iqs-Place
i have this string here i want to cut off everything after the "/" how do i do it tell me pls
It means it is deleted.
split the string and delete the last element and join
Should all slash commands have a .followUp().
how doe
btw thats the only string and its connected i dont think i can split it
is this the only string?
Here.
let string = "7393988102/4xa94xl5iqs-Place";
let regex = /7.*?2/;
console.log(string.match(regex)[0]);
It will return the numbers.
ok but like the numbers can be random lmao
cuz im using node-fetch
welp i think its impossible
lmao
let string = "7393988102/4xa94xl5iqs-Place";
let regex = /\d+/;
console.log(string.match(regex)[0]);
string.split("/") this will cut the string at the slash
ok
Or this...
regex is slow
code913's better.
well thats alot simpler
so the string becomes ["7393988102","4xa94xl5iqs-Place"]
now just use the first element in the array
thanks
you're welcome
code913
?
I'm confused... 😐
The interaction message gets deleted.
i dont know what a follow up is tbh
Ah.
But quick question...
Is this how you delete messages from a specific user?
try {
const embedB = new MessageEmbed()
.setColor(black)
.setDescription(`Successfully deleted **${amount}** messages sent by **${user.user.username}**!`)
const userMessages = (await interaction.channel.messages.fetch()).filter((m) => m.author.id === user.id);
await interaction.channel.bulkDelete(userMessages, true);
interaction.channel.send({ embeds: [embedB] });
// return await interaction.followUp({ embeds: [embedB] });
} catch (err) {
embedError.setDescription(tryError);
return await interaction.channel.send({ embeds: [embedError] });
// return await interaction.followUp({ embeds: [embedError] });
};
try it out and see
It deletes them all. 😐
including the ones not from the user?
.. no, all the messages sent by the user.
then it seems to work
ah
Yeah.. 😐
So if I had /purge HamoodiHajjiri#9923 5, it would delete 5 messages from you rather than a number like 50/100.
The bulk delete endpoint (https://discord.com/developers/docs/resources/channel#bulk-delete-messages) only accepts a collection of message snowflakes, so, instead, you could fetch a collection of messages, filter by the author (like you're doing), then take a subset of the result.
In fact, Discord.js has a method for that: https://discord.js.org/#/docs/collection/main/class/Collection?scrollTo=first
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
Do I need a React context when I only need to pass props down two levels (Home => Navbar => User)?
5/5s @quaint wasp
ish
keep in mind discord ratelimits are dynamic
you really should be looking at the dynamic ratelimit, not a static one
generally u won't want to put stuff into a tight loop
like, if ratelimit is 5/5s put at least 5 seconds between each message, just to be safe
it does work, just stops.
Hey.. just for confirmation.. I've got the variable userMessages and added .first(amount).. did I do it correctly?
try it out and see
It does work. 🎉
no
let time = inter.options.getInteger('time')
let reason = inter.options.getString('reason')
switch (time, reason) {
case time:
console.log("time")
break;
case reason:
console.log("reason")
break;
case reason && time:
console.log("reason && time")
break;
default:
console.log("nothing")
break;
}
Time and reason are optional so I want to check if they are given or not. But the output is always "reason".
Switch statements don't take two "parameters"
imagine switches with 2 params 
You're better off using some ifs
although hacky, this works
yuck
although !!reason && !!time might be unnecessary
since && will turn it into a boolean already
it would need to be higher up anyway
because its a strict comparison
the switch evaluates each case with === against true
ye but shouldn't reason && time become a boolean?
weird
try logging it xd
I did lul
but anyway, there you have it - an inverse switch-case
or you could be a normal person and use if-else
up to you to use either one
but this is sooo much code :/
dot dot dot
just check for them individually lol
let string = "";
if(time) string += " time"
if(reason) string += " reason"
console.log(string)
let arr = [];
if (time) arr.push("time");
if (reason) arr.push("reason");
console.log(arr.join(" && ") || "nothing")
now you just have more checks
more checks, but may be more in line what they want
Tim's doesn't add &&
neither "nothing"
My bot is marking this IF condition as true, even though I'm running the code from a channel that doesn't belong to the category with ID "699265633128546374", so it SHOULD run the code inside of this IF statement, but it doesn't and just checks the next one. Can someone please tell me what I'm doing wrong?
}```
I know parentId might be nullable but in that case, is there a way to make it "not nullable"?
Remove the ! at front of the if case
parentId is null, when a channel doesnt belong to a channel
No, that's not what I actually want
If the command is ran outside the category with ID 699265633128546374, the bot should run the code I put into that If condition, however, as I said the bot is literally ignoring that part of the code and checks the rest of conditions, because after that if statement there're some } else {'s
It's not my case either, the channel is inside a category
!a === b means if not-a equals b
and not if a not-equals b
which in js becomes if boolean equals string
Oh, you're right! Just remembered there's !=
How do I check if the role from the bot is higher than the role of the user / member?
@quartz kindle sorry to keep bugging you i never knew the inner workings of most shit until now lmao
just to confirm std strings are allocated in the heap?
and when another string is appended on a new heap block is allocated and copied over?
in which library
discord.js
member.roles.highest will get you their highest roles
then just compare the position property of those two roles you got
to get your bot as a member do guild.me
i want to point my INTERACTIONS ENDPOINT URL to my localhost. is the best way to do that to use a service like noip.com to get a domain name pointed to my ipaddress and then buy a certificate and install it on my local?
an instance of std::string is stored on the stack, but points to a string buffer stored on the heap
its like a small buffer manager
yeah thats what i thought
so i'm doing it right nice
i also made my own smart pointers
nice
ngrok is what im looking for
If i added in my bot config it will display the server count ?
"Authorization": "my-topgg-token-here"
nope, youll need to have the code to post it
From where i can get it ?
Wait it's public or ?
What should i add here ?
I am not using shards my bot is not in 2500+ servers
int serverCount = ...; // the total amount of servers across all shards
i have event listeners setup for the invite and kick events for the bot. i store the active guilds in the db. then i count the number of active guilds to get a count
Do we need intent for on_member_join ?
yes, GUILD_MEMBERS
oof
is it possible to make events like guildDelete and guildCreate go to the INTERACTIONS ENDPOINT URL?
the bot joining the guild is an interaction
it isn't
it isn't an interaction lol
i think this should work await msg.guild.members.fetch()
oh yeah
do that in a loop
but you might want to slow down the loop so you dont get rate limited
that's a not so smart idea though anyway
your ram is going to get filled up really quick
i agree
member objects are super heavy
if you are running this right when discord starts there might not be any users populated in the cache
then you don't need to fetch all members at all
just reduce the guilds' memberCount property
it's a dumb and a useless statistic anyways
nobody cares but you lol
it doesn't, you just don't know how to use the library lol
it sucks when it comes to being optimized
but other than that it's a great library
i'm converting my code to slash commands and i dont think i'll even need a library
the api gives you everything you need
like in the request body
ngrok works perfectly for testing slash commands locally
discord wants bots completely off the gateway
they force us to use websockets and then force us to stop using them
yeah well
they themselves don't know what they're doing
if it wasn't clear enough with the message intent coming soon lmfao
they are doing the right thing now
discord was basically a POC that grew too fast
they actually had plans for bots to integrate with the client back in 2016
like slash commands and all
but only got around to doing it now
probably got under new management
cry me a river
DiscordAPIError: Invalid Form Body
embeds[0].description: This field is required
You probably supplied an empty string for the description
button.channel.send(button.clicker.user.avatarURL())
how can i make it send the avatar animated if its animated
my avatar is animated but it doesnt send it as the gif
hmm wait nvm i think its just dynamic: true
ya it is nvm
You tried look up some DNS address that didn't exist
fyi 
const users = client.guilds.cache.flatMap(guild => {
return guild.members.cache.filter(member => !member.user.bot)
})
how do i fetch a channel with buttons
await button.guild.channels.fetch
doesnt work obvs
button.message.guild.channels.fetch ig
(node:2508) UnhandledPromiseRejectionWarning: TypeError: button.message.guild.channels.fetch is not a function
that's why I said "ig"
this is what data it gets from button clicker
aka the user who clicks the button
there you have it then
for guild
member.guild.channels
channels are guaranteed to be cached, you don't need to fetch them
since when
since always
you might be confusing them with members
o
let ticketchannel = button.guild.channels.cache.some((channel) => channel.name === "ticket-logs")
ticketchannel.send dont work
hm wait lemme try ID
It's best to always use ID when searching for a specific channel
.some returns a boolean
and use .find() or .get()
^
ah ic
how can i change the label background if radio button is selected in this structure:
<label>
<input type="radio">
<span>
<i></i>
</span>{{label}}
</label>
i have tailwind installed on the project btw if it makes things simpler
can i register a slash command in some way that forces it to send me the guild name without me having to make an api call?
you cant
there is a hacky way to do it by putting the label after the radio input and using the label-for attribute and some css selector shenanigans
the same principle used in css tabbed boxes
that sucks js time then i dont like the hacky way thanks
What command I use for update nodejs for version 16.6.1 (or higher) in termux?
why not use rest syntax to merge the map and extra props (...res.data)
though it looks pretty standard
msg.member.voice.disconnect()
you may have issues with very high concurrency, otherwise looks fine
1500+
thx :iara_sunglasses_cool:
anyone know how i can get a mysql value
using python
its stored in the format userid, pronouns
actually
i'm switching to json
you know the mysql query line first?
Across all languages, it's similar. Just how you execute the statement.
SELECT * FROM Table WHERE key = val;
Although, I would recommend using prepared statements. So, something similar to
SELECT * FROM Table WHERE key = ?
val;
let row = new MessageActionRow().addComponents(
new MessageButton()
.setLabel("YES")
.setStyle("SUCCESS")
.setCustomId("yes"),
new MessageButton()
.setLabel("NO")
.setStyle("DANGER")
.setCustomId("no")
)
let message = await msg.channel.send({ content: "Button test", components: [row] })
const filter = (inter) => {
console.log(inter.user.id, msg.author.id)
if (inter.user.id === msg.author.id) return true
return inter.reply({ content: "You cant use that" })
}
const collector = msg.channel.createMessageComponentCollector({
filter,
max: 1
})
collector.on('end', (ButtonInteraction) => {
let id = ButtonInteraction.first().customId
if (id === 'yes') {
return msg.channel.send({content: 'Confirm'})
}else {
return msg.channel.send({content: "Decline"})
}
})
I would like to disable the buttons after collector.on('end'). How can I do this so?
Using discord.js
I believe the only way to “disable” the buttons entirely is by editing the message to no longer have the components in them
message.edit({components:[new MessageActiveRow().addComponents(message.components[0].components.map(v=>v.setDisabled()))]})
try this (didn't test tho)
before
let id = ButtonInteraction.first().customId
It should work now, but instead the bot doesn't listen to the command at all... What should I do? I'm not even getting any errors in the console
if (message.content.startsWith(`${prefix}gamevote`)){ if (message.channel.parentId !== "699265633128546374") { let errorEmbed = new Discord.MessageEmbed() .setTitle(`**Something went wrong**`) .setDescription(`something here`) .setColor("RED") .setFooter(`Command ran by: ${message.author.tag} (${message.author.id})`, message.author.displayAvatarURL) .setTimestamp() message.channel.send(errorEmbed).catch(console.error); } else { some more code } }
seems good if your intention is:
1- message must start with prefix+gamevote
2- category ID shouldn't be 699265633128546374
if it's not working, then probably he don't even check this whole code
or ur prefix is undefined
so do some console.log to check
message.author.displayAvatarURL
should be
message.author.displayAvatarURL()
2- category ID shouldn't be 699265633128546374
Correction, category ID shouldn't be other than 699265633128546374
Will try again with the displayAvatarURL() fix, thanks!
then don't use !==
use === instead if you only want him to reply for channel inside that category only
But I want the bot to send the embed if the user is trying to run the command outside category ID 699265633128546374
Btw it's fixed now, thanks a lot! 
which discord.js version u are using?
12.5.1
do slash commands have a built in way to rate limit?
is it something bad
if i'm not wrong,
In v12
to category is called parentID not parentId
depends,
if you want to use latest features like slash and interactions
then you have to use v13
After some tests I realized you're right - I've edited it and now it works as expected, thanks again!
Oh I see; well, the bot I'm currently developing doesn't require to access that kind of features, but will definitely keep it in mind 
to avoid such mistake, in discord.js.org documentations
select ur version
because it will show u the latest version documentation by default
because it will show u the latest version documentation by default
got it, didn't know about that!
@low bone do you know how should I set up my code so that my bot checks if the user reacted to a message, and if they reacted again (with other emoji) the bot would remove the previous reaction by the user and leave the most recent one?
Alright, will look into it!
Another question; is there a way to make the bot display a category's name by its ID?
just get it and .name
I need some help with influxdb configuration to a subdomain on my host
After some time checking docs and some articles on the internet, I'm still unable to setup a reactions collector correctly.. Could you please help me out?
What didn't u understand abt collectors?
How to literally setup one lol, I don't know where I should start from
djs?
yes
I'm so sorry, but I still can't get it at all
An example of an actual reactions collector that'd work similarly to what I want would help me a lot
- check if a user reacted to the message;
- check if the user reacted to the message with other emoji
-> if that happens, remove the first reaction and leave the second one
xD well, yes! but that doesn't mean I wouldn't love to learn how to create it myself
I'm just literally out of ideas, I don't know how to create one
Anyone?
As I said I've checked docs and many articles already, but I'm unable to find something similar to what I need, so I can't really learn how to adapt those examples from internet to my case
Have a break then, if you're exhausted there's no good in burning ur head
It's not hard at all, you just need to look at it with a fresh mind
I'm sure my mind is fresh enough, I just, don't know how to do it, not even after looking at docs
Just realized I have to completely rewrite my bot in js by April Bc discord.py is not implementing slash commands

Dpy has a technically official slash lib
Even then, all you need is to have the intent whitelisted if you need to use message content
According to the sole d.py dev: “If you want to apply for the message content intent, you cannot use it for command handling purposes; they will explicitly deny you the intent.“
What does "time" mean in this code line?
const collector = message.createReactionCollector({ filter, time: 15000 });
Timeout
Unfortunatly I don’t have anything else to use it for. But I could probably just make some shit up 
Bad idea
If all you use message content for is command handling just move to slashes then
What should I do if I want the bot to check for new reactions on that message indefinitely?
then it circles back to the fact that d.py slash commands is “not implemented” according to the dev. Whatever, hopefully by then someone will make a working fork and I won’t have to switch languages
Doesn't the documentation talk abt that?
Like setting timeout to -1 or something
They probably talk about it somewhere
And do note, keeping collectors open indefinitely is...sub optimal at best
Use the official-ish lib
Dpy slash iirc
It's been around since slashes became a thing, often referred as the main slash lib for dpy
Gotcha, I’m relatively new to bot dev stuff so I didn’t even know slash commands were gonna be a thing until today
Yes, I know, but I don't want to setup a timeout, but rather stop the collection when a condition is met
Doesn't look like so btw
Is timeout a required attribute?
Looks like it's optional!
So just leaving that line as
const collector = message.createReactionCollector();
Should work, right?
can i use DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE to prevent timeout from happening?
https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-response-object-interaction-callback-type
how would i send the followup message?
without timeout it'll forever until next reboot
wym ?
like usin the raw api or a library
i would send an ack and it's in loading state. then i need to send the actual message after
i am using slash command INTERACTIONS ENDPOINT URL
@coarse topaz
i dont get what ur tryna do, just send a normal message and edit / send actual message later?
the type should be 4
ur like, doin some weird stuff
Just edit the message with the same content
Then do whatever u want to do and edit it later
like make an api call
yeah, usually its how ur making the api call. ur sending multiple responses for one request
if that makes sense idk ive barely slept
how r u making the api call
discord is calling my INTERACTIONS ENDPOINT URL
i am not making any api calls currently
what library u usin
i registered my INTERACTIONS ENDPOINT URL with discord and made slash commands. discord calls my nodejs expressjs project with info
i honestly have no idea what ur trying to say and how that works but im going sleep
Yeah, he's not using a library. Instead, he's creating his own webhook API that Discord interacts with.
Does anyone have experience with the ShardManager.broadcastEval() from discord.js?
im getting a 404 error when calling the webhook
https://discord.com/developers/docs/resources/webhook#execute-webhook
same issue with the interactions endpoint
https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response
hm
how can you see the function parameter names
Webstorm
nice
Is it possible to use replit inside VSC? All I need to do is connect to repl.run but idk how
Yeah probably
how do i connect
Isn't repl.run() deprecated ?
I am returning DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE. it says to ACK an interaction and edit a response later, the user sees a loading state. How do i do the edit a response later part?
https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-response-object-interaction-callback-type
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
what happens if i run an openssh server on replit then connect with the repl.co domain
RangeError [EMBED_DESCRIPTION]: MessageEmbed description must be a string.
.setDescription(warn.content.map((w, i) => `**\`${i + 1}\`** | Moderator: ${interaction.guild.members.cache.get(w.moderatorID).user.tag}\nReason: ${w.reason}`))
Did I do something wrong?
It is legit 1 INDEX.
correction: javascript sucks
It’s done like that for a reason
V13.. 🤷♂️
I was waiting for someone to just say Typescript is better. 😂
.. but guess not.
how do i implement an iterator for a class
I have this:
class LinkedList {}
and I want to be able to do this:
for (let node of list) {}
nvm i can just iterate the nodes property which is an array
idk if that's true or not but i'm gonna remake mine in TS cause i accidentally deleted all my commands in JS
Oof.
i cant seem to lock a channel
const role = message.guild.roles.everyone;
const perms = role.permissions.toArray();
const newPerms = perms.filter((perm) => perm !== 'SEND_MESSAGES');
console.log(newPerms);
await role.edit({ permissions: newPerms });
message.reply("channel locked")
i figured it out
This is my kick command
module.exports = {
name: 'kick',
description: 'kick users!',
execute(message, args){
const member = message.mentions.users.first();
if(member){
const memberTarget = message.guild.members.cache.get(member.id);
memberTarget.kick();
message.channel.send("User has been kicked");
} else{
message.channel.send('couldnt kick mentioned member');
}
}
}```
I want only people with a specific role to be able to kick
so where can I add this
```js
if(message.member.roles.cache.has('782908342548299778')```
so that only members with that role can kick?
before const member but open it with{
and close it at the end
ohh okay thanks :)
So pre much js if(message.member.roles.cache.has('782908342548299778') { const message blah blah blah }

like this?
module.exports = {
name: 'kick',
description: 'kick users!',
execute(message, args){
if(message.member.roles.cache.has('782908342548299778')
const member = message.mentions.users.first();}
if(member){
const memberTarget = message.guild.members.cache.get(member.id);
memberTarget.kick();
message.channel.send("User has been kicked");
} else{
message.channel.send('couldnt kick mentioned member');
}
}
}
Pardon?
Do you not know
I was talking about this https://docs.replit.com/repls/repl-run
hello need help
/home/runner/EVON/commands/cat.js:2
const fetch = require('node-fetch');
^
Error [ERR_REQUIRE_ESM]: require() of ES Module /home/runner/EVON/node_modules/node-fetch/src/index.js from /home/runner/EVON/commands/cat.js not supported.
Instead change the require of index.js in /home/runner/EVON/commands/cat.js to a dynamic import() which is available in all CommonJS modules.
at Object.<anonymous> (/home/runner/EVON/commands/cat.js:2:15)
at /home/runner/EVON/index.js:30:17
at Array.forEach (<anonymous>)
at /home/runner/EVON/index.js:28:9
at FSReqCallback.oncomplete (node:fs:185:23) {
code: 'ERR_REQUIRE_ESM'
}
exit status 1```
can any one help me
is it possible to make ```js
if(myArray.includes("myString"){
//code here
};
(nodeJS)
you're trying to do require inside a module
use import instead
can you give more context?
so i want to have a command.json where you can change/add aliasses for commands, and i am using switch/case for commands
why
just put more than one case for the same command
case "command":
case "alias":
message.reply("both work");
break;
yeah, but i have that, but i want to have it in a json
?
like that i only edit the json not the code
Is it allowed to use the cache of all servers in a bot and fetch all the member count of each server and add it to the number variable?
Go to server cache > in each server fetch member count > add each member count to the total amount variable.
Everyone does that though
So it's allowed
Also you can just use client.users.cache.size instead of adding all member cache
It takes time to cache each one..
no?
.. so I want to go to each server, and get the member count by fetching.
rate limits
Ah.
and bad idea
All guilds have a memberCount variable, you don't need to fetch...
.. meaning it is caching users slowly.
not as bad of an idea as to have a nextjs file structure made entirely of index.js files
.. would I be able to make it so each guild I can get the member count?
and i don't see what's wrong with a non accurate user count
Keeps increasing and doesn't show the total real amount.
you can only really keep a rough estimate
guilds.redcue
It's such a useless metric, why do you need this?
imagine saying that to someone who uses farenheit and/or inch
Does this cause ratelimits?
It doesn't
no
Because it's using the cache
Ah. 👍
prolly cause you're on mobile
or you've placed them in different rows, we can't know for sure because we can't see the code
@drowsy crag oi
No thank you
❤️
@rose warren
some people are just weird
WHO
No ads please
okk
hello can i dm someone to help me with my automoderation system?
Hello
this is my ban command, but the thing is if I try banning myself it obviously doesnt work and shows error in console but then the bot stops responding until I restart it. Anyway I could fix that?
module.exports = {
name: 'ban',
description: 'bans users!',
execute(message, args){
if(message.member.permissions.has('ADMINISTRATOR')){
const member = message.mentions.users.first();
if(member){
const memberTarget = message.guild.members.cache.get(member.id);
memberTarget.ban();
message.channel.send("User has been banned");
} else{
message.channel.send('couldnt ban mentioned member');
}
}
}
}```
you mean, if you try to ban the bot?
no like if I run the ban command on myself, as in try to ban myself it shows errors but then the bot also stops responding to all the commands until it's restarted
what error it shows?
You should try...catch the ban call
Try ```js
memberTarget.ban().catch(err => console.log("Can't ban that user"));
(edit: missing bracket)
oh okay thanks
Also, you can just require the ban members permissions for a ban command. Not all people with ban permissions need to be administrators
How do i set url to button
set the style to 5 and the url to your url
does anyone have any good resources for learning about asynchronous stuff with python? I'm trying to wrap my head around like async io and stuff and i just... can't.
let b7 = new Discord.MessageButton().setCustomId('invite').setStyle('LINK').setEmoji('robot');
link buttons cannot be emoji buttons and vice versa
link buttons also cannot have a custom_id
I saw one in select menu
select menus =/= buttons
I just started buttons
why do i get this error? (node:16096) UnhandledPromiseRejectionWarning: TypeError: setTimeout(...).then is not a function
So dk anything
async setTimeout is only in node v15+
and must be imported from timers/promises
const wyr = require("wyr");
msg.channel.send(`:loading: fetching random wyr...`).then(m => {
wyr().then((response) => {
let question1 = response.blue.question;
let question2 = response.red.question;
let embed = new Discord.MessageEmbed().setAuthor(`WYR Generator`, msg.author.displayAvatarURL()).setTitle(`Would you rather...`).setDescription(`**A:** ${question1}\n**B:** ${question2}`);
setTimeout(() => {m.edit(embed);}, 150).then(
m.react('🅰️').then(() => {
m.react('🅱️')
})
);
});
});``` this is the code btw
so whats wrong
i wish i was jared, 19
whats wrong in my code?
it has an emoji in the label
oh
how can i edit a message and also remove the previous content v12?
guess it can have an emoji then
but anyway, robot isn't a valid emoji
and link buttons cannot have a custom id
\🤖 is a valid emoji though
can someone help?
give it null content
how would i do that
oh yeah just that the bot's role isnt an integrated role it's a normal role which can be removed and added anytime and can be assigned to others as well 
so I placed it above staff roles
as it has admin perms
and dont want mods to be giving it to themselves
content:null
and because of that these mods were kicking each other so made it admin only for a while 
well it was v12 but i alr found it lol just m.edit('', embed)
works now, thx
took them long enough to add async timeouts natively
callbacks are a thing of the past am i right
unless you don't have async support
let message = await msg.channel.send({content: 'test'})
setTimeout(async () => {
if(!message) return;
message.delete()
}, 10 * 1000)
The 'message' gets deleted before the timeout starts so he should return because the message was deleted. But he doesnt so he will throw an "Unknown message" error. If I do console.log(message) in the timeout he will log the message and deleted = false.
I dont know if it is important but the message gets deleted while the 10 seconds are running
You should be able to check if the message is message.deleted === true, but if that's not working, you can always just catch the error.
Which you should be doing anyway since you don't know if that promise is going to be rejected for whatever reason
or you can silently handle the promise via .catch(() => null) which wouldn't throw an unhandled rejection and let you check via NOT operator
I mean for the easiest way you'd download some kind of library that does all the heavy lifting for you
you mean .tar.gz files? or what
thats basically a zip file
what do you want to do with it?
targz is usually just zips for linux
message is undefined
show your command handler
that's not the handler
the handler is the run part
in the message event
your command has a run function
You’re calling your <command>.run() in your message event
this file... i wanna unzip it
the first argument is message, not client
open it with winrar or winzip or something?
I am trying to make a timout for buttons so the buttons get disabled after a few seconds. This works fine but now I want to cancel the timout if you interact with the buttons. So I am now so far that you make sth with the buttons but the buttons still get disabled after a while. How can I cancel the timeout if a interaction was given?
clearTimeout
winrar moment
tfw free trial expired but you can still use it
alright you pirate
Imagine calling it cracking just by replacing the reg file.
What a strong security layer of WinRAR 
These methods are oldschool… once again oldschool rockz
it is a very old program lol
pretty sure they don't care about some kiddies cracking it
they get tons of revenue from businesses using it anyways
since to "legally" be able to use it they need to have a license
test
lel
Can’t see your test message and test received either
Must be a skill issue
skill issue confirmed
github pages?
You mean a domain
You can get a domain on github pages
You can get a custom domain with gh pages right
yes
but you have to buy it yourselff
yes yes
really?
github pages.
Can't u get a free domain from github if ur a student?
or do they not do that anymore
I remember there was a time they did that
i would be glad 😂
you get github student pack which includes services that offer a year free on certain TLDs
iirc there's namecheap and name.com
tim where did u host your website?
it's not free prob
oops
most free webhosts have catches to them
hosting or domain?
those are two different things
Is there any reason why I should make a bot open source?
both
hosting is like a server where your programs/websites run, they only give you an ip address
Nope
a domain name is something you buy separately, and point it to an ip address
for the well fare of humanity lol
I buy my domains from a few places depending on the TLD and price of the specific domain
hmm
typically just do your research on the domain side
if you want both domain and hosting, many providers give you 1 domain for free if you buy their hosting
waao
How to change perms of a text channel?
just like, in discord?
ok
Don't ping mods please
Ah ok np
The error I get when the bot has 0 permissions
button.defedUpdate()
Should i remove it?
are you taking more than 3 seconds to deferUpdate?
Ping: 69420ms
lol
yeah feels bad for replit bots which sometimes have more than 3 seconds of ping
This is the code of the bot
I mean this command's code
ad there are ppl like me who spam discord api with Webhooks just to get the whole replit cluster get ratelimited
lol
let reply = `Previous warnings for <@${userId}>:\n\n`
how can i turn the string into a code block
use
\`\`\`
reply = `\`\`\`\js\nYour text\n\`\`\``
ok ty
if (i.customId === 'help') {
await i.deferUpdate();
await wait(500)
await i.editReply({ embeds:[help], components: [row, row2, row3] });
}
why wait 👀
It was like this in the sample code
I didn't change it because Discord knows something.
actually, pretty sure they just have that to show how to defer updates. like if defering is needed.
such as if you are unsure how long something will take
So if i remove it i dont get any problem?
yeah looking at the djs guide the wait period is over 3 seconds
yeah, its only for if you need more than 3 seconds to respond to the interaction
But it doesnt give any problem when bot has permissions
still, all your doing is just waiting 500ms for zero reason
It was so that the bot wouldn't be counted as spam.
thats not what discord, or the guide says
https://discordjs.guide/interactions/replying-to-slash-commands.html#deferred-responses
As previously mentioned, you have three seconds to respond to an interaction before its token becomes invalid. But what if you have a command that performs a task which takes longer than three seconds before being able to reply?
In this case, you can make use of the CommandInteraction#deferReply() method, which triggers the <application> is thinking... message and also acts as initial response. This allows you 15 minutes to complete your tasks before responding.
@solemn latch i think the .editReply() method is actually used to edit the reply the interaction previously made. For example if a button is clicked and it sends a message and then u edit that message later again. He needs to send a message first before editing, or needs to update the message containing the button. I might be wrong
Yep, i was right, u are trying to edit a message which u never sent
Actually i sent
Hmm
I am editing buttons not embed message
Maybe its bc of this
Is there a way for bots to turn off the speaker's mic when muted?
for me this are contained in obj
{ str: 'hello', elapsed: 33.237 } //logs this
how i can send str and elapsed if i use obj[str,elapsed ] i get not defined
if i send obj i get Cannot send an empty message
(as discord message)
Ex: message.channel.send(obj);
message.channel.send(obj[str, elapsed ]);
send(${obj.str} : ${obj.elapsed})
??
ok
imagine that it worked
also
is unhashing in discord illigal
Unhashing?
what does it mean?
If you can crack a hash in a reasonable amount of time it was a shitty hashing algorithm to begin with
unhashes your browns
yup
no i mean like discord will ban my bot if i add it as a feature
Bruh
An unhash command for MD5?
I mean I highly doubt it because your bot will likely not be able to crack any hashes
yup
Hashes are specially made to be one-way ops
am stupid '-'
You'd take a fuckton of resources just to break a single hash
I’m running a lookup hash table for 4 billion game account IDs
If you're using salts yeah
it takes long time
Still haven’t been banned yet 
I’m not sure what type of specs this information is based on, but I highly doubt that you’ll want a bot taking up those resources
Yeah no MD5 is the worst way to store passwords after just plain text
it take 30s
Since there are already gigantic lists with known passwords out there
x
fact
Unless your bot is running on some really impressive specs
Passwords are one thing but arbitrary data? Even md5 is gonna take some time
markdown has versions?
He cracking those 3 character passwords in 30 seconds 😳
It’s not like a stolen password would be an issue if somebody has stolen personal data out of a database
4*
Daring today ain't we?
DeferUpdate just means you cannot update right now(within 3 seconds).
Waiting and defering isn't needed if you don't need to wait on anything.
Yeah I understand that, but to his error it seems like he is trying to call the .editReply method to actually create a interaction response
check the git codes
He isn't editing the original message of the interaction, neither trying to create a new response
I didn't answer that part. I answered the question of if he can remove the deferUpdate
Again, I might be wrong from what I've understood. So pls explain to me aswell if I am wrong 😂
Ahh
Didn't look at anything else tbh
Gotchu
in the kitchen
Type again delete old one instead edit
:/

Do you mean token?
Skill issue
Welp
There's no such thing as a bot cookie
What's your native language?
Kannadian
Try asking in #general-int in your native language
Nah





