#development
1 messages · Page 2063 of 1
a lots of
u can make a function so most of the operation is abstracted
so u can just do, say, check_bit(bits, index) to return either true or false
yep i means it already exist in php
nice
I'll try to implement this efficiently . Thanks you for your time and your help ! 
yw, also regarding your initial question now you can simply use AND condition since you'll write just 6 times
yep its obviously less than 353 times 😓
according to the mysql docs, the BIT data type is basically like a varchar but for numbers, it can be specified with a size of 1-64
okok
they dont mention anything about how its handled internally, so i guess a BIT(1) will still use 8 bits of memory internally
and a BIT(64) will use 64 bits of memory
BIT(60) will use 64 too right?
most likely yes
it most likely sets a fixed int type depending on the bit size
like uint8 for 1-8
uint16 for 9-16
etc
they could go an extra length and make an arbitrarly long uint field that's partitioned internally
like java's BigInteger
yes but i doubt they do that
because that is also much slower
actually
apparently
they do that indeed
so BIT(128) is valid?
it says the limit is 64
yeah
wait (M + 7) / 8 means it'll always have 7 extra bits?
or does the 7 decreases the closer M is to 8?
Index means the positions of the bit in the bits array? e.g :
index = 8
1000 0000
1 = the index
or its like in programming index-1
it's exactly like dealing with an array, but it's stored the other way around
array[0] == (bits << 0) & 1
so basically 1 means 7 in this example
yes
nice
bits are always right to left
also if u ever need to check what bits are on u need to convert to binary first, because 128 as easy to visualize as 1000 0000
the computer doesn't need that tho, only humans
yep I studied the basis of the binary but i never really use it when i was programming
bitwise is probably the only practical application for such knowledge I can think of
sometimes im using NOT for search bar
idk if php supports, but u can now use the fancy bitwise ops (&=, |=, ^=, ~=, >>= and <<=)
he don't 
nhe
ah
idk why they are not with the bitwise operator
they're technically accumulating operators
yep they were with them
that's why i thought he do not supports them
and in facts its the same thing just you assign the result to a var ?
bits >>= 2 is the same as bits = (bits >> 2)
yep
How can I get the channels of a channel category?
I believe u need to filter where <channel>.parent.id === id
idk if discord sends what channels are inside a category
So i have a bunch of users of my app and i want to add another field to their accounts (MongoDB)
is there a automatic way? instead of manually doing it
git is for source code not database structure
huh?
well u can get-or-create the property
like, try to get, if it doesn't exists add it
right, thanks
is there a way to make slash commands to reply with an error as you're the only one who can see this
use an ephemeral message
Only problem with ephemeral messages is that you have to defer the interaction as ephemeral to get that to work iirc
Unless they fixed/changed that
you cant directly reply with ephemeral?
You can but if you need to defer then you have to choose to defer as ephemeral or not I believe
ah
Otherwise it’ll bug out and just go with whatever type the deferment was
So if you defer as ephemeral but send a normal message, it’ll send as ephemeral
Which idk if they’ve fixed or not, I just remember that being a pain in the ass when I was making bots
rip
i still didnt do anything with slash commands
and the deadline is aproaching T_T
I haven’t done anything on my main bot with interactions yet because I’m lazy
And it’s in under 100 servers and not growing, no reason for me to tend to it tbh
its so stressful working on a bot that already has thousands of servers
im always afraid of breaking it and disappointing hundreds of people
That’s what bug reports are for 😉
btw, a question for you typescript addicts:
is there a better way to create a type guard for class properties other than this?
class A {
b?: string
hasB(): this is A & { b: NonNullable<A["b"]> } {
return typeof this.b === "string";
}
}
i wanted something more like this["b"] is NonNullable<this["b"]> but apparently it doesnt work
Why not just return boolean and do the same thing
because it doesnt work as a type guard then
I’m too stupid to know what a type guard is
basically this
const bla = this.b // bla is string | undefined
if(this.hasB()) {
const something = this.b // something is string
}
because it doesnt work then, it wont narrow down the type of this.b
this.b would still be string | undefined
Oh you’re saying for the compiler to know too
yeah
You could just typehint something and force cast it since you know it’s there
yeah thats an alternative
but this works perfectly
just sounds stoopid
its basically typecasting the entire class
If it works for you then go for it
But I find that fighting the compiler over small things like this usually isn’t worth the effort, do a small check to guarantee it’s safe, then force cast
Or if you really want you could just go with if(this.b)
I think the compiler would narrow down the type at that point
who ponged?
o alr
yes im just trying to simplify some stuff but oh well
Imo if(this.b) is the way to go; using a method basically does the same thing in the compiler’s eyes
my actual use case involves multiple variables
wait so
so im doing it to avoid if(a && b && c && d)
what's the defer reply
and just do if(hasVars())
and also does some validation, like hasVars also checks if they are valid
how tf do os's store files with directories
with no hierarchy i can imagine how to implement that but directories?
they call dora for the map to each file
lmao
it depends on the file system on disk i guess
like ntfs uses the mft, fat uses fat
you want to make your own file system too?
bro come on
you already know im in it for making everything from scratch
using what someone else already made is boring
except for things that are not affiliated with your task or are very difficult to accomplish
SpeedyFS
SFS
STFS
speedy technology file system
xD
well most file systems use something like nodes/inodes or whatever they call themselves, that hold information about what type of object it is
it can be a directory or other things
and this node then holds pointers to either other nodes, or to data blocks
plus a bunch of extra shit for redundancy and data protection
like journaling
for now i'll just make a dos machine back in the day
do u guys set ratelimits on commands for each user?
each dm with a different user is a different channel
you dont really need to ratelimit dms tho
becuse the user is already rate limited by discord
so they will never be able to use more commands than discord allows
is-busy npm library when you accidentally make an infinite loop: 💀
my command is heavily using mongodb
isn't it the same for a normal guild channel
mongol dee bonk
indeed
a normal channel has multiple users
oh gotchya
so 2 users using 5 commands in 5 seconds = 10 commands in 5 seconds your bot has to respond
which breaks the rate limit
indeed
student programmers wanting to get a js certification realizing they have to pay £300 to enroll in a "charity" openjs foundation
actually no i think thats just to take the test
you have to pay more for a course too
self-taught is the way
is there a way i can implement an event and check if the discord pfp is still available
ammm how can i check with if(){} statement which one of these user has selected:
PAIN
hi age, I'm kuuhaku

