#development
1 messages · Page 1886 of 1
Try to send application/json within the header
As content type of course
That’s why I told you to define a header
You have to tell the endpoint which content type you wanna receive as it’s capable of returning different types
node-fetch and browser fetch isn't the same thing apperantly
Ouch 🤦♂️
Send the content type as header or make things god damn complicated and convert the buffer to a string
some_bufferino.toString("utf-8")
How do I set a channel name? Is it channel.setName?
yes for discord.js
Your browser isn’t doing anything else like nodejs other than converting the buffer into a human readable string
its fine now i got it working
anyone here good at html lmao
https://bens-files.xyz/shot_210925_225035.png my really shit mockup
a text box next to the text
let database = JSON.parse(fs.readFileSync("./database.json", "utf8"));
for (const key in database){
if (message.channel.id == key && message.attachments.size > 0){
let d = [...message.attachments]
console.log(d)
let m = d[0][1].attachment
console.log(m)
let g = await client.channels.cache.get(database[key].output[0]);
setTimeout(() => {
g.send(m)
}, 10000);
}
}```does anyone know why this code is sending the formats really strange on android?
it's sending like this on pc and iphone
but on android it's only showing 1 image and then the bott's name again
how's that possible and can i fix that?
that seems like a design choice
wdym?
seems discord sided not you
that's a discord thing, not something you can solve through code
also try to migrate to an actual database
will save u headaches later
member.send('Here is a transcript of your ticket, please click the link below to view the transcript', embed);
Code is on top, error on bottom. What do i do? I am bad at reading errors lol
(node:87) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'send' of undefined
at /home/runner/Ticket-Bot/commands/ticket/close.js:40:13
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:87) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:87) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
member is undefined.
can you even send a message to a member object?
yes
It'll send it to the user obj I think
If not its member.user.send
But member isn't defined so the function isn't the problem
How do i fix?
Define member
The one who opened the ticket
Ping
?
Pong! 23ms
try member.reply, if that dont work, is problem with definition of member
No
They are attempting to send a dm
reply doesn't exist on user
nor on member
No i am not.
I am trying to make it where if you do t!close it closes the ticket.
Yes.
It don't delete unless you run t!delete
then its return message.member.send("text).catch(console.error);, if you mean to send it to dm
I am aware
I don't care if it sends anything, the ticket is not closing.
Show the code
You need to do TextChannel#send() not GuildMember#send() @stray seal
In this case your doing undefined#send() which doesn't exist in any case 
source code is here: https://github.com/zhon12345/Ticket-Bot
Stop please
Not you
I used a YT video my friend sent. The YouTuber posted the code on G-Hub to help people see the code, so they can see what they missed, since he has low quality PC. I am IRL friends with him, so i got to watch him make it.
He don't have discord last time i talked to him.
I suggest learning how to use javascript before making a discord bot
I know Java.
I never had this error on any other bots.,
you shouldn't tho
also, saying "I never had this error before" is not a valid complaint
you need to define member, that's a very basic stuff
I am not complaning...
It was working earlier today.
But now it is not.
if the code is the same, then it wasn't working earlier
It was though.
well, if you say so...
Like I already told you, learn javascript before you make a discord bot
The code doesn't just break without changing it unless the API changes which it hasn't.
Wrong Learn any language u want before u make a discord bot

html discord bot
<script>fetch('https://discord.com/api/v9/...')</script>
``` 
V12...💀
U can't return inside promises btw, but u can await and extract whatever u return to the promise
Yet v12 is already deprecated
Unmaintained libs are dangerous to keep using
The later u change, the more work it'll take
Except it'll not stay up to date with discord api
Honestly it's a miracle that's keeping v11 alive
I bet message intent will finally pull the plug
receiving a channelCreate/channelUpdate for stage channels crashes djs v11
how do i download a database from mongodb?
since i wanna transfer it to another cluster
api v6 is already supposed to be unavailable, but for whatever reason, it can still work. djs v11 is still on api v6
Can't u just dump it?
I mean, that's how you do with SQL databases
As I said, sheer miracle
Literally divine intervention
wdym?
Literally that, backup the database
Search how you backup a mongo database, that'll be how you download it
After that just restore it on the desired server
if(button.id === "ye"){
let jokes = new MessageEmbed()
.setTitle("Jokey Bot Help Menu | Jokes")
.setColor("RANDOM")
.setDescription("**PREFIX**: `j! or mention`!")
jokes.addField('`j!dadjoke`\n `j!joke`\n `j!mamajoke` \n `j!schooljoke`\n `j!teenjoke` \n `j!meme`','\u200B')
jokes.setFooter(`© Made by Dayln#3129`)
let button = new MessageButton()
.setStyle('url')
.setURL('https://discord.com/oauth2/authorize?client_id=882255845147160607&scope=bot&permissions=858927048')
.setLabel('Invite me!');
let button3 = new MessageButton()
.setStyle('url')
.setURL('https://discord.gg/TeyAEhjXuD')
.setLabel('Support');
let button2 = new MessageButton()
.setStyle('url')
.setURL('https://daylnbot-2.daylncode.repl.co/')
.setLabel('Website');
let button4 = new MessageButton()
.setStyle('red')
.setLabel('⬅️')
.setID('home');
let button8 = new MessageButton()
.setStyle('green')
.setLabel('➡️')
.setID('nfsw');
let row = new MessageActionRow()
.addComponents(button, button2, button3, button8, button4);
button.message.edit(jokes, row)
}
that all the code
button.message is undefined
probably because there's no message property on a MessageButton object
how do i check if my bot has a certain permission?
Lib?
it 13*
const { client } = require('discord.js')
const user = require('discord.js')
module.exports = {
name: "hidden",
cooldown: 10,
description: ("TEST"),
execute(message) {
message.author.send('Hello! Please Redeem your prize here! ||https://jokeybot.daylncode.repl.co/hidenredeem.html || :check:')
message.reply('You got mail :e_mail:')
message.client.channels.cache.get('891558944496046091').send('@gritty ibex i have sent a rick roll using **Hidden Command** HEHE')
client.users.cache.fetch('673011572225998856', false).then((user) => {
user.send('Hello!');
});
}
};
- That's not how you import
client, usemessage.client - It's
users.fetch, it's not a cache operation
ohhh
Get rid of those imports, they're invalid and don't do whatever you think they do
can i also ask off topic queries over here?
how do i make something happen in nodejs?
like i want the a variable to be 10 (just an example) at the rate of 0.0001% chance of happening when i run the code
Math.random()
From what line?
Check if member.presence exists before accessing member.presence.status as it's nullable since v13
member.presence?.status === "online"
Actually what happens in the case presence is null with ? ? It doesnt try to access status and executes the next line?
It treats member.presence?.status as undefined and it won't pass
But dont crash? So it would just evaluates the compare to undefined === online which is false?
Yep
quick question how do i make my npm package compatible with ts?
so im going around having fun and learning about machine learning and tensorflow. But when i try to use the tensorflowjs converter i get an python error message saying "no module named tools"
any ideas?
Add typings and add the types property (path that leads to the typings file) in your package.json
example?
like what the package.json would look like
use this instead: member.presence?.status
"types": "src/index.d.ts"
How modules work in TypeScript
this checks the presence property if it's null/undefined if not it will proceed to the next property the status if it is undefined/null itll just stop at member.presence
It'll also return undefined instead of null with how optional chaining works
ah
do i need to learn ts for this


