#development
1 messages · Page 2021 of 1
Yes
ty
const db = require('quick.db');
module.exports = {
name: "warn",
description: "Use this to warn an user",
usage: ">warn <Mention User> <Reason>",
run: async (client, message, args) => {
if (!message.member.hasPermission("MANAGE_MESSAGES")) {
return message.channel.send("You don't have permission to use this command")
.setTitle("Only Moderator+ Commands")
message.channel.send(embed);
return;
}
let Member = message.mentions.members.first() || message.guild.members.cache.get(``)
let member = message.mentions.users.first()
if(!member) {
message.channel.send("Please mention a user with reason")
return;
}
if(member.id === message.author.id) {
message.channel.send("You cannot warn yourself.")
return;
}
if(member.id == client.user.id) {
message.channel.send("You cannot warn me")
return;
}
if(message.member.roles.highest.position < Member.roles.highest.peermission) {
message.channel.send("This user is above you, so you cannot warn them noob.")
}
let Reason = args.slice(1).join(" ");
client.db.add(`Warnings_${message.guild.id}_${member.id}`, 1)
let Warnings = client.db.get(`Warnings_${message.guild.id}_${member.id}`)
const embed = new Discord.MessageEmbed()
.setColor(`#FF0000`)
.setTitle(`${member.username} has been warned!`)
.setDescription(`**Reason:**
> ${Reason || "No Reason provided"}`)
.setFooter(`They now have ${Warnings} warnings`)
message.channel.send(embed)
member.send(`You have been warned in ${message.guild.name}. Reason: ${Reason}`)
member.send(embed)
//DM's the user that they have been warned
}
}
please use hatebin.com
Trying to ask a dev that use v12
Don't use v12
Why are you still using v12?
I use discord.js v12 as u can see but I try adding
message.guild.member.id but when I do I can't warn with id and I'm having trouble
nope, it isn't
Personally
it's outdated, and will shoot you in the back
Even if it's better for you personally, doesn't really make it better in reality, v12 will stop working soon entirely
I mean my bot still working and run like a champ with v13
V13*
V12*
But if I'm force to move v13 I will
But this free website that let me code and much easier support v12
it's better to migrate slowly while you can than wait for it to force u to change
it's a matter of spending 1 hour over 10 days or spend 10 hours over 1 day
I mean I am learning from @fringe jewel and she use v12
also you might also switch to another discord bot lib
...you're missing the point entirely
Okay yeah I get it
because well the d.js v14 changes are just ridicilous
looking at d.js I'm happy JDA isn't as volatile as it
Oh, I haven't seen the changes, can you tell me what is changing?
But if I use v13 I will have to change everything in the coding and it gonna be fucking hard since I'm a beginner at coding bots
not to say all the QoL stuff they remove just because people were misusing it
Thank you!
you see, coding using an outdated library is like a snowball
Throwing snowballs during summer
you go, and go, and go.
when u note you have 1m lines to change because you left it for later
if you're a beginner perfect! you'll have less trouble migrating to new version
If you are just learning you kind of have an advantage learning the newer version anyway.
But there is better tutorial on v13 then v12 right? I heard v12 never really had tutorial
"tutorial" is subjective
if you mean videos depends, it's a real bad source of tutorials
the library documentation is there tho, as well as google
there's no better tutorial than documentation + google
Just look at the guide, it should tell you how to migrate from v12 to v13
Not tutorial my bad, for example I said I need help figuring out the code so that people can use id to warn members
well, that's up to you to write
you're not supposed to grab pre-made code around the net
A big thank you!
But how else I'm I going to learn the code?
by thinking
documentation will tell you what tools you have
you'll be the one baking the cake
if you want I can give you some courses and guide links on JS
If you can that would be great
Ty
Tysm
do note, none of those are about making bots, but about learning node.js
which is what you'll be using for bots
once you have the base, anything else is pretty easy to get the hang of
yw

discord.js moment
they named a class in full caps?
RichEmbed > EmbedBuilder
isn't it just called Embed now
Embed would be the resulting object no?
It's EmbedBuilder now
Also
huh, weird
thought they moved to builders package for embed builder
discord.js has always been like this, with every new update you have to rewrite your bot
v11 to v12 to v13 to v14 lmao
Then don’t use the useless builder tools
^
Most of the changes are the builders, which you really don't need
v11 was a really good version
v12 was annoying with these cache everywhere
v13 is ok, no real breaking change
v14 is bad
V12 was an easy update though
All the updates are pretty simple to upgrade from
But annoying
That’s why god made search and replace all
Yeah
Is annoying really a good answer to breaking change
Best vscode feature
If an update is annoying but provides you with much more functionality, is it really fair to dismiss it as "annoying"?
Raw api moment

discord.js v11 lmao
it just works, everything is stable and uses the raw v10 api without any abstractions
I'm surprised v11 works still
I agree that these changes provide some good functionality but is modifying everything a good solution?
will be unavailable soon

