#development
1 messages ¡ Page 1626 of 1
toLowerCase()
:]
ty
also for ms
what would 1 hr 30 be
60 * 60 * 30
prolly not
oh wait
1000 * 60 * 60
most likely
Too much math for me tbh
can someone help I keep getting this error and there is a file called ../../afk.json
Unhandled Rejection at: Promise {
<rejected> Error: ENOENT: no such file or directory, open '../../afk.json'
at Object.openSync (fs.js:476:3)
at Object.readFileSync (fs.js:377:35)
at play (C:\Users\KPC\Desktop\Discord Bots\JavaScript\PyroBot\src\commands\music\play.js:102:31)
at Object.run (C:\Users\KPC\Desktop\Discord Bots\JavaScript\PyroBot\src\commands\music\play.js:156:9)
at processTicksAndRejections (internal/process/task_queues.js:93:5) {
errno: -4058,
syscall: 'open',
code: 'ENOENT',
path: '../../afk.json'
}
} Reason: Error: ENOENT: no such file or directory, open '../../afk.json'
at Object.openSync (fs.js:476:3)
at Object.readFileSync (fs.js:377:35)
at play (C:\Users\KPC\Desktop\Discord Bots\JavaScript\PyroBot\src\commands\music\play.js:102:31)
at Object.run (C:\Users\KPC\Desktop\Discord Bots\JavaScript\PyroBot\src\commands\music\play.js:156:9)
at processTicksAndRejections (internal/process/task_queues.js:93:5)```
Can you even use forward slashes in windows?
oh is that the issue
Pretty sure fs dirs resolve based on cwd if you pass relative dirs. You should use the path module to path.join(__dirname, "../../") and get an absolute dir and pass that
but yeah what PapiOphidian said is true. It goes back two directories from where play.js is
So it would look in C:\Users\KPC\Desktop\DiscordBots\JavaScript\PyroBot\src\ if i'm not mistaken
in the src directory?
well
is it not
in that case it's just ./afk.js
you give it a relative path. It might exist relative to the __dirname, but it's not relative to the process.cwd()
because you're already in the music directory from where you're calling it (play.js)
its a JSON file
oh really
lol
It's only 1 directory back
..\afk.json
I can't even tell if what I'm saying is true
its only one
Go with PapiOphidian's way maybe
2 dirs back from music dir
So it works now?
60 (s) * 60 (min) = 3600 (1h)
Therefore 60 * 90 = 5400 (1,5h)
And donât forget to multiply by 1000 since JavaShit timestamps are in ms
and its the stupidest error
Show us the full filepath for your afk.json
wdym
open it with your editor or something and show us the full C:\Users\ etc. path
if it shows up anywhere
it's hard to tell by that screenshot

This is all an example
process.cwd(); // /home/user/bot/src
__dirname; // /home/user/bot/src/commands/music
// fs.readFileSync accepts relative paths based on process.cwd()
// if you tried to do relative without accounting for process.cwd(), ../../ would resolve to
// /home/user
const path = require("path");
const afkjsonpath = path.join(__dirname, "../../");
fs.readFiledSync(afkjsonpath + "afk.json"); // /home/user/bot/src/afk.json
U are using the fs function to get the directory?
Ok so your afk.json is in the commands directory
no
mhm
Make sure to use the absolute filepath FS requires
var random = ['#1d4e7a', '#2f1d65', '#99047f', '#c0ed0c']
let randomcolor = random[Math.floor(Math.random() * random.length)];
module.exports = {
prefix: ';',
colors: {
info: '#5b57d9',
error: '#de554e',
neutral: '#f2f255',
success: '#43d177',
random: randomcolor,
},
}```
`randomcolor` only returns the first string
anyone know why
first color* #1d4e7a
Using __dirname for example
Which will NOT work on Windows without replacing \ with / in the path
__dirname.replace(/\\/g, "/");
on client restart, it picks another color
weird
You never reassign the random value from initial assignment. You can use Object.addProperty to module.exports.colors and assign module.exports.colors.random as a getter
ah nvm i see whats wrong here
wait so how would i reassign
Object.addProperty?
hm
__dirname resolves with / or \ depending on os
@compact prairie Can you do me a favor and collapse ("unexpand") the commands folder? I'm curious now đ
Is Phyton a good program to program bots?
Nope it does not
Even if it didn't, it'd resolve with \\ which is also compatible with path resolvers
Misunderstood, yes it does lmao
Thatâs why you need to replace it for fs functions
fs path resolving accepts \\
Yeah there you got your escaped \ already but not if you call the dirname const
it is two directories back đ
lol
just use path.join(__dirname, "../../") to get an absolute dir 
Try it with backslashes then I guess? ..\..\afk.json
or use the absolute dir what PapiOphidian recommends
...(__dirname.replace(/\\/g, "/") + "/../../afk.json);
why are you using the spread operator on a string
probably windows being windows
We gotta have errors to help
whatever i give up ill rewrite it
Mood
Excuse me everyone my phone has not been charged all night it's on the charger and I'm trying to process this
Does another charger work?
sticking it in the microwave will supercharge it /s
But does another charger work
Should be a good try at least
All that you guys have to say is wrong I told you guys before I even drink this class somebody hacked in all of my products costing me money to put my new tablet in the shop including a deductible I just bought for Christmas otherwise I'll be advancing right about now on your level instead of using my cell phone
I'm trying to figure this out too I told you guys we have a mastermind manipulator and a hacker and our entity and you guys refuse to acknowledge that
damn that sucks
I got to get on board the best way I can with the processing that I do have because I don't have a tutor I don't have a friend and I don't have any family but my man that I've been with for four f****** years excuse my language everyone is my heart pain cyberbully and hacker and you guys are acquainted with him thank you very much
that message is english but when you try to connect two or more words together, it doesn't make sense at all
You know I didn't get this far in this world cheating myself I'm only human
are you mashing your keyboard suggestions
hmm even if English isnât your main language
You can believe what you don't want to believe in or whatever you be with somebody and you find out their darkest secrets and just for them to cover it up they'll sit there and spit in your
black lives do matter I don't I haven't got this far lying and cheating that's why I want to go to school so I can advance to get on this level out of understanding
@split hazel
And not developed relevant anyway
they're trolling
Obviously yeah
I have evidence of him admitting recently of his hacking and etc even still in my identity
@tawny cosmos please stop
Reading that shit brought me close to the tree near the street Iâm driving on
Agreed I'll stop right there I'll step back because I'm more of a man than anything
this is just painful to read
i feel like I am gonna get shout at but...
whatever ID you got from addUsers[0] wasn't valid as a member
or the member wasn't cached.
members.resolve(...) instead of members.cache.get(...) maybe?
okay
Yeah. You'd possibly have the fetch the user and possibly account for the fact that the member isn't in the guild anymore
ty
Ignoring exception in command give:
Traceback (most recent call last):
File "/home/pi/.local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "/home/pi/Documents/Central_Communications/cogs/central-economy.py", line 87, in _give
await db.execute(f"UPDATE economy SET money = {currentbalance + amount} WHERE user_id = {member.id}")
TypeError: can only concatenate tuple (not "str") to tuple```
```py
@commands.command(name='give')
@commands.has_permissions(manage_guild=True)
async def _give(self, ctx, amount, member: discord.Member = None):
if not member: # if member is no mentioned
member = ctx.author # set member as the author
async with aiosqlite.connect('/home/pi/Documents/Central_Communications/database/economy.db') as db:
cursor = await db.execute(f"SELECT money FROM economy WHERE user_id = {ctx.author.id}")
currentbalance = await cursor.fetchone()
await db.execute(f"UPDATE economy SET money = {currentbalance + amount} WHERE user_id = {member.id}")
print(f'Gave {member} {amount} K-Bucks')
await db.commit()
print('Saved!')
pass
embed=discord.Embed(
type='rich',
colour=discord.Color.dark_green(),
description=f'{ctx.author.mention}: Gave {amount} K-Bucks to {member.mention}!'
)
embed.set_author(name=ctx.author, icon_url=str(ctx.author.avatar_url))
embed.set_footer(text="Developed by LIPD Productions Inc.#1205", icon_url=str(ctx.guild.icon_url))
embed.timestamp=datetime.datetime.utcnow()
await ctx.send(embed=embed)
pass```
How do I get the new balance into a tuple so SQL will be happy with it?
yikes f string
well seems fetchone returns tuple and amount is string, so you can't concatenate them
So, what do I do?
What's money type in the db?
Int
So you should index the tuple so that you get the money ig and also you want to type hint the amount to int so d.py cast it as int for you
omg lol
I tried that, gave the same error
Checking
(1000,)
No because money is the column
Have you ever try it
Thatâs the correct SQL syntax, yes
thanks for confirming
Also don't use f string, you can use ? in sqlite for the placeholder
well probably in this case it doesn't really matter since the values are int
Not correct. 'money' is not defined
? is prepared statements. Sometimes, prepared statements are not appropriate to use considering they cause 2 queries instead of 1
For statements which accept non arbitrary input, prepared statements are not necessary
I donât magically know your table layout.
If youâre using a different name for the column then adjust it of course.
Mosttt of the time prepared statements are worth it
Unless you're running the query once
Once a prepared statement is made generally the db caches it for a considerable amount of time
if you're planning to have some sort of api which needs the bot instance, would it be better to host the server on the same process as the bot?
What do you need the bot instance for? You could have a socket based IPC where the client connects to the api to serve data or respond to actions. Or if it's to do rest actions, you could use a modular interface for rest actions only, considering the gateway and rest can be used completely separately
That seems more like a python error, how did you do it?
Exactly as it was written into an f-string. Then I tried it not an f-string as you suggested and it was being read as a column
SET money = money + {amount}?
I donât get why it wonât update the damn field
f"UPDATE `economy` SET `money` = {amount}"
try this?
Thank you. That triggered it the right way
Thatâs what we he told him before already
He just didnât follow the correct syntax usage for fstring I guess
eh, we all make mistakes
Aye
Why do I get this error?
Isnt that like..
in defineing part?
I used toLowerCase before in the code
đ
This.. tells me smth else..
đ
It suggested that tho.
What do u mean user?
the command executer never provided arguments along with the command
therefore, the args array is empty
It did, but it also had an if statement which you probably didn't have.
oh
so i just add this like it says? if (!args.length)
also
I am big brain
I AM ACITUALY am reading the docs..
That is correct. If there are no args, state that you require arguments
also, those aren't docs. That's a user guide to help newer users understand concepts and practice how to handle arbitrary input and user-proof your applications
This is the official documentation - https://discord.js.org/#/docs/main/stable/general/welcome
OH
Wait..
I added if (args.length) {//code } and it still gived me the same error..
const name = args[0].toLowerCase();
const command = commands.get(name) || commands.find(c => c.aliases && c.aliases.includes(name));
if (!args.length) {
if (!command) {
return message.reply('that\'s not a valid command!');
}
data.push(`**Name:** ${command.name}`);
if (command.aliases) data.push(`**Aliases:** ${command.aliases.join(', ')}`);
if (command.description) data.push(`**Description:** ${command.description}`);
if (command.usage) data.push(`**Usage:** ${prefix}${command.name} ${command.usage}`);
data.push(`**Cooldown:** ${command.cooldown || 3} second(s)`);
message.channel.send(data, { split: true });
}```
you don't do anything if there aren't any arguments. In fact, if arguments were provided, then the command wouldn't even run, because you locked it under a conditional scope. You need to return if there aren't any arguments and you require them.
Also, you accessed the args before even checking if it's empty or not
@earnest phoenix when did you start trying rs? đ
I am running my bot code and it is not going online and it is not giving an error. Can someone help me?
Just 12 hours ago 
pain.
I started reading the book months ago though I'm still half way reading that 
do... you have code in ur bot?
reminds me that I still need to read a cpp book I have. I kinda wanna dip my toes into functional programming and manual mem management.
Yes, I don't know if I banned with some shards I was not notified by the discord
Discord will always notify you if your client's token has been reset
Probably a cloudflare issue. What you can do is listen for client debug events
I did returned..
and shows an error
yes, but i don't know what would happen if i banned my bot or some fragments, it just doesn't go online, even with the code running
ok
No you didn't. On the top of the code block, you tried to access args[0].toLowerCase without checking if args was an empty array or not prior to that. Furthermore, you only added entires to the data array if there was no args
You can't "ban" a bot or individual shards
Actually, you probably shouldn't even have shards
cf can ban your ip
It happens when you spam reconnect queue
Wow
Happened with me once during one of that discord falls
how do u check tho? Isnt it client.on('message', message => { //code }?
@lyric mountain I have a bot with more than 2500 guilds
That's a listener
And how don't you know what's the issue?
can this problem go away after 1 hour?
before you try to access args[0], you should do
if (!args.length) return;
only has to be 1 line
the bot simply did not notify me and went offline, nor did an error appear
What if you try to reconnect?
An error MUST popup
Well !args[0] does the job too, since trimming and splitting the content canât lead to an empty element
No bot will fail silently
Therefore if 0 doesnât exist, no items exist
Unless you're muting errors
Like physical book? I've never actually read the physical one
@lyric mountain I tried to connect several times and it didn't even give an error
Impossible
Run the code in debug level
If it still doesn't show anything run in trace level
If it STILL doesn't show anything, your vps is dead
ok
How did you spam the gateway that much?
If I remember right the limit was 1000 logins per 24h.
its 1000 before discord resets your token
Yeah youâre right, just checked the docs again.
Clients are limited to 1000 IDENTIFY calls to the websocket in a 24-hour period. This limit is global and across all shards, but does not include RESUME calls. Upon hitting this limit, all active sessions for the bot will be terminated, the bot's token will be reset, and the owner will receive an email notification.
But if so he would receive an email
How can you drink water from a bottle BEFORE water got filled into the bottle?
Ye...
I got it.
wait..
I didnt.
But it says its not a function.
So Its not soppuce to be in the if message thing?
Youâre defining it const = command;
There are no functions defined in it (or properties)
Just send a few more lines to see what you actually wanna do
well if this is few..
here
const name = args[0].toLowerCase();
const command = commandFiles.get(name) || commands.find(c => c.aliases && c.aliases.includes(name));
if (!command) {
return message.reply('that\'s not a valid command!');
}
data.push(`**Name:** ${command.name}`);
if (command.aliases) data.push(`**Aliases:** ${command.aliases.join(', ')}`);
if (command.description) data.push(`**Description:** ${command.description}`);
if (command.usage) data.push(`**Usage:** ${prefix}${command.name} ${command.usage}`);
data.push(`**Cooldown:** ${command.cooldown || 3} second(s)`);
message.channel.send(data, { split: true });
so I basicly need to get it out of the thing that listens to the messages?
That's discord limit
Cloudflare is a bit more annoying
You cannot eat an apple from an apple tree seed
Yeah thatâs what Iâve said.
Dealing with a Cloudfare ban doesnât actually has to do anything with Discord.

Command does not exist before you finish "const command = ..." declaration
Guessing his IP, country or range got banned for malicious actions etc.
but I did finish it
No no, mostly because request spam
Always happens if you don't shutdown your bot during discord seizures
lol
Unless your lib limits reconnect requests itself
@quaint wasp
It does not exist
Ah, nvm, that's commands
What's the error again?
Oh huh missed that I guess
This
Show error
Same here I agree no man or woman in this world ever done anything for me
sence thats how it is in my code..
What is "commandFiles"?
đŚ
wtf
No
@rustic nova Got warned by Speedy already and is trolling again
Has been warned a few times in support too
Next one is a trout to the face
ping me when they're doing it again
Damn lost the context... mobile Discord sucks
yup
Like, to free space
oh there was a bigger message i just saw
Alright ty
sorry i missed that lmao
Thx
đ
Is he still here
Speaking about you
oh, thats the folder that has all of the command files under it.
Nono, I mean how are you defining it
Not the folder itself, the variable
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));?
Or a collection
but in coding
Maps are like jsons
"JSON" means nothing
Jsons are also key-valued
other than "a file-based version of a javascript object ro array or value"
bot review VS bot developer
I think you got your terminology confused
So funny sometimes in here.
"JSON" is a string-based version of a javascript variable
ro
Both jsons and maps are a key-value structures
lol
W3Schools seriously has corrupted people with their shitty fucking terminology
Stop using the word "jsons" it's not a structure
It's an OBJECT that you're talking about
â˘ď¸
Ok, so what?
So stop using the wrong word for it
Are you JS attorney?
guys stop this its not going to get any of you any where.
lmao
its kinda funny tho
Now stop calling them "JSON". They're objects. Use the real word like real developers.
Like, fckin gatekeepers
passing filters ^ (if there are filters)
Anyone have any ideas for âfunâ commands. Ive been trying to expand on the fun section of my bot. So far itâs just memes and reddit
Yeah well try telling that to an interviewer when he laughs at your face for calling an object "jsons".
ecconomy.
Avatar
dog facts
It's like arguing why someone who has common rigs are gamers or not
no it's like if oyu called your computer "The CPU" like my auntie does.
Or whether someone who watched only 2 anime are otakus or not
STOP guys its getting anoying!
@quaint wasp there's plenty of existing guides and tutorials on how to make a command handler
maybe follow one that's good?
like this one https://anidiots.guide/first-bot/a-basic-command-handler
@quaint wasp they told you already get() canât be used on an array
so im asking them here
Ok but no, what you're doing is trying to use the wrong things in an array
after I tryed to fic the,.
Follow that guide, it'll be fine
if you have any issues with that guide, let me know and I'll help you
I didn't say you were
I'm just saying you're tryign to use a Map() method on an array
and that doesn't work
The person that wrote it is the idiot
don't worry about the name of the thing just read it and learn
oh ok, then that works.
I'm sure you're also not smug and you're not a killer.
So maybe don't think too much about it

ya. Im not kiler. I am kiler.
Kiler
ok.
one l.
Because there are many events and it makes for better separation of concern while programming
It's easier to read than having 8000 lines in your index
Why does this happen?
Use a non-shitty browser.
pins
Safari is crap
or #site-status
I tryed to do that bc I didnt knew what a cmd handler was and it just says something like "Your index file is over 2000 characters."
And because of that it just wont read it,.
đ
@umbral zealot thats a shitty command handler you sent me over there.. đ
no it's not
it's literally the one most people use
a lot of people have copied it and adapted it
If you're having issues using it, it's not the handler's fault I promise you
Ik
But I want an advanced one.
Mine is
but..
I just ran into an isseu while I was advencing it.
your isn't advanced, yours is broken
Doesnt mean I should start over
Youâre not supposed to use the structure mentioned on the website, it just should help you understand how to read the files and to use it in combination with the inbuilt djs command handler.
Yeah I mean, you could just write your own but clearly at this moment you're not capable of doing that
oh
shoot
thats my cmd handler
some lines are useless..
Like comments
but nvm that
Simplicity is the utmost advancement
Don't try to go advanced if you don't need it
But I want the bot to be better
What makes the bot good or better is your ability to code it right - not to add fake complexity and pretend it's "good"
My life is already hell af so i dont mind.
Hell has 9 circles
im on all 10.
So here's the thing ```js
client.commands = new Discord.Collection();
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(./commands/${file});
client.commands.set(command.name, command);
}
That's your handler.
```js
client.commands = new Discord.Collection();
fs.readdir("./commands/", (err, files) => {
if (err) return console.error(err);
files.forEach(file => {
if (!file.endsWith(".js")) return;
// Load the command file itself
let props = require(`./commands/${file}`);
// Get just the command name from the file name
let commandName = file.split(".")[0];
console.log(`Attempting to load command ${commandName}`);
// Here we simply store the whole thing in the command Enmap. We're not running it right now.
client.commands.set(commandName, props);
});
});
That's mine.
Just because it has comments doesn't mean it's copied ^^
I've been doing this for 4 years
I wrote 90% of that site
I was in there support server but got banned for being to annoying
yeah I know you were
Yes.
WOWOWOWOW
So now have we at least established that the handler isn't crap?
I thought you were a male for some reason before.
A common mistake to make.
(Probobly because lots of males use discord..)
i mean, a lot of females do aswell
Back to topic, rewrite ur handler
SO I got to get rid of EVERYTHING?
mine is only 156 lines long..

Go simple, then upgrade it as you go
Don't try to build a skyscraper from terrace down
I think this is better:
ok if you say so
Copying a handler and not knowing how to work with it / understand it will just result in a similar matter.
It's not, but either will work, at least.
Nah that doesn't solve the problem
yes it does
STK is just a person that refuses to take the time to learn
A nice help vampire/tyler
?
He's using js
whatever you give him, he'll still not be able to code a bot
ik ik
ya
Shh move on with your snakes
idk how to use py.
so basically how i would make a handler
Ill use that when ik how to use js.
a function where on message, check if prefix is good
then run a function that is that command
?
i dont think so
oop.
Dude

OH wow so scary
That isn't that big
There's no "small bot command handler"
I couldnt fit 16 commands onto index
would my method work?
it said "Your file is to big to read"
or not?
or smth
i do mostly py so js isnt my main
said its over 2000 charecters
1 command or 20534623462 commands won't change the handler
Mine has 176, so what?
the handler is the same
Command count doesn't define whether a bot is big or not
This entire conversation stems from the fact that with 2 command handlers you've been shown (and I know for a FACT you've seen months ago) you're still unable to do a simple thing like "call get() on the correct variable".
Programming isn't supposed to be that hard.
me? or the other person?
Smug
Cmd handlers are godsent 
oh ok
note though, the dpy command handler is amazing
and its default
and i 100% encorage someone to make it in js
what package is it?
Eris had one like 5 years ago
guys
oh
guess wut
And there's a dozen frameworks out there
Im eating McChekin from McDonalds.
Snakes have no legs, so no threads 
snake charming > java but its called javascript
@lyric mountain my snakes have mutations
Sigh, typical #development moment.
Which helps advanced devs to save time and actually frustrate inexperienced coders even more due their complexity even if oop coding is easier to understand
on why snakes > coffee
You can relatively easily write without a cmd handler in js and convert the code when you have the time to understand it and set it up, that's what i did
Snakes are cold, coffee is hott

Thatâs the reason Iâm even following this chat while driving...
Canât get enough of it lmao
fucking drive and be careful to not run over small children
or big children
just dont run over people
Well GTA told me to do so, not my issue I guess
whats commando?
lol
A handler
Using a lib won't solve ur issue
lib?
hmm
Why is it so hard for me to balance learning java and still doing my daily dose of python 
Both are quite distant
ikr
good
for some reason this isnt showing the names,
.setTitle(`${message.author.name} Has Hugged ${message.mentions.name}`)
mention finder
if (message.mentions.members.size === 0)
return message.reply("Please Mention A User To **Hug**");
username 
message.author.username
still getting undefined for the second name
arrey man
do you not know the basics of d.js?
it will be
message.mentions.users.first().user.username
oh im still newish to doing mentions in embeds n what nto
I think its not js related more like djs related
oh yes, i meant that
its not an array, its a collection, which is basically a map
arrey = bruh
its hindi
hmmm i see
How can I vertically center this text
<div class="member dark">
<img src="https://cdn.discordapp.com/avatars/312972248241668096/5a474732aab914eddb15d379d3492a2c.webp"><p>pog</p></div>
</div>
#joins .member {
margin: auto;
}
#joins .member img {
border-radius: 50%;
height: 58px;
width: 58px;
padding: 10px;
padding-right: 3px;
float: left;
}
#joins .member p {
text-align: center;
}```
this trick has worked for me before
[thing you want centered] {
display: flex;
align-items: center;
justify-content: center;
}
just make sure the thing you want moved around is a separate element inside of the flexed element and that the flexed element is resized to be as large as possible (width: auto; height: auto;, maybe? I'm not sure exactly)
how do i make commands/help.js work?
do magic
why is it wrong?
i tried member.guild.me.user.haspermissions also
nvm
worked
how do i make commands/help.js work?
i voted in poketwo but the box didnt come
ask on their server, we`re not the poketwo developers
they say ask top.gg you say ask poketwo
WTF
What exactly did they tell you
they told me its top,gg problem not ours
oh I get it. you confused #development with #support
check the pins in #support
There's nothing we can do for you until the site's back online fully
not sure why they sent you here
they know it's not fixed yet.
ok well that's a different story
smh people are so bad at describing issues
You're limited to 2 votes per IP per bot per day
-_-
so if anyone else on your IP address (home, or VPN if you're using one) has already voted, you can't.
Ok well that's all I Can tell you
that didnt help me at all still thank you
The indicator that you've already voted only happens if there's already been a vote in the last 12 hours from your IP
Soooo
But there is a known problem with votes.
I am using display: flex
How can I make it to where they don't all adjust?
To what the others sizing is
nvm fixed it
Hello I am new to discord
hello i am old to discord
desktop reveal
yes i switched to linux
but idk how to change partition size so i'm stuck with 300 MB of storage
is there a way to change partition size for linux through linux
what?
it depends on how you have coded the bot
some peopel use a command handler
others idk what do
Guys, i have this help command : https://pastebin.com/DEcJhZ8e
And i don't know how to make it ignore a specific category, help ?
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Is there a way to check if something is a snowflake?
of course, download the is-snowflake module
is that the exact name?
can't you just check the string is an int and make sure the length is between 17 - 19
joke
that generates
?
require("discord.js").Snowflake.deconstruct(snowflake); my man
oh wait I am dumb LMAO
First is a actual user ID the second is words
So if the binary is all 0s would that mean it isn't a snowflake 
Yes
Thought so
Check for some real snowflake to see if it works
if (!Number(binary)) invalid ez
Yeah I got it now
Btw why are you developing something while you had to play the new act ?
Yes
I finished for the night
Ok
btw @blissful coral should I play my first ranked match now to get my rank rn ?
what is your rank from last season
b2 act rank
actual rank?
lul
return client.commands
.filter(cmd => cmd.category === category).map(cmd => `\`${cmd.name}\``).join(", ")
.filter(cmd => cmd.category === "category name").map(cmd => map.delete(cmd.name));
``` is this the correct way to delete a category with a specific name from a map?
When doing member.roles.cache is there a way to put them in order of hierarchy?
sort by their position
can anyone help how to start my bot if 'node .' and 'node main.js' doesn't work
you have to define "main" in your package.json
how can i do that?
npm init
Extreme you were correct... Riot does suck at comp experiece
i really dont want to point the elephant in the room, but doesn github webhooks do exactly that?
The discord ones? Nah
hmmm pretty sure they do...
can anyone help how to start my bot if 'node .' and 'node main.js' doesn't work?
ehm . . .
console.log(guildCache)
//commands working
(() => {
const prefix = message.content.split(" ").shift().toLowerCase();
console.log(prefix);
if(guildCache.prefixes.includes(prefix)){
guildCache.prefix = prefix.toString();
}
})()
ok
What's the point of that iif though?
that function creates its own scope
so that "prefix" variable will only exist inside if that scope
oh wait
that wasn't your problem
Also why make instant functions ?
I didn't see the image above
the problem is bc of that self invoked function
The problem is that he hasn't put a semicolon after the first console.log call, and js thinks he's calling the return value of the console.log
We said that
uh... no you did not but alright
it it possible for me to develop a new operator (or whatever it should be called) for js, that returns the factorial of a number if I try to do
const fact = 4!;
console.log(fact); // Should output: 24
nope
unless you create your own transpiler
Or maybe your own babel plugin or something
But what's the point
How often do you need the factorial of a number lol
this isn't an operator but it looks cool js function f([string]) { return Array(Number(string)).fill(1).map((_, index) => index + 1).reduce((acc, cur) => cur * acc, 1); } f`7`; // 5040
string template functions
does the variable, string has to be called that?
no
function a(text, vars) {
console.log(text, vars);
}
a`Text ${1}, text ${2}`;
// ["Text ", ", text "] [1, 2]
p cool
oh I guess the rest of the arguments are the expressions
And there's also a raw property at the end of the text array
that raw has the same 3 strings
ÂŻ_(ă)_/ÂŻ
const params = new URLSearchParams(req.url);
const formId = params.get("form") as string;
console.log(formId, req.url);
Am I going crazy y'all
Apparently it's an invalid URL
but why is ws giving me an invalid url
Promise { <pending> }
(node:47024) UnhandledPromiseRejectionWarning: FetchError: invalid json response body at http://ergast.com/api/f1/drivers.json/alonso reason: Unexpected token < in JSON at position 0
at E:\smol bot\node_modules\node-fetch\lib\index.js:272:32
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:47024) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, orhout a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, usedled-rejections=strict the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:47024) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js
terminate the Node.js process with a non-zero exit code.
can someone tell why i am getting this error
i am requesting data from an api
you need to await the promise and then parse
oh, ok, thank you
@cinder patio Help help
ask ask
i did that
let data = await fetch(`http://ergast.com/api/f1/drivers.json/${driver}`);
const info = data.json().stringify()
still shows the same error
ok so
ples explain
Are you seeing the event thing
I told you yesterday
I already putted all commands on one event
data.json() also needs to be awaited
But the message stills appearing
ooh
hmmm, mind sharing your code again @fathom frost
ok
guys, kinda starting here but does anyone know how could I set my bot to use @ mention as its default prefix? I have no clue how to do it
Can i share on dms?...
no
@cinder patio still the same code
ok
error*
Show how you await it
=|
(await data.json()).stringify()
oh, ok
btw
mhm
you will most likely get an error for trying to call .stringify()
json can't have functions
ok not appearing...
no you do JSON.stringify(...)
But why are you parsing and then stingifying? What is your goal
you only asked me to parse it
I didn't ask you anything
^
That was when you had to await the fetch
oh
It's just await data.json() to get the data
data.json() parses it from a json string to an actual object
oh, ok
if (err !== null) return;
imghash
.hash(body)
.then(hash => {
let result = db[hash];
if (result === undefined) {
message.channel.send("f");
}
message.channel.send( + result); ({ time: 10000 });```
^^^^^^^^^^^^^^
timeout dont work
what
are u want to add timeout for sending message?
yup
can u wait a min
ohk
np
Hi, that code returns me undefined and not the variable string. Idk why. Can someone help me ?
let site;
axios
.get("https://api03.thehostingbot.xyz/netheberg.fr")
.then((response) => {
var data = response.data
if(data.statusInfo.statusCode == 200){
if(data.pingInfo.time<250){
site = ":white_check_mark: | Site Web (" + data.pingInfo.time +"ms) [[Visiter le site]](https://netheberg.fr)";
}else{
site = ":chart_with_downwards_trend: | Site Web (" + data.pingInfo.time +"ms) [[Visiter le site]](https://netheberg.fr)";
}
}else{
site = ":x: | Site Web `"+`${data.statusInfo.statusCode} - ${data.statusInfo.error}`;
}
})
console.log(site)
Add catch() to check if your promise gets rejected for some reason.
its an async issue not an error
@woven sundial put what you do with site in the .then
you can't use something that's defined after the fact before it's even defined
Maybe should I just await it ?
sure
bc I cant put my result in the axios get request
how do i get these objects?
Iterate over yourarray[0].DriverStandings
oh, ok
wtf suddenly i cant see offline peeps on my server
its happening only on 1 server
i can see on others
dafuq
ples explain
since that gets you the object itself which contains DriverStandings, you access that and then probably do for loops over it or something
oh, ok
i made an html table and i want to make like the squares in the table glow if the cursor is on it, help ?
You can do that with css, using the :hover selector
Here is an example
https://developer.mozilla.org/en-US/docs/Web/CSS/:hover
The :hover CSS pseudo-class matches when the user interacts with an element with a pointing device, but does not necessarily activate it. It is generally triggered when the user hovers over an element with the cursor (mouse pointer).
We all saw that cheap ad 
I apparently fat fingered my ctrl-c and pasted the wrong link, oops
phat
Use hover for the whole line table tr:hover td or just for the cell youâre in with your mouse table td:hover
does running d.js on multi process is necessary ?
depends on how big your bot is and how much cpu it is using
write them. with code.
Ok what code?
your bot's code.
discord.js?
Step 1) learn programming
Step 2) choose a library
Step 3) write your bot
Step 4) ???
Step 5) Profit!
Ok
Step 5)
Damn capitalist!
const Guild = require("../../models/guilds");
module.exports = async function getGuild(client, id) {
try{
const guild = await Guild.findOne({ _id: id }).catch(e => require('../function/error')(e, undefined))
if (!guild) {
const guild = await require('./newGuild')(client, id);
return guild
}
if(!guild.voice){
guild.voice = {
"enable": false, "_id": ""
}
await guild.save();
}
------>> console.log(guild.voice) <<------------
return guild;
}catch(e){
return require('../function/error')(e);
}
}
Why is it console.log() nothing just a empty object ?
voice: {
"enable": Boolean, "_id": String
}
this is in my model
The property is probably a getter/setter which voids the value assignation
getter values won't appear in object logging
const is only for shallow reassignment. You're able to reassign the value of object properties of consts
no, I mean
i still don't get get it
u mean the value is too big?
to display it?
hi
if u wanna talk go #general
@lament rock i have done this before and it makes no problem, but now i dunno why it is not saving and it has an empty obj
getters and setters are methods which pretend to be properties. A getter specifically returns a possibly private variable scope locked. Setters are properties which accept reassignment statements to change the value of a possibly private variable
would message.reply(embed) work as a ping before sending the embed?
Pls talk in human language
:(((
I am speaking human. Getter and setter properties do not show in logging/stringification of Objects
Is it possible to document that a value of a function will be an object that has an unspecified property name, basically the property name can be anything in JavaScript using JSDoc? For example:
function deleteMany(...keys) {
return keys.map(key => ({
[key]: this.delete(key)
}));
}```
in ts its ts interface stuff { [key: string | number]: any }
you can type cast key to be keyof object where you replace object with whatever object you want
or keys to be Array<keyof object>
If you want it to be an instance of the class properties, you could do
@param {Array<keyof typeof Class>} keys
Idk if the this keyword works
or wait. Exclude the typeof Class. typeof Class is before it's constructed
just Class is when it's constructed
Hmm lemme see
Oh wait
This is a Map extension, right?
keyof returns a type which shows all of the Object's properties as an OR
What are you trying to do
If you have the generic type for what you key your Map with, you can just pass that generic
I think this is how it's done
/**
* @template K
* @template V
* @extends Map<K, V>
*/
class Thing extends Map {
constructor() {
super();
}
/** @param {Array<K>} keys */
deleteMany(...keys) {...
DiscordAPIError: Unknown Message
2021-03-01T09:37:18.790588+00:00 app[worker.1]: at RequestHandler.execute (/app/node_modules/discord.js/src/rest/RequestHandler.js:154:13)
2021-03-01T09:37:18.790589+00:00 app[worker.1]: at runMicrotasks (<anonymous>)
2021-03-01T09:37:18.790590+00:00 app[worker.1]: at processTicksAndRejections (internal/process/task_queues.js:93:5)
2021-03-01T09:37:18.790590+00:00 app[worker.1]: at RequestHandler.push (/app/node_modules/discord.js/src/rest/RequestHandler.js:39:14)
2021-03-01T09:37:18.790591+00:00 app[worker.1]: at MessageManager.delete (/app/node_modules/discord.js/src/managers/MessageManager.js:126:5) {
2021-03-01T09:37:18.790592+00:00 app[worker.1]: method: 'delete',
2021-03-01T09:37:18.790593+00:00 app[worker.1]: path: '/channels/773263328017252372/messages/815880348768534558',
2021-03-01T09:37:18.790594+00:00 app[worker.1]: code: 10008,
2021-03-01T09:37:18.790594+00:00 app[worker.1]: httpStatus: 404
2021-03-01T09:37:18.790595+00:00 app[worker.1]: }
why does this happen?
When you try to fetch a message which doesn't exist/has been deleted
or try to do some other rest action on a message which doesn't exist/has been deleted
in your case, delete
@earnest phoenix I may have mis-understood your question initially. Sorry. The message I replied to should be correct
@lament rock the problem is I can't find in the code where the problem is
maybe I used a message.delete(); incorrectly
You need to check if a message has already been deleted or not and then try to delete it
aight
I meant like, to specify the property of the object so it can be anything, as you can see, there's { [key]: this.delete(key) }, the key would be the name of the property by the help of [] around it, but i want to specify so the property name can be anything, not just a specified property name
You can just cast it as K since it'll be the same as what the user defines it as