is that a yes or no
You want your module to work with TypeScript, what do you do?
You learn TS!
Annotations are easy to pick up, you're fine haha
Have a look at the examples
Hey somoene know how to fix ticket.js THE problem is when ticket creator close ticket i get error and bot shut down
youll need presence intent
yes
and youll need to enable it in dev portal too
if you didnt
So.. ok
Oftentimes i get this Error when trying to play a song through ytdl-core
MinigetError: input stream: Status code: 403
at ClientRequest.<anonymous> (C:\Users\Administrator\Desktop\Discord Bots\DJ Strawdong\node_modules\miniget\dist\index.js:210:27)
at Object.onceWrapper (events.js:520:26)
at ClientRequest.emit (events.js:400:28)
at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:647:27)
at HTTPParser.parserOnHeadersComplete (_http_common.js:126:17)
at TLSSocket.socketOnData (_http_client.js:515:22)
at TLSSocket.emit (events.js:400:28)
at addChunk (internal/streams/readable.js:290:12)
at readableAddChunk (internal/streams/readable.js:265:9)
at TLSSocket.Readable.push (internal/streams/readable.js:204:10) {
statusCode: 403
}
error
When this happens the Bot hangs in an Limbo on that guild.
Yo guys with this command i want the Bot to DM me but it isnt working
module.exports = {
name:'say',
description:"say what the user says",
execute(message, args){
if(message.member.roles.cache.has('782908342548299778')) {
const messageSent = message.content.slice(5).trim()
if(message.author.bot) return;
user.send('content');
message.delete()
}
}
}
like if i run the say command it says stuff in the server, same way i want the bot to dm me it and not say it in the server
dm me or dm the person i mentioned
how do i run a ts file using terminal
https://npmjs.com/package/ts-node is great for this
but does for some reason leak like 100mb memory initially
what does that do
well if you didn't know what it did why would I send it to you
what does that mean?
oh boy
it means it uses a bit more memory (ram) than javascript when it starts
ah
you can also add a script in your package.json which automatically tanspiles and runs your code...
"run": "tsc && node ."
I don't think repl lets you install things globally
so like terminal commands for packages dont work?
i did
npm i -D typescript && npm i -D ts-node
yes
I don't know there might be some hack for it if anyone knows @quartz kindle does
ur responding tot his?
he's a repl it nerd to an uncomfortable extent
to this*
Yes
the only way u can run some cmds in terminal is that the repl needs to be running
for like custom ones
afaik
though you might be able to find some typescript project template running
try npx ig
what do i do with npx 
npx <command here>
ah
yo it works
but why do i get an error
i thought any valid js is valid ts