in jda they mark the feature as obsolete and for-removal
but only remove 2 or 3 versions later
discord.js team loves changing things for no reason and without warnings
The only reason it works as well as I have it is I've updated some abstractions and gutted the back end gateway and rest internally and switched to cloudstorm and snowtransfer
nice
Is that always possible when swapping api versions?
If it is I imagine it takes some extra work to keep it functional.
most of the shitty changes are done by the community
No, I think breaking changes should be discouraged. But I also think people complain about the less impactful ways discord causes breaking changes
don't bother
managed libs 🤮
i never inspected it soo ¯_(ツ)_/¯
they most of the time try to make it as functional as possible so you don't need to insta-change when upgrading
Yeah Discord with their intents
but it gets like minimal life support
Interactions are a great feature but the message intent isn't necessary
^^
Message intent is great imo
nah
No
they never inspect shit before does it really need it or actively inspect
it's an underwear with a hole
the reason for it to exist is to protect user privacy
but they don't enforce it below 100 servers
so it's useless
spam/scam bots are always short-lived bots
Most bot invites are above 100 servers anyway
there's a reason why they pushed back the deadline to October (was it October or September, idr)
they're trying to make users switch, while polishing the interactions system
clearly end of April isn't enough
I'm still happy with the idea of it.
In the future I probably won't invite any bots that have the intent.
I doubt the next deadline will be enough, too
regarding what I mentioned earlier
Hopefully they make that visible to users
the crossed method is marked as obsolete, they don't just remove it from night to day
In other words, deprecated
I don't think so
ye
Or they can add a new scope like "receive messages" that you can disable if you want
Discord plans and plans and plans, never works out well, plan on making slash-commands and interactions from the very start of Discord, implement it 6 years later, delay important features and mark a deadline earlier than you can ever implement and stabilize your APIs and features, mark a date to decommission older API versions and keep post-poning them and all that crazy stuff
Classic Discord™️, and then there's the discord.js™️, trying to be as "consistent" as possible 

that's like asking hellen keller to write a book
I don't know who hellen keller is
the only thing consistent is that it eats memory like it's Minecraft Java

