#development
1 messages ยท Page 1903 of 1
I'm using slash commands for the buttons, now, what could I do?
here's an example:
npm uninstall discord.js && npm install detritus-client
const { Utils: { ComponentActionRow } } = require("detritus-client");
const row = new ComponentActionRow();
// first button
row.addButton({
label: "whatever",
run: context => didn't need to differentiate
});
// second button
row.addButton({
label: "whatever 2",
run: context => didn't need to differentiate
});
erwin 2.0
I'm following detritus code of conduct
I have to encourage people to uninstall discord.js
Does something like this, work?
Wait, messed up in something.
ayo wouldn't this always return true
Does this work?
const row = new MessageActionRow()
.addComponents(
new MessageButton()
.setCustomId('yes')
.setLabel('No')
.setStyle('SUCCESS'),
new MessageButton()
.setCustomId('no')
.setLabel('Yes')
.setStyle('DANGER')
)
const filter = (interaction) => {
if (interaction.user.id !== message.author.id) return interaction.reply({ content: 'You cannot use this button.' });
};
const collector = message.channel.createMessageComponentCollector({ filter, max: 1 });
collector.on('end', ButtonInteraction => {
const id = ButtonInteraction.first().customId;
if (id === 'yes') return message.channel.send('Banned user.');
if (id === 'no') return message.channel.send('Cancelled Action');
})
return await message.channel.send({ content: 'Hello World!', components: [row] });
A promise is also a truthy value
Yeah, I changed that.
Does something like this work?
you're over complicating
Am I?
I thought this is how you can handle each button, alone.
const row = new MessageActionRow()
.addComponents(
new MessageButton()
.setCustomId('yes')
.setLabel('No')
.setStyle('SUCCESS'),
new MessageButton()
.setCustomId('no')
.setLabel('Yes')
.setStyle('DANGER')
)
const filter = interaction => interaction.message.id === message.id && interaction.user.id === message.author.id
const response = await message.awaitMessageComponent({ filter, time: 10000 }).catch(() => null);
if(!response) { return message.channel.send("timed out") }
if(response.customId === "yes") {
// do something
} else {
// do something else
}
Oh. Let me try that real quick.
Remind me, mine is more complicated, that's all?
and dont forget to edit the message and remove the buttons once its done
.. or set it to disabled, which I am not sure how.
yours is not designed for this job, and has lots of issues as well the way you did it, including working on other buttons on other messages in the same channel, which will make it spam "you cannot use this button"
Ah, makes sense.
For sure, but it didn't work, unless I did something wrong?
Oh, I found it.
False alarm.
const newmessage = await message.channel.send(...)
const response = await newmessage.awaitMessageComponent(...)
Didn't work either...
const m = await message.channel.send({ content: 'Please select a button to perform an action.', components: [row] })
const filter = (interaction) => interaction.message.id === m.id && interaction.user.id === m.author.id;
const response = await m.awaitMessageComponent({ filter, time: 15000 }).catch(() => null);
if (!response) return message.channel.send({ content: 'You have timed out.' });
switch (response.customId) {
case 'yes':
message.channel.send({ content: 'Hooray.' });
break;
case 'no':
message.channel.send({ content: 'Failed' });
break;
};
WAIT-
It's not working, yet.
m.author.id would be your bot's id, so message.author.id
In my interaction event, I did this.
if (interaction.isButton()) {
};
I have nothing to handle there...
you dont need the interaction event
Ah, so I just remove the isButton?
Alright, I just removed it. What can I do for this?
It says interaction failed, so do I do something like...
did you defer the button?
How so, exactly?
response.reply() instead of msg.ch.send
Or
response.deferUpdate(); with message.channel.send
response.followUp()?
Why won't that work, too?
switch (response.customId) {
case 'yes':
response.followUp({ content: 'Hooray.' });
break;
case 'no':
response.followUp({ content: 'Failed' });
break;
};
// โโ Confirms to the "interaction" that it has worked
await button.reply.defer()

How could I do the same but for .followUp?
Where did you get, button, from. ๐

.. and?
what u expect from me to say?
I just asked what I could do to make it followUp based on my code.
ic
I didn't mind you not knowing the answer, so I'm just waiting for an answer from anyone.
You can use collector
Wait, not collector exactly.
As a test one, yes.
You need that buttons one time or everytime?
One time.
Use it one time for a command.
Huh, why so?
Why would you wanna use a collector if pressing a button is triggering the interactionCreate event?
...
and
collector.on('collect' async i => {
if(i.customId === "yes") {
//Code here
}
});
I'm using mine for one time use, like one performing command, use.
Yes but using it on interaction create event isnt logical
depends on how u build it
Tim, could you tell me how I could follow up the button?
i.fallowUp()
I'm not using a collector. ๐
interaction.fallowUp()
followups can only be used if you defer it first
response.defer?
yes
What does defer do, exactly?
As he said you have to defer the button reply, then sending the follow up message
Oh I see.
when you receive an interaction, you have 3 seconds to reply. if you dont reply in 3 seconds, the interaction fails
defer basically responds with "i will respond later"
I'm so sorry, I didn't see the comment. :/
so you have more time
button.deferReply() ? Isnt better
TypeError: Cannot read properties of undefined (reading 'followUp')
await response.defer.followUp({ content: 'Hooray.' });
no
Lol
Wait-
await response.deferReply()
Try your best Sir Iโm driving
but you only need this is your response actually takes time
if you can respond immediatelly, just reply
Aha, but why was I not able to use .followUp?
because followup only works if you defer
just try to defer or reply first then use .followUp()
If u need so

