#development
1 messages · Page 2 of 1
so youre looking for a specific 429 that is on the /gateway/bot route
because all other 429s are not a problen
in most cases the gateway rate limit happens when trying to login, so it should be caught by the error generated by client.login
probably yes
is 1 the actual pid of the shell process? or is it just a shortcut for "this shell"?
because process.kill will likely need the actual pid
Is that a webhook message?
I doubt it is.
Slash commands route through webhooks and as such, you can embed links in text without wrapping them in message embeds
Everything webhooks can do, slash commands can do
slash commands can do text like that
not regular bot messages tho 
embeds can too
i use it on my bot
[words here](https://something.com)
How do I convert a timestamp with format yyyy-MM-dd'T'HH:mm:ss.SSS'Z' to Unix/Epach
doesn't new Date() allow inputting a string?
Yeah testing rn
Works ty
Found out on answer from https://stackoverflow.com/questions/11893083/convert-normal-date-to-unix-timestamp
How can I convert normal date 2012.08.10 to unix timestamp in javascript?
Fiddle: http://jsfiddle.net/J2pWj/
I've seen many posts here that convert it in PHP, Ruby, etc... But I need to do this i...
When i make a post request to /users/@me/channels with a recipient id, it tell me that bots cannot use this endpoint, i used this since 1 year, anyone know what is the new endpoint to send a message trough api ?
yes
const createChannelRequest = await fetch(`https://discord.com/api/v10/users/@me/channels`, {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'Authorization': `Bot ${token}` },
body: JSON.stringify({
recipient_id: user.id
}),
});
return
{ message: 'Bots cannot use this endpoint', code: 20001 }
well, you could get the guild and then fetch the channels
maybe they made that endpoint user-only to prevent private channels leak or something
^
but it's not the guild channel endpoint
discord has been very strict regarding data security in the past year
I didn't say it is
i should not get this error then
you should 100% be getting that error
read what I said again
you can't access a user-only endpoint by using a bot
^^^^
but it's /users/@me it's not guild related, if it was, bot won't be able to send messages anymore then
I never said it is guild-related
That endpoint is intended for users only
what's the endpoint for bots then
none
Use the documentation
maybe they made that endpoint user-only to prevent private channels leak or something
you need to create a channel
see the docs
Use a library to do this stuff, why are you doing it libless in the first place
not specified on doc
or...why are u calling the endpoint directly tho?
on doc it say it's /users/@me/channels
oh you can bet it is, else lib devs wouldn't be able to make a wrapper for it
i don't use libraries
what language?
You need to understand how the discord api actually works before trying to do things libless
assembly?
The discord api is very extensive
I already know how the api work
Obviously not or you wouldn’t be here :p
You need a channel id to send a message with a bot, but the endpoint to create a channel doesn't work anymore, that's what im trying to say
ok so, go to a library project github and see how they do it
you just need to see what endpoint they're calling
and with what data
optionally just go do discord documentation and find it
the discord doc is outdated
then go to a discord lib project repository
like d.js or JDA (idk how "clean" d.js is, ik jda is well documented tho)
What endpoint are you talking about
POST request to api/v10/users/@me/channels, it should return a channel id, when you put a user id in recipients
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
Yes it doesn't work anymore, look like it's outdated
you really ignore what I said didnt u?
Use api v9 and see if it works for a quick test
it's not user-only endpoint
let currentPage = 1
let messageId
function getRow() {
const r = new Discord.MessageActionRow()
r.addComponents([
new Discord.MessageButton().setCustomId("previous").setEmoji("◀").setDisabled(JSON.parse(`${embeds.length > 1 && !currentPage <= 1 ? false : true}`)).setStyle("SUCCESS"),
// new Discord.MessageButton().setCustomId("trash").setEmoji("🗑").setStyle("SUCCESS"),
new Discord.MessageButton().setCustomId("next").setEmoji("▶").setDisabled(JSON.parse(`${embeds.length > 1 && !currentPage == embeds.length ? false : true}`)).setStyle("SUCCESS")
])
}
let row = getRow()
interaction.reply({ embeds: [embeds[currentPage - 1]], components: [row] }).then(a => { messageId = a.id })```
Getting this nice error that I have no clue of where it's located, I'm guessing it's inside **getRow()**
still the same, a mod of dtesters told me the body is invalid, but i don't see anything wrong in it
ok, then make it work
I told u the solution yet your ego refuses to let u look how official library devs do it
okay
Yea no
it isn't outdated
djs uses v10 of the api and still uses that same endpoint
oop, I'm not returning r so it's a void function
weird then i don't know why i'm getting this error
How are you forming the body
code would be helpful
we aren't going to play a guessing game
const createChannelRequest = await fetch(`https://discord.com/api/v10/users/@me/channels`, {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'Authorization': `Bot ${token}` },
body: JSON.stringify({
recipient_id: `${user.id}`
}),
});
return
{ message: 'Bots cannot use this endpoint', code: 20001 }
Well discord doesn't even accept strinfied json last I heard
they don't
it is URLSearchParams
it has to be a urlencoded body
iirc
yeah it work now, thx yall 🙂
👍
are you using discord-api-types perchance?
djs v14 is a lot harder to read
they split off their rest stuff from the main package
😔
True