a guy mentioned he was following your tutorial, nothing big
I didn't make a tutorial..
I'm just teaching him how to use discord.js v12...
And when I finally get used to v13 I'll teach em that.
but kk
const { Client, Message } = require("discord.js")
module.exports.config = {
name: "clean",
group: 'fun',
description: 'Clean recent bot messages',
permissions: ['MANAGE_MESSAGES'],
botperms: ['MANAGE_MESSAGES'],
usage: '.clean [amount]',
example: '.clean 5'
}
/**
*
* @param {Client} client
* @param {Message} message
* @param {*} args
*/
module.exports.run = async(client, message, args) => {
let amount = args[0];
if (!amount) return message.channel.send({ embeds: [ client.main ] });
if (isNaN(amount)) return message.channel.send({ embeds: [ client.amountNum ] });
if (amount > 100) amount = 99
let collection = await message.channel.messages.fetch({
limit: amount
})
const filter = collection.filter(m => m.author.id === client.user.id);
message.channel.bulkDelete({ embeds: [ filter ] });
}```
What's the issue?
What does the { embeds: [ filter ] } means?
The bulkDelete() method doesn't take an object with the embeds property
You are confusing me
You filter by messages in the channel and then pass IDs to bulkDelete that match a predicate
VIP vc regions?
VIP regions were deprecated. They're now just 320kbps
I saw that they have been removed from new versions of the Discord api
they used to belong to guilds with the PARTNERED feature
ic, just now I noticed those enums exist (or used to)
weird that they exist considering my PR to document voice regions got closed immediately
https://github.com/discord/discord-api-docs/pull/4773
Got removed in djs 14
no, just make your own as an individual 🙃
plus alternatives exist
tfw vip regions got removed
How can I remove unnecessary dots in a string? Ex.
h.e.l.lo
The tricky thing is that if this is in a huge block of text like this:
h.e.l.lo! I do stuff. Sometimes. Not really...
I can't just replace . since that would become:
hello! I do stuff Sometimes Not really
I tried this:
for (let i = 0; i < text.split(" ").length; i++) {
if (text.split(" ")[i].includes(".") && !text.split(" ")[i].endsWith(".")) {
text.split(" ")[i] = text.split(" ")[i].replace(".", "");
}
}
But that didn't seem to work for some reason. text is the string provided.
you can't really, not without sacrificing the ... case
separate by spaces to get words, count numer of dots in word and number of sequential dots in word, replace if more that 1 dot in word that is not sequential
You could use regex, but that wouldn't really be accurate either, such as
text.replace(/(\w)\.(\w)/g, '$1$2');
Tim has the biggest brain
or if dot is surrounded by non dot and non space
Ah I see. But would that work for words like i.ex.i.s.t compared to i.e.x.i.s.t?
text.replace(/[^ .]?\.[^ .]?/g, "$1$2");
Thanks! I"ll try this and Voltrex's method rq
Yeah it seems to only work 70% of the time, but thank you anyways
wait is that a website for regex?
I'll try that
I recommend https://regex101.com/ more rather

tysm i rlly need that haha
ill use that. tysm for your help
takes too long to update
It doesn't for me
A regex I made is this (\w)\.(?! |\.+$)
It matches if there is a character and then a . and there is not a space after it or if it doesn't have multiple .'s and is at the end of the string
the capture group is the character, so you can replace with $1
why negative lookahead for single-char?
Negative lookahead is more appropriate for this situation and more accurate
Thank you! Testing right now and it seems to work really well.
\.[^\s.] ignores if a dot is followed by a space-like char or a dot
you should be checking if its at the end of the string though
Then the +$ can be replaced with {2,3}
Yours didn't match that last .
because it shows only 1 match
That's actually pretty smart

put ... inside the text
Yes. I understand if the ... isn't at the end of the string, it will get replaced
currently trying to figure out a solution
as I understand, regex doesn't overlap capture groups
that's why it didn't capture before
I'm unsure why you would need to check if it's at the end, removing the $ just works fine
ye, this one works fine
people can throw in 3 .'s in between 2 chars and it breaks
well, the rule states multiple .'s should be ignored

ye, both suffer from that
It doesn't, it works the exact way they wanted it to
I still think my version is the most logically correct
I meant this
I think it's better for it to just ignore the amount of dots in-between, it it can also just replace them if wanted
Instead of \., it can just be \.+
yours doesn't allow in-text triple dots
I'm working on it
that removes 3... at the end of the string
You also missed the $ in the regex
That would make it replace all ...s, time to find a solution to make it work with both™️
true™️
this one also doesn't remove triple dots at the end
Does it allow 3 dots in the string at the end of a word
who the fuck types like that anyway wtf
I did it
do share
see after "was a pig"
I love how impossible to read regexes are, but they just work
kekw
having a highlighting does help
ah yes, forgot about the client
Now guess what time it is, regex speedtest time
how?
I'm already testing them no need
voooolt
KuuHaKu's regex: 9.243ms
My regex: 8.461ms
source: trust me
In 99,999 iterations
my source is I made it the fuck up
Alright here's the regex (\w)\.+((?! |\.+))(?!$)
This is how I tested them
const text = 'H.e.l.l.o! I do stuff. Not really... wtf...t...f h...m...';
const regex = /* your regex */;
console.time();
for (let i = 0; i < 99_999; i++) regex.test(text);
console.timeEnd();
welp, indeed

new v of discord.js is already out?
Nope
I was scaried about some messages that I've seen in this chat
should be
as always with new djs versions
Haha, it's because the v14 is available as a "dev" version
when is v14 expected to be properly released?
why is it saying "top.gg token missing"?
well ik why but I did put the token correctly
if you put it correctly there should not be an error 
only the dev version
https://www.npmjs.com/package/discord.js/v/14.0.0-dev.1649505803-3c0bbac
see at: https://www.npmjs.com/package/discord.js/
=> Versions
/workspace/node_modules/discord.js/src/client/Client.js:548
throw new TypeError('CLIENT_MISSING_INTENTS');
^
TypeError [CLIENT_MISSING_INTENTS]: Valid intents must be provided for the Client.
at Client._validateOptions (/workspace/node_modules/discord.js/src/client/Client.js:548:13)
at new Client (/workspace/node_modules/discord.js/src/client/Client.js:76:10)
at Object.<anonymous> (/workspace/trophylets.js:3:16)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/workspace/prefix_commands/useful/leaderboard.js:4:33) {
[Symbol(code)]: 'CLIENT_MISSING_INTENTS'
}
Did you import intents from djs?
import?
I'm passing
const timeZone = result.language === 'pt-br' ? 'America/Sao_Paulo' : 'America/New_York'
const date = moment(dateRecive).tz(timeZone)
but if i pass a date, like my bot's uptime, it returns me a wrong date

const { Intents } = require…
Yeah exactly
same error
If you're using discord.js, the <Client>.uptime property returns a number in milliseconds since the client emitted the ready event, not a date
how can i turn <Client>.uptime (milliseconds) into a date?
Just show a few lines more
Which are before the error and belong to it
new Date(/* milliseconds */)
ok
same thing
Is this v13?
Then either the timezone passed is invalid or it's correct but it seems incorrect, also I recommend using something else rather than https://npmjs.com/package/moment since it's discontinued and no longer maintained, the updates are mostly security patches
Do you have any tip?
Doesn’t have the native date class some methods to adjust the time offset for another timezone in JS?
yes
I will use the Data class itself
You can just do
const covertedTz = new Date(
new Date(client.uptime)
.toLocaleString('en-US', { timeZone: ... })
);
Use the constructor to create a date based of a timestamp or string, than convert it to your timezone
yes yes...
hei hei, have someone an bot suggestion for bot message auto delete?
ik Dyno have auto prune but we wanna an bot with auto delete function for bot messages/embeds, it can be an bot with premium option
I just updated something in Schema (mongoose/mongodb), but it didn't change anything 
nice
you need to edit the saved data
need to edit this and schema

mongodb doesnt change them automatically
this is not the only one...
ohno
I don't want to do it manually 💀
can someone please help 
How can i get the biography of an user ( djs )
Not possible?
not yet
You mean the "about me" section of a user?
Yea
They're not exposed to the API, so not possible
They probably will be exposed later on but may not be
Check back when they add pronouns to user profiles. They might start including that data into the User payload since having to fetch /users/{user.id}/profile for each new user in chat would be stupid (assuming they show pronouns in chat ui)
https://www.reddit.com/r/discordapp/comments/txx31k/discord_is_adding_a_separate_pronouns_field_for/
4,611 votes and 849 comments so far on Reddit
what
const data = await schema.findOne({guildId: guild});
data.antispam = { config: [], check: data.antispam }
await data.save()
}```
If the db can handle the volume and is close or on the same machine as the bot, you can use Promise.all instead since waiting for everything to finish before moving to the next operation will take forever
ah yes
I'm trying to add images https://imgur.com/smP4VCE and https://imgur.com/FPhzNRm to my server's top.gg page long description, but I'm slightly unsure as to how exactly to do it since I think I'm inputing the format incorreclty as the images don't actually show up. I've never used html formatting so I'm kinda clueless in this field 
both are wrong
imgur image urls start with i.imgur
copy the image url, not the page url
it didn't change anything?
yes I am sure
They don’t.
A valid img url ends with an image file type
Those are the preview links
if u GET the imgur url u get the page itself, while the i.imgur returns the image
it's a trick most sites use, because the end user doesn't really bother to get the direct url, so they can add trackers as much as they want
a
Yeah imagine providing the direct image URL with just the ability to log the request source instead of the entire client
While the direct image url still is one redirection less
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/aiohttp/web_protocol.py", line 314, in data_received
messages, upgraded, tail = self._request_parser.feed_data(data)
File "aiohttp/_http_parser.pyx", line 546, in aiohttp._http_parser.HttpParser.feed_data
aiohttp.http_exceptions.BadStatusLine: 400, message="Bad status line 'invalid HTTP method'"
Error handling request```
what is going on here and how do I fix it
Well you’re obviously using the wrong HTTP method
Figure out which one the endpoint expects then use it
(might be GET POST PATCH etc.)
well
I am using
client.topggpy = topgg.DBLClient(client, dbl_token)
client.topgg_webhook = topgg.WebhookManager(client)
client.topgg_webhook.webserver.router.add_post(path="/dbl", handler=bot_vote_handler)
client.topgg_webhook.run(5000)```
is any of that wrong xd
You should provide details like that before the first one answers 
that would have been smart wouldnt it
I also have the bot_vote_handler is that would help too
Does your error even come from that library?
it literally just spams this in my logs
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/aiohttp/web_protocol.py", line 314, in data_received
messages, upgraded, tail = self._request_parser.feed_data(data)
File "aiohttp/_http_parser.pyx", line 546, in aiohttp._http_parser.HttpParser.feed_data
aiohttp.http_exceptions.BadHttpMessage: 400, message='invalid constant string'
Error handling request```
The webhook listener actually doesn’t do requests
That sounds more like the source
You should begin to handle your promises
To properly catch errors and see where they come from
well I have a on_command_error
but I guess it isnt good enough lol
I have found
@tasks.loop(minutes=30)
async def update_stats():
conn = await client.pool.acquire()
try:
await client.topggpy.post_guild_count()
print(f"Posted server count ({client.topggpy.guild_count})")
except Exception as e:
print(f"Failed to post server count\n{e.__class__.__name__}: {e}")
await conn.close()```
this
thing
this is exactly what they say to put in the docs though
so I got no idea
That shouldn’t be the source as the exception would include the error message you can see
oh shiiiiiit
it did
it posted that literally once
and the other 20 errors are the first one I sent
Hmm just comment the webhook listener out as well as the server count post
To make sure the errors aren’t coming from there
lowkey advert?
the problem is that it happens randomly

