#development
1 messages · Page 46 of 1
🤔
So I'm having an issue with tampermonkey.
I have a require which ideally would load every time the script is loaded, but it seems to only update when I change the script version.
Any ideas on how to get around that while still using tampermonkey @require? https://www.tampermonkey.net/documentation.php#_require
Tampermonkey is a free browser extension and the most popular userscript manager. It's available for Chrome, Microsoft Edge, Safari, Opera Next, and Firefox. Even though some of the supported browsers have native userscript support, Tampermonkey will give you much more convenience in managing your userscripts. It provides features like easy scri...
You could try adding a timestamp as url parameter to get rid of browser caching
But im not sure if that works with relative paths like this
But it’s worth trying…
@require tampermonkey://vendor/jquery.js?<timestamp>
and it's content, not context
Mobile
Man include details… we don’t even know what your OS is
After installing it, it should be installed as service and should be running already
Might need to be configured
Your config files should be in /etc/postgresql/…
Guess pg default configuration should already be good enough for you
So you can actually begin to create an user, your database and query it
In ts I have a type like
type A = {a: number} | {b: string}
I want to merge those and make,
type B = {a: number, b: string}
Can someone make me a utility type for that
If you can, you could make them separate types and use & like so:
type A = {
a: string
};
type B = {
b: string
};
type C = A & B;
const c: C = {
a: "",
b: ""
};
Oh that I knew, but that union is dynamic.
I want to convert that on the fly
u dont use the browser to install stuff on linux
apt install postgresql
sudo -i -u postgres
psql
wdym "tied on"?
...? mongodb or postgres?
skill issue
you either pass it as a parameter or make it global
like u do with client
u require index to get client?
that's horrible
nothing should ever need to import index
if anything use a third file to hold global variables
else you'll soon or later run into cyclic import errors
use a third file to hold global variables or pass it as a parameter
or do js stuff like client.db = db
author cant have roles
author is an user
...so you get the member
Then observer isn’t defined
…basic javascript
Names don’t just magically exist without any definition
I love when you say "X isn't defined" and someone answers with "and how do I define it"
One message removed from a suspended account.
One message removed from a suspended account.
both the file that defines it and the file that needs it can require another file which exports an Object. You can assign properties to the Object in the main file and they'll appear in the other files that require that file.
you should be saving as uuid instead of names since names can change
looks good to me, but im not familiar with mc api or mongoose
but yeah. Always use keys that don't change
why you use user ids instead of tags
my tag is PapiOphidian#0110 and my user id starts with 32006…
I can change my name whenever, but my user id never changes
that logic should follow everywhere
An observer is a block that emits a redstone signal when the block or fluid it faces experiences a change.
bot edit page -> webhook -> scroll down
Thanks :)
idk why people insist on using mongo, its confusing af
or why they’re afraid of learning sql, you can actually get into it real quick
the basics are really not difficult
sql learning curve is surprisingly good
the floor is really low and the ceiling is very high
plus postgres is turing-complete, so u can do some funny scripts on plpgsql
anyone know why the error cannot read properties of undfined (reading 'catch') comes from
dmusr.send(`[USER REQUESTED] ${toSend}`).catch((e) => msg.author.send(`unable to send message to that person`).catch(e => console.log(` could not send message: ${e}`)));
``` it does the same with `try catch` too
send returned nothing
?
but its not suposed to
unless it failed
which is why the catch is there
or am i misunderstanding
lol
its a shitty variable name
dm user abbreviated probably
^
are u sure the user exists
im dming myself and it logs the mesage and the username in the console befor sending
so i know its valid
can u show me what dmusr is defined as
const dmusr = msg.mentions.users.first();
the user might exist, but are u sure send is a thing?
isnt that how you dm some one
dont you have to fetch the user after that though?
ok
now dmusr is undefined
but also same error too
bruh im actually dumb the error was coming from the line above where I accidentally .cached a console log
Sending always returns the message object
If it is sent it'll enter the then() block
Excluding interaction replies
Else it'll enter the catch() block
mmmmm new server so beautiful 🥹
Hmm very less ram in reference to the core count
Ah I see… very cpu intense lol
wtf am i looking at
anyone know typescript?
Just ask your question
Don't know how typescript works, But yet I am here trying to host a bot on ts.
C:\Users\rudei\bot-2>yarn
➤ YN0000: ┌ Resolution step
➤ YN0000: └ Completed in 0s 583ms
➤ YN0000: ┌ Fetch step
➤ YN0013: │ typescript@patch:typescript@npm%3A4.8.2#~builtin<compat/typescript>::version=4.8.2&hash=f456af can't be found in the cache and will be fetched from the disk
➤ YN0066: │ typescript@patch:typescript@npm%3A4.8.2#~builtin<compat/typescript>::version=4.8.2&hash=f456af: Cannot apply hunk #16
➤ YN0000: └ Completed in 33s 257ms
➤ YN0000: ┌ Link step
➤ YN0007: │ bufferutil@npm:4.0.6 must be built because it never has been before or the last one failed
➤ YN0007: │ erlpack@npm:0.1.4 must be built because it never has been before or the last one failed
➤ YN0007: │ utf-8-validate@npm:5.0.9 must be built because it never has been before or the last one failed
➤ YN0007: │ zlib-sync@npm:0.1.7 must be built because it never has been before or the last one failed
➤ YN0009: │ erlpack@npm:0.1.4 couldn't be built successfully (exit code 1, logs can be found here: C:\Users\rudei\AppData\Local\Temp\xfs-14fdf553\build.log)
➤ YN0009: │ zlib-sync@npm:0.1.7 couldn't be built successfully (exit code 1, logs can be found here: C:\Users\rudei\AppData\Local\Temp\xfs-cfa2bf85\build.log)
➤ YN0000: └ Completed in 51s 463ms
➤ YN0000: Failed with errors in 1m 26
looks like a problem with yarn and not typescript at all
well then yarn,.
@pliant gorge
hello, i have a problem with mysql2
anyone can help me?
it doesn't have the time to get the id
const insertContent = `INSERT INTO \`shark_ticket\` (\`ID\`, \`ID_Utente\`, \`ID_Claim\`, \`Timestamp\`) VALUES (NULL, '${interaction.user.id}', NULL, CURRENT_TIMESTAMP)`
var INSERT = insertContent
pool.query(INSERT, function (err, result) {
if (err) throw err;
});
const selectIDtContent = `SELECT \`ID\` FROM \`shark_ticket\` WHERE ID_Utente='${interaction.user.id}'`
var INSERT = selectIDtContent
pool.query(INSERT, function (err, result) {
if (err) throw err;
var ticketID = result[result.length - 1];
client.ticketID = ticketID.ID
});
pool.query is an asynchronous function, everything that happens inside the function(err, result) {} will happen "later" not "now"
it's the same with the normal connection
yes
how can i resolve this?
how can i get the id from the database?
what you can do is make a Promise and await it, but its still gonna be async
it after create a channel
put whatever needs the id inside the function, not after
async function example1 () {
const mysql = require('mysql2/promise');
const conn = await mysql.createConnection({ database: test });
const [rows, fields] = await conn.execute('select ?+? as sum', [2, 2]);
await conn.end();
}
whit this?
for example yes
ok, thanks, i try it
Is it possible to edit an ephemeral message?
reach out to the owner of that api, probably they can help
or whoever owns it
also, have you perhaps tried visiting the site directly, no clue where you've gotten that, its not even an existing site
I think it is right?
Only deleting won’t be possible?
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
per docs yes
per djs, check the docs
oh an ephemeral message
cant be edited no
only non-ephemeral messages can be edited
My brain is broken atm, but help me out
I'm making a !rob command
A 85% chance for success
How do I do the chance
get a random number between 1 and 100 if number below 85, do success
async function select () {
const mysql = require('mysql2/promise');
var connection = mysql.createConnection({
host: client.config.host,
user: client.config.user,
password: client.config.password,
database: client.config.database,
supportBigNumbers: true,
bigNumberStrings: true
});
const selectIDtContent = `SELECT \`ID\` FROM \`shark_ticket\` WHERE \`ID_Utente\` = ?`
var INSERT = selectIDtContent
const [err, result] = await connection.execute(INSERT, [interaction.user.id]);
if (err) throw err;
var ticketID = result[result.length - 1];
console.log(ticketID.ID)
await connection.end();
}
select;
it doesn't log
select()
also, await the createConnection line
const obj = {
uuid: 1234,
use: function() {
console.log(this.uuid)
}
}; obj.use()```
Is this possible?
Yes, that's valid
Good 2 know
Since the scopes of the methods are bound to the object, you can access the properties and methods through a method
You can also use a getter if you'd like
For example:
const foo = {
bar: 1,
get baz() {
return this.bar;
}
};
console.log(foo.baz); // 1
hey does anyone know why my interaction isn't working in dms?
Uncaught TypeError TypeError: Cannot read properties of null (reading 'id')```: ```js
console.log(interaction.member.id)
i love you
Does anyone understand the lavalink of erela.js
what is your question
Hello, i have a problem
Uncaught Exception: DiscordAPIError[40060]: Interaction has already been acknowledged.
the problem is I made a music system for the bot, when playing music, youtube says there is an age limit or something, it doesn't play it says you need to set an email and password, but I don't know how to set it
is for modal
(under line 283)
[FATAL] Possibly Unhandled Rejection at: Promise Promise {
<rejected> DiscordAPIError[40060]: Interaction has already been acknowledged.
at SequentialHandler.runRequest (/home/bot/Shark/node_modules/@discordjs/rest/dist/lib/handlers/SequentialHandler.cjs:287:15)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.queueRequest (/home/bot/Shark/node_modules/@discordjs/rest/dist/lib/handlers/SequentialHandler.cjs:99:14)
at async REST.request (/home/bot/Shark/node_modules/@discordjs/rest/dist/lib/REST.cjs:52:22)
at async SelectMenuInteraction.deferUpdate (/home/bot/Shark/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:192:5) {
rawError: {
message: 'Interaction has already been acknowledged.',
code: 40060
},
code: 40060,
status: 400,
method: 'POST',
url: 'https://discord.com/api/v10/interactions/1020749447115854025/aW50ZXJhY3Rpb246MTAyMDc0OTQ0NzExNTg1NDAyNToweWQ3QjhFNVA4UVpLNVJLbVRSQ3U1cmdwZ2k2MkVNOEJMSTBIdTNhdW5NR2FjMmM5eVF0RG55MG5mUjJUNWFHZDlmNE1BY09KektjVGp3RWpjZ0NTOTJZdWk1TUd2SmQwNkVKSHBtd2JsOEM5enA3aXQwWE82dkd2U3JmbU9pag/callback',
requestBody: { files: undefined, json: [Object] }
}
} reason: Interaction has already been acknowledged. ```
@boreal iron this is your area of expertise my g
I have hardly touched interactions
Though I have a feeling it has something to do with the interaction has already been received and refuses to receive it again
or discord is using poor choice of words, or I am just misunderstanding their choice of words
@sharp geyser did you look at my problem
I did, and I can't really help
pls help me, and don't ignore
okey thank you
Ever since youtube put measures to stop music bots from streaming their music on discord
I haven't touched it
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.
Also
Why do you have so many event listeners for interactionCreate
that just sounds like a bad idea
Okay your code is just fucked up in so many levels
is for ever response of the sellect menu+
interaction was already responded to, aka you either replied to it or deferred it
I have a feeling you are getting this Interaction has already been acknowledged because of how many times you are essentially listening to that event and then trying to deferUpdate it
if another one responds to it already, the ones after it will cause that error
funny enough all this is in the interaction create event
so he just nested 20 interactionCreate listeners in a interactionCreate listener
The more you look at the code, the more cursed it gets
@rustic nova he makes a new db connection each event call
💀
cc @rotund river probably good to not do that, apply caching there
fat fingered the emote