So many imposters
timposters
hi, not bot related but i have a very weird network issue, can i ask here?
just ask
its very weird, so when i download things on web or test speed
its fast
but downloading on steam and literally any other program is super slow
even chrome installer is super slow
or test speed
what speed test program?
hm, because ik most providers use caching, which adds some biasing to the speed results
maybe ur downloading a commonly downloaded program
try downloading ubuntu
it's not a normally downloaded file, so you'd get pretty accurate results
on steam its so sloww
check if your region is right on steam
it is, i changed like 6 servers
and whether your antivirus isn't getting in the way of it
none, no av
yeah also youtube wont load its so werid
see
but
like...
its supposed to be like 10 seconds
not 22 minutes
man i changed dns, used proxy and vpn idk what else, changed hop limit
you tried a different device? see if it’s ur internet or computer
What's your cpu usage at?
Steam downloads use a ton of cpu to decompress the game files.
Not to mention your disk write speed as well
If you have a slow disk you’ll probably experience slow “download” speeds
That's cool. Slash commands are basically webhooks so that's why I was thinking slash commands might be able to too.
I see I got no replies
But the FUD about sqlite not working with multiple processes seems to be just that
is there a way to do something like embed.fields to see how many fields there are
embed.fields is an array of field objects so you can do embed.fields.length to see how many there are in the embed
Why does Prisma convert type "String" to "Varchar(191)"? Why 191 and not the maximum of 8 Bits => 255?
Well okay I found an explanation:
https://www.grouparoo.com/blog/varchar-191#its-s-fault
if someone's interested
let message = await interaction.fetchReply()
message.editReply({ephemeral: true, content: `Dein Gegner hat nicht innerhalb von 30 Sekunden geantwortet. Sie werden daher gegen einen Bot kämpfen.\n\nIch sehe du hast wieder alles gegeben! Bleib dran, um neue Techniken und magische Sprüche zu erlernen. Du hast ${random_number} EP gemacht mit diesem kampf.`})
```message.editReply() is not a function?
You are hot misty. Thank you
idk if ephemeral will be possible here tho
we could always try!
channel = await interaction.guild.channels.create(`${interaction.options.getUser("gegner").username}-${interaction.user.username}`, {
type: 'text',
permissionOverwrites: [{
id: interaction.guild.id,
deny: ['VIEW_CHANNEL'],
deny: ['SEND_MESSAGES'],
}, {
id: interaction.user.id,
allow: ['VIEW_CHANNEL'],
allow: ['SEND_MESSAGES'],
}, {
id: interaction.options.getUser("gegner").id,
allow: ['VIEW_CHANNEL'],
allow: ['SEND_MESSAGES'],
}]
});```is interaction.guild.id even a thing? I always used to use message.guild.id and it worked
now it doesn't.
well if interaction.guild.channels works then you should be able to get the id
you could do interaction.guildId if you don't wanna go through .guild
keep in mind tho if the command is used in dms there will be no guildId or .guild
but this is essentially the same. Why doesn't this work then?
You are not being descriptive
"Why doesn't this work then?" is not helpful to us trying to help you
I am very sorry misty. let me help you
What are the errors. What is it doing instead
The channel doesn't have that lock in front of it (the one that indicates it has had permission overwrites). No errors at all, normal guild members still see the channel
Why are you defining deny twice btw
It is logical that if it is an array it takes multiple
Yea I know I was just pointing it out
as for yyour issue I see nothing wrong
Unless discord.js changed how you define everyone
Yea I don't know that all looks correct to me
Based on the documentation that should work
strings in v14 are not screaming snake case anymore
Wait really?
Wait they don't even support strings do they?
you have to use the PermissionFlagsBits
I still think it is better to use the enum
allow: ["ViewChannel","SendMessages"]
yes, using the flags from the enum is recommended precisely because of this
does discord-hybrid-sharding support v14 yet?
Does not seem like they have mentioned anything about it
mine works well
It doesn't look like they depend on djs as a whole
So it probably doesn't matter what version you use it on
(async () => {
require('dotenv').config();
const { ShardingManager } = require('discord.js');
const manager = new ShardingManager('./src/index.js', { token: process.env.TOKEN, totalShards: 2 });
manager.on('shardCreate', shard => {
shard.on('ready', () => {
if (manager.shards.size === manager.totalShards && manager.shards.every(x => x.ready)) shard.send('allReady');
});
console.log(`[SHARDS]: Launched shard ${shard.id}`);
});
await manager.spawn({ delay: 10000, timeout: -1 });
})();
Another sharding issue, shard 0 spawns and ready event is fired, but shard 1 also spawns but ready event doesn't fire.
Ready event as in the shard.on.
how do you know? you dont have any console.log inside it
No, I do. However, they're not logging.
Anyways, I'm keeping it one shard for this time.
It's weird, though, it used to log but now no. I'm still in V13.9.
When hosting the bot and dashboard do I host them in the same place?
you don't need to
you can
Hey guys, I am trying to find a way to add a song to a queue.
I set the bot to play a song, but when I tell the bit to play another song it skips the current song to play the new song. How do I just make it play the next song after the current song to finish?
Wdym
it is really up to you
yeah
How can I link the bot and dashboard
a database
you can make an api that handles fetching data related to the bot
Huh
or IPC which you prova don't need to
or you can host it on the same process so you already have info on the bot that you can just use
Mind sending me a website with a documantion explaining this
I don't know of one
If anyone does please send me it
i dont see a console.log inside the shard.on("ready")
(async () => {
require('dotenv').config();
const { ShardingManager } = require('discord.js');
const manager = new ShardingManager('./src/index.js', { token: process.env.TOKEN, totalShards: 2 });
manager.on('shardCreate', shard => {
shard.on('ready', () => {
if (manager.shards.size === manager.totalShards && manager.shards.every(x => x.ready)) /*for (const [, shard] of manager.shards) */shard.send('allReady');
console.log(manager.shards.size === manager.totalShards, manager.shards.size, manager.totalShards)
console.log(manager.shards.every(x => x.ready));
});
console.log(`[SHARDS] Launched shard ${shard.id}`);
});
await manager.spawn({ delay: 10000, timeout: -1 });
})();
and those two console.logs dont log anything?
When spawning the second shard, no.
The only thing that logs is the [SHARDS] part during shard 1.
a bot dashboard is a very broad subject, its the same as creating a website with a login system, it can be done in a million different ways, and you need to know both front end and back end code, as well as databases
the [SHARD] log is only logged once? if so the other shard is not being created at all
The SHARD log logs for the first shard so do the 2 console logs. However, the SHARD log also logs for the second shard, but the 2 console logs don't.
what does the debug logs say?
I haven't really tested that out.
I'm just rewriting the bot for now then I'll get back to it.
👀
But you are having issues with your shards identifying
listening to the debug event might help
Sure, I'll do that. I'll just finish the basic files then I'll figure it out.
this is my config code, and it works without it
so im a bit confused
should i be using it
as opposed to context menu or buttons for example
i got all of these commands but only the 5 last ones are actually loading please help
I like your menu, looks nice
First thing I’d recommend here is logging client.commandArray somewhere before/after you register your commands
Also instead of doing fs.readDirSync, I’d use the promise version of the fs API for asynchronous reads
first an empty array then one with every command object inside
what
There’s a version of the fs api that you can use async/await on, instead of being stuck in callback hell
Here’s a quick little tutorial that explains how to use it https://flaviocopes.com/node-fs-await/
Node.js built-in modules famously are not promise-based.
This is for historical reasons, as those modules were created before promises were a thing.
We’ve had promisify for quite some time, but I recently found out Node.js provides a new API that’s promise-based.
I thought it was new but it’s been introduced in Node.js 10 (2018, it’s been a whil...
and how do i translate this import * as fs from 'node:fs/promises'; to using require?
bc i havent learned import and when i tried i got some errors i had no idea how to fix
and people just told me to use require instead
You might have to do something like
const fs = require('fs').promises;
Then you can use stuff like await fs.readFile(someDirHere)
Imo it’s much cleaner than using the synchronous version of fs
then i cant use filters
TypeError: fs.readdir(...).filter is not a function
const fs = require('node:fs/promises')
just do that
I'm currently working with zod. Now I wonder if I should make an extra file to store all those Objects? Or other suggested file structure?
what's zod
if you are using promises you gotta await it first
because you're calling filter directly on the promise, not the result of the promise (if you're using the promises variant)
(await fs.readdir(...)).filter(...)
U gotta have the () around await fs.readdir(...)?
if you do it on one line yes
if you wanna put it in a variable and call .filter on a variable you can do it that way as well
Ahh that’s the issue then
wrapping it in parans just resolves the promise and allows you to use it directly after
const SomeAsyncFunction = (smt) => {
return new promise((resolve, reject) => {
fs.readdir(....)
.then(fileList => {
resolve(fileList.filter(smt))
}).catch(reject)
})
}
//In your code
await SomeAsyncFunction(Filter function)
That works as well ig
const map = new Map();
map.set(1, {"abc": 1});
const get = map.get(1);
get["bcd"] = 2;
map.set(1, get);
console.log(map);
So... map.set(1, get); isn't needed at all? I thought you can't manipulate maps without it's set() method?!
no
you dont need to use async fs if you're only loading files at startup
also there's a bracket { inside then which doesn't belong into
the map stores only a reference to the object, so anything you do to that object will be seen in all its references everywhere
ahh, okay makes sense
the code ran but the other commands still arent showing
Show updated code
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');
const { AsciiTable3, AlignmentEnum } = require('ascii-table3');
const fs = require('fs').promises;
const clientID = '811586423933108254';
module.exports = (client) => {
client.loadedCommands = new AsciiTable3('Commands')
.setHeading('Command', 'Command Name', 'Status', 'Reason')
.setAlign(3, AsciiTable3.CENTER);
client.handleCommands = async () => {
const commandFolders = await fs.readdir(`./src/commands`);
let files = [];
const { commands, commandArray } = client;
for (const folder of commandFolders) {
const commandFiles = (await fs
.readdir(`./src/commands/${folder}`))
.filter((file) => file.endsWith(`.js`));
for (const file of commandFiles) {
const command = require(`../../commands/${folder}/${file}`);
commands.set(command.data.name, command);
commandArray.push(command.data);
files.push(file);
}
}
for (i = 0; i < commandArray.length; i++) {
if (!commandArray[i].name) {
client.loadedCommands.addRow(
files[i],
'\u00A0',
'⭕ FAILED',
'Missing a name.'
);
} else if (!commandArray[i].description) {
client.loadedCommands.addRow(
files[i],
commandArray[i].name,
'⭕ FAILED',
'Missing a description.'
);
} else {
client.loadedCommands.addRow(
files[i],
commandArray[i].name,
'🔷 SUCCESSFUL',
'\u00A0'
);
}
}
const rest = new REST({
version: `9`,
}).setToken(process.env.token);
(async () => {
try {
console.log(`Started refreshing application (/) commands.`);
await rest.put(Routes.applicationCommands(clientID), {
body: client.commandArray,
});
console.log(`Successfully reloaded application (/) commands.`);
} catch (error) {
// console.error(error);
}
})();
};
};```
What exactly is the difference between a manager and a collection? 
https://cdn.hamoodihajjiri.com/8wZ5PRHj0M
The Manager usually has a cache of type Collection, but also has other utility methods on top of it related specifically to the collection it’s managing
Have you made sure all the commands are in the array when going to post?
they are
Have you tried publishing them to 1 singular guild to see if they actually are being created cause global commands can take a while to fully register
that also didnt work and isnt commands registering instantly now?
what is to learn abt import tbh?
Commands are not guaranteed to be registered globally instantly
It’s usually pretty fast nowadays but still not guaranteed
That is why I always push to a specific guild when testing
imagine quoting keys in objects
At least I am guaranteed it to be there
pleb, that's necessary if keys have whitespaces

try calling a property like so object.fuck you
map.set(1, {"\"\"": 1})

they still didnt load
how much did ya wait?
since last time 15 min
with guild commands
and ive never had an issue like this before and those commands that showed up got made as soon as i launched the bot
might I ask why are you doing the creation of the commands yourself through the rest
because i found a tutorial that used it
I would recommend using the client instead
client.application.commands.set(commandsArray, guildId)
let djs handle the request for you
so remove the const rest = .... and replace the await rest.put(....) with what you sent
I would recommend doing so, that way if they don't post it is either djs fault or you have malformed data in the commands data
still a nope
I have no idea what is going on then
You already say your commands array has all the commands so it should post
{
name: 'add',
description: 'Adds a dino or breeder',
options: [ [Object], [Object] ]
},
{
name: 'addbreeder',
description: 'assignes a user to a dino to breed',
options: [ [Object], [Object] ]
},
{
name: 'adddino',
description: 'adds a dino line to request',
options: [ [Object] ]
},
{
name: 'claim',
description: 'Claim a dino you want',
options: [ [Object], [Object] ]
},
{
name: 'dinos',
description: 'Lists every dino you are able to claim'
},
{
name: 'list',
description: 'gives the list of every dino thats added and those that are breeding them'
},
{
name: 'next',
description: 'Contines the queue for a dino',
options: [ [Object] ]
},
{
name: 'notify',
description: 'Notifies the next person in queue',
options: [ [Object], [Object] ]
},
{
name: 'queue',
description: 'Sends the queue of a spesific dino',
options: [ [Object] ]
},
{
name: 'remove',
description: 'Removes a dino or breeder',
options: [ [Object], [Object] ]
},
{
name: 'request',
description: 'Sends a requests for a dino if you want to breed',
options: [ [Object] ]
},
{ name: 'test', description: 'test' },
{
name: 'unclaim',
description: 'Unclaim a dino you are in queue for',
options: [ [Object] ]
},
{ name: 'help', description: 'A description of all commands' },
{
name: 'settings',
description: 'change settings for the bot',
options: [ [Object], [Object], [Object], [Object], [Object] ]
},
{
name: 'annonce',
description: 'give an anouncment',
options: [ [Object], [Object], [Object], [Object], [Object] ]
},
{ name: 'button', description: 'Return a button' },
{ name: 'embed', description: 'Returnes an embed' },
{ name: 'menu', description: 'Return a menu' },
{ name: 'modal', description: 'Returns a modal' },
{ name: 'ping', description: 'repies with pong' }
]```
thats the output if i log commandArray right before i do client.application.commands.set(commandArray, '494567290990493696')
and none of them get posted?
i got it to work now and i dont even wanna talk about it
You're sure 494567290990493696 is a valid guild ID?
Doesn't look like so
it is i just made a dumb dumb and i dont wanna talk about it
lemme guess, you tried to set the commands before the client has been ready?
How can I add slash command support for my discord bot in rust?
well has nothing really to do with your programming language
you register them to the API, then listen to the interaction_create event to receive interaction events
nope, i had defined the command option type wrong in some commands
v13 json style
ah, well I use the values (integers) the API expects
to get rid of djs changing the names of the enums etc.
now im just trying to see if i can detect if a name or description value is missing or type is a string then pass that into the table
so that wont happen again
well once you begin to use the values the API expects you will remember which value is what, quickly
i just want to keep it as a backup
can't find a way to log my error to console and to a file
either I move the entire process stderr to my error log file or log it in the console
You can also overwrite stdout and stderr and since console.log and console.error pipes to those streams. You can replace it with a stream.Passthrough iirc or stream.Transform if you can't specify a callback with Passthrough
anyone here any good with tailwindcss?
Just ask your question
listen to the boy
no hes not
lol
But he's older than you
Who waffle?
Yes
Then why is he smarter
you should
And I like it 
ok bud
Damn… not much going on today
After careful consideration I am still going to use unity
Despite the negative feelings people are having towards it rn
Some russian guy got banned
so ye
that happened