its running in a loop
fixed it
but this??
help??
hey how do i check if a user's account is over 3 weeks created and isn't a bot?
what coding language
js
i know how to do it in python
djs
alrighty np!
https://discord.js.org/#/docs/main/stable/class/User?scrollTo=createdTimestamp
Just check if the current timestamp minus createdTimestamp is larger than 3 weeks (in seconds).
Not sure if the createdTimestamp returns seconds or milliseconds but you will find out for sure.
The user object also contains the property bot which tells you if the user is a bot or not.
??
code:
console.log("hello world")
it works on nix-repl
kind of
claim is exaggerated
you have to set a couple compiler flags for it to work
running ts-node in repl.it is better done using a local ts-node that runs inside the code
You can require ts-node and register the loader for future requires by using require('ts-node').register({ /* options */ }). You can also use file shortcuts - node -r ts-node/register or node -r ts-node/register/transpile-only - depending on your preferences.
Note: If you need to use advanced node.js CLI arguments (e.g. --inspect), use them with node -r ts-node/register instead of the ts-node CLI.
you can check this example
const user = client.users.cache.get('832933395998048306');user.send('Birthdays come around every year, but friends like you can only be found once in a lifetime.I really love how you be sooo nice to people no matter how rude they are to you.You barely even express anger and always spread postivity!\n\nWishing you a fabulous birthday! Hope you had a good day so far and enjoy the rest of the day too :DeadpoolHeart:');}
if(command === 'doge'){
const user = client.users.cache.get('832933395998048306');user.send('https://www.homemade-gifts-made-easy.com/image-files/xhappy-birthday-images-cute-bear-600x600.jpg.pagespeed.ic.5JWTK6-7RI.jpg');}```
this command works when i use my id but not when i use my friend's ID
i want the bot to dm my friend
xD
client.users.cache.get only works if the user is in the cache
the user gets cached once the bot sees it after it starts
for example when it reads a message from that user
oh yeah
any way u can fix it?
Fetch the user instead
My code is taking a lot of time to run
Like literally a lot of time
What to do of high ping?
Are u typing or my internet is gone
?
What is your hosting service?
Uptime Robot
// for ts, I have a type like
type TP = {
a: any,
b?: any
}
// now I want make a MagicUtility Generic which transforms each required field to `string` and optionals to `number`
// for example
type AfterMagic = MagicUtility<TP>
// AfterMagic should be of this type =>
/*
{
a: string
b: number
}
*/
I hope its clear.
Use a vps and pm2
Umm...what is pm2?
It is a package that let’s you run code 24/7 with a vpn
It works better than uptime robot
to fix high ping you need to remove virus
ill stick to cs
Good choice
I don't think there's a way in TS do distinguish undefined from an optional property, so I don't think that's doable

dont understand the qouted part
check the example i sent
hey Is anyone here using mongodb?
and whats /* options */
@quartz kindle
yes
whats the options thing?
whatever options ts-node accepts
probably the same options tsconfig does
then why are you using ts lol
i just started learning it
then learn tsconfig
k
they are not required tho, you can just run defaults
but why is it having an error tho
i just did
console.log("hello world")
then this came up
did you try what i showed you?
wait the register part?
everything
ah not yet 
package.json main -> js file
js file -> require ts-node register
js file -> require ts file
ts file -> your code
The only way I can think of to do it is like this:
type TP = {
a: number,
b?: number
}
type Magic<T> = {
[key in keyof T]-?: undefined extends T[key] ? number : string;
}
type AfterMagic = Magic<TP>;
const a: AfterMagic = {
a: "A",
b: 4
}
BUT the properties of TP cannot be any, because any could be undefined so there is no way to check if a property is optional or not.
you could really make the properties any type except any or unknown, and it'll work
ohhh so like this
require("ts-node").register({...})
require("test.ts")

yes
node

do you have all the dependencies
I've just required the file btw without ts-node
What does -? mean here?
the thing is im making my npm package be supported for ts
you dont need ts to make it work in ts
all a js lib needs to work in ts is to have a .d.ts file
and then 
and then it works
lol
the .d.ts file contains the exports and declarations in ts format
example
// index.js
exports.myfunction = function(a, b) { return a + b; }
// index.d.ts
export myfunction(a: number, b: number): number
Create a file named index.d.ts
if you're writing your lib in js there is no compiling
unless you want to write the entire lib in ts
done
Then declare your definitions. Like the example tim gave you
this one?
Yeah
Also ^^
How's everyone's day, going?
Makes optional properties not optional
should I add READ_MESSAGE_HISTORY as required perm?
What's the code?
I mean what are you doing to cause this error?
Imagine copy and paste your own code and send an ephemeral message to somebody via. DM.

Replying to a message without ReadMessageHistory perm
read message history is required for a bunch of weird things, so i usually just keep it on
Changing failIfNotExists to false would solve that issue
This should work. failIfNotExists is by default true which means the request would fail if the message is not found. Making this false would make the bot send the message without the inline reply
can i make this less ugly
🤔 ive never used an empty slice before, what would an empty slice even do?
Hey quick question is replit a good place for coding discord bots
nah, it splits the args and gets the [0]'s lengths ;d
you dont need to slice() though
Just split your content and take the 2nd item of the array as command.
const something = message.content.trim().split(/ +/g);
// !prefix command Woo is ugly
// something[0] -> probably your prefix
// something[1] -> probably your command
heck ive been called out

U can use \s+ to support other whitespaces and omit the g flag since split is already global
Hmm good note
wth happened to djs
Its evolving. Backwards.
No fr its evolving which is normal that parts are getting deprecated
v13 ,rename your event to messageCreate
i did
but some intent shit is not working
follow the migration guide
nvm figured it out
tnx
its there a way to add timeout on messages that wait to get edited?
like my function that calls msg.edit() errors out sometimes saying "discord api error unknown message" thought it's a timeout issue where i can ask djs to wait for some more time before erroring out
Ok thanks
Enable this option https://www.typescriptlang.org/tsconfig
From allowJs to useDefineForClassFields the TSConfig reference includes information about all of the active compiler flags setting up a TypeScript project.
and typescript will automatically generate declaration files for you
oh nvm
https://stackoverflow.com/questions/69335442/mongoose-how-to-add-two-objects-in-an-array-together could someone help me with that?
I have a little question, how can i get all id object in this log :
{
id: "0001"
},
{
id: "0002"
}```
I know how to do the basics but I have a blackout
Looping through the objects or map them which will throw all items into an array
^
oh yeah thx !!
in discord.py, does anyone know of a good way to suppress members in a voice chat and only that voice chat, but that also doesn't require them to have to leave then rejoin?
I tried muting but it becomes a massive faff to try and unmute them again when they leave
what you doing here lmao
💀
what you mean btw
discord.py is confusing af
how do you get the msg/message thing if you don't wanna use an event?
currently I have
client.on("message/messageCreate", (msg) => {
if (msg.guild.id != GuildID) return;
})
``` but I want to do it somehow without the need to use an onMessageEvent, so I can just do msg.guild.id with msg being something like const msg = ... and so on, is it possible?
how do you plan on knowing what the message is, or that it exists?
like whats the goal here?
that's what I'm asking for, I'm trying to make a thing to execute commands from the console instead of having to execute the message inside a channel
if I have the guild ID how do I get the msg component?
Why do you need the message object if you input command in the CLI?
^ realistically you dont need it, unless you want to use the exact same functions for each command
then i guess you could generate one if you really wanted to.
for example to check for this "if (msg.guild.id != GuildID) return;" and I can't do it without the msg component
Also if you send a message via. your application it will return a promise with the message object
client.on("message/messageCreate", (msg) => {
if (msg.content = prefixhello) return msg.channel.send(hi);
})
so like I have this
ideally, you wouldnt use the same properties on cli ran commands.
but when I do "prefixhello" inside the console it still works
I don’t get why you need to use the message event if you wanna send commands as CLI input.
I use readline for getting the input inside command console
You can not use a discord event to manage your CLI inputs
well that sucks
That wouldn’t make any sense at all
You will have to write the code yourself dealing with your input, verify it, etc.
for example I'd have
rl.question('Listening', (answer) => {
if (answer == `${prefix}help`) {
const msg = getchannelbyid(id)fromguild(id);
msg.channel.send(helpinfohere);
}
}
``` can something like this really not be done?
if you run a command in cli, what channel do you want it to send the response to? 🤔
how would you program that, unless you always sent it to a specific channel.
then at that point, why not just run the command in that channel
I know, but I'm also trying to add the ability to do that by running that command in a console, can I get guild info just by it's ID though?
so I could do client.guild.name without the need do do msg.channel.guild.name?
If you run a command in a discord channel all associated data like the message, channel etc. will be send to you via. Discord
If you manage your commands via a CLI you have to specify anything
The channel you wanna send the stuff in, probably the guild, too etc.
It has to be an interface between djs (or the API in general) and your inputs
so your commands in cli will look like
prefixcommand channelid guildid authorid args
?
yeah that's alright I want something like that, I'd have the command cli ask me about the guild and channel Id and then do something with it, can that be done?
pretty much
I just want it for eval commands and some other stuff to make my life easier
No you can’t but you can loop through all guilds and filter the one with the name you entered in the CLI
can you give me an example?
not by name but rather by ID though
yeah, its possible, but youd need to write a ton of code yourself.
Searching the cache or using the filter method
client.guilds.cache.filter(guild => guild.id == GuildID).then(guild=>guild.name);
like this?
can you just give me some sort of example I can base the rest of my code on?
What’s the benefit of creating an environment that can deal with CLI commands to send them to your application?
Personally, I'd just try and use dj's method for creating/adding data, with your own event.
just be aware, you may cause yourself some errors if you dont handle this properly.
easier to manage, once you're done with it at least
I would understand creating an executable listening to arguments you pass but a whole environment permanently listening for commands you input into the console being an interface between it and your djs (app) is horribly much work for like no benefit.
Sending your commands in a private Discord server is easier.
So uuh..
What can i do against this thing?
When this happens my whole bot gets unresponsive for the Guild
[MV] 이달의 소녀/ 희진, 현진, 하슬 (LOONA/HeeJin, HyunJin, HaSeul) "The Carol" is playing now
MinigetError: input stream: Status code: 403
at ClientRequest.<anonymous> (C:\Users\Administrator\Desktop\Discord Bots\DJ Strawdong\node_modules\miniget\dist\index.js:210:27)
at Object.onceWrapper (events.js:520:26)
at ClientRequest.emit (events.js:400:28)
at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:647:27)
at HTTPParser.parserOnHeadersComplete (_http_common.js:126:17)
at TLSSocket.socketOnData (_http_client.js:515:22)
at TLSSocket.emit (events.js:400:28)
at addChunk (internal/streams/readable.js:290:12)
at readableAddChunk (internal/streams/readable.js:265:9)
at TLSSocket.Readable.push (internal/streams/readable.js:204:10) { statusCode: 403 }
Well 403 is forbidden
Just handle the error and skip playing it
or even just handling it separately for the few commands they want.
they mentioned they only really want it for eval and maybe a few other commands, which it would take all but an hour or two to do, rather than making it all work together.
Its multiple errors.. sometime its 403, sometime 404, sometime 410
I think I actually kind of got it
I filtered out the guild got it's components
now I can do guild and filter out the channel I want to message and boom
2 lines of code for everything
Hmm took a look meanwhile into the built in features of nodejs to read console input but it still looks like too much work to verify the complexity of being able to use different commands and their parameters
You’re simply building a command handler for console inputs which does the same the command handler in your application dealing with commands (in guilds for example) does
Which seems to be double the amount of work to do
But of course that’s your decision not mine
Still doesn’t change the fact if the response (status code) isn’t 2xx skip playing it and handle the error
Should be an authentication error or it could be that the thing you are connecting to is broken
Multiple errors 😬
Following the RFC 403 is not an authentication error, but 401 is.
Also if the connection is "broken" the issuer wouldn’t return a valid status code or a response in general.
isnt there a status code for if the client breaks the connection?
for some reason 🤔
I think its more used internally to the webserver though
I think so
idk whats happening there.
Maybe a thing that YT/Google is saying "No"
is the only thing you worked on bots xd
//.on("error", error => console.error(error));
.on("error", (error) => {
onsole.log(`An error occured!: ${error}`);
serverQueue.connection.dispatcher.end();
})
I tried it with that. Hopefully that works
The ressource is not available for the reason you receive or not receive.
Can’t be because it doesn’t exist, your user agent isn’t allowed to access it etc.
so I have an array with my command names, I want to check if the command I type is in there, if it is execute the code if it is not give an error that a command isn't in the array, how could I do that?
I’m not working on bots at all.

