#development
1 messages · Page 1879 of 1
if it does, youre about to enter a whole world of pain
these can run on raspberry pi, i have checked
sure, for one or two servers
yea
but each stream spawns a transcode via ffmpeg
so you end up with dozens -> hundreds of ffmpegs running
a friend of mine ran a music bot that worked like this, and it ate like 32gb ram on my box and killed it
with 7000 servers
:O
he was rewriting it in D++
lol
maybe lavalink would be better
but now hes not sure if hes going to, because of the aggressive takedowns
than ffmpeg and youtube-dl
so i guess it's not safe to run it on a pc
yeah lavalink scales a bit better
use lavalink
you cant just "use lavalink" though... he didnt write the code
if you really want to run it on pc
srry elaborate im not the coder im the sponser and host
that would mean a rewrite of the bots core functionality to use it
yep i went through that pain
same as "move it to D++" is certainly not trivial either lol
np
my current todo is making my bot speak slash command
its a fun one... because the lib i use has slash commands as a first class citizen, its not hard from that perspective.... but my bot takes command input from all over the place
not just messages, but via a dashboard command feed, via a scheduler, etc
so slash commands have to feed 'transformed' command input into that same system
heres how im approaching it
@quartz kindle how would I make your editStructureAdd code work in djsv13
Honestly, it's so stupid
They're acting like everyone uses Structures
But no, only people that know what they're doing use them
Yet they still decided to say fuck you and removed it
I use Structures when I want to easily integrate a really useful feature into djs' classes
like Tim's edit structure
- which is open source on github by the way
it's like so insanely useful
and that is what I use to keep Undefiner from flooding chats
actually, I wonder, did Tim update the repo for v13
Used to be a way to extend discord.js classes
https://github.com/timotejroiko/useful-snippets/blob/master/snippets/discordjs-responding-to-edited-messages.js I use this but slightly modified as it didn't work for my bot at first
it's not a big deal lol, there is definitely a way to do what you're doing without structures
yes but it's a mad pain
structures were so much better
this idiot is so stupid, I now hate 1Computer1
that's not even proper use of Structure, what a moron
literally it's just
function sendAndEditResponses(message, content, _options) => {
let options = _options;
if(typeof content === "string") {
if(!options) { options = {}; }
options.content = content;
} else {
options = content;
}
let sent;
const previous = message.client.responses.get(message.id);
if(previous) {
// use the forge method if using discord.js-light else fallback to fetching for regular discord.js
const msg = typeof message.channel.messages.forge === "function" ? message.channel.messages.forge(previous.id) : await
message.channel.messages.fetch(previous.id, false);
if(previous.attachments || options.files) {
await msg.delete().catch(() => {});
sent = await message.channel.send(options);
} else {
if(previous.embeds && !options.embed) {
options.embed = null;
}
sent = await msg.edit(options);
}
} else {
sent = await message.channel.send(options);
}
message.client.responses.set(message.id, {
id: sent.id,
attachments: Boolean(sent.attachments.size),
embeds: Boolean(sent.embeds.length),
timestamp: Date.now()
});
return sent;
}
Put this in your utils file or something and use it where you want to
I wouldn't classify this as mad pain
ALSO, in this specific case you can do this, too:
Message.prototype.send = function(content, options) { ... }
when ever its time for my bot to post the guilds in top.gg it gives an error, Error: 401 Unauthorized, any idea?
Don't even need to do this anymore as you can now delete/update attachments for existing messages
@opal plank im writing in TS now, happy?
please ping me if you know
i did it the dumb way in v13 lmao, check functions.js and extensions.js in djslight
alright
whats ts?
Typescript
what it do dood?
thatscript
just JS cosplaying as a statically typed lang
hmmm
anyone knows? please
const DBL = require("dblapi.js");
const dbl = new DBL(dbltoken, { webhookPort: deleted , webhookAuth: 'deleted' });
not so long ago
I mean, there HAS to be somewhere you input bot id
else how would the lib know where to post to?
lads anyone knows how to do this? i want to make my bot reply to a message which was replied to when doing the command
so like this is the command
and then the bot replies to this
does mentions work for this?
ok
where tho
lets theere is a command called -command which when a user replies a message with the bot replies to that specific message
for example
-command
and then the bot will reply to this message
you can grab referenced message
i want to add it to const dbl but i already added the webhook stuff
as it seems, u need to chose one of the two
or have 2 instances
although it'd be better if u used top.gg/sdk
since that's the official lib
what if i want to use both, webhook and the client
^
idk how to use it , wheres the docs?
dblapi.js is deprecated
you can always use void characters
ye
did u define dbltoken?
idk then, it was supposed to be only that
you'll need to ask someone who actively uses it to see if there's anything else
reset your token and try using the reset one
try using the token directly rather than a variable
does your token look something like
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpTYI6Ijg1OTE1MDM5MDEzNDMwODg5NCIsImJvdCI6dHJ1ZSwiaWF0IjoxNjMxODgyNTU2fQ.OytT6wKJhuRrK2ojFgwNh9IP4dyTqLufajX7Cp3yiLA
very likely starting with ey
yes
It’s not required 
try using the sdk then I guess?
how
what do i cons the api for?
like define
const Topgg = require(`@top-gg/sdk`)
const api = new Topgg.Api('Your top.gg token')
Error: 401 Unauthorized (You need a token for this endpoint)
yes
no idea then
okay, ty for trying
this is how you send a vid with your bot right?
ey
Hey, do u know how to get the message content from message id
you first get the message by id, then u get the content
?
did u try?
I tried, didn't work
did u fetch the message?
Yeah
which error u got?
I didn't get any.. It returned me script which had message id, guild and etc
Simply wanna use it so ppl can quote the message with id
...again, did u FETCH the message?
YUP
show the code u tried
I'll send the code snippet after few hrs
Yh, I'll ping you
ok ok
bot dev
i have never done that......
this video is in the bots folder so i cant do it with a link
google it
../ means "one folder above"
🤦♂️
@flat pelican
how do i add up all these numbers in my for loop?
for (const key in g){
let z =+ g[key][1].uses
console.log(z)
}```
don't define a variable inside a loop
smh
it'll get zeroed on the next pass
i know it's just a snippet i am using
Thanks
lol
your snippet is kinda the reason for your issue
huhh how would i do it then
excuse me time traveler
put the variable outside the loop
it's been on v12 for like 3 years
i have but it's still outputting this
are u talking abt node or djs?
rather than adding up the numbers
also put console.log outside the loop
Bro what
wait
ient.on('guildMemberAdd', async(member) => {
let z;
if(member.guild.id !== id) return;
let gInvites = await member.guild.fetchInvites()
let g= [...gInvites]
console.log(g)
for (const key in g){
z =+ g[key][1].uses
}
console.log(z)``` this actually returned 1 lmao?>
// declare variable here
for (/* loop */) {
// sum here
}
// print here
i've tried that but it logs 1?
then the sum is 1
any idea how to post the servers on top.gg with out using dbl.postStats(bot.guilds.cache.size), since i cant because i have a webhook
don't use dblapi.js
ask in #topgg-api how to use the sdk
dblapi is deprecated, you shouldn't use it no matter the reason
it doesn't, u need to use timhack
can't be true
where would i find that?
well, the loop summed all the values
if you're curious, put a console.log inside the loop
oh boy
for (const key in g) {
z =+ g[key][1].uses;
console.log(g[key][1].uses);
}
then sum it yourself to check the result
owh... what is =+ for then?
1 =+ 2 is the same as 1 = +2
so since the nodejs bash version is installed with the latest, i'm assuming i have to move all my files for code over to the bash?
so 1 = 2
ahha!
meanwhile 1 += 2 is 1 = 1 + 2
i see.
i defined it as let z, is that the cause of a NaN error?
I’m a bit confused, but I’m using MySQL to store a bunch of data, however in the middle of the night the bot will disconnect from the database and shut down. I’m super confused since I’m not touching the bot. I’m hosting the bot an a raspberry pi, so I attached the error.
no, but trying to do arithmethic ops on non-numbers might cause it
welcome to mysql
get used to random disconnects, data corruption and senseless errors
I found out why
Pain
Is it possible to avoid them or nah?
i am basically adding things up to an undefined value. So i can better just use: let z = 0
get used to random disconnects
Maybe if you didn't configure it well enough
Would I be better off paying $0.85 per month for hosting? Or would a hoster not change this issue?
I'm experiencing them really rarely
it's not an issue with the host but with the db itself
Your script or lib should be able to try a reconnect if so.
MySQL is just ew
depends on what data you store normally
PostgreSql is good
Alr. I’ll take a look. Thanks 👍
Ah. Ok
for example, do you have any VARCHAR(255) column?
Yes
change to VARCHAR(191)
Alr
Your bot also doesn't die if Discord disconnects the connection, it will reconnect as well
Keep that in mind to handle a database connection similar
Okay. Sounds good. Thanks y’all
but really, if you don't have much data I suggest going to postgres
mysql is too glitchy to be worth it
change to VARCHAR(191)
Imagine if your string to store is 192 
but really, if you don't have much data I suggest going to postgres
I would switch to SQLite but okay
sqlite might be too simple for some stuff
"cool" data types?
hey kuu, do i have to move my files over to the node bash?
arrays being one of em
hmm..."to node bash?"
well i mean that's what came up with the timhack link
ah, that
If you need to save an array in a table-based database you're doing something wrong.
ye, there's a full tutorial there
How so?
not save as array, but do array ops
with pogres you can convert a resultset into an array and manipulate as you'd do in prog langs
Anyways serialization is the key you have to go with then
serialized arrays won't allow element manipulation
If I need to save an array of thumbnails for an anime ima make the field be the type of text and also mark it to allow arrays
Yeah I know, there's no possibility to manipulate it in SQL other than deserializing in your code, manipulate, serialize it again and update the entry
pogres has a shitton of support for in-server manipulation
I've got a few tables only containing some JSON data and deserializing and serializing is indeed a bit annoying but the way it works.
I still wont change my opinion about saving an array in a database but I can accept your opinion, too
The use case matters and no MySQL MariaDB isn't bad or shady, not even close
like, I agree with saving not being necessary at all
I just like the operations it allow after you typecast it
It's just not the best database to start with as beginner
bash index.js
index.js: line 1: syntax error near unexpected token (' index.js: line 1: const { REST } = require('@discordjs/rest');'
mariadb is fine
mysql is the baddie
That's at least something I would sign to 100%
also it's made by Or*cle
look right after the semicolon
Anything Oracle has "took" over the years got fucked up somehow
I love java but hate oracle for how shitty their business model are
java didn't deserve it
show index.js at line 1
Can't belive I've got the same opinion like you, but yeah
const { REST } = require('@discordjs/rest');
Even if I don't like Java
starting to think bash doesn't like node
that's line 1
wait
lemme try something
ohhhhh wait
that was it, i didn't realize bash doesn't like to run index.js
now it works
it needs to run run.sh instead of index.js
ah
so it works now, but issue i have being is how to get the old code migrated to the newest discord.js
manually, slow and steady
sigh
well now it works with the slash command
imma have fun with converting old code into the new version
new issue
when a command is run, the bot does nothing, no errors
this is the newest version with interactions
intents maybe?
omg
@lyric mountain here
@bot.command()
async def getmsg(ctx, msgID: int):
msg = await ctx.fetch_message(msgID)
await ctx.send(msg)
no privileged intents
that was the issue
new issue
NOTE: Once your bot reaches 100 or more servers, this will require Verification and whitelisting.
it's already verified with 237 servers
you can't just send a message that way
you need to get the content with something like msg.content
or whatever it is for dpy
what would i do to enable intents
go to discord dev dashboard and enable it there
then add to client during creation
i can't enable it
Did your bot already was in more than 75 servers?
Verified doesn't mean you can enable the intent
It must have been verified for this intent tho
well what can i do then?
FWIW you can just annotate the parameter with the Message class and it'll lazy fetch the message for ya
Contact Discord to ask for a verification for this intent with a very good explanation why they should whitelist your bot
i'm guessing i'd have to do that through email
Not sure if there's another verification button
Probably not, yeah via. mail should be the right way to go
well that's going to be a problem, i won't be getting anywhere because they never respond to my emails
i will figure out a way
or more

You need a verification process for each intent
it should boot normally if u don't use either of them
you can apply for both at the same time
Yeah I meant like they check if you got a valid reason for each intent
ah, yeah
will they just force intents in the future?
they are
One can be denied, one can be accepted
intent already are kinda forced
except message, which will soon be too
well i mean fully enforced
No bots with less 100 servers will not require it
login will also be a privileged intent
/s
For developing reasons
guild member and presence are already enforced. If you are getting your bot verified it needs to apply for intents you need. in a couple of months message would be too
Naa, downloading discord on pc or mobile would probably needs verification and a pre-nitro subscription
I guess it's more realistical it will require Nitro in the future

Depends on what events you need
Members joining/leaving for example do require the member intent
no, its to access guild member's status
well then i don't need privileged intents
There's no guild presence intent
although i will need it for when message intents come
like i said i'm smoothbrained with the new stuff
imma have fun fixing every code i have
oh ffs i've declared client twice for no reason
throw new TypeError('CLIENT_MISSING_INTENTS');
^
TypeError [CLIENT_MISSING_INTENTS]: Valid intents must be provided for the Client.
bitch what
Are you updating to v13 atm?
One message removed from a suspended account.
Yeah just open the guide and take a look at the changes djs made
You will have to update some more code
i swear to gosh discord.js is going to make me have an aneurysm
omfg they're really making me reinvite my bot

i knew i should've stuck with developing my bot instead of discontinuing it
ReferenceError: CLIENT_ID is not defined
anyone?
hey broken tooth does your bot use youtube api for music?
or what does it use
cuz if it does hope it doesnt get deleted like rythm and groovy
XD
they will just tell me to remove it right? since rythem is still a thing
and there a huge bots with music commands in them, i dont think they will first try to get a bot that is in 490 servers
yea i guess thats true
lol why did you ask me in first place?
because of the about me?
cuz if your bot grows it could get deleted for terms of service
and yes
sorry but no because i don't understand the topgg API i tryed on like adding it to my bot for like voting = something for like a week but it just didn't work so yea i gave up :|
i managed to make the voting works
with the webhook
hey
lol
he deleted the message
oh rlly what do you use it for?
my bot has economy in it, so they get 20,000 coins from voting
and it sends a message
in a channel
do you just use the discord coding or like discord js
o can you please send me the code for like the webhook for the voting
just saw it rn
Can just use the docs
https://docs.top.gg/libraries/javascript/#webhooks
name: 'ping',
description: 'Replies with Pong!'
}];
const rest = new REST({ version: '9' }).setToken('token');
(async () => {
try {
console.log('Started refreshing application (/) commands.');
await rest.put(
Routes.applicationGuildCommands(CLIENT_ID, GUILD_ID),
{ body: commands },
);
console.log('Successfully reloaded application (/) commands.');
} catch (error) {
console.error(error);
}
})();
const { Client, Intents } = require('discord.js');
const client = new Client({ intents: [Intents.FLAGS.GUILDS] });
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
});
client.on('message', async msg => {
if (!msg.isCommand()) return;
if (msg.author.bot) return;
if (msg.commandName === 'ping') {
await msg.reply('Pong!');
}
});```
ok markdown
```js
Code here
```
better
so my issue is nothing is happening
like the bot won't do anything
well except CLIENT_ID not being defined
What's the isCommand method?
👀
most people use double backticks for some reason
erwin included
detritus didn't serve him good
so like if the bot were to recieve a command, such as "/ping" or whatever it is, it should reply with pong
But where did you get that method from?
wait djs v13
discord.js v13 docs
I dont see it in v13 docs
well the main/stable
when you read an actual idiot's guide
i mean that documentation made me lose most braincells
Hmm 👀
You think that's bad?
Detritusjs documentation uses typedoc
404 just takes you to the homepage
Good navigation is undefined
and finally
NO DESCRIPTIONS FOR ANYTHING
ditch typedoc, return to monke
my feeble brain does not understand what the fuck that is meant for
It is the msg thing in client.on
OMG
has anyone here ever worked with fastapi?
umm no?
and i realized it's not
you have a ! in front of it so if it is false it returns true and if it is true it returns false
who here plans to leave their standard prefix commands in their bot after implementing slash commands fully
i mean sure, they wont work, unless you have message intents, but what if you plan to have those intents, and taking them out is more work?
me
i was thinking of leaving mine in until at least april
to give users time to get used to the slash commands, have both during a migratory period
Anyone know how i can fix this? Im not sure how the names are same
PS C:\Users\great\OneDrive\Desktop\New> node deploy-commands.js
Started refreshing application (/) commands.
DiscordAPIError[50035]: Invalid Form Body
4[APPLICATION_COMMANDS_DUPLICATE_NAME]: Application command names are unique
at SequentialHandler.runRequest (C:\Users\great\OneDrive\Desktop\New\node_modules\@discordjs\rest\dist\lib\handlers\SequentialHandler.js:198:23)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async SequentialHandler.queueRequest (C:\Users\great\OneDrive\Desktop\New\node_modules\@discordjs\rest\dist\lib\handlers\SequentialHandler.js:99:20)
at async C:\Users\great\OneDrive\Desktop\New\deploy-commands.js:31:3 {
rawError: {
code: 50035,
errors: { '4': [Object] },
message: 'Invalid Form Body'
},
code: 50035,
status: 400,
method: 'put',
url: 'https://discord.com/api/v9/applications/883983230645198859/guilds/836514366643896340/commands'
}
@novel jetty one of your commands has the same name
you probably copy pasted command template then forgot to change the code
{"message": "401: Unauthorized", "code": 0}
I only have this 2 and it doesn't seem to be the same
const { SlashCommandBuilder } = require('@discordjs/builders');
module.exports = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Replies with Pong!'),
async execute(interaction) {
const channel = interaction.client.channels.cache.get('878236244927209512')
await channel.send(`Pong!`);
await interaction.reply('Replied!')
},
};
const { SlashCommandBuilder } = require('@discordjs/builders');
module.exports = {
data: new SlashCommandBuilder()
.setName('online')
.setDescription('Angelus is online!'),
async execute(interaction) {
const channel = interaction.client.channels.cache.get('878236244927209512')
await channel.send(`Angelus is online!`);
await interaction.reply('Message sent!')
},
};
omg
ig it's a problem with the command handler
client.commands = new Collection();
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
// Set a new item in the Collection
// With the key as the command name and the value as the exported module
client.commands.set(command.data.name, command);
}
console.log client.commands and see what it says
A bot can't join a guild without a human using the invite
why does discordjs have guild.join anyways??
PS C:\Users\great\OneDrive\Desktop\New> node .
Collection(2) [Map] {
'online' => {
data: SlashCommandBuilder {
options: [],
name: 'online',
description: 'Angelus is online!',
defaultPermission: undefined
},
execute: [AsyncFunction: execute]
},
'ping' => {
data: SlashCommandBuilder {
options: [],
name: 'ping',
description: 'Replies with Pong!',
defaultPermission: undefined
},
execute: [AsyncFunction: execute]
}
}
huh
show the updating slash commands code
const { SlashCommandBuilder } = require('@discordjs/builders');
const fs = require('fs');
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');
const { clientId, guildId, token } = require('./config.json');
const commands = [
new SlashCommandBuilder().setName('ping').setDescription('Replies with pong!'),
new SlashCommandBuilder().setName('server').setDescription('Replies with server info!'),
new SlashCommandBuilder().setName('user').setDescription('Replies with user info!'),
]
.map(command => command.toJSON());
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
// Place your client and guild ids here
//const clientId = '875735026317262928';
//const guildId = '823963920984965131';
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
commands.push(command.data.toJSON());
}
const rest = new REST({ version: '9' }).setToken(token);
(async () => {
try {
console.log('Started refreshing application (/) commands.');
await rest.put(
Routes.applicationGuildCommands(clientId, guildId),
{ body: commands },
);
console.log('Successfully reloaded application (/) commands.');
} catch (error) {
console.error(error);
}
})();
I got it
It worked
Thanks
lmao
@earnest phoenix You know where i can define client?
const { SlashCommandBuilder } = require('@discordjs/builders');
const { MessageEmbed } = require('discord.js');
const { version } = require("../package.json")
module.exports = {
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Replies with Pong!'),
async execute(interaction, client) {
const embed = new MessageEmbed()
.setAuthor('Watcher')
.setColor('BLUE')
.setDescription(`Watcher is running on ${version} with ${client.ws.ping}ms`)
const channel = interaction.client.channels.cache.get('878236244927209512')
await channel.send({ embed: {embed}});
await interaction.reply('Embed Sent!')
},
};
It's throwing this error
TypeError: Cannot read property 'ws' of undefined
at Object.execute (C:\Users\great\OneDrive\Desktop\New\commands\ping.js:15:68)
at Client.<anonymous> (C:\Users\great\OneDrive\Desktop\New\main.js:40:17)
at Client.emit (node:events:406:35)
at InteractionCreateAction.handle (C:\Users\great\OneDrive\Desktop\New\node_modules\discord.js\src\client\actions\InteractionCreate.js:66:12)
at Object.module.exports [as INTERACTION_CREATE] (C:\Users\great\OneDrive\Desktop\New\node_modules\discord.js\src\client\websocket\handlers\INTERACTION_CREATE.js:4:36)
at WebSocketManager.handlePacket (C:\Users\great\OneDrive\Desktop\New\node_modules\discord.js\src\client\websocket\WebSocketManager.js:345:31)
at WebSocketShard.onPacket (C:\Users\great\OneDrive\Desktop\New\node_modules\discord.js\src\client\websocket\WebSocketShard.js:443:22)
at WebSocketShard.onMessage (C:\Users\great\OneDrive\Desktop\New\node_modules\discord.js\src\client\websocket\WebSocketShard.js:300:10)
at WebSocket.onMessage (C:\Users\great\OneDrive\Desktop\New\node_modules\ws\lib\event-target.js:132:16)
at WebSocket.emit (node:events:394:28)
@novel jetty there is no client passed to execute, you should remove it and use interaction.client
Where should i add interaction.client?
Ahh
hey i would want to scrape this chart. How would i ever do that?
link?
wahahha bruh

How did you do this bro
xD
f12, look at the requests
Network inspector 
i got an error in my brains here
you cant regex the html if the data is not included in the original request tho
but flaz's method was kinda easier to use
Use a headless browser and wait for the page to fully load and then evaluate the document inner HTML 
flaz's method is the correct method, i was about to post it but he found it first
xd
flaz, do you know how i can use network inspector to use i myself later on?
^
press f12 on your keyboard, click network, click fetch/xhr
oowh
then just look at each request
awesome guys. Thanks!
what is the best way to get fetch the info's on the site and log tthem?
node-fetch?
depends on how you want to handle the data
smaller size: phin
browser like style: node-fetch
cool: axios
it's just to get some data in json form
here
node fetch then
await outside async
also cool: bent
op: got
best: undici
const response = await fetch('https://api.nasdaq.com/api/calendar/earnings?date=2021-09-17');
const data = await response.json();
console.log(data);```why is it sendin the error: fetch is not a function
how did you import it?
const fetch = await import("node-fetch")
show full code
const Discord = require("discord.js");
const client = new Discord.Client();
const auth = require("./config.json");
const fs = require("fs");
client.on("ready", () => {
console.log(
"Your bot is Running on Discord. All checked and running!"
);
client.user.setActivity(`Stock gatherer!`, { type: "PLAYING" });
});
client.on("message", async (message) => {
if(message.content.startsWith(auth.prefix+'start')){
const fetch = await import("node-fetch")
message.channel.send("**The earnings screener has started successfully!**")
const response = await fetch('https://api.nasdaq.com/api/calendar/earnings?date=2021-09-17');
const data = await response.json();
console.log(data);
}
});
client.login(auth.token);
literally the whole file
question, how do i create a slash command
try using this instead
the code won't do it
yes you need the default import
it didn't error, but now i have an unsolvable promise that keeps pending
i mean what i'm currently using
i tried to do this for another site
but it didn't really work
Not all of them use an API
@eternal osprey you should try phin for just fetching data and converting it to json
phin?
You need to open the network tab and then refresh
If you open it after loading the page, it won't be able to capture the requests
flazepe remember sus npm logo
what language is this lmao
JSON
it's a javascript object but converted to a text file
I know.
their api should give you an overview of what the heck you're getting from the api
But i mean, the information in this json doesn't really match the one on the site
I am trying to get the market cap
of what?
v
found it!
node-fetch at 7.5 mb? That's just false 🤔
phin is at 2.1 kb
It's strangely called upravene
wat
yeah really strane
Oh ok
node fetch you fat bastard
their website is written in the slovak lanuae
here's a suggestion: add a command that gets market caps of cryptocurrencies
im tired of constantly opening coingecko
looks like polish
axios.get('https://www.finscreener.org/enginejs/cache/earnings/calendar/mapTyp1.json?t=1631900164069')
.then(async (response) => {
let m = await response
console.log(m)```the response is not logging?
i finally fixed my bot
the non-formatted value is right above it lel
for four hours i overlooked on piece of code
but yeah no idea why do that server side
it's polish with terrible grammar/spelling
kurwa perkele
I mean I know you can't use special characters but some of it doesn't make sense
you can still talk in Polish without them
they're just there to add accent and pronunciations
ąmóńguś
if it doesn't let me declare a variable named this the language is racist
bug
I was about to call js racist when I realised it does support characters from other languages
lmao
especially if it's python which is basically english
imagine Turkish people using that
oh shit
discord definitely sus
does zero width space or hangul filler work
embedMessage is not defined
define it
oh, unknown interaction
Make it known
ohhhh
I love these responses
discord gives me 5head errors for some reason
like sending a response after 3 seconds is a 404
response to an interaction?
the interaction token is deleted after 3 seconds, so it doesnt exist, therefore 404
I thought it lasted 15 minutes
how hard was it to store it for 5 seconds longer
15 minutes if you defer right? 3 seconds if not?
ah idk I don't interact
i don't command
Interaction tokens are valid for 15 minutes and can be used to send followup messages but you must send an initial response within 3 seconds of receiving the event. If the 3 second deadline is exceeded, the token will be invalidated.
https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-response-object-interaction-callback-data-flags
just defer your response, then send it later
also
sending an invalid response fucked my discord client
it showed sending command forever until i reloaded the page
Custom prefix is not mandatory for a bot right
nope
Ok thanks
if you get ratelimited just slow down
ah yes the floor is made out of floor
how do i delete a waiting message
you don't
discord hasn't thought out a lot of things
including getting a good development team
so what can i do
restart client
deferred or what
If it's deferred just delete it 4head https://discord.com/developers/docs/interactions/receiving-and-responding#delete-original-interaction-response
I think they mean the one that shows loading
that only shows to you
If our bot is verified and tho bot developer role is removed can we request the staff for the role?
i. mean. this
it's stuck doing it
using djs?
yes
embed
i'm trying to send an embed
how did you try to send it
why could it be
the role name is @everyone
aka <@&264445053596991498>
hmm WAIT
yea but what's the problemo
ReferenceError: role is not defined
what are u doing
epic embed fail
what are you trying to do man
I want to sort the roles in the menu and select a role from there.
but the bot shows the roles and everyone role
yes
So you want to show all roles except managed roles (bot roles) and <@&264445053596991498> role?
What version of Discord.js are you on?
12
Ah then you need to upgrade to v13
Role tags (which has the integration/bot ID) is implemented in v13
v13 is much harder than v12
You could use the raw API but that's a bit too much
What are the obvious changes?
i will work on my bot later, i spent way too much time on fixing it
is there any discord servers where i can get help with web dev
well its kinda js problem
i mean this channel is for development, not only bot development so you can ask any question you want related to development
it might be easier/better performing to use api requests rather than ejs for something like that
fuck web development especially frontend
if you disagree with me send your message to /dev/null
if you really want to use ejs for this.
https://stackoverflow.com/a/46615886/16910071
if i tell u what im trying to make wound that make it easier to see what i need to do as i might be doing it wrong
sure
its a website that im gonna be able to put my code onto it, and people will be able to see it and ect, so its like my github page but only for me
to get what is it in this, how I do this?
then this will work @azure lark
but how do i get all results from a mongo db
are you using mongoose?
yes
await Model.find();
will get all documents
and return an array
Model being your model
so can i just set is as a const then do found.options1 to get the option of data 1?
options1: {
type: String,
}
});```
its an array, so getting the first thing will be found[0] to get the first document
loke that, if its my scheme
getting options1 would be found[0].options1
so thats options1 of the first thing in found
and could i just do found.forEach(found => {
console.log(found.option1)
});
to log add the options1's
I’m having a bit of trouble with reactions. Whenever I react to the message, it returns “Reacted with neither.” Also, I’m not sure how I would get the user ID of the person who reacted. Any ideas?
Code: https://hatebin.com/qevrbikkdr
yep that works
alr
you should really be logging the error in the catch.
how would i use this https://stackoverflow.com/a/46615886/16910071 and the modle.find() together
instead of results as the variable, use found
then inside the loop, it would be found[i].options1
Hey! I have an inventory command for my bot, and i want items to stack, but i cant figure out how. I have tried for a long time, but havent found anything that works :/ Does any of you? Items are stored as objects in an array.
items probably would be easiest if stored as ints
for example
items = {
"sword": 5,
"shovel": 1
}
in this case this user has 5 swords and 1 shovel.
yeah
but what i dont understand is how i find the number of the same items
waaaait
im so dumb
i save items to the inventory as different objects
can anyone help me How do I add server Acknowledgements code in my userinfo command discord.py
this isnt working?
for(var i=0; i<found.length; i++) { %>
<p class="white-text">
<%= found[i].options1 %>
</p>
<% } %>```
code is my modle thgat i impprted in
you didnt await code.find()
ah
find is a promise
where do i add the async
the async goes with the parent function, if one exists
it dosent lol
then you dont need async, top level should be async already
it still shows nothing
the modle is
const CodeSettings = require("../models/settings");
then wouldnt it be CodeSettings.find();
no, when rendering the file i sent CodeSettings as code
can anyone help?
so your current code is
<% const found = await CodeSettings.find();
for(var i=0; i<found.length; i++) { %>
<p class="white-text">
<%= found[i].options1 %>
</p>
<% } %>
Correct?
its telling my await is only an async function
alright lemme look up ejs then
you need to provide async: true option to use await.
https://ejs.co/#docs
in your ejs.render method
how do i iturn it to true lol
the page i linked to showed it
it dosent tell me how to act do it lol
so just do:
async: true
}
const renderTemplate = (res, req, template, data = {}, options) => {```
yep
still same error
how are you using renderTemplate?
renderTemplate(res, req, "index.ejs")
it would probably just be easier to pass the data along rather than in the ejs file
renderTemplate(res, req, "index.ejs", await CodeSettings.find());
making sure
const CodeSettings = require("../models/settings");
is in the file
so like,
await CodeSettings});
});```
Hey! How do i change the value of an object in an array? I need to change the count value to count + 1, but nothing i have tried works.
renderTemplate(res, req, "index.ejs", {
data = await CodeSettings.find() }
);
inventory[0].count++;
will change the first objects value to +1 of what it is
yeah
but
there will be more objects soon
and i want it to be able to change those as well
do you know how you want to change them?
like searching for the item value?
no
inventory.find(obj => obj.item === "dog");
for example will get the first one(since its "dog")
can also do the same thing with count
i want it to be like if there is no document it should create one, and if there is a document with the same item name as its trying to create it should add 1 to the count
your looking for mongoose update then
https://mongoosejs.com/docs/api.html#model_Model.update
youll want to set upsert to true, upsert means "if no document is found create one!"
so by default it will update, if ones not found it creates it
youll also probably want setDefaultsOnInsert set to true, so it will by default set the new item count to 0
Wait
i think i explained wrong
the code starts with creating a document if there isn't any
and i want it to update the object, and if there is no object with that item value it should create a new object
You can find with this, use .count++ on it and save in a variable.
If(!variable) //will be true if its empty create a new obj and push it
Actually that might error
I’m having a bit of trouble with reactions. Whenever I react to the message, it returns “Reacted with neither.” Also, I’m not sure how I would get the user ID of the person who reacted. Any ideas?
Code: https://hatebin.com/qevrbikkdr
Also related to logging the error I’m dumb and didn’t put a check
show us the $event file
is discord planning to improve the ui for slash commands so that the subcommand grouping is more organized?
anyone here ever used projectsend?
I need to add Microsoft (Called windows live on there) Oauth but its giving HTTP ERROR 500
const text = `\n[DATABASE - ${date} EST]: Database Action: Updated Comissions status to false.`
await fs.writeFile("../DatabaseLogger.txt", text, (err) => {
if (err)
console.log(err);
})```
no errors being printed, nothing being logged onto the txt file
ok but can you attach files on slash commands?
like upload files and not just link them
well, no ig
rip
but hey, ephemerals are no longer useless
exdee
although I still wish I could send ephemerals directly
ye
depends
why is the object inside an array?
but you said you didnt want multiple?
it cant do that, its not possible
do you mean this? ```js
[{
"1234": [{
"user_id": "123456789123456789"
}],
},{
"1234": [{
"user_id": "123456789123456789"
}]
}]
just remove the outer array
make it like this
{
"1234": [{
"user_id": "123456789123456789"
}],
"12345": [{
"user_id": "123456789123456789"
}]
}
arrays = access by index
objects = access by key
because its an array
why so many arrays inside arrays lol
dont use arrays then, use the object directly
thats what objects are for?
objects cannot have duplicate keys
I’m having a bit of trouble with reactions. Whenever I react to the message, it returns “Reacted with neither.” Also, I’m not sure how I would get the user ID of the person who reacted. Any ideas?
Code: https://hatebin.com/qevrbikkdr
Also related to logging the error I’m dumb and didn’t put a check
why do you need 1234 to be inside an array?
does it say that after 20 seconds or after you react?
again, why is the 1234 object inside an array
yes
yes what? which one?
sorry after 20 sec
but you said you want them to not have duplicates
objects do not allow duplicates, arrays do
exactly
that's impossible in an object
bruh
again, literally remove the array
arrays are only if you need to store duplicate values and/or access by index
maps are if you won't add duplicate values and/or access by key
let obj = {};
if(!obj["1234"]) { obj["1234"] = []; }
obj["1234"].push({channel_id: "82374682763482"})
what are you trying to do?
does this log anything?
no
then something is wrong with your filter
try filter = () => true
and see if it logs
and why cant you use what i said?
what i said literally does what you are describing
?
Doesn't seem to log anything.
Code: https://sourceb.in/5Y5pdVTLk1
still doesnt explain why what i said wouldnt work
whats your discord.js version?
v13
yes
does it still send reacted with neither?
yes
t[new_id_here] = []
put console.log(collected) inside the catch
aight
Make sure u have reaction intent
comparing ssd to hdd is not fair on any level
I mean, hdds at least are big
and cheap
oh. it prints out TypeError: Cannot read property 'author' of undefined.
there you go
<prop>.author prop is undefined
oh i see. mb sorry u had to walk me thru that lol. thx
why are you still using an array?
Why not just use a cache
isnt that what hes doing?
How would I get the ID of the user who's reacting to a message?
Code: https://sourceb.in/BBVeRKUsJH
put it back in the filter
so smth like this?
return ([":white_check_mark:"].includes(reaction.emoji.name) && user.id != message.author.id);
filter = (reaction, user) => reaction.emoji.name === ✅ && user.id !== message.author.id
but if you want reactions for multiple users, you have to check reaction.users in collected
or use a reaction collector
awaitReactions is good for single user
aight. thx 👍
Sorry to bother, but is it possible to remove the time limit? Ex. just to send the message "yes" whenever the user reacts instead of waiting 10 sec?
Code: https://sourceb.in/9Djrtx8oxx
yea rn it waits 10 sec tho. it would be nice if immediately whenever the user reacts it sends the message "yes" or whatever.
put 1 ig
ex. if there is this message:
asdf
and i react
the bot still waits 10 sec
before doing whatever
set the max to 1
Woo
alr ill try that.