Same freedom of speech spiel
Lemme guess, scam links?
No
misty is a dinosaur I’m like 12
Arguing with staff cause he couldn't speak russian in general channel so he got muted for that
then repeated to dm me death threats in russian towards staff
#mod-logs covers a good bit of it
lmao
Hey
I am only half way to 18
actually more than half
ancient
He also threated to cancel us on twitter
as if top.gg hasn't had that happen before
imagine using twitter
Cancel me on twitter
Twitter is 30% degens and 65% political degens and 5% shitposters
I have a private account because my friends dm memes
Jwaffled I think
Whenever I get to follow a link to watch comments I see like 75% shitposters
Or more
this bozo?
Just go into any political statement and watch the comments burn to the ground
Yes that bozo

https://youtu.be/sRWE5tnaxlI I do not like this
To offset some of the banana-based JavaScript "weirdness" that's making the rounds, I'm bring you a 40 line JSFuck compiler that turns innocent looking JS into a mess of obfuscated symbols.
=[ 🔗 Links 🔗 ]=
-
⭐️ Patreon: https://www.patreon.com/lowleveljavascript
-
💌 Updates to your inbox: https://tinyletter.com/lowleveljavascript
-
Martin Kle...

u found jsfuck
it's too late now:
you can write console.log('Hello World'); or this https://pastebin.com/4yWePPkC
yuck
yuck, no wrap text
i just copied it from herehttp://www.jsfuck.com/#
nice work