Error [ERR_REQUIRE_ESM]: require() of ES Module node_modules/node-fetch/src/index.js from
not supported.
use node-fetch v2
or use const fetch = (await import("node-fetch")).default
Bruh..
Dude if you can reply to somebody pressing a button immediately then do it.
If you canโt you have to defer the reply to send your follow up message later on
Now question, isn't defer the reply and sending your follow up message is basically, two messages sent in a row?
No deferring is telling Discord to expand the lifetime of the webhook to 15 min instead of 3s
It is using for if codes take more than 3s to run
Tim still writing omg 
Ah, so now I understood. How exactly, in code, are you supposed to defer then follow up? Now I have the response as the button interaction object.
when you receive an interaction, you have 3 seconds to respond with one of these:
reply = respond immediately.
update = respond immediately by editing the message.
deferreply = respond with "i will respond later".
deferupdate = respond with "i will edit the message later".
if you defered it, you have 15 minutes to respond.
if you used deferreply, you can use reply
if you used deferupdate, you can use update
followup = respond to a defered interaction or to an already responded interaction
As I said if somebody is pressing the button you (await) defer the reply
Then later on in your code you send your follow up message if youโre ready to
If somebody is pressing a button and you only perform an action like deleting a message or anything else doesnโt take longer than 3 s, respond with a reply which is immediately
Ah, now this all makes sense. I remember in the slash commands whereas it would defer the reply, so I believe adding a line like
if (interaction.isButton()) await interaction.deferReply({ ephemeral: false }).catch(() => {});
.. would solve all the issues for my buttons, correct? (Confirmed after testing)
๐
Yup, but I defer replied it, anyway? .. if that's possible.
the messagecomponent helper methods are selfcontained
Thank you so much, Tim. I have every big note from you saved, mostly.
What do you mean, exactly?
awaitMessageComponent and ComponentCollectors do not need the interaction event
the interaction event does not affect them
Ah, but I added that line, it seem to solved the issue, though? Unless you're talking about something else.
you are just making it automatically defer all buttons
no matter where they came from
Isn't that good, or has a big downside?
if you use the helper methods, dont mix it up with the interaction event
otherwise you're working on the same thing from two different places, which will create a mess, and possibly race conditions (strange bugs depending on which happens to be executed first)
So instead of if (interaction.isButton()) await interaction.deferReply({ ephemeral: false }).catch(() => {});, I remove it and defer the reply manually?
Slash commands.
.. but yeah, removed.
its the same with reactions for example
you have awaitReactions and reactioncollector
and also the messageReactionAdd event
when you use reactions, you dont mix them up
you dont use both the messageReactionAdd event and awaitReactions for the same thing
How long are buttons actually triggering the event? Forever?
Ah, I see. (pinged, my bad)
Tim? Youโre aware of that?
Anyways, to handle each button alone. I define a message variable by sendnig a message and its buttons, create a filter to do a couple of checks, and a response variable to await the message component returning the button interaction object. We check if it is nulled (aka timing out), else checking the ID and performing an action in response.
That's it, right? ^
Now we did this all using messages, how does this differ from interactions (slash commands)? It's the same, right?
node:events:371
throw er; // Unhandled 'error' event
^
Error: socket hang up
at connResetException (node:internal/errors:691:14)
at Socket.socketOnEnd (node:_http_client:471:23)
at Socket.emit (node:events:406:35)
at endReadableNT (node:internal/streams/readable:1331:12)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
Emitted 'error' event on ClientRequest instance at:
at Socket.socketOnEnd (node:_http_client:471:9)
at Socket.emit (node:events:406:35)
at endReadableNT (node:internal/streams/readable:1331:12)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
code: 'ECONNRESET'
}
but the err is lil weird
@quartz kindle 
the other side disconnected u
afaik each button click generates a new interaction with a new token
not sure if there is any limit
there could be an age limit based on the message timestamp, but idk
thats what it sends when you defer
if you used deferReply you have to reply at least once
Ah.
i wanted to do a search bar using json (expressjs), but i have no idea how it works
someone help me?
errr...search bar using json?
Wait, I'm confused. How can I prevent the third message, again? I got a bit confused.
example json:
{
"search": [{name: "Staff", img: "./img1.png"}, {name: "Home", img: "./img2.png"}]
}
u mean return a json?
yes