so it could take a day or a week to happen


I mean the API recently had issues responding with 4xx and 5xx status codes
You may have encountered that
is there a way to make it not crash my whole bot if it happens lol
so just make a on_error instead of a on_command_error
Well I don’t speak py to help you with that
on_error 💀
But defining a global exception handler shouldn’t be hard to do I guess
god phoenix has some of the best error screens I've ever seen
what is pheonix (link pls)
Phoenix is a web framework for the Elixir programming language that gives you peace of mind from development to production
it's dynamically typed you'll love it
I want a regex that selects all symbols that are not underscore or alphanumeric
So I could replace them with a underscore.
FE, "algae.peach.%285" should be replaced with "algae_peach_285"
I must admit, this is true as shit
Indeed it is!
perhaps you're looking for \W?
what's that, whitespace?
basically I want to convert the string, to be set as a unique username.
I want the username to follow the same convention as variables names in programming
\w would be [a-zA-Z0-9_], but \W would match the opposite of that
oh wow, yes thats what I want
But can I do it so, it select all consecutive symbols, and replace with underscore
like \W+?
incredible, regex is so powerfull
in term of database usage, how do I connect my bot with it if I'm using vps
wich database are you using?
Pls help on this 😮💨
// function
async function cercaCanale(client, id) {
const canale = await client.channels.fetch(id)
return canale
}
//guildMemberAdd
const canale = await cercaCanale(client, cercaServer.channelID)
if (canale == null) return
await canale.send({
embeds: [embed],
files: [attachment],
})
//error
TypeError: canale.send is not a function
at Client.<anonymous> (/root/novabotStable/events/guildMemberAdd.js:76:30)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
hey guys. can someone help me with writing TOS for my discord bot? it's necessary for verification
Mine is a bit over the top, but it's a cover your own ass or else situation
https://github.com/AmandaDiscord/Amanda/blob/rewrite/TERMSOFSERVICE
surely people will read the whole tos 
you are legally allowed to put BS in there and it is other people's fault for not reading
fr 