wtf glitter

Need some help with finding the issue with my application commands
oop
options is not choices on last
I couldn't figure out how to do this
Hey guys, not sure if im allowed to post this here, but I'm looking for someone that can make me a discord bot dashboard, please dm me if you can do this, there will be payment
Also, I would like it to look good!!
<ButtonBuilder>.setEmoji('<:name:id>')
how do i put that bott over there, not just emojis
make a second ActionRow
`const { ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js');
client.on('interactionCreate', async interaction => {
if (!interaction.isChatInputCommand()) return;
if (interaction.commandName === 'ping') {
const row = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId('primary')
.setLabel('Primary')
.setStyle(ButtonStyle.Primary),
);
await interaction.reply({ content: 'Pong!', components: [row] });
}
});`
like this ?
yes
Can you catch Discord.JS API Errors?
I'm copying a old eval command of mine but it doesn't catch api errors
using try {} catch () {}
await your calls
yoo got a question!
how can i have only one if(without an or) and have the ids in an array
sometimes its lots of ids, having them in an array seems more clean
array.includes()
["abc", "xyz"].includes(message.guild.id)
sound great, testing it out now!
Does anyone know how to get information about who invited a bot in DJS? 🙃
Like is there a addIntegration event I am not seeing or a property on guildMemberAdd?
The discord api doesn’t allow us to fetch who invited the bot