KuuHaKu, are you experienced with slash commands?
only in java (jda)
๐
What? One time you tell me to defer and one time not, and one time it sends that random third thinking message and one time not, so I am not sure how I'm supposed to manage that.
I understand what defer does, so yeah. ๐ .. but I want to know why it sends that third line.
AYY
I took
Now leave
@drowsy crag
when you deferReply, it waits for reply
when you deferUpdate, it waits for update
so if you did deferReply once, you have to use reply once
no matter how many followups you do
one of your followups has to be a reply
.. and the same time, defer reply gives me more time?
How so, in slash commands, I never used deferReply ONCE, or is it because it responds in less than 3 seconds?
Could you check if my token arrived, I clicked.
Nevermind.
thats why i said
only use defer if you think it will take more than 3 seconds
otherwise just reply
I got lost in the code.
const m = await interaction.followUp({ content: 'Please select a button to perform an action.', components: [row] });
const filter = (int) => int.message.id === m.id && int.user.id === interaction.member.id;
const response = await m.awaitMessageComponent({ filter, time: 15000 }).catch(() => null);
if (!response) return interaction.followUp({ content: 'You have timed out.' });
switch (response.customId) {
case 'yes':
// await interaction.deferReply({ ephemeral: false }).catch(() => {});
await interaction.deferReply({ content: 'Hooray.' });
break;
case 'no':
// await interaction.deferReply({ ephemeral: false }).catch(() => {});
await interaction.deferReply({ content: 'Failed' });
break;
};
Should I send a message in the first line? .. or follow up?
try just reply
Interaction Already Replied
I didn't. Nvm, I did.
Alright. I currently made it so it sends a message and then the user picks a button. It deletes the message afterwards and follows up.
I'd like to ask.. now for this code that I sent..
https://sourceb.in/VCPmOXRGNo
You told me to use defer when it would take more than three seconds, now to use defer, do I just add
await interaction.deferReply({ ephemeral: false }).catch(() => {});
.. and what else, exactly? I reply, where? In the follow-ups? Like replacing those with follow up?
I promise this is the last question, I have over-disturbed.
Anyone know where this error is coming from?
/workspace/node_modules/discord.js/src/rest/RequestHandler.js:298
throw new DiscordAPIError(data, res.status, request);
^
DiscordAPIError: Invalid Form Body
message_reference: Unknown message
at RequestHandler.execute (/workspace/node_modules/discord.js/src/rest/RequestHandler.js:298:13)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RequestHandler.push (/workspace/node_modules/discord.js/src/rest/RequestHandler.js:50:14)
at async TextChannel.send (/workspace/node_modules/discord.js/src/structures/interfaces/TextBasedChannel.js:171:15) {
method: 'post',
path: '/channels/895641534823792671/messages',
code: 50035,
httpStatus: 400,
requestData: {
json: {
content: 'We all look at the world through our own eyes.',
tts: false,
nonce: undefined,
embeds: undefined,
components: undefined,
username: undefined,
avatar_url: undefined,
allowed_mentions: [Object],
flags: 0,
message_reference: [Object],
attachments: undefined,
sticker_ids: undefined
},
files: []
}
}
[nodemon] app crashed - waiting for file changes before starting...
From somewhere you have a text of We all look at the world through our own eyes..
I dont have it anywhere
Apparently vercel's own swr package supports nextjs ssr
I prefer react-query
but that's not going to give you caching
the caching swr and react-query have are all client side meant for deduplication
Using vercel's nextjs to host a website on vercel using vercel's swr
the vertical integration baby
With vercel analytics
// fast interaction
await interaction.reply(...)
// slow interaction
await interaction.deferReply(...)
await somethingSlowThatTakesMoreThan3Seconds(...)
await interaction.reply(...)
followups can be used anywhere after .reply
How, though, follow ups can be used anywhere?
You can't just do .followUp() and it's empty.. and for fast interaction, you can also use followUp, only, correct?
?
followups are just extra messages
if you ever need them
for example if your interaction reply needs 2 messages
because its too big for 1
OH.. but I have never used .reply() in slash commands, ever. ๐
then do
ye
discord.js is confusing af lul
i find it easier to use the raw api than discord.js lmao
.. I find it harder to understand.
It all started when they did the v13 ๐
I do, though?
ES6 is not for me
you mean ESM?
Alright, so I understood the idea. ๐
nobody actually uses ESM lul