ok well at least he does close it nvm
but he made an inf loop
so fun
and yea each interaction create listener he made responds to the interaction
and he is only making multiple cause he is trying to do different things with each value from the select menu
which you can quite literally just use one interaction create and loop through each value and do some validation

not to mention every single one deferUpdates
so
Ima play witcher 3 before work so cya guys
Hey, did anyone know how type that in typescript
{
"random string":{
encounter?:number,
category?:string
}
}
would it not be
[key: string]: { encounter?: number, category?: string }
@sharp geyser and @rustic nova thanks, after use one client on the bot has sped up, what are the other problems?
Wdym
How did u speed up your bot
i use too many client on for each interaction of the select menu, and it tooks 2-3 second to edit the message, and now, using one it modify immediatly
Oh nice
please optimize your database usage too
because you're calling your database on every interaction iirc, doesnt matter what interaction does it
What sort of issue do you have?
Have been outside the entire day and couldn’t reply 
Help please..
I dont need help
jk i dont
someone else does
what does the error say
Can’t locate the file.
Just 50? That’s nothing! I created 50 message event listeners and each queries the database 10 times /s
Okay, so did you compile your ts code yet
How?
tsc -p .
uh if you're not running that as an npm script, you need to have typescript installed globally
something something path variables
Let me try that.
Is anyone familiar with ORNF and ORGR?
So object role grammar rule and object role normal format?
npm i typescript?
I am mean I am trying the bot using npm run start
now I can just run tsc -p right
tsc -p
error TS6044: Compiler option 'project' expects an argument.
so how would I be able to work my project?
tsc -p "path/to/project"
tsc -p dist/index.ts?
Nah, you dont need -p at all if you got .tsconfig in root
Just run tsc
--project
Compile the project given the path to its configuration file, or to a folder with a 'tsconfig.json'.
I just ran tsc and got so many errors
Progress! lol
hey guys so im currently implementing crypto to my bot so basically lets say u buy 10 cherry money (my bots currency) with bitcoin how should i calculate how much it goes up or down? i already found an api to receive data about the currency and here it is linked below:
https://haste.cherrybot.xyz/uwilehepuv.m
this data changes on my bot every 1 hour
nobody will buy bot currency with crypto
your not actually spending money
its just money inside the bot
but that money changes based on btc irl rates
does that make sense? i dont really know how i can explain it well
so like
10 in bot money (based on usd rates) to btc
but i want that money in the bot to also change
based on btc changes
well, you'd need to track btc prices on the database
already got that done
to have a before and after value
yes
then just do now - before
yes
users money + this?
now / before to get the multiplier
1.00004878287
tho ur doing it in the opposite way
the bitcoin price is always 1 btc
if ur currency is based on btc, it'll always be 1 coin = 1 btc
and 1 btc for example is worth 2000
u need some currency to have an anchor
const together = [letters,numbers,symbols*10]
Does this work for a password gen?
then do money * (before / now) when converting from money -> btc
do not change the current value from the user's wallet
else you'll have a leaking currency
to revert, do money / (before / now) (btc -> money)
I cant see exactly what ur trying to achieve there
and no, best way to generate a password is using hash + base64
I'm figuring out how to make a pass gen.
do note, it'll not have symbols, so you'll need to replace random characters urself
so then shouldnt this go up? https://shot.rip/zbj
10 is usd first num is crypto before 2nd is crypto after
nope, because the crypto got more expensive
can i get some help tooo
tried using the same commnd in git bash
bash: venv/bin/activate: No such file or directory```
what is source supposed to do?
activate the virtual env
btw, I probably mistook a thing, u should actually do money / crypto, because the crypto value is adjusted to the currency already
doing (now / before) will get u the percentage of increase/decrease
source venv/bin/activate # Activate virtual environment
pip install -Ur requirements.txt # Install dependencies```
just do userCurrentlyHas / currentVal
the currency was already converted by the api
ok so not only I lost all my data on my PC I also lost my bots source code because my vps had a purge I didn't know about 😄👍😄👍😄👍😄👍😄👍😄👍😄
"vps had a purge"?
sounds like u were using a sketchy service then
also tf u were not using git
supposedly they clean nodes every other month to save on space and remove servers that aren't used
Another question: How to set status to Streaming?
they cant simply delete the data
what service was it?
Set the activity type to streaming
nah, since I didn't expect my disk outright fail, expected more of it slowing down overtime
ty, just checking since it wasn't in guide
the same one I mentioned a couple weeks ago 😂😂
which was...?
I used digital ocean for a week but it was worse than Daki
Yes we remember everything
Yet again telling Bae to use a remote repository...
I will once I get my new PC
Lmao
You mean your SSD? Or did you get an entirely new PC?
Sounds dumb if he got a new pc for a drive problem
I ordered an external SSD that I will copy my files on to, then put them on the new PC
wanted a new one anyway, kinda sad I can't copy over all my games tho 😦
maybe I will copy over any gamesaves I can find
and reinstall
Do you not use steam?
but all my MC worlds are too big... 😔
Rip
steam saves...?
I thought it was stored in the appdata
for most steam games it is
Typically the game itself stores a save
Or at least any good game
I’ve been able to install a game on a different device and have my saves
🤷♀️
well you're probably talking about games like csgo
my singleplayer playthrough of gta v won't be saved
😔
hey
does anyone know a good npm package that i can use to convert my date to a different timezone?
i see and imagine if we have more than one random string like
{
"random string":{
encounter?:number,
category?:string
},
"random string2":{
encounter?:number,
category?:string
}
}
Does it work ?
interface t {
[key: string]: { encounter?: number, category?: string }
}
const s:t[] = // dfjejof
You'd need to create another interface, or use Record (Record<string, t>)
That's basically ts interface Bla { [key: string]: t }
You don't even need an npm package for it, you can just use the built-in <Date>.toLocaleString() method, for example:
const date = new Date();
new Date(date.toLocaleString('en-US', { timeZone: 'Asia/Jakarta' }));
The new timezone will be in Asia/Jakarta as specified
Wait aaa
Nm I'm dumb
Oml
Yes, the interface they gave does what you want I believe. There's no need to do t[] as it's not an array
how tf did u strikethrough a codeblock?
Could i also select timeZone "EST" or "GMT +8 etc etc?
Thanks btw!
huh apparently i cannot?
just add the offset directly to the date
wdym?
if you want it to parse user input, a package could be convenient
Only thing i basially need to do is convert the current time to GMT +8
I'm surprised js doesn't have timezone built in
in java u just do ZoneId.of("GMT+8")
i tried finding packages for it, but couldn't find a good converter
does anyone know a good package where i can convert the current timezone to a different timezone like EST, PST, GMT +8, GMT -7 etc etc
make your own I guess
how should i make my own lmao
i tried fucking around with the date property in js but it isn't really working
Skill issue
I mean if you know the offset just add it to the timestamp or remove it
this is the only data i've got
+5h or -3h shouldn’t be difficult to do
You don’t need the local zone names if you already got the offset
Owh wait so those + and - are the offsets?
So i could basically get the current time and add that number up to it?
Well an offset of +8 means GMT + 8 hours
So i should get the current time in GMT and add + 8 hours to it
got it
thanks for your time and help bro
So make ur script using utc then calculate your offsets to the gmt
Date.now() already returns UTC/GMT
Doesn’t it return the local system time?
"local" time isn't really a concept since its how many ms has passed since jan 1st of 19 something GMT
Plus, your devices connect to a time server
What did I misunderstand? Your system time isn't local. It's all through time servers
Nvm wasn’t reading carefully
Though we were talking about a local date format
Not timestamp
moment-timezone or luxon
luxon is more modern and up to date, but does not include its own tzdata files, it relies on the existing files on your system
moment-timezone is sort of deprecated but they still regularly update its built in tzdata file, so it doesnt need the system one
meaning moment-timezone will always be faster to update as new tzdata files are released
Could someone help? This is not to do with development but rather just discord bots.
In the Discovery status page of my application, it says Your application must use slash commands, or have been approved for the Message Content privileged intent with an ❌ next to it. So I created a slash command and it STILL has the ❌, anyone got any idea why?
did u create the slash commands as global or local?
Hello
?
...
ty.........................
this is for help with development, if you want to talk in general, use #general instead
thank you
no problem ||ok, i'll stop||
I got autism and adhd I never saw
.,.
as simple as that, "serve" is not a command
Well, I know that, is there a alternate way to download that.
Also you should probably ask more specific questions, I've noticed you have a tendency to just post an error message with nothing else attached
See, like that
Already did that.
since adding a new PATH command requires restarting of the terminal
I reopened.
But did you FULLY restart the terminal
Like, close and open
No
Aka click the little trashcan button in the top right of the terminal in VSC
fully
Would I need to re install the serve?
no
Nope.
Are you sure you're in the right directory
Actually that shouldn't matter I don't think
yes.
do %PATH%
or well, sec
yeah am not too sure how node or yarn handles packages, so can't help myself
Nevermind, Downloaded it with npm install -g server and it works, Thanks.
ah yes, the classic combining yarn and npm for some reason
I don't know how I would be able to ask this but like, The website is up and running but something doesnt work nor gives me a error.
then the logic is probably flawed or the error handling doesnt get to stderr
oh no, oh no
😔 Waiting for my bot to be approved...
same
Hello everyone, how to fix error discordapierror : missing permission but don’t crash bot?
how can I check if a User is the Owner of the Guild?
in nodejs, i have a process.on('unhandledRejection', error => { }); to catch any unexpected errors b4 it crash the bot. Can also try discord-bitfield-calculator lib to help assist in checking if there is sufficient permission
In discord.py there Is a on commands error event but i think if you know the error you should handle It by itself to provide a detailed description of what's wrong
I want the lines outside the gray background to be deleted but the function I am using is not working
If you pay attention to the upper left part, the lines are overflowing from the background.
I want to round the picture and crop those parts
the lines in the middle should be visible and the dots in the corner should not
local, does it need to be global?
yeah
Not realated to d.js but i need help idk if this is right place but yeah....
How do i connect http://152.70.156.177:25588/ this with my domain without actually getting any CName from host?
Like host is a diffrent thing which isn't mainly for website hosting but i use express for bot....
Tho it has ip adress thing...
I wanna connect it to domain with cloudflare or anything
I used portzilla butt.. portzilla only loads for some ppl from uk and us and is not worldwide it is 48 hrs something.
And I'm noob and not into this stuff
this channel is for anything development related, not just bots and discord.js
you could create an A record pointing to your IP through CF
I did like i have a record in my domain and even in cloudflare
If your domain already has this ip as target what’s the issue then?
http://yourdomain.com:25588/
DNS_PROBE_FINISHED_NXDOMAIN shows this 😕
When did you change the A record?
2 hours less for 48 hrs
Should I wait for more time?
I added a name(s) in domain do i need to add it in cc?
Cf
Doesn’t resolve to anything except in china
You either did something wrong or have a damn shitty provider
Okay if i did something wrong then what steps should i follow?
Is anyone familiar with object role modeling? If yes, could anyone tell me if this is correct: “Salesman (Name) and ID (SaleID) visited Customer (Custname) at Date (DateOfVisit).
Shitty provider - domain or host?
This shows that it a record is working for my state but not working for me lol
With root host or www or something?
root and www, if you want the domain to be accessible at www.domain.tld
yes also add alt=""
yes
Okay Thank you!
Now it looks like this..
Ah
fix your quotation marks
whatever unicode that is
What?
" this
that's some other unicode quotation mark, not "
wew
still not a correct quotation mark you're using on the site
okay try it
Diddnt work. It disappeared
whatever one you're using on the site, it's not the correct one, can't help otherwise
I think they're using the correct quotation mark, their font just displays them differently
If it works then it's the correct one
nah, had some user before with that
invalid image url it is then
Does it work with the previous quotation marks you had?
you should have added a .jpg
that's an album
Okay
oh
turn it on and dont turn it off?
buy a vps
buy a raspberry pi and run it off that
"web process failed to bind to $port within 60 seconds of launch"
so?
im no heroku expert but you could google that and most likely find a way to fix it
so in your code you have to listen to that port to prevent it getting shut down
how...
do you know how to code?
no alot
ok well im assuming you could just have an express app listen to that port and it would prevent it being shutdown
heroku is terminating their free plan in a month and a half anyway
a
google has a free vps
and its much better than heroku btw
but you need a credit card to verify your account, you will need to borrow one from your family if you dont have one
explain to them that its free, and you need it to study programming
@verbal frost fyi since you've asked the same thing in #topgg-api
guess you're not the only one
AWS has a good free VPS too
still generally against free stuff, as there's no direct relation to who's the actual product now: The user or the vps
True
I know a good cheap VPS, https://advinservers.com have a good $2 a month VPS with 2gb ram and I’ve used them for roughly a year with little to no problems
Advin Servers is a small and affordable hosting provider based in Delaware. We offer a variety of solutions to fit your needs, including virtual private servers, with locations all over the world.
Or https://time4vps.com have some good container vps servers (not as good as their main line of servers but still pretty good)
I've got a !help command,
I have 2 fields (arrays) in the embed with the commands listed
I'm getting a "Must be 1024.... in length", I know what the error means but I need help knowing once it's close or over 1024
let categories = { Other: [] };
Object.keys(commands).forEach((key) => {
let cmd = commands[key];
if (cmd.isAlias) return;
if (cmd.hidden) return;
if (cmd.category) {
if (!categories[cmd.category]) categories[cmd.category] = [];
categories[cmd.category].push(cmd);
} else {
categories.Other.push(cmd);
}
});
const emoji = config.commands.help.divider;
let field0 = [];
let field1 = [];
let selectMenuOptions = [];
Object.keys(categories).forEach((key) => {
selectMenuOptions.push({
label: key,
description: `${categories[key].length} command${categories[key].length != 1 ? "s" : ""}`,
value: key,
emoji: client.emojis.cache.get(emoji.split(":")[1].replace(">", "")),
});
if (field0.length <= field1.length) {
field0.push(`${emoji}**${key}** I ${categories[key].length} command${categories[key].length != 1 ? "s" : ""}`);
} else {
field1.push(`${emoji}**${key}** I ${categories[key].length} command${categories[key].length != 1 ? "s" : ""}`);
}
});
let embed = new MessageEmbed({
color: config.bot.color,
title: "Command Categories",
author: {
name: client.user.username,
icon_url: client.user.avatarURL(),
},
});
if (field0.length >= 1) {
embed.addFields([
{
name: "\u200b",
value: field0.join("\n"),
inline: true,
},
]);
}
if (field1.length >= 1) {
embed.addFields([
{
name: "\u200b",
value: field1.join("\n"),
inline: true,
},
]);
}```
Or should I say, split an array once the joined value length (array.join("").length) is close or over 1024
1024*(field.value.length)/1000000 should do it getting the index in an array
I think I saw that discussion, but I already have a thing that "revives" the bot every 15 minutes so it wouldn't shut down, and the function I use gets the env.PORT the way it should, with the local being 5000. And I found 0 articles on python
Maybe I'm misunderstanding somethinf but that exact code worked for weeks and now it doesn't without changing anything
u can give me example code that?
client.on('unhandledRejection', (e) => {
// you can access the error here via variable e
// note that fatal runtime exceptions can still crash the application
});
replace the client with one that you used to define the bot client
Ng việt nam à
Đặt cái code đó ở file nào
Index.js hay commands
T muón làm caid nào là ko đủ perm là nó thông báo tin nhắn ra chỗ dis đó ấy chứ kp crash luôn bot
use english, we are in international waters here
with the code specified, it won't crash the bot
ah
i see what you want
you can wrap the possibly error code in a try / catch block
How
try {
doSomethingPossiblyErrorProne(args);
} catch(e) {
// this block of code only gets executed if the try block got errors
notifyError(e);
} finally {
// possibly clean-up code here
// this block is optional
}
also you should probably study language fundamentals before keep doing
Hey does anyone know if i am calculating the times correctly? Because for some reason my bot is saying that the converted time is in fuking februari... while the selected timezone is GMT + 1
const date = new Date().getTime()
let g = test[interaction.options.getString('keyword')].time
let newtime = (Number(g) * 24 * 60 * 60 * 1000 ) + date
console.log(newtime)```
Because GMT +1 means urrent gmt time + 1 hour right? Or is there a certain calculation for that?
now here comes the catch
some timezones have daylight saving
so you have to also handle that
just use Intl API
I really really really suggest you to use a already made library for that
https://www.youtube.com/watch?v=-5wpm-gesOY can tell you why
A web app that works out how many seconds ago something happened. How hard can coding that be? Tom Scott explains how time twists and turns like a twisty-turny thing. It's not to be trifled with!
A Universe of Triangles: http://www.youtube.com/watch?v=KdyvizaygyY
LZ Compression in Text: http://www.youtube.com/watch?v=goOa3DGezUA
Characters, Sym...
i couldn't really find any suitable npm packages tbh
https://www.npmjs.com/package/time seems to do it
all of them required actual place names such as 'Australia/Sydney' instead of EST or PST
yes, that is normal
leap seconds

