#development
1 messages · Page 1993 of 1
if you want to use InteractionServer, yes you need an https domain
i mean, makes sense tbf if its all webhook based
you can still use the websocket for testing for example, before moving to https
but for a rest client and others it'd be fine to dev on local?
ye
so lets say i wrote all my interactions and such with an interaction server.. thats not technically a bot is it? like, do i still need some kind of bot account type thing running somewhere for users to add to their guild etc?
its an application
you can invite it like a regular bot
but if you dont give it the bot scope, it probably wont show in the member list, etc
but it will show in the guild's applications
ahhhh ok
i believe they already fixed the online issue
even if you dont have the bot scope, it should still show online
I think I'm gonna have to make some time at the weekend to try out this lib
its just such a different way of writing a bot than im used to 😄
so the interaction server only receives interactions right? like, i know thats a dumb question. but im wondering about other events like guildCreate etc, how might those get handled?
or would you also run an 'internal sharder/rest client' alongside the interaction server to handle other events?
yes, if you want to receive other events, you will have to run a websocket alongside
although at that point you dont really need the interaction server anymore, just use the websocket for both
yea, I think I'm just gonna have to mess around with it and see how I get on 😄
speaking of the rest client, thanks @quartz kindle
Its so much easier and faster to figure out how everything works looking at your code.
had to redo a lot because of cloudflare workers, but still saved a ton of time.
yw xd
sad times that I had to add this rule to my server 💩
nobody else experienced this issue on coding servers?
Isn't that a bit excessive
regularly, but blocking permissions isn't the answer imo
used to just use a tag that would paste a message like that
pastebin
Automatic code snippet detection that deletes the user’s message and sends either a pastebin of it or a formatted code block

that's...know what that aint a bad idea at all
just need to check what the user sent
if it's indeed code or unsolicited dikpik
OCR
i do
I'm hoping that even those who haven't bothered to read the rules will find a way to share their code that doesn't involve an image, if we take that function away from drive by spoon feed wannabes
lol
it's basically a treesort
you can distinguish those who code and those who have no idea what they're doing by how they show their code
good luck doing ocr on those blurry angled images with uneven shadows and cut off text
like those stock "hacker" images
yup
yup
uwu
I have this NextJS code here:
const getLocalStorage = () => {
if (typeof window !== 'undefined')
return JSON.parse(localStorage.getItem('localStorage'))
};
And the problem is, that in NextJS after loading the page, this function only works once because window isn't undefined anymore and otherwise I get the error window is not defined. How can I get localStorage data even after rendering in NextJS?
wdym it only works once? window doesnt get undefined again
when does window become undefined again?
I mean like when I render the site it gets the data and after that I can't get localStorage anymore...
does anyone know how to modify the volume of an opus stream without the use of ffmpeg
I doubt a human would be able to understand it much less a computer
use Angular, pls
you're disgusting
Usually you should use useEffect for running code only on the client side
useEffect(() => {
// Code here...
}, []);
I don't think that's possible without FFMPEG, I've tried it before myself, but to no avail
des but I can‘t call a function that‘s inside useEffect right? Like I need to get localStprage data on button click whenever the user clicks it
If you want that then just pass a callback to the button?
<button onClick={() => {
// Access localStorage here
}}>
</button>
and you can do whatever you want in useEffect\
I found a lib that changes the audio of pcm, but the problem then becomes converting an unknown stream type to pcm and then transform and then convert to opus
Flashbacks of pain of working with opus streams
by the time I do this, the computation cost might be more than just using FFMPEG
working on my lavalink rewrite trying to avoid usage of ffmpeg, but I guess there's no avoiding it
Perhaps
there is always an alternative and everything is possible
just harder :^)
if you're gonna use ffmpeg in node anyway, you might wanna try using a native addon version, instead of the usual command line version
wait that really works? with that you can easily access localstorage etc.? All the time?
is there a specific addon I should use for audio processing
Looks like a nice language
https://discordjs.guide/interactions/slash-commands.html#options it's on a different endpoint
Tldr skill issue
petition to add a trollface emoji to this server so us non-nitro users can use it
spotify_result = next((activity for activity in user.activities if isinstance(activity, discord.Spotify)), None)```
ah
i used their search
why is that returning none even tho im listening to music
who in their right mind designed a language and decided "yeah, that looks like good syntax tbh"
python hurts me
await interaction.guild.bans.create(user, { reason: `[${interaction.member.username}#${interaction.member.discriminator}] `+reason })```
what be this
GuildMember does not have a username and discriminator property iirc
Use interaction.member.user or interaction.user
no py devs here 😦
wdym im py dev
@dry imp i needed help with this
Well the code you showed doesn't actually show you constructing and sending the embed.
nah that embed isn't mine
its from another bot just logging the ban
i cba to load up audit logs 
Ah, then it's probably what Debert said
yep fixed it
its interaction.member.user.username and interaction.member.user.discriminator

Error: ENOENT: no such file or directory, open './databases/944252016685887579.json'```
So i am creating json files for each guild id, while my bot is deployed to heroku.
Is that why the json files are not actually being made?
as heroku blocks it?
heroku doesn't allow you to create files like that iirc
That's fucked up. Thanks tho waff
They practically purge your file structure regularly.
So trying to host a database inside your project is not feasible.
Instead, you have to use Heroku's provided database(s) to do so.
Don't know how you'd set it up though since I don't use Heroku
not really. What's fucked up is using json as a database 😛
and heroku in general
json databases rock
but not as much as rocksdb
This project is not mine, it's a stupid school project so i really didn't give a fuck about using fancy databases and hosts
we don't talk about rocksdb
they literally have rock in their name, you cant outrock that
also yet another stupid api wrapper question: how do I change the response I get from an api into an object of a class type? I normally just model the responses with interfaces, but that seems too raw since I have no methods and such
the rock is not a database
well, do you actually want to wrap the object into a class?
or only "type" it as a class?
wrap it into a class
the rock can be anything
unless that's a stupid idea..?
just create the class and assign the params
Alright
I figured that was the way to do it but I didn't know if there was some magic that I was supposed to use instead
well
in js you could do this
class A {
constructor(obj) {
Object.assign(this, obj);
}
}
but idk if ts will allow that
ts wants to know everything statically, meaning you have to type the whole thing in
surely there's an easier way
if I use interfaces then I sacrifice the luxury of methods and props wrapped into a single class
I could do something like ```ts
export class Perf {
games: number;
rating: number;
rd: number;
prog: number;
prov: boolean;
constructor(data: PerfData) {
this.games = data.games;
this.rating = data.rating;
this.rd = data.rd;
this.prog = data.prog;
this.prov = data.prov;
}
}
interface PerfData {
games: number;
rating: number;
rd: number;
prog: number;
prov: boolean;
}
pretty sure you can do data: Perf
my bots taking years to load when using my actual bot token
when i use my test bot token it loads in seconds

its only in 345 servers
345 is more than 1
running locally or in a server?
server
how long is "years"?
5+ mins compared to 10 seconds
ok thats not normal
yep
discord.js
client.on("debug", function(info){
console.log(`debug -> ${info}`);
});```
that i'm guessing
yeah
honestly i never used it 
yep it worked
it was an issue with presence intent
👍
app.post("/dblwebhook", webhook.listener(vote=> {
const votesusers = vote.user
console.log(votesusers)
let channel = client.channels.cache.find(channel => channel.id === '949100386759893042')
const upvotes = new MessageEmbed()
.setTitle('Upvote Status')
.addField(`Log of Upvotes Status`, `${votesusers}`)
.setColor('RANDOM')
.setTimestamp()
channel.send({embeds: [upvotes]})
}))``` why its not sending the embed? on this code line ```js
const webhook = new Topgg.Webhook(topgg)``` what webhook should i put? The webhook in discord or in the top.gg?
Neither, you should put your secret that you set in top.gg page
There's a webhook in the servers discord, and top.gg
i just wondering if what webhook should i put in the code
where in the code?
izza secret
there is no where in the code to put any webhook
A webhook is just a reverse api
Instead of you calling the service the service calls you
old me: omg lets use json!1!!!!! https://capy-cdn.xyz/QmS8fi8z.png
oh yes, lets store ids as numbers and watch them become all invalid as soon as the file is loaded
:^)