ESM is so much better but node.js does it terribly
I don't get why you can't have both require and ESM
because of how esm works
require is sync, esm is async
esm relies on the entire process being compatible with its asynchronous multi-stage loading system
^
Error [INTERACTION_ALREADY_REPLIED]: The reply to this interaction has already been sent or deferred.
at CommandInteraction.reply (C:\Users\Utente\Desktop\novabot recon\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:89:46)
at Object.run (C:\Users\Utente\Desktop\novabot recon\SlashCommands\monete\lavoro.js:108:30)
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
[Symbol(code)]: 'INTERACTION_ALREADY_REPLIED'```
How can I fix this?
Don't reply if you already replied to the interaction. Edit the original response or create a follow-up message instead
ty
If I have a string to return from a slashCmd, i need only interaction.followUp
?
Sure, unless you want to edit the original response, then use https://discord.js.org/#/docs/main/stable/class/CommandInteraction?scrollTo=editReply
export default was the worst thing ever to happen to js change my mind
whats so bad about it lol

How do i update a role constantly?
So it will constantly chheck the new members.size
what do u mean by new members
i use !start
and want to check the members.size each 5 secondsd
if (minigame1.members.size == 5){
as the minigame1 role object only changes when !start is used
so i was thinking about a setinterval?
on the role defining
if(subcommand == 'start'){
let minigame11;
setInterval(() => {
minigame11 = guild.roles.cache.find(r => r.name === "old-wise-man-minigame")
}, 1000);
}
if (minigame11.members.size == 5){ //here
Why is this constantly throwin undefined errors?
in the last line
Post the error message
ye
`` if (minigame11.members.size == 5){
^
TypeError: Cannot read property 'members' of undefined``
sure
Well itโs gonna log as undefined
Because minigame11 is undefined
As the interval needs to start?
So could we fix it by addding a timeout?
As i have a reaction collector, that adds a role to users. But i need to actively check if 5 people have that role
but the role size doesn't update by itself, as it's under the !start command
that's why i was thinking about an interval to check
Can i just wrap my whole if() statement in a settimeout\
Mb cuz ur interval func starts after u check ur member size
till the interval gets it
why are you waiting 1 second to set minigame11?
It needs to check the member size each 5 seconsd
so a function can trigger
but in checks after 5 sec first time
then you need to do this:
let minigame11 = client.guilds....
setInterval(() => { minigame11 = client.guilds.... }, ...)
looks sturdy! Thanks
i mean that why it undefined in ur if statement
Should I make my bot use slash commands now as its a bot that likely will shutdown after christmas (seasonal bot)
it has no good reason to keep using message intents
if you're gonna shut down the bot after christmas then there is no need for slash commands
True
most people are still used to normal commands
also tru
Its a christmas bot which just plays christmas music
about normal
hey tim
if (minigame11.members.size == 5){```this still doesn't trigger
as it's under the !squidgame command, which is only fired once
awit it's not
it's under none
There isnt another way on activating slash commands without kicking the bot?
if the app has to post to the guild slash commands, no other way
You just have to reinvite the bot with the applications.commands scope
No need to kick it
client.on("ready", () =>{
client.user.setActivity(`${client.guilds.cache.size} server | ${client.users.cache.size} membri`);
console.log(`${client.user.tag} รจ pronto!`)
});
There is a way to actually update this?
What
uhm
in the bot activity
update the number of guilds and users
without reloading the bot
Yeah, use setInterval
Just be careful with spamming presence changes, the limit is 5 every 20 seconds iirc
setInterval(() => { client.user.setActivity(...) }, 20000)
ty tim
I knew this ๐
Luckily :/
(node:194) UnhandledPromiseRejectionWarning: MongooseError: Query was already executed: GSMData.findOne({ LOACode: 'LOA-7ONC' })
const loareq = await tickets.findOne({ "LOACode": code }, function (err) {
if (err) {
console.log(err)
}
})
if(loareq === null) return message.channel.send("Code does not exist in database.")
await tickets.deleteOne({ LOACode: code }, function (err) {
if (err) {
console.log("THIS ERRORS")
return message.channel.send("Ran into an error attempting to delete that LOA request.")
}
return message.channel.send("Deleted that LOA request from the database.")
})```
idk what that means im only running the query once
I wouldnโt call that a command handler since it does only load your files and stores the modules in your collection.
The actual handler manages the event, your commands and their execution as well as it should include a permission handler, maybe a guild or global command handler, a proper registration, update or delete handler of the commands itself etc.
Loading the modules is just, hmm, a small part of it.
Weew code blocks on mobileโฆ
As I said a proper handler also handles permissions etc.
Based on all the properties you provide in a command module
You should more likely think about to switch to slash commands before rewriting something you have to rewrite later againS
Slash command handler ain't bad
Slash command handlers are harder to understand than the current code I have
handling permissions is not really a must, depending on your bot
i dont bother with them lul
^
Yeah that fairly depends on your needs and commands
I got some commands configurating the bot on a guild which should only be possible for members which specific permissions
You can implement them from djs lib
But that doesnโt need to be the case for you
I mean if you wanna lock some commands to specific permissions and need to build a command handler anyways, these few lines checking for member permissions combining them with permissions set in the module isnโt complicated, just a few lines
The way discord let you handle or lock commands to user IDs is just trash in my mind
(or roles)
why do you want .env on github?
The way I handle that is by having a comment at the top of my code which shows what .env variables I need.
Or listed in the Readme without the actual values.
i keep my keys outside of the project
Only for the database I wrote some bash scripts to dump the tables and send them over via FTP
Actually not required for anything else tho
But Iโm old and tired you know 
I wonder how Tim must feelโฆ
thats how i feel ^
i finally got self hosting done with my raspberry pi, feeling pretty accomplished
nice
if(warnings === 1) return; {
const embed = new Discord.MessageEmbed()
.setAuthor(`Advertisement Deleted`, message.guild.iconURL())
.setDescription(` **-** \`Moderator\`: <@${message.author.id}>\n **-** \`Reason\`: ${reason}\n **-** \`2nd Warning\`\n\n> Please make sure to read: [#765952677213110272](/guild/264445053596991498/channel/765952677213110272/)! `)
db.add(`warnings_${user.id}`, 1)
channel.send(`<@${user.id}>`)
channel.send(embed)
}
if(warnings === 0) return; {
const embed = new Discord.MessageEmbed()
.setAuthor(`Advertisement Deleted`, message.guild.iconURL())
.setDescription(` **-** \`Moderator\`: <@${message.author.id}>\n **-** \`Reason\`: ${reason}\n **-** \`1st Warning\`\n\n> Please make sure to read: [#765952677213110272](/guild/264445053596991498/channel/765952677213110272/)! `)
db.add(`warnings_${user.id}`, 1)
channel.send(`<@${user.id}>`)
channel.send(embed)
}```
This is my code, when I do the command, it sends both 1 and 2, meaning it sends both of the embds, I want it to only send the #1 embed which is the bottom one, then when the Staff Member runs the command again, it goes to the top #2 embed, how do I do this?
So first time they use the command it adds 1 warning to the DB then sends the embed
The 2nd, it adds the users warning to the DB and sends the top embed.
Why do you need two embeds for this anyway?
You dont need two embeds for that or two sends. You only need to set each description separately(or use tenorary and do it in one).
Then add the send to the end
Also you have a return in the first if statement
const embed = new Discord.MessageEmbed()
.setAuthor(`Advertisement Deleted`, message.guild.iconURL())
if(warnings === 1){
embed.setDescription(...)
}
else if(...){
...
}
channel.send(embed);
or
const embed = new Discord.MessageEmbed()
.setAuthor(`Advertisement Deleted`, message.guild.iconURL())
.setDescription(`${dynamic stuff} static stuff`)
channel.send(embed);
or
const embed = new Discord.MessageEmbed()
.setAuthor(`Advertisement Deleted`, message.guild.iconURL())
.setDescription(warnings ?? desc0 : desc1)
channel.send(embed);
So, would I need warnings === 0 or would I want that to be one?
Cause I want it to send a initial message
Wait nvm
Personally the middle method(its called template litterals) makes the most sense to me.
Did for me! Tysm!
``num = int(input("Enter the number to check it is prime or not\n"))
for digit in range(2, num):
if num % digit == 0:
print("Not a prime number")
break``
now here i wanna add a reply for
Is a prime number
so how can we add in this existing code
i want to add for a reply that the number is prime
I don't even mean to disregard that code, I literally don't understand it 
wtf
Just do num % 2
f=0
if num==1 or num==0:
f=1
for i in range(2,num):
if num%i==0:
f=1
if f==1:
print("Number is not prime")
else:
print("Number is prime")```
although did with this
still..
Overcomplicating
it may be possible that no is divisible by 3
Yeah okay
Just add an else branch to the if
...
No, I need to get my shit together
Use some sort of variable, type bool possibly
flag probably. Default it to False and in your if, set its value to True so that it indicates that the number is prime
Then later in the code add another if-else that actually works with that variable and outputs "Prime number" if it's True
||Found this on Google for you:https://www.programiz.com/python-programming/examples/prime-number||
thanks buddy for the help
Uhm hey, when I uploaded my code for my bots website on to my topgg page
I am not sure where to place the css
Like:
<style>
my CSS stuff
</style>```
But nothing showed up like none of the CSS
Or is there a different way of adding it
@ripe prairie
Error: Unsupported state or unable to authenticate data What does this mean?
Snippet:
const msg = await interaction.deferReply({ embeds: [embed] }).catch(err => console.log(err));
for (i = 0; i < 3; i++) {
await msg.react(emojiArray()[i]).catch(err => console.log(err));
}โโ```
Error:
```TypeError: Cannot read properties of undefined (reading 'react')
at Object.execute (F:\VOTIFY_new\commands\ynpoll.js:57:23)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Client.<anonymous> (F:\VOTIFY_new\index.js:192:16)
F:\VOTIFY_new\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:89
if (this.deferred || this.replied) throw new Error('INTERACTION_ALREADY_REPLIED');
^
Error [INTERACTION_ALREADY_REPLIED]: The reply to this interaction has already been sent or deferred.
at CommandInteraction.reply (F:\VOTIFY_new\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:89:46)
at Client.<anonymous> (F:\VOTIFY_new\index.js:195:22)
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
[Symbol(code)]: 'INTERACTION_ALREADY_REPLIED'
}```
Help me in reacting to interactions
What is emojiArray()
Otherwise msg will always be undefined
And for the other error, don't reply twice
Edit the initial response or create a follow-up message
That's declared correctly outside this snippet
I just want to react with multiple emojis
Once the interaction is replied with
whats this now
./Commands/ping.js
const discord = require('discord.js');
const { SlashCommand , CommandOptionType, CommandContext} = require('slash-create');
module.exports = class ping extends SlashCommand
{
constructor(creator){
super(creator, {
name: 'ping',
description: 'Replies with the Bot and the Api latency. Nothing Special.'
})
}
async run(ctx){
const ping = 'Pong!'
return ping
}
}```
index.js
const fs = require('fs');
const { SlashCreator, FastifyServer } = require('slash-create');
const discord = require('discord.js');
const intent = new discord.Intents(32767);
const client = new discord.Client({intents: intent});
const config = require('./config.json');
const clientToken = config.token;
const prefix = config.prefix;
const ApplicationId = config.applicationId;
const PublicKey = config.publicKey;
const path = require('path');
const creator = new SlashCreator({
applicationID: ApplicationId,
publicKey: PublicKey,
token: clientToken
});
creator.on('commandRun', (command, _, ctx) => {
console.log(`${ctx.user.username}#${ctx.user.discriminator} (id: ${ctx.user.id}) just used ${command.commandName}!`);
let totalCommands = config.commandsUsed;
totalCommands += 1;
});
creator.on('commandError', (command, error) => {
console.log(`Unable to run ${command.commandName}! The error is given below. \n Error: ${error}`);
});
creator.withServer( new FastifyServer())
creator.registerCommandsIn(path.join(__dirname, 'Commands'))
creator.syncCommands()
creator.startServer()
client.login(clientToken).then( _ => {
console.log('Successfully logged into the Client!');
});
gamer forgot to unlock channel
hi gamers
hey, how do i stop a code from moving on as an alternative of timeout?
run code1
-the block-
run code2```
As i don't want to wrap the whole code2 function in my settimeout.
Someone know how bot leave a server less tha 25 or 30 members,?
Check the member count
I mean what is the code
What library are you using?
Js
I see
@pale vessel like i want to leave bot which less than 30 members
Fix what?
u shouldn't ask for a copy-ready code
canale.send not message.canale.send
- get member count
- check if it's larger than 30
--> if yes: leave guild
--> if no: nothing
there we go
now just translate that into code through using the discord js docs
errr...invert ur boolens
discod.js
Discord.js-light
detritus.js
Hello how do you add a website to the bots page not editing the bots page
<iframe> on longdesc
ohh
discod*.js-light
because codfish
i know i am funny
Couldnt understand bc i am away from english culture
<iframe>
html code?
</iframe>
i did that but its not showing up?
that's....idk how to explain how wrong that is
iframe is a "window" to another site
so in iframe, there needs to be a domain?
ye
you can do iframe without domain
u CAN use raw ips, but...well...yk
you can iframe code
<iframe srcdoc="HTML CODE HERE"></iframe>```
ohh
inline html be like
or just use something like github pages, vercel or dbot.cc
then its a proper iframe
html code iframes suck
ah
This ^^
oh boy, if it was that easy
We can give you the general idea and help with specific parts of implementing it, but we will not give you the whole thing
I'd hate programming
You just get the vote timestamp from the vote event and store the ID and timestamp in your database. Then check it for expired votes.
i just need vote reminder
My point still stands
i just need a little code of it
Which part exactly?
@deft citrus ^
i dont understand
๐ข
Look into cron jobs
yeah
Look at your lib's docs
You'll have an on_message event handler for that case
i have it
but i dont know the code
Do you want it to be a command or just some sort of "random message" the bot will reply to as non-command?
for dm a user
command
command in the first part refers to the commands framework of d.py
I assume you're familiar with the commands framework?
ctx in commands is a Context object, which happens to implement an attribute named author as a shortcut for <Context>.message.author
client.command()
async def vote(ctx):
await ctx.send('Vote use here')
Meaning, to get the user who used the command, you refer to ctx.author. That will be an instance of either User or Member, but both implement Messageable, meaning you can use .send() on both of them
ctx.send will reply in the channel where the command was used
yes
ty
vey much ty it worked by ctx.author.send


