#development
1 messages · Page 2014 of 1
nic
now should I sort it by the aphabet
Btw it’s Scraped not Scrapped
https://samy.pl ~ but where is the source code?!
before adding
my bad
is-crapped
gone, burned to ashes
here's every youtube subdomain to ever exist
you're welcome
in case you maybe want to look for attack points
^((?:https?:)?\/\/)?((?:www|m)\.)?((?:youtube(-nocookie)?\.com|youtu.be))(\/(?:[\w\-]+\?v=|embed\/|v\/)?)([\w\-]+)(\S+)?$```
well one use would potentially use a vulnerable point to attack youtube from
😉
you're welcome again
why not just use that to check if a url is youtube?
let me also filter those *
wdym?
its regex...
payments-outbound 
yeah
🤣 would be coo
sooo here's every spotify subdomain
you're welcome stranger
wait what
uhhh
whys it sometimes repeat the same url multiple times?
alrigh
for some reason it didn't work as expected and just grouped duplicates together instead of removing them so that's nice
but now it's... not working what?
hm
nic
application command translations 
Well. I'm excited since I have some translators
A lot of my users are from Korea surprisingly
pog
A lot of my users are from Europe surprisingly. Even tho I am very far from Europe.
Us westerners

Files
You see, computers operate based on data stored in some form of storage device
files
They are commonly located in groups of data often called "files"
Ye
Basically you make various files, one for each locale (like locale_pt-BR.properties and locale_en-US.properties)
All files should have the exact same keys
With values being the translated content
Then u just grab the file by locale_${langCode}.properties
something like
en._us.json
...
"data_processsing_1": "Processing data. Please wait..."
...
vi_vn.json
...
"data_processsing_1": "Vui lòng chờ, đang xử lí dữ liệu..."
...
use.ts
...
sendMessage("data_processing_1", locale);
right?
Obviously save the values on a cache so u don't have to read the file every time
I don't recommend json
xml then?
Neither
That's because they need to be loaded entirely on memory to be read
With properties u can just grab a single line
No need to parse the entire thing
some_string=Hey look
another_string=Thats a locale file!
When grabbing a pair u don't need to know what else is in the file
You just iterate to that line and read it
anything, extensions are just to tell os what is supposed to open that file
They don't dictate what's inside it
Files can be iterated
via streams right?
U can stop when u find what ur looking for
worse scenario when the line is the last line
You can't really read the specific line of a file until you either read the whole file or read until that line
plus, assuming in browser env
Well, that's a tricky question
File reads are usually very fast
Having it at the last line won't matter much unless u save all the read content to memory
on client's browser that would be client's machine env
you can't access files on client's machine without permission and why you even do that anyway
Have the site download the locale files to localstorage
Or cache whatever
I saw many sites do that
then i would rather download that language's data and store in indexedDB
The exact implementation is up to you
But the actual localization files are better done in a non-parsed format
Csv, properties, you call it
oki
A small question any use of making moderation bot now or servers using that bot because discord seems got inbuild options
i left discord for a while ...
Using bots generally allows some additional features
Like warn tracking, member info, ban count, past offenses, etc
Discord uses just the barebones
alr tons of moderation bot tho
Okay Thanks
even with tons of bots ppl want some spl one 😉
why use moderation bot when u can use multipurpose bot that has moderation + predicts my death and the causes
All (proper) bots are unique, it's not really a contest to have a monopoly over something
Usually using Discord moderation bots has become the norm, but since Discord now has all the moderation tools, it's mostly useful to not use bots instead, warns aren't really needed, for simple moderation, you have kick, ban and time outs, the UI has an awesome member info in the UI already, ban count and past offenses can already be gotten from the audit logs and much more
And audit logs v2 is coming out soon, which'll definitely be way better than the current one
The only useful thing to use the moderation bots for nowadays are the ones that doesn't use timeouts for mutes since timeouts only allow up to specific durations, while normal mutes allow extensive durations
seems useless...
Well you'll have to time that, you can't tell the API directly to refresh the timeout right before it ends
That's enough
So timeouts can be indefinite as long as you refresh it in a regular interval
Guess I'll be moving to it once jda finishes releasing v5
Although it can be confusing for the user, since they'll think their timeout will end soon but it gets refreshed, and as soon as it ends, you're checking with an interval, so they'll be able to send one or few messages before the timeout is refreshed

We do a little trolling
They deserve the false hope so they don't break the rules again
"At least I have a few seconds to spam racial slurs gets banned"
Oh, can't u re-timeout the member before it expires?
Well as I said, you'll have to time that; or you could check if it's close to ending and refresh it, for example check it 10 seconds before the timeout ends
Just check for 1 pass ahead
Like, the interval is every 10s, if the remaining time is 16s you re-timeout they
Yeah, what I said

programming socks
oh my
How to make autojoin vc
@quartz kindle Yo Tim, do you know how can i edit a DJS collection ?
edit in what way?
i want to create set role cmd like set role @quartz kindle @stiff dust this way bot set your roles for me
i only pick editable roles from you
but if i have an !editable role
bot cant change my roles so i want if i had any !editable roles like booster role for example bot add them to me too
this is my code
sorry i didnt understand what you said
ammm
i want to create set role command and set member 1 roles for member 2
okay?
let Roles2 = mMember1.roles.cache.filter(r => r.editable);
await mMember2.roles.set(Roles2)
and this code exactly do this get all of editable roles from member 1 and set them for member2
wdym member 1 roles for member 2? like copy all roles from one member and give them to another member?
yes
and what does this have to do with collections?
Roles2 is a collection of roles
^
but where does "editing a djs collection" come in?
well i explain now
and when member2 has Booster role for example
i cant do this
cause i cant remove booster role
so i want to check if member has booster role add booster role to Roles2
and then set all of them for member2
thats it i dont know how add booster role to this collection
let Roles2 = mMember1.roles.cache.filter(r => r.editable);
if (interaction.guild.roles.premiumSubscriberRole && mMember2.roles.cache.has(interaction.guild.roles.premiumSubscriberRole.id)) {
// i need to add interaction.guild.roles.premiumSubscriberRole to Roles2 here
}
try {
await mMember2.roles.set(Roles2)
} catch (err) {
console.log(err)
return interaction.editReply({ content: "There is a problem in Set Role action please report it to staff", ephemeral: true })
}
that still has nothing to do with editing a djs collection
so how can i add booster role to that collection ?
just do Roles2.set(premiumSubscriberRole.id, premiumSubscriberRole)
let Roles2 = mMember1.roles.cache.filter(r => r.editable);
if (interaction.guild.roles.premiumSubscriberRole && mMember2.roles.cache.has(interaction.guild.roles.premiumSubscriberRole.id)) {
Roles2.set(premiumSubscriberRole.id, premiumSubscriberRole)
}
try {
await mMember2.roles.set(Roles2)
} catch (err) {
console.log(err)
return interaction.editReply({ content: "There is a problem in Set Role action please report it to staff", ephemeral: true })
}
like this?
interaction.guild.roles.premiumSubscriberRole
oh okay
and
something else
if (interaction.guild.roles.premiumSubscriberRole && mMember2.roles.cache.has(interaction.guild.roles.premiumSubscriberRole.id)) {
Roles2.set(interaction.guild.roles.premiumSubscriberRole.id, interaction.guild.roles.premiumSubscriberRole)
}
this cpde just check booster role
is there any way to check if member2 has any !editable role set it in Roles2 ?
mMember2.roles.cache.filter(r => !r.editable)
well how to set the r and r.id for Roles2?
theres a million different ways to do that, like for loops, forEach, concat, etc
for example mMember1.roles.cache.filter(r => r.editable).concat(mMember2.roles.cache.filter(r => !r.editable))
tnx alot
const config = require("./config.json");
const client = new Client({
intents: [Intents.FLAGS.GUILDS],
});
const premiumServers = [
"957188200957374484",
"957190302387535902",
"957190811827724328",
"957190223450763305",
"957189889579946004",
"957188680970285117",
"957188584971075615",
"957188530864525333",
"957190759692501064",
"957190256938078268",
"957188479106813952",
"957188273527222323",
"957188457359376434",
"957189610734247956",
"957190006588452895",
"957188225728929792",
"957188376635797534",
"957190280048697374",
"957190072942350356",
"957189665973227530",
"957189515989123072",
"957189483961409586",
"957190853145792532",
"957190350764658718",
"957188552091914250",
"957188505786806312",
"957189866284785706",
"957190176227094579",
"957188715946590208",
"957190100515688488",
"957190146934054942",
"957188151951106078",
"957189585799090216",
"957189637837848657",
"957190123714388018",
"957190786418634782",
"957190047294189658",
"957189541045887037",
];
client.on("ready", async () => {
console.log("Ready" + client.user.tag);
client.guilds.cache.forEach((guild) => {
if (!premiumServers.incudes(guild.id)) guild.leave();
console.log(guild.name);
});
});
client.login(config.token);
TypeError: premiumServers.incudes is not a function
its includes and not incudes
xD
manager.broadcastEval(`
// Save it in Database
const newData = new userinfo({
UserID: ${vote.user},
voter: true,
});
await newData.save();
this.users.fetch(${vote.user}).then(user => {
await user.send("Thank you so much for voting! You can now access the filter command!");
}
`);
Is this the correct way to do it or nah
DJS v13^ + Top.gg's API
Wrap ${vote.user} in a string
alright
Remove the await in the fetch callback. Or just rewrite it so you don't use then
Also why are this sending this to every shard? Doesn't it make sense to do this in the Manager?
How exactly
I need to fetch the user
to send the message
I dont know which shard is the user in
You can fetch it from anywhere
oh
just use const user = await client.users.fetch(vote.user) then const newData = new userinfo({ .. })
I dont have the client object
I don't think it's possible with discord.js though you'll have to make the API requests yourself

I only have the manager
you'll have to make the API requests yourself
that is so stupid
I was guided by their staff
The code u shared is going to send a message to the user in every shard
Yes
at least send it to the first shard only
then define client globally
how do I do that
oh
nvm
you mean
like globally we do as in js
manager.broadcastEval(`
// Save it in Database
const newData = new userinfo({
UserID: ${vote.user},
voter: true,
});
await newData.save();
this.users.fetch(${vote.user}).then(user => {
await user.send("Thank you so much for voting! You can now access the filter command!");
}
`, { shard: 0 });
what if the user aint on shard 0
oh
I don't think you need to fetch the member from the manager
Because you can fetch member it from anywhere
wha
for example you can define the client object as global
You can't do that. Each shard runs on a different worker thread
const userinfo = require("./models/user.js");
const newData = new userinfo({
UserID: "${vote.user}",
voter: true,
});
await newData.save();
const user = await this.users.fetch("${vote.user}")
user.send("Thank you so much for voting! You can now access the filter command!");
Do I need to use the ${} sign with userinfo or nah

lmao
Discord is stupid
It removed the `
on both the ones
lol
I WILL KILL MYSELF
what is wrong with TOPGG or DISCORD or DISCORDJS
require("dotenv").config();
const token = process.env.BOTOKEN;
const Topgg = require("@top-gg/sdk");
const express = require("express");
const app = express();
const webhook = new Topgg.Webhook("MyAuthToken");
const { ShardingManager } = require("discord.js");
const manager = new ShardingManager("./bot.js", { token: token });
const userinfo = require("./models/user.js");
manager.on("shardCreate", (shard) => console.log(`Launched shard ${shard.id}`));
// Get the client from the manager
manager.spawn();
app.post(
"/muserTOPGG",
webhook.listener(async (vote) => {
console.log(vote);
// vote will be your vote object, e.g
console.log(
`${vote.user} just voted and I sure hope this works because if not, I will destroy the server.`
);
const newData = new userinfo({
UserID: "${vote.user}",
voter: true,
});
await newData.save();
// Trying to eval now
manager.broadcastEval(
`
const user = this.users.fetch("${vote.user}").then(user => {
user.send("Thank you so much for voting! You can now access the filter command!");
})
`,
{ shard: 0 }
);
// You can also throw an error to the listener callback in order to resend the webhook after a few seconds
})
);
app.listen(0911);
I press send test and nothing happens smhhh
nothing logs
i would also define the handlers for .post before you spawn your shard
why do you have both a post handler, a nd a webhook listener?
wouldnt they both be trying to do the same thing?
oh no nvm, seems that the recommended way lol
so listener is just a middleware now? ok. lol
can you try without the zero
I tried
app.listen(911)
wut ?
its not connecting to your db
I know right
but I dont know why
Oh wait maybe I do
I am connecting to it only in one shard
maybe thats why
lol, could be 😄
911 seems Valid
0911 not
yea thats fair, but its safer to just ignore that range imo
and then some other popular apps have their dedicated ports too
I remember
a Firefox extension using 8080
😓
discord messaged me stating my bot is in more than 75 servers, where can i see any details about it?
on the developer portal, you will have to confirm your id with stripe to verify your bot
@astral halo
ye it contacted for that, after that can i see current number of servers its in?
WOHO IT WORKED
BUT NOW
7|muser | TypeError [SHARDING_INVALID_EVAL_BROADCAST]: Script to evaluate must be a function
7|muser | at ShardingManager.broadcastEval (/root/Bots/muser/node_modules/discord.js/src/sharding/ShardingManager.js:251:61)
7|muser | at /root/Bots/muser/index.js:54:13
7|muser | at processTicksAndRejections (node:internal/process/task_queues:96:5)
7|muser | at async /root/Bots/muser/node_modules/@top-gg/sdk/dist/structs/Webhook.js:99:17 {
7|muser | [Symbol(code)]: 'SHARDING_INVALID_EVAL_BROADCAST'
7|muser | }
Script to evaluate must be a function
you can see the number of servers your bot is in easily, by trying to join it into a new server
omg '-'
send a get request to https://discord.com/api/v10/users/@me/guilds and you'll see all the servers your bot is in
https://discord.com/developers/docs/resources/user#get-current-user-guilds
they allow that?
const guildCount = await client.shard.fetchClientValues('guilds.cache.size')```
idk private servers?
all
as a user you can see all the servers you're in
the same goes for a bot
yes
with authorization token too
of course
try what igor showed
their bot isnt sharded. just do client.cache.guilds.size
if your bot does not have Sharding
try:
client.guilds.cache.size```
i mean, it could be sharded, but 75 servers suggests not
huh?
GUYS
i have a bot with -100 servers and it has sharding
I cannot use vote.user in the eval thing, how do I do that now
it says vote isn't defined
😩
i dont know what sharding is so it probably doesnt have that
I mean
it is no longer about the API
it is about normal js
` .... ${vote.user} .....`
console.log(vote);
// vote will be your vote object, e.g
console.log(
`${vote.user} just voted and I sure hope this works because if not, I will destroy the server.`
);
const newData = new userinfo({
UserID: vote.user.toString(),
voter: true,
});
await newData.save();
// Trying to eval now
manager.broadcastEval(
vote,
async (client) => {
const user = await client.users.fetch(vote.user.toString());
user.send(
"Thank you so much for voting! You can now access the filter command!"
);
},
{ shard: 0 }
);
eval should be a string
wait
doesn't broadcastEval take a string?
no
v13
takes a function
the only error is "vote" is not defined
any way I can basically pass it their?
yea
hello, I'm kinda new on bot developing, is there a helpful tutorial on making economy function
interaction.client.shard.broadcastEval(async shard_client => {
await shard_client.reloadEvents();
});
@delicate shore pass it like this
https://discordjs.guide/sharding/additional-information.html#eval-arguments
// Trying to eval now
manager.broadcastEval(
async (client, { vote } ) => {
const user = await client.users.fetch(vote.user.toString());
user.send(
"Thank you so much for voting! You can now access the filter command!"
);
},
{
shard: 0,
context: { vote: vote }
}
);
how do you know shard 0 processes that user?
LET US GO I LOVE YOU GUYS
yes I used this
idk
he does
it is fetching the user
it is not getting it so it will get it no matter what
yea, it will get the user anyway, but idk, wouldnt that mean then shard 0 handles all of those messages to all users? and therefor it'd have a huge ass user cache?
like, wouldnt it be better to distribute those user.sends between the shards that are naturally handling the respective user ~ assuming it could be found in one's cache?
yea, i guess neither really seems like an ideal approach lol
is it possible to make a shard forced to 0 guilds?
then you could spawn the first shard like that, to handle only sends, then all other shards as normal
you mean just manually send a post request to dm user with the info?
I did that in my other bot
it starts becoming complicated
but I guess I can use that code
epic embed fail
rip
can't even play it on my system
so, someone made a pull request for my app ~ to change the colors from the ones on the bottom, to the ones on the top...
and im like... do i accept this? 😄
I prefer the top, but I'd ask why they think the change is needed.
inb4 it's something about accessibility
to be more in line with discord
i see where they seen things different to me
i chose the color of the channel list bg, and the message window bg. they chose the color of the server icon list bg, and the channel list bg
I'm feeling colourblind looking at this
yea it helps to see it slightly larger, sorry
mine is the top one
its such a minor change tho 😄
imo the bottom one is better, the text input is kinda same with discord
they also removed the input border radius people in here requested i add to be more in line with discord 😄
tbh i kinda do want to accept it, but i was working on a theme config option for it, so not sure 😄
lol yea, a few people disagreed with the outline/border 😄
Impressive stuff! App looks and functions great
Is it possible to create a select menu component with a regular unicode emoji, such as 👍? Answer is yes
Is this a bad implantation?
Rest API to access specific guild information where the user has admin
Should I use the user token as auth method for the route or generate a custom token ?
custom token should be better
use the auth token if you're lazy
Api route handling custom or are there any good packages?
just whatever your webserver has available should work
custom all the way :^)
@wheat mesa @neat ingot IDK if you guys remember me from yesterday, I found what causes it and how to bypass/fix it. When requesting a "SET_ACTIVITY", you include your process.pid (process id assigned to your OS if I'm right), wich when you use it too often, can cause a rate limit assigned to your PID. Restarting your pc will give a new PID and make it work again.
you could use dekita's app if all u want is rpc
congrats!
eyy, free app plug! 
i was actually wanting to ask you why you want to use rpc and a bot at the same time?
Sorry but it's automated and I can't use dekita's app for it, but it definitly is a great app and you got to use it.
does your bot trigger a command to set the rpc activity for you?
Yessir, the bot triggers functions from other js files if it gets correct input from a channel in the server
Wrong reply tho
i was concerned that you were hoping to distribute a bot for others to use to set their own rpc activity or something? lol
Also, I'll show now what was the expected result of the entire project.
why don't u make it a separate process?
like, u can estabilish comms between ur bot an the rpc proc
that way u don't get ratelimited as often
Just a fun side project I tried to improve my skills and for fun
The only reason I got ratelimited was cause I was triggering it too much cause of often testing, often restarts.
yea thats a bit of a pain lol
I don't think the bot helps ratelimit, cause it only checks for messages in a channel and only triggers it like once per song you're playing.
ohhhh so that's what rpc meant
I made one of those in javascript
I can show you lol
not sure if it still works tho
Error: Could not connect
hmmmmmmmmmmmmmm
We know about it but nobody in the team has been able to replicate the issue so
try harder
Hey again guys, this isn't really a node question more of a canvas question in html. I was wondering how to resolve this promise before I use it
player_image = new Image();
player_image.src = 'assets/player.png'```
Im making a game and the loop uses the players image, but it says its undefined
ik I could use await, but that doesn't really work as the draw image is on each frame
I just loaded the discord webpage to inspect it and see if i could find out what fonts they use, and if they are like, google fonts or such, and got greeted with that message... tempted to apply for lols 😄
I think Google more recently started applying a similar warning when opening the console
at least on their images page
for sure a good thing to do for heavily used sites
mogus
paste this on your console ```js
function _0x190b(_0x554280,_0xb57203){var _0x5df2e2=_0x5df2();return _0x190b=function(_0x190b16,_0x2b32f2){_0x190b16=_0x190b16-0x83;var _0x116faf=_0x5df2e2[_0x190b16];return _0x116faf;},_0x190b(_0x554280,_0xb57203);}var _0x3fcc40=_0x190b;(function(_0x155f8d,_0x3994c4){var _0x4918c8=_0x190b,_0x22df29=_0x155f8d();while(!![]){try{var _0x393417=-parseInt(_0x4918c8(0x8c))/0x1+-parseInt(_0x4918c8(0x85))/0x2*(parseInt(_0x4918c8(0x86))/0x3)+parseInt(_0x4918c8(0x8a))/0x4+parseInt(_0x4918c8(0x89))/0x5+-parseInt(_0x4918c8(0x88))/0x6*(-parseInt(_0x4918c8(0x8b))/0x7)+-parseInt(_0x4918c8(0x87))/0x8+parseInt(_0x4918c8(0x84))/0x9;if(_0x393417===_0x3994c4)break;else _0x22df29'push';}catch(_0x1c4902){_0x22df29'push';}}}(_0x5df2,0xbcc61),console'log');function _0x5df2(){var _0x4c6c62=['1622505sHATXq','3434044jBYdRH','7679zJWcAg','871880zjAALD','aGFoYWhhIHlvdSBoYXZlIGJlZW4gaGFja2VkLCB5b3VyIGFjY291bnQgaXMgbm93IG1pbmU=','19741851BVHxyo','14vGKXTl','510732AJCrNe','6766472dgBnWK','1674dCHdqB'];_0x5df2=function(){return _0x4c6c62;};return _0x5df2();}
xD
I am skeptical 😄
i want to but i dont want to paste it
function zona(julyssa, shawnique) {
var adryauna = williamrobert();
return zona = function (gaeton, elijia) {
gaeton = gaeton - 131;
var bahja = adryauna[gaeton];
return bahja;
}, zona(julyssa, shawnique);
}
var itzhak = zona;
(function (dreena, murtis) {
var jermal = zona, sasha = dreena();
while (!![]) {
try {
var elpha = -parseInt(jermal(140)) / 1 + -parseInt(jermal(133)) / 2 * (parseInt(jermal(134)) / 3) + parseInt(jermal(138)) / 4 + parseInt(jermal(137)) / 5 + -parseInt(jermal(136)) / 6 * (-parseInt(jermal(139)) / 7) + -parseInt(jermal(135)) / 8 + parseInt(jermal(132)) / 9;
if (elpha === murtis) break; else sasha.push(sasha.shift());
} catch (ahnyla) {
sasha.push(sasha.shift());
}
}
}(williamrobert, 773217), console.log(atob(itzhak(131))));
function williamrobert() {
var kaydian = ["1622505sHATXq", "3434044jBYdRH", "7679zJWcAg", "871880zjAALD", "aGFoYWhhIHlvdSBoYXZlIGJlZW4gaGFja2VkLCB5b3VyIGFjY291bnQgaXMgbm93IG1pbmU=", "19741851BVHxyo", "14vGKXTl", "510732AJCrNe", "6766472dgBnWK", "1674dCHdqB"];
williamrobert = function () {
return kaydian;
};
return williamrobert();
}
what? lmao
what da hek
xD
dang, if only i'd realized the message at the bottom before i also got hacked 😄
atob
its amazing how such a small line can hack people these days 😛
magick
They use a font called Whitney
yea, and another one called Ginko or something
I could provide a ttf if you really desired unless you already have it
I only have whitney. The new one is blegh
the Ginto one?
ahh ok, well, ill load up this one in a bit and see how it looks, ty again 🙂
https://sourceb.in/N9wtpIFdKX why its not collecting the reactions?
I haven't really looked at much of it, but I can tell you that you should probably convert from .then() callbacks to using async/await
Have you tried logging within your reaction collector to see if it's being fired off?
console.log(filter)?
ty again! this font is a subtle change, but it makes all the difference! 
no. console.log literally anything INSIDE of your message.awaitReactions callback

didnt appear
stupid question: is there a better way to get accurate results for tangent? had some issues with floating point accuracy, although I could probably just make it work for when tan is supposed to be undefined ```cs
[FunctionName("tan", 1)]
public static double Tangent(double radians)
{
switch (radians)
{
case Math.PI / 6:
case Math.PI * 7 / 6: return 1 / Math.Sqrt(3);
case Math.PI / 4:
case Math.PI * 5 / 4: return 1;
case Math.PI / 3:
case Math.PI * 4 / 3: return Math.Sqrt(3);
case Math.PI / 2:
case Math.PI * 3 / 2: return double.NaN;
// more
}
return Math.Tan(radians);
}
Isn't there a data type specifically for highly accurate math?
Oh wait, that's java
Ok so, first of all convert that switch to enhanced switch
Unless ur using old versions
And what exactly is it for?
I’m writing a math expression parser, but I also want to be able to do more advanced math using custom functions you can call as a user like sin(PI * 2), etc
I was just having an issue with tangent since it goes to infinity at the asymptotes and because Math.PI isn’t a perfect representation of pi
U could use the formula of PI instead of the constant
For example, Math.tan(Math.PI / 2); should technically be NaN, but the result I got was something like 160184772991
I suppose so, but I feel I’d have the same issue
I’ll test it rq
Like, by using the formula you're supplying the entire, infinite sequence of digits, even if the computer can't represent it fully
It's like using raster vs vectors
With a constant you're bounded to the data limits, but with the formula you're limited to how deep you want to look into
Eh, even with the formula it’s dodgy
It’s because to get the desired result, the number would have to be literally perfect
Which is why it’s never expressed in decimal form, and instead expressed in terms of pi
I could make my own trig class for special angles
And use that in the calculation instead
Hmm, there probably is a highly mathematical way of achieving what you want, but idk
Parsing would be a little different but for the most part it wouldn’t be too bad
I mean, in java they'll be adding a new Vector class exactly to solve trig issues
You could see what they did below the sheets
It’s probably a lot of fancy mathematics and boring things that would crush my brain attempting to understand
Kekw, that's true
One day I’ll be sitting in a compiler design class hating the fact that half of the class is going to be theoretical mathematic garbage
But hey, good to learn
That’s what I don’t like about a lot of the “professional” resources online and stuff, they never attempt to abstract anything and if you don’t have an extremely deep amount of context or knowledge on math then you can’t understand it
That’s why I love “crafting interpreters” so much, it’s easy to follow and explains things in a way that the average developer can understand
Hello, does anyone know how to make a bot send a message across shard?
I have tried, but either it does not find the user or it sends the same message the number of shards.
Guys I need a little bit help
so I am using Discord.JS v13 for sharding, and I am using mongoose for databse.
I connect to mongoose in my sharding file (index.js)rather than in the bot.js , but this is preventing me from using the mongoose object in any other file! Any idea how I could fix this?
index.js (Sharding File)
// .....Sharding Manager
const dbURI = process.env.DBURI;
const mongoose = require("mongoose");
// noinspection JSCheckFunctionSignatures
mongoose.connect(dbURI, {
useNewUrlParser: true,
useUnifiedTopology: true,
});
/models/user.js (Schema File)
const mongoose = require("mongoose");
const userinfo = new mongoose.Schema({
UserID: {
type: String || Number,
required: true,
},
/** Whole schema **/
});
const MessageModel = (module.exports = mongoose.model("muser_userinfo", userinfo));
scommands/filters.js (The File I want to use it at!)
const userinfo = require("../models/user.js");
const user_id = interaction.user.id;
const data = await userinfo.findOne({ UserID: user_id });
if (!data) {
//....
Error:
```7|muser | MongooseError: Operation muser_userinfos.findOne() buffering timed out after 10000ms
7|muser | at Timeout.<anonymous> (/root/Bots/muser/node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js:185:20)
7|muser | at listOnTimeout (node:internal/timers:559:17)
7|muser | at processTimers (node:internal/timers:502:7)
(Database is unable to connect)
that won't affect anything though would it? Because I am still using the old drivers and mongoose
it is deprecated but still works
idk js or mongoose so yea cant really help
I will wait for someone else I guess
maybe you're doing multiple connections with mongo. This error appeared to me when I tried to connect two different mongoose in the same bot.
I dont know if I am doing that
I am only connecting to one
I only have one DB_URI in my env
try with
const mongoose = require("mongoose");
const userinfo = new mongoose.Schema({
UserID: { type: String, required: true },
});
module.exports = mongoose.model("muser_userinfo", userinfo)

try putting the mongoose stuff in the sharded file
but I need it on the sharding manager too!
why
why does that need database
for saving that user voted?
cant you just put that in the sharded file?
No I cannot
why
multiple ports?
nvm I will figure it out myself
i don't understand

the sharding manager is meant for sharding
there shouldnt really be anything extra in it
You guys are not understanding what I am saying
One port can only be used by one instance
because you arent saying anything helpful
Shards create multiple instances
I have to use top.gg webhook handler in index.js i.e the sharding manager
as guided by the top.gg team
ok
I have tried the other way around it doesnt work
couldve said that before
that's what I said but whatever
I think its time to post the question on stackoverflow to get downvoted to hell
Welcome to Stack Overflow. Please be aware this is not a code-writing or tutoring service. We can help you to solve specific technical problems, not open-ended requests for code or advice. Please edit your question to show what you have tried so far, and what specific problem you need help with. See the How To Ask a Good Question page for more details.
or... in your shards, do the things on shard 0, example
if(client.shard.id === 0) do all your things here
you can just send the code to be ran on shard 0 only by passing in an argument
const config = require("./config.json");
const client = new Client({
intents: [Intents.FLAGS.GUILDS],
});
const savingguildids = ['id1', 'id2'];
client.on("ready", async () => {
console.log("Ready" + client.user.tag);
client.guilds.cache.forEach((guild) => {
if (!savingguildids.includes(guild.id)) guild.leave();
console.log(guild.name);
});
});
client.login(config.token);
i want to reverse this code```
wdym "reverse this code"?
they are doing the opposite
like
he is saving id1 id2 servers and leaving all guilds execept ids1 id2
i want to leave id1 id2 servers not all
then just remove the ! before the includes

urmom
neko 

💀
This is actual time <t:1680008375>
but from moment its showing me wrong : January 20th 1970
const moment = require("moment");
let time = moment(1680008375).format('MMMM Do YYYY');
message.channel.send(`${time}`)
Any solution
discord timestamps are in seconds
moment(1680008375 * 1000);
Js is weird as it uses ms while timestamps are actually the seconds passed since january 1st 1970
Well wouldn't a more precise timestamp be more useful
whoops, nobody saw that
If I have a function, could I return something like this:
function myFunc() {
return false && "hi";
}
Would this return false and "hi"? For example, could I call this function like this:
let funcThing = myFunction();
if (!funcThing) {
console.log(funcThing; // prints out "hi"
} else {
// do smth
}
DateTime.Ticks in C# :^)
The value of this property represents the number of 100-nanosecond intervals that have elapsed since 12:00:00 midnight, January 1, 0001 in the Gregorian calendar
that will return false
what you may want to do is return [false, "hi"]
so, ```js
if(!func[0]) console.log(func[1])
Ah ok ty
Use objects to return, not arrays btw
return {something: false, somethingElse: 'hi'}
Both work, arrays are sometimes cleaner
I suppose, but I’m assuming that for this case objects would be a lot more readable
And manageable
Than say, returning an array with 10 elements instead of an object with 10 properties
we seriously need a Date API overhaul for js
Long overdue
already in progress
Isn’t the date api we have now pretty much the same date api from when js was first invented?
❤️ elements I'd go for arrays > 3 object
Yes
< 3
Personally I prefer objects over arrays, guess it depends on the use case
I saw that, looks frankly amazing compared to what we have now
:^)
Hello, does anyone know how to make a bot send a message across shard?
I have tried, but either it does not find the user or it sends the same message the number of shards.
client.cluster.broadcastEval(async (c, { userid }) => {
let user = await c.users.fetch(userid)
if (user) {
user.send({ content: "hi" })
}
}, { context: { userid } })
:^)²
Now can you tell me what each of those mean :^)
why not use objects tho
to make it 1:1 with the C api
ok that makes sense yeah
this is the C api
yes, the C docs tell you to create an array of size 50, but only returns 30 values
the other 20 are used for temp values and shit
ty, will do
is it possible to make a function in ejs and then run that function from a <script>?
for example;
<%
function log(){
console.log("Hello World!")
}
%>
<script>
(somehow import the function)
log()
</script>
you have to write the function as a string to the html body
what you have inside <% %> runs on your server, what you have outside runs on the user's browser
i see
if you want to run the function in the user's browser, you need to write the full function text so its included in the html that the user downloads
im not sure that will work
this function cannot access your server data from the browser
is there a way to loop a ejs function?
to do what?
i tired setInterval(function, 1000); but nothing
like,
function log(){
console.log("Hello World")
}
setInterval(log, 1000);
but in ejs
where?
cuz i tired that but it didnt work
in your server or in the user's browser?
server? im assuming?
only if you do it outside the renderer
F
you need to think of ejs as an html builder
ohh ok
the entire ejs code will be processed only once in order to create an html file, that is then sent to the user
everything you do inside the ejs file its just used to help build the resulting html, it does not have any kind of persisting connection to the user's browser, nor does it have any long running process
ok
if i did
function log(){
console.log("Hello World!")
}
setInterval(log, 1000);
res.sendFile("./path")
})```
would that keep logging Hello World?
yes, plus once more for every access
if you access that page 10x, it will be logging 10 times per second
would it stop once the page is closed?
no
How to crush a server 101
*crash maybe IDK
if i tell you what im trying to do maybe you could come up with an idea what to do as i have no clue?
im guessing you're trying to detect how long a user stays on the page?
no, its to do with a music bot lol
do explain then
so there is gonna be a page that you can control the bot from, im trying to make it so that the page displays the current song playing
i have done this:
let q = client.distube.getQueue(req.params.id) || "none"
and then imported it so it can be used with ejs
if you just want to press buttons and control the bot, you can do that with regular http/ajax requests
if you want the page to auto-update the bot information, then there are 2 ways you can do that: execute ajax requests from the browser in an interval, aka polling, or create a websocket connection
im trying to make the bot auto-updated the info
the easiest way would be with polling, the most efficient way would be with websockets
i already have all of the user auth and stuff, that wouldnt be affected by websockets would it?
with polling you would do something like this js // server app.get("/botstatus/:id", (req, res) => { const queue = client.distube.getQueue(req.params.id); res.send({ nowplaying: queue }); }); ```html
<!-- browser -->
<script>
setInterval(() => {
fetch("mywebsite.com/botstatus/" + serverID).then(x => x.json()).then(result => {
console.log(result);
})
}, 1000);
</script>
with websockets its a bit more complex, you need to create a websocket connection between the browser and your server, so that the server can keep feeding information to the browser while it stays on the page
the downside is that this method is slower/less efficient, since you need to keep sending requests every second, if you have hundreds of people with the bot page open, you will be sending hundreds of requests per second to your server
👍
/botstatus gives the error: TypeError: Converting circular structure to JSON when something is playing
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });
.
.
.
client.on('guildMemberAdd', (member) => {
const channelId = 'MYID'; // The Channel ID you just copied
const welcomeMessage = `Hey <@${member.id}>! Welcome to my server!`;
member.guild.channels.fetch(channelId).then(channel => {
channel.send(welcomeMessage)
});
});
i used this for welcome but it doesnt work
and what's wrong ?
Like any bug or something
It doesnt work
can you try with client.channels.fetch(... ??
instead of member.guild.channels.fetch
how do i log the name of the current song playing
no it doesnt work again
@boreal iron @quartz kindle hello fellow osdevers
im making a graphics driver which supports layers instead of a single flat canvas - the only issues im stuck on is re-rendering specific parts of the real display
say you have 3 layers which overlap
and you removed the first one (one behind all overs)
what would you rerender lmao
i can check everything pixel by pixel which would probably be okay for a two layers but multiple?
worst case scenario i'll rerender the whole display 💀
all 800x600 pixels worth
actually its a lot more confusing than that considering a layer can have transparent colours too
i can also keep track of all objects (such as lines and rectangles) coordinates which will allow specific re-rendering but if you're drawing individual pixels thats gonna get expensive
How do I fix my css skill issue? I just suck at css and want to get better at it.
practice more
You can start at here. https://www.freecodecamp.org/learn/responsive-web-design/basic-css/change-the-color-of-text
Use
member.guild.channels.cache.get()
Instead of
member.guild.channels.fetch()
I would also recommend to add
if (!channel) return;
Does someone know an open-source self-hosted hosting software? Like a cool software that can do the hosting stuff for you on your own server? That would actually be awesome 😅
yeah its called pterodactyl 💀
well but that's for gaming servers...
not really
its mostly general purpose
but it is quite restricted yeah
honestly you could make something like that yourself
setup docker and use a driver to spin up a docker instance "aka creating a server" and then give the IP and setup the SSH to that server
that all can be done automatically with a dockerfile
its also funner since you make it yourself:)
tim is an osdever
i call people osdevers who help me with my os 😳
still stuck on the design issue tho
what issue?
implementing a graphical driver with layers supported
im stuck on the part where you re-render things
when for example a layer is hidden
or a rectangle is drawn or cleared from the layer
it would be expensive to redraw everything
can't u save the previous frame and compare with the new?
especially since i have no GPU acceleration since that shit is literally closed source in manufacturer drivers
like, only render the differences
opengl?
question is finding those differences
let me draw something
do u have a pixel matrix or something like that?
yeah theres a "visual layer" which contains everything shown on the screen since reading from video memory is extremely expensive
then theres additional layer buffers which hold all pixel data for each layer
each layer holds 800x600 32 bit ints
ok, the first thing you could do is check differences between row sizes
like, the row storage size
when u change a value in some index it'll affect the total size of the array
unless the language ur using pre-allocates the whole range
when u find a mismatch between 2 rows just iterate over it checking each entry
each buffer is preallocated with all values set to 0 (black)
say each colour is a different layer
how would you find out what to redraw when for example layer 2 (blue) is removed?
my initial idea was storing each drawing operating (e.g. draw rectangle) as an object which holds an index + coordinates
actually that doesnt really help lmao
use a zIndex to define what gets drawn on top
whatever is below doesn't need to be drawn
the layers are basically a zindex
pixels I mean, not the actual windows
maybe instead of layers i should make everything an object you can adjust the location and index of
anyone in here know html that could help me. my site is acting up but i cant find whats wrong/know whats wrong
just state the issue
also, can't u do a sequential modification of the to-render matrix?
i click on a menu option and it just adds the previon page onto the new page
...what?
like, what's the expected result VS the current result?
oh wait
I get it
it supposed to me /updates but its /updates/commands
show how ur redirecting
the code I mean
ok hold on
<li class="sd-tab-item" ><a href="commands"><div class="">Commands</div></a></li>
oh so it should be commands.html?
...no, that'd be ever wronger
you need to use actual paths
idk if ../ is a thing in html
in the worst case just use the full path
update: yes, you can use ../
it means "go up one level"
use /droxz.com/commands
but I must ask, is that droxz.com really necessary?
ok
this is my testing domain so it just has a bunch of pages like droxzlinks/droxz.bot, droxzlinks/api, ect
yeah but thats expensive considering theres multiple layers
like, just jump to the first index of the next layer
instead of iterating non-relevant pixel
for (int y = Math.max(0, window.y); y < window.y + window.height && y < screen.height; y++) {
for (int x = Math.max(0, window.x); x < window.x + window.width && x < screen.width; x++) {
pixel[y][x] = ...; // set the pixel
}
}
like this
(don't mind my long condition)
idk what's ur structure
layer would be the window
hmm, bad variable name maybe
x/y would be the leftmost top pixel
by layer i mean it has its own canvas which is the size of the display but at the end its all squashed together into one depending on their index
ik ik
there, renamed it
you'd iterate over the windows in crescent order according to their z index
you can even check if the resulting pixel would be the same color as the current and skip that index
that way you save on meaningless array ops
i did it but it doesnt make any change
you could also have a buffer matrix to flat all the pixels before transferring to the render matrix
they are all already flat because it would be expensive flatting everything out
that's called a guard, it'll stop the processing if channel is undefined or null
i dont think i understand you though
i mean all of this changes
yes
3 layers each holding a single rectangle right?
yes
like, instead of iterating the whole 800x600 screen, you only iterate on where pixels exist
do you have any soultion for this ?
so let's say you have a tiny 50x50 rectangle, you'd only iterate over the space that rectangle occupies instead of the entire screen
solution for what?
what he suggested is changing cache.get to fetch
which will fetch the channel instead of relying on the cache
^ this
it doesnt send welcome message
ok, any error in the log?
nothing
show the code
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });
.... my code ...
client.on('guildMemberAdd', (member) => {
const channelId = '958031024569323550'; // The Channel ID you just copied
const welcomeMessage = `Hey <@${member.id}>! Welcome to my server!`;
member.guild.channels.cache.get(channelId).then(channel => {
channel.send(welcomeMessage)
if (!channel) return;
});
});
right i see, but another issue what if layer 3 is completely a single colour (e.g. whole screen reg) but layers 1 and 2 have something else such as rectangles
idk how you're not getting errors
im using discord js v13.6
you could have a 3d matrix
(a cube in this case?)
check for the rightmost entry that's not 0
draw that one
ignore everything to the left
this way you'd have only 1 op per pixel, and would only draw what's on top
are you sure you're not getting ANY error?
because that code shouldn't even run
no error
.cache.get(channelId) is getting the channel from the cache
it's not guaranteed to exist
.then after it only makes it worse, because it doesn't return a promise
do what he said
i did it
^
@lyric mountain let me debug with console.log(member);
const channel = member.guild.channels.cache.get(channelId);
if (!channel) return;
channel.send(welcomeMessage);
like this
there is nothing on console
it's meaningless to have a guard on the last line
even if i only draw the pixels that have a significance its still quite a lot of interactions going down the layers (unless i spend more memory in each layer containing another canvas which contains the data of layers 1 and 2 as if layer 3 didnt exist so it can be easily restored without iterating down the layers
memory writes arent that expensive its the reads which really kill performance
speaking in terms of clock cycles
hm, I can't think of anything then
yeah its really tricky
im seriously considering just having a bunch of objects with a single canvas with just some x indexes
so if you made a rectangle its an actual object and its x and y coordinates are stored
so the relevant pixels can later be rerendered from all objects
that's probably the best option
and the arrays can be sorted based on their indexes so it doesnt have to perform uneccessary slow checks
although heavier
i think its actually better than the layers approach
instead of thinking about huge canvases you think about smaller objects
if you wanted a window for example you just make an object that fills the entire screen
use a treeset instead
faster than sorting the array each time
also you could technically split the job across multiple threads
like cut the screen into a 4x4 grid
const collector = await message.channel.awaitMessages({ filter: msg => msg?.content, time: 260 * 1000, errors: ["time"] })
.then(async collected => {
console.log("yes");
})
.catch(collected => console.log(`After a minute, only ${collected.size} out of 4 voted.`));
``` For some reason, nothing passes the filter and I have no idea why. I debugged the filter and it worked, but didn't fire the collected event.
Anybody know why?
it's probably something to do with the fact that you're doing await message.channel.awaitMessages() and using a .then() callback afterwards
Maybe. I'll try removing the await. Thanks.
Didn't work 😢
are you getting errors?
If I'm writing to a file, how do I check if it's still writing? I'm dealing with writing to large files, but am not sure how I can check if a stream is being written to:
let stream = file.createReadStream();
let dest = fs.createWriteStream(join(__dirname, "../../../web_server/videos/" + name + "/") + file.name);
stream.pipe(dest);
Nope.
try not using a filter and see if you get your desired result
I don't know if filter is required, I'd assume not though
I tried that lol
can't you do fs.writeFile() and that returns a promise?
Didn't work.
Filter is required I believe. This is how I handle it:
const filter = (async (i) => {
return await i.deferReply() || true;
});
message.awaitMessageComponent({ filter, componentType: "SELECT_MENU" }).then(async (interaction) => {
});
I have a filter lmao.
Ah true. Thank you. mb
^
Ah ic. mb didnt see
not sure then, might be related to intents of some sort ¯_(ツ)_/¯
I though of that. However, I pushed it aside since I have no idea which intent it would be.
btw I'd like to mention how all the rest of the commands with awaitMessages work just fine
like what..?
are you doing it the same exact way?
// I mean, it works I guess
public static double FindAndInvoke(string funcName, params double[] operands)
{
var (method, argLength) = FindFunction(funcName);
if (method is null)
{
throw new FunctionNotFoundException($"Function '{funcName}' does not exist.");
}
if (operands.Length != argLength && argLength is not null)
{
throw new ArgumentException(
$"Method '{funcName}' takes {argLength} arguments, not {operands.Length}.");
}
if (argLength is null)
{
return (double) method.Invoke(null, new object[] { operands });
}
return (double) method.Invoke(null, operands.Select(x => (object) x).ToArray());
}
private static (MethodInfo?, int?) FindFunction(string funcName)
{
foreach (var method in methods)
{
var attrs = Attribute.GetCustomAttributes(method);
if (attrs[0] is FunctionName && ((FunctionName)attrs[0]).Name.Equals(funcName))
{
return (method, ((FunctionName)attrs[0]).ArgumentLength);
}
}
return (null, 0);
}
``` I wonder if this is a valid use for tuples, these two functions are probably garbage in the first place though
Await isn't the error, then is
You see, then is a step of the promise chain
The last then defines what gets output from it
Since you're doing console.log, which is a void function, you get nothing
C# is so fckin similar to java I'd comment on it but saw foreach
Also does it really enforce newline brackets or is it a myth?
doesn't enforce, just auto formats it
I'll format the formatter
fn() {
}
fn()
{
}
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
Should I ever code in c#, I'll make sure to override any kind of formatter so it ends with inline brackets
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
inline brackets resistance
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
Brehhhh
you tried to send a message to a channel that your bot cant see, that was deleted, or that is from a guild your bot is not in
Outstanding brackets are a crime against humanity
how do I make bot show activity showing how many members is inside the server
uh what
wasn't sharding is needed when bot is inside 100+ server or something, I'm just testing old project.
Yes
But shards can have unique activities
Which is what you'd need to show per-server member count
But you can't since too many shards would make it impossible for you to start the bot
is it different with overall member count or same
your bot cannot have a different activity without sharding
You can't have an accurate member count
Not without sacrificing more ram than humanly purchaseable
I use this but it only show 1 member which I assume is the bot itself, but it shows correct server number
var activities = [ `${bot.guilds.cache.size} servers`, `${bot.users.cache.size} users!` ], i = 0;
noted
Second, you need to have member intent
It's important that you read this carefully
Cache is supposed to have only commonly acessed data

