#development
1 messages ¡ Page 2039 of 1
my bad I thought you just wanted to know what was wrong 
Well yes cause that helps with helping u 
yeah
yes
being real with you
fair
some one managed to break my bot buy sending it a 3k character msg
didnt even know that was a thing tbh
2k for non nitro users 4kfor those who do have nitro
Up to you
yeah cuz the bot cant send msgs over 2k
and it to early to deal with thrying to make its send two msgs
Sending two messages can get messy to begin with
misty i finally make a github account
imma spread beautifully written code with correct indentation
think discord js has a parameter which automatically sends two messages for you if an overflow happens
link ur github to ur discord
later when im on laptop
okie
async fetch(id: Snowflake, options: MessageFetchOptions = { cache: true }) {
if (options.cache) {
const response = await this.client.rest.get(`/channels/${this.channelId}/messages/${id}`);
this.channel.messages.set(id, response);
return response;
}
return this.channel.messages.get(id);
}
Should I cache if it is true, or should I check cache if it is true
I don't really think it matters but I want your guys opinion on this
I would suggest to keep the cache's purpose as, if it is true, the bot checks the cache for the message, if not goes to fetch the message. If cache is false, it fetches the message directly from discord itself. So the user could choose between directly making a request to discord, or to possibly save a request
that wouldnt be very intuitive
async fetch(id: Snowflake, options: MessageFetchOptions = { cache: true }) {
return this._parse(
options.cache
? this.channel.messages.get(id)
: await this.client.rest.get(`/channels/${this.channelId}/messages/${id}`),
);
So you mean like this then?
especially as discord.js already uses the cache option to mean a different thing
Are you talking about me tim or vis?
both
I was thinking when using the term cache, it would fetch from discord itself and cache it then return, and if it is false it would just fetch from the cache and return
discord.js uses the cache option for a different thing
their fetch method always checks cache first regardless, the cache option just toggles whether the returned data should be cached or not
Ah, that makes sense
they use the force option to not check cache before fetching
What is the point of not checking cache first tho
if it is in cache it saves you from making a pointless request
in rare situations its possible that the cached data is bad/broken/modified/corrupted
for example if you somehow accidentally cache a partial
I see
channels.set(id, { id })
then the fetch method would not fetch, even if the cached channel only has the id and nothing else
the guild channels I cache to the client are partials
anyone here use beautifulsoup4?
wtf is that
Seems like you just give it something to parse and then you can access what you need
It's just Cheerio for Python
misty, the structure of the site makes me wanna kms
the fandom site
but the fandom site is the problem
i'm sure that's what he's doing
hii guys, so i have this code for my clear command on my old bot, and its used with prefix, i would like to create same but with slash commands any idea on how could i do that?
and this is code with slash commands, ofc it will not delete msg, this was just test so I can see will everything work
hehe great... đ
oh...tnx
Or just interaction.user for the user object
yea, i need to check if user have permissions to use specific commands
Youâve just copy pasted some code into a slash commands handler, make sure you define everything
anyone know how you make it so instead of a new line it adds an ellipsis for the link
i tried text-decoration: ellipsis but it didnt work
text-overflow:ellipsis;
``` maybe what you are looking for
anybody got this github issue before? this is my first time getting this issue
is that github app?
try doing git status on cli to see if anything is unadded
if so, just do git add .
still the same nothing changed
did u commit already?
i stashed everything đł
well then, that's why it says nothing changed
you unstash it
how? restoring everything? through a command?
are u sure u stashed?
yes
do git diff origin/master
oki
or origin/main if ur using the new github naming scheme
is ur remote branch named main?
yes
then idk what u did
remote? but there is only one branch which is the main branch...
you have a remote repository no?
oh my bad
oh oki lemme try
Your remote identifier is broken, refs/remotes/origin/main is invalid
oh- is there a way to fix it?
Delete the local .git/refs/remotes/origin/main file/directory on the working directory of the project and run git fetch to fetch the original identifier
uhm... how do i do that? i am not quite sure esp with commands
rm -rf <path>
careful with that command
oki
uhmm idk... nothing seems to be working...
i googled how to fix it earlier on but nothing works
@vivid fulcrum You got any advice on site accessibility?
typescript error with new discordjs version?
What the fuck
If you are using the master version of djs don't
it isn't stable
I'd highly recommend downgrading
I see, you could try asking in the djs server then I am sure by now people have started complaining about it and the actual pros who use djs has found a fix
in the process of trying to get unbanned đ
do you have strict mode enabled?
nah i dont think so. i assume thatd be in tsconfig?
yes
discord.js where every update breaks the TypeScript typings
nah its not on strict mode i dont believe

set strict: true in compilerOptions of tsconfig.json
dont think it errors for djs anymore but theres now 4.4k errors in my code đ˘
Lmao
djs requires using ts in strict mode
I donât get the point of not using strict mode in ts
Using TypeScript without strict mode is like using a bulletproof vest but it's not actually bulletproof
hey now
đ
A bulletproof vest prop 
bruh
anyone wanna send me some
using typescript is like using performance enhancing drugs
it'll help but it can fuck you over
code?
I can send you some
im working on this cool email
Get some
placebo performance
all is good until typescript tells you you cannot do something
which happens every 5 seconds
but then you can use any or ts-ignore!!!!!!
it happens every 5 seconds if your code is shit đŠ
my bacalhau is shit
ok debate time
i'm making an antiscam lib
is it better to emit events with EventEmitter from its own class, or should the user pass the client object and emit events from the client class so users can handle the event from their events folder
(djs)
The first option raises the question of client object access in the events
a lot of djs specific libs i see handle it like that
pass the client object so it can emit events
The first option would be the most ideal, the second option would not only confuse those who read the code but it also breaks typings, so it's better to just emit them from it's own class
ah ok
i tested today, its as simple as literally doing client.emit(<eventName>, <whatever i need to pass>)
I made shit code once again!
Are you proud of me :)
Of course, I'm proud of you
guys
is there a way to run a specific event handler before any other handler in js:):(
I searched a bit and I don't think it's possible
so. I think I made something cursed. the @types/node package exports Object.assign as a weird definition. It has multiple type signatures for merging up to 8 Objects I believe. index signature being target & source. Next one being target & source1 & source2 and so on and so forth.
This can be an issue because you might want to merge more than however many signatures there are and still get typings. I present to you my cursed solution;
type Assign<T extends { [k: string | number | symbol]: any }, SR extends Array<{ [k: string | number | symbol]: any }>> = SR extends Array<infer O> ? T & O : never;
so i have this code, which should be used to ban members from the server, but I also got this error, so if could anyone help me on what i do wrong, it would be nice```js
const { SlashCommandBuilder } = require('@discordjs/builders')
const { DeveloperID, OwnerID } = require('../config/config.json')
const { Permissions, member, Message } = require('discord.js')
const run = async (client, interaction) => {
let member = interaction.options.getMember('user')
let duration = interaction.options.getNumber('duration')
let reason = interaction.options.getString('reason')
if(!member) return interaction.reply('Invalid Member')
try {
await interaction.guild.members.ban(member, duration, reason)
return interaction.reply(`${member.user.tag} Has been banned from the server!`)
} catch(err) {
if (err)
console.error(err)
return interaction.reply(`Failed To Ban ${member.user.tag}`)
}
}
module.exports = {
data: new SlashCommandBuilder()
.setName('ban')
.setDescription('Ban user from the server')
.addSubcommand(subcommand =>
subcommand
.setName('user')
.setDescription('User you want to ban')
// .setRequired(true)
)
.addSubcommand(subcommand =>
subcommand
.setName('duration')
.setDescription('Duration of the BAN')
// .setRequired(true)
)
.addSubcommand(subcommand =>
subcommand
.setName('reason')
.setDescription('eason of the BAN')
// .setRequired(true)
)
/*
async execute(interaction, member, message) {
if (!interaction.user.id === DeveloperID || interaction.user.id === OwnerID || interaction.user.id.permissions.has('BAN_MEMBERS')) {
interaction.reply('You Dont Have Required Permissions To Use This Command!')
return
}
if (interaction.user.id === DeveloperID || interaction.user.id === OwnerID || interaction.user.id.permissions.has('ADMINISTRATOR')) {
interaction.reply('Mentioned Member Has Been Banned')
return
}
}
*/
}
Well, your code has a LOT of things wrong with it
This is commented out either on purpose or on accident; but regardless, youâre not passing the arguments in the right order
this is comented on purpose yes
and that is not very importnat
Well, thereâs no execute function while itâs commented out
actualy
So command.execute() does not exist
that is used so owner of the bot or it developer can use this command either if they have permissions or no (if they want to use it on diferent servers)
You have not exported an execute function to go along with your command
Thatâs why youâre getting that error
That function does not exist
ah amm uncomented async but yea still have things to fix
now i dont getting error but bot dosent respond
Can you show the code youâre using now?
Youâre probably still passing the arguments in the wrong order
well... ```js
const { SlashCommandBuilder } = require('@discordjs/builders')
const { DeveloperID, OwnerID } = require('../config/config.json')
const { Permissions, member, Message } = require('discord.js')
const run = async (client, interaction) => {
let member = interaction.options.getMember('user')
let duration = interaction.options.getNumber('duration')
let reason = interaction.options.getString('reason')
if(!member) return interaction.reply('Invalid Member')
try {
await interaction.guild.members.ban(member, duration, reason)
return interaction.reply(`${member.user.tag} Has been banned from the server!`)
} catch(err) {
if (err)
console.error(err)
return interaction.reply(`Failed To Ban ${member.user.tag}`)
}
}
module.exports = {
data: new SlashCommandBuilder()
.setName('ban')
.setDescription('Ban user from the server')
.addStringOption(option =>
option
.setName('user')
.setDescription('User you want to ban')
// .addUserOption(option => option.setName('target').setDescription('The user'))
// .setRequired(true)
)
.addStringOption( option =>
option
.setName('duration')
.setDescription('Duration of the BAN')
// .setRequired(true)
)
.addStringOption(option =>
option
.setName('reason')
.setDescription('eason of the BAN')
// .setRequired(true)
),
async execute(interaction,client) {
/*
if (!interaction.user.id === DeveloperID || interaction.user.id === OwnerID || interaction.user.id.permissions.has('BAN_MEMBERS')) {
interaction.reply('You Dont Have Required Permissions To Use This Command!')
return
}
if (interaction.user.id === DeveloperID || interaction.user.id === OwnerID || interaction.user.id.permissions.has('ADMINISTRATOR')) {
interaction.reply('Mentioned Member Has Been Banned')
return
}
}
*/
}
}
My man you have all the code inside of your execute function commented out of course itâs not going to respond đ
yea lemme try uncommenting this
TypeError: Cannot read properties of undefined (reading 'has')
after i uncommented permissions
interaction.user.id is a string, it wonât have any permissions property
interaction.member.permissions.has
but interaction.member is not always present, so you'll have to set the dm permissions as false or check if the command was executed in a DM
it's taking too long
well.. u will have to wait for it to finish
it take like 2 or 3 hrs
and from some reason i get this error of undefined id: ```js
async execute(interaction,client) {
if (!interaction.member === DeveloperID || interaction.member === OwnerID || interaction.member.permissions.has('BAN_MEMBERS')) {
interaction.reply('You Dont Have Required Permissions To Use This Command!')
return
}
if (interaction.member === DeveloperID || interaction.member === OwnerID || interaction.member.permissions.has('ADMINISTRATOR')) {
interaction.reply('Mentioned Member Has Been Banned')
return
}
}
console.log(interaction.guild.roles.cache)
@quartz kindle mail is torture đ
i think i need to watch a low level email crash course before i can continue
good luc
i wanna use this but i have no idea how to configure the dnshttps://github.com/Flolagale/mailin
ok, here we go: ```
Collection(0) [Map] {}
TypeError: Cannot read properties of undefined (reading 'id')
at get cache [as cache] (D:\discord_bot\Sushi_Bot\node_modules\discord.js\src\managers\GuildMemberRoleManager.js:36:101)
at get permissions [as permissions] (D:\discord_bot\Sushi_Bot\node_modules\discord.js\src\structures\GuildMember.js:262:39) at Object.execute (D:\discord_bot\Sushi_Bot\commands\ban.js:40:33)
at Client.<anonymous> (D:\discord_bot\Sushi_Bot\index.js:45:23)
at Client.emit (node:events:527:28)
at InteractionCreateAction.handle (D:\discord_bot\Sushi_Bot\node_modules\discord.js\src\client\actions\InteractionCreate.js:83:12)
at module.exports [as INTERACTION_CREATE] (D:\discord_bot\Sushi_Bot\node_modules\discord.js\src\client\websocket\handlers\INTERACTION_CREATE.js:4:36)
at WebSocketManager.handlePacket (D:\discord_bot\Sushi_Bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:351:31)
at WebSocketShard.onPacket (D:\discord_bot\Sushi_Bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22) at WebSocketShard.onMessage (D:\discord_bot\Sushi_Bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
did you disable the role cache?
or do you have the guilds intent disabled?
hey, how can this be improved?
make a list
- Incomming call to {channel} from {user}
- Call Satrted by {user} from {channel}
- To answer use /answer
- To Decline use /decline
The text is fine imo, maybe just add an empty line before the last one
That way it's
There is ...
The call was started ...
Answer the call by using `/answer` or decline with `/decline`
There
put it as footer
I'm having trouble with a Java class
One message removed from a suspended account.
In one class I have a method
Public void decider
And in the other I have
Calculator calculator = new Calculator;
calculator.decider();
But I'm getting a Cannot make a static reference to a non static method error
what is your exact code
One message removed from a suspended account.
One message removed from a suspended account.
Brb
One message removed from a suspended account.
it bothers me how you name the variable the same thing as the class
and how you dont add () to the new Calculator
One message removed from a suspended account.
One message removed from a suspended account.
missing parens
One message removed from a suspended account.
fed up with my final project for school đ totally burned out from programming, you?
also why is your Public capitalized
One message removed from a suspended account.
public should be all lowercase
One message removed from a suspended account.
that's why i asked them for the exact code
//this is the class in main
public static void main(String[] args) {
Area_calculator AC = new Area_calculator();
Scanner input = new Scanner(System.in);
System.out.println("Welcome!");
System.out.println("1) Area calculator\n2) Exit");
try {
int x = input.nextInt();
if (x == 1) {
Area_calculator.main();
}
}
catch (InputMismatchException e) {
System.out.println("Invalid input");
}
}
One message removed from a suspended account.
WHAT THE FUCK
wait i just noticed it
One message removed from a suspended account.
ive used it for maybe an hour...
Area_calculator kekw
literally calm down
I'm gonna die
i use camel case in EVERYTHING
python, java, c#, c++
that's friggin murder
its the sexiest
stop being toxic
good to know this was a good spot to ask
One message removed from a suspended account.
bro, if you want your code to look hot, use camel case, 100% your code will make people drool
One message removed from a suspended account.
im so fed up with people in this channel acting elitist, either provide feedback or just shut up, calling people degenerates makes you one
joke or not
doesn't matter
ok degenerate, your feedback to my feedback wont stop me from advocating the pure hotness of camelcase
im 100% bias
@solemn latch deal with this <33
anyways, what problems are you having with the code
dudes calling the mods on me rip
@sage bobcat i discovered jquery recently, and oh my god its hot as hell
i don't have the nerves to continue on with this lol, you got called out on your behavior and now you're trying to switch up subjects really quick and seem like a better person
toxic
no offense, i dont care
One message removed from a suspended account.
anyways
One message removed from a suspended account.
faith
$(document).on('click', 'a[href!="javascript:void(0);"][target!="_blank"]', function(event) {
event.preventDefault();
$("#root").fadeTo(500, 0);
$("#root").promise().done(function(){
window.open(event.target.getAttribute("href"), event.target.getAttribute("target")!=undefined ? event.target.getAttribute("target") : "_self");
})
});
setTimeout(function(){
list = $(".caret");
lsize = list.length, size = 0;
list.each(function(){
if($(this).parent().attr('caret-text')!=undefined){
for(i = 0; i < $(this).parent().attr('caret-text').length; i++){
var $this = $(this);
setTimeout(function(value, last){
$this.before($this.parent().attr('caret-text').charAt(value));
if(value == last-1){
$this.remove();
size++;
if(size==lsize){
$("#content").fadeTo(1000,1);
}
}
}, (($this.parent().attr('caret-speed')!=undefined?parseInt($this.parent().attr('caret-speed')) : 200)*i), i, $(this).parent().attr('caret-text').length)
}
}
})
}, 1000)
its hot
cry is kind of right, please dont insult people based on their code/personal preferences.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
your opinion is wrong
what the fuck is a SPA
Single Page Application
One message removed from a suspended account.
single page app - react, angular etc
ew
why
It is faster for one
wellllll
I've noticed it is faster at least
SPAs are meant just for that, apps that contain lots of information or routes
ajax
jquery is fine if you're doing some light websites like a portfolio
One message removed from a suspended account.
what if you want a user to be able bookmark certain things
WELL I JUST LEARNED IT SO BRING IT BACK DAMNIT
One message removed from a suspended account.
browser history apis and offline routing
what the fuck
that sounds invasive
One message removed from a suspended account.
js can access the browser history and modify the url without reloading the page
One message removed from a suspended account.
thats invasive as fuck
and js can also detect url changes to change content
when was jquery created
One message removed from a suspended account.
spsaking of SPAs, i just learned about solid - https://youtu.be/hw3Bx5vxKl0
seems like a really nice alternative to react without virtual DOM
SolidJS is a JavaScript framework for building fast, declarative UIs on the web. It shares many ideas with React, but does not use the virtual DOM to deliver a more performant and pragmatic developer experience.
#webdev #programming #100SecondsOfCode
đ Resources
Solid Docs https://www.solidjs.com/
Solid GitHub https://github.com/solidjs/solid...
DO YOU THINK I WAS BORN AFTER 2005?
ye it regularly comes up in the top ranks in performance benchmarks
One message removed from a suspended account.
i still prefer svelte because i dont really like react's api
One message removed from a suspended account.
have yet to try out svelte but it seems like it has a nice niche
One message removed from a suspended account.
cause you're a feckin granny?????????????????????
i love JSX though so solid has my priority rn
One message removed from a suspended account.
One message removed from a suspended account.
well can you illegally operate a forklift?
One message removed from a suspended account.
i refuse to have any respect for anyone
One message removed from a suspended account.
when you come down to my shithole and pay for it?
One message removed from a suspended account.
i aint made of money granny
One message removed from a suspended account.
hi
One message removed from a suspended account.
your bio makes me want to do unholy things
what was that issue
@earnest phoenix i was speaking of things such as ⨠murder â¨
that it isn't a web standard anymore
oh
One message removed from a suspended account.
deal

One message removed from a suspended account.
One message removed from a suspended account.
That looks cool ngl
i will single handedly bring back jquery as an industry standard with a lot of force and violence
the next standard is WASM 
One message removed from a suspended account.
One message removed from a suspended account.
I need to brush up more on web dev related shit
what the fuck is a wasm
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
That sounds pain
One message removed from a suspended account.
i compiled an old qt app for wasm and it was actually super fast
One message removed from a suspended account.
you don't write wasm yourself
also, this is how i keep my email safe from scraping,
is it stupid?
https://i.imgur.com/zDEuEsH.png
or actually good
very stupid cause u made it
:)
im going to find you
it's going to work fine for most scrapers
and then cry in front of your face
hm
however it's useless if the scraper also evaluates js, i.e. if it uses puppeteer
if ur email has something searched up that i want i bet i could find it if i tried like hell
One message removed from a suspended account.
I wish I had knowledge
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
id call you smart, if you're always yearning to learn more i consider you smart
i love when people are actually interested into what they're doing
which is a rare occasion in this channel
I am interested in what I do
but I fuck it up so bad

constructor(client: BaseClient, data: GuildTextChannelData, guild: Guild) {
super(client, data, guild);
this.name = data.name;
this.position = data.position;
this.nsfw = data.nsfw;
this.parentId = data.parent_id;
this.lastMessageId = data.last_message_id;
this.topic = data.topic;
this.lastPinTimestamp = data.last_pin_timestamp;
this.rateLimitPerUser = data.rate_limit_per_user;
// Gotta come up with a better way to do this......
(async () => {
for (const message of await this.client.rest.get(`/channels/${this.id}/messages`)) {
this.messages.set(message.id, message);
}
})();
}
like wtf is this
I am sure there is a better way to do this
đ
out here making random functions
i do that too when im too lazy to abstract code into its own function lmfao
Lmao
arrow functions for the win!
Oh fuck just realized I don't have strict mode on in ts
now all my code is erroring

One message removed from a suspended account.
i always have it off because i mostly work in react
im sorry but i am not typing out React.MouseEvent<T>
where T is an unnecessarily long name of an element
any is easier
what are you trying to do there?
I am trying to cache all the messages from the current channel
One message removed from a suspended account.
why?
kush
It was just to see if it actually worked
turns out it does
I am going to find a better place to actually cache the messages
Well yea
Ima include a cache option for messages which will have a limit
default will be 50 tho
Mmm, actually I might of though about this wrong haven't I
One message removed from a suspended account.
ram usage skyrockets faster than the stock market
I should not be caching all the existing messages should I
Only the ones being sent during the bots process
libs only cache incoming messages
If they want
inb4 âmy program keeps crashing idk whyâ
Stfu
they dont retroactively attempt to cache past messages
not even all of them, there's usually a cache limit
Yea, I just thought of that
Ima let them decide but I will have a default limit
i have better idea! download them locally then have your library first query local messages 
better performance but at what cost
Is git rm a command or is it just rm
@quartz kindle do you know anything about email authentication
for some reason every library tells me to set a "username and password"
but why
you dont need an email or password to send an email to someone do you
git rm deletes tracked files (not the actual files)
it's useful when u gotta update .gitignore files
ah yes. Send an email without an email
you're most likely using an smtp library
you need to authenticate with your smtp server to send emails
Ahh but my system doesn't recognise rm as any command
Windows is rmdir
you can also create your own server but that's a hundred times more annoying than just using an already established one like google's
thats exactly what im trying to do
i dont want to sync or send emails
just have a server that can receive them
anyways i got it working but still dont know anything about imap/smtp
the hard part is now parsing them
Oh thank you!
so i got this basic mongodb filter js let ifAdded = await Dino.findOne({ guildID: guildID, dino: dino }); but if i do console.log(ifAdded, guildID); this is my output https://srcb.in/wNq1lWoZJC but that shouldnt get outputted bc the guildID variable isnt equal to the one that i get from the database
what is dino? do you want it to return the document that contains both that guild id and that dino value, or either of them?
i want to return the function if the dino variable is already in the array and guildID is already declared
so i get a input where guildID is 123 and dino is pt i want to check if thats already in the collection and if it is i want it to return a message
if that makes sense
then you probably want something like ```js
.findOne(
{
$and: [
{ guildID : guildID },
{ dino: { $in: [ dino ] } },
]
}
)
nope, didnt work
or actually thats wrong
it should be $elemMatch according to the docs
.findOne(
{
$and: [
{ guildID : guildID },
{ dino: { $elemMatch: dino } },
]
}
)
i think?
idk mongo is confusing af, i really dont like it
Error: Query filter must be an object, got an array
or is it ```js
.findOne(
{
$and: [
{ guildID : guildID },
{ dino: { $elemMatch: { $eq: { dino: dino } } } },
]
}
)
how about you just do it the js way
const data = await ....findOne({ guildID : guildID });
if(data?.dino?.includes(dino)) {
}
i haven't thought about doing that
and that still gets the wrong document somehow
but this looks like works so ill just do it this way
do you somehow have multiple documents with the same guild id? or maybe you dont have any document with that guild id so it falls back to something else?
idk i dont use mongo
then it should log as undefined
what about ```js
.findOne({ $eq: { guildID : guildID } });
nope
i gotta figure out this tomorrow its getting late here but thanks for your help
idk i feel like there is something very wrong with your schema
It worked before when I tested it in only one server
Argument of type 'GuildChannels' is not assignable to parameter of type 'GuildTextChannelData'. Â Â Type 'GuildTextChannel' is missing the following properties from type 'GuildTextChannelData': parent_id, last_message_id, last_pin_timestamp, rate_limit_per_user, guild_id
At this point I don't get what I am doing wrong
I get what the error is stating, but I am sure that this should be working
if (client.options.cache?.channels) {
for (const rawChannel of data.channels.values()) {
switch (rawChannel.type) {
case ChannelTypes.GUILD_TEXT: {
const textChannel = new GuildTextChannel(this.client, rawChannel, this);
this.channels.set(textChannel.id, textChannel);
break;
}
case ChannelTypes.GUILD_VOICE: {
// @ts-expect-error
const voiceChannel = new GuildVoiceChannel(this.client, rawChannel, this);
this.channels.set(voiceChannel.id, voiceChannel);
break;
}
case ChannelTypes.GUILD_CATEGORY: {
}
}
}
}
show full error
wheres the line numbers and shit
const textChannel = new GuildTextChannel(this.client, rawChannel, this);
Doesn't tell me what line it refers to in the error itself but this is one of the two affected
the other is the new GuildVoiceChannel()
show more code then
I am unsure of what you'd want to see... as the affected code is already shown?
the code you showed and the error make no sense to each other
which variable is of type GuildChannels? how did you define that type? where did you assign that type?
Mmm I thought the error would be self explanatory to the situation. GuildTextChannel takes in 3 params, client, channel data, guild. The GuildTextChannel requires the data to be of type GuildTextChannelData
export interface GuildTextChannelData extends GuildChannelData {
name: string;
position: number;
permission_overwrites?: Array<PermissionOverwrites>;
parent_id: null | Snowflake;
last_message_id: Snowflake | null;
topic: string | null;
nsfw: boolean;
last_pin_timestamp: string | null;
rate_limit_per_user: number | null;
}
Which is this
This was my mistake for not supplying proper information my bad
Argument of type 'GuildChannels' is not assignable to parameter of type 'GuildTextChannelData'
whatever you are passing into the constructor is not the right type
idk what is GuildChannels type
export type GuildChannels = GuildTextChannel | GuildVoiceChannel;
Now that I think about it, this would probably be more helpful to make this be the Data instead of the channel itself ngl
Actually that wouldn't make sense nvm
where are you assigning this type?
in my Constants file
are you making rawChannel be this type?
RawChannel is an array of GuildChannels
Oh? What do you suggest it to be then?
the variable data.channels is an array of GuildChannelData
somehow you are making rawChannel be channel after conversion, instead of before conversion
Actually that makes sense
It isn't going to be a channel until it is converted so it should be the data instead
switch (rawChannel.type) {
case ChannelTypes.GUILD_TEXT: {
const textChannel = new GuildTextChannel(this.client, rawChannel as GuildTextChannelData, this);
this.channels.set(textChannel.id, textChannel);
break;
}
case ChannelTypes.GUILD_VOICE: {
const voiceChannel = new GuildVoiceChannel(
this.client,
rawChannel as GuildVoiceChannelData,
this,
);
this.channels.set(voiceChannel.id, voiceChannel);
break;
}
case ChannelTypes.GUILD_CATEGORY: {
}
}
So I could do this then right?
so yeah, the actual problem is nowhere in any of the code you showed
Yea sorry that was my negligence heh
that will work yes
but it would be more correct to fix the root type
instead of having to cast
Mmmm
I thought I wouldn't have to cast cause they all extend GuildChannelData but then again it makes sense it wouldn't
yeah but you were giving it GuildChannels, not GuildChannelData
I changed it to be GuildChannelData
đ
hey so, i have a large query param in the url
but the server says the route itself doesnt exist
if i remove a few words from the url it works
im not able to find the right words to explain but hope im making sense
http://localhost:5013/assets/v3/ultimate-small-2022-03-09T11:40:42.980Z-gbV7b8cP0YCk4nZuh_O4V-imgonline-com-uaaaaaasdasdasdasdasdasd-nkhzpE3Ql4BXXt.jpeg
this is the entire url and the route is /v3/:filename
if i remove some letters the route is detected and goes to the appropriate function.
I think the : would have to be url encoded
i thought the same
but you see uaaaaaaass stuff?
i remove that and the route works
Odd
yeah i find it very odd
is it cause the path is too big or something
idk
its not even max size
that shouldn't be the issue but im not sure what else could be causing it 
probably to do with the way you handle it server side
oh
it says the route isnt there at all
uhh
which is why im confused even more
i cant rlly be much help without knowing how you handle the route 
its basic express.get()
oh
yeah i've tried asking in their discord. but you can give it a shot too and let me know ig
cn you show me your code of how you handle it because i tried recreating it and it works fine for me
you put in the same url?
i made a file with the same name and it worked for me so
i guess its fastify, im not handling it in any custom way, just using their defaults
most likely yea

yeah it was an issue with fastify, they have a limit of 100 characters for some reason

well actually it states its for ddos protection, they've given the option to increase limit so all good ig
Nvm was able to fix it
guys is there a way to use all intents in discord.js
Yes, you can just import the intents and use them
import { Client, Intents } from 'discord.js';
const client = new Client({
intents: Object.values(Intents.FLAGS)
.reduce((all, bitfield) => all | bitfield, 0n)
});
Although that's not what intents are for, you're supposed to choose the ones you only need
ahh tnx a lot man
or just do intents: 0b11111111111111111
my bad
fixed it
The error isnât about the id, itâs the object before id thatâs null
also
anyone here know aoi.js?
gross
all i know is stay away
just took a peek at it
ХНава ĐŁĐşŃаино!
my god that library goes against all programming conventions in node.js
bros coding in php without using php with that library
isnt aoi.js just the next version of dbd or whatever it was called
bdfd
yeah aoi.js is the successor of dbd.js
So I am trying to fetch the content of a .txt or a .json attachment that is sent as a message in discord. And the content inside is gonna be the message content object. I wanna fetch the file, and get the object inside the file (to be able to use that as a payload to create a message).
Using axios to get the file link (discord's cdn link of the file), to make a get request with the responseType being json. Then I am using JSON.stringify() and then JSON.parse() the stringified element. But for whatever reason, the JSON.parse is still returning a typeof string instead of a object.
What am I doing wrong, or is there a better way to do this?
This is the .txt file
You're supposed to consume the data AKA the body of the request, the JSON.stringify() isn't meant for that
*also i just realized that i missed a " after embeds nvm
I dont get it, maybe could u dumb it down a bit more please đ
Oh man, Axios' documentation is the worst
You should just use node-fetch or undici honestly
you are stringifying a string
res.data is already a string
JSON.stringify(string) is basically the string again
but with extra quotations and escape characters
Oh nevermind, you seem to already be consuming the data using the resourceType option, didn't notice that consumed the body; although yeah the issue is what Tim said
Average code of a user in the discord.js support server
Hmm, okay that makes sense
But I face this aswell, when I dont stringify the body
how do I give the image a specific name?
Try logging res.data
??
If the image is embedded with a URL, it won't have a name unless you attach it to the message again and give it a custom name
then you are getting an invalid json data
Guess I was just dumb to not check that. Yeah it returns a typeof obj... Thanks
how do I attach is to the message then?
Yeah I'm confused aswell... responseType is mentioned as text, but the response is actually an obj
Axios is dumb
fair enough
undici >>>> *
Hell yeah
Time to move ig?
node-fetch > axios
Undici > node-fetch > Axios
request > undici
undici > http > node-fetch > axios
http > all
HTTPRequest > Everything
okay well
I still need help
I want something like this but it needs to actually work
undici is actually not based on http like everything else, it was made to replace node's native http
so yeah, undici > http > everything else because everything else is built with http
thats not physically possible
they can use http better than how you would use http yourself
meaning, making it easier to work with
but if they can do it, so can you
I'm not going to write my own package for that if there's plenty that do it better
you dont need to write a package, http is not hard to use by itself
yeah it is, hence why undici is so good as it offers both
an easy to use package and is better than http
I've never used undici so I can't really have a say so I'll just say that you're right
import { MessageAttachment, MessageEmbed } from 'discord.js';
// Initialize the attachment.
const attachment = new MessageAttachment(/* Buffer or URL */, /* Name of the attachment */);
// Initialize the embed.
const embed = new MessageEmbed()
// Set the attachment to use the attached image, using the `attachment://` prefix and the name of the attachment.
.setImage(`attachment://${attachment.name}`);
await <TextBasedChannel>.send({
// The attachments.
files: [attachment],
// The embeds.
embeds: [embed]
});
how does files work? does it automatically convert given attachment to setImage?
I'm using better-erela.js-spotify and erela.js-vk for spotify search, how do I set clientID and secret, I already have them in music.json ?
no image appears to form
yes
Show code (I suppose you didn't use it correctly)
it's quite bad, I rewrite everything once I make sure it works
Either that API doesn't return an image, or the attachment name has a space when someone uses it, it doesn't work if it has spaces
does it work if you send the url without the attachment? like does discord resolve it into an image?
it does, also doesn't have any space
yep
if you send the attachment, is it sent as a file instead of an image? or does it not send at all?
Try logging the attachment instance
returns a json, with url and the name
if you send the attachment, is it sent as a file instead of an image? or does it not send at all?
And show it to us
{'attachment': 'https://some-random-api.ml/canvas/triggered?avatar=https://cdn.discordapp.com/avatars/603128116914683974/36b874038d55d194e27d859bd20094f6.webp?size=1024', 'name': 'mrHeavenli-triggered'}
it does not show in the embed, it's empty
no errors
an empty embed, like so
Remove the size parameter
is it because I set the dynamic to true? I wanted the GIF to be the output
so the image is not static
gif and webp does not work for me, jpg and png does work
It can also be caused because of the attachment name not having an extension, since that also changes what it's supposed to be
at least you have an attachment now
that means its working
now you have to give it a valid extension like voltrex said
Not like that though
I want the attachment to show up in the embed
show code
here
Uh
In the displayAvatarURL() method, remove the dynamic option and replace it with the format option set to png
that worked
It's because the API (The "Some Random API" one) doesn't support GIFs nor WEBP files
what is the api/dependacies that bot usually use to find spotify song/album/playlist
I can't seems like to make erela work on mine
Depends on the programming language you're using
javascript
so i making lock command and got error:
so how am I suposed to define channel?
here you got the code
You're using parameters that are not even passed or declared, the current channel would be interaction.channel
what even is channel and message in this context?
show where you call the execute function
(He passes it as interaction, client I believe @quartz kindle)
then thats obviously gonna be undefined
Learn js before making a discord botâ˘ď¸
any idea why my code sorts all of the most recently added commands to the top? shouldn't it be random?
const sorted = commands.sort((p, c) => p.help.category > c.help.category ? 1 :
p.help.name > c.help.name && p.help.category === c.help.category ? 1 : -1);
``` I'm sorting it by category, but I don't see why it would line the categories in a specific order if I haven't told it to do so
read the docs
that method is built specifically for things that you exactly don't want to do
I'm trying to get an array of sorted channels and roles
and if the value is over a certain length then slice it
how come does it say that there is none?
can anyone help?
where does it say there is none? also show actual code? not a cut pic that hides part of it
let slicedChannels = message.guild.channels.cache.fetch(channel => `<#&${channel.id}>`);
if (!slicedChannels) slicedChannels = "No Channels In The Server";
if (slicedChannels.length > 16 && slicedChannels.length != 0) {
slicedChannels = slicedChannels.slice(0, 16);
slicedChannels = slicedChannels.join(", ");
}
let slicedRoles = message.guild.roles.cache.fetch(role => `<@&${roles.id}>`);
if (!slicedRoles) slicedRoles = "No Roles In The Server";
if (slicedRoles.length > 16 && slicedRoles.length != 0) {
slicedRoles = slicedRoles.slice(0, 16);
slicedRoles = slicedRoles.join(", ");
}
basically I want to get all the roles and all the channels, if there is none show a text, if there is go ahead and if there is too much slice them and join them via a coma
but it says that join is not a function
Why are you checking if slicedRoles.length > 16 && slicesRoles.length != 0
Thatâs redundant
?? Yes it is lol
If itâs under 16 itâs not going to return true anyways
0 is less than 16
So itâs redundant
Just pointing out the redundancy, havenât looked at the problem really
I see
Is this even a real thing?
pretty sure you want .map not .fetch lol
if (!slicedChannels) needs to be if (!slicedChannels.length)
let slicedChannels = message.guild.channels.cache.filter(channel => `<#${channel.id}>`);
if (!slicedChannels) slicedChannels = ["No Channels In The Server"];
if (slicedChannels.length > 16) {
slicedChannels = slicedChannels.slice(0, 16);
}
slicedChannels = slicedChannels.join(", ");
let slicedRoles = message.guild.roles.cache.filter(role => `<@&${roles.id}>`);
if (!slicedRoles) slicedRoles = ["No Roles In The Server"];
if (slicedRoles.length > 16) {
slicedRoles = slicedRoles.slice(0, 16);
}
slicedRoles = slicedRoles.join(", ");
.filter is also wrong
I updated it slightly, although now it says that roles doesn't exist
(role => `<@&${roles.id}>`);
this is the error
yeah I just noticed that
thanks
@quartz kindle do you know how to filter out the channel categories?
since they aren't highlighted it looks quite ugly
.filter(x => x.type !== "GUILD_CATEGORY").map(...)
thanks
@quartz kindle sharing a bit of what ive learnt
there really isnt many resources on making your own email server so i kind of had to try and fail
so to receive emails i think you need to have a running SMTP server with a valid MX record
but sending emails gets a little more complicated
you need to first lookup the domains MX record (the emails domain) and then connect to the domains SMTP server
and once you connect you can then send the email to it
i thought it was much simpler than that
and I think email servers can verify if the email it is sent from is indeed sent from where it was supposed to be sent from by reverse searching the MX record
this library can resolve the MX record https://github.com/martyndavies/legit
đ
When I use JSDOM's runScripts: "dangerously", the content is returned first and then the scripts are run. How can I do the opposite, which is run the scripts and then get the returned content?
let url = ...;
await something(url); // Logs a script from the page last.
async function something(url) {
let dom = await createDOM(url);
return console.log(dom.window.document.body.innerHTML); // Logged first
}
async function createDOM(url) {
let dom = await JSDOM.fromURL(url, { pretendToBeVisual: true, runScripts: "dangerously", resources: "usable" });
console.log("a"); // Logged first.
return dom; // Returned first
}
If the page contains <script>console.log("hello");</script>, what is logged is:
"a"
some_html_here
"hello"
according to the docs, jsdom uses a virtual console, which is where the console.log from the script goes
this virtual console then redirects the output to the nodejs console
and apparently this process is not synchronous
the script itself is still run first, just the console part of the script that has an extra round trip
So I'm restarting from scratch on my lib and I wanna do it right this time which means building it from the ground up in steps. For now I really wanna focus on the gateway and make sure everything about it is good enough to be used in a production level bot. Which means I have to take into account basic error handling from the gateway, dispatch events and other things. My main focus right now is how I should effectively handle errors from the gateway so people at least know why the bot crashed.
Should I handle the errors as the events happen or make use of the websocket error event
there are 3 layers of possible errors
the tcp layer, the websocket layer and the discord layer
typically your websocket library will handle the tcp layer internally, so you dont need to worry about that
but you need to handle the websocket layer and the discord layer separately
I assume the websocket layer & discord layer would be handled in the websocket.on('error')
the websocket layer includes the websocket error and close events (close can happen without errors)
for the discord layer, you need to check the close codes from the websocket
Gotcha, that makes sense
How does a error response from discord look like do you know?
close codes simply close the websocket, and the close event should give you the close code
Ah okay
there are some things that dont close the websocket, for example invalid session
those you will receive as an opcode instead
Yea, that makes sense
So I won't really need to worry about any error handling in the message event will I?
Or is it not safe to assume that if any error happens the error event will catch it?
from opcode 0 no, but you can receive other opcodes from the websocket message event, like invlid session
Oh so Iâd need to pass in virtualConsole: true?
from what i understand, the virtual console is already enabled by default
i dont think there is a way to force the virtual console to work synchronously
what you can do is follow the same strategy they recommend for loading async scripts for example
return the result from the script directly into the dom, and then get it from the dom
Ah okay. Ty!
this is what they have in their docs for loading async scripts
Ah I see. Ty thatâs super helpful đ
export const GatewayEventCloseCodes = Object.freeze({
4000: { message: 'Unknown Error', reconnect: true },
4001: { message: 'Unknown Opcode', reconnect: true },
4002: { message: 'Decode Error', reconnect: true },
4003: { message: 'Not Authenticated', reconnect: true },
4004: { message: 'Invalid Token', reconnect: false },
4005: { message: 'Already authenticated', reconnect: true },
4007: { message: 'Invalid Sequence', reconnect: true },
4008: { message: 'Rate Limit Exceeded', reconnect: true },
4009: { message: 'Session timed Out', reconnect: true },
4010: { message: 'Invalid Shard', reconnect: false },
4011: { message: 'Sharding Required', reconnect: false },
4012: { message: 'Invalid API Version', reconnect: false },
4013: { message: 'Invalid Intent(s)', reconnect: false },
4014: {
message:
'Disallowed Intent(s), please make sure you have enabled said privileged intent.',
reconnect: false,
},
});
let error = GatewayEventCloseCodes[data.code];
Can I not do this?
TS7053: Element implicitly has an 'any' type because expression of type 'any' can't be used to index type 'Readonly{ 4000: { message: string; reconnect: boolean; }; 4001: { message: string; reconnect: boolean; }; 4002: { message: string; reconnect: boolean; }; 4003: { message: string; reconnect: boolean; }; 4004: { message: string; reconnect: boolean; }; ... 8 more ...; 4014: { ...; }; }>'.
When doing something similar other places it doesn't cry about a type mismatch or whatever
data.code is a number btw
did you give a type to data.code?
yes
private _onError(data: { code: number }) {
let error = GatewayEventCloseCodes[data.code];
if (error.reconnect && this._sessionId) {
this._resumeConnection();
}
Promise.reject(new Error(error.message);)
}
you either need to change GatewayEventCloseClodes to a generic type like Record<number, { message:string, reconnect:boolean }> or you need to change data.code to 4000 | 4001 | 4002 | ... instead of number
hello friends, i am trying to edit a reply to a slash command after a user presses a button```js
client.on(interactionCreate, async interaction => {
interaction.update(hi);
});
```response: { message: 'Unknown interaction', code: 10062 }```
something else i tried was ```js
interaction.editReply(`hi`);
``` however this tells me: ```The reply to this interaction has not been sent or deferred.
any ideas?
discord.js v13
thanks in advance, please ping me if you know
you need to check if the interaction is a command afaik
actually I'm not sure
I don't use djs
wdym restarts the bot?
it crashes
a button
oh i think something just clicked.
well interaction.update updates the original message
and then crashes the bot and gives an error, even though it did what i wanted it to do
do you have multiple interactionCreate listeners?
you said you're editing the response from a slash command, where is the slash command code?
i've got this code in a separate file so i can make button pages without having to have it in each command, there would be multiple listeners but there should only be one in this example as i only used the command once
um... what
i mean
do you have more than one .on("interactionCreate") running?
if so, you need to isolate the interactions
because you cant run multiple codes for the same interaction, and you cant run button code on slash commands and slash code on buttons
i do not
well i do, but this one only gets buttons
how do you make it only get buttons?
if (!interaction.isButton()) return;
then please include that in the code you show
didn't realize it was related, my bad
can you show the full error that crashed your bot?
also await your promises
await interaction.update(...)
the error when using this is very very long
thats not a good reason to stop using it, in fact it helps create more problems and useless errors
it didn't click until just now that the listener for the actual commands would get the buttons too
thanks for your help
yeah all interactions come trough the same listeners
thats why it needs isolating with isButton, etc
one last question, how do i make it so the buttons don't expire after 3 seconds?
defer
what do i defer, exactly?
the original message? the bot's reply? the button interaction? i can't seem to figure it out
nvm got it
https://www.toptal.com/developers/hastebin/izikuzeyun.typescript
Other than working on events what else should I do to make this better/things I should add
i deleted my team
But in Creator it is showing
My development name
And saying I'm unauthorized
I have a general question of a challenge i am facing with mongodb with node.js. I want to be able to create documents rather quickly and auto increment a number per document. The issue i am facing when it concerns many users running commands at once the bot often will duplicate a document. Does anyone know work around for this?
Put all documents that will be created in a queue
with workers?
or
omg nvm i got it thanks
@earnest phoenix does node's crypto support rsa-sha256?
i need to verify a signature in emails
Although if you're talking about the main Crypto APIs rather than the Web Crypto APIs, it depends on the method
For ciphers, it depends on OpenSSL so you can see all the algorithms by running openssl list -cipher-algorithms
The hash algorithms depend on the available algorithms supported by the version of OpenSSL on the platform, which you can run openssl list -digest-algorithms to list them
For signatures and verification, the name of the signature algorithm can be used such as the one you just said, as pulled from the documentation:
In some cases, a
Signinstance can be created using the name of a signature algorithm, such as'RSA-SHA256', instead of a digest algorithm. This will use the corresponding digest algorithm. This does not work for all signature algorithms, such as'ecdsa-with-SHA256', so it is best to always use digest algorithm names.
lmao
Speaking of Java I have a programming contest in Java today in my CS class lmao
Yell "The floor is Java" in the contest, watch everyone lose their minds
I canât ruin my classmatesâ dreams, itâs the only language they know!
Itâs a way of life for them
java the hutt
tell them javascript is an improved version of java
How dare! They should learn something greater to achieve their mysterious dreams, something that doesn't involve /dir/dir/dir/dir/dir/dir/dir/dir/dir/dir/dir/dir/dir for something simple
Lol
package com.waffle.org.program.waffle.dev.tests.parser.waffle.com;
public static void volatile verbose package implicit casting transitioning const Main(String args[]) {}
Thank God it isn't!
I would rather make a game in pure LLVM IR than having that
make a gayme
I'll make you a gayme for you to become a gaymer
That reminds me of the old console wars where they gave the consoles a name of their own, PlayStation to GayStation, Xbox to Shitbox, and so on
pcmr > *
Lmao
Thereâs so many keywords in Java I didnât even know existed until I looked at standard lib code
Like transient
good luck, but it's not as useful as you'd think
you might end up with your emails not being received
that's fine
tho making it reliable isn't hard just keep it up
some services even resend email
the issue with email is that there is a massive safety infrastructure out there created to fight against spam and scam
and this infrastructure often involves trusted/safe ip addresses
so some systems might refuse to communicate with your server because its not part of its list of safe servers
people who work with email marketing for example, they explain how important it is to chose your email provider wisely when sending marketing campaigns
because using a less known service may lead to increased number of rejections
:c
I'm trying to send a POST request to a website, but since the website that is sending it uses ajax and I'm using NodeJS, I have to "convert" their request to axios. But when I send the request from NodeJS, the request is valid but data is null. I've copied the request headers of the website and tried around 15 different request in the same format, but data is returned null every time. I retyped the ajax request into dev tools on the website itself and the response works, but with axios it doesn't. What is the difference between an ajax request and axios itself?
ajax request:
$.ajax({ url: "./data/searchdata-test.php", type: "post", data: { 'anime': "a" }, dataType:"html" });
axios request:
axios.post(this.url + "/data/searchdata-test.php", { anime: "a" }, { responseType: "html" });
I'd also like to mention that I tried the standard fetch method in dev tools and get the same result as when I use axios in Node (data returns nothing/no response).
fetch request:
fetch('./data/searchdata-test.php', { method: 'POST', body: JSON.stringify({ anime: 'a' }), }).then(console.log)
idk if i can send it here but:
||removed||
they use an unofficial api
(imma delete the link in a sec)
manipulate in what way?


