#development
1 messages · Page 1922 of 1
or am I wrong
Probably still cached
mmm I see
I always had the issue of it being empty
Whenever I fetched a user and saved it to a var
after banning the var was empty
Hmm np was just assuming you might be on v13
since the user no longer existed in the guild
nor .values or entries worked, but .keys worked
but it filters unobtained cards
it does the opposite to what I want
What exactly are you trying to do
Just invert za boolean
ima let kuuhaku talk
:p
one more thing regarding v13
Ping me when this convo is done so I can ask another one pretty please 
Nono, come back
i'm trying to filter the unobtained cards from the obtained
just go ahead and ask
It probably takes a few seconds before the event being sent by Discord and until it’s being removed of the cache
I can help
Oh okay
const config = require("../config.json");
const Discord = require("discord.js");
const db = require('quick.db')
module.exports = {
name: "dmad", // Command Name
description: "Bans a member from the server. ", // Description
aliases: [" "], // Aliases
usage: " ", // Usage
guildOnly: false, // If Command In DMs return
admin: false, // Bot Admin only
async execute(message, args, client) {
let prefix = config.prefix
const member = message.mentions.members.first();
const proof = args.slice(1).join(' ');
if (!member) return message.reply('Mention a user!');
if (!proof) return message.reply('Tell me a You need to include PROOF (`nah dmad <@user> <proof>`) **proof needs to be a screenshot LINK**');
member.ban({days: 7, reason: `DM Advertising | Moderator: ${message.author.tag}(${message.author.id})`});
message.delete();
let channel = db.fetch(`logs_${message.guild.id}`)
const embed53 = new Discord.MessageEmbed()
.setColor("RED")
.setThumbnail(message.author.displayAvatarURL({ dynamic: true }))
.setFooter(message.guild.name, message.guild.iconURL())
.addField("**:bot: Case Type:**", "```Ban```", true)
.addField("**:premium: Target**", ` \`\`\`${member.user.tag} ${member.id} \`\`\` ` , true)
.addField("**:moderator: Moderator**", ` \`\`\`${message.author.tag} \`\`\` `, true)
.addField("**:developer: Reason**", ` \`\`\`DM Advertising\`\`\` `, true)
.setImage(proof)
.setTimestamp();
var sChannel = message.guild.channels.cache.get(channel)
if (!sChannel) return
sChannel.send({ embeds: [embed53] })
process.on('unhandledRejection', error => {
console.error('Unhandled promise rejection:', error);
});
message.delete();
}
}
It doesn't do anything after ban
does no one know how to discords syntax highlighting

Don't tell me its another easy fix breh
Paimon has gone to sleep now
I don’t
Not even available on mobile 
@earnest phoenix So how would I make it do stuff after it bans the user? As per rn it stops right as it bans. 🤣

For me JS highlights
ban after its done
ofc you wanna check if they are bannable before doing anything about banning em
let a = 1 + 1
Ik what you wanted to say
its what I do
Ha discord knows you use php so they are booling you
Okay, so another dum question 
Does
if (command ==== 'on') {} Not work in djs v13 either?