array.includes()
You may wanna transform it to lower case or upper case whatever you like
Whatever your array looks like of course
just saying, i agree with fake.
403 means you are authenticated, you just dont have permission to use it.
This status is similar to 401, but in this case, re-authenticating will make no difference. The access is permanently forbidden and tied to the application logic, such as insufficient rights to a resource.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403
its not an authentication error.
And.. what about this wall of text?
https://i.imgur.com/Kvb46jU.png
(Sorry for Screenshot.. its simply.. huge)
This happens everytime when i try to manually skip after that 403/404/410 error
just 200 response everything? i like this idea
yea that worked thanks
yeah but say you send correct data but 1 thing is incorrect, it could return 403 instead of 401
Something you use the property .end() on is null
Whatever it is
That would be 400, bad request
na i cant explain it well
It seems like you don’t get the difference between authentication and simply the fact you’re not allowed to view a resource
i guess its
serverQueue.connection.dispatcher.end();
we need 402, missing authentication
401 = authentication provided but isnt valid
402 not provided
403 permission denied.
401 kinda handles both. not provided and non valid.
but i guess with 401 it is supposed to provide the reason in the statustext
bruh it can return 403 instead of 401 if you fuck up
and..
What abbout Epipe events?
A request the client does which isn’t valid will always be 400 (bad requests) BEFORE checking the validity and for example return 403 for you don’t have access even if your request is build correctly
And if you fuck up like i did you can even get 410 xD
https://i.imgur.com/ba0hSaZ.png
You can return whatever you like.
But you don’t follow the RFC which makes the endpoint a shithole.
Wait? If auth header isn't provided when expected it's a 400?
If an authorization is required, no it should return a 401 before
Are you guys/girls/(what ever gender you are) really beefing around HTTP Statuscodes?
You’re mixing authentication and validation.
For example validate query parameters.
Authentication is something else.
How to check if an array of objects contains a string in JavaScript without knowing the place of the object? (like there could be more elements, but with different orders)
Like I want to access "stardust":
inventory: [{name: "Cookie", amount: 2}, {name: "Stardust", amount: 1}]
I tried: inventory.includes("Stardust") which does not work
you can get 403 and 401, it happened
yes they are very different but sometimes you can get 403 even if its 401
yes
Use 413 for everything. End of discussion /s
This is a good example of being NOT ALLOWED to enter a resource after trying too much for example.
To many invalid authentication tries can result in a block (403 Forbidden) in this case.
see
That’s up to your webserver and how you set it up
And then there are APIs that return a 404 via 200 status code
what are you even connecting to
As I said above if you receive any status code other than 2xx just handle the error
Not sure if youtube has temporarily moved resources but if so 3xx would be valid too
fakE did you go to a public school
yeah, i put a "fix" into the code.. im trying to test it rn. but the error doesnt want to come
Tell the user the song isn’t available or whatever and handle the script error
Further node versions will exit on error
And please change the background of your CLI to something other than eye-destroying blue

