#development
1 messages · Page 1843 of 1
Does anyone know how to do presets to fill in fields in JS?
IE: I have like 4-5 buttons that when I click should fill out some fields.
My current plan is just to have a map of objects that the key's will be the buttons ID and fill out the fields with that data.
I dont think thats the cleanest solution though.
any frontend framework?
umm
well.. my bot has administrator permission
and every other one
but says it has no perms of changing nicknames
is the bot role above the role of the member you want to change?
Is it possible to use an array of strings (which originates from the keys of an object) as a type? So that the type is one of those strings eg
[“apple”, “pear”] into type = “apple” | “pear”
sounds like you're trying to mix dynamic typing with static typing
I guess
Is it possible tho?
I have a json file with itemnames and id’s
And I don’t want to add a new string to the itemname type every time I add a new item
cant you just import the stuff from the json file as a type?
I want to send a message when a user does something on a website. For example clicking a button a bot is sending a message to a discord server. I dont have a webserver and dont know at all how to it.
when the button is clicked, just make an api req
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
and how to make an API request?
i dont even know what language ur using
discord js
They could also make their own api that runs alongside their bot and send a message when an endpoint is hit
Would be a lot easier
it wont for him, it'd be another 10 tasks
so im making a api for my users to upload their sever count to my dbl, but im afraid of malicious users that send 100 request every minute, so i was wondering if is there a way to like blacklist a ip or something so that my backend does not receive the request
i know i can do something like
app.post("/api/bot/servers", async (req,res) => {
if(blacklist.includes(req.bodyID)) return res.json({ success: false, msg: "you have been rate limited" })
})
but my backend will still be able to received their request
You could use debouncing behavior by adding a time gap between requests and restarting it if a request is sent in that time period.
But that's generally inefficient.
if you want to block something before it reaches your node.js server, you have to block it elsewhere
for example in nginx, if you use it
or iptables
on linux you could even configure fail2ban for that
just Implement ratelimits
you can set ratelimits per ip and a global ratelimit
using something like express-rate-limit
I think he want to block before reaching the api
do i have to wait for my bot to be approved to add in posting stats
yes
okay thanks
Need commands for bot plz
Ping
Still not working
What do you want your bot's theme to be? Music? Moderation?
Yes
Welp. Then look into integrating basic commands from the categories you want
Then work from there
what's the best way to return a static list of commands in golang? currently i have code that looks like this
func GetCommandList() []api.Command {
return []api.Command{
&HelpCommand{},
...
}
}```
but i was wondering if anyone else does it differently
wait if i need to fetch the everyone role by name it should be "Everyone" or "everyone"?
<@&264445053596991498>
hm
why are you fetching it
idk i was testing out things lol
if you use djs
and want to get the everyone role manager so u can edit the permissions for it
https://discord.js.org/#/docs/main/stable/class/RoleManager?scrollTo=everyone
kkk
I am curious as to how many people here know and use golang
How many of y'all use Node version 13.x?
and how much different it is from Node version 12.x?
No Just asking I got an alert to update thats why asked.
oh poggest?
Yea it adds cool stuff
Ahh okay which version do you use?
oh goood 👍
hi
hi
is it possible to get the message to which a user replied?
from the reply message itself
no
you have two options and none of them are viable
wait nvm
i misread what you're asking
if you want to get the message the user replied to, totally possible
what is this for
a help command or something?
Message.referenced_message
iirc
Cbf to check the docs 
im not able to search my bot on the search bar, how can i?
let gg = client.guilds.cache.get("819932711665401856");
if(!gg) return;
if(!gg.member(message.author).roles.cache.has("871417011685720174")) return
Why i get member is not function error
I am using v13
because it isn't
no, its for when a user wants to run a command and the program needs to figure out what to run
Could you tell how i do it
guild.members.cache.get
GuildMemberManager.cache.get
the way i did it is i made a register func for each command, which adds to a slice on a commandhandler struct
interesting
not sure if its the best way to do it but its the way i did
thats definitely an approach i should consider
scuffed code LOL
i dont do discord bots much so this is all i came up with
yea that looks pretty good
maybe make it a common struct like Command
since they will all be the same structure

It's only looks good on desktop now
test
go is weird because no generics n shit but i hear thats changing soon
yep thats coming
bout time
Should I leave it as it is?
the only other thing id like would be ternary statements
My man
rofl id be down for that too
What you guys use in your bot?
well i recently started using go
migrated from rust since async traits are funny
yeah yeah you can fix with a macro but id rather wait for it to come into nightly channel at least
what used to bother me a lot was circular import errors in go but as it turns out that only comes as a result of poor package structure supposedly
Went over my head but ok you figured it out xD
yea you need to split up code a lot more
i mean the design choice kinda makes sense
and i did end up sorting things around
so maybe...
but stack overflow nerds say otherwise
me when
How can I go about the "remember me" option? (Normally I was using express-session but I need to make a system with tokens)
what node version is required for
https://www.npmjs.com/package/node-fetch
the latest version or above 8.9.1
nothing is mentioned in there
;-;
nvm i got it lol
can someone link me to <t:1628836884126> docs?
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
Have everyone thought of backup server just incase the electricy goes down or problem accured on your network
Yea
I host on DigitalOcean and if their power runs out I'm fucked
So when the main server die the backup server that have it own battery will turn on and the alt server is just for like !emergency where it tell why the bot off
Just so the user feel that no, the bot is not abandoned
Dude,
My host died once and it was for 30 seconds and it was like 4 months ago
why would I need a backup server
Incase electricity die if you live in not so rich country
My bot is hosten in Germany
*hosted
Or like a PI cluster so if one PI broken
🙀
Why would I host my bot myself ?
Like why ?
I host my bot myself
Since its free and i can control the electricy use and also im in full control
Also as security things so i can brag in desc how user data in encrypted for no reason
Well not as free...
and even if i do host it myself it has a very high ping
Ik im using data for my host please don't trhow me out
wait u host on mobile?
No
oh ok
But i use mobile data
but still id rather u go for a hosting service
@thorny arch i host on tablets >:D
And hosting there is probably better than pc (:))
use vps
@shrewd hazel u have a credit card?
No... Im not legally be able to have one
understandable
Can you give me one?
no
Sad
i dont have one either
can someone
i haev a debit card
anyways, can someone help me with this
sry man cant help with java script
well u can try using heroku if u are having roblems with hosting
thats what i use
k
hmmm
its fine
yea
Discord.php
huh
LoL
i am confusion
Discord.pyjs
Mhuah
maybe post the part of the code that is giving the error instead of just the error code
For seo, the content should be around 1500 words. So would it affect negatively if i duplicate a para multiple times and make the text size of 0.1px (not visible)
lol
wdym
const { AutoPoster } = require('topgg-autoposter')
const ap = AutoPoster(process.env.TOPTOKEN, client)
ap.on('posted', () => {
console.log('Posted stats to Top.gg!')
})``` this is waht i have
Try retyping
im trying to show server count
?
retype the code
how will that change anything
it always work
let me check again
pro advice
yes
don't OpenGraph tags work for SEO?
@quaint wasp most rate limits are 5 - 30 seconds so use 30 seconds just to be safe
can /cmds have dash in name (-)?
No, only underscores
is it possible to have a streaming on twitch activity while keeping the mobile presence?
no
well
I mean if you wanna keep the phone icon
no
But if in activity, then yes
ah nevermind then, i def wonna keep the mobile icon
yeah, i was trying to have it so the presence was mobile but the activity was a button to the twitch profile like the streaming status has
i kinda figured so
ye
does anyone know how to get find a category by name instead of ID? I've been trying to figure it out and I can't seem to. And on google I keep finding solutions that require an ID to work
categories.find(c => c.name === "The name")
alr ty!
np
isnt the mobile status not supported by the api?
how tf did u even do that 
Hey uh, This is like another thing;
So how in gods name would I give someone the ability to make a custom embed?
Because I don't want to make a entire if chain within the database to check if a title or a description was set for the embed, So say for example the title of the embed in the database is as '' that it won't add a title
But I don't want to make a couple hundred thousand char long if chain to test every possible match up
store it in the db as a object?
What do you mean precisely?
since discord.js accepts raw data
Okay so here;
<MessageEmbed>.toJSON()
?
if (!db.get(`Guild-${member.guild.id}`)) {
db.set(`Guild-${member.guild.id}.welcomeChannel`, 'None');
db.set(`Guild-${member.guild.id}.embed.text`, 'Placeholder Text');
db.set(`Guild-${member.guild.id}.embed.enabled`, 'False');
db.set(`Guild-${member.guild.id}.embed.color`, '#f3ad4c');
db.set(`Guild-${member.guild.id}.embed.title`, 'Placeholder Text');
db.set(`Guild-${member.guild.id}.embed.URL`, 'None');
db.set(`Guild-${member.guild.id}.embed.author`, 'None');
db.set(
`Guild-${member.guild.id}.embed.description`,
'Placeholder Description'
);
db.set(
`Guild-${member.guild.id}.embed.thumbnail`,
'https://cdn.discordapp.com/icons/839309957908004894/a_a77505a0c6821f7a6b02c4ffb0bacb91.png'
);
db.set(`Guild-${member.guild.id}.embed.field`, 'None');
db.set(
`Guild-${member.guild.id}.embed.image`,
'https://cdn.discordapp.com/icons/839309957908004894/a_a77505a0c6821f7a6b02c4ffb0bacb91.png'
);
db.set(`Guild-${member.guild.id}.embed.footer`, 'Placeholder Footer Text');
}```
So say I get all of this, How would it just not add in a embed piece if there is no value attached, Like I can change the `'None'` values
Escape the object and save it as string in your database aka. serialization
Hmmm
Lemme actually try that out
Just confused how I would execute that at first but let me try
Does anyone have a example I could try? Because I don't even know how to start working on just making the embed itself then
Then parse the serialized string in a try-catch block to check if it’s a valid object
console.log your embed and you will see the structure
Take its var and serialize it
Serialize / deserialize objects is what u need
I am confused I don't know how I would handle people adding in a title or a description and then removing it or adding it
let embed = embed builder…
embed.title = title
embed.url = whatever
It’s an object
You can access its properties however you want
Adding them, deleting them, changing them
if(title) embed.title = title
That’s why I said just create a random embed for testing and log it to your console
To see it’s structure
I'll try that yeah
(docs will show its structure, too of course)
Yeah
I am just overwhelmed at how I am going to make this rn
WAIT
AH
I DIDN"T KNOW YOU COULD DO;
embed.setTitle(thing)
AND THEN SOMEWHERE ELSE
embed.setDescription(thing2)```
I
YES
Okay byeeeee
That makes things so much easier
Like I was planning this entire thing out
My ass is dumb sometimes
I can't believe it
Well you can also use the methods
If you pass null as argument it should not set a title, description etc.
Keep in mind using the methods required embed to be a valid structure
Yeee
That’s always easier to work with
@boreal iron hi pleas credits
it wasn't 100% working but your answer was helping me get to the actual code, once again thanks!
.categories didn't seem to be a thing and this worked fine
this was the code btw
const channel2 = await message.guild.channels.cache.find(c => c.name === "(channel name)");
hey guys!js if(args1[0][1] == 'spotify'){ let tokens = fs.readFileSync('./codes.txt', 'utf8'); message.delete() const links4 = tokens.split('\n'); const index4 = tokens.indexOf(`${args1[0][2]}`); if (index4 > -1) { links4.splice(index4, 1); console.log(links4) const newlinks2 = links4.join("\n") fs.writeFileSync('./codes.txt', newlinks2);
why is this little snippet not removing the line from the file? (The 'index4')
@boreal iron hi pleas credits
what kind of help do you need with it
i want to put a background and also make the bots logo float
idk any css
easy
can you give code if possible?
add me to the team
can you just share the code?
like basic code
for background and float
.entity-header__image {
animation: float 5s ease-in-out infinite;
}
thats for float
okay
i have to put in <style> tag?
yes
does anyone know why it works when i have 50 items, but not if i have 250 items in the txt
nope not working
<style>
.entity-header__image {
animation: float 5s ease-in-out infinite;
}
</style>``` this is what i have
in the beginning of my description
Changing CSS properties usually requires to clear your browser cache
did you log index4?
why ?
can you check if its floating for you?
my bots logo
Why?! Wtf because they are cached lol
right
CTRL + F5 or SHIFT + F5
id hve to sign in again on all websites
<style> tags update instantly
Nope damn cloudfare caches topgg
Unless the page's html is cached by Cloudflare.

what should i do now?
Don't you have to do the keyframes for that animation? Or is float bootstrap?
idk anything about css
Then Ctrl+F5 won't do, no?
It should
I c
I find clearing cache and reloading a couple of times works for me.
i mean i did do that
Since you'd have to wait until it's refreshed/purge the cache manually
But doesn’t always work for topgg… sometimes clearing the cache will result in an even older version of the website
@keyframes float {
0% {
box-shadow: 0 5px 15px 0px rgba(0, 0, 0, 0.6);
-webkit-transform: translatey(0px);
transform: translatey(0px);
}
50% {
box-shadow: 0 25px 15px 0px rgba(0, 0, 0, 0.2);
-webkit-transform: translatey(-30px);
transform: translatey(-30px);
}
100% {
box-shadow: 0 5px 15px 0px rgba(0, 0, 0, 0.6);
-webkit-transform: translatey(0px);
transform: translatey(0px);
}
}
@cold ruin
It’s so ridiculous
ok
forgot to give you the keyframs lol
Then has your page saved? You could always right click on the long description and inspect element to see if the CSS is there. If it is, then your code is wrong.
do i have to pu tthis in sstyle tag
Yeah that's what I thought
i didnt put the whole thing lol
so i have to put this in the style tag?
Yes
after the .entity-hear__image ?
Before
man i need to go learn css
Although idk if it really makes a difference. I just always declare keyframes before.
border-radius: 50% !important;```
border-radius: 50% on the logo's class
add this in this
ok
np.
yeah ik
its annoying to spoonfeed
i spponfeed people c++
this changes the whole page's bg right
no.
then?
No that's your card in search results / page background on beta mode.
no ;-;
Yes for the page background you need css
i want a theme
for your pages bg yes
Yeah that's easy to find online
🥄
@cold ruin If you find the option on the background, let me know, I found an html code but it did not work
the option is the card
the description?
for the page's bg youd have to use css/html as mentioned by mac
uyes put your code in the description
then click SHIFT + F5
after saving
It's literally the most basic CSS task. You'll find lots of help online for setting a page background in CSS.
you mean something like this? that's what i have in my bot
^
. -. xD
yeah im doing it
ok but it doesn't do anything wrong to talk
<div id="bg">
<img src="https://i.pinimg.com/originals/0e/f3/d1/0ef3d1c3ddb4991db19c9ee4ac57ca1d.jpg" alt="">
</div>
is this correct
Am I stupid or am I blind or does this just not work? Like all of the values are defined but it doesn't change them because of the if (!thing === 'None") statement
Because you turned them to booleans
does that work?
I am stoopid ples explain
false/true === "None" will never be true
it wouldnt
if(!title) …
How could I try it then lmao
Because I am stupid
As you can see
I want to make a cooldown for a user like the bot returns in the code if the user is still on cooldown. But the timer runs well but it runs further in the negative area -1, -2, -3,...:
const { RichEmbed, Collection } = require("discord.js")
const cooldown = new Collection();
const { convertMS } = require("discordutility");
let time = 4000;
if (cooldown.has(msg.author.id)) { // if user on cooldown
const timeLeft = cooldown.get(msg.author.id) - Date.now();
const converted = convertMS(timeLeft); // Changes the ms to time
//add message here if code
console.log("cooldown for: " + timeLeft)
} else {
cooldown.set(msg.author.id, Date.now() + time); // <- saves the time
setTimeout(() => cooldown.delete(), time)
}
Lemme try
ok
Why would u even save none as string in your database?
Save the entities as null and check if(field) …
or if(!field) to check if they aren’t set.
Whatever…
since when does discord have buttons in v12?
v12 doesnt have buttons v13 does
oops okay
client.on('interactionCreate', async interaction => {
if (!interaction.isCommand()) return;
if (interaction.commandName === '!setup') {
const row = new MessageActionRow()
.addComponents(
// ...
);
let embed1 = new Discord.MessageEmbed()
.setColor("#0000FF")
.setAuthor('FoodFactory Tickets' , `${client.user.displayAvatarURL()}`)
.setDescription(`Réagissez avec le bouton pour créer un ticket.`)
.setFooter("FoodFactory Services")
.setTimestamp()
await interaction.reply({ephemeral: true, embeds: [embed1], components: [row] });
console.log(interaction.user.id);
}
});
i have this little code. How would i now console.log() the user who clicked the button?
ah tthere is a collector nvm
btw its <interaction>.user.id
where?
you can console.log interaction.user.id to get the user who clicked the button
inside the same handler right? Just like this (edited the code block above)
yup
You need to catch the errors and then send them to your channel.
Same should be done for process errors.
But I would recommend any of that anyways.
How do i check if a certain button was used?
Like a button named testrow for example
Check the button ID
Or loop through the option‘s data and check if the element name matches your hopefully unique name
(to bring up another way)
is it ok to constantly update a data in mongodb?
how constantly?
in a for loop ig?
...I meant frequency
it will only update if a run a command
so it's not "constantly" at all
k thx 
hello
I have added the logs-..... stuff to the database (using my shitty brain) and when I check for it, the promise returns false..
when its defenetly in there since the db.lenght shows 1...
ping in replies
hm, did you console.log to see what was returned by the db?
it returned "< pending >" for some reason
:/
to put an id into the database I did this
you need to await promises
(Obviusly after I figure this out I will add more error handlers like if the id has letters in it and ect)
oHH..... Right
im using discordpy
when i restart the bot, all the cooldowns reset
how do i prevent this from happening
i need to restart the bot to update it
Keep your cooldowns inside a database and fetch your database on startup
how
Store the timestamps
in string format?
Doesn’t matter you can convert string to timestamps and vise versa
(as long as they are valid of course) 
Saving them as INT consumes less storage even if that won’t matter at all
If you fetch something from db, it most likely is an object, not a boolean
better check like if(logs) { ... }
oh ok
string !== true
You’re checking if your string is a boolean true which will always be false
const muteRole = await …
const muteYesNo = (muteRole) ? "Set up" : "Not set up";
what does ? stand for?
It’s a ternary operator
if(true) true else false
(true) ? true : false
aka. shorthand if statements
I have a basic webserver:
const http = require('http');
const port = 3000
const fs = require('fs');
// const express = require("express");
// const app = express();
const server = http.createServer(function (req, res) {
res.writeHead(200, { 'Content-Type': 'text/html' })
fs.readFile('index.html', 'utf8', function (err, data) {
if (err) {
resizeBy.writeHead(404)
res.write('Error: File not found')
} else {
// res.write(data)
res.write('Site loaded')
res.end()
}
// res.end()
})
})
server.listen(port, function (error) {
if (error) {
console.error(error)
} else {
console.log('listening on port ' + port)
}
})
When someone joins the site, an API request should be made so my bot sends a message
ok
You need help? I dont see a question lol
er yes....
When someone joins the site, an API request should be made so my bot sends a message
How? xD
On which part are you stuck?
Do you recieve a event, when they are on the page?
I dont know how to send a request to the API so my bot interacts or can react to this
Do you recieve a event, when they are on the page?
Yes: ```
res.write() runs when joining the site
You could use a discord webhook for sending the message
can you teach me in DMs please? xD
not a big deal for you
quite a big deal for someone that doesn't have a clue lol
Css
I suck at front-end
oh
const Discord = require("discord.js")
const webhook = new Discord.WebhookClient({id: ID, token: TOKEN})
webhook.send("User on Page")
in the webserver's code?
Yes, the message send will be, where you write with res.write
You could start with Templates
DiscordAPIError: 405: Method Not Allowed
You created a Webhook on the Channel?
oh wait
How do I get token and ID from the webhook?
Copy webhook url , the last part is the token and the one before: the id
still DiscordAPIError: 405: Method Not Allowed
Can you show how you are passing it?
And which version of djs?
const http = require('http');
const port = 3000
const fs = require('fs');
const Discord = require("discord.js")
const webhook = new Discord.WebhookClient({ id: '875723949911203840', token: 'heres the token' })
// const express = require("express");
// const app = express();
const server = http.createServer(function (req, res) {
res.writeHead(200, { 'Content-Type': 'text/html' })
fs.readFile('index.html', 'utf8', function (err, data) {
if (err) {
resizeBy.writeHead(404)
res.write('Error: File not found')
} else {
// res.write(data)
res.write('Site loaded')
webhook.send("User on Page")
res.end()
}
// res.end()
})
})
server.listen(port, function (error) {
if (error) {
console.error(error)
} else {
console.log('listening on port ' + port)
}
})
You are missing the token.
where?
v13.1
here goes the token replace with your webhook token
I just censored it for you lol
Oo
Try {content: "hello"} in send
Just finished uploading all my docs and guides to gitbook, feeling good
still same error
so this just returns a "Provide a valid ID" every time... even if I actiually put a correct id..
wait I changed <, and > here, but even when they were different same thing happened
ping in repllies
I was questioning why that
- Id recommend you to update to d.js v13
You can easily get a channel id with slash commands
Yeah but why
Why are you checking if the id has more than 19 characters or whatever
Id recommend to just remove those two lines
alright..
args[] are a string array, they arent a number
you could try instead of checking if args[0] is a number, just checking if there is a channel with that id
You can't compare like that
much easier and more efficient
oh
Use channelid.length
ok
👍
And that's even better since not all IDs are valid
true
well
I did this
if(!message.member.hasPermission('ADMINISTRATOR')) {
return message.channel.send('Dude, you must have admin perms or else what are you even thinking?')
}
const channell = args[0]
if(!channell) return message.reply('Please specify a channel!')
if(isNaN(channell)) return message.channel.send('channel must be an ID.')
const chan = message.guild.channels.cache.get(channell)
if(!chan) return message.reply('I could not find that channel anywhere')
db.set(`logs-${message.guild.id}`, chan)
message.channel.send('Succesfuly setted up logs channel!')```
And it works
Yep that should be okay
You got your answer already.
Smh
Sus
If you wanna send a request to Discord then do it or include a library, init a client and let it do the job for you.
Just curious, since you included express why not use directly?
cause idk how to
XD, why not just see small tutorial for express instead of building a web server from scratch
Then use discord.js package to send message
You can use webhook as well
honestly "I dont know how to" is never a valid thing to say when developing.
If you don't know how to use a library, learn.
being a developer is a majority about learning, If you are not learning, you are not developing imo.
! prefix is illegal
agreed
thats why is "//" it.... 😑
what a convenient time to get pinged
???what
wrong question bruh:
Here is the right one:
I have here a basic webserver:
the file is called app.js and is in the folder "webserver"
const http = require('http');
const port = 3000
const fs = require('fs');
const Discord = require("discord.js")
// const express = require("express");
// const app = express();
const server = http.createServer(function (req, res) {
res.writeHead(200, { 'Content-Type': 'text/html' })
fs.readFile('index.html', 'utf8', function (err, data) {
if (err) {
resizeBy.writeHead(404)
res.write('Error: File not found')
} else {
// res.write(data)
res.write('Site loaded')
res.end()
}
// res.end()
})
})
server.listen(port, function (error) {
if (error) {
console.error(error)
} else {
console.log('listening on port ' + port)
}
})
The bot is in the same folder than the "webserver"
How can I interact with the bot when the site is loade?
This code runs when someone loads the site:
} else {
// res.write(data)
res.write('Site loaded')
res.end()
}
you want the server to interact with the bot?
Yes. I think I have to module.exportthe client
to be honest I dont know really how to export the user to the webserver 🥴
Would be very nice if you lead me
require the index file of my bot?
yes
let indexjs = require ('./DiscordBot/index.js');
like this?
you're exporting the client so name the variable client as well ¯\_(ツ)_/¯
"client"?
can you give them
alright and then?
wut 13.1 (o.O )
Yes. It has context interactions.
Oh, alright looks like I'm not up to date
I think I've a similar issue these days.
Just guessing but try to restart your editor and make sure to exit the process 100%
Try uninstalling and reinstalling djs maybe?
npm uninstall discord.js
oh silly me
Then npm i discord.js
Then try this:
Just guessing but try to restart your editor and make sure to exit the process 100%

Vsc has never crashed on me
Since when do collections not have an array property anymore?
Property 'array' does not exist on type 'Collection<string, ApplicationCommand<{}>>'.
I literally just returned from vacation and pulled my code from github
lul
it used to work
Property 'toArray' does not exist on type 'Collection<string, ApplicationCommand<{}>>'.
hmm lemme check myself
.values() ??
ahh nvm... .array()
so it is .array?
Isn't documented somehow but works for me (o.O )
You know what the weird part is
let existingCommands: Collection<Snowflake, ApplicationCommand>;
It should say Snowflake
not string
trying to make my client globally accessible, but it has this type error, Ive never encountered it before.
Anyone got any clues? This is my first time using typescript..
I've never used global
its a default feature in node
its accessible in any file
oh wait, I might need @types/node
since its a node feature
same error?
bruh... I might have to literal initialize everything
declare global {
namespace NodeJS {
interface Global {
someValue: string;
}
}
}
// Assignement works fine now
global.someValue = 'My hovercraft is full of eels';
tf
ack
thats how ts works
in classes
you also have to declare all the properties
class Something {
public item: string;
constructor() {
this.item = "something";
}
}
f
Collection is from discordjs right?
is it possible they removed the .array method in v13?
Im considering just going back to Javascript :L
TS is a pain in the ass for no reason
bruh Im struggling just attaching a variable to the global scope... TS is fkin retarded
Probably... I was accidently looking into the v12 code telling you .array() would exist
It doesn't anymore
to loop over it
for(const [snowflake, collection] of collection_resolver)
that doesn't somehow exist in TS?
I'll just map it

okay, so since I cant use declare or node's global, how can I make the variable Bot accessible anywhere in any file
by passing it to each file
how?
If you use classes as your commands
You're calling your exports somewhere, probably in your main file
I dont... I use commands as commands...
Command files, like in the documentation of discordjs
you can do
// Ping.js
class PingCommand extends Command {
private client: Client;
constructor(client: Client) {
super({
// Command name and stuff
})
this.client = client;
}
run(message) {
console.log(this.client) // logs your client
}
}
// index.js
new Command(Bot)
u want to prob put the Command in a collection or something
then you can use this.client in each command
Well then you import them and run them in your event listener...
For example command.execute()
that doesnt make sense, what does that do
lmao what is this
would importing it ensure that its always the latest updated Bot instance?
I need to be able to grab Ping and other bot information that changes, without passing it through the execute function or some shit
Thats better
how to grab boost level of a server in discord.js?
The guide already tells you how to do it:
https://discordjs.guide/command-handling/#individual-command-files
That's if you use classes tho (my example)
In this case async execute(interaction)
Im using Typescript, keep in mind
Oh... didn't know that one
You can still use regular JavaScript in TypeScript.
damn Microsoft fanboys anywhere these days
I don't use ts cuz it's from microsoft
I just like using it
Error: connect ECONNREFUSED IP
I can't connect to my mysql server in my VPS how do I fix that again? x)
You can't connect to your own hosted server? lmao
shush
ECONNREFUSED IP looks like a non-whitelisted IP
doesn't matter you can bind it to 0.0.0.0
yeah its bound to 127.0.0.1
help meh with a error in my bot pls
That's localhost only
node index.js
Bot made by MR.X and The Ash
Loaded Moderation Bot v2.0
Fontconfig error: Cannot load default config file
/home/runner/Dank-United-Premium/node_modules/enmap/src/index.js:949
.prepare(
^
SqliteError: database disk image is malformed
at Map.[init] (/home/runner/Dank-United-Premium/node_modules/enmap/src/index.js:949:8)
at new Enmap (/home/runner/Dank-United-Premium/node_modules/enmap/src/index.js:214:18)
at Object.<anonymous> (/home/runner/Dank-United-Premium/index.js:75:14)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
at internal/main/run_main_module.js:17:47
exit status 1
```
pls
Not really needed tho if you don't add firewall rules for incoming connection to it anyways, but doesn't matter at all
SqliteError: database disk image is malformed
Error: Host '(Some id idk if I can show it).access.telenet.be' is not allowed to connect to this MySQL server
I've never seen this error before
Your SQLite file is corrupt
mine?
Yeah
Dude if you run a server in the internet you should at least know something about networking and firewalls
i never went to this problem before ;-;
Change your default INPUT policy to DROP and allow connections you want and trust only
Alright
pls
Or block the ports to your MySQL server if you dont wanna change the INPUT policy
(DROP them)
..
There's nothing we can do to fix it if it's corrupt
..
Just google if there's a way to fix it
As long as your firewall doesn't refuse or block requests on that port, automated crawlers will always try to brute force accounts
If you use the database locally on that server only, restrict any access from the outsite
I have a dev database and a main database
the main is only used on the vps
I just set the host of the dev to *?
Or is that bad?
guys, how can I have a timeout for message deletion now on D.JS 13?
That will allow the user to login from anywhere even attackers trying to brute force the password
You have to wrap it in a setTimeout function.
But only into the dev database right?
You could generally DROP incomming connections to the database port

omg, why would they do that?
And how would I do that?
sudo iptables -A INPUT -p tcp -m tcp --dport 3306 -j DROP
It wasn't consistent with other methods like send, edit etc
As first INBOUND rule
guess I'll leave the messages now xD
yeah I'm really new to this stuff you're just talking chinese to me atm
lol
jk
You should know the risk of hosting an own server without being able to secure it well enough 
The crawlers are continuesly attacking your system trying to brute force the password for all possible account names
do you know how can i make slash command with live search for option ? like /tenor command or /giphy
If you haven't restrict that access it only takes a while until they're in
You have like a documentation or something I can use?
I can send u (probably) billions of lines of webserver logs of attackers/crawslers scanning each possible IP every few minutes for weak points
A MySQL server responding to the request with INVALID LOGIN data is the total WIN
That will cause other script getting into place and trying to brute force that access since it's not secured
Well, I'm not an IT security expert and I don't have money to pay one to secure my stuff I haven't even finished high school yet
That might be true and don't get me wrong, but that doesn't protect you from being attacked without your knowledge
I know that but you telling me over and over that people WILL attack me does not help me to solve it lol
Not people, but bots, scripts etc.
Well I told you to add a firewall rule in the first place to DROP incoming requests for the port 3306 (default MySQL port)
I sent the example above anywhere
And I told you I didn't know how to
Use google?
I am currently
You just hammer that command into your VPS shell
but I can't find anything
Adding a firewall rule is very easy
I just execute it?
this
after identifying as sudo user
U were talking about inbound rules and shit I thought I had to do other stuff first
That's an inbound rule
A rule to drop incoming connections on port 3306
I still want to connect to it tho
But it needs to be on top the inbound rules list
Run your dev db on your local machine
Connect to it locally or externally?
does anyone have a bot which adds emoji?
You will always be able to connect to it locally, no matter what u write down in the firewall
Can't my provider has blocked all my ports and my mom doesn't know the password to the admin account
What
from my pc
bruh momentito
If you host it on your machine you just do localhost:3360 or whatever the port is
aka I have no ports to host things like mysql and shit
They can't block internal stuff
^
It doesn't work like that
oh yeah my brain is exploding rn
Plus if you forgot the admin password, just reset it
But usually the password is the password behind the router
Well if you somehow need to connect to your MySQL server externally then change at least the default port and block the access for the user root
Those blocks are in place for port forwarding, where it's exposed on your public ip
I have blocked access to all users except for the user that ONLY has rights to the dev database
You can additionally whitelist your public IP (if you got a static one) for access from it only
And the dev database only contains my discord id and some data that isn't rlly usefull
ok but how do I undo the inbound rul then?
I'll change the port
That doesn't matter, as soon as you got access to the database, SQL injections and other methods will at the end grant you access to the storage and the system
even if the user has practically no privileges?
it only has privilages on the dev databse
bark
Is there a way to whitelist my IPs? Because I also can't host locally as my parents are divorced and I change pc's every week
sudo iptables --list --line-numbers
sudo iptables --delete INPUT <rule number>
probably number 1 or 2 if you haven't set up other rules
You know what I'll do
For the firewall or the database?
Both is possible.
both
The rule I mentioned can be extended.
sudo iptables -A INPUT -p tcp -m tcp --dport 3306 -j DROP
to
sudo iptables -A INPUT -s <your_ip>/32 -p tcp -m tcp --dport 3306 -j ACCEPT
That rule would make sense only if the default input policy is DROP
That mean you would whitelist single connections only
Also, don't IP's change?
Or user user@12.34.56.78
will allow access from the source IP 12.34.56.78 only
If you haven't a static one, then yes sometimes
why does readdirSync not recognize a folder that very obviously exists...
I just checked, I have a dynamic Ip
At least the database settings should be set to a hostname you use
I'll look into it later, gotta have diner now ty for the help tho
Your working directory is not src/ and the folder is in src/commands/
other parts of the file are using ./ and it works fine
that makes no sense
use require('path').join(__dirname, 'commands') for the path
user@% - any hostname can connect
user@1.2.3.4 - source IP 1.2.3.4 can connect only
user@localhost - local system access for the user only
to get the path relative to current file
goddamnit why does node have to be so fuckin inconsistent with files like this
half the packages recognize /src as the working dir
half dont
:L
No
Ok but I can use % in mysql and then whitelist my ips on the firewall?
It depends on from what dir you start the process
Well just just the static var __dirname
If you start from src/ working dir is src/. If you start from root working dir is root
I wouldn't recommend doing that anyways. I would always restrict the access on the database as well as the firewall
But at least on one of course
look at this, its stupid... I have to grab the files from ./src/commands but when I require them, I use ./commands
Ok ty
All the node modules and project config will be ignored
I created a channel with discord.js, when I try to type in it tho it says the message couldn’t get delivered? Why?
the whole point of having a src folder is to build it later on
bc require supports relative paths
that's why you should use absolute paths or build absolute paths by combining __dirname with relative paths
readdirSync(__dirname + "/src/...)
errr no it makes sense if you understand why 
doesn't matter unless you learned something
I learned that fs is retarded for not using relative paths, or making it toggleable
:|

const JSONSTATS = require('../../../data.json')
const fs = require('fs')
function JSONSAVE() {
fs.writeFile("./assets/data.json", JSON.stringify(JSONSTATS), (err) => {
if (err) console.log(err)
})
}
await delete JSONSTATS[r.user]
await JSONSAVE()
``` not remove why ?
:/
How you maked it colored
```language
code
```
Ohh
```js
// javascript code
```
let whatever = true;
javasriptCode();
https://ayeven.github.io/hanyuu/ lol, front end is not my best. Here some basic I do
Just another generic discord bot using discord.js library and using Javascript as the language
javasript
javasript
What does Tim wanna tell us with this?
Anybody...?
jekyll theme with md 
did anyone work with flutter
i need some opinions on it
is it worth picking up etc


Damn you search deep until you can find something to complain about, yee? 
aye shame on me
Will add a typo into any code I write in here in the future just for you :D
life would be boring without trolling
Whats trolling?
its less fun if its done on purpose tho :^)
you can know whether it's trolling or not by looking at deez
whats deez 
deez

damn wanted to ask that, too
sounds like nuts
but wouldn't make much sense in that context
but who knows how dirty KuuHaKu's mind is

KuuHaKu doesn't have a mind
you have to ask joe
we have two
My bad humanizing him
Won't happen again, Sir.
Give the text in the sidebar a text-overflow so the words don't cut off like this
for the command pages, you could style it differently, make use of the space on the right