depends on what command is
Pergunta em #support
Ok
const config = require("../config.json");
const Discord = require("discord.js");
const db = require('quick.db')
const { version } = require("discord.js");
const moment = require("moment");
const m = require("moment-duration-format");
let os = require('os')
let cpuStat = require("cpu-stat")
const ms = require("ms")
module.exports = {
name: "emergency", // Command Name
description: "List all of my commands/info about a specific command.", // Description
aliases: ["h"], // Aliases
usage: " ", // Usage
guildOnly: false, // If Command In DMs return
admin: false, // Bot Admin only
async execute(message, args, client) {
let prefix = config.prefix
const cmd = args[0].slice(prefix.length).toLowerCase();
if(cmd ==='on') {
message.channel.send('Yes')
}
}
}```
As long as cmd = on
then yes
huh?
It doesn't work tho.
then log what cmd is
:p
how?
chances are the issue lies there
Got something for you
console.log
It didn't log either @earnest phoenix
#general message got somethin for u as well
Show what it logged?
const cmd = args[0].slice(prefix.length).toLowerCase();
if(cmd ==='on') {
console.log('Yes')
}
}
}```
Right?
;-;
no
lol
very much no
if cmd is not = on
then anything in that if statement wont work
o-o
log cmd outside the if statement
it might be easier to mention that I learn by example or my simple words
console.log(cmd)
alr
It logged a space
also some people hate looking at screenshots so you can copy and paste logs
It logged 1 space.
You better move to a mention as prefix soon or slash commands
then cmd is nothing but a whitespace
April is coming
its fine for now fake
Winter is coming
people under 100 guilds can use the message priv intent without being verified
Well a mention as prefix works as well as I said
so its not exactly mandatory
Error:
const cmd = args[1].slice(prefix.length).toLowerCase();
^
TypeError: Cannot read properties of undefined (reading 'slice')
at Object.execute (/home/runner/nah-moderation/commands/emergency.js:22:23)
at Client.<anonymous> (/home/runner/nah-moderation/index.js:173:13)
at Client.emit (node:events:390:28)
at MessageCreateAction.handle (/home/runner/nah-moderation/node_modules/discord.js/src/client/actions/MessageCreate.js:25:14)
at Object.module.exports [as MESSAGE_CREATE] (/home/runner/nah-m```
what is args
debug 101
figure stuff out
Still in early stages building that can already respect the upcoming restrictions
true
Personally if I make a discord bot again it wont have message commands
it will use application commands
They are actually okay
Its not working
Literally trying everything, and its not working with command === 'on'
I'm prefix commands gang
I also have so many usages where stuff aren't even prefixed
Like link detection and interactive games
Interactions can't do shit outside of question-answer stuff
slash has more benefits imo
ofc in a bot like that its not as important
but in a rpg bot for example it relies on the use of commands
and having the ability to not have to check for args and shit
discord does it for ya
as long as you specify the argument is required discord wont let the command run without specifying it and its right type
Rpg as in afk games right?
Cuz for actual tabletop rpg you'd be better not having to type commands
That’s probably what guilds commands are for to let users respond with something you can dynamically deploy as command within seconds
Since any other content without a bot mention doesn’t exist anymore
wait wut
Yeah I guess
Wait im confused
Exists
what does this mean
how can I hide a command folder from the help command?
dont specify it as a command folder to be displayed?
No mention || no intent = no message
So basically
👀
A deaf bot
The messages we are typing right now, wouldn't cause the message even to fire
unless we mention the bot
commands are loaded from the handler
Dehydrated water
wut
Doesn't that make a lot of bots useless?
It would, It would have the message author and stuffs, just not the message content
Paimon was right
I mean you can get the intent tho
if you have a valid reason
TypeError: Cannot read properties of undefined (reading 'print')
at Fastwipe.run (/app/Commands/Collection/fastwipe.js:217:57)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
I can get this in different places, but error always the same, and when I recheck it, it's alright. But sometime it appears again, what can be the problem?
So wait
With the intent you get everything
Yes
Yeah, just like it is now
You just need to convince discord you need it
Yea and intents are not hard to get either
Show fastwipe.js line 217
I mean you literally just gotta tell em without the intent the bot is fucking useless
so
Damn 2 min without a network connection and I completely lost the context
Lol discord provided intents for my friend for message edit and delete logs
I lowkey hate the idea of priv intents
Yet they declined people who wanted it for XP system

So its not that hard to get it anyways
Are they already asking people to apply for it?
Well xp systems dont need message content if you think about it
Yea
They have a good reason, just a gross implementation
Spam detection tbh
Like, to prevent xp farming
I assume content length as well
Eh dont xp systems have a cooldown of like 1 min ?
MEE6 has that
Idk, it varies a lot
and most of em have that
I mean ye good reasons but still can't help but hate it
:p
it is an annoying process
let k = 2 + Math.trunc(50 / joinData[0].print)
This error is not about this line, I can get it in different places.
Before this line is await getting data from db
Well it wouldnt be private if everyone followed all the rules. there are some kids who misuse bots
joinData[0] could return undefinded
All services are born pure
^^
It's the kids who destroy em
Okay so back to my original question. Is there a way for the bot to delete the previous message?
truth
Fetch it
Can you elaborate?
Would I have to add that message to a DB?
What language?
djs v13
Just fetch the last sent message in that channel by your bot
Then edit it or well delete it if you like to
Actually, I'm more concerned abt what kind of ads it does
How would I even do that? Didn't even know that was a thing ._.

Its like whenever someone sends a message in the channel, the bot would send this message. Like a info thing
Yeahh^
So no dm ads right?
Atta boy
I'm just so confused on how to fetch the last sent message tbh, I am just picking up djs v13, cause I've been on djs v12 for the longest time frfr.
Even then, I thought I knew all djs v12 but I never knew you could fetch the most recent sent message in a channel.
There is no big changes, just read the docs and everything should be clear
So something like:
let channel = message.channel()
channel.messages.fetch({ limit: 1 }).then(messages => {
let lastMessage = messages.first();
if (!lastMessage.author.bot) {
lastMessage.delete()
}
})```
?
Then send the new embed etc?
Also check message author
if (!lastMessage.author.client) {
Why limit 1?
Cause it should only have 1 message by the bot per channel.
If u limit to 1 it'll ignore if last message is not from the bot
The embed should be the most recent sent message.
So limit it to like 15-30 ish?
Does the bot automatically reply with this ad embed if somebody sends a message in that channel?
Yes.
Then, once another person sends a message
it would delete the previous embed
and post the emebd after the most recent sent message.
Ah okay
Also in like 10 channels
All the channels are in a array
So I am just confused on how to stick the embed to the most recent message.
Anyone got any examples or a expanded explination?
Well you have to think per channel
Another option is to store last sent embed message's ID in a map
So you can fetch by id on next message

If a user writes something in predefined channel, check if it’s a text channel, then fetch the channel messages, delete the last one sent by your bot, then send a new one
Or yeah store the last message ID
o-o
Which is most likely more efficient
How would I store it in a map?
This is so confusing, literally a beginner now lol, and I thought I had it all figured out 🤣

A json, think of a map like a json
Fetching whenever a message is sent in that channel really is a bad idea
Think of if a discussion moves into that channel
For whatever reason
The bot is set to delete any messages in that channel w/o a link or w/o 100 charecters
Alr thought of that 😉
Well saving or at least caching the last message ID actually really is a good idea
Can you give me a example of how I would do that?
I don't wanna be blunt and ask for code, but like when it comes to new stuff I can literally only learn by example and its just how I was built ig 🤣
You can also fetch this message and check it’s created timestamp and let your bot repeat that embed only if for example 5 mins have passed
Like a basic cool down to prevent multiple people typing in that channel let’s your bot begin to spam
Then if it goes inactive for 30+ minutes they won't see the last posted at
My server has 300 members
There is no way it will get 1 post per/5 min
I mean maybe
but eh
I think the json one would be a good idea.
Anyone think they could give a code example by chance if at all possible?
You just need to remember it'll not persist between restarts
But u can use both methods if u must
When you send the embed save the resulting message ID somewhere
Like a global map
<Map>[channel id] = message.id
Then when u send another message just check for the saved id for that channel
Don’t need to create a database or JSON file for it
Use the already existing channel cache
Adding a new property to the channel
Containing your message ID or better a map with the ID as key and the message object as value
.....
I give up, lol. My brain is fried, I can just go w/o it. Tysm for your time tho! Hopefully once I dive into discord.js v13 more I can understand what all that means^ 🤣
That’s not djs related
Ah true, I forgor js allows adding properties for anything that moves
Aye
let map = new Map();
let send = channel.send(your_embed);
map.set(send.id, send);
message.channel.lastBotMessage = map;
Something like that
then message.channel.lastBotMessage.delete()?
Next time you check if channel.lastBotMessage && channel.lastBotMessage.has(…) and so on
No that’s just the cache of your last message

That’s just a simple var containing your last message in a property of the channel

If the property exists and has something in it (length not 0) then it’s a message sent by your bot in that channel
You gonna loop through that map and delete all messages by their ID it has stored
Than clear the map
Then send your message
Then add its ID to the map again
Can’t actually write a code example on mobile
you lost me at map I use quick.db, so maps are something that I have no idea how to use.
Yk what, im just wasting your time at this point. My bad.
No can’t happen
Oh my, my brain capacity is not big enough for this 
Should I send the code that I have rn?
message.channel.addMyUniqueFuckingVar = "something";
So you can see what I alr have.
Bad idea tho code blocks on mobile without syntax highlighting are a nightmare to watch
And I’m going to sleep after this shower anyways 
Ah
We can continue that later on
What you need to understand is you can simply add a new property to any existing structure
Receiving a message, then message represents your message object
message.channel the channel object it was sent in
message.author the user who has sent the message
Right?
Means you can simple add properties to the structures
message.channel.thisPropertyDoesntExistYet = "test";
Next time someone sends a message in that channel
You can access that var
It now exists in your cache until you restart the app or delete the property
@earnest phoenix
Using …send() returns a promise
The whole message object you sent
hm
Means that’s the way you can easily get its ID
let send = await message.channel.send(your_embed);
message.channel.lastSentMessageByMyBot = send.id;
Next time someone sends a message
You can check if that property exists for that channel
Prototype pollution 😐
Propopype pollupion
imagine not
@earnest phoenix
You can easily test what I mean, may that helps
Head to your messageCreate event and write console.log(message.channel.testProperty); above anything
Then directly under it message.channel.testProperty = message.id";
Now send two messages in the same channel and watch your console
Result will be undefined and a message ID
That property testProperty now only exists for that channel
Sending a message in another channel will again log undefined
Because there’s no property testProperty for that channel yet
u guys ever heard of this server
yea
very very
i heard someones name is cosmic stinky
bit rude if u ask me tbh
Hey guys how do I install discord.js V13?
ello boys and girls
repl console go brrrrr
I dont even think you can update node on repl
if you can it is either super annoying or a simple method that isn't documented well
I've heard it is super annoying to do so
cool
can you not reply to me every single time
you can simply just respond
make a .replit file and put this
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
export NVM_DIR=\"$HOME/.nvm\"
[ -s \"$NVM_DIR/nvm.sh\" ] && \\. \"$NVM_DIR/nvm.sh\"
[ -s \"$NVM_DIR/bash_completion\" ] && \\.\"$NVM_DIR/bash_completion\"
nvm install 17.1.0
node index.js
"""
it will install node 17.1.0, u can change versions by replacing the "17.1.0" in the .replit file code
its neither super annoying nor documented in replit (||i guess||) it just takes little more time than normal to startup the bot on "run" (||this is a ping disabled reply||)
Hey, has anyone used firebase hosting?
can i use try in a single code block multiple times ?
You can nest them
tip from tim: every discord.js object has a .client property so you don't need to pass client to every command
example:
const client = message.client;
codewars has node 10 and 8 most katas don't even have babel to use new features
can i get help
yep
i am clicking on submit button not showing anything
A weird thing huh. I see almost daily 4 different servers in my log that removed my bot.
The thing is though; These 4 servers are always the same and they always get logged at the same timestamp. Any ideas where the problem is?
go to your package.json and add this in it
"engines": {
"node": "16.11.0"
},
then it should update the node version when you do npm install
here's the example
Just use the autoposter and it has a timer on it by default. 🙂
topgg autoposter its in the api documents
npm i topgg-autoposter
if you use javascript its this
const client = new Discord.Client() // Your discord.js or eris client (or djs ShardingManager)
const { AutoPoster } = require('topgg-autoposter')
const ap = AutoPoster('Your Top.gg Token', client)
ap.on('posted', () => {
console.log('Posted stats to Top.gg!')
})
That or frequently sending a POST request to topgg including your guild count
ah
yeah autoposter not for java
hasn't been updated in a while
oke
Well then use a library to create http requests and do it yourself
Every 30 min or hour is recommended
At least the auto poster sends the requests every 30 min if I’m not wrong
yea every 30 mins
More frequently would be nonsense
Well I’m sending it via an interval every 30 min triggered in the ready event
If I have to restart the app multiple times for whatever reason this prevents spam
Not that the count on the site would actually matter and the fact topgg is being cached so badly it’s not up to date most of the time anyways for the users
So I’m trying to redirect all traffic to one route, something like a maintenance route but it keeps redirecting too many times
I wanna redirect everything from “/**” in the firebase json
You would have to exclude the route you want to redirect to
/maintenance.html
will match /**
Loop detected
Yea tried that, but it’s not loading the js for some reason
I excluded the route I’m trying to redirect to, it just shows a blank page
lmao
nope
that just tells npm you have node 16 it does not install it
...because script.js turns to maintanence.html?
it does its the node engine that the project uses and if the pre installed version is older version it updates it to the version that is stated as the engine
tried that, doesn't work
that only works in a managed environment like glitch or heroku
its not part of node or npm itself
if you run that on a vps it will not work
it just tells npm that the project requires that node version, and it will show a warning if you run it with the wrong version
basically your entire project has to run inside a system that reads, detects and auto installs everything based on your package.json
those systems exist but are not the norm
Yeah mostly, anyway I can ignore css files?
Same thing is happening with css files, I’m able to see the css being downloaded over the network but doesn’t load on the page
Anyway I can ignore those?
Have you checked the console for any errors?
I’m firebase Json
Yeah only bootstrap css isn’t found there are no errors after that
try ignoring anything that ends in .css, .png, .jpg or .js
Well there no errors in console, it doesn’t load css or images
Yeah how do I put that in the firebase json file?
i do not know
‘’’redirects": [
{
"source": "!/maintenance.html",
"destination": "/maintenance.html",
"type": 302
}
],
‘’’
What I currently have
I'm not good at this, but y an exclamation mark?
you dont need a dot (.)?
Exclamation indicates that redirect everything except that route
Just looking for a way if I can extend this to not apply for images and css files as it’s not allowing them to load
As of right now my bot is being coded in discord.js V12 as V13 breaks my bot
V13 is not meant to break bots , what's the issue with it that u referring as"break"
Is there a reason to why many of the topgg api packages aint working anymore?
the script is run before the browser renders the page
put the <script> at the end of <body> or put a defer attribute on the tag
@delicate shore
Thanks for this
what about this
read what I said again
I did
this issue got fixed
the only one is the first one
the inline event handling one
document.getElementById('save').addEventListener('click', save_options);
tried this
got an error
cannot read event listener of null something like this
Cannot read property 'addEventListener' of null
how does your html look like rn
<html>
<head>
<script src="index.js" defer></script>
</head>
<body>
<label>
Input API Key
<input type="text" id="wptk" />
</label>
<button id="save">Save</button>
<div id="status"></div>
</body>
</html>
<!--formating-->
try console.log(document.whatever)
one minute
unrelated but are you supposed to put the input tag inside of label?
I don't know
Also I am getting this error as well along with the previous one
Hey I Have made my own bot dashboard can anyone help me how to do this
i want to get weebhook message when some one login
my code is in js
// when someone login
weebhook.send("some dude loggined");
okay so no longer getting error
yes i want to do that
nevermind jinxed it
I have never encountered csp issues myself maybe tim can help
i am not getting enough sources for docs can u help if u have any
why would there be docs specifically for that
uff , ;-;
idk how your login system works but on your server when someone logins you redirect them to the dashboard right?
yes
yo I got another issue
When I fetch the data normally
is it confusing 0 for something
should I show you my fetchDislieks function
probably
async function fetchDislikes() {
const videoId = new URLSearchParams(window.location.search).get("v");
const endpoint = `${BASE_ENDPOINT}/videos?key=${YT_API_KEY}&id=${videoId}&part=statistics`;
return fetch(endpoint)
.then((r) => r.json())
.then((r) => parseInt(r.items[0].statistics.dislikeCount));
}
This is working on any video with over 1 dislikes
but with 1 or 0, it doesnt work
youtube is removing dislike counter
they are probably scared for rewind 2018
maybe that's the problem?
Weebhook
the bot is named anime hub
OH
also can you suggest a name for the pastebin ripoff I'm making?
Also why it does this
function editDislikes(dislikeNo) {
// Fetch the dislike label
const selector =
"ytd-menu-renderer.ytd-video-primary-info-renderer > div > :nth-child(2) yt-formatted-string";
const dislikeLabel = document.querySelector(selector);
// Update the label with the new dislike count
const formattedDislikes = convertToYTThousands(dislikeNo);
dislikeLabel.textContent = formattedDislikes;
}
because youtube
why
useless variables
icantbelieveitsnotpastebin
what happens on youtube rewind 2018
NICE
function convertToYTThousands(num) {
if (num < 1000) {
return num;
}
if (num < 1000000) {
return `${Math.round((num / 1000) * 10) / 10}K`;
}
return `${Math.round((num / 1000000) * 10) / 10}M`;
}
what you mean
https://www.npmjs.com/package/number-abbreviate @earnest phoenix
this exists
(num / 1000000) * 10 is the same as num / 100000
we are reviewing youtube source code
ah
you have to remember youtube is an ancient site
I cannot use it
theres probably shit code left behind
👀
I am not using nodejs
vanilla
so what should I use
website?
As in js on a website?
web js
yea
yes
plain javascript with no libraries
okay
that's what vanilla means
no modding
and ask if it can do that
how can I not use detritus
bruh
You able to use jquery?
never used it dont wanna riask it
function abbreviateNumber(value) {
var newValue = value;
if (value >= 1000) {
var suffixes = ["", "k", "m", "b","t"];
var suffixNum = Math.floor( (""+value).length/3 );
var shortValue = '';
for (var precision = 2; precision >= 1; precision--) {
shortValue = parseFloat( (suffixNum != 0 ? (value / Math.pow(1000,suffixNum) ) : value).toPrecision(precision));
var dotLessShortValue = (shortValue + '').replace(/[^a-zA-Z 0-9]+/g,'');
if (dotLessShortValue.length <= 2) { break; }
}
if (shortValue % 1 != 0) shortValue = shortValue.toFixed(1);
newValue = shortValue+suffixes[suffixNum];
}
return newValue;
}
there
vanilla js
without jquery
I have my own question now
I have two NextJS api routes for managing data in Mongoose:
pages
/api
createPaste.js
deletePaste.js
How do I "share" the same mongoose connection to every file to prevent multiple connections and rewriting code?
Is there a value passed to every page?
Like an object
like how in express you have req, res
Error: socket hang up
at connResetException (node:internal/errors:691:14)
at TLSSocket.socketOnEnd (node:_http_client:471:23)
at TLSSocket.emit (node:events:402:35)
at endReadableNT (node:internal/streams/readable:1343:12)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
{ code: 'ECONNRESET' }
What can be problem?
yep
You lost connection
there's a req and res object for api routes
Amazing
middlewares are in beta
host lost connection?
Thats basically the only way
Seems like it yes
idk about djs users but don't use beta for production
I mean
you need to not make it async
if you make it async it'll return a promise
igor lurking in chat
Async functions always return Promise<T>
I dk what tf should I do anymore
git commit -m "!life"
Either you need to await your function call, or get rid of the async keyword in the function if you don’t need it
google has banned your account for complaining
@earnest phoenix there is this workaround https://nextjs.org/docs/api-routes/api-middlewares
wtf now
// Helper method to wait for a middleware to execute before continuing
// And to throw an error when an error happens in a middleware
function runMiddleware(req, res, fn) {
return new Promise((resolve, reject) => {
fn(req, res, (result) => {
if (result instanceof Error) {
return reject(result)
}
return resolve(result)
})
})
}
async function handler(req, res) {
// Run the middleware
await runMiddleware(req, res, cors)
// Rest of the API logic
res.json({ message: 'Hello Everyone!' })
}
export default handler```

Because you’re not awaiting an async function
Show the code and show what you’re using to call the function
can someone explain how he is editing youtube
probably tamper monkey or some shit
Yeah
wait
I feel like I am high
on drugs
I just ran node . on a non nodejs project on a literal chrome extension code
ayo how about I create a db.js file that exports the mongoose connection and import in every api route
that video is so dumb
i read a book called they both die at the end and (spoiler alert) ||the countdowners app is a blog for people who are about to die, not a countdown of your death||
Sorry if this isnt the place to ask but
I'm getting the "Missing Access" error when starting the bot. I've read the faq channel in the discord.js server and have already kicked it and reinvited it with the application.commands scope enabled but I still get the error
jokes on people with spoilers always enabled
||never gonna give you up||
what code is causing the error
I have seen that
This
await client.guilds.cache.get(g.id).commands.set(arrayOfSlashCommands);
I never knew we had to pay a fee
apple's fee is 99$ a year
hello
ah yes, mchema
use a vm 
to stop abuse
@wheat mesa how does this look
meanwhile I'm using mongoose even though xetera said it sucks
what does your db schema look like?
you can use whatever you want, my opinions are just words at the end of the day
that hits hard
anyways what's the best way to send/parse form data using fetch api
I'm currently using url params
uh I think you have the wrong database
you have no table called scores
oh
ok well you definitely don't want a table named data
What do you wanna do?
you need to think about how you're going to model your data first
what's exp? what are you building?

I know what exp is
is it something a user has?
or a guild?
or an exp on an item
ok yeah alright
so you probably want that to live alongside the user information in a table I would probably call user
sure
There's no guild column to use the where clause
right they just copied an unrelated example online
if your experience is global you just sort the user table by experience and limit to top 10
Or just the top 10
if it's guild specific you're going to need to do some joins
Stringified JSON is all you can do as far as I'm aware
lol no
The LIMIT is 10, if there is less, 10 is still the LIMIT
not the amount
What type of db is that? Doesn't it need to be awaited?

What type of db is that?
I wonder if prepare is the method for prepared statements
Means to insert or update stuff, not to get it in this case
db.all("SELECT * FROM my_table", function(err, rows) {
rows.forEach(function (row) {
console.log(row);
})
});
Or
db.each("SELECT * FROM my_table", function(err, row) {
console.log(row, row);
});
Your row contains all columns
If you SELECT ALL
ALL = *
eh what
The result is sorted by your ordner clause
in this case descanding
If you wanna sort ascending then ORDER BY exp ASC
how am I creating the same model twice?
and now it's fixed by using commonjs ???
nvm not fixed
on the first request to the server it works and then nothing works
first request 201, next request 500

aren't imports cached in nextjs? how am I creating the same model again if i'm not importing db.js again?
What's another way to create a message collector rather than using a class for it?
and I'm back... my DNS server rebooted 
Well the column is called exp
So it's row.exp
Or taking the result you got (which is an object) and interact with it
just select everything, order by exp and limit to 10. Not sure what the issue is
let toplist = [];
db.each("SELECT * FROM data ORDER BY exp DESC", function(err, row)
{
console.log(row);
toplist.push(row);
});
Push it to an array if you wanna use the result outside
that won't work
the callback is asynchronous so the stuff outside runs before array.push
ahh didn't know that
console.log the result and figure it out
do you think console.log would mutate the thing you pass it?
if it has things you don't need, select the stuff you need instead of using *
fix what?
ah
let arr=[];
//in each loop
arr.push(...)
//send message
message.channel.send(arr.join('\n'))
You better use db.all()
db.all("SELECT * FROM data ORDER BY exp DESC LIMIT 10", function(err, rows)
{
console.log(rows);
for(const row of rows)
{
console.log(`${row.username} has ${row.exp} xp.`);
}
});
You can interact with rows
What's another way to create a message collector rather than using a class for it?
Is there some type of createMessageCollector or something.
well what did you do?
You need to reply outsite the rows loop
OR it will reply any iteration of course
db.all("SELECT * FROM data ORDER BY exp DESC LIMIT 10", function(err, rows)
{
let toplist = [];
for(const row of rows) toplist.push(row);
// reply here joining your toplist array
});
keep in mind the array items are still objects
you gonna join() the item.values()
db.all("SELECT username, exp FROM data ORDER BY exp DESC LIMIT 10", function(err, rows)
{
let toplist = [];
for(const row of rows) toplist.push(`${row.username} has ${row.exp} xp.`);
let embed =
{
author: { name: "Fancy toplist" },
description: toplist.join("\n")
};
...reply({ embeds: [embed] });
});
you can just use map fyi
let toplist = rows.map(row => `${row.username} has ${row.exp} xp.`)
you can just use map fyi
Yeah but I'm trying to explain how it works
Rust looks cool maybe I should learn it
yeah you can also add fields to the embed inside the loop and send the message outside
whatever you like
I don't always prefer the shortest way
Does anyone have experience with highlight.js plugins? 😩 How do they work
The docs suck ass
like wtf
6 hours debugging >>>>> reading shitty docs tbh
prism is better
Prism's docs aren't looking much better LMAO
Very easy to extend without modifying the code, due to Prism’s plugin architecture. Multiple hooks are scattered throughout the source.
But yes I'll probably switch
pretty sure field names cannot be empty
you probably have to use a zero width space
just use the description with newlines
You still add an embed field every iteration
Take a look again on that one
Or map the rows, the same but a little bit shorter
ok
How do you wait for the collector to finish before starting with Code.findOne({....
Should I create a new promise?
I will never understand the usage of a collector when using interaction.
You always receive the event if somebody presses a button.
That is your "collection".
Just way more complex than needed.
Also good thing is buttons have no timeout. You can press them always until you disable them.
where did you define it?
row doesn't exist at the point
need to put it in the map then if you wanna calculate it
depending on the current row being looped
dont use a collector, use awaitMessageComponents
Honestly, the moment I used that code got 10k people attacking me not to use it. 
^^
Correct.
Permissions.FLAGS.SEND_MESSAGES
Permissions as in const { Permissions } = require('discord.js');
const checkMutes = async () => {
console.log('Running')
const now = new Date()
const conditional = {
expires: {
$lt: now
},
current: true
}
const results = await muteSchema.find(conditional)
console.log('Passed Mongo!')
if (results && results.length) {
for (const result of results) {
const { guildId, userId } = result
const guild = client.guilds.cache.get(guildId)
const member = (await guild.members.fetch()).getHours(userId)
console.log('Passed mongo FOR!')
const muteRole = guild.roles.cache.find(roles => roles.name === "Muted")
member.roles.remove(muteRole).catch(() => null)
}
console.log('Passed FOR!')
await muteSchema.updateMany(conditional , {
current: false
})
console.log('Passed update!')
}
setTimeout(checkMutes, 1000 * 60)
}
checkMutes()
it's log Passed Mongo! then it stops and it do that again but it didn't remove the Muted role or edit on the data!
all interactions expire after 15min including buttons
well, if nothing is logged after if(results && results.length) then its easy
just console.log(results) and check why
No you can press buttons after days
It will trigger a new button interaction
Changed my internal structure since I noticed that
The whole slash command part is a structure and now additionally other interactions
Loading the file structure to a map saving it like commands using the name as the interaction custom ID is a different structure which can always respond to interactions
Other than slash commands which will expire
If you wanna get rid of people using the button than disable it
I guess that’s why they don’t expire and this feature exists
That pressed button interaction will still expire
But that’s not important for this case
I can guarantee you that if I were to press an old button on my bot and try to defer update, it'll say unknown interaction
It creates a completely new interaction
Im not assuming that I’m using it
You gonna add components with a custom ID for example post them to your channel and hit that component 1 day later
You will receive a, as in my example, button interaction you can interact with
The initial interaction is already expired of course
I think we’re speaking about different things
That lets me think you’re speaking about deferring the initial interaction response but no that won’t work of course
But you can still use the button interaction to get the initial interaction (message) ID and work with it, update it etc
Which ends up being the same
this doesn't work
let chhi = Object.entries(chh).filter(item => array4.find(exists => item.name === exists.name))
it'll not find in chh?? it looks like it's finding in array4 but all the cards are in chh and array4 is the user's cards
if you check the docs for Object.entries() you will see that it converts an object into an array of key-value pairs, like this: {a:1, b:2} => [[a,1],[b,2]]
therefore you have to adapt the filter for it
where's good old filter_map when you need it
and .values is same
good question
what is the structure of array4?
i know chh is something like this { barbarian: { name: "abc", ... } }
what does array4 look like?
it's a array
["potato","potato2"]
that
he meant what's inside it
9 times out of 10, having numbers at the end of variable names is a pretty good sign that you're doing something wrong
[
'Giant', 'Archers',
'Minions', 'Arrows',
'Elite Barbarians', 'Barbarians',
'Knight', 'Minion Horde',
'Goblins', 'Cannon',
'Elite Barbarians', 'Royal Recruits',
'Arrows', 'Goblin Gang',
'Tesla', 'Arrows',
'Zappies', 'Bomb Tower',
'Elixir Golem', 'Rocket',
'Three Musketeers', 'Hog Rider',
'Heal Spirit', 'Battle Ram',
'Royal Hogs', 'Rocket',
'Dart Goblin', 'Zappies',
'Wizard', 'Prince',
'Wall Breakers', 'Archer Queen'
]
you could call that array cards
you might want to look into https://en.wikipedia.org/wiki/Zero_one_infinity_rule
The Zero one infinity (ZOI) rule is a rule of thumb in software design proposed by early computing pioneer Willem van der Poel. It argues that arbitrary limits on the number of instances of a particular type of data or structure should not be allowed. Specifically, an entity should either be forbidden entirely, only one should be allowed, or any...
I don't know if this was intended to apply to things like array3 but I think it makes sense
so.. that makes it completely different from before
if chh looks like { barbarian: { name: "abc", ... } }
then you have to match they key value
not the name inside the object
Object.keys(chh).filter(key => !array4.includes(key))
ok
but it doesn't remove the true things
it happened before too with some stackoverflow answers
[
'archers', 'mega knight', 'lava hound', 'barbarians',
'elite barbarians', 'royal giant', 'spear goblins', 'goblins',
'minions', 'zap', 'mortar', 'cannon',
'giant snowball', 'knight', 'arrows', 'bomber',
'skeleton dragons', 'fire spirit', 'rascals', 'firecracker',
'tesla', 'royal delivery', 'bats', 'ice spirit',
'skeleton barrel', 'electro spirit', 'minion horde', 'goblin gang',
'royal recruits', 'skeletons', 'musketeer', 'zappies',
'heal spirit', 'elixir golem', 'battle healer', 'rocket',
'earthquake', 'goblin cage', 'tombstone', 'inferno towner',
'goblin hut', 'furnace', 'bomb tower', 'elixir collector',
'barbarian hut', 'three musketeers', 'mini p.e.k.k.a', 'giant',
'valkyrie', 'mega minion', 'wizard', 'battle ram',
'flying machine', 'hog rider', 'royal hogs', 'ice golem',
'dart goblin', 'p.e.k.k.a', 'golem', 'giant skeleton',
'wall breakers', 'witch', 'balloon', 'dark prince',
'prince', 'goblin giant', 'hunter', 'electro dragon',
'guards', 'bowler', 'executioner', 'cannon cart',
'barbarian barrel', 'goblin barrel', 'lightning', 'freeze',
'poison', 'mirror', 'skeleton king', 'golden knight',
'archer queen', 'electro giant'
]
``` there are all cards but in a array nothing more
figure it out
check if the case matches
check if the keys match
console log things to make sure they are correct
run simple tests to make sure parts of it work
How can I react to an message from an interaction?
I've tried with interaction.react
but it isnt correct lol
You can't
you have to get the message from the interaction
You also have to respond to the interaction
I could add buttons and no need for reaction
I.e. defer update it
right?
You still need to respond to it in order to avoid that "This interaction failed" error
I make an ID for the interaction and save it in interactioncreate
But yeah you can have buttons instead of reactions if that's what you mean
I'll try, I'll be back if it doesnt work lol
"Save" as in check for the ID in the interaction create event
if (interaction.customId === "ID") {
I want to do something like this
Now I'm confused, I want to do a multi page command, with a list of the server where my bot is
It is actually with a sense doing this in that way
A pubic command?
a pubic command
I've gotten this error, i've tried to fix it for a long time without success, so i'm askin you. What is a possible fix to this error? Error: Expected token to be set for this request, but none was present
I get this error when trying to deploy my commands.
you're doing it before client.login()
Am i not supposed to have client.login() after the client.on('interactionCreate')?
Speedy hacked into the mainframe to get that information
yes, but you said that happens on deploying commands
interactionCreate is not used for deploying them
interactionCreate is fired when a slash command is executed right Tim?
yes
Figures
found the issue, put the wrong token :p
👍
As well as if any other interaction happens, like a button, menu etc
Mobile internet pretty stable today, 4G, noG, 4G, noG…, E, dead
Changing every few minutes
I love that country

Does your server still perform good?
I’m somehow moving forward setting up VM after VM
PiHole some, database configured, file/webserver is up
Being not far away from moving most of my infrastructure back home except the dns servers of course
And some voice/game servers due my limited upload speed
in 2021
Alread excited how long the database generation will take this time
I somehow think I’m faster b somehow copying the 800GB to my local network than generating the database again
But im not sure how to perform this
Needs to travel from system to a different one
And the database servers will both need to be offline due ltable ock
FTP somehow doesn’t feel reliable enough
ha 4g nerd
Copying the data dir of the database
Imagine having a microwave in your pocket and at your head
literally doesnt mean anything
Oh it absolutely does
Doesn't to me
I use a microwave a lot anyway
always be cooking them tv dinners
put microwave inside microwave
That might create a black hole
what if
we put microwave inside a microwave
then
put that microwave inside a microwave
triple microwave
how many files?
ftp is good for large files, but terrible for millions of small files
you could try torrenting lul
can you port forward with 5G?
ofc ofc
Probably not much
Need to check that
I need to move all files as well as hidden ones etc
Literally the whole database lib to a different server
Still believe that doesn’t take as long as generating the database again
Don’t wanna wait 15d again
For the job to be done
Will probably take longer since it’s a SATA SSD not NVME
I prefer a direct transfer process
Not wanna upload it to anywhere
Also don’t wanna install crap packages on the systems
then ftp it is
try an ftp lib that supports multiple connections for concurrent file transfers
otherwise its gonna be slow
or something like rsync
Hmm alright will look for one later
it's a warcrime to use a teapot for coffee tho
theres no other code that would be accurate in my case anyway lmao
kek
what's ur usecase?
its not my api
lmao
its my ipc lib
it doesnt work behind proxies, for example replit
replit doesnt like tcp
so i have to simulate a handshake like websockets do
do your feet stink?
👐🧴
Handshakes aren’t allowed in 2021 anymore
🤝
no
undefined got corona
xD
feetshake are the new thing
Eww no
no alcohol