you'd need to convert that yourself from the UTC something to the place
also it does support it wdym
Immutable date wrapper
anything that doesnt have you make time manually
but does it handle leap seconds and daylight savings time
time was sadly removed from npm
what the actual fuck
let d = DateTime.now().setZone(database[interaction.options.getString('keyword')].timezone)```
Owhhh
so just divide by 1000 technically
I think that there's more wrong to it
It's not really working as gmt +8 returns me my own current time
while the timezone is GMT +8 so should display 21:07
instead of 3:07
sounds correct to me, the gmt timezone + 8?
I am pretty sure that i cannot use GMT +8 to specify the timezone
no it displays my own time
while it should display 21:07
Doesn't discord timestamps always show your timezone?
They correct for that on discords end
Iirc
Ah really
honestly
you dont even need to convert stuff
like woo said, discord does that, so you'll only need the unix time
though you might need to directly send it instead of using discords timestamps
I want to like display the current time of someone
i see
I see why it's not working
it's basically not accepting GMT +8, PST, EST etc etc as timezone
Only actualy city names
what should i do?
Hi guys where do you guys live
https://www.davidsemporium.co.uk/worldclock.html I COULD USE THIS!!
The time In Cities and Towns In Time Zone Order with GMT time
North Africa
ℂ𝕆𝕆𝕃
nah just kidding i am from the Republic of Congo
Cool
var d = DateTime.now().setZone('China/Beijing')```i am losing my mind
how can this not work
Huh i heard Singapore is 7 hours infront
the error is pretty well explained
Bro i am still stuck with the fucking date converter
no package works
like literally none
timezones are standarised by the iana timzone database, aka tzdata
accronyms like EST, PST, etc are not valid timezone identifiers because there are duplicates, different countries/cities that use the same accronym to mean two different offsets, and also due to daylight savings time, which these accronyms do not account for
for your particular use case, its better for you to have the user specify the offset in hours
instead of an accronym
but that still wont account for daylight savings
how long are you going to save that information? is it like a database where each user has a "timezone"?
Was that to me?
is the plan still available?
yep
Advin Servers is a small and affordable hosting provider based in Delaware. We offer a variety of solutions to fit your needs, including virtual private servers, with locations all over the world.
yes
Quit unable to understand the error, You mind explaining it to me?
Don’t waste your time.
Just fixed it.
somewhere in your code, you imported something with a dep: prefix, which the error is saying its only allowed in the nighly channel, which means its only available in developer versions of rust, and not in official versions, and also required running with the -Z flag on the command line
Downloading a customized version of rust should fix the problem.
Also another error.
Tried doing sudo apt-get install libssl-dev.
To fix the problem but same error.
Idk how you’ve had so many errors with CLI tools in the past few days
This is the source I am using, Trying to run the web, What would be the command for that?
What does this mean? https://cdn.hamoodihajjiri.com/Wt36NjXurO
you are building a react app that is run inside a browser. https does not exist in browsers
Oh, what now?
why do you need https?
I'm not really using https except to use the .get() method.
browsers have fetch and xmlhttprequest
anyone know ?
Wait, I didn't even install os, looks like I only need to worry about https. I'll need to remember simple HTML.
I'm able to convert something like this to fetch? This is a JS file: https://cdn.hamoodihajjiri.com/f2oyWOj3y4 .
fetch(url here).then(x => x.json()).then(data => {
...
})
fetch('https://api.dictionaryapi.dev/api/v2/entries/en/meow')
.then((response) => response.json())
.then((data) => console.log(data));
fetch failed cause: TypeError: Argument is not a ByteString
i mean
youre running that in node
its supposed to be run in a browser
but it should work in node too since v18
I'm yet so confused.
Is there a need for jwt token?
not the best.
The token is still there
well you know the error.
The error yes, but not the code
Why building it yourself?
Just go to release and download the latest version
Or is that a runtime error?
cargo build --release
how can I get the amount of users of every guild the bot is in combined? aka its in for example 2 servers, 1 has 10 users and 2 has 56 users, I should get 66 as output (discord.js)
each guild has .memberCount
you have to loop over all guilds and add up their member counts
Hey hey, does anyone know how i could find the center in this program?
We are not allowed to use ints
and we also constantly have variating border sizes.
@lyric mountain might be a question for you XD
do you know width and height tho
nope
you only get dropped in a situation like this
while the border height and width change each scenario
and the bot (arrow) must find the center for each one
is it always square?
yeah
is this for collegeboard or something
then first thing is determine the height and width
the bot cannot remember how far it walked?
we have functions step(), in_front_of_wall(), on_ball(), turn_right, turn_left
you cant count the number of steps?
nope as we cannot use ints
just do it with floats then? XD
lmao
i dont see how it can be done without the bot somehow remembering how far it walked
for example, walk forward until you hit a wall
Unless you have defined the width and height of each square.
A possible strategy to find the center of the earth is to keep placing balls at opposing walls of Charles
world, until they meet. At that position, you have found the middle of one the axes of Charles world.
This is illustrated in the figure below:
ah so you place balls?
so basically
oh so the world size changes?
yeah
do you know the tile count?
it can have 100 variances where the hight and width changes
nope
walk forward until wall, place ball, walk backwards until wall, place ball, walk forward until ball, place ball, walk backwards until ball, place ball, etc until you hit the center
then repeat on the other axis
How would i know if it hit the center?
if left and right are balls
it will reach a point where it cannot move to a non-ball place anymore
or up and down depending on which way you go
OMG
YOU ARE A GENIUS
i didn't even thing of that