Not like many people use what I make tho
would be surprised if someone tried to take me to court
thx :) maybe it's a bit late with 97 servers and a limit of 100 without verification :/
anyone can help me with this ?
https://stackoverflow.com/questions/71855807/trying-to-give-role-for-voter-top-gg
i'm trying to give top.gg voters role in my server but there's so many thing happened got me confused and i can't find any solution for it.
full source code : https://sourceb.in/dSlb2nhjPH
here's m...
before the console log i couldnt find the user, add console log error to see what error are you actually facing in
Make sure your firewall/router allows/forwards connections for the selected port
Pls help on this 😮💨
// function
async function cercaCanale(client, id) {
const canale = await client.channels.fetch(id)
return canale
}
//guildMemberAdd
const canale = await cercaCanale(client, cercaServer.channelID)
if (canale == null) return
await canale.send({
embeds: [embed],
files: [attachment],
})
//error
TypeError: canale.send is not a function
at Client.<anonymous> (/root/novabotStable/events/guildMemberAdd.js:76:30)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)```
console log canale
its not about receiving data , it wokrs fine but when the bot try to give the role its shows the user not found :)
console log the error
ight 1 sec
TypeError: Cannot read properties of undefined (reading 'roles')
the error code line
user.roles.add(role).catch(e => { console.log('Something went wrong, i cant add roles') })
You can’t assign roles to an user
But to guild members
I mean ask yourself where is that role going to be added?
You got the role from your guild cache but didn’t assign it to the member in the guild but to a random discord user
Alright
i think this one will work
let guildid= client.guilds.cache.get('928290243843604500')
let role = guildid.roles.cache.get("942061236475002952")
user.roles.add(role).catch(e => { console.log('Something went wrong, i cant add roles') })
right ?
If you wanna assign them to the user in your guild, make sure to check if the user is a member of the guild before
No
guild.members.fetch(user-ID)
If the user exists as guild member then fetch and assign the role
what site I could hire html programmer, fiverr is my last option for it.
unprofessional? fiverr
professional? contact a company
like uh, freelancer
so unprofessional
you can also sniff around sites like mcmarket and ogusers
only need it for a single project.
guess gonna take a look at mcmarket first, thanks for the info.
also does anyone know how to make unreal engine editor not run like shit
I get like 10fps on the preview
Once I tried make my gpu focus on the program and it boost the fps for a few.
though im not rendering anything special
very simple cubes on lowest presets
I swear you need a $3000 gaming rig to run this 💀
production builds run fine tho
worst case scenario I'll go back to unity
that is indeed a worst case scenario 🥲
My PC crashed everytime I open Unity for some reason.
if message.content.startswith('Get message'):
print('\----------', end="\r")
id = message.content.split(',')[1]
print('\\---------', end="\r")
g = await client.fetch_user(str(id))
print('\\\--------', end="\r")
async for message in g.history(limit=None):
print('\\\\-------', end="\r")
if message.attachments:
print('\\\\\------', end="\r")
user = await client.fetch_user("723927865544146954")
print('\\\\\\-----', end="\r")
attachments = message.attachments
print('\\\\\\-----', end="\r")
file = files = None
print('\\\\\\-----', end="\r")
if len(attachments) > 1:
files = attachments
else:
file = attachments[0]
print('\\\\\-----', end="\r")
await channel.send(content=f'{message.content}', file=file, files=files)
whats wrong with this its not working also not giving any error
Well anybody here makes bit in pure node.js?
define "pure node.js"
Like without discord.js and doing coding in js only
but at what point would it stop being "pure" (note that "pure js" isn't equal to "pure node.js")
making a bot without using a library (especially if you're going to interact with the gateway) is just shooting yourself in the foot
My mistake
and you're just gonna end up with a homemade d.js anyway
nah, its more like making your own gun from scratch and then you shoot your own foot
i did
you're an exception
Well I also did but not completely I did make many bots in autocode where djs isn't supported >-<
waitwaitwait
autocode 💀
lmao
in what world would autocode be more pure than djs?
pretty sure autocode uses djs behind the scenes
i mean, most other competitors do/did
hello
why are some functions in js modifies the original value rather than make a copy of it? isnt it just simpler if they all just return a new value?
because it's oop
References
like obj.setSomething(value) is expected to modify the object itself so you can work with states and keep logic inside themselves
there are very few functions that actually modify the object
but they likely do it like that either for peformance reasons or because it makes logical sense
ie array.sort() and array.splice()
there should be an immutable array class which has all the methods Array has but they return a clone instead of mutating it
Array.Prototype.cloneSort = () => { const arr = [...Array]; arr.sort(); return arr; }
how do I fix
#
# Fatal error in , line 0
# Fatal JavaScript invalid size error 169220804
#
#
#
#FailureMessage Object: 000000314EBBE980
1: 00007FF79E4B7B7F v8::internal::CodeObjectRegistry::~CodeObjectRegistry+114079
2: 00007FF79E3D25AF std::basic_ostream<char,std::char_traits<char> >::operator<<+65023
3: 00007FF79F0B2772 V8_Fatal+162
4: 00007FF79EC365C5 v8::internal::FactoryBase<v8::internal::Factory>::NewFixedArray+101
5: 00007FF79EADFB83 v8::internal::FeedbackNexus::ic_state+62771
6: 00007FF79EAF66E0 v8::debug::Script::GetIsolate+15840
7: 00007FF79E96A231 v8::internal::CompilationCache::IsEnabledScriptAndEval+26913
8: 00007FF79EE08F91 v8::internal::SetupIsolateDelegate::SetupHeap+494417
9: 00000206B49899E5
ur trying to create an array with invalid size
what's the max size?
How do I make my app eat more ram?
It is crashing only using 2gb of memory
Array.Prototype.cloneSort = function(...args) { return [...this].sort(...args) }
the size is an unsigned 32 bit integer, which makes the max around 4 billion
why is it not 64 bit integer on 64 bit systems?
because 32bit is faster and uses less memory
why would you need an array with more than 4 billion items?
even if you fill it up with zeroes, it will still use stupid amounts of ram
minimum 4gb multiplied by whatever overhead array items have
If you need something that large I feel like js isn't the language for it anyway.
Sorry this is sort of off-topic to this channel, but how can I download files directly from https://mega.nz? I'm trying to use this library: https://mega.js.org
But I can't seem to download the folder. I've also tried .decrypt (see code below), but that doesn't seem to work either. Most likely because the project is a fork of the original mega package.
let file = await mega.file(url);
let key = file.key;
console.log(file.directory); // true
await mega.decrypt(key).pipe(fs.createWriteStream("../file/" + file.name));
why is your code different from their docs?
did you try following the full docs from here? https://mega.js.org/docs/tutorial/login
To log in to an account use the Storage class:
including logging in using the storage object, then finding the file object from it?
I know I'm moving to v13
But is it even possible to make it when people vote for my bot on top.gg the bot is able to give the member anything
I dont see alot of these bot have this
Okay so it is possible
K thx
I'd say "I don't see alot of these bots NOT have this"
only shit bots have this
and has better compatibility:)
though actually 64-bit modern cpus apparently can process 64 bit integers faster than any other size
such as 16/8/32
because env properties are not known at compile time
therefore they are nullable, aka not guaranteed to exist
so you have to either check for their existence first, or tell typescript that the value is not nullable
btw it works, thx
Umm
What is the standard price for hiring freelancer.
depends on their skill level
I see.
$5
ill just lump that in with my $5 spent
god researching NFC programming is painful... every article I stumble across just tells me to use an app...
Finish my homework for 5$ 😀
@quartz kindle I need ur master astrologician help
how could I get moon phases given a 0-365 day calendar?
is there like a pattern or formula?
use an API ez
depends how accurate you want it to be
there are many premade calendars, you could make it on a calendar basis, or on an orbital basis
for example you can do some math with the moon's orbit and the sun's orbit speeds
If we were to draw a line between the Earth and the Sun, and time the duration the Moon takes to complete this cycle, we'll see that it takes roughly 29 days 12 hours 44 minutes 3 seconds or 29.53058770576 days. This is when the Moon is in the same position relative to the Sun, and so has the same lunar phase. This measure is of the Moon's orbit is known as a synodic month.
pick a starting epoch where the moon had an exact phase, and use those timings to proceed
that would be a fairly simplified but still accurate method (will likely lose some accuracy the further away from the starting epoch it gets)
thx 😘
does anyone want to havea go at making my cs script actually work cause I'm too lazy
;]
How could I make this part of my website better? I feel like the general layout feels too descriptive and not “eye catching”. This is the search results page by the way. I’m trying to play around with different search result layouts and just can’t find a way to make this feel more modernized.
Also I just realized the logo isn’t centered with the page whoops.
everything is off-centered so maybe you should focus on that first
I have a question about buttons.
I'm trying to do a command with buttons that edit an embed.
If I handle the buttons in interactionCreate.js by their customId, how can I edit the embed?
discord.js?
yes
interaction.update()
and how I add a field in the embed?
I would ask for help in a collector to do inside the file, but I dont know if someone has the time to explain how to do it
you dont edit the embed, you replace the embed with a new one
the same as you do in message update
interaction.message should have the original message
the message should have the original embed
you can use it to create a copy of it
then do the changes, and send the new embed
I'm sorry for not getting it, but I'm new with Buttons and also with editing embed, how I get the original one?
In the console.log(interaction.message) I see the embed and it is correct, but how I update it
create a new embed
copy the information from the old embed into it
the MessageEmbed class also allows creating a new embed from an existing embed
new MessageEmbed(oldEmbed)
and oldEmbed in an another file doesnt return undefined?
wdym?
input.value + 1
this no worki
why
should change the number
shit
had to use
Number()
oh god the rightest icon trigger my ocd so bad
Not really a development related question but more so a question about windows. So I am having the issue of windows not recognizing a previously recognizable hdd drive I setup for my pc which has all my projects and other important things that I do need and would like to not lose. I am wondering if anyone can help with this. I have already tried going through device manager and looking at it and it seems that it is registered as an Unknown Device
what kind of disk is it?
Well, if what the question you're asking is what I assume then it is an hdd
internal? external? usb? sata? m2/nvme?
tried unplugging and replugging?
Yep
major sata issue
tried a different sata port?
Tried a different sata cable as well?
Only other port is the port my ssd is connected to which is more important than my hdd
:^)
tried unplugging and replugging the power cable? assuming 3.5 inch disk
I have tried unplugging and plugging the cables back in yes
Have you tried booting without it, shutting back down, and then booting with it plugged in?
I had to do that for my GPU once
Scared the ever living fuck out of me
PC wouldn’t boot (for the first boot I ever did on this one), unseated the GPU and unplugged it, booted without it, shut down, seated and plugged it back in, and then it worked perfectly on the next boot
I turned my pc on one time and heard a loud gunshot noise. turned out a capacitor in the psu had blown. ~ that scared me into tears lol
didn't know this
I just tried with it on and it appeared again
was more tears cause of no pc than noises though 😂
but in the past when it has came back it usually goes away after a while
how old is this drive? it sounds a little temperamental
so the disk worked again?
For now yes
back it all up now
I have another sata cable somewhere
if it disconnects again I will just find it and try it
backup your important projects to some private github repo 🙂
already on it
upload to google drive or mega
idk, it just does 😄
mk
discord minimizes uses an '-'
- is beter imo
yea, seems to be neater, and a more common way to show minimize
ye
idk why bootstraps minimize icon is so low
I’m dealing with an array that has around about 250 objects. Should I just do a simple for loop to find the object I need. Also to find where that object is inside the array, or should I use something else?
use the find method?
array.find(element => element.thing === 5)
or the some method
array.some(element => element.thing === 5)
an array of 250 elements is considered tiny
9874275
classic 32bit limit
i honestly dread to think what kind of data your farming if your array has 4 thousand million elements 😄
discord.js cache
tru

tf does this mean
want to join a big code help server but getting this
because i need some aspiring c developers to help me which i dont think this server has
big code help server probably gonna have less good c devs than in here tbh
I might get automodded for this but I'll give it a shot for you @split hazel
hell yeah I didn't get automodded
nic
yeah if youre a bot dev you get link passes
It says C++ but they do C in there
time to get realmodded :troll:
epic i'll give it a shot
there's also https://discord.gg/vnyVmAE if you find that there's not much help in that server
is there discord.js server? LMFAO
but I can't vouch for the knowledge of the people in that one since I'm not in it
I know the C++ people in there are expert level nerds
skull
yes? is that a question or are you trolling? lmao
No cus I need to be in it
tho its more of an operating system question (no not my os)
Need help
discord.js is like one of the biggest servers lol
everyone knows it
just go to their website and click join discord lol
nvm it js
was wondering if its possible to open a file with both read and write and be able to append data at the end
or would i have to open another handle with append
you can create multiple handles to the same file
yeah just was wondering if its possible to do it with one
probably yes, but you'd have to do it more manually i guess
not sure what append does for you that r+ doesnt
guess not since theres one function which accepts data and how that data is accepted depends on the handle mode
i'll give it another try
want to be able to seek certain structs in a file as well as add new ones at the end
@quartz kindlewait seeking to the end of the file then writing works
i swear that didnt work for me before
well great i guess
xd
@quartz kindle dynamic array allocation stack vs heap
i see a lot of people using the heap unnecessarily when the data they're storing is temporary so they should just use the fast stack
find it pretty cool how you can allocate space on the stack by doing char items[size]
but you need to know the size at compile time
if you know the maximum possible size that can happen, you can just reserve a big enough stack array for that
otherwise you have to use heap
yeah the only exception:(
i think thats only for static (in other words global) variables
i can make arrays with dynamically acquired sizes on runtime
since when
right time to look stupid
brb
@quartz kindleyeah you can
no errors
i mean its not a surprise its possible
huh weird
in assembly form its a simple subtract x from stack pointer
last time i tried doing that it didnt work
pls help me
i want make the msp glitch
Programming languages that support VLAs include Ada, Algol 68 (for non-flexible rows), APL, C99 (although subsequently relegated in C11 to a conditional feature, which implementations are not required to support;[2][3] on some platforms, could be implemented previously with alloca() or similar functions) and C# (as unsafe-mode stack-allocated arrays), COBOL, Fortran 90, J, and Object Pascal (the language used in Borland Delphi and Lazarus, that uses FPC).
i guess my compiler didnt like it? idk
?
talking to speedy
talking germany ?
what
where ist he invite tracker
I think just wrong server moment
i want to make the mso hair gkitch does anyone know to do it?
???
What is that
unsafe? dont see how that would be unsafe
movistarplanet
what??
played that as a kid bro
hahah
unsafe in the context of C# means using pointers, not sure if that’s what it meant by that but that’s what I see
can you help me ?
pointers are kind of the whole point of c/c++ haha
well mostly c since you have references in c++
Yes
C# is more like Java than C/C++ though
But still has pointer capability
Just only when marked as unsafe
actually i can see why its unsafe @quartz kindle
if you were to provide a negative integer to it for example it would accept it without question possibly overwriting stack variables and causing segmentation faults
since theres no runtime checks
but other than that if you have validation checks you should be fine
@quartz kindle so now every time I try and delete something from the hdd it disconnects and reconnects
backup asap
rip
Chkdsk it
chkdsk would fail
chkdksdshckhsdkhskd it
My brain is too fried to think about this after working with ASP.NET for the last 5 hours: if I have a postgresql database with a column of keys called "id", if I delete one entry via ID, is there a nice way to shift all of the other elements back? Ex: IDs = [1, 2, 3, 4, 5, 6] and values = [6, 5, 4, 3, 2, 1], DELETE ID = 5, IDs becomes [1, 2, 3, 4, 5] and values becomes [6, 5, 4, 3, 1]
(ping on replies, gonna get off for the night so no rush)
I use discord.js v12 and I am trying to make the bot send the message to a specific channel and I dont know if this is right or not Im confuse?
client.channel.cache.get(channel_ID).send(``)
channels
it would have to be a very manual process. I don't believe postgres offers that functionality, so you'd have to do it in code and then write the columns back.
This is assuming the auto increment constraint is okay with modifying the ID
actually. You shouldn't do that because there's an internal int being incremented to use as the next available ID
you could also change that but ???
How can i get votes of a user
For example by listening to the webhooks topgg can send to your endpoint
here your first issue: you use discord.js v12
and heres your second issue: you use discord.js
here is your third issue: you use discord
heres your fourth issue, you live
I need with bot
I'm trying to deploy a express app on heroku, do I need web dyno or worker dyno for that?/
web
client.channels.cache.get(...)
do I need to limited dm command to owner only ?
because my friend said it could be abuse by people
correct me if i'm wrong but you can limit it to server admins
that's what most moderation bot did
If not, you can have it as long as the dm tells you who and where the message came from, and if there is a block feature to not get dms.
so like from author
ah alright then, I'm probably just gonna limited it to bot owner since I don't want people to misuse it for advertising and such, gonna add where the message come from either.
wht shld i enter here
Even with the image file type, it still doesn't render for me
server setting > integration
oh
when i do send request it doesnt do anything'
i entered the url
I'm not really using webhook neither know much about it, maybe try send test.
i did tht
is there another way to see who voted?
Yeah after sleeping on it, I’m now realizing how bad of a solution that idea was
what's diff, in these 2
let a = function(x, y) {
return x * y;
}
// And
function a(x, y) {
return x * y;
}
uh how do I make bot send who sent the dm to a user.
no difference
the second is hoisted to the top
And the first is anonymous
{
function a(x, y) {
return x * y;
}
}
a() // works
{
const a = function(x, y) {
return x * y;
}
}
a() // doesn't work
pretty pointless distinction imo
so all functions by default are accessible from anywhere?
for named functions
accessible within the scope of the function they're located in, much like var
but also
a() // works
function a(x, y) {
return x * y;
}
a() // doesn't work
const a = function(x, y) {
return x * y;
}
function names are registered before execution, anonymous functions don't get that because they don't have names
hmmm, now I get it. Named functions are very similar to how var works
well var won't behave like above
but it doesnt throws exception atleast
it does
djs 13 change haspermission to permission.has ? tried it but ended up with undefined reading has
i think u need to include permissions
I already did
if(!message.member.permission.has("MANAGE_MESSAGES")) return message.channel.send('You do not have permission to use this command!')```
bruh I still can't put the code properly on discord
typo
its need to be permissions
if(!message.member.permissions.has('MANAGE_MESSAGES'))
what's issue here?
type OnlyNumAndString = <T>(arg: T) => void
// TS-Error: Type 'T' is not assignable to type 'number'.
const fun:OnlyNumAndString = (a:number) => {}
Also I want T to be only of type number and string
Can't you do ```js
<T extends number|string>
ah
it ended up like this
I already typed the message tho
you probably want type OnlyNumAndString<T> = (arg: T) => void;
But than I'm forced to give a generic type for T.
I want it to auto detect, for number or string
not sure if you can use T without generics
(arg: string|number) => void
na na. It should be either one of them not both
pretty sure you'll have to use generics
is anyone here good at docker
docker terrifies me
You'll always need to provide the type if you don't want to use an union...
unless you set a default to the type parameter
anyone know how to solve this
don't send an empty message
It's not a empty message.
The error disagrees
You'll need to find where the error is coming from
Which can help spot the issue
deleted the embed part, and it worked, but the embed was supposed to tell where/who the message send
just show the previous code
run: async (client, message, args, cmduser, text, prefix) => {
if (message.author.id !== ownerID)
return message.channel.send('You are not the owner of this bot')
let user = message.mentions.users.first() || message.guild.members.cache.get(args[0])
if (!user)
return message.channel.send('Please mention a user or provide a valid ID')
let msg = args.slice(1).join(' ')
if (!msg)
return message.channel.send('Please provide a message')
let dm = new Discord.MessageEmbed()
.setTitle('DM')
.setDescription(`${message.author} has sent you a DM`)
.addField('Message', msg)
.setColor('#00ff00')
user.send(dm)
message.channel.send(`DM has been sent to ${user}`)```
this was the previous one
are you using v13 right¿
yes
change user.send(dm) to user.send({embeds:[dm]})
also, there can be a error if the user has closed dm so add a .catch((e) => {return message.channel.send('Your DM is closed!')}) to the user.send()
oh right, I forget to add the error part if the user closed their dms/blocked the bot
Make sure you have a way for if an error were to occur, you’d be able to stop it. Like a catch statement.
let dm = new Discord.MessageEmbed()
.setTitle('DM')
.setDescription(`${message.author} has sent you a DM`)
.addField('Message', msg)
.setColor('CYAN')
user.send({embeds:[dm]})
.catch(e) => {return message.channel.send('User DM is closed!')})
message.channel.send(`DM has been sent to ${user}`)
}
}```
like this ?
I installed redis-server on ubuntu 20.04
and its running and active
but I can't seem to access it from my docker container
Tried, but instead it send the message twice (the one with embed and one without)
that will send both messages if the user's dms are closed
make senses.
use .then for a success promise
try {
await user.send(msg)
} catch (e) {
return message.channel.send(`${user} has their DMs closed`)
}
message.channel.send(`DM sent to ${user}`)
}
}```
Tried this and it's still sending the message twice (if the user has his dm closed)
i wonder if the return is only returning out of the catch function
instead of the whole try function
I try that aswell
if it's sending both messages maybe save the message in a temporary variable and only write message.channel.send(message) once at the end
what
ok wait i was being stupid, i didn't realize what you were asking my bad
Well the way I had to set it up post to be like client.channels.cache.get(`ID HERE`).send(embed2);
plus
why don't you check if the channel exists
if it doesn't you are performing "send" on undefined
with will throw a reference exception
if the channel is undefined it shouldn't send the message in the dms
I'm having an issue with my bot not being able to ping a role. It has full permissions and normal users can ping a role perfectly fine, but the bot isn't able to for some reason.
interaction.channel.send("<@&" + roles.queuePing + ">");
The role is sent with colors and whatnot, it just doesn't send the notification.
all good lol
I was not reading and my dumbass thought I already put .send(embed2 LMFAO

rewrite it as
.catch((e) => {
message.channel.send(`${user} has their DMs closed`)
})
.then((msg) => {
if(msg){
message.channel.send(`DM sent to ${user}`)
}
})```
that might work?
try {
await user.send(msg);
message.channel.send(`DM sent to ${user}`);
}
catch (e) {
message.channel.send(`${user} has their DMs closed`);
}
assume the block is async
you don't want to execute message.channel.send(`DM sent to ${user}`); unless user.send(msg) is succcessful
if user.send(msg) fails it throws a PromiseRejection
which skips execution to catch block
which rejection is DiscordAPIError
mhm, @fickle arch try this
plus it looks cleaner than callback chains
fair
tried that, and the result was same like the previous code that I sent, it sent the user message twice.
ok wait so do you mean it sent both of the channel messages
or it sent the dm and said that the dms were closed
this basically
sent the message twice on the dms
for the channel it doesn't send the one saying user dms is closed.
dm = the message embed and msg = the message you're trying to send right?
yeh the dm is the msg I tried to send to the user dm
because if so, you have user.send({embeds: [dm]}) written once already, and then
user.send(msg) written in the try statement
so it sends the dm and then sends the msg, so delete the user.send that's outside of the try statement
let dm = new Discord.MessageEmbed()
.setTitle('DM')
.setDescription(`${message.author} has sent you a DM`)
.addField('Message', msg)
.setColor('ORANGE')
user.send({embeds:[dm]})
try {
await user.send(msg);
message.channel.send(`DM sent to ${user}`);
}
catch (e) {
message.channel.send(`${user} has their DMs closed`);
}
}
}```
I'm probably mistaking the placement of it
let dm = new Discord.MessageEmbed()
.setTitle('DM')
.setDescription(${message.author} has sent you a DM)
.addField('Message', msg)
.setColor('ORANGE')
user.send({embeds:[dm]}) //delete this
try {
await user.send(msg); //change this to await user.send({embeds:[dm]})
message.channel.send(`DM sent to ${user}`);
}
catch (e) {
message.channel.send(`${user} has their DMs closed`);
}
}
}
delete this statement
user.send({embeds:[dm]})
yeah, do yk how try statements work?
why do you send that message twice to the same location
i can give a quick explanation if you need
i think they were slightly confused on what a try statement does
sure, I'm still new on developing either.
delete either
user.send({embeds:[dm]})
or
await user.send(msg);
delete the 1st one i mentioned
so a try statement will run the code inside of the block, all it's saying is that if it fails it will run the catch statement instead of logging an error and stopping the app
deleted the user.send embed and put it below the await
but if it's successful, the code inside a try block still runs
now try executing again
that's oki, learning takes some time! if you need help with anything you can dm me btw
i tried
try executing the code
if any error happens, catch it
finally do stuffs after the code either fail or succeed
thanks fam, really appreciate your help
also thank you for the help
ofc!
alright the code is working but if only the user block the bot somehow
huh?
so basically I sent the test dm to my friend, he have dm closed, the bot still send the message but if he block the bot, it send the other message
after the bot is blocked
how do i set user agent on electorns webview
app.setAttribute("useragent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) discord/1.0.45 Chrome/91.0.4472.164 Electron/13.6.6 Safari/537.36");
``` this doesnt work
firebird
User-Agent
or user-agent
u forgot the dash
I'm having an issue with my bot not being able to ping a role. It has full permissions and normal users can ping a role perfectly fine, but the bot isn't able to for some reason.
interaction.channel.send("<@&" + roles.queuePing + ">");
The role is sent with colors and whatnot, it just doesn't send the notification.
Pretty sure you have to specify allowed_mentions