oh hecc this development
@slender thistle i need 1 more help
how to set a time for dm
means it should dm every 12h
ty
does having some custom background means the website you wont show in <iframe>?
You're gonna have a database to save last time you DM'd the user and probably work with d.py's tasks framework for that
@slender thistle await asyncio.sleep(5) how to write that 5 in hrs
Calculations, math
I feel like you might be missing some of the basics of python at this point
^
making discord bots is cool but you're going to have a hard time running into a wall at every step like this
Yup
pretty self explanatory, need to see the code tho
If you put the sleep in the command, take a guess
bot.command()
async def vote(ctx):
await ctx.author.send('Vote use here')
await asyncio.sleep(5)
will it work
forever
you have commands defined as bot.commands but you're trying to reference commands here which doesn't exist
that first error message is like pretty obvious
wdym "forever"
means every 5 second it will dm
No
how to make it like that
It will DM once, and not even after waiting
Because you put the sleep after the .send part
if i add it before .send
Then in the future fetch the registered commands, compare them with your loaded ones to check if your commands need to be registered, updated etc.
Get a hang of Python itself first please
There's nothing indicating it will do it repeatedly
Instead of copy and pasting the guide ugly example, just use djs inbuilt class and methods

maybe don't blame your lack of experience on slash commands
Well Iโm okay with it, later on registering global slash commands over and over again will overwrite existing ones causing your bot to not be able to deal with slash commands for up to an hour until they are deployed in any guild
hilarious
Which means like a full hour of interaction failed messages anytime you start your app
As discord states handling registrations accurate in the future will become important
Which maybe means spamming the API with registrations for the same commands for no reason might get you rate limited, locked out, banned etc. in the future
Enjoy your performance drops
i think they fixed the performance issues
AMD hardware gets hit pretty hard by win11
A shithole full of hardcoded stuff you canโt manipulate through registry or group policies anymore, thatโs what it is
Thatโs already available for Windows 10
You just have to install it yourself
Wow they are capable of improving things? Wut
anyone help me to make a reminder that reminds the people every user that use the command'
People can help you if you have issues with figuring out the implementation, but I donโt think anyone here is going to just write your code for you if thatโs what youโre asking
Meanwhile the whole shit they are carrying around since Win 7, or 8 is still running in the background as well as any old app to manage your PC just harder to find
no i just need wht command is used for reminding them every 12hr
Iโm not a fan and will never be but yeah
I still donโt understand what youโre asking
i'm sticking with windows 10
try linux
no thanks
its good
client.command()
async def vote(ctx):
await asyncio.sleep(5)
await ctx.author.send('vote here')
i'm not interested in coding a browser
rlly good
how to make it forever