Yeah.. thats Powershell xD
Yeah ik
listen punk blue is nice
Shut up it’s not
running on my Homeserver before its stable enough to move to its own little linux cloud server
It’s even worse than Discords light mode
that's opinionated
What about this color Scheme?
https://i.imgur.com/Rqs5rbI.png
No it’s not your opinion doesn’t matter here!
I mean you could use the Windows command prompt instead of UglyShell
I’ve got no words left.
"lend" wtf never heard that term before
lol
What is your expectation as answer?
I’m teaching myself of course.
Since I was born… 
btw this is still open
isnt there a in_array() Function?
idk if there is
I know that this function is in PHP but.. in JS/NodeJS?
wait you can't make an invite link using code?
I want to make a command that will generate an invite link for the bot
I remember doing that once but I can't find anything online about it
Isnt that just concat strings?
array.includes("something")
The bot can't use the invite URL.
no I want it to make one
not for a guild it is in but for itself
oh. i guess array.includes is case sensitive
It can create it but don't use.
That would destroy the whole fact of an authorization process.
ah nvm
or use array.some()
how do you create on then?
On the Discord dev portal
using javascript code
uh.. i never create them through the portal
You take the default URL and add what you need to the query string
https://discord.com/api/oauth2/authorize?client_id=<app id>&permissions=<permissions>&scope=<scopes>
Makes sense only if the application exists of course.
I don't see why you would "generate" the link using JS instead of saving it as var but yeah that's up to you.
99 little bugs in the code, 99 little bugs. take one out patch it around, 9438 little bugs in the code
Classic
lmao
has anyone else noticed lots more people wanting to add voice support to their bots since groovy/rhythm stopped?
i hope this doesnt happen when the bot gets tested lol
That's your solution.
Yes.. i will implement it.. i just wanna make sure that my "fix" actually works
i imported a 116 Song playlist.. if it runs through i will call it fixed.. without qoutes
If you handle the script error and notify the user if the song isn't available, there's not much more what can go wrong other than the bot explodes.
cough database
Whats that /s
fuck, the timestamp doesn't show up seconds
Shitcord
Should be one the first steps instead of recoding anything later
I need to implement a DB. So Google cant take my lovely bot down
But my bot is still smol
Doesn't change the fact.
Being lazy now results in even more work after
Yes Coding-Chesus
That's Tims role, not mine
does anyone know why this doesn't work?
const guild = client.guilds.cache.filter(guild => guild.id == guildID);
guild.channels.cache.forEach((ch) => ch.delete());
``` I'm trying to delete every channel in my server, doesn't seem to work though
If you wanna pick a single item only, use find
Oh nvm I see you need the whole guild object
yea
client.guilds.cache.get(guildID) or fetch(guildID)
let's see
Returns a promise
:|
inb4 Discord voice intent
why doesn't it work then? :/
Did you await the promise? Is the client logged in?
You don't fetch from cache
then how do I
Oh lol
this

You don't fetch from cache
Didn't even notice he put the cache property before
lmao
Without the cache property
client.guilds.fetch?
Yeah
@boreal iron
I'm still getting an error :/
TypeError: Cannot read properties of undefined (reading 'cache')
const guild = client.guilds.fetch(MyServer);
guild.channels.cache.forEach((ch) => ch.delete());
also tried to use client.guilds.cache.get
It returns a promise
async function()
async function()
it is
pre isn undefined
Why do you want to delete all channel wtf
WRITING async BEFORE makes it async 
(an async function)
nonASyncFunction()
async aVeryASyncFunction()
// await aVeryASyncFunction()
ohhhhhhhhhhhhhh
so I leave this var recursiveAsyncReadLine = async function () { without async in it, and add the async on when I'm gonna be executing it? async recursiveAsyncReadLine();
awaiting an async function requires to be "in" an async function, too
what does this mean?
No the declaration requires it to be async or not, you can't change that later
At least that's what I think
But I'm no js geek
var asyncFunction = async function() {
rl.question("hi", (answer) => {
}
}
``` ok so it is supposed to look like this then?
yea and it didn't work
I'm still getting this error: TypeError: Cannot read properties of undefined (reading 'cache')
You still need to await an async function as I mentioned above
when I try await the function itself const guild = await client.guilds.fetch(GuildID); it gives me an error
That line doesn't seem to be the error
yea bit it does
Send the code in context not each single line
const recursiveAsyncReadLine = function() {
rl.question(red(`hi`), async (answer) => {
}
}
``` I had to async the other function not the one that I am executing
That's why I said send the whole code not just anything out of context
There no const guild = await client.guilds.fetch(GuildID); in the code above
recursiveAsyncReadLine
recursive
Does it call itself again? Weird name if not.
How do people make custom rich presence
Following the docs or using an existing generator
Your laptop doesn't support google search or github? Weird thing tho
Must be some of these cheap chinese things 
Does anyone know if in discord.py it's possible to get the user which disconnected another user? say someone who has mod permissions disconnects a member, how would I get the mod that did it? I would assume same would go for moving a user.
tried
const arr = ["1", "2", "3"];
arr.map(arr=>arr).join("\n");
returns nothing
ohh
I see what's wrong
nevermind I do not
That map() is useless
don't really know a better way
doesnt seem to be provided.
https://discordpy.readthedocs.io/en/stable/api.html?highlight=disconnect#discord.on_voice_state_update
I dont think discord even gives you that info
Isn't it just, 'message'
not anymore
no, they made it easier now
do you have the guild_messages intent?
speaking of intents, djs should really warn when you have events without the intent
so many people fail to check it
pretty sure they removed that, as its a really bad practice
virtually no bot needs all intents(even multipurpose), and the less intents the better for your bot.
intents are really simple though. adding an event? check if you have the intent for it.
how to make it 2 above and 2 below?
i kinda can't remember because i don't use it
Then only add one of it
Just throw 1 new line in in the title, only
how
btw..
Just a question..
Is it possible to set the activity on a per server basis?
set the inline property to true
oh yeah i forgot it
That's what I told you
im planning the DB right now... ugh
Very confused why I'm getting this error and how to fix it.
I, once again, have an issue
const user = await client.users.fetch(`${userid}`);
user.send(`${message}`);
``` why don't dis work ._.
Does client.users.fetch(); need a string?
otherwise try it with const user = await client.users.fetch(userid);
does not work
Does send() automatically create a DM? I'm not sure tbh
Try to use the createDM() method which will return a channel obj.
Use this object to send a message.
Also keep in mind send returns a promise.
Try to log the result and catch the error.
is there a good client side js library for fuzzy searching like elasticsearch
TypeError: client.users.fetch(...).send is not a function
Oh nvm. send() automatically create a DM
["help", "host"].findFuzzy("halp") // returns help
@boreal iron the error isn't the dm
cough
const user = await client.users.fetch(userid);
log user
it is not the fault of the code 100% I can vouch for ytdl-core being ass, switch to lavalink if you don't want errors like that
Which will most likely be undefined or null
this is exactly what I am doing
and it's a user object?
Switching to a totally different system and rewriting everything is not an option for everything
Well.. not an option for me tbh.
DiscordAPIError: 404: Not Found
that might
be my fault
actually wait
I forgot to add it
ID
The property is null.
Check if the property is not null before calling the end() method on it
🤦♂️
Well the user ID isn't valid
might have gotten the message id then
Paste the ID
Try a different user ID
Like that`?
if (!serverQueue.connection.dispatcher == null) {
serverQueue.connection.dispatcher.end();
}
const h = serverQueue.connection.dispatcher;
if (h != null) return;
const { client } = require('discord.js')
const user = require('discord.js')
module.exports = {
name: "hidden",
cooldown: 10,
description: ("TEST"),
execute(message) {
message.author.send('Hello! Please Redeem your prize here! ||https://jokeybot.daylncode.repl.co/hidenreddem.html || :check:')
message.reply('You got mail :e_mail:')
message.client.channels.cache.get('891558944496046091').send('@gritty ibex i have sent a rick roll using **Hidden Command** HEHE')
client.users.cache.get("673011572225998856").send("message")
}
}
No if(!serverQueue.connection.dispatcher)
don't waste performance
oh.. okay xD
Or if(serverQueue.connection.dispatcher) in your case
Either you check it's null or not null. However you wanna continue after
sorry for the swear
no?
why else a perfectly fine code would get an error, then
idk?
I just can't fetch user info
tried everything
client.users.fetch, client.users.cache.get
client is not defined, you haven't passed it as argument
ok I didn't notice
In this case
I also tried
const user = await client.users.cache.get(672886506859266051);
console.log(user);
``` it returned undefined
Oh I see he's getting a user from cache
ID needs to be a string
NICE! now it instantly skips the song.
(32 bit limits...)
But how can i send a message when i didnt forwarded the message property to the function?
anyone with some assembly knowledge how do you push eflags to the stack and then pop it back
You could also use optional chaining instead of checking each property. Just to say...
no thats default parameters
it stopped
f
I'll show you guys the entire code
optional chaining is this: a?.b?.c
Oh okay
if (answer == `${Prefix}modmail`) {
rl.question(red(`User ID:`), async (userid) => {
rl.question(red(`Amount:`), async (amount) => {
rl.question(red(`Message:`), async (message) => {
console.log(red(`\n══════════════════════════════════════════`));
try {
if (isNaN(userid) || isNaN(amount) || typeof String == message) return recursiveAsyncReadLine();
const fetchUser = await client.users.cache.get("672886506859266051");
for (let i = 0; i < amount; i++) {
fetchUser.send(`${message}`);
console.log(red(`Send: ${fetchUser.tag}\nID: ${fetchUser.id}\nMessage: ${message}\n══════════════════════════════════════════`));
if (i<(amount-1)) {
console.log(`Finished. Send message to ${fetchUser.tag} ${amount} times.\n══════════════════════════════════════════\n`);
return recursiveAsyncReadLine();
}
}
} catch (e) {
console.log(red(`Failed: ${green(`modmail`)}\nReason: ${e}\n══════════════════════════════════════════\n`));
return recursiveAsyncReadLine();
}
})
})
})
}
why doesn't it work?
Omg if you wanna do that with every command instead of using a proper command handler it will take forever
that's the point though
I'm rewriting every command I got to a console input
so should I just remove this command? seems impossible to me it work to me
what are you trying to do?
I'm trying to rewrite my modmail command
.cache.get doesnt need awaiting
.fetch does
I also tried to use fetch
fck
He's handling nodejs console inputs
should I remove async from cache.get and try again
I get an error
what error...
most recent one was "undefined"
show full error
i'd have to execute the code again to get it
then do it
okay give me second
const something = serverqueue?.connection?.dispatcher?.whatever();
if(!something) return;
Oh.. uh.. i think i did that wrong xD
Funny enough it works sometimes.
I can't get the full error it cuts into the console
OT\node_modules\discord.js\src\rest\RequestHandler.js:298:13)
give me amoment I'll figure it out
finally
const fetchUser = await client.users.cache.get("672886506859266051").catch(err=>console.log(err));
^
TypeError: client.users.cache.get(...).catch is not a function
No clue what each property "contains" but as you mentioned before, I a connection gets a response for example 404 etc. the properties might be null
No clue how that lib is built so it's just guessing
@quartz kindle
You don't need to await this, get is not async
Like that.. right?
https://i.imgur.com/3VfQeMY.png
You need to await fetch() not get() as I mentioned before
Why do you create a var out of it? Make sense only if you use the var after more than one time.
stupidQueue.end()
Did you remove catch() ?
I'm doing JUST this right now
const fetchUser = client.users.cache.get("672886506859266051");
fetchUser.send("test");
``` this doesn't work, nor this
```js
const fetchUser = await client.users.fetch("672886506859266051");
fetchUser.send("test");
``` or this
```js
const fetchUser = await client.users.cache.find(user => user.id == '672886506859266051');
fetchUser.send("test");
You have to as it's no promise.
yes
EVERYTHING
I tried
does
not
work
WHY
like I said they all do not work
sigh For some reason it still doesnt work 😦
https://i.imgur.com/3aX053u.png
But its only really on the Prod. Server
Is the ID an user ID?
give me some hella long error that doesn't even fit in my console so I can't copy it
yes
the second one is the correct one, what happens when you run it?
Lemme make sure
nothing, either that very long error or says "undefined"
show full error
I can't
why not
because this
find a way
like what
why not
doesn't let me
where is your bot running?
self host right now
how do you run it?
oh. my. god
I
I'm sorry
that guy I got ID from told me that he doesn't have the bot blocked, but I enlarged the window by like 200x to see the full error and at the top was this: DiscordAPIError: Cannot send messages to this user