under the belly
LMAO.
on_ball() can be checked
ok
your teacher is a sadist
i kn0w
i have a problem btw guys
so our initial plan might not work
as on_ball() only works if you are standing on it instead of in front of it
well then turn 180° and step one back
only until stepping back makes you also be on a ball
you would then need to turn 180° again and go back once
yes that's why I made the undo() function in the other example
means you're in the middle
No look let me send you an example
while(!north()){
if(!in_front_of_wall()){
step();
put_ball();
}else{
turn_right();
turn_right();
}
}```I have used this, but there's a problem
imagine that i am on a ball, it will error

and how would i make the program stop as soon as only 1 tile is left?
Like that's not even possible
Bro my teachers are fucking me realtime
What
do you always start in a corner for this case?
Yes
walk until you find a ball, then walk 1 step backwards
what about the facing angle?
There's no ball in the field at the begin. You must place everything
always looking east
yes i knw
but only function available in regards of looking direction is north()
the first ball you place when you hit a wall
easy then, as first put a ball, then walk UNTIL you're in front of a wall, put another ball, then turn 180°, walk UNTIL you're on a ball, turn 180° step one, place ball, and so on
There's a problem
you can only use on_ball() when you are on a ball
walk UNTIL you're on a ball, turn 180° step one, place ball
except the first ball the procedure is always the same
on ball = 180° turn, step one, place ball
when stepping one, check if you're ON a ball
if so you have filled the X axis with balls
in that moment, you turn 180° a last time and step once
and your in the centre
now the same procedure for the Y axis
but the FIRST action is NOT to place a ball
since it's already there#
but i would constantly have to create while loops
you can use recursive functions
the procedure repeats for both axis until you're stepping forward and being on a ball, then break it
while(!in_front_of_wall()){
put_ball();
step();
}
turn_right();
turn_right();
while(!in_front_of_wall()){
put_ball();
step();
}
turn_right();
turn_right();
while(!on_ball){
step();
}
turn_right();
turn_right();
step();
put_ball();```
I would have to constantly use while loops
however we don't know what the width of the box is
so we cannot use such approach
Are those while loops being nested in a while loop a good idea?
Unless there is a way to break out of them
or wait is that while loop being ended nevermind
that formatting fucked up my view on it
he cant use break lmao
is this for some school project or smth?
it is, and the teacher imposes ridiculous conditions
are we allowed to help with this?
idk
no let me tell their teacher rn
It doesn't count for a grade iirc
then its cool
it's just homework
I just don't think helping someone with a graded project is the right thing to do. As it would be mostly us telling him what to do and him learning nothing
Yup i agree.
That’s no issue at all
so you can't use any variables at all?
nope
What are the conditions
You still can use statements inside the loop
only functions, if statements, put_ball(), on_ball(), in_front_of_wall(), get_ball(),turn_right/leftm step()
this sounds familiar
He can create his own functions check if he’s on all ball or not to do the required steps
I did something similar in my cs class that wasn't worth shit
And use it as statement inside the loop
What country are you from?
The hell is this goofy ass "homework"
- no value-returning functions
- no
break - no arrays
- you cannot know the next tile without stepping first (except if it's a wall)
- you cannot know the dimensions of the map
US
oh and no pointers
That last one implies that it could be dynamic
Ah i am currently studying in France.
ye but you cant do stuff like getSize or getX
😔
I am killing myself
like, there's no way to retrieve the dimensions
This some wack ass shit bro
Is this exercise a local program or available online?
is this in java?
Oh fun
I want the lines outside the gray background to be deleted but the function I am using is not working
the lines in the middle should be visible and the dots in the corner should not
and no I sadly cannot provide you the program as you gotta login using the students number and password
iterate over all pixels, set the alpha based on brightness of the mask
give us your student number and password /s
And credit card information
lines can change color
and the funny little numbers on the back
Right now i got this far, but then it of course reaches a ball he placed earlier on and tries to put another ball which causes a rash

a mask should always be BW
simply set alpha to be how white the mask is at that part
white means 255, black means 0, interpolate for other tones
That’s why I said earlier ONCE you’re on a ball turn 180° and step once, place a ball
But check if you’re not already on a ball
That procedure is just a repeating process
while(!north()){
if(!in_front_of_wall()){
step();
}else{
turn_right();
turn_right();
if(!on_ball()){
put_ball();
}else{
step();
put_ball();
}
}
} ```i know, i got this far now. So it basically goes on, till there's a gap. However, how does the bot know that he's on the last tile?
I feel like this is pretty easy, but I don't have an env to test so I can't really be sure
What’s north()?
it kinda is, simply track the amount of steps until the next ball, divide by two and step that amount
A function to check the facing angle?
to check if it's looking north
i cannot use ints and variables
wtf
so how would i be able to track balls placed lmao
Is there any direction or just north?
just noeth
Yes that confirms that the mentioned way is exactly what they expect you to do
As the last step would be from down to up being on a ball, turning 180 going down again and you’re in the middle of the y axis
Waaaaht
yeah but i am still stuck at the x-asix code
this issue
Taking a shower real quick
Be so kind and send the entire code incl all prebuilt functions please and ping me
Maybe not in a code block 
sure
void find_center_agent()
{
while(!in_front_of_wall()){
put_ball();
step();
}
}```is what i have rn
I deleted the rest
is there documentation on premade functions?
no, but all the functions are: step(), north(), turn_right()/left, on_ball(), in_front_of_wall(), get_ball(), put_ball()
this is all
most of them are boolean functions
I see
only with a certain condition
so imagine i use a while loop with !north
I could first do everything, then at the end once it's in the center look up north
does that mean you don't actually have to place balls on the y axis?
you can turn around 360° on each step down as long as you not in front of a wall
when being in the middle of the y axis and looking north the script would be done, right?
no matter balls or placed or not?!
@eternal osprey
yup!
You don't have to place balls as long as you find the middle
so lol
is there a hiring channel?>>
find the middle of x axis, go down until wall, then turn 180° go up and the script would automatically stop when being in center?
no, you gotta use service portals like fiver or however they are called
no you have to stop it
like in the code
ah ok
Cargo.toml "port" category?
With category I mean e.g. [dependencies]
yeah i am so stuck that i think to just give up
lemme try something
I'll ping u
is this enough to understand?