you mean this? Topgg.Webhook("your webhook auth")
thats the secret / password / auth / whatever that you get in your bot's top.gg edit page
brah chill we got prayer after i sent the link
yea
why its not sending :/
what did you put in your top.gg settings?
in the bot's edit page
in the webhook part
import json
new = { }
with open("warningchannels.json", "r") as file:
warningChannels = json.load(file)
for channel in warningChannels:
print(channel)
new[channel] = {"guild":channel, "channel":warningChannels[channel]}
with open("new.json", "w") as f:
json.dump(new, f, indent=4)
print(new)```
how can i make it store like json { { "guild":"000000000000000", "channel":"000000000000000" } }
in the webhook URL?
in both url and auth
yes its wrong
what should i put?
where is your bot hosted?
In my main server
{ { } } is not valid json, do you mean [ { } ]?
no, your hosting service, where is your bot running
mongo stores like that
ah heroku
and I need to quickly move it to mongo 
{ id: { } } is valid, { { } } is not
then its YOURPROJECTNAME.herokuapp.com/dblwebhook
and you need to have a web dyno enabled
ohhhh
do modal forms support autocomplete?
i pushed wait
after pushing the webhook
i got this error
2022-03-04T02:29:38.565331+00:00 app[worker.1]: node:events:498
2022-03-04T02:29:38.565345+00:00 app[worker.1]: throw er; // Unhandled 'error' event
2022-03-04T02:29:38.565346+00:00 app[worker.1]: ^
2022-03-04T02:29:38.565346+00:00 app[worker.1]:
2022-03-04T02:29:38.565346+00:00 app[worker.1]: Error: listen EACCES: permission denied 0.0.0.0:80```
port 80 is locked
you need to use the port that heroku gives you
i believe its port 3000
What should i put in .env.PORT?
the webhook?
Nope
You need to out exactly like it's written in that picture
Heroku is the one assigning what port you'll use
3000 in that example is for local tests
Is there a way to find out a specific shard’s ram usage
I saw this one bot do it on its dashboard
Don’t remember whats it called
after i changed the app.listen there's no error at all but there's still no send message in my server
or is it bec theres no new upvotes for my bot?
Well, yeah you'll only receive events when they happen
ok ok thanks!
Does anyone have any idea why this is sending the query parameters incorrectly? ```ts
async execute(): Promise<T> {
const res = await Axios.get<T>(this._endpoint, { headers: this.parseHeaders(), params: this.parseParams() });
console.log(res);
return res.data;
}
// ...
private parseHeaders() {
let obj: Record<string, any> = {};
for (const [key, value] of this._headers) {
obj[key] = value;
}
return obj;
}
private parseParams() {
let obj: Record<string, any> = {};
for (const [key, value] of this._parameters) {
obj[key] = value;
}
return obj;
}
``` For some reason the parameters are being sent like '/api/users/status?ids[]=jwaffled&withGameIds[]=false' when it should be sent as '/api/users/status?ids=jwaffled&withGameIds=false'
oh wait nevermind I know what's wrong
accidentally was making the map's value a string array instead of joining them with a comma
So I want some advice on how I should go about calculating the prices of items my rpg bot will have. The price should be affected by how rare it is, but I also had the idea of giving items a base price that people can sell for, or auctioning the items off/selling em for a price of their own
how would i get this to send a random file from the folder? this is what i tried and it does not work var memes = ["mail1.jpeg", "1.jpeg", "4.png"]; var meme = Math.floor(Math.random() * memes.length); var colors = ["#0099ff", "", ""]; const embedmeme = new MessageEmbed(); embedmeme.setColor("#" + randomColor) embedmeme.setTitle(memes[meme]) embedmeme.setImage('./images/' + memes[meme]) await interaction.reply({ embeds: [ embedmeme ] });
I dont think you can set files as images with setImage
I think you gotta use attachments
Don't quote me on that tho but iirc that was a problem
You must attach the file using the files option of the <CommandInteraction>.reply() method and give it a name through the name option and the path to the attachment through the attachment option, and set the image to the embed using the <MessageEmbed>.setImage() method by providing the name to the attachment after attachment://, for example:
const embed = new MessageEmbed()
.setImage('attachment://some-image.png');
await interaction.reply({
files: [{
name: 'some-image.png',
attachment: './images/some-image.png'
}],
embeds: [embed]
});
i think,they need to use fs. cause they are getting them from a file/folder
am rn on school bus atm so i cant send the code
oh yeah i forgor about it
You should give the items a base price of choice, to calculate them you should give every rarity a percentage of how rare they really are and divide it with the base price, the lesser the outcome, the higher the actual price
Hm
So if an item was listed as 1000 but it has a 20% drop rate it would be worth 5000 in the end?
Perhaps
How should I calculate probability tho
I plan on having crates people can find that gives em a random item
and the crates themselves will also have rarities :^)
You can kind of apply the same idea to it, with the magical Math.random() method
hm
finally a usable format of creating rest requests ```ts
async getRealTimeStatus(withGameIds: boolean, ...userIds: string[]) {
let gameIds = 'false';
if (withGameIds) {
gameIds = 'true';
}
return new RequestBuilder<ResponseTypes.RealTimeStatus>(
this._accessToken,
Endpoints.UserEndpoints.GET_REALTIME_STATUS,
)
.setParameterArr('ids', userIds)
.setParameters('withGameIds', gameIds)
.execute()
.catch(err => this.handleError(err));
}
(don't judge the boolean thing)
Judging hard
typescript is on crack or something, it didn't let me toString the boolean
since when could you ever toString a boolean
Damn ig you can
that dont makesense tho ngl
nah
I'll just do String(withGameIds)
why would you ever toStrting a bool
just because it's not a very useful method explicitly doesn't mean it's there for no reason
a lot of things use it internally
would this work? embedmeme.setImage('attachment://' + memes[meme]); await interaction.reply({ files: [{ name: 'some-image.png', attachment: './images/' + memes[meme]}], embeds: [ embedmeme ] });
can't you read the file with fs and pass the buffer as attachment?
this is what it does
pssss if it was detritus i might be able to help
if it was in python im able to help
const img = new Discord.MessageAttachment('./some-image.png', "some-image.png");
embed.setImage("attachment://some-image.png");
interaction.reply({ files: [img], embeds: [embed] });
Hi
so i assigned two events to elements like this, but however
only mouseenter was captured
if i remove element.onmouseenter, then it starts picking up mouseleave
but if i set two events together, only mouseenter is fired
idk what is causing the issue, can you help?
I tried the exact same thing, @civic scroll. However, I can not replicate this issue...
const leaveEvent = () => {
console.log("leave")
element.removeEventListener("mouseleave", leaveEvent)
}
const enterEvent = () => {
console.log("enter")
element.addEventListener("mouseleave", leaveEvent)
}
element.addEventListener("mouseenter", enterEvent)```
How can i make the avatar to circle, after putting the beginPath() the avatar and fillText gone
or i should put in ctx.arc(x, y, Math.PI * 2, true);
confused
???? you're using angular?
bro.. this isn't how you use angular
if you're using a js framework you never call querySelector, addEventListener, etc
except for some specific edge cases which I don't think is the case here
i had to
since those elements are dynamically created and appended in innerHTML
the data get being fed to HoverService which get mouseenter, mouseleave, location
again, dynamically
created element
i can't even pinpoint exact position
that's fine
since each text being fed in is different
that's why you have props
so i can't put the thing in HTML
sure you can
gimme a moment
are you only displaying one optional thing at a time?
all
is it a dynamic amount
yes
look at interpolate methods and you will get what i mean
oh man...
i legit couldn't use component for this case
why not do something like
<div *ngFor="let notification of notifications">
<your-component
[x]="notification.x"
[y]="notification.y"
></your-component>
</div>
Then have your component just position itself
then the tags can't be put between the text
and i can't pick up events if i don't specify listeners, which brings me back to original problem
imagine if it's something like
"Attack Interval <@ba.vdown>increases</>, ATK <@ba.vup>+{atk:0%}</>, attacks deal <@ba.vup>Arts damage</> to at most <@ba.vup>{attack@max_target}</> enemies and have <@ba.vup>{attack@buff_prob:0%}</> chance to <$ba.stun>Stun</> the hit targets for <@ba.vup>{attack@stun}</> seconds\n<@ba.rem>Liskarm is <$ba.stun>Stunned</> for {stun} seconds after the skill duration</>"
so you have a list of things like
[regular text here] [special text @listeners] [more regular text] [some other special thing]
?
yes
vanilla api is enough
i just can't get it to fire the event
anything but mouseleave fires
so you might need something a little bit more sophisticated. You can have an array like
type Field = TextField | InterpolatedField
const fields: Field[] = [{
type: "text",
text: "Attack Interval"
}, {
type: "interpolated",
onClick: someFunction,
text: "increases"
}, {
// ...
}]
and you render them in a for loop + ngIf
might be an issue for nested tags
maybe you're removing the element before mouseleave can fire?
no
the element is there
when i let only mouseleave it fires normally
but not when i added in other events
btw you don't need const refThis = this; if you just use arrow functions
the this in function is referring to the element itself
yes because function() {} creates its own this context, () => {} doesn't
and refThis so i can use services in the class
yes because i need to access the element
for its coordinates and dimensions
I would cry if I had to maintain a codebase like this though you're really shooting yourself in the foot here
it was simple me like
if mouse enter, get location, display on that location
if mouse leaves, hide the popup
that... all it is
i just couldn't get that one event to fire for some reasons
can someone give me some tips with this?
try replacing mouseleave with mouseout maybe
clip path image before putting text
fair, doesn't really fix anything in this situation
i don't know what is blocking it from firing
dude idk like you've really resorted to black magic here
ctx.beginPath();
ctx.arc(x, y, Math.PI * 2, true);
ctx.closePath();
ctx.drawImage(pfp, x, y)
ctx.clip();``` like this?
ye
it's probably an issue with you trying to jam non-angular inside an angular codebase and the events not working as expected
tho idk enough about angular to know why it'd be like that
image remain the same
draw img before begin path
ctx.drawImage(pfp, x, y)
ctx.beginPath();
ctx.arc(x, y, Math.PI * 2, true);
ctx.closePath();
ctx.clip();
still same
:((
actually i will use a tree instead
i will try
.addField('Team 1 - TOP', 'x', true) // TOP
.addField('Team 1 - JGL', 'x', false) //JGL
.addField('Team 1 - MID', 'x', false) //MID
.addField('Team 1 - ADC', 'x', false) // ADC
.addField('Team 1 - SUP', 'x', false) // SUP
.addField('Team 2 - TOP', 'x', true)
.addField('Team 2 - JGL', 'x' , false)
.addField('Team 2 - MID', 'x', false)
.addField('Team 2 - ADC', 'x', false)
.addField('Team 2 - SUP', 'x', false)```
why is my bot not making both TOP fields next to each other and the rest of the fields under the TOP fields?
So i would have something like: TOP 1 Top2
The rest The rest
probably because you go inline: true once and then every elese false for the most part
Discord doesn’t support tables as you would like to display it
Ah really', that's sad. Is there no other way to display it in like a table?
owh fuck
markdown table time 😉
Only reliable thing is to work with code block
But that however will be fucked on mobile
In that case, is there any way to tab out an addField?
addField()
space
addField()
you can use a zero width space as a blank character
Sure with line breaks in your value using unicode chars
ah okii let me try
Symbol: , Name of the character: zero width space, Unicode number for the sign: U+200B, the icon is included in the block: General Punctuation.
See my linked message
This guy wanted to do nearly the same like you
Just see what I wrote
For example one top list on the left (in code blocks) one right
Totally agree, dunno why that’s not a thing in discord (at least in embeds)
Probably because of the horrible scaling on mobile
_time to sleep _
that's a single text block 🤨
yeah it's the same concept. you're essentially creating an html tree but instead of rendering the html into a string you're only storing the tree data structure and then serializing into the html with angular's templating
should be exactly the same concept
yep
i will try it out later
this is where data structures comes in handy in the frontend
it's not all just css 😛
i got in css jail
for a reason 💀
but still if the event listener works then that would be more straightforward
it's not straightforward lol it's just more convenient considering you already started working on it
it's sunk cost
or at least feels that way to you
that part is maintainable since there is no collision and they are unique
maintainable 
it is
smon trust me for once 
i might cringe at my decision 2 years later
but for now it's feasible
it's just so elegant to solve it the correct way
but
but
alright i will try come up with a struct and ask you later
but still idk why the mouse event
<a class="navbar-brand" href="index.html"><img src="img/pws.png" alt="logo" style="top: 5px; left: -6px"/></a>```I tried this before
negative left and top, respectively
didn't really do anything at all
oh no
don't use absolute position
<nav style="display: flex; justify-content: space-between; align-items: center">
<img />
<your-buttons-component />
</nav>
Why not if i may ask?
because that's not what absolute positioning is for
css is like building legos
you put legos on top of each other pretty much
I recommend learning about the box model, flexbox and grid
ah okay, thank you! Will have a better look at css
layouts in css are just rectangles inside other rectangles
Does snyone know how can I setup a github workflow to upload compiled ts code to a different branch after an edit has been made in the main branch?
oh, yeah I forgor top/left only work in absolute
was supposed to mention margins
gh actions for you
how? no idea, but it's kinda like docker or something
yes I'm asking about setting up an action for that
I know it can be (and should be) done... but i have no idea how
why do you want compiled code in version control?
maybe to be able to just clone without compiling or whatever, idk
poor man's non-cross-platform container
for sure
almost* anything you can do manually can be done through code
- except client-side stuff like interactions
so interaction.id wouldnt work?
it would too
what I mean is that you can't interact with interactions through code
like using slash commands or clicking buttons
uhm, if i click a button on a message, how do i make it log the id of the message with the button?
print message.id
cause i tried to log interaction.id in the button event
ah
interaction.id is the interaction's id
Can you make a slash command with many string options, but out of those options, you have to provide one? Not a particular one, just one
you mean like optionchoice?
no i don't mean choices, I mean string options that the user can provide a string for
you mean variable signatures, no that's a thing I wish they added
ohh, okay. I wish too... I think it's possible to kinda get this feature with subcommand groups tho
but its not the same and would be a lot better with options natively supporting that
yeah you have to make do with subcommands
we can only dream of proper mutable signatures
and datepicker and array options
damn I forgot about those
TypeError: Cannot read properties of undefined (reading 'id')
may it be because i call it before sending the message?
my bot keep going offline because it keeps running this command npm ci and it's getting annoying
TypeError: Cannot read properties of undefined (reading 'id')
at Object.execute (/home/runner/Disbank-API/commands/blackjack.js:101:52)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Client.<anonymous> (/home/runner/Disbank-API/index.js:43:13)
/home/runner/Disbank-API/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:90
if (this.deferred || this.replied) throw new Error('INTERACTION_ALREADY_REPLIED');
line 101 is: messageID: interaction.message.id
what do you want to do with the message id?
save it
can smbdy tell me, how to find following in js
(3 ** 4 ** 5) % (1e9 + 7)

Use smaller numbers duh
you sure you don't want ((3 ** 4) ** 5) % (1e9 + 7)?
wth is **
Power
exponential
oh
No
It’s evaluated the same way either way though isn’t it? Or is exponential precedence different than left to right
without parenthesis, 4 ** 5 is evaluated first
where's Tim
I know PEMDAS I just didn’t know that exponents were evaluated right to left instead of left to right when chained together
a to power b to power c, so its makes sense to find b ** c first.
that's cuz exponents modify their base, not the final result
so it's not really right to left, but top to down
hmm, correct
anyone know of a js module that will let u run a web server without any extra routes or anything? like a normal web server
like express?
yeah but without any extra routes or anything just like a normal web server that lets u view it’s directories and reads .htaccess let’s u view all the images, json files in that directory etc
idk if that’s even possible
no it's not
a webserver without routes isn't a webserver
you can do what u want with nginx or any webserver really
hmm alright, i was really hoping to be able to run a website on pterodactyl that’s why i was wondering
idk what pterodactyl is, but simply setup a webserver for the site
it's not the hardest thing
alrighty thanks
@quaint rampart you can try making one yourself
It is easy and requires little skill
Can be done via express
that's...that's what i just said
yeah ik i started working on it cuz of what u said
how did they manage that this time?
Use * for the route and scan dir each time for the required path
Math.pow or ** ?
both
Mhmm
exponentiation is an expensive operation in general
even in other langs
for example python:
depending on the situation, it will be much faster to use a multiply loop instead of powers
this includes groovy startup time, compilation, execution and return
without startup time
now lemme do it 100k times
idk what to say
it gets lower every time I run again
yea v8 is a beast
nice eval command
it's just a simple output really, if you're talking abt the syntax that's groovy
it highly depends on the situation, since some things are optimizable others are less optimizable, if youre just gonna run the same numbers in a loop, it will probably be compiled to give the end result directly and skip the entire computation
im not entirely sure how to return something in mine lmao
but in some of my projects i got a significant performance boost from removing them
and i cant use async or i dont get an output :(
ye, for pre-defined values it barely computes anything
What lang?
meths again?
I imagine if the value is well defined before the loop it just consider the first value for everything else
groovy
Js or what?
GROOVY
Ok
lol
Nvm I'm dumb

Weird
is topgg completelly fucked up today?
mayb
If I take something bigger it will be Infinity
easier way to go to infinity is just any ** 10 ** 100
or any / 0 (depending on lang)
why doesnt this work even tho im listening to music
is the api broken or something ?
it prints this
do u have the presence intent?
uh no
enable it on both sides then
whats that.. im making a bot after like 2 years
n in different lang
by different i meant i used to code in js first
a couple years ago discord added privileged intents
how do i enable em ?
i have all that enabled
is there anything i need to do with code ?
now enable in the code
also, make sure your lib is updated
otherwise it wont have them
its latest i think
intents = discord.Intents(messages=True, guilds=True)``` so something like that ?
since when..?
bot = commands.AutoShardedBot(PrefixGetter(config.get('core').get('prefix')), intents=discord.Intents(messages=True, guilds=True, presences=True)) ion this this works i still dont get anything back
idk then
there are forks of it probably
or just use another language
i was finally started to like python 😦
meh
Pycord and next cord are the two most popular
I've heard of pycord, none of the rest.
when choosing a library I like to check the source code and if its still maintained.
To my knowledge
thats what im doing i just looked at the last updated time
pycord seems to be most starred out of all of em
does this mean file is too big? ```Uncaught DiscordAPIError: Request entity too large
No debugger available, can not send 'variables'
Process exited with code 1
how big is it? limit is 8MB
Unfortunately no library wants to admit what they're not good at
So it's hard to pick
so according to you what is pycord not good at ?
you have to test them, stuff like how much memory they use at login, etc
Imo that should be the responsibility of the library dev, assuming they care about marketing to devs
It's hard to do that on your own since you practically need to learn all five and choose
good to know size was 30mb lol
yeah thats just too much work just pick the most starred one lol
but its the responsibility of bot devs deciding which tool is the best for the job
is rest cord a good idea ?
plus isnt it easier to make dashboard using restcord cuz php is like a web client ish im not sure
it doesn't really matter
The library dev can at least guide the developer. If I have a choice between Discord.JS, Eris, Ditritus, etc. I'd at least like to know what problem library X solves that libraries Y and Z don't or did not at its time.
checkout discord.js-light to see an example
for now its cyberpunk time 😎
lmao
yes they can help, by providing good descriptions, docs and benchmarks whenever possible
but still, the dev needs to test their particular use case and make their own decision in the end
Yeah I don't disagree that a dev should still make their own decisions
I just think that library devs should do more to express what their library is good and not good for, which can be highlighted through methods like you just said.
discord.js memory usage is a vizualised skill issue
Discord.JS is more of a convenience/abstraction library
It is modular, but not enough for most people
Modular, not modular, doesn't really matter for memory usage
For the average bot in 1-500 servers, memory usage is not very important.
Especially with intents, people favor the convenience over the memory usage cost
it does lol, especially if the cache is configurable
hell you can get modular cache by either allowing no caching, internal or external
but thats too advanced for people making libs to get popular tbh
a non-modular lib can still have a configurable cache
this
the thing is not exactly being modular or not, its more how much dependent on each other the modules or components are
djs is super dependent on a lot of stuff both internally and across the little modularity it has
as i know pycord, nextcord is forked off discord.py sooo
idk
They obviously hate you too 
Isn't pycord a fork too
I noticed 
POOF GONE
What's a floating ip
and so we were like oh that's strange and added it back
but DO didn't change our default gateway after it was added
i said its forked off discord.py aswell
so we spent like 1.5 hours trying to figure out wtf the issue could be because it didn't occur to me that DO's feature just straight up wouldn't work
time to change providers 
so I ended up fixing it by manually querying the gateway and changing it for each node
I hate my life
fuck DO
why not switch
^
lol
its known iirc
it's just the load balancer
ah
yteah
yeah
also wouldn't someone accessing the site from the ip bypass cf ddos protection
ig you could simply block if the origin isn't cloudflare
yes
yeah thats not the best
surprised they dont just filter all cloudflares ip
bearing in mind top.gg gets ddossed every so often
How do I do a reload command in djs
delete require.cache[require.resolve(filepath)];
setImmediate(() => require(filepath));
You have to destroy ticking timers and remove events from event emitters and remove external references if you're gonna do that. I wrote a module called heatsync which does the brute of the work
some weird quirks is if you want to make things hot reloadable is you need to export an Object and then on file change, delete all old props and then assign new props from updated reference to the old Object
how does rate limits work for editing interaction responses?
ie, is it the same as normal message editing, or does it remove the limit like responding to an interaction?
afaik it’s normal message editing
But I could be wrong
Might be worth just testing it
Hey! Whenever i reply to an interaction and i want to get the interaction.message.id, i get this error:
TypeError: Cannot read properties of undefined (reading 'id')
Then you don’t have the message object attached to the interaction
...
Or interaction isn’t what you think it is
I don’t know how djs works internally for this, but you may have to fetch the message
like i reply to an interaction, in the same code i try to save the message id after sending it.
Oh wait, interaction.message isn’t even a thing
then how does this log the message id in the button event?
Because that’s not the same object. https://discord.js.org/#/docs/discord.js/stable/class/MessageComponentInteraction
If you want to save the message ID of the reply, you need to fetch the message object - within the reply options
See this:
Aha… I mean that’s not the ID of the reply but okay
ik, didnt need it for anything else than matching it with another id
🤷
(0.47246).toString()
Works or nah?
Why would it not?
Wanted to confirm
Also you can easily test this yourself if you really wanted to know :p
Thanks bud
for most things like that you can stick it into any browsers console
f12 console tab
https://i.imgur.com/KmBF98V.png
That too
I do it a few times a day just to double check what I'm doing lmao
chavs start a node instance in the terminal to test

Chads build their own nodejs interpreter to test
superior beings build their own OS just to test something
Gigachads make their own universe from scratch to test something
big bun uses preexisting libs for features that are dogshit!
Sounds like a good idea
Lets see if I will get in trouble for taking over the world and making null the supreme leader
(development debate time) serious talk the sanctions from companies such as "facebook is banned in russia" is stupid because it don't affect the people in charge at all only the residents
I mean, people in charge do use social media as well
so in a way it does affect them
but it does also largely affect the people who don't even want to be part of the war
Same thing is happening with their economy
The people are suffering cause of what their leader is doing.
Banning social media ironically makes it harder for the truth to get out about the war as opposed to Russian sponsored propaganda
they didnt ban facebook
well
russia did
facebook banned all russia media outlets
I know google banned some of their services in russia iirc
especially their ad services
the intent is to strain russia of resources
sanctions are always felt most by the people than the targets
@split hazel it affects their economy, also its not just facebook
Spotify blocked all news sources
Shell and BP started pulling billion$ investments
Ford suspended all operations in russia
General Motors halting all exports to russia
Boeing said Tuesday that it would suspend support for Russian airlines
Apple has stopped selling its products in Russia
Facebook block access to Russian news outlets RT and Sputunk across europe
Twitter has similarly announced plans to "reduce the visibility and amplification" of Russian state media content.
Netflix refusing to air Russian state TV channels in the russia (required by russian law starting this week)
Spotify has closed its office in Russia "indefinitely" and restricted shows "owned and operated by Russian state-affiliated media."
Roku (streaming service) blocked russian news outlet RT
YouTube, which is owned by Google, said over the weekend it had blocked Russian state media within Ukraine, including RT
- Will also be limiting recommendations of these channels
Airbnb's suspend all operations in Russia and Belarus
Intel has stopped all shipments of its products to Russia and Belarus
Microsoft is suspending all new sales of its products and services in Russia
BP said Sunday it was planning to exit its 19.75% stake in Russia's biggest oil company, Rosneft, and their joint ventures
Equinor will also begin to exit its joint ventures in Russia
Exxon planned to leave its last remaining oil-and-gas project in Russia and not to invest in new developments
Shell is also getting out of Russia and ditching its joint ventures with Gazprom, including its involvement with the moribund Nord Stream 2 natural gas pipeline.
Mastercard has blocked multiple russian financial institutions
DirecTV is cutting ties with RT, the Russia-backed television network
Disney is also suspending the release of its theatrical films in Russia
H&M paused all sales in Russia
Ikea the world's largest furniture company, is closing its 17 stores in Russia
jeez
basically every western company you can name has limited or stopped doing business in russia in fear of violating sanctions
except coke maybe
I wish it would be banned in the EU, too
Why my upvote api still not working :/
const Topgg = require('@top-gg/sdk')
const express = require('express')
const app = express()
const webhook = new Topgg.Webhook(webs)
app.post("/dblwebhook", webhook.listener(vote => {
const votesusers = vote.user
let channel = client.channels.cache.find(channel => channel.id === '949100386759893042')
const upvotes = new MessageEmbed()
.setTitle('Upvote Status')
.addField(`Log of Upvotes Status`, `${votesusers}`)
.setColor('RANDOM')
.setTimestamp()
channel.send({embeds: [upvotes]})
console.log(votesusers)
}))
app.listen(process.env.PORT || 3000)```
not sending on channel even in console.log
Do you even receive votes?
Is your topgg token accurate?
Btw, you don’t need to use .find, you can just .get() with the id of the channel
and vote.user actually provides the user ID?
Make sure your channel ID is right then
Maybe log your var channel
Hi Guys i want to know which one would you rather ? a Big Schema for each guild that saves all data of that guild in one schema or different schema for each thing for example 1 schema for prefix 1 schema for each system and 1 schema for each log ?
A single schema would be better instead of multiple, since having a lot of schemas can lead to inflation of the database and a lot of memory being used as there will be more data to deal with
well a single schema doesnt make the bot slower?
Cause for example maybe just 5 server have kicklog so if there is only one schema for kick it will check between 5 data but if i save everything in 1 schema it will be more than 5 data cause maybe each server use just one option of bot so bot should check many more data and in each one check for data.kicklog
srry for bad english
It would be lethal to store all of that data in separate schemas, as it would just produce way more documents than a single schema would, managing fewer documents is better rather than many, and single schemas would be way faster than many schemas for single data
so you suggest me to use 1 schema for all of them
also have you work with mongoose cause i have few question
I mostly use the official MongoDB driver called mongodb which is used in Mongoose, but I know much about it, go ahead
I'd argue that it depends on what you want to do. Having multiple entries and drawing relationships between them is popular with SQL and relational databases, but since you're using MongoDB, that isn't as easy to pull off nor as beneficial. Since all you're really storing are constants that make sense on that specific guild, it's fine to use one large schema, but would suggest you at least use collections for duplicate keys like this:
Like, you could easily abstract all the XChannelID: String into their own separate documents and store it under your schema.
now i have multi schema and in channel delete event if someone delete a channel that saved in my data base i will remove that data cause it doesnt exist anymore but now if i try to use 1 schema for that i cant delete the data so i need to update it but what should i do for that update it to what ??
for example in my schema i have KickLogChannelID so if someone delete one channel that has same id with KickLogChannelID i should update GuildSchema but update it to what ?
null ?
Just delete it, query the channel with that ID and delete it from the schema since it no longer exists
delete what ?
The data for that channel saved in that schema since that channel no longer existed as you said that you listen to the channel delete event to delete it, there's no need to update it when the actual channel no longer exists
<MongooseSchema>.deleteOne({ id: <Channel ID> });
no i cant delete the data
maybe a server have for example kicklog and banlog
if they delete kick log channel
and i delete the data
the banlog will disable too
im talking about this style
Oh that's what you mean, for that you can just update the data, not delete the document, and it'll be just fine
You update it to a default value, such as null
i cant do this
jesus
well if i update it to null
this should become false cause data.kicklog is null ?
if (data && data.kicklog) {
// log
}
or i need to check it in some other way
That check should work
and my last question
for example if in my schema i define it like this:
KicksChannelID: { type: String, default: null },
which one should i use for update ?
let newData = await GuildModel.findOneAndUpdate({ KicksChannelID: null })
let newData = await GuildModel.findOneAndUpdate({ KicksChannelID: default })
newData.save()
default is a keyword, you can pass that in like that, you need to know what the default value is and pass that in
well can i just use the null one?
Yes
tnx alot <3
how can i set button url
discord.js
const row = new MessageActionRow()
.addComponents(
new MessageButton()
.setCustomId('primary')
.setLabel('View Documentation')
.setStyle('LINK')
.setUrl("https://docs.blacklister.xyz"),
);```
doesn't work
2|index | TypeError: (intermediate value).setCustomId(...).setLabel(...).setStyle(...).setUrl is not a function
2|index | at Object.execute (/root/bots/blacklister/slashcommands/apikey.js:27:25)
2|index | at processTicksAndRejections (node:internal/process/task_queues:96:5)
2|index | at async Client.<anonymous> (/root/bots/blacklister/bot.js:146:9)```
MessageButton.prototype.setURL() (https://discord.js.org/#/docs/discord.js/stable/class/MessageButton?scrollTo=setURL)
ah
also ig u cant have CustomId for Link style (not sure)
Wouldn’t make sense anyways as it doesn’t trigger an event
also which one is better set null by default for each one or just set the type ?
Default as null is good option in this case
okay tnx <3
tnx
oh god i need to change everywhere 😢
that's a party
wdym ?
synonym for "that sounds painful"
oh yeah 😅
ig i need to debug for 1 week...
and there is a harder way after do the code stuff...
i need to change the data base manually and import channels from different schemas to main schema for each server
i find smoething !!
the else part is fine but in first if statement (data && data.TotalVotes) ig i do a little wrong i want to change the data but now i see that i just findOneAndUpdate it and maybe the finded one is different with data so how can i update the data ?
i want when someone vote
if they voted before (there is a data) made data.TotalVotes +1 and if tehre isnt create one
findoneandupdate({GuildID: yes}, {$inc:{TotalVotes: 1}})
what is $inc ?
this is how i do the topgg api vote log right?
const Topgg = require('@top-gg/sdk')
const express = require('express')
const app = express()
const webhook = new Topgg.Webhook(webs)
app.post("/dblwebhook", webhook.listener(vote => {
try {
const votesusers = vote.user
let channel = client.channels.cache.get(channel => channel.id === '949100386759893042')
const upvotes = new MessageEmbed()
.setTitle('Upvote Status')
.addField(`Log of Upvotes Status`, `${votesusers}`)
.setColor('RANDOM')
.setTimestamp()
channel.send({embeds: [upvotes]})
console.log(votesusers)
} catch (err) {
console.log(err)
}
}))```
in my config
```js
{
"webs" : "http://project.herokuapp.com/dblwebhook"
}``` am i missing something?
I feel like your url is most definitely not project.herokuapp.com/dblwebhook
wdym?
That feels like a not specific domain at all
if i get this Application error then its not?
its right :/
oh wait
i got error
at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=project.herokuapp.com request_id=882d2826-d567-45a6-8206-4a00483627de fwd="203.177.43.166" dyno= connect= service= status=503 bytes= protocol=http```
at=error code=H14 desc="No web processes running" method=GET path="/dblwebhook" host=project.herokuapp.com request_id=da7429f2-8f2e-48bc-b037-cbc3cfbe71f5 fwd="203.177.43.166" dyno= connect= service= status=503 bytes= protocol=http```
Like I said :p
^
do you have a webdyno enabled?
this is the web dyno right?
yeah, the web dyno needs to be on to receive a webhook.
not the worker?
the worker can also be on, but youll probably need to modify your code to use both.
is there a documents for that? got confused after i got interested with topgg api
lmao
documents for what? how dynos work?
This page isn’t working
domain.xyz redirected you too many times.
smh how do i fix it
looks like the site is in a redirect loop.
the fix kind of depends on the cause, where are your redirects?
just goes to an index page. It is a react site
it used to work for a while, just started getting this error
I'm learning how to use modules, but when passing a parameter for require I get the error that require(...) isn't a function.
["loadEvents", "functions"].forEach(Boolean).forEach(h => {
require(`./handlers/${h}.js`)(client)
});
require(`./handlers/${h}.js`)(client)
^
TypeError: require(...) is not a function
maybe try https://wheregoes.com/
Have you ever wondered: Where does this link go? The URL redirect checker follows the path of the URL. It will show you the full redirection path of URLs,
Hmm, it says I have a loop.
I don't know why this is so sudden.
I also don't know how to fix it
is ./handlers/${h}.js exporting a function
a ton of things can cause redirect loops, I would start by looking at every redirect(only look at the pages its actually redirecting to)
Yes.
module.exports = client => {
// smth w/ client
};
waiit nvm. one of the files doesnt have module.exports
yep it works now. whoops
Anyone know what language this is in?
"title" : "{{Title}}",
"author" : {
"name" : "{{Author}}"},
"description" : "{{Content}}"}
] }```
I want to add color and a footer
yes
Alright, any documentation for the embed?
For discord embeds?
With JSON, yes
Yeah discord only accepts embeds in json afaik
{
"embeds": [
{
"title": "{{Title}}",
"author": {
"name": "{{Author}}"
},
"description": "{{Content}}"
}
]
}
formatted if you care
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
^ embed docs
djs has an embed builder but that converts to json anyway i think
Yeah it does
You have my attention. Where can I find it?
do you have the djs package
Neg, only Python
It's probably easier to just use json anyway
I can download the Js stuff needed
yse
I know, but idk where to add the footer
Like the order(json doesnt care about order, only structure)? Or like, in what way?
The discord docs cover it pretty well, I linked to them earlier.
It's ok
If they covered it well, there would be visual references as well
It's pretty uncommon for docs to do that.
Typically only beginner libraries do that
I’d say it’s really clear
oh god
It’s just showing the json structure, you don’t really need a visual representation
If you are confused on how json works I can find a source.
Nvm, I found some more examples of what I'm looking for
which do you all prefer
"variable": "value"
variable: "value"
"Variable":"value" is more correct iirc.
i like the 2nd
i always forget the quotes
im used to doing '/" when making strings so it throws me off :/
First one is proper json structure, 2nd one is usually used for props in an interface or something like that
First one also has the advantage of being able to be anything that's representable with a string
ye
If I have a variable in a JS file and I want to change it, get the variable, etc. Would this woork?
file1.js
// Define the variable.
var someArray = [];
// Export the variable.
module.exports.arrayReference = someArray;
file2.js
const file1 = require("file1.js");
// some variable idk
let myString = "sup";
for (var i = 0; i < file1.arrayReference.length; i++) {
// do smth with the array
file1.arrayReference.push(myString);
}
// log it or whatever
console.log(file1.arrayReference[0]);
Never, ever even think of the word "var"
Use let
mb. it was just an example haha. but yea i got u
Abt the variable thing, u can just export it
That's how u make global value files