Yeah after killing each telemetry endpoint, blocking any sort of non security updates, modifying it a little Windows 10 is actually pretty good
i think microsoft already patched most vulnerabilities that were found
@wheat mesa hello
I know very little about python
Iโm not speaking snakish either
client.command()
async def vote(ctx):
await asyncio.sleep(5)
await ctx.author.send('vote here')
how to make it run forever
like it should dm the person every 12h
Thatโs almost a bad idea
Considered spam as more people will receive a message
Users typically donโt like random bots DMing them on a schedule about what I assume is an ad to vote for it
not like this
if they run comand ^vote remind
understand
not spam
If you do not have the chance to opt out of that itโs just spam
id understand
kind of against tos? what if the people who vote at the same time keep getting the message at the same time?
bro if they type command ^vote remind
bro if they run command ^vote remind
oh if they do the command
Even then imagine sending 1000 users a message every 12 hours, around the clock somewhere, itโs still end up being API spam
i was thinking like right after they vote they recieve the message
Sending a reminder once is okay not forever
every 12h
they can stop
it
also
not that it should dm the person
In theory you could schedule it for 12 hours after the command is run, that user gets a DM
yes
how
But if you plan to send the messages all at once, then thatโs gonna be an API problem
oh
yeah discord will throw a shit fit over api issues
Even then imagine sending 1000 users a message every 12 hours, around the clock somewhere, itโs still end up being API spam
Thatโs what I stated already
Youโd have to store a timestamp of 12 hours after the time of the command being run along with the user id, then once that timestamp is hit then you send the message to them
Still wouldnโt recommend it though
okay i understand
Not sure how to implement that in python
i will make two types of comand
vote remind
and
direct it will dm
the
person
if they run the command
^vote
and ^vote remind
it will remind the person 1 time
and if the person type the command again
after 12h
then again after 12h he will recieve dm
of voting
60X60
=
3600
3600x12
=
Well itโs your decisionโฆ doesnโt change the fact we canโt help you out with python
I'd use Json
{
"userid": "Timestamp"
}```
43200
then do a commands.tasks.loop
json isnโt good for writing and reading lots of data as a db
Probably best to just use an actual db with K/V pairs
any DB works
I know how to do time checking
huh JSON is not a database 
^^
I just recommended JSON as thats what I have used before with a feature similar to this
it stored the time from datetime.time.now()
When you have a large JSON file with lots of data itโs better to just use a database
and then would check every 60 seconds if datetime.time.now() had X second difference and reset if so
Tbh if so I would also use the timestamp as key, not as value checking each process tick if that key exists, if so use itโs value
Which in this case storing data for 12 hours, json may be suitable for a small bot, but if it gets larger then a db is a much better option
Which is more cost efficient
ah I should really move to a different method of storing then lmao
how to add good frame
I store over 1k blacklisted user ids in a json 
good frame?
ye
what do you mean by that-
like when we type .help
oh like an embed?
embed = discord.Embed(title="Embed Title")
embed.add_field(name="Command name", value="command description")
await ctx.reply(embed=embed)```
Play around a little with it
add embed.add_field(name="Command name", value="command description") for every command you have etc
or just use the embed generator FakE sent
Itโs actually good to understand how to format (style) and build your embed
Wellโฆ you may wanna move to database, too in the future
Or move to a less destructive format
Databases are pretty easy to set up
Might use Mongo
Just gotta make sure to implement a cache if youโre querying for information fairly often
CSV might also work for some time until it reaches a specific size
I also have MySQL but hosted on a webserver so it may be slower
and I don't want my API to be slow
Ew ew ew ew ew ew ew
MySQL sucks ass
MySQL ๐คข
Actually not, no
DB options I have on cPanel
If you can ever reach its limits, tell me
Use Postgres or Mongo
Shhhh Java user, go on, Sir
Iโm not a Java user!
Just use Java from time to time
I much prefer c++, typescript, and C# over Java
From time to time? Thatโs even worse.
Thought you just touched it once by accident
But that changes everything