djs?
anyone know solution?
yep
Ima assume you're using djs
if so you can use the createMessageComponentCollector
https://discord.js.org/#/docs/discord.js/main/class/Message?scrollTo=createMessageComponentCollector
just wondering because I'm not up to date on slash commands and other stuff.
I'm trying to display a table, is a codeblock still the most appropiate way?
table?
yeah, you dont know tables?
| heading | stuff | table |
| ------- | ----- | ----- |
| stuff | fooo | bar |
| stuff | fooo | bar |
| stuff | fooo | bar |
stuff like this
A code block is the only way to realize this properly
But still will be horrible for mobile users to look at
At least if the table is wider than the screen size
bruh
ive ran out of shit to code
and im not in the right mindset to start working on a file system or update my database
so ima add paging to my os :o
not that kind of paging everyone calls it that swaps data between disk and memory
paging is a part of it tho
after i fix my os yet again
well im only having issues with crashes when scrolling the terminal
other than that its relatively stable other than random artifacts when playing my snake game
might actually push some shit to github
finally 
I wanna make a bot but I’ve also got no ideas for one
a bot that gives bot ideas
I had an idea that turned out to be too difficult to make so
What idea was that?
The Auxcord thing
Also if you wanna make a bot you can help me with the one im doing on the side
Audio manipulation is difficult
Ah right I remember that
I am currently making a global moderation bot.
What lib
detritus
Ok deal
obv
Idk what you mean by global moderation though
So would it be a bad idea to share info of user's ban reasons with other users for the sake of moderation? I'm not sure of discord's feelings about this sort of data
Would it be enough to have a publicly available ToS about what data we collect and what we do with it and a way to request data deletion?
that's probably a gray area
Yea we are pretty worried about the possible implications about it
like, it could lead to pre-judgement of people
Like as in?
People make their assumption before the person even has the chance to interact with the community?
yes
sometimes people can be pushed into being dicks if the environment is too toxic
that, and long term effects of user interaction.
Ie, many people do dumb stuff when they are young.
Some dumb mistake at 14 could affect a user in their 20's.
also u can booli someone by banning without reason and putting a ridiculous reason
like, someone just joined -> "Banned for pedophily"
next server looks at the reason and thinks it's legit
We are going to be mitigating that by requiring a message id(s) of their offensive behavior so people can't just fake a reason
So your ban logs wont include bans from VC, or dms?
We have yet to determine that far ahead we are mostly trying to flesh out the smaller details
I feel like we won't though as it would be rather hard to track that sort of stuff unless we find an alternative method
do this: allow only pre-defined ban reasons to be selected
and only show to other servers if it occurs more than, say, 5 times
We were also thinking that
Mmm, that is also an option
that way u reduce false-positives
I was also thinking of an appeal system but idk how well that'd work
K
What wud be the regex for, selecting everything before first dot.
FE, group.slice.ts should give only group
Basically I want text.split(".")[0], but in regex
/^([^.]+)/
One Google search away
It didn't work, im trying to make vsc snippet
It does work, if used correctly.
Doesn't js allow limited splitting?
In java it'd just be <text>.split(".", 1)
Oh wait, nvm, misread ur question
What u want is actually /^(.+?)\./
Until and including the dot
Note the capture group
Ur missing the capture group in my answer tho
"match anything until the first dot"
Compare both regexes
Mine doesn't include the dot
Which one only gives the first characters back without including the dot at all
Whatever
some people just don't want to understand
Although I did forget ? there
No it's not like that, do you even know what a capture group is?
<string>.split(".")[0]
stop fighting guys 💀
https://code.visualstudio.com/docs/editor/userdefinedsnippets#_variable-transforms
${TM_FILENAME/(.*)\\..+$/$1/}
This one is removing the extension of the file.
But I want the first word before first dot.
this does the job cc @rocky hearth
${TM_FILENAME/^([^.]+)/}
I'm trying, but the snippet wont work.
uhh
that's not how to use it
What do I change here?
They are trying to create a VScode snippet. Not implementing in their code
And im not used with vsc snippets so i cant help much, gotta wait for someone who knows it
you want to remove the first word before the first dot?
@rocky hearth you want the snippet to print just the file's name without the extension?
not remove, but select
nope, if the file name is group.slice.ts, I want just group.
It will always be the first word before first dot
oh okay
so we can just remove all the things after the first dot, no?
yes, remove everything after first dot, (dot included)
/\..+/ this get everything after the first dot
yes
so it should be something like this?
${TM_FILENAME/\..+//}
i dunno
The typical XY problem
Cool, it worked. 👍
nice
How? I did mentioned what my end goal is.
No. You asked about selecting everything before the first dot. Your actual goal was to get everything after the first dot to get removed. vsc snippets work only with the second apparently, which is the goal. You tried to alter what you want by thinking it would be the same, which is not the case.
vsc snippets work only with the second
Oh, I wasn't aware of that.
By selecting I meant to keep only that part. My Bad
.addField('Attitude is now in', `${await bot.shard.fetchClientValues('guilds.cache.size').then(total => total.reduce((a, b) => a + b, 0)).toLocaleString()} Servers`, true)
``` https://cdn.hamoodihajjiri.com/odiu3Af5cq
Should I make a parenthesis like (await ...).toLocaleString()?
probably can't do await in string
I'm not going to add an await, just adding parenthesis; before await and before .toLocaleString().
`${await bot.shard.fetchClientValues('guilds.cache.size').then(total => total.reduce((a, b) => a + b, 0)).toLocaleString()} Servers`
`${(await bot.shard.fetchClientValues('guilds.cache.size').then(total => total.reduce((a, b) => a + b, 0))).toLocaleString()} Servers`
You seem to be calling the toLocaleString() method on a promise, so I would recommend wrapping it in parentheses, yes
Like this, basically.
Indeed, many thanks!
Sounds normal to me
https://sourceb.in/qzKuE3neIw, is there any way to send message on the first collector.size?
Hey, is there a way I can add more buttons to an embed that already has buttons?
MessageActionRow row
I’m assuming there should be only 1 action row?
Or can I append multiple
@crystal wigeon edit the message but pushing more objects into the array
You don't really need multiple
As far as I remember
well uh, i need to change the text on a particular button
how would i do that
after user clicks
any1?
Wym by the first collector.size
Collector#size is a number
You can't send anything to it
they probably mean when someone interacts first
?
so my problem is i have 3 buttons and when someone clicks i need to edit the label on one of these buttons
If they mean the first collected interaction they can do collected.first() to get the first one in the collection and do whatever they want with it
and these buttons are all ActionRowComponents cause its already sent in the embed
@bright hornet
I would help you but I don't know much about collecting button responses
Hmm
You could probably get the button that's collected and maybe change it's data but you'd likely have to resend the buttons with different data by editing the message you want to change the buttons on
Alright thanks thanks
You'd essentially be sending the same message just different button names
thats what im trying to do, but i also shouldn't be removing other buttons
that's sad that its only sending the message after the second value.content, i think there's no way sending it for the first collection
Huh?
its possible, you're just not clear about what you're trying to do haha
collection.first() will trigger for the first time
I need to send a message in the first collection
when someone reacts for first time
Im using max: 2
yeah
collection.first() should give you the first interaction
I'm too tired to think of a solution for you sorry
iz okay
But the thing is collectors don't return the data until it's collected everything
^
yeah
Thats what im saying
that
So you can't really do it unless you made your own collector which why do that
even i use collected.first() to send it to my first if else statement it still wait for the second collection
I just need to think about this logical
Yea collectors just collect everything then send data
nope plain message collector
I guess what you could try doing is not supply a limit and just stop it when it reaches 2 collected
you could try createMessageComponentCollector
You might be able to as it will not wait until it's collected everything (iirc)
As there is no limit to collect
and then do whatever you want on first interaction and defer
is there defer on
you can use it
You just told them to use the component collector
That's for buttons, select menus and modals
wat
ah
its fairly simple
got confused for a sec
I'm confused are you using buttons Syfy?
nope
createMessageCollector
Huh
normal collector
Ah okay
Makes sense
Well I'ma sleep sorry I wasn't able to help much but I feel if I tried I'd make the situation worse
Its alright, have a good sleep!
Uhh just update the code?
Hey guys, why the fuck does my json keep telling me that there's an unexpected end of Input:
{"John":{"name":"John","type":"Accountant","promotion":"Best accountant","strength":[0],"popularity":[1],"finances":[0]}}```
if(!database["John"]) database["John"] = {
name : [],
type : [],
promotion : [],
popularity : [1],
finances : [0],
}
fs.writeFile("./database.json", JSON.stringify(database), (err) => {
if (err) console.log(err)
});
seems fine to me
Then what's the issue lmao?
JSON.stringify() also works, idk what your error is
I- dont think that could be even a reason, are you sure that this code is the part that returns a error
Should i send you the code?
One sec
const ms = require("ms");
const n = require("../n.json");
const fs = require("fs");
const moment = require("moment");
let database= JSON.parse(fs.readFileSync("./database.json", "utf8"));
if(!database["John"]){
return;
}
console.log(database)
}
send the error stack
it doesn't look as if anything here could cause an error
Yeah, unless the data saved in database.json is missing a syntax somewhere and JSON.parse is returning that error
It is hard to help without looking at the error stack
It might be because you’re using json as a database. Concurrent writes fuck it up.
^ you'll want to write a db handler to prevent multiple writes at the same time.
You'll also probably want some error handling.
fs.writeFile is an async operation, it lets your js code continue running while the file is being written. if your js code gets to a point where it needs to write again while the previous writeFile did not complete yet, your code ends up writing to the same file more than once at the same time, which basically destroys it.
anyone got a VM 
you could be reading from an empty file that doesn't default to {}
const EventEmitter = require('events')
class TheBrozyCluster extends EventEmitter {
constructor(options = {}) {
super()
this.cluster = require('cluster')
this.Utils = require('../../Utilits/Utilits/Utils')
this.config = require('../config')
this.worker = this.cluster.Worker
this.id = options.id
this.uptime = Date.now()
this.name = {}
}
async spawn() {
try {
const name_cluster_1 = this.id === 1 ? 'Andrômeda' : '1',
name_cluster_2 = this.id === 2 ? 'Hydra' : name_cluster_1,
name_cluster_3 = this.id === 3 ? 'Lyra' : name_cluster_2,
name_cluster_4 = this.id === 4 ? 'Pegasus' : name_cluster_3,
name_cluster_5 = this.id === 5 ? 'Cetus' : name_cluster_4,
name_cluster_6 = this.id === 6 ? 'Fornax' : name_cluster_5,
name_cluster_7 = this.id === 7 ? 'Volans' : name_cluster_6,
name_cluster_8 = this.id === 8 ? 'Lynx' : name_cluster_7,
name_cluster_9 = this.id === 9 ? 'Draco' : name_cluster_8,
name_cluster_10 = this.id === 10 ? 'Starburst' : name_cluster_9,
name_cluster_11 = this.id === 11 ? 'Centaurus' : name_cluster_10,
name_cluster_12 = this.id === 12 ? 'Eridanus' : name_cluster_11
this.name = name_cluster_12
this.worker = await this.cluster.fork({ id: this.id, cluster_count: this.config.clusterCount })
this.Utils.logger('SUCCESS', `Cluster ${this.worker.id} (${this.name}) spawned with ${this.worker.process.pid} process pid`)
await this.Utils.sleep(5000)
} catch (error) {
this.Utils.logger('ERROR', error.message)
}
}
}
module.exports = TheBrozyCluster
I created this cluster system, using node;cluster. And I wanted to know how to handle each cluster individually
do you understand how the cluster module works? have you read guides about it?
the cluster module is a bit tricky to understand because it works very differently from the child_process module
for example, your code is missing the single most important thing in the cluster module: cluster.isPrimary, previously named isMaster in older versions
finally moved to hetzner
I put it in another part of my code, this is a class, it's just to make everything simpler
if (this.cluster.isPrimary) {
for (let index = 1; index < this.clusterConfig.clusterCount + 1; index++) {
const clustering = new this.TheBrozyCluster({ id: index })
await clustering.spawn()
}
await super.login(token)
}
Yes, I read
what do you have in your else block?
nothing, just if
then you dont have anything running at all
I have, the bot is running on the primary cluster
the isPrimary check is the most important thing in the cluster module, because its was tells your code what to run in the primary, and what to run in the children
if(cluster.isPrimary) {
// everything here only runs if this is the primary. the primary should create forks
} else {
// everything here only runs if this is not the primary, it should run the code that the forks should run
}
when you fork a cluster, it creates a new child process that runs the exact same js file all over again
I know this, hence the question, since I'm passing my bot on the primary cluster, the working clusters would be copies of the primary cluster
if you dont have any other code outside that if(isPrimary), then you forks are not running anything
hmmmm
you run node index.js, which starts the script in primary mode
then inside the script you use cluster.fork()
that function will run node index.js again, but in worker mode, not primary
I understand, could I pass the bot client on worker clusters?
no
the workers are entirely new processes, run from scratch, just like running a new node index.js
hm....
inside the worker, inside a non-primary if block, you need to run your class and create a new client
for example ```js
if (cluster.isPrimary) {
console.log(Primary ${process.pid} is running);
// Fork workers.
for (let i = 0; i < numCPUs; i++) {
cluster.fork();
}
cluster.on('exit', (worker, code, signal) => {
console.log(worker ${worker.process.pid} died);
});
} else {
// this is the code that the workers will run
const client = new Client(...);
client.login(...);
}
this is the example that the official docs have
so i would create a client for each worker?
yes
hm....
just like you would do with child_process
or worker_threads
in fact, the cluster module is just a child_process.fork() that is able to share a port
so its only useful for running webservers
its not really useful for running bots, unless you want to also run a dashboard inside it, or something
but then, can I remove my client from the parent cluster or can I leave it in the parent cluster and child clusters?
actually this is a test for me to run in my bot with the integrated panel
you can remove it from the parent, you dont need it there
if (this.cluster.isPrimary) {
for (let index = 1; index < this.clusterConfig.clusterCount + 1; index++) {
const clustering = new this.TheBrozyCluster({ id: index })
await clustering.spawn()
}
} else {
await super.login(token)
}
so?
ideally you'd have only the clustering class on the primary, but sure you can also have a non-logged-in discord client
not connected?
oh and by the way, this can be simplified: ```js
const name_cluster_1 = this.id === 1 ? 'Andrômeda' : '1',
name_cluster_2 = this.id === 2 ? 'Hydra' : name_cluster_1,
name_cluster_3 = this.id === 3 ? 'Lyra' : name_cluster_2,
name_cluster_4 = this.id === 4 ? 'Pegasus' : name_cluster_3,
name_cluster_5 = this.id === 5 ? 'Cetus' : name_cluster_4,
name_cluster_6 = this.id === 6 ? 'Fornax' : name_cluster_5,
name_cluster_7 = this.id === 7 ? 'Volans' : name_cluster_6,
name_cluster_8 = this.id === 8 ? 'Lynx' : name_cluster_7,
name_cluster_9 = this.id === 9 ? 'Draco' : name_cluster_8,
name_cluster_10 = this.id === 10 ? 'Starburst' : name_cluster_9,
name_cluster_11 = this.id === 11 ? 'Centaurus' : name_cluster_10,
name_cluster_12 = this.id === 12 ? 'Eridanus' : name_cluster_11
this.name = name_cluster_12
tojs
this.name = [,"Andrômeda", "Hydra", "Lyra", "Pegasus", "Cetus", "Fornax", "Volans", "Lynx", "Draco", "Starburst", "Centaurus", "Eridanus"][this.id];
ok
but how so?
?
nor connected?
i dont know what your full code is, but you have super.login() so im assuming you have another class which extends Discord.Client
yes
so you dont need that class in the primary
but I have a problem, before I got all the names of the clusters, but now I'm not getting it, because the names are in the cluster class
lol
you can pass the names in the fork arguments, or you can get the name from the id you passed in the fork argument
this.cluster.fork({ id: this.id, cluster_count: this.config.clusterCount }) this should be available inside the workers as process.env.id and process.env.cluster_count
I can't run my bot due to there being an end of output on my token run line, yet I didn't make any changes to this code line.
Full error;
SyntaxError: Unexpected end of input
/home/runner/Icey-Mail/index.js:309
client.login(process.env.token)
SyntaxError: Unexpected end of input
Line:
client.login(process.env.token)
I did it the way you told me, but the clusters are coming one primary and one secondary
like, the cluster with id 1 comes secondary and the cluster with id 2 comes primary, and similarly with the others
This is normal ?
are u saving it in a json?
Nope.
I'm using repl it. It's in a .env file
I'm dumb, not that dumb though.,
check if your token doesn't end in " or '
nor has any of those characters inside it
not the word "token", the actual token
no need to show me, just see if the token has quotations in it
Repl works different.
It calls the value
The key shouldn't be the token.
I've been using this same process for 3 years.
It's not any of that.
unexpected end of input means your code is not closed properly
somewhere along your code you have an extra ( or { that you never closed
I know,
Oh.
I knew that. That's why I was confused.
So why wouldn't the console tell me where
because it cant detect where
it can only detect it once it reaches the end of the code, and realizes something is missing
like the code "ends unexpectedly"
the program doesnt know what caused it, it just knows that it wasnt supposed to end there
one easy way to find out what's wrong is to copy and paste your entire code here
and auto-format it
it will be indented correctly into blocks, and you will be able to see which block was not closed
doesnt sound normal, you'd need to show your full code
I don't mean the key
no structure would ever use the key
when I say "token" I mean the value (which is called token) not the actual written text
@quartz kindle there’s flexible networking for cloud servers too on Hetzner, if you don’t need an IPv4 or v6 or non of it (private network - vswitch connectivity)
Got released a few hours back
well it only interests me if there is a difference in pricing (in vps, not dedi)
It is as IPs are already an extra item on your bills for a few weeks/months
That doesn’t affect your current price, only if you remove the IPv4 option
Since IPv6 is for free
extra item on your bills
dw, americans are already used to that
I'm just going to rewrite the entire index.js.

it's not a code issue I believe
It was.
As soon as I deleted everything and just added the login, everything was fine.
then it's something else in your env that's wrecking the env json
like a random quote dangling in another field
so if i remove my ipv4 does it get 50 cents cheaper? it says the ipv4 is chargeable max 50 cent per month
Yeah
im currently paying for the 3.99 plan
It's not.
CX11
I just said.
The bot works fine now.
Tim helped.
Tim said it was from some code line above, missing a [, {, or (.
You can choose between IPv4 and v6, one of both or nothing
And yeah the price should drop by 0,50€
welp i rather keep it
Yeah I’m doing that, too but just wanted to mention it
The DNS servers without IPv4 would be fun

What do I put in the requirement area to get a file within a folder?
Worded weirdly.
I keep getting this error, I do know why.
Error: Cannot find module './config/config.js'
Require stack:
- /home/runner/Icey-Mail/commands/Owner/eval.js
- /home/runner/Icey-Mail/index.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/home/runner/Icey-Mail/commands/Owner/eval.js:4:21)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
This is how my files are setup.
How would I call conig.json?
Right now I have this, const { OwnerID } = require('./config/config.js')
if the file is .json then require it as .json, not .js
also, if you're requiring it from eval.js then you need to use a relative path from that starting point
../../config/config.json
another episode of "I'm probably using localhost to refer to the host machine inside a container"?
i'm just following Outline's install steps
including their docker-compose.yml
Docker is the recommended way to run Outline – updated Docker images based on Alpine Linux are available on a monthly release cadence and are tested by the maintaining team.
you can't use 127.0.0.1:5432 for that 😭 wth
i should probably change that then ig
hi! if i want to make my bot track the votes on a server its on , i need the bot to be on top.gg right? like approved and so else i dont have a token to authorize the bot to check on the votes of the server
which container is this? https-portal?
are you just running docker-compose up -d?
docker-compose run --rm outline yarn sequelize db:create --env=production-ssl-disabled
lol wtff
the standard way this is done, you need to create a shared network between them
networks:
some-network:
services:
outline:
image: outlinewiki/outline
env_file: ./docker.env
networks:
- some-network
depends_on:
- postgres
- redis
- storage
postgres:
image: postgres
env_file: ./docker.env
networks:
- some-network
# ...
or an easier option is to add network_mode: host to outline
but that won't work on a mac
should be okay
got a new dedi today 
poggies
Nice
and then when you do the migration you need to reference postgres:5432 with the name of the service and not localhost
wtf now i run it again and it suddenly exists
amazin
Epik
nah i give up with Outline i stg
right so uh
I booted my bot and commands dont work
don't tell me I have to rewrite it
again
hey guys
how would i send a few messages after each other?
so: ```js
message.channel.send...
// wait 5s
message.channel.send...
// wait 5s
etc etc
Lidnsey your mom
@solemn latch
@hollow ocean no ads please
Probably not a good idea to do this anyways, but you could use setTimeout
use promise cascades
hmmm i see
let end = Date.now() + 5000;
while (Date.now() < end) {};
plot twist: the world ends in exactly 4999 millis
lmao²
await message.channel.send(...);
await new Promise(r => setTimeout(r, 5000));
await message.channel.send(...);
await new Promise(r => setTimeout(r, 5000));
await message.channel.send(...);
(Also probably not the best idea to send multiple messages per command assuming it’s for that reason, but if you’re going to then I guess waiting 5 seconds is good)
Message Content intent is not enabled and a prefix is configured. This may cause limited functionality for prefix commands. If you want prefix commands,
pass an intents object with message_content set to True. If you don't need any prefix functionality, consider using InteractionBot instead. Alternatively, set prefix to disnake.ext.commands.when_mentioned to silence this warning.
client = commands.Bot(command_prefix=prefix, intents=intents, case_insensitive = True)
Traceback (most recent call last):
how to fix it
python
enable message inents
I've had an issue recently with a bot currently private and in development getting banned by Discord. I've been unable to get in contact with the staff. Has anyone else had this happen and how did you resolve it?
Do note, if your bot is in more than 100 servers you'll need intent approval
Regardless of being public or private, what you're doing with the api does matter
Like if u spam is too much it will eventually be banned from interacting with it
Usually you'll see a ton of red flags before that happens
Like cloudflare bans, token resets, discord alert, etc
Hmm. I was using Hikari which has rate limiting. Regardless, it was working fine for months until another user started testing it. Not sure why it started happening.
Also if u break the ToS it might be banned without previous notice
Heya tim, do you have any idea on how should I send in collector.on('collect') when the first collection collected? Im having a max: 2 tho.
Okay, I'll see if I can find out exactly what they were doing when it got banned. Thank you for the insight.
Maybe you should rephrase your question, it doesn't really make sense in this case
They want to send something on the first collection
but djs doesn't stop the collector until everything has been collected
so .on('collect') won't fire until 2 has been collected if you set a max
The collect event of the collectors does not depend on the max option
Every time something is collected, the collect event will be emitted, so you can just set a count, increment on every call, and then call <Collector>.stop() on demand when the needed amount is reached
yea
but if you do supply a max to the collector doesn't it wait until that amount has been collected for it to fire?
Nope
this is me just confirming my thoughts on the matter
That's the end event you're talking about
hey I was thinking of putting a survey sort of and send the URL to it to the guilds owner when they kick my bot. Is that by any chance against ToS or anything of this sort? The survey is just to determine why they kicked the bot so I could possibly improve on it
Assuming your bot has no mutual servers with said guild owner, you would not be able to DM them anyways
You could perhaps make a guild leave command that admins can use that sends an optional survey then leaves I guess
But overall there's not a whole ton you can do about it. If they want to kick it, it's gone and you wouldn't have a reliable way of contacting the owner afterwards
https://developer.mozilla.org/en-US/docs/Web/API/Web_Authentication_API
How can i use it in expresss
Im trying to open a popup window by window.open()
then lets say i randomly created a number and saved it in a variable code now i want that code to be transferred from the popup window to the main window any idea how can we do that?
save data on localStorage and a storage event should trigger
works for different tabs not sure about windows
you can remove the value after the event too
Or just create a function
function BroadcastMessage(m){
localStorage.setItem('BROADCAST', JSON.stringify(m));
localStorage.removeItem('BROADCAST');
}
window.onstorage = (storage) => {
if(storage.key !== "BROADCAST"){ return }
console.log(JSON.parse(storage.newValue))
}
Isn't there a BroadCastChannel API made just for that purpose?
https://developer.mozilla.org/en-US/docs/Web/API/BroadcastChannel
The BroadcastChannel interface represents a named channel that any browsing context of a given origin can subscribe to. It allows communication between different documents (in different windows, tabs, frames or iframes) of the same origin. Messages are broadcasted via a message event fired at all BroadcastChannel objects listening to the channel.
it allows communication between different documents (in different windows, tabs, frames or iframes) of the same origin.
So it should according to the specs, but I have only used it for cross tab communication so can't say with 100% certainty that it would work
For some reason it even connects from chrome tab to edge
IDK what's wrong but it's so cool
wait what 
So your chrome broadcast gets received by edge too?
Lol
This seems solid answer for that i will try broadcastchannel incase it dont worked i will use your method
thanks both for the help
im after ideas for an animal for the mascot for D++, something cute is good but not an absolute requirement. also something no other big project is using so no elephants, dolphins, crabs etc.
if i can get agreement on whats best i may commission an artist to make the mascot real 😄
ping me suggestions
i guess bird species arent widely used so perhaps one of them?
yeah maybe
somone suggested a bee
instead of birb
lightweight, fast, organised
and can be made to look cute
possible
anime girls
....
lmao
how are they lightweight, fast, or organised
besides lib isnt called libweeb
I guess you never watched naruto
💀
set it to enable i think
what should i enable?
did you manually enabled in the code
wdym
ur message content intent is not enabled in the code
so u cant use prefix commands without message content intent
intents.message_content = True
paste this
discord.py i see
If you read his error message you can see he uses py
Thanks!! works
How to fix this
It's like a thanks for inviting message
hey guyz. So if i want to show the bot's logo in an embed. What do i use?
in js?
or py?
@client.event
async def on_guild_join(guild):
joinchannel = guild.system_channel
embed=disnake.Embed(color=0x8400a8, title="Thanks for inviting me!")
await joinchannel.send(embed=embed, view=link())
client.warnings[guild.id] = {}
why does it not work
"thumbnail": "image link"
this is the error
does the server have any system channel?
tnx
In the server settings
There's an option to set a channel as system channel
All system messages goes in that channel
that's what system_channel is
and in case there is no system channel it'll return NoneType
and you can't send message in NoneType
That's probably the error you're having
check if joinchannel exists before sending message
a platypus
nobody knows where the beaver starts or where the duck ends, the result code is at best alien, but for those who know how to deal with it's a neat animal
oh also platypuses got a poison barb, like c++'s segfault
is there another option
on a normal channel
that is not system?
not anymore
So can i do that sends in private the message to who invited it for thanks for inviting?
is it possible?
you can fetch all channels and try sending message the first channel you can
[Highly not suggestwd]
You can't tell who invited the bot
Unless you do oauth2 which is tough af if you don't have any experience
know what, that's a quite good idea
didn't think about adding more scopes to bot invite
so there's no possibility of adding a thanks for inviting?
There is but I guess you won't go that far for a simple thanks for inviting message
Because a lot of bots have it
you're not a lot of bots 
just do it like this
If there's a system_channel send message else do nothing
faxxxxx
Last question XD How do i put that the bot if it dosen't have permissions it will say I need "Manage_messages ecc" permission
well, you can send a dm
ah wait, u didn't mean send_messages
just make a permission check before executing a command
or you can just put the whole code inside a try catch and let it do everything by itself
why work hard
EOP is pretty bad
May can you send the code string? Idk.. 🙂
umm
I can't
hahahaha no
no spoonfeeding
just do something like this
try:
# Try sending message
except:
print("If something breaks")
thats bad
because what if something else breaks
won't it throw error as well ?
but always saying "You need MANAGE_MESSAGE permissions" when you catch an error is bad
for error handling
have error handling for each and every scenario
how do you say?
if you don't have SEND_MESSAGE perm
you send a dm
yeah ^
catching ALL errors and just returning perm error each time is really bad practice
Can you send me the dm thing? please.
do this
what I do
That was the actual question
Who do you send the dm if you don't know who invited
for every command, there's a Permission declaration
well, you don't do anything then
...........
it should dm "who did the command" and tell i don't have permission for that
that is what i'm asking
yes
then good
what language is this
?
java
not really, but the concepts are the only important part in my images
add a requires or whatever property to each command and put all required perms
before executing the command, check if all supplied permissions are allowed
if not, get the missing permissions and show an error message
except you wont be allowed to use administrator permission
top.gg bot decline speedrun
literally
Yeah yeah
example
I know they don't give permission
They only give specific perm
it's not that they don't give, the straight decline if they see the words "administrator" and "permission" written in the same sentence
administrator is the only blacklisted permission in top.gg
as it should be, idk why discord even allows it
Where can i find the "Permissions names"? Like Manage_Server idk
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
try ctrl-clicking @commands, it should take u to the source code of it
or use that
bitfields are weird
who tf represents bitfields in hex
discord
a lot of people represent them in hex because its shorter but its confusing af
someone experience with ejs and express?
What is the permission of the Warn/unwarn
Should i put Manage_messages or roles? IDK
Warn based on an command or an users message?
none, for the bot? none
for the user, I suggest either manage_messages or kick/ban depending whether u kick/ban after a certain amount of warns
yeah i was thinking manage_messages
can anyone help me in this
if(message.member.roles.cache.has('950054688680730654')){ message.channel.send('');
how to set more then 1 role in permissions
message.members.roles.add
and how to add
...
because I m new
read how a function in javascript works
and again
read the basics before heading to a boss fight
ok
@novel belfry
https://discord.js.org/#/docs/discord.js/stable/class/GuildMemberRoleManager?scrollTo=add
https://eloquentjavascript.net/03_functions.html
thank u
@client.event
async def on_slash_command_error(interaction, error):
if isinstance(error, commands.MissingPermissions):
embed=disnake.Embed(color=0xb30000, title="Missing-Permission", description="You need "Perm" Permission")
await interaction.send(embed=embed)
That works for all commands, How can i made it for only 1 command Like For the ban command: Missing Ban Permission for the kick cmd: Missin kick permission ecc. How do i do it?
you need to make a permission checker
or see if error doesn't contain the missing permission
hello guys my bot has 1K servers and 382K Members, And I use these intents:
'GUILDS',
'GUILD_MEMBERS',
'GUILD_BANS',
'GUILD_EMOJIS_AND_STICKERS',
'GUILD_VOICE_STATES',
'GUILD_MESSAGES'
I want to buy a VPS can someone help me how much Ram do I need? (Node JS) and also which one is better Windows or Linux
your first question cannot be answered, it depends heavily on what you're doing and on your code
the second, linux, there're literally NO scenarios where you'd want windows over linux for servers
unless you refuse to learn a new OS and/or is heavily attached to windows
well its multi purpose bot
I have many events cause bot have log stuff
Well I can't explain everything for you 
do you have music features?
no
why do u use voice_state intent then?
bot don't go to voice channels at all
log
give me a brief description of your bot
well my bot is multi purpose bot with many futures most of them are basic but uesful for example auto thread media only youtube only channels and etc. it has giveaway system and also I have all of these events for logs
except these but has something like 100Commands (Anime Commands (kiss, hug ...), util commands (avatar, banner, server...) and also moderation commands to ban, kick, timeout members and ...)
please tell me you have a single event listener and is redirecting to the respective files
well I have a loader and require my loader in index.js and then all of these events are just module exports
ok, that's terrible
actually, I'll need to check whether d.js internally uses a single listener, but if it doesn't, that's a serious performance issue
(I Want to rewrite my bot soon, so If I have to change my event and command handlers please tell me)
let's consider it does for now until Tim appears here to elaborate any further
so, do you do any image generation?
like custom profile or stuff?
hm, my guess is at least 2GB at least then

but it heavily depends on how many servers and how frequently images are generated
plus d.js is known to be a memory hog at times
how many servers?
wdym?
caching members, channels, presences, etc
I fetch guild members in some commands
sure
well, go with 1GB, most providers allow upgrading later on if necessary
get the one closest to your target audience
but it doesn't matter much, unless you're doing music, latency will be the least of your worries
Modals
Okay thank u
if (cips < price) {
return res.redirect('/store?nomone');
}
hey guys this is by far the worst error handling, if u can even call it that
i wanna implement a new one and recieve them on form of messages in frontend as well
^
idk man i wasn't there before
because you uploaded node_modules to heroku?
Different operating systems have different file encodings
Just upload your package.json and use npm i
i think heroku will do that automatically for u
and uploading node modules to heroku is bad because dev machine might have different binaries than production
don't forget remove this too
^ linux uses \n for newline but windows uses \r\n
do not remove package-lock!
In instances where you have to fix npm security issues in dev, removing package-lock makes you vulnerable
🤔
npm would also have to fetch additional metadata for the tree if you do not commit package-lock
package-lock does exactly what the name says, locks the package versions and their sources
aren't the versions already defined on package.json
No, because some versions of a package accept newer versions of packages that might be vulnerable
"^0.1.x" might have installed 0.1.2 when initially installed, but if 0.1.3 exists, then it will use that.
right
bruh
i was trying to: push...dosent matter
i was pushing wrong directory
...
i realised when i checked the name
is there anybody who has windows, a tp-link adapter , and a hotspot capable phone
Dude go on what is your problem
deploying issues
I had a tp-link at some point
it broke after about a year and a half, my ping would spike all the time
I am currently using DSL-2720u
I wasn't too upset though, only paid like 20 bucks for it
only d-link
It's not wireless
Hmmm
I have mobile data and that's good for me
await interaction.editReply({
content: 'Heads',
ephemeral: true
})
ephemeral true is not working
well using editReply with ephemeal doesnt make sense in the first place
is it just me or npm kinda slow and crashy? 
^^
i tried it with interaction.reply and followUp still not working
also if u wanna edit an ephemeral message u have to make sure u are using deferReply
One of the many reasons the previous company I worked at moved to https://pnpm.io
o no i mean the website
npmjs
i use yarn
tho
copium
Oh, well.., the site is no better 
💀
I mean, npm is fine for me atm, just as slow as normal
i only use npm for global installs
Johand bullying npm is not allowed
Tbf, it’s not that bad. It’s just really slow doing navigation between packages for me
~4 sec from clicking search results to package page loaded
We've significantly reduced the Next.js install size. We did this by moving our monorepo to pnpm, which allows us to remove duplicate packages while creating the pre-compiled versions that we use. This leads to a reduction in install size of 14MB.
Pretty nice numbers from the recent next.js release
npm.io is a quite good alternative
pnpm caused so many issues for the topgg repo that i ended up moving back to yarn lol
it didn't integrate with GitHub actions tooling at the time either
i've had tons of issues with both pnpm and yarn so i switched back to normal npm lol
what would be the best http status to use in case I require additional data to proceed?
you mean the request doesnt contain all the necessary data error or
no, like, I'm making a websocket endpoint where I require an authorization key right after the client connects to proceed
else it timeouts
well yeah
use a 4xxx close code
the 4xxx range is reserved for applications
If I'm reposting files with files: Array.from(message.attachments.values()), how can I spoiler them?
idk, try something like Array.from(message.attachments.values()).map(x => (x.spoiler = true) && x)
👍
there was a website that told about sharding and scaling stuff on discordjs bots something like "dumb" i forgot. can someone share the link pls? 