#development
1 messages · Page 1930 of 1
I'm learning!! Ayo @solemn latch (ik ur a mod and you don't like pings), but I have been striggling with Slash Commands for the longest time, this fr helped me out SOO MUCH! Your awesome.
opening a DM with Woo
lol, Tyty
you are always allowed to dm me
just not for dev help 😄
Time to create a new discord bot today!
nice
What theme?

Still thinking about that
among us imposter theme
:C
@sudden geyser I know what Theme Im doing
Klay Im doing a YouTube Notification bot
for my servers YouTube channel
Are you sure you want to do that? There are many bots that offer that feature already.
I want to make my own that i change anything on it
https://media.discordapp.net/attachments/911649508495077509/914582671806562407/MemberInfo.png
replace ms to hour on chartjs-node-canvas
Object.values(StatsTop).map(r => {
DateChart.push(moment(r.date).format('YYYY/MM/DD'))
VocalChart.push(r.voice)
})
var configuration = {
type: 'line',
data:{
labels: DateChart,
datasets: [
{
label: "Vocal Hour",
data: VocalChart,
backgroundColor: '#dc143c'
}
]
}
}```
@sudden geyser Nvm my bot won't turn on gotta scrap this on
Plus i thought I don't know anything about integrating youtube with a discord bot
WAIT
WAIT
I FOUND SOMETHING I MISSED
Hey guys I got this error how do i fix it?
You're missing the start script in your package json file
How do I put that in?
Thanks
You should always use npm init -y to initialize a new project.
That will create a package json for you
Know what Ima go Use my Other bot for music while i code my other bot

No i have 1 bot on 24/7 for music auto moderation and fun and games
I'm working on a 2nd bot
there's bots that are amazing at one thing
multi purpose bots that are mediocre at everything
and then there is you
with both of them
Yes
lol i typed dubstep wrong
it still knew what song i wanted
forgot i need to sign back into github
Just wondering. Would a /lastseen or !lastseen command that displays the time when a user sent a message last/was last online?
is that a question..?
I mean there is clearly a question mark, but I don't get the question tho 😅
ig he forgor the question terminator
like "Would X be useful?" instead of "Would X?"
If you mean "Would a /lastseen command that displays the last time a user sent a message or was online be useful?", that's subjective and up to you. I wouldn't find it useful, but someone else may. It would probably be better in a /user info command though.
I meant adding the details to a more general command (/user info, which displays other stuff)
which could include the last time they were seen?
it is user information after all
Just read over it and realised it doesn’t make sense, I was trying to ask if a /lastseen command that displays when a user was last online/sent a message is possible or not?. Sorry for the confusion
I used to have that for my bot until discordjs fucked mentions
You'd need to record when your bot last "saw" that member. For example, tracking messages and their online status to update state.
It's not baked into the API, but certainly possible.
Noted. Thanks!
Heya, how would I import clean_code. It says it isn't a module.
A file by that name probably doesn't exist or its path is wrong
I thought you were going somewhere else with that
and then there is you
bad at both
jack of all trades, master of none
Ppp
i have a configuration like this for my slash command
"name": "config",
"description": "Customize.",
"options": [
{
"name": "server",
"type": 2,
"description": "Customize server.",
"options": [
{
"name": "matchmaking",
"type": 1,
"description": "Customize matchmaking for you server.",
"options": [
{
"name": "visibility",
"description": "Matchmaking Visibility.",
"type": 3,
"choices": [
{
"name": "Public (Default)",
"value": "public"
},
{
"name": "Private",
"value": "private"
}
]
}
]
}
]
}
]
}```
The options come in looking like this ```{
"options": [
{
"name": "server",
"options": [
{
"name": "matchmaking",
"options": [
{
"name": "visibility",
"type": 3,
"value": "public"
}
],
"type": 1
}
],
"type": 2
}
],
}```
but all i care about is ```{
"options": [
{
"name": "visibility",
"type": 3,
"value": "public"
}
]
}```
If i refactor the group names then the options change making my code coupled to the group and subgroups. is there a good way to get around this? i was thinking about writing a marshaler that dynamically traversers the options and finds the actual options. any other ideas?
import java.io.IOException;
import java.util.Scanner;
public class AppPilotos {
public static void main(String[] args) throws InterruptedException, IOException {
final int MAX_ELEMENTOS = 20;
int opcao, qtdCadastrados = 0;
String[] pilotos = new String[MAX_ELEMENTOS];
Scanner in = new Scanner(System.in);
int x;
String nome;
int cpf;
int localCPF;
do {
System.out.println("\n****\nMENU\n****\n");
System.out.println("1 - Cadastrar piloto");
System.out.println("2 - Listar pilotos cadastrados");
System.out.println("3 - Localizar piloto pelo CPF");
System.out.println("4 - Aumentar espaço de armazenamento");
System.out.println("0 - Sair");
System.out.print("Opção: ");
opcao = in.nextInt();
in.nextLine(); // Tira o ENTER que ficou na entrada na instrução anterior
if (opcao == 1) {
// Se não tem mais espaço no vetor, caio fora
if (qtdCadastrados == MAX_ELEMENTOS) {
System.out.println("\nNão há espaço para cadastrar novos pilotos.");
voltarMenu(in);
continue;
}
//Cadastre seu piloto aqui
if (qtdCadastrados < MAX_ELEMENTOS) {
System.out.println("\nQual o nome do Piloto: ");
nome = in.nextLine();
cpf = qtdCadastrados;
pilotos[qtdCadastrados] = nome + qtdCadastrados;
System.out.println( "\nNome: " + nome +"\nCPF: "+ cpf);
qtdCadastrados = qtdCadastrados + 1;
}
System.out.println("\nPiloto cadastrado com sucesso.");
voltarMenu(in);```
// Se não tem ninguém cadastrado no vetor, caio fora
if (qtdCadastrados == 0) {
System.out.println("\nNão há motoristas cadastrados para exibir.");
voltarMenu(in);
continue;
}
if (qtdCadastrados > 0) {
// Exiba os pilotos aqui
System.out.println("\n Pilotos cadastrados \n");
for(int posicaoPiloto = 0; posicaoPiloto < qtdCadastrados; posicaoPiloto++){
System.out.println(pilotos[posicaoPiloto] + " - CPF: " + posicaoPiloto);
}
}
voltarMenu(in);
} else if (opcao == 3) {
if (qtdCadastrados == 0) {
System.out.println("\nNão há pilotos para serem localizados.");
voltarMenu(in);
}
if (qtdCadastrados > 0){
System.out.println("\nQual o CPF do piloto: ");
localCPF = sc4.nextInt();
System.out.println("\nPiloto com o CPF " + localCPF + " é o: " + pilotos[localCPF]);
}
voltarMenu(in);
} else if (opcao == 4) {
System.out.println("\nQual sera o novo tamanho do armazenamento: ");
x = in.nextInt();
String[] pilotos2 = new String[x];
System.arraycopy(pilotos, 0, pilotos2, 0, qtdCadastrados);
System.out.print("\nArmazenamento aumentado!");
voltarMenu(in);
continue;
}
else if (opcao != 0) {
System.out.println("\nOpção inválida!");
}
} while (opcao != 0);
System.out.println("Fim do programa!");
in.close();
}```
private static void voltarMenu(Scanner in) throws InterruptedException, IOException {
System.out.println("\nPressione ENTER para voltar ao menu.");
in.nextLine();
// Limpa toda a tela, deixando novamente apenas o menu
if (System.getProperty("os.name").contains("Windows"))
new ProcessBuilder("cmd", "/c", "cls").inheritIO().start().waitFor();
else
System.out.print("\033[H\033[2J");
System.out.flush();
}
}```
thats it
I'm having problems with the "pilots" array. Its limit is 20, and I have "option 4" which has the functionality to increase it, in this case I create a new array, copy the values from the old one and put it in the new one. But apparently, the other options in the code do not use it, what should I do?
how does this look?
const x = {
"options": [
{
"name": "server",
"options": [
{
"name": "matchmaking",
"options": [
{
"name": "visibility",
"type": 3,
"value": "public"
}
],
"type": 1
}
],
"type": 2
}
]
}
const cleanOptions = options => {
if (!options.options) {
return options;
}
return cleanOptions(options.options[0]);
};
console.log(cleanOptions(x))
It looks fine
I found the options structure limiting as well
So I made some functions to conveniently extract values
But it didn't rely on recursion like yours did
Can I make it so what a slash command can only be used by a specific number of users.
Yours is probably better since subcommands and subcommand group options are quite static
you can use a database to do that
that one is actually broken
i have another fix
aw
How can I make a function when someone vote my bot ?
works
const x = {
"options": [
{
"name": "server",
"options": [
{
"name": "matchmaking",
"options": [
{
"name": "visibility",
"type": 3,
"value": "public"
},
{
"name": "visibility",
"type": 3,
"value": "public"
}
],
"type": 1
}
],
"type": 2
}
]
}
const cleanOptions = options => {
if (!options[0].options) {
return options;
}
return cleanOptions(options[0].options);
};
console.log(cleanOptions([x]))
Broken version
const x = {
"options": [
{
"name": "server",
"options": [
{
"name": "matchmaking",
"options": [
{
"name": "visibility",
"type": 3,
"value": "public"
},
{
"name": "visibility",
"type": 3,
"value": "public"
}
],
"type": 1
}
],
"type": 2
}
]
}
const cleanOptions = options => {
if (!options.options) {
return options;
}
return cleanOptions(options.options[0]);
};
console.log(cleanOptions(x))
the command will still show up for everyone though
ejs newbie here... For some reason CSS is not being applied on my page, when my head.ejs is as follows: ```html
<meta charset="UTF-8">
<title>WaffleBot</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@200;500&display=swap" rel="stylesheet">
<link rel="stylesheet" href="../../styles/style.css">
<script src="../../src/index.js"></script>
and my `index.ejs` imports `head.ejs` ashtml
<!DOCTYPE html>
<html lang="en">
<head>
<%- include('../partials/head'); %>
</head>
<body>
<header>
<%- include('../partials/header'); %>
</header>
<main>
<div>
<h1>Test</h1>
<p>Test2</p>
</div>
</main>
<footer>
<%- include('../partials/footer'); %>
</footer>
</body>
</html>
as a basic test, my style.css is just ```css
body {
background-color: #343434;
margin: 0;
}
any errors in the network tab?
yeah, I got a 404... Interesting
probably off by a directory
../../styles/style.css
maybe an absolute reference would be better
Oh yeah you're right, I'm starting the program from a different directory haha
stupid relative paths
well thats great my dashboard is experiencing 2 304'S
even with this cleanOptions function, i'll still need to route the options to a function. and to do that i'll need to look at the group and sub group, which means my code is still coupled to the groups
nm, all my command names are unique so i can just ignore the groups.
is it bad that my bots dashboard is at 5000 MS!?!?!?!
I've changed it to use absolute paths now, but the console is telling me localhost/:10 Not allowed to load local resource: file path
Is there something I'm missing here? Whenever I was using raw html/css I didn't ever have this problem
wdym
It's a local CSS file on my pc
My project is structured like this, and I'm loading the CSS file the way I would normally do it. Although a big difference between what I normally do is that I'm using express now
I'm gonna take a break and come back to this later
How about an easier (but more wasteful?) solution, such as recursively changing the options array to a map of the names as keys?
const x = [
{
"name": "visibility",
"type": 3,
"value": "public"
},
{
"name": "voice-channels",
"type": 3,
"value": "enabled"
}
];
console.log(x.reduce((acc, val) => ({...acc, [val.name]: val}), {}))
{
visibility: { name: 'visibility', type: 3, value: 'public' },
'voice-channels': { name: 'voice-channels', type: 3, value: 'enabled' }
}
i added the full clean options function here
Welp, I'm back again.
const { SlashCommandBuilder } = require('@discordjs/builders');
const Discord = require('discord.js')
const wait = require('util').promisify(setTimeout);
const { Client, Intents, MessageActionRow, MessageButton, MessageEmbed, MessageSelectMenu } = require('discord.js');
const cool = new Client({
intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES],
});
const { r1 , r2 ,r3 ,r4 , r1m , r2m , r3m , r4m } = require('../config.json')
module.exports = {
data: new SlashCommandBuilder()
.setName('roles')
.setDescription('Dropdown!'),
async execute(interaction, message) {
const rw = new MessageActionRow().addComponents(
new MessageButton()
.setCustomId("r1")
.setLabel("Role 1")
.setStyle("DANGER")
.setEmoji(r1m),
new MessageButton()
.setCustomId("r2")
.setLabel("Role 2")
.setStyle("DANGER")
.setEmoji(r2m),
new MessageButton()
.setCustomId("r3")
.setLabel("Role 3")
.setStyle("DANGER")
.setEmoji(r3m),
new MessageButton()
.setCustomId("r4")
.setLabel("Role 4")
.setStyle("DANGER")
.setEmoji(r4m),
);
const roles = new MessageEmbed()
.setColor(`AQUA`)
.setTitle(`Roles`)
.setDescription(
`Take your roles by clicking on the corresponding buttons!\n Click on them again to remove them!`
);
interaction.reply({ embeds: [roles], components: [rw] });
}
}
cool.on("interactionCreate", async (interaction) => {
if (interaction.isButton()) {
if (interaction.customId == "r1") {
if (interaction.member.roles.cache.some((role) => role.id == r1)) {
interaction.reply({
content: `The role <@&${r1}> was removed from you`,
ephemeral: true,
});
interaction.member.roles.remove(r1);
} else {
interaction.member.roles.add(r1);
await interaction.reply({
content: `The role <@&${r1}> was added to you`,
ephemeral: true,
});
}
} else if (interaction.customId == "r2") {
if (interaction.member.roles.cache.some((role) => role.id == r2)) {
interaction.reply({
content: `The role <@&${r2}> was removed from you!`,
ephemeral: true,
});
interaction.member.roles.remove(r2);
} else {
interaction.member.roles.add(r2);
await interaction.reply({
content: `The role <@&${r2}> was added to you!`,
ephemeral: true,
});
}
} else if (interaction.customId == "r3") {
if (interaction.member.roles.cache.some((role) => role.id == r3)) {
interaction.reply({
content: `The role <@&${r3}> was removed from you!`,
ephemeral: true,
});
interaction.member.roles.remove(r3);
} else {
interaction.member.roles.add(r3);
await interaction.reply({
content: `The role <@&${r3}> was added to you!`,
ephemeral: true,
});
}
} else if (interaction.customId == "r4") {
if (interaction.member.roles.cache.some((role) => role.id == r4)) {
interaction.reply({
content: `The role <@&${r4}> was removed from you!`,
ephemeral: true,
});
interaction.member.roles.remove(r4);
} else {
interaction.member.roles.add(r4);
await interaction.reply({
content: `The role <@&${r4}> was added to you!`,
ephemeral: true,
});
}
}
}
})```
No error in logs, just this interaction failed
I was thinking more like this:
function re(data) {
// Implementation is probably broken
data.options &&= Object.keys(data.options).forEach((k) => {
data[k] = re(data[k]);
});
return data;
}
It doesn't extract the options like you originally wanted, but it does make working with options much simpler (data.options.server.options.matchmaking.options.visibility.value vs. using .find).
@solemn latch ^ You said to lyk if I needed anymore help :)
Try adding an interaction reply after the last ID if statement
What would it reply to?
Doesn't matter tbh, just checking if it's an if statement issue
So like
} else {
interaction.member.roles.add(r4);
await interaction.reply({
content: `The role <@&${r4}> was added to you!`,
ephemeral: true,
});
interaction.reply({ content: `Testing123`, ephemeral: true, })
?
At the way end?
If so, it didn't send "testing123"
Just did the same thing. o-o
I think you need to go a few lines down with it
I cant tell, after the if statement not in it.
Moved it to after } else if (interaction.customId == "r4") { Like after the } one
Did not send the reply.
Ok yeah, something strange then that I don't know about.
Try console logging in that spot instead to see if the codes even getting that far
If not put the log near the top, maybe inside the isButton if
Anyway I need to sleep. Gl
I did that
await interaction.reply({
content: `The role <@&${r3}> was added to you!`,
ephemeral: true,
});
}
console.log(`Test`)
} else if (interaction.customId == "r4") {
if (interaction.member.roles.cache.some((role) => role.id == r4)) {
interaction.reply({
content: `The role <@&${r4}> was removed from you!`,
ephemeral: true,```
Didn't log anything.
Goodnightt!
Its because my module exports {}'s
Were at the top
and not at the bottom...
So it cut off all of the bottom
});
}}
})```
I must be missing a few things there
I've been getting that for like 10 minutes now
🤣
Then it goes to this
So its back and forth
GOT IT
oml
Nope
why code when you can just cry
Ikr 

Figured it out, nothing after cool.on("interactionCreate", async (interaction) => { works for some reason....
Still doesn't work after that 
did you actually login?
i dont see a login here ^
you are creating a new client
Oh?
Oh yeah, lemme just yoink that out of there
Now its just this:
DiscordAPIError: Unknown interaction```
Wait nvm
Got it
:)
I think
Nope, still "Unknown Interaction"

What exactly is going on?
Well your interaction has already been expired
You will have to defer it if your response takes more than 3s
Which is the lifetime of each interaction by default
lets say I have this, how can I receive the {test: true} within the shard
https://i.callumdev.xyz/hi48g.png
!MomijiStare non animated
Either <:NAME:ID> or <a:NAME:ID>
!3sEneW animated
check previous message author id, if equals to new message author id, delete message
or if you're somehow unable to check prev message data, store previous user ID in memory or db or something
then compare
that's how i'd do it but im not the best coder so
Okay so my server just got raided, all members are there. But I need to figure out how to make a command that can delete channels that has hail in it. How might I do that?
There are over 200 hail-sumthin channels
Proof:
if channel name has text "heil" in it, delete channel
and make it iterative by grabbing all the channels in the guild
then running through all of them
channel.delete()
}```
?
if it's js i can't really help with the code unfortunately
not very familiar with it
at least in python it'd go something like
for channels in guild:
if "heil" in channel.name:
delete channel
or since you know what the channel names are, you could even see if the channel name starts with "heil"
that's javascript in five seconds
who the fuck doesnt put spaces around &&
who the fuck uses single quote for strings
agreed
link has a code formatter github action that changes my strings to single quote
@marble juniper delete action or -3000000 social credit
me
which is why I have the action
so it all stays in the code style I want it to be
Always bet on JavaScript
master of the amount of js libs though
thats also intentional
cuz semi colons are useless in javascript
and only add extra bytes
the only real use case I can think of for semicolons is
;(async () => {
// stuff
})()
Lol
they are not useless
how would for statements work without them?
there are also cases where the automatic insertion does a bad job and breaks the code
and most of the code is jsx which does break from asi
What is this?
So does anyone know any bot that can show leaderboard ranks in real time
Like xp ranks
.catch()
well it shouldnt if u handle it properly
then the process should not end, unless your are catching at the wrong promise
U could just listen for unhandledRejection and uncaughtException from the process to eliminate all the possible causes for the process being stopped. But even with that its better to find where the errors are originating and actually handling them
1 thing bots should never need the administrator role
if the message doesnt send nor the catch it prob means that your if statement is false
what is your error in the console?
that's the catch block tho
how to thread message move to other channel or thread??
already answered but its an anonymous function
if ur an await spammer its pretty useful
in a db or in a table?
SELECT count(1) FROM table
what?
top.gg webhook is exclusively related to votes
you want to upload the server count?
Yes
what language?
discord.js
how can i print server count to webhook
So how to write another bot on how many servers?
Interactions 
why
what will you need a second bot for
(*  ̄︿ ̄)
I will use this for the briefing
What's with it ( ̄▽ ̄)
( ̄﹏ ̄;) it's not like I forgot about interactions or anything
( ´ ▽ ` ) for sure
how does one create buttons with discord.py?
step 1: discord.py is dead
step 2: migrate to hikari
step 3: delete python
step 4: let things that depend on python break
this
isnt there a third party library that adds buttons to discord.py?
There's like a ton: discord-buttons, buttons, discord-buttons-plugin, discord-components, discord-py-buttons
The first one seems to be outdated
pagination-utils 
discord-components is great
oh ok thanks 🙂
if you join their server, they have a slash command which returns a code snippit
Hello! My main scripting language is python. Which app do you recommend for python language. In replit i have to go back to website each 2 hours to re run bot since it goes offline. This is very annoying
Use Flask to host your bot on Uptime Robot
wdym
There’s a module named “Flask” which is utilized for app development
And click on the secrets icon
Add a secret under the lock icon named “DISCORD_BOT_SECRET” with its value being your bots token
Then create a new python file called webserver.py
Use flask and threading to create a basic app
create a route for the app
Like this:
@eternal girder.route(‘/‘)
And then run it through app.run
@mystic raven add from flask import Flask to the top
then add app = Flask(__name__) underneath that
then ```py
@app.route("/")
def ping():
return "I'm alive!"
app.run("0.0.0.0")```
how do u type like this btw
write inside ```
ok
yeah
DiscordAPIError: Invalid Form Body
embeds[0].description: This field is required
at RequestHandler.execute (/home/runner/Hype-4/node_modules/discord.js/src/rest/RequestHandler.js:298:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RequestHandler.push (/home/runner/Hype-4/node_modules/discord.js/src/rest/RequestHandler.js:50:14)
at async TextChannel.send (/home/runner/Hype-4/node_modules/discord.js/src/structures/interfaces/TextBasedChannel.js:172:15)
at async paginationxd (/home/runner/Hype-4/commands/Owner/servers-list.js:93:26)
show servers-list.js
You need to provide at least one of the following when making an embed: a footer, a title, a description, or a field
I’m assuming that you didn’t provide at least one of those
alr i need help
i have the array "todos":[{"todoId":788,"title":"test","content":"big bun is testing this"}]
how to i get each todo item to be
<p><b>test</b></p>
<p>big bun is testing this</p><br>```
which framework
python btw ^^
idk how i'm gonna work this
for loop?
i mean true
i managed to get it to grab the users email from the database and it gets the todos array
for todo in user["todos"]:```
put this in the non existent js to py convertor:
let msg = "";
for (const todo of todos) {
msg += `${todoId} smth smth\n`;
}
alr i got it working
for todo in user["todos"]:
todos = todos + f"<br><p><b>{todo['title']}</b> - {todo['content']}</p>"```
baby shark baby shark todo todo todo todo
how do i embed a raw c without making stuff like /// weird things
?
just how do i make c treat some strings as raw string
Raw strings for output?
printf(R"My raw string");```
What are you using C for and not C++?
C not C++
I know. I was asking why you were using C and not C++. What do you need raw string for?
Care to show?
uh embedding base64 data to be decoded later
yeah not sure why you wouldn't use C++ for that. But show what you want to do with C I guess
How do I get the number of servers in the discord 0 perm invite link to the message?
wdym
What ?
godzilla had a stroke
yes
Is it unbearable?
No it has to be taken but I don't know how
I’m so confused lmfao
same
There's no reason to be rude about it.
they don't double
it's just a convention bot owners use to incentive voting, so top.gg sends whether it's weekend or not
Ohh I saw this on @Mac#8888 's Pixxiebot docs. It might be the bot's feature
ohh thanks
like "vote on weekends to get double credits" or whatever
but the actual vote is always 1
thanks for info !!!!!
yw
Is it just me or does joining a voice channel on mobile register voiceStateUpdate multiple times?
Cause I added a logging feature to my bot (or something even though I added a return statement when an user leaves) it ends up crashing and throwing the error, “User isn’t connected to a voice.”
there was a bug some time ago related to this
do we have any rule against webscraping?
no?
https://bscscan.com/txs
i am starting out a project and it is required for me to scrape from this site with a few filters using nodejs,
any recommendations
it's not discord.js related, it's your job to handle multiple voiceStateUpdate at the same time accordingly
ik
then
js
i just don't know which tool to go with
not cheerio cuz it has that jquery shit
you don't even have to scrape
they have an api
what does a raw string do
Ah ok thx
is it a feature in py?

why is this denied?
it should allow everything
aws permissions are so confusing
they really fucking are
it took me 20 minutes one time to get a cloud function working
copilot?
yeah lol
lmao
Lmfaoooo
@_@
Fastest math method
meth
moth

bath
depends, what for? whats your target audience?
you can support both at once, its a bit of a hassle but everyone will be happy
es6 if you are looking forward to future standards and dont mind losing potential users
commonjs if you want simple, plug and play, easy to use
es6 users can use commonjs, with a few restrictions
commonjs users cannot use es6 directly, they must use async imports
same
you can support both by adding an esm layer
just for getting named exports to work in es6
its just a file that imports everything, then exports it again the es6 way
jank
TypeScript preferring export default is really annoying even though it'll be transpiling down to cjs anyways
I don't understand the use case of export default anyways since it's just taking up another index signature which is useless
its likely for backwards compatibility with cjs's module.exports = something
best of both worlds i guess?
Still doesn't make sense to me because if they wanted to access a constructor or a function and also other members, they can assign static members to the function
someone probably just went "what if i want to do (insert dumb practice here)? i could do it before, now i cant anymore?"
and they went "sigh... fine lets add this as well so you can keep doing it your way"
I don't feel sympathy towards dumb practices
i do because i did them a lot
and really, a LOT
did i already tell you about the good old times where i would eval(fs.readFileSync()) instead of require()?
:^)
i did it seriously
"I might be BASEd but I just don’t like ROTting bananas"
dWdnY2Y6Ly90bG5tYi5wYnovczYwOW5xMnBycm81N3M3c3I0NTY4NjFxcTY5NDBwczI (don't worry this isnt some random token, its something encoded)
is anyone good at decoding things, if so, can anyone decode the above string? there's a hint above "BASE" and "ROT" but i have no clue 💀
isn’t that basically what require does
in one of the first iterations of my bot
Well. That is a thing that exists I guess. Not great and obviously shit code, but good meme
atleast according to native toString() code iirc
base = base encoding, for example base64
rot = rotation cipher, for example rot13 or rot47
oh
it's base64
hmm i got this from it
uggcf://tlnmb.pbz/s609nq2prro57s7sr456861qq6940ps2
now decode with rot13
and you get https://gyazo.com/f609ad2ceeb57f7fe456861dd6940cf2
ye ol' tim
and tim as in timotei
Invites and guild displays are approximates
The raw data from Discord event has approximate_*_count fields
well rather they're whatever value got cached when the invite embed was created iirc
That's why they're approximates
It's almost never correct if the target guild experiences a lot of joins and leaves
Yes
okay
why is this so small?
Isn't 20 enough?
they're probably just wondering why it's so low
lot of app names out there longer than 20 characters
Anybody know how to see how many lines a file has when it doesn't allow you to scroll because it's so big
wc -l <filename>
yuh
Any way to do it on windows that you know of
How about find /c /v "" <filename>
I don't use Windows myself but most answers are one search away
Doesn't seem to work
Maybe I should just calculate based on filesize
Anyone know how much space each character takes in a .py file?
depends on the implementation
Got it
Ok so this is the final result (had to stop the program since it was taking too long)
That goes on and on and on
Had to count the lines with powershell
188 million is nice
Rust is a sick language
You can stream the file and count how many new line characters there are
Sounds like a hassle considering the file is 7gb
Plus I already got the line count now so it’s good
That's most likely whatever you're using does.
Streaming doesn't matter what size the file is. You would analyze each chunk of data and then evict the chunk from memory once you're done with it. Memory usage never gets too high unless you retain chunks in memory
Fair
I just used whatever powershell command I found on google after struggling to open it for a while
Didn’t feel like writing code for it
“The lazy man’s solution”
How to make cooldown command as UTC time zone in discord.py? [Not user cooldown]
And the error as Hours, Minutes and Seconds

someone know how to install packages in offline apps
What do you mean?
What do you want to cool down for? A command run for a guild, a user, a channel, please expalin.
I want to import packages in my code on Dcoder
but how will ai do
Don’t have a clue about decoder
Dcoder
I know it’s an app.
But I haven’t used it before.
ok just coz the console isn't doing any imports I will try on VS code
Use if else to check the time simple
why i'm always get this error when i wanna push a code in vc code to github
i'd censcor your mail, but apart from that i mean it literally says "no secret key"
is this repo private?
yes
then you need to authenticate to interact with it
how
normally it was username and passwod but if iirc the turned off password authentication, so you need a secret key
i have a secret key but i dont know how to do it
https://stackoverflow.com/questions/36810467/git-commit-signing-failed-secret-key-not-available maybe this article helps you
I am getting this error when trying to commit using Git.
gpg: skipped "name name@mail.com": secret key not available
gpg: signing failed: secret key not available
error: gpg failed to sign...
@solemn jolt ping
hi
have you checked the discord developer docs?
cause uh
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
it's right there
hello,i've made a command and in that command i've added buttons through discord-components and when i click the button my bot is supposed to edit the last message but when i click on it the bot edits the message but i get this message "this interaction failed",can someone help?
ty so much
lmao
i tried not working
no, because it's part of the member object
What library are you using
@carmine topaz ^^
you know
there ya go
just check the after object and before object
@carmine topaz
np
alr so
i have a file called click.js
which has the function in for the onclick event
how do i send an api request on click?
nice
xhr or fetch
jquery
await schema.findOneAndUpdate({
userId: msg.author.id
},{
$addToSet: {
(type2==="selling" ? "selling" : "buying"): text
}
})
am i not allowed to do some comparing stuff inside a ()?
do you mean []
doesnt that means ur creating an array 
sure
wtf is that syntax
idk i havent been coding in js for a while now 
Shorthand statements:
(condition) ? yes : no;
((condition) ? yes : no);
so i just have to enclose the condition with () and that should fix the error 
have you try this sir?
let something = (type === "selling") ? "selling" : "not selling";
You’ve got another :text behind which doesn’t make any sense at all
im declaring a key in an object so i can just use
{
"something": text
}
he's doing it inside an object bruh
so far it hasn't errored after i started it
you can use [] for dynamic key
I know what he’s doing but still shorthand statements doesn’t support an else if structure means your syntax is wrong
ye it works now thx
And yes if you define a dynamic key then wrap it in brackets
Still an horrible form but it’s your code
am i correct in assuming bots need to be in over 100 servers to get this button and i cannot create by own buttons there?
You can enable that button in your bot’s dashboard
I'm thinking about placing a web panel link somewhere
no minimum server limit
ah ok, can i add custom buttons to that like a webpanel link
ok
I’m trying to attach a file to a message, but for some reason the file isn’t getting sent. All that IS sent is “log.txt”. The log.txt file is in the same directory as the index.js file.
Code:
https://sourceb.in/mNNguki3E5
It is the most recent update of discord
U will find it in the dev portal
hi umm
const reactionCollector = marketList.createReactionCollector({ filter, time: 30_000, });
dos this not work at all now???
it used to work before. and i see no events being fired on collector.on("collect")
thats your index file right
you know that ../ means one directory up and ./ means same dir
if (totalPages <= 1) marketList.react(bin);
else {
marketList.react(backward);
marketList.react(forward);
marketList.react(bin);
}
const reactionCollector = marketList.createReactionCollector(filter, { time: 30_000, });
reactionCollector.on("collect", async (reaction) => {```
Help. This worked before but the collector is no longer working
Mb. I also tried it with ./ and it didn’t send the file
in v13 marketList.createReactionCollector({ filter, time: 30_000 });
and not 30_000 its 30000
I tried this also, didn’t work
https://throwbin.io/OyYHP2o
Help me with this Err_require_esm
Error and code is shared in throwbin
Throwbin is a website where you can store text online for a set period of time.
ty
ofc
Just use version 2.5.x
Change the ^ into a ~ in your package.json for node-fetch to prevent updates to version 3
People who owns this business here?
No
i think you can see the issue here
there is scroll room while there isn't supposed to be
100vh counts without top bar
safari is eternally cursed with the 100vh height bug
this is chrime
Chrome
i was thinking about it scrolling to the middle of the page
and locks it in there
so its like this
is it not ios?
android
oh
lol
Make sure html, and body both have 100% height
No padding or margin
Or do you speak about the button?
Is it possible to make it so only a role can use a specific slash command? {v13 ofc}
No, you'll need to check at runtime like UnidX said
Okay.
if (interaction.user.roles.cache.has('914989881804062741')) {}
TypeError: Cannot read properties of undefined (reading 'has')
user cant have roles
How do I fetch if they have a role?
get them as a member (interaction.member?)
I had that, then I changed it 
if (interaction.member.roles.has('914989881804062741')) {}
TypeError: interaction.member.roles.has is not a function
cache
one sec
Yeah like in a common handler you check if the interaction member has the permissions to execute the command
Oh lol
didn’t see the scroll bar

Tell me the benefits to php and I will stop hating on it

elephants are cool
I don’t get the question.
The benefits compared to what? Trees?
compared to just normal html
lol
I didn’t know HTML is a program language.
I’m about to learn something new every day in here
wait from what I was told php is basically just html is this wrong?
Try to do something dynamic in HTML 
Omg
So ima not ask that person questions about web dev again 
so can you tell me what php is then. Since I was told entirely wrong
I can tell you pretty much the same thing written down if you search for what PHP is or you gonna google it yourself 
It’s mostly used for web programming including anything associated like backends etc.
That’s what I would add to the general description you can find in the ‘net
I see
so it essentially makes connecting the frontend to the backend easier?
that is my takeaway from reading online and what you wrote
Well that’s a very simply explanation but yeah
HTML is just a markup language as name says only being able to display static content
Hey guys, do you know if there's a way to download a log of when people joined the server?
they don't like persistent data storage
It is the backend
It doesn’t display things "easier" it is the fundation to generate dynamic content
How Tf do you set statuses on discord.py again
Stackoverflow has let me down and none of that code works
which discord.py fork are you using
@spark flint how about change_precense: https://discordpy.readthedocs.io/en/latest/ext/commands/api.html?highlight=presence#discord.ext.commands.Bot.change_presence
can you show what you tried
In bed atm so can’t get my code
how do i add ratelimits to quart/flask ping me pls
I am using node 17.x I tried these methods ain't working
Then use 2.5.x
I want a code of discord.js that return the link of the first website in search result
Plz help me
In search on what?
How can I access an image from localhost? I have an express server on my server and I just do res.sendFile(path). Now since I have my express app set to localhost only I can't access it anymore through http://localhost:3001/path/to/the/image. It worked with the IP instead of localhost but then the app is not on localhost only...
if (totalPages <= 1) marketList.react(bin);
else {
marketList.react(backward);
marketList.react(forward);
marketList.react(bin);
}
const reactionCollector = marketList.createReactionCollector({ filter, time: 30_000, });
reactionCollector.on("collect", async (reaction) => {```
The reaction collector isnt working at all. i tried putting logs in the filter as well but nothing happens
djs 13
Wdym localhost only? localhost is just a hostname and it does point to an IP address, normally 127.0.0.1 / ::1
Can anyone suggest a website design?
yes but when it's on localhost you can't access it through the web. It's not on my PC localhost. It's on the server via localhost
O, you meant local-only interface?
message.channel.send("fkin rat work pls work").then((msg) => {
msg.react("👌");
const collector = msg.createReactionCollector({ filter, time: 30_000 });
collector.on("collect", r => console.log(`Collected ${r.emoji.name}`));
collector.on("end", collected => console.log(`Collected ${collected.size} items`));
});```
Im literally using the example they gave in the docs... still doesnt work wtf. i can see the message with the emoji in the channel but when i click on it nothing happens and after 30secs i can see the log in the "end" event
use a message button component
yes, how can I access an image from there? (via Link like http://localhost:3001/path/to/the/image)
via localhost it's not to everyone...
man like, i have to change everything now?? I have this everywhere
does this mean, collector doesnt work anymore?
that's exactly like updating discordjs
it does but there's no point
ik but this still exists no
why not?
just trying to figure out why the on collect eveny isnt being triggered
and if you use something like detritus you can have a separate event handler for every button so you don't need to have a filter
got it
I'm the moderator and I would like to reward the first few members that joined
Anyone else know if there's a way to download a log of when people joined the server?
You can't really
You can
You can get when a user joined a server easily
Discord API provides that info in the member object iirc
Could you kindly tell me how? 🙂
What language
But there are only larger futures announced and some of theme are after release
When I need to ask someone about updates on server related to this future, easier is send one link then founding screenshots and trying describe this all times
Also discord provide data about it in many different places like: gh pr, ddevs q&a, stage-info channel, announcements on discord developers and discord townhall servers, blog posts
Many of futures also don't get all screenshots in descriptions and details how it works, but you can check this in canary client update
English?
Oh, I'm just a moderator on this server and I would like to reward the first 200 members that joined. But not sure how to get the log
wouldn't it be wiser to have a gh repo for storing changelog then?
like, don't think making an app just for that is worth it
I’m assuming you’re going to use discord.js, so here: https://discord.js.org/#/docs/main/stable/class/GuildMember

<Member>.joinedAt is a Date object, and <Member>.joinedAtTimestamp is a Unix timestamp
But there will be more futures then one list with that. I planned tracking prs, blog posts, announcements, clients updates and ddevs events
ddevs events will be with transcriptions and summaries
still
This will be more user friendly when u send this for someone who don't use github that usually
well, you do you
Also some data will be 1:1 from github gits like summaries, but thanks for feedback
MobX or Redux?
(Using react)
there is a coding language that is named "English" 
@woeful pike you are smart
doesn't really matter honestly use whatever you want
basically it's renting space for your servers and other computing hardware at a third-party provider’s data center facility. Typically, colocation services include the building in which everything is housed, as well as networking, physical security, redundant power and redundant cooling components, which then support the servers and storage provided by the customer
lol
disable your tracking 
Basically yeah lol
the effort to colocate your hardware lol... just rent a cheap server, I guess that's better compared to what they offer you
Not really
With the 1U yes
compared to what they offer you
You can get when they joined yes, but downloading it you shouldn't really do.
hello i have a javascript website code and also i have a domain but i dont now how to run it
Can someone help me with express and an image as response? I described my problem here:
https://stackoverflow.com/questions/70185935/err-connection-refused-on-express-running-on-localhost
I always get the the error ERR_CONNECTION_REFUSED when I try to access an image on http://localhost:3001/image and I don't know why. My express is only listening to localhost for security reasons. ...
I hope it's okay to post my problem with a stackoverflow link
Would it be possible to register slash commands in the main file? I tried using a separate file to store the commands, but the commands don’t get registered/don’t exist.
Ex. Of what I mean:
https://sourceb.in/jN1p63plfp
404
Bin not found
const { SlashCommandBuilder } = require('@discordjs/builders');
const Discord = require('discord.js')
module.exports = {
data: new SlashCommandBuilder()
.setName('accepted')
.setDescription('Send the Application for a User to apply for Staff!')
.addUserOption(option => option.setName('target').setDescription('Select a user')),
async execute(interaction, message) {
if (interaction.member.roles.cache.has('914989881804062741')) {
const user = interaction.options.getUser('target')
if(user) {
const role = interaction.guild.roles.fetch('914989881804062741');
user.roles.add(role);
const application = new Discord.MessageEmbed()
.setAuthor(interaction.guild.name + ` Welcome Aboard!`, interaction.guild.iconURL())
.setDescription(`:tada: Welcome to the **#Team Aspire** __Crew__, we are so excited to have you with us. With a concensus reached, we have decided to **__accept__** your application to be apart of our Staff Team! Welcome & Enjoy!`)
interaction.reply({ embeds: [application] })
}
} else {
const staff = new Discord.MessageEmbed()
.setAuthor(interaction.guild.name, interaction.guild.iconURL())
.setDescription(`You need to have the <@&914989881804062741> role. `)
interaction.reply({ ephemeral: true, embeds: [staff] })
}
}}```
> **`Error`** : TypeError: Cannot read properties of undefined (reading 'add')
formatting said hello
const {SlashCommandBuilder} = require('@discordjs/builders');
const Discord = require('discord.js')
module.exports = {
data: new SlashCommandBuilder()
.setName('accepted')
.setDescription('Send the Application for a User to apply for Staff!')
.addUserOption(option => option.setName('target').setDescription('Select a user')),
async execute(interaction, message) {
if (interaction.member.roles.cache.has('914989881804062741')) {
const user = interaction.options.getUser('target')
if (user) {
const role = interaction.guild.roles.fetch('914989881804062741');
user.roles.add(role);
const application = new Discord.MessageEmbed()
.setAuthor(interaction.guild.name + ` Welcome Aboard!`, interaction.guild.iconURL())
.setDescription(`:tada: Welcome to the **#Team Aspire** __Crew__, we are so excited to have you with us. With a concensus reached, we have decided to **__accept__** your application to be apart of our Staff Team! Welcome & Enjoy!`)
interaction.reply({embeds: [application]})
}
} else {
const staff = new Discord.MessageEmbed()
.setAuthor(interaction.guild.name, interaction.guild.iconURL())
.setDescription(`You need to have the <@&914989881804062741> role. `)
interaction.reply({ephemeral: true, embeds: [staff]})
}
}
}
there, now it's readable
lmfao, ty. I actually just fixed my problem too^ So nvm 🤣
ye, user cant have roles
they can
Which is why I defined it here ; const user = interaction.options.getUser('target')
It could be "goat" or "member" or "top_gg_says_users_can't_have_roles" but its jsut how you define it
nope, users aren't bound to any guild, which mean they don't have any guild-related properties
what u want is const member = interaction.options.getMember('target');
I alr had that 🤣
Oh, I didn't even notice that just re-wrote it to getMember
ye, that was the issue
could you technically have a portable node environment
Say you load nodejs on a USB could it work?
hm
🦆
Refactoring your bots slash commands into individual projects is a great idea.
Well yes you can it's just whether it's plausible to do so
At some point there could be issues most likely
You could probably setup your ide terminal to reference the node executable by just typing node
or maybe not idk
Would it be possible to register slash commands in the main file? I tried using a separate file to store the commands, but the commands don’t get registered/don’t exist.
Ex. Of what I mean:
https://sourceb.in/uJqXkmox6r
The idea behind a portable node environment is you don't have access to change path variables I'd guess
The idea of splitting up your slash commands is that you load the necessary information for discord to use, and when you call the interactionCreate event somehow run the corresponding command, I assume anyway
I'd think of it as essentially making a modified command handler
where you register the necessary info, like the command name, options, etc and then on command call run the necessary code.
Remove that trash code example you copied from the guide.
Use the inbuilt methods to register/update/delete commands.
I suck at explaining but this is essentially how I did it
make your own handler directly against the api
Before doing that, fetch the already registered commands and make sure, NOT to register them over and over again on any restart
Yes good idea that can be troublesome
Unbelivable that trash they call a "guide"
look at how beautiful my command router is
It'd be better if it was java
unless you plan on getting message intent, I advise not to use awaitMessage
🗿
java is too slow for lambdas
better not
php and better in one sentence

that's a great argument but sadly urmom

fair point
well, just check the message content
total escalation
I'm just messing with you fake
like, only stop listening when you get a valid input
Can someone help me with express and an image as response? I described my problem here:
https://stackoverflow.com/questions/70185935/err-connection-refused-on-express-running-on-localhost
I hope it's okay to post my Problem like that
I always get the the error ERR_CONNECTION_REFUSED when I try to access an image on http://localhost:3001/image and I don't know why. My express is only listening to localhost for security reasons. ...
I haven't used Express in ages oof
connection_refused usually means the port isnt open
maybe the problem isn't even with express....
http://xxx.xxx.xxx.xxx/image vs http://localhost:3001/image
one has a port
one doesn't
oof... okay that's just wrong but both have a port..
actually, the first one does have a port (80)
does 127.0.0.1 work?
nope..
use postman to see if u can ping that address
I also tried other search engines and browsers.. it just works if I have it on ip
actually
I can, I can even ping localhost on the server
but did postman work?
yes
You get the error when accessing the image in your browser?
on my VPS. I have 2 servers (React as Frontend and Express as Backend) and Express usually connects via localhost for security reasons
I can't via localhost because localhost is on my server
both the server and the code are on the vps?
are images served by react or express?
If it's on the vps then localhost won't work right?
or you're trying to access localhost externally?
You're trying to access the webserver externally?
But wrote
My express is only listening to localhost for security reasons.
yes sure
by express via res.sendFile(path)
hm, did u check if nothing else is connected to the port?
yes it isn't. Express would crash if it is tho
it might make sense to put the images onthe frontend
actually just use nextjs on vercel
security...? And it's easier in backend so you can access it form other API endpoints too
don't bother abt image security
if the user can see he can grab it anytime he wants to
everything user can see can be grabbed
generate a uuid so the file names can't be guessed
well yes it's not that big deal... all tho I need this to work for future things too.. I don't get it why it doesn't work. Maybe it's actually the path or so..
Reminds me of the dude trying to hide client JS code in his page, telling us it's possible to encrpyt it 
that guy was funny
isn't it possible? xD I just read something about it... at least in nodejs there's a module for it 👀
u cant hide anything clientside
or something like that xD
client side, not server side
since browser needs to access it to be able to render
ye okay nvm xD
Anything which has been rendered in your browser IS visible
so anything the browser has access the user has too
Like saying anything you see is visible, anything you can't see is, guess, invisible
any solutions from you guys about the express problem? Maybe idk maybe you guys know how to get the ip of the own server, then I could build it diffrent and it would work
it's hard to say what might be the problem
connection refused is a VERY broad error
Yes it's even hard for me and I have the whole code and built the system xDD
you could try to check ur webserver logs to see if there's anything useful there
you shouldn't be worrying about infrastructure stuff.
it could even be google chrome that causes it...
in long-term already
so then other question.. how can I get the ip address? I mean not like the hostname I mean the actual ip adress so I could fix this problem I guess
can you login to the vps? is it linux or windows?
wtf... I shouldn't update certbot
Have you ever seen this error?
An unexpected error occurred: KeyError: '<domain_here>'
yes sure I can xD I also know it but it's for the future use-case. It's about a software you can self-host so I need the ip address. Not my current one, because this one I know
it's the same ip you use to ssh into it
.
why would you need the ip of software that is self hosted? is this like a p2p network?
Is it just me or am I understanding the situation wrong
Can you connect to something that is hosted on a vps with localhost?
Without having something like an ssh tunnel open
Ah I see. I’m just wondering if it’s possible to register the cmds in one file instead of separate files. It prob is cleaner and a lot easier to read using separate files but I’m not entirely sure how registering slash cmds work even after reading the docs on it
You can split the actual command code up
But when you call the interactionCreate event you can call the code in that file to run
Typically how a normal command handler works
Using gems?
*te
I need it for the API request because every server has it's own ip so I need to enter the server ip as the proxy to fetch all the data if I'm not able to do it with localhost...
What?
there is a header with that info
the servers can send in their ip when calling the api
but i guess they need to know the ip to call before calling it
i made a p2p network in college using java
I'm not exactly sure how id do it since I've not yet made a proper one, but I'd think of it as making a modified command handler but instead of looking out for messages just look out for the interactionCreate event to be called and use the command name to run the proper code and make sure to pass the command the interaction so it can do it's stuff in the separate files
yes it already calls the ip
are creating a p2p network?
?
I don't think so 🤭
i think you might be
Still didn't got his issue... enlighten me, please
It's just going be a self-hosting software with 2 servers (Frontend & Backend) and they need to communicate with each other and also send files like images
i think he want to create a network of machines connected directly by ip address
hmm
only 2 machines?
Expose the webserver to the internet but add firewall rules for it to only allow inbound connections by your second server
It doesn't necessary need to be with ip, localhost is also possible and even better with security but there's this stupid issue with the image response
yes
Sucks my school laptop doesn't have java on it for some reason
P2P und tunnels are nonsense, just use a proper firewall setup to allow inbound connections only by your second server
can't be easier
yes yes
Idk what that means cause I'm dumb asf but yes I agree since fake said it
you can do the access control from node, but firewall will be safer
https://www.npmjs.com/package/express-ip-access-control
fake is like Tim but always online

Tim = FakE ^ 3
who's tim? xDD
Lol
The ruler of #development
Anyways... what's the OS of your webserver(s)?
He has the biggest brain
debian 10
Tim helped me with this code
Well then use iptables to add inbound rules for the firewall to allow connections from source IP (your second server) only on port XXXX
oh man... my brain really hurts rn...
Not that complicated... assuming your default INPUT policy is ACCEPT, just DROP inbound connections for port XXXX if the source (IP) is not your second server
Keep in mind to bind the webserver to your IP or just 0.0.0.0 not localhost anymore after setting up the firewall rule
Is there a way to make a replica like the activity bot made by discord?
dont get him locked out of the vps lol
)