My CS classes all use Java sadly
My class doesnt know even programming langs lol
Our teacher told us today that js arrays start from 1
wtf
Tell her to do a different class
She teaches Java
Not her job to know Javascript but also not a good idea to tell kids stuff about js if she isnโt sure about it
bed teacher
:^)
Thought about saying boy, but no, not for you grandpa
Iโm at school looking at C++ stuff and a website I was looking at just got blocked in the middle of me looking at it
Nice ๐
Because itโs a โForum/Message boardโ
lmao
Back when I was young, playing Medal of Honor on a school PC, after "hacking" the administrator account (on XP), just by reading the password written on the note, sticking on the school server and nobody closed the door, because the room got to hot for the servers

people text nsfw such as the f word
hello how increase size of image in html js <img src="https://images-ext-1.discordapp.net/external/gF0US_OD9LvVWMeHwHApjHIJ_Up6wn26jkBLGO6SaSk/https/media.discordapp.net/attachments/858687192099454979/896262275273482260/standard_3.gif" >
the image size or the displayed size?
if you want to make it look bigger you can use the width and height attributes
done
<img width="69" height="420" />
done
already rember now
ok
Oh no... not float!
You better use CSS here to scale up, keep aspect ratio
there's a property called aspect-ratio but idk if it's supported in many browsers
I meant working with width and height as well but entering % as values
Like 110% width and height to keep the ratio
oh
If you specify an URL
can we change color gray to yellow or blue
F
what are you using to make the text look like that
`
you can style the <code> element
@boreal iron what is author link icon
any example
that is the url to author image
means
spoonfeeding
<style>
code {
background-color: smth;
}
</style>
An icon above the title left of the author
hmm thanks
Error: Cannot find module 'quick.db'
cough PHP
by learn ejs
bruh
that is appearing like flash destroying the console
my bot suck on approve from 17 days
I've already got a working HTML site which I have setup with Flask but I want to run on root domain and on a webserver rather than using Replit
No idea how to use PHP lmao
Then install it?
Patience, Sir
yeah it's installed
Back in the past it took months
idk why appears
you setup slash handler?
???
i checked the package.json, reinstalled and all that but same
any solution?
you make slash commands?
how?
Go on Mr. Erwin
when even npm is anti detritus
can you show your bot
It's too complex for you mortal djs minds to understand
It's a private bot
lmao
using a template language calling it complex

oh it mean you are lucifer
What in the...
empty responses is one of detritus's special powers
You better switch to PHP now
I don't watch Netflix except for stranger things and squidgame
are you still watching?
I'm waiting for 4th season
3rd season was disappointing
@quartz kindle hi
woow, double ping, scary
@boreal iron bro
Dude, not needed to ping me, I can't help you with python, still
That hasn't changed the last 30 min
client.remove_command("help")
or bot.remove_command("help")
ty
If you using Python
Lol python is so easy
yup
On js
client.application.commands.delete(command.name)
Than its being much hard
name is the command's identifier
Than
But not it's ID, just the object key
never gonna understand their logic
like, aren't names supposed to be unique already?
let cmd = await client.application.commands.fetch()
let c = await cmd.find(c => c.name === "help")
client.application.commands.delete(c)
Yes i forgot ()

@quartz kindle I need help
I have a bunch of <figure> elements inside a <section> on a page and I want the tab key to go through each of those elements
but it instantly jumps to the <a> tags of the page <footer>
You could have a guild and global command with the same name on the same app
working
do you mean like
t 1
t 2
t
t
t {
}
hm true true
hmm could I use a <ul> and remove the bullets with css
Send a screenshot of the code
I didnt fully get what you wanna do
press tab and it jumps to the page bottom
instead of going to React
I am on phone

And did you try using js ?
tabKeyDown => window.location.href
I don't see <figure> anywhere?
oh I'm blind
screen readers and other stuff don't work with js
there are over 100 html semantic elements so you don't have to use js for accessibility
Its your choice
I don't even know if js can be used for accessibility
Dont you wanna go a part of site when you press tab?
You don't need JS for that
But can use
I found the tabindex attribute
apparently that's all I needed to make it "tabbable"
tabindex is the most misleading attribute name in history
because it's not an index, it's either a 0 or a -1 lol
and you're not actually supposed to set it to anything other than 0
@earnest phoenix problem solved in one line of html with no js (technically this is react but you get the point):
<figure
+ tabindex={i + 1}
/>
No i didnt get it bc i just know react's name lol
ya that causes issues for screenreaders. Just set them all to 0 and make sure the tabbable elements are rendered in sequential order
wat
read up on the MDN page
they're in two different sections but in sequential order
you should be able to set it all to 0 then and they'll become tabbable
once it reaches the end of the first section's children it will move to the next right?
yeah it moves to the next tabindex element on the page regardless of the value you give it if they're all 0, that's why tabindex is kind of misleading. Anything above or below 0 is problematic for screenreaders
works and also if you click anywhere inside the section and press tab it moves to the first element of that section
yeah it's complex enough to be people's entire job descriptions lol. It's important though
i dont have time
Can you edit a follow up message?
anyways I have another question:
in nextjs I can put styles for individual pages with [name].module.scss
but I have to put the style name in a template string everytime as they're generated at build time with weird names:
- import "styles/index.module.scss";
+ import { skill } from "styles/index.module.scss";
<figure
- className="m-4 has-text-centered skill"
+ className={`m-4 has-text-centered ${skill}`}
/>
any way to use the normal class name but still have class name override protection with css modules?
are you using bulma with css modules?
yes
I imported it in the global stylesheet and then added my custom styles in scss modules
how do I check if a promise still hasn't been resolved?
I don't think there's a property for that
But you can try this
Hope this helps too.
https://stackoverflow.com/questions/36294109/how-to-check-if-a-promise-is-pending
^^ more complicated, visit 1st link better by code913.
nah you're methods better
Promise.allSettled will wait for all promises to resolve first