Should be in audit logs
Legend! Ill try
Wait like 5 seconds on add for caching to clear
Ye, audit logs are fun 🙃
why are all my bots tokens invalid?
made like 7 bots on my account like a year ago and made them all join a vc whith my mates on a privet server and messed around with them
no im trying to use one to test some code
bot all the bots tokens are invalid
the one i still use the token is still good but the others are bogus
some arent in a server but the 3 thats are dont work
guess ima have to regen the tokens then and se if that works. btu could some one give me and explanation to why this has happend?
Could be a lot of reasons. If you accidentally post your token on GitHub, discord will automatically reset it for you
mmm i know about that but i havent touched those bots in almost exactly a year
yeah
?
Regenerate all their tokens ez
true but they where they all invalidated in the first place thouygh ?
It's also very likely you just never had the right token in the first place
And if this is untrue it could be a number of other reasons that aren't worth thinking about
Just Regen the tokens and call it a day
theo bot had a bunch of tokens in a json file and loged onto each one after the other started it up today and they are all dead exept for one that ive been using more recently
yeah fair neough
Include the identify scope to the invite url
Ah, u don't mean ur bot
What if I don't want to
Sorted it out with audit logs 💯
Imagine relying on discord to handle it
ok so tryna make a command handler for my test bot cuz its got like 20 commands now and really messy, also want to be able to reload the commands withough having to restart it
however keep gettting "cannot exicute undefined" error
code incomming
uploads 45 files
try {
console.log(command)
console.log(commands)
commands.get(command).execute(bot, message, args);
} catch (error) {
console.log(chalk.red("[ERROR]: ")+error);
message.reply('that command is broken lol').catch(error => {console.log(chalk.red('[ERROR]: ') + "Send Error - " + error); });
}
so this is athe bit that the errors comming from
well that doesn't really give us anything to work with tbh
im getting there
ok ok
didnt want to post the entire file
commands.get(command).execute(bot, message, args); is where the error comes from
bot.commands = new Discord.Collection();
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
bot.commands.set(command.name, command);
console.log(chalk.yellow("[INFO]: ")+`loaded command: ${file}`)
}
is the handler in the index file
and this is in the message create event file
what's commands
should it not be bot.commands
^
How does one of your commands look
but yeah its undefined either way
one sec
const chalk = require('chalk');
module.exports = async (bot, msg, args) => {
let message = msg.content.split(" ");
msg.delete().catch(error => {console.log(chalk.red('[ERROR]: ') + "couldn't delete msg: " + error); });
msg.channel.send(message.content.slice(4)).catch(error => {console.log(chalk.red('[ERROR]: ') + "Send Error - " + error); });
};
see how this map has an empty key?
i thought it uses the file name? and yeah i wondered why that was like that
There's no such thing as command.name when you're importing it
You need something more like ```js
module.exports = {
name: 'say'
execute: async (bot, msg, args) => {
// stuff
}
}
yeah i had thats before (some of this code is from an old bot i made with a handler)
i just thought it wasnt needed cuz it used the file name
oh well its been a while since ive delt with handlers
require() only returns the exported object within the file, not the file itself
fair enough
does someone know how to wait for mongodb gridfs upload?
here's my current code, but it's never resolved
async (filename, path, metadata) => {
const stream = createReadStream(path).pipe(
serverBucket.openUploadStream(filename, {
chunkSizeBytes: 1048576,
metadata,
})
);
return new Promise((resolve, reject) => {
stream.on("end", resolve);
stream.on("error", reject);
});
}
*turns out to be "finish" instead of "end" oof
I'm thinking of a way to translate the bot according to the client's language, the problem is to find some docs that talk about it...
does anyone have something in mind about it?
thx
np
👌
Heres what my bot currently does, im looking for suggestions:
Get URL from user/avatar -> push data to google - > get data - > push data to API- > get URL of search -> return data from vision in embed, showing total matching images online -> get screenshot of google.com's image search, to show mods/admins a clean version of the results
its a reverse image search bot, could anything be added?
Make that command nsfw only
Anything that involves google is a risk by itself
Searching r/oppai
Lmao
can do
nvm r/oppai was banned
r/OppaiLove
But well, tbh, what is the goal of that command?
Like, the final use-case
helping users find catfish in servers to report to mods, from selfies channels, etc
Ok but, is someone really gonna use it?
Like it's already a common sense that nobody uses a their own image as pfp
At least no womans
example: https://i.imgur.com/R7Gl70w.gif
Because that'd be literally asking for DM assault
wym?
You see, the web is a horny place
I mean it’s pretty much common sense to not reveal information about yourself on the internet like your face to random people
lol yes, yes it is
have you seen dating servers?
But I see the use case for reverse image searching
99% of women who do use own images for profile in sites like discord get DM assaulted by horny people
Just look at reddit
I’m like 99.9% sure those are against ToS
lots of them are, yes
Mainly because it’s easy for kids to get on there
but discord doesnt seem to care 😛
women don't exist on discord
I can see the use case for reverse image searching if someone sends a picture of “themself” to you to verify if they’re actually being genuine
true
this is what, id assume, 70% of scans are for
the other 30 are avatar scans and then random selfie scans from chanels in servers
proceeds to make a face in blender
But you gotta be really careful with what you allow to be shown in what channels
There's also the doxx risk
Google images is not a safe place to screenshot without the channel being marked as nsfw, especially if someone reverse image searches something nsfw
very true
Perhaps you could include the screenshot only if the channel it’s in is marked as nsfw
I already pointed that at the beginning
@earnest phoenix Just put safe=active in the url param
oh?
Yes, I really do believe people reading this might be sad enough to answer "yes" to the question "Ever wanted to know how to construct your own Google search strings?". So with that in mind, here are Google's search string parameters. All of them.http://www.google.com/search?Google's URL. If you…
Ehh idk, I wouldn't trust google filter
At least he won't be liable legally
Google safe search allows educational NSFW
So yeah, heads up, it may not do what you think it will do
proceeds to search a peanus
Vegana
Yeah, no filter is 100% accurate either
wut this?
I'm getting this from sentry so can't pinpoint the exact location
And djs logs are useless as always
have fun searching
I won't be here If I found the solution on google
that's not what I mean by searching
nvm I'll just do
process.on('unhandledRejection', (a) => {
console.log(a)
})
process.on('uncaughtException', (a) => {
console.log(a)
});
Let node suck itself
bro thats actually cool af
If you want to reply (this is the keyword here) ofc you'll need to know the previous messages
You can't reply to a message you don't know exists
Is there a way to vote for my own bot but as a test, so that the vote is not counted but still the event is executed?
Yes use the test button on topgg
hey guys
what intents do i need for the voiceupdate event to work?
i already added the Intents.flags.guilds
the error is saying that setState requires one of the following keys: show, health, armor, hunger, thirst
toUpdate is not recognized as any of those keys, as its just a generic string
you need to typecast toUpdate to specify those keys instead of just being a generic string
ty
bruh, this wasn't happening before, it started happening earlier in the day
The url doesn’t exist? Check routes maybe
see the error code: "ERR_EMPTY_RESPONSE"
I had disabled cloudflare, the error is 520
idfk why
so annoying
L
Check your server logs
Both your server's and webserver's
fun fact: I'm using interactions
yes?
help
let { label, value, description, emoji } = option;
^
TypeError: Cannot destructure property 'label' of 'option' as it is null.```
yeah I can't do null in this case but like
you get what I'm trying to do
I wanna display options only if they match the condition
nevermind I had to use [] instead of null
Can you show the code causing the issue?
I have like a few thousand lines of code and don't know where it's coming from
Options are an array and you can’t pass multiple arrays to it anyways
let options = [];
then if(…) options.push({ … });
.addOptions(options);
I literally can
my method worked
Hmm you should really await any reply since it’s a promise to figure out which one causing an error
It never occurred since yesterday
So I thought it was because of the discord api problem
They said it was giving extra errors
im getting db.set is not a function error
db.set(guild.id, a[i])
db.set(a[i], channel[2].id)
Hmm could be possible
Wasn’t really aware there has been an issue
what is the db variable?
i fixed
if(talkedrecently.has(message.member.id)){
return
}```
Uncaught TypeError TypeError: Cannot read property 'id' of null
Huh why is this happening>?
The rest of the code performs well (it does give me a role like it should)
but it errors and send this
it came from this exact line
well, member is null obviously
Probably used in a DM
Make sure that you only check for spam/whatever you’re doing in a guild
I log member and it actually shows lmao
and it isnt in dm
Well then it’s happening somewhere else. Member is most definitely null, it does not magically appear after being null for no reason
What’s message
I assume a Message object but you gotta be careful with the order you have your arguments in for your command handler
not even nginx/apache logs?
eh, socket.io
I had uncountable issues with that little bugger
may I ask, what are u using it for?
does somebody know how I can linesplit urls in an embed
e.g.
raw/ayatugerud```
and still make it clickable?
why do you want to do that anyways
what you can do (although I don't really get why) is:
[https://hastebin.com/](https://hastebin.com/raw/ayatugerud)
[raw/ayatugerud](https://hastebin.com/raw/ayatugerud)
it's technically 2 links, but should work as u asked for
Hello
it's a music bot
I want my embed not to stretch out but more of a square shape
because I believe it looks better
alright thanks doe
an example: using to post and get data of what is playing on the server
ey guys i have an issue that's fucking me in my ass rn: js client.on('messageCreate', async (message) => { console.log(message.member) if(message.member.user.bot === true){ return } })Uncaught TypeError TypeError: Cannot read property 'user' of null. My log first logs the guildmember and then logs null/ Why is it being fired twice lol?
can't u use websocket for that?
Kinky
=== true 
but well why don't u simply message.author (or user idk)
also, did u check if ur not registering the event twice?
why? :(
wtf
message.member.user.bot?
smh
message.author.bot
faster, less overhead, more reliable and more flexible
Stinki Flazepe
@lyric mountain
https://www.npmjs.com/package/ws
https://www.npmjs.com/package/websocket
is there a difference between these two?
I think the ws is is more widely used
.addChoices(option.StringChoices.choices.map(c => [String(c[0]).replace(/\s+/g, '_').toLowerCase(), String(c[1])])),
where should the name: '...', value: '......' between
is now v13 and i will go to v14
testing this in a live environment? member isn't available in DMs for example
oh
ok
yeah that'll cause issues too since === is a type and equality comparison
so no type coercion
better use !!message.member.user.bot === true
what you're looking for is ```js
client.on('messageCreate', async message => {
if(message.author.bot) return;
}
actually what he's looking for is:
client.on('messageCreate', message =>
{
if(message.author?.bot) return;
}
no >:C
yes, author isn't always present
perhaps webhooks
maybe isn't available if you don't have partials subscribed
or this
yeah idk
@wheat mesa is this site working for you?
.addChoices(option.StringChoices.choices.map(c => [String(c[0]).replace(/\s+/g, '_').toLowerCase(), String(c[1])])),
where should the name: '...', value: '......' between
is now v13 and i will go to v14
down
weird it's just white for me
im getting a 406 as well
your sentence makes no sense
?
he means where he needs to put the options into
just show the associated code if you want an useful answer
slash command handler
No is all every time a small part of an option of my commands
String("UwU")
for example this is one of my commands https://sourceb.in/HE3QfxLUbb
You know you can just paste the code in discord chat instead of using a third party site?
that could indeed be
WHY do you import your command file let pull = require(`../slashCommands/${dir}/${file}`); and then PUSH the structure which is already as the API expects it INTO A SLASH COMMAND builder?
what a nonsense
yes I know that, but then you also see the lines of the code instead of counting
no
don't
there is a fuck ton of code in there
that would be like 3 messages of just pure textwall
don't discord upload that as file and minimize it
I just did
but not easy to read
but does it matter that I use a website
it gets cut off after a few lines
like 60ish lines
third party sites are much better, it also allows mobile users to read it easily
previously pasteebbin was banned in some countries
and I heard sorcebin is same
turkey
*Turkey
yes here in the netherlands it is allowed
but the people who'll help you can't use it
module.exports = {
name: "customspeed",
description: "Verander de snelheid van de bot.",
options: [
{
"StringChoices": {
name: "snelheid_getal",
description: "Welk snelheidsbedrag moet de muziek hebben?",
required: true,
choices: [
["0.25", "0.25"],
["0.50", "0.5"],
["0.75", "0.75"],
["1", "1"],
["1.25", "1.25"],
["1.50", "1.5"],
["1.75", "1.75"],
["2", "2"],
]
}
},
]
module.exports = {
name: "customspeed",
description: "Verander de snelheid van de bot.",
options:
[
{
type: 3,
name: "snelheid_getal",
description: "Welk snelheidsbedrag moet de muziek hebben?",
required: true,
choices:
[
{
name: "0.50",
value: "0.5"
},
{
name: "0.75",
value: "0.75"
},
{
name: "1",
value: "1"
},
{
name: "1.50",
value: "1.5"
},
...
]
}
]
}
wtf
choosing this sturcture in your command files is exactly what the API expects
oops, there're some of my names and descriptions still in
Yes I do a lot in my slash command handler, which can make my codes shorter
does anyone know a good npm library/package where I can create a word scrambler and unscrambler ( instead of having to make my own function in js )
basically I am trying to scramble an URL ( so people won't be able to figure out the URL so easily )
the URL serves the purpose to get the base64 encoded json objects from it
and I would like to hide it from the people,
so I want to create a scrambler that randomly scrambles the URL
like here
and then I pass the scrambler variable to some function and then unscramble the url
but how do I adjust line 72 in the slashcommand handler to v14, so with that name and value
Defining an useless key like StringChoices makes no sense at all
Just assign a type to the option or choice
Which is exactly like the API expects it
Well, those are fetched in my slashcommand handler
Then you can literally get rid of 75% of your repeating code
Discord.js fucks with raw requests (using ts / eslint)
Yeah but that's not the point, I'm here to ask how can I change that line to v14 instead of talking to me length of my code
saying can't access private property raw
@boreal iron literally told you that
what the heck are you referrring to?
where?
I tried following your path a while ago
using Client.raw to send raw requests so I didn't have to use those useless builders
Thern ts stopped complying
look up
why the heck would you use client.raw to send your requests? I never said this
if you wanna keep your horrible structure, go on
there are the docs
to v14
you literally told to use raw requests so I don't end up changing my code with every djs version
I just want to know how to do that line because I can't figure it out with the docs.
No I told you to stop using the builders, like I do everytime when seeing that mess people build
The builders do only create the raw objects for you as it will be send to the API as it excepts it
then how do i send it?
Since the builder constructors are continuesely changing their name, or removing methods or guards, just write the objects yourself instead of using builders
Ok an example:
send / edit won't take raw
Hi !
I found a code on GitHub which allows to create a database of movies (because I am the creator of a movie server)...
Except that there is a problem... When I follow all the instructions that are written on the GitHub I get an error...
The error concerns the resolvers...
at file:///C:/Users/Lucas/Desktop/Cin%C3%A9Mix%20Search/src/resolver.js:28:53
at ModuleJob.run (node:internal/modules/esm/module_job:193:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:541:24)
at async loadESM (node:internal/process/esm_loader:83:5)
at async handleMainPromise (node:internal/modules/run_main:65:12)```
The GitHub: https://github.com/RealAlphabet/StreamSearch
I would just like to run the bot on my server and not take knowledge or anything...
this is why you just use detritus instead 😉
They always expect your options, for example, components being "raw" data like the API expects
payload.reply({ embed: {
title: 'Title',
description: 'Desc',
fields: [
{ name: 'something', value: 'something else' }
]
color: 0,
}});
pretty easy
much better than the builder stuff 99% of the time
and slash command options are really easy too
I feel like the builders were given as tasks to the junior devs to make them busy so the senior devs could work on important api stuff at discord 
For example instead of using embed builders, just write the object yourself - that's SHORTER, FASTER and looks better (imo)
let embed =
{
color: resolveColor(colors.somecolor),
description: "some description here"
};
Instead of using the action row builder, then component builder (select menu/button builder etc.) write the object yourself (once again)
let component =
{
type: 1,
components:
[
{ type: 2, style: 5, label: "button1", url: links.discord },
{ type: 2, style: 5, label: "button2", url: links.website }
]
};
Then pass those vars as options LIKE you would pass your builder vars
await message.reply({ embeds: [embed], components: [component] }).catch(() => null);
That's not new really
its starting to show lol
It's just the actual way the object looks
bruh i was using 12 untill a month or so ago
Another embed example:
let embed =
{
color: resolveColor(colors.somecolor),
author: { name: "Title", icon_url: icons.someimageurl },
description: "some description here",
fields:
[
{ name: "**Field title**", value: "Field description" },
{ name: "**Field title**", value: "Field description" },
{ name: "**Field title**", value: "Field description" }
]
};
So you don't have to use stuff like ```js
let embed = new MessageEmbed()
.setThis()
.setThat()
.setEtc();
i know that you gotta send the embed in a funny way now instead of just msg.channel.send(embed)
but thats bout it
Here's an actual example of some code I used: ```ts
return payload.editOrRespond({
embed: {
color: Constants.KanzenColors.ERROR,
description: 'I am unable to ban that user due to my role position.',
},
});
Much cleaner than making an object and using methods imo
This has been the same for ages, just not many people use this method
Most people use the object builders that are built into djs
But most of the time (I'd argue at least) just doing the structure manually is easier
i thought you couldnt use it the old way now, just throws an error about inproper formatting or somthing
i cant remember
Well yeah you can't do THAT anymore
We're just talking about the creation of the embed itself
The docs are literally telling you EXACTLY how your object has to look like, as the API expects it
For example for a message:
https://discord.com/developers/docs/resources/channel#message-object --> array of embed objects
https://discord.com/developers/docs/resources/channel#embed-object --> object (accepting the properties as listed)
That's EXACTLY what the builders are doing for you
ah fair neough
anyone know a good scrambling & unscrambling algorithm
you call the annoying constructer, call the methods like addActionRow() or addFields() etc. and the class returns the final object for you in the structure the API expects @near stratus
as written above
I usually only use the builders when I have something like this: ```ts
let embed = new Embed()
.setTitle('Some conditional embed')
// Set other stuff down here
if(someCondition) {
embed.setDescription('Some condition passed');
} else if(anotherCondition) {
embed.setDescription('Another condition passed instead!');
} else {
embed.setDescription('No conditions were passed');
}
the fight against the builders has just begun
tf
just do if condition1 ....
if condition 2 ...
condition 3 ....
my man it's an example
also that has nothing to do with what I was saying lmao
if(someCondition) {
embed.setDescription('Some condition passed');
} else if(anotherCondition) {
embed.setDescription('Another condition passed instead!');
} else {
embed.setDescription('No conditions were passed');
}
Why calling setDescription()?
if(someCondition) {
embed.description = 'Some condition passed';
} else if(anotherCondition) {
embed.description = 'Another condition passed instead!';
} else {
embed.description = 'No conditions were passed';
}
typescript private props
Plus it's more explicit
I don't like setting internal properties of something without a setter
It's just better practice
smh
what r u guys trying to do
In this case it's perfectly fine but in general I don't do that
stopping people from using builders and bloat their code with useless stuff
what are builders
These
whats wrong with that
anything
ok name one
it's unnecessary 95% of the time
why so
97%
because you can just do something like this: ```ts
return payload.editOrRespond({
embed: {
color: Constants.KanzenColors.ERROR,
description: 'I am unable to ban that user due to my role position.',
},
});
(Too lazy to write a different example)
scroll up a little bit, we explained why
not bloating this channel by repeating everyting 5 times
I use the raw structure even for the more complex components, though I don't like putting type: 1 and stuff like that
I usually use the enum
Then use djs enums
for the types so it's easier to read
yeah but if u repeat this every time u need an embed this is just gonna be hella annoying
No?
It's really easy
If anything calling 5 methods every time you want to make an embed is annoying
u can just make a function for that builder and then pass arguments like description
That's not the point
Only for the first times you're reading/writing them...
After using the API type integers you will remember quickly which one is what
wouldn't something like this be easier or am i misinterpreting something?
let stuff = ""
if(thingOne) {
stuff = "one"
}else if(thingTwo) {
stuff = "two"
}else {
stuff = "three"
}
let embed = new embed()
.setTitle('Some conditional embed')
.setDescription(stuff);
The raw structure is easier to write than making a bunch of jumbled calls
that's very messy
I don't like that style
Not to say I haven't done it before, but I still don't like it
how so?
no, its gonna cost u to write the whole embed structure every time u wanna do smthing related to an embed when u can just write it once and pass arguments
Have you heard of a thing called variables
You can store it in a variable
And modify it as you wish
let embed =
{
title: "Some conditional embed",
description: stuff
};
and why would u use a variable over the builder
This structure is easier to read, it's more explicit when you're writing it
Because the builder is basically pointless
The embed is really easy to represent as an object
its up to everyones preference really
tbh it is absolutelly pointless
yeah thats true but why make a big deal out of it
Most people's "preference" is because they don't know that u could do otherwise
even more since builders being renamed every major version, now their scope has changed etc.
🤷♀️
was a rough raft to show a point but thx. its been a while since ive use embeds
And once they get stuck on the builders they don't go back
and methods/guards being added/removed without any reason
yeah discord is dumb as hell with that
I use detritus and things very rarely get name changes so it's not really a big deal but still
v14 is hilarious
basically every new version is "hilarious"
The biggest name change in detritus was like renaming SlashCommandClient (And anything to do with slash commands/interactions) to InteractionCommandClient
that's the point, you don't have to change anything expects the intents class name if you don't use builders anywhere
🤮
I know you're weird
{
}
you can just use some online converter to convert the embeds to its update depending on their version
easy saves time
Although I must admit the raw structure method is more annoying if you're not using typescript
that... does not save time
I know you dislike brackets and parantheses
that sounds like a hassle
Why would you do that if you could just avoid it all in the first place?
why would u avoid it in first place if it only takes u copy paste
its no big deal as u can see
idk about you but I'd rather not copy paste 500 billion files every time djs makes a change to the builders
omg... ok this discussion is pointless
if you wanna keep update your code and bloat it by using builders and their annoying structure, you're free to do it
idk if discord changes their library/builders 500 million times
v500000014 sounds amazing
have fun changing your code on any major version and on other releases, too
not to mention djs was an insufferable experience after I swapped to detritus
everything is just so much better with detritus tbh
Pretty much no major breaking changes between updates, very quick support for new features, a built in command handler, etc
tbh when seeing how people "code" and paste things together it doesn't matter at all which lib they use
they will always prefer djs I guess since you can copy and paste tons of stuff
it's so easy to start up your bot!
(Although this is not counting sharding which is something I'm doing in a bot I'm working on)
sharding is really easy to handle anyways
but djs has a fairly nice documentation to be honest and it's performance is quite okay if you don't think about ridiculous upscaling
ridonkeylous
oh no
oh yes
lol
detritus needs to update the request lib they use to something else though, it's a memory hog
I love to give tutorials/explanations as foolproof as possible while keeping it fancy
don't tell djs
what do they use?
oh yes
lmao, undici keeps being a piece of shit
i also had many issues just from trying it out
im back to https lol
what the fucking heck sort of requests you all do to experience this sort of issues?
cake's notsobot uses ~130gb of ram in 725k servers with detritus
never had any issues why the http(s) libs or nowadays node-fetch
not at all
Granted he caches a lot
damn how did you get all that info
ah
is it hosted on a single machine or did they switch to multiple machines/kubernetes?