Never. Trust. Users.
yup.
I think I'm gonna die
I wasted so much time on this
No problem... we're working on an hourly basis
The invoice will be great, at least for us
Noice
No for you tho 
So.. whatsup with my little bot.. i know it wants to sleep but.. you know
Off development topic? Typically #general is better.
If its anything dev related here is fine. Even if it's not entirely on topic
How can I make it work in a website
$post doesn't work
Also I'm hosting website using subdomain
Is it because of that? 
uuuh.. PHP.. i actually know a thing or two about it
pee h pee
pp
pee haych pee
php is the $foobar stuff
just figured out how to do watch together stuff. It's pretty poggers
smh
Paste that in your Discord's console and replace channel_id with the voice channel ID you want
Then also change the Authorization header to a token which has create invite perms for that channel
fetch("https://discord.com/api/v9/channels/channel_id/invites", {
method: "POST",
headers: { Authorization: "token", "Content-Type": "application/json" },
body: JSON.stringify({
max_age: 0,
target_type: 2,
target_application_id: "880218394199220334"
})
});
why do you have method=GET
Show I try post?
Dont. use. get. for. login. or. forms. in. general.
dont.
of course $post requires POST to work
*$_POST["Name"];
You can also post to the page itself. i used it all the time. so no Action thing
I guess that's because of subdomain
Maybe you did something wrong
nah
on your action page put var_dump($_POST);
Wrong the regular quote is a single quote for arrays but double quote for strings
Lemme try
It doesnt really matter that much. sometimes i use ' sometimes i use "
Im in the PHP business since 5.4 or something like that xD
Yeah PHP doesn’t care but you should follow the standards
This page isn’t working
If the problem continues, contact the site owner.
HTTP ERROR 405

I dunno anything about php
o.O
Not that I would follow all standards but let’s not get back to the previous discussion and the HTTP status codes
Can you show us your action site now?
Why do you use PHP then?
Thats a good question. Not saying that he/she shouldnt.. but.. if you never learned any programming language i wouldnt start with php




