#development
1 messages · Page 1889 of 1
for(guild of client.guilds.cache) console.log(`ID: ${guild.id} | Name: ${guild.name}`);
c# dev I see
Whait.. that cant be that easy
console.table(client.guilds.cache.map(guild => [guild.name, guild.id, guilld.icon]))
guess you could do this too? ^
It is
this makes a nested array
isnt that what you want for a table?
huh console.table that's a thing, lol?
wow complicated stuff i don't understand
does table support that?
// an array of arrays
var people = [["John", "Smith"], ["Jane", "Doe"], ["Emily", "Jones"]]
console.table(people);
niice
Yup it does
https://i.imgur.com/SC5Ydp3.png
obvs can add the parameters you want, just grabbed a few random ones
You should include the check if(guild.available) ... then display it
That works.. thanks.. for some reason i tried to create an Object, many new arrays.. maybe im too deep in the PHP stuff
technically it works with objects too, just the guild object may be a bit much to do that with
if you need it to be presentable(not 0, 1, 2)
console.table(client.guilds.cache.map(guild => [guild.name, guild.id, guilld.icon]), ["name", "id", "icon"])
ye
probably a cleaner way to do it. but im lazy 👀

cough i.. s.. sorry,.. but.. uuh
hehe
Now the table is empty

heck, I did it wrong. thats mb
But its correct.. i guess.. i read a bit in the documentation for console.table
@signal flax
console.table(client.guilds.cache.map(guild => {name: guild.name, id: guild.id, icon: guild.icon}))
would be the correct way to get everything to work, I would think.
console.table(client.guilds.cache, ["name", "id", "icon"]))
also could work.
tbh, not worked with tables enough
i mean.. if i do that i only get the ID as "key"
https://i.imgur.com/b7PT9PB.png
But i just realised why it cant work that easily. Its not an Associative Array
sorry copied the wrong thing ^_^
Is it worth to spend time on printing the table of guilds into your console instead of working on bot features?

Ha! Got you, Sir!
Personally i really like knowing where my bot is, what it does and stuff like that
All my web apps had extensive logging features so... hehe
why not use something like honeycomb or datadog
But thats also enough for me. cD
https://i.imgur.com/p6ZwxYA.png
or just get a proper database explorer like pgadmin
Just throw anything into a database
Yeah well
Well then save guilds your bot got added to in the associated event and additionally again in the ready event
As well as commands users used etc. IF you really need to
Anything else is cached by your lib already
Hi I Need Project Moderation bot
I guess i would do that.. but i wouldnt to that in prod.
Hmm depends on your bots features
Btw.. cheat mode
https://i.imgur.com/tVWj4DJ.png
I generally do that for statistics and metrics
For now its a Music bot.. the funny part comes when i finally create my own little YTID -> Song Database
What’s the purpose of this database?
Cutting of the only Google API i use
Not sure if music bots have a future especially if they use YT
why are you even trying to print a table
Bc. it looks nicer than just a random blob of text
but why even print it in the first place
I’m not gonna question “features" people code in this channel anymore.


nah, its bad code. somehow messed that one up twice
adding parenthesis around the object will fix it, the arrow function thinks the brackets are the body.
console.table(Array)
@reef stump gyan
pls help, I'm trying to do a music command but i still get this err
Hich Bzanm La xati 😂
@reef stump aaa
@signal flax wara aw projecta chak bkayn
Mast Froshi 😂 😂
@reef stump nauala kulera froshm😂
😂 😂
🥺
@signal flax aley Boxoman Serverman Nya Hatuyn Lera qsa akayn 😂 😂 😂
Console.log(„Serverid. | etc.“)
@reef stump toy ni leray😂
😂 😂
@signal flax Hatiw la hamu shwenek ham
Kura aaa😂
It’s only for „not forgetting what coloumn was what“
lol imagine the guild name is longer than ur table destroying your format

Uh… let’s not talk about that hehe
Btw.. what are these guys speaking… is that php8?
Referencing this one function that’s was named in Hebrew… kinda funny tbh.
do
Dunno they should probably move to #general-int
*error
https://en.wikipedia.org/wiki/Scope_resolution_operator here is the lore for the unchoosen
In computer programming, scope is an enclosing context where values and expressions are associated. The scope resolution operator helps to identify and specify the context to which an identifier refers, particularly by specifying a namespace. The specific uses vary across different programming languages with the notions of scoping. In many lang...
Should have said idc 

God thanks I disabled animated emojis or gifs 
Np gonna send over the invoice real quick
I’ll let my accountant know
how do i chheck if an item is not in here?
for (const key in de){
if(de[key].A.toLowerCase() == maka){
z = de[key].B
}if(!de.toString().includes(maka)){
z = 'This item isn`t in the database!'
}
}```i have this now, where de is the ss i sent. This always returns me 'item not in database'. How would i fix it?
console.log(key)
How can I fix that? I'm trying to do a music bot!
Error: Error: Cannot find module '/root/novabotv13/node_modules/@discordjs/voice/node_modules/@discordjs/opus/prebuild/node-v93-napi-v3-linux-x64-glibc-2.28/opus.node'
so to loop i used de[key]
how can I fix that?
you can do for(const key of Array[])
opus package?
Replace Array with your array
this is de[key]
And you won't have to call it by index
Wait what?
already did
yeah
for(const var of Array) will work
the same way
and you don't have to call the index
Use the new package
remove opus
Remove opus completely
npm uninstall -g <package>
so it would be npm uninstall @tepid scrollordjs/opus
I'm kinda lazy
oops
Poor disc
another victim of a non needed ping
damn lol
npm uninstall <@discordjs/opus
37 packages are looking for funding
What is this?
ignore them
Tbh, always thought it was like donations
That's my ninja way, dattebayo
I send the full err
They are looking for help funding the development
what node version are you using
16
.?
novabotv13]# node -v
v16.10.0
hmmm
latest is 16.10?
I dont even use it man
I'm using @koenie06/discord.js-music
maybe is this package?
but in local worked and on vps no, i dont get it
Different djs versions?
wait i used that once
that package was ratelimited because youtube put a strike on it
I dont get y on local works and uploaded not anymore
How do I count the amount of documents in mongoDB?
How can I make a message autodestroy itself?
msg.delete({timeout:5000})
})```
with this?
What version of discord.js are u using?
v13
The timeout option was removed in v13
You'd have to use .then(sent => setTimeout(() => sent.delete(), 5000))
Deletes a message, even if it's not cached.
tysm
Can I get the id from someone who used a slash command?
if i did this
<ClientApplication>.commands.cache
would have something right?
Eris ftw ^_^
A
Nothing. In terms of updating commands without restarting the app, comparing name, description and options with the cache instead of fetching the commands is useful.
Not like a few commands would increase the cache size dramatically
today's 24h project: a local music bot 🙂
https://github.com/brainboxdotcc/musicbot/
i wanted something to stream my personal music collection on my server, so i made this... and it became something more because others said they wanted to contribute to it
cpp best for music bots 
Somehow looks like Brain has too much time
you'd think that, this is about 8 hours work
Small numbers
i'd spend more than 8 hours a week wrestling the damn turkbots out of the queue
ARA911 FBI ATATURK LOL
say, do any of them even have slash commands yet?
🤣
lol
I have maybe had 2?
Well it’s still enough time til may, don’t worry 
and 99% broken
lol
nah
queue is better now
Just big again
I am gonna crush it next time I have a free week
Waiting on getting quarantined again ;ekwk

lmao, this song really took some encoding
[INFO] Begin mp3 decode of file: Nightwish - Ghost Love Score
Note: Illegal Audio-MPEG-Header 0x4c595249 at offset 17287437.
Note: Trying to resync...
Note: Hit end of (available) data during resync.
[INFO] End mp3 decode of file: Nightwish - Ghost Love Score [4.95 seconds]
[INFO] Begin opus encode of file: Nightwish - Ghost Love Score
[INFO] End opus encode of file: Nightwish - Ghost Love Score [92.73 seconds]
92 secs 😮
good job it can start playing while its encoding the opus lol
F12 -> inspect element
i cant figure it out
After u select the background, look at the bottom right corner, the classname will be listed there
is it this: chakra-ui-dark
Try it
code?
Don't use Discord buttons package. Discord.js v13 has them built in
So i need delete buttons package?
buttons.channel seems undefined
I havent worked with buttons so im not sure how to fix the issue
It's recommended to use the official wrappers for Buttons.
But I'll go ahead and tell you that the channel ID passed to the wrapper doesn't exist
If you're using v13, there's a specific casing for Id
I forgor what it is
you forgor 💀
Yeah. Update Discord.js to v13 and have fun fixing bugs and syntax changes from v12 to 13
I'm am dummy 💀
English
Oh shit
I’m having issues voting
Bots using discord.js v12 already crash upon encountering a stage channel 
Like, every time I try to vote, the page refreshes during the ad
v11 moment?
v11 is dead
v12 at least works but would crash upon encountering a stage channel
Damn if i upgrade to v13 my bot gonna be deadddd
It's fairly easy to update to v13
Yeah but i dont have so much time to work on bot i have school
This should help you update from v12 to v13
https://discordjs.guide/additional-info/changes-in-v13.html
yeah it cant register stage channels
and crashes
some ppl found a fix to this but wait until 2022 april(?)
v11 can't even connect to the gateway
it can
There has been changes that breaks the entire thing
great for people who only copies codes lmao
Discord API v6 will probably become inactive entirely after they offically enforce the message content intent
probably sooner
I REALLY have to update my Discord libs because Discord sucks and updates super frequently for whatever reason
and then I also have to catch up with commits to Discord.js
Idk how or why they have so much activity
it's like they're pulling shit from their ass

They basically pull something new out of their ass entirely out of the blue, it's really annoying for lib devs honestly, it's the reason discord.js v13 was so delayed 
frfr
It's made me super de-motivated from updating my lib forks
plus I like spending time with my wife
Reject lib development, live happy with wife 
Rates of?
It's great, well as you know I maintain Node.js and V8 which is kinda pretty hard to do so and many other projects, well you can count on me; but not sure how much you would pay, it's really up to you for the pricing, I've made tons of stuff for people for free
Nah. Taking up an offer on free dev is self destructive to the dev unless they were super dedicated helping to the project. I burned myself out over the years of doing everything I did for free or next to nothing. If not for my own enjoyment or benefit, then it's not worth it for me
Good point, well you can hit me up anytime for the development of your projects or new ones so I can see what I can do and discuss the pricing if you're up to it


guys how do i get the tags of all the owners of all the servers my bot is a part of
You can get owner IDs from guilds and resolve them to users
how
pelase help me
i want to die right now my bot got into many servers because of good feature set and discord flagged it for inorganic growth
so i want to check if there are people who just invited the bot to multiple servers
also i did try doing that but it returns as undefined
can someone please help me
forEach is synchronous iirc, so it'll console.log before running the .then()
Use a for loop
for (const guild of client.guilds.cache.values())
console.log(await client.users.fetch(guild.ownerId));```
Or u could map it to an array and use Promise.all()
a .then block can only run once all the code waiting to be run in the stack (like your console.log) is run and cleared. If you have code that relies on the result of a promise it all has to go inside the .then block
...sooo node-fetch only works with esm imports now
I don't wanna use old versions though, looks like I'll have to switch
could this work?
inter.member.id
Try it and see
Whut?
U have to use import since node-fetch v3
I don't get any err but the command doesnt work
no longer const fetch = ....?
- const fetch = require("node-fetch");
+ const fetch = (await import("node-fetch")).default```
Or actually use import if you're dealing with ESM
Now typescript can't find the declaration files for node-fetch even though I've installed them 😩 what a mess
But they're built-in?
Try inter.user.id
yeah for 3.0.0...
inter.member is only for guild-only command interaction
but there is no user property in docs :/
There is
I changed my mind
still doesnt work :/
if(msg?.includes('{User}')) replaced_message.replace(`{User}`, `\${member.user.username}`)
if(msg?.includes('{Server}')) replaced_message.replace(`{Server}`, `\${member.guild.name}`)
``` Why is it not replacing the words?
let replaced_message = msg;
if(msg?.includes('{User}')) replaced_message = replaced_message.replace(`{User}`, `\${member.user.username}`)
if(msg?.includes('{Server}')) replaced_message = repreplaced_message.replace(`{Server}`, `\${member.guild.name}`)
``` So if i use it like this it would work?
Yes
Works now , thx guys
Is there an equivalent of array.filter that only returns element indexes?
another for loop for every interaction
seems fun
another?
I have four
well a filter is basically a for loop too, soooo
Damn
[92, 2, 47, -12, -6, 31].map((e, i) => [e, i]).filter(([e]) => e > 0).map(([, i]) => i);```
the first arg to the second map isn't an array
how is the destructuring working?
better just use a for loop
otherwise map.filter.map is 3 loops
a for loop can do it in one
Stop hating, just because you’re too old to remember all function names and the order of their parameters 
for those who dont know, .split() in js is explode() in php
And Sir we’re proud of having this
5/7 naming scheme
should I open my bot repo? it's already organized so I don't leak critical stuff 
which splits by number of chars
the better question would be, would anyone be interested in improving my code and request to pull those improvements?
does php have any prototype/class methods on strings? or is everything funcional?
Mostly ppl do not contribute, when they do not need the stuff.
ye, youre likely only gonna get contributions from people who use your bot and/or code
yeah, makes sense
and probably 99% of the users don't code
idk, I was thinking of some kind of GitHub lurker looking for code to contribute
which is a very small group and you have to have attention, that someone does not clone your bot.
that's the problem. even though they don't get any tokens, they could steal the code 
ain't there a way to make it public but deactivating the clone option?
You can protect your work with a license.
There’s also an implode() function 
And explode()
that won't do the whole trick
Yeah, you can never be safe....
UnhandledPromiseRejectionWarning: TypeError: allmembers.send is not a function
allmembers.send('Test')
allmembers.send is not a function
aka, .send does not exists in the variable allmembers
how to do that now?
let allmembers = message.guild.members.cache.filter(member => member.presence.status !== "offline")
allmembers.send('Test')```
oh
if you want to send a message to multiple members, you have to send one by one
okie
for(const member of allmembers) {
await member.send("test")
}
Imagine using send() on the whole user collection… fun guaranteed
imagine if discord supported batch/bulk endpoints for everything
Discord "a safe place" you know
no reply
check logs
clear logs
then you did something wrong, or didnt save
that will throw an error if the message fails to send
isnt that mass dming
yes
what i mean by isnt is it is
const discord = require("discord.js");
module.exports = {
name: "massdm",
category: "moderation",
usage: "purge <number of message>",
run: async (client, message, args) => {
let allmembers = message.guild.members.cache.filter(member => member.presence.status !== "offline")
for(const member of allmembers) {
await member.send("test")
}
}
}```
xD
srsly dont do it
ull get a:
- ban from topgg(if ur doing that on ur bot that is in topgg)
- get ratelimited
const member of allmembers.values()
🙄
nope its private bot chill
if u do get ratelimited it could affect ur bot in topgg too
if its an ip ban
it also can affect your account
oh
like in general why do u want to MASS DM 100 members
discord can by their TOS close your account for your bots api abuse.
Btw. you need the intent to get presences
Maybe there’s a legitimate reason like sending ads
for a private bot?

thats also a violation of the api tos

also low chance of everyone is being in the bots cache
Ding dong, and we found another example of sarcasm resistance
only if u do .fetch
Caching all members will have a lot of memory footprint
Tfw only mod at work does it
/home/runner/Snake/node_modules/discord.js/src/rest/RESTManager.js:32
const token = this.client.token ?? this.client.accessToken;
^
SyntaxError: Unexpected token '?'
Hint: hit control+c anytime to enter REPL.
Error ^
const SnakeGame = require('snakecord');
const Discord = require("discord.js");
const client = new Discord.Client();
const snakeGame = new SnakeGame({
title: 'Snake Game',
color: "GREEN",
timestamp: false,
gameOverTitle: "Game Over"
});
const config = {
prefix: "!"
}
client.on('ready', () => {
console.log("Clearing Console");
console.clear();
console.log('Ready!');
client.user.setActivity(`${config.prefix}snake`);
});
client.on('message', message => {
if(!message.content.startsWith(config.prefix) || message.author.bot) return;
const args = message.content.slice(config.prefix.length).trim().split(/ +/);
const command = args.shift().toLowerCase();
if(command === 'snake' || command === 'snakegame') {
return snakeGame.newGame(message);
}
});
client.login(process.env.TOKEN);
Code ^
d.js needs at least node v16.6
How do i update it with the Console?
I am on replit, how i update?
Use a Node version manager
Where?
I don't know what Tim's solution is
^ ^ ^
you can use the official nix solution now
the nix repo updated their stable node to 16.8
link?
previously this solution was limited to node 16.4 since it depends on the nixos stable repo, but nix updated it recently to 16.8
my bash solution is still the only one that supports unofficial builds tho
like the pointer-compression build
compres ion??
🗜️
Voltrex get out of development!
i'll take free 30-40% memory reduction anyday
FakE quit driving!
only 4gb ram imagine
Ha! I'm not at the moment
what if repl suddenly lets people use 5gb ram and times change
they dont even let you fully use 512mb lmao
lol
so thats still a long way to go
plus, even in a vps, you will rarely use 4gb ram on a single node process
you will likely process shard way before that
what if its a turkum bottomom using lots of memory with internal sharding
they can go fuck themselves
Oh no npm i * bottums
also, if they're using 5gb, with pointer compression it will likely use less than 3gb
so still within limits
:^)
🤔 pointer compression?
yes
what if hypothetically they used 9gb
they have lots of image buffer cached
o hype
and fetching from disk takes 20 seconds each
lmao
Just yelling at the computer > *
in russian accent: work or i wiw kiw you
"START MY BOT NOW"
That sentence didn’t contain any cyka or blyat…
Weird
Thought that’s part of any Russian sentence
blyat job tvoyu mat
tbh, would double check the code for it before using it.
But if it works I dont see why not
I don't recommend using that all-in-one lib since it can be pretty outdated and not updated in a long time, and it also limits the functionality than just using the official libs provided by the bot lists

most botlists will probably error without an actually listed bot
Also chances are it'll just end up bloating ur code
Since rarely someone will have a bot in ALL supported lists
just do individual calls
or write ur own multi-post wrapper
I’m trying to install node canvas, but I keep getting the error npm ERR! code 1 And afterwards npm ERR! command failed. My node.js version is 16. I heard that you can try downgrading to version 14, but I believe Discord.JS requires version 16. Any way to fix this or alternatives to node canvas?
Hii,
futures = []
with ThreadPoolExecutor(max_workers=len(accounts)) as executor:
for users in get_user_followers(username): # get_user_followers is generator
for scraper in scrapers:
future = executor.submit(get_followers_email, scraper, users)
print(users)
print("Next")
futures.append(future)
for fut in as_completed(futures):
fut.result()
- what i'm trying is get the values from generator
- there are two workers, so each worker should process the different values
but in here both workers are processing same values
can someone help me? Trying to use react with typescript
Did you use the TS template?
nvm, but I am getting this error when running tho:
Could not find an open port at 0.0.0.0.
Network error message: listen EACCES: permission denied 0.0.0.0
deno better than node in performance?
no
I guess very few deal with ThreadPoolExecutor
This people ,who tell that smthg else is better then this, but never use it 
help pls
deno is not a language
it is a js runtime like nodejs (made by the same guy)
question: what is the limit for how many buttons an action row can have
5
ty
25 buttons are possible ,If your text is small
ok
is 5 button limit for a poll command enough?
because having more than 1 row === extra logic and headaches
anyone? pls
firewall problems
how do I solve
I tried many different ports
allow nodejs access to network through windows firewall
alright i'll try
how do I set a prefix for discord.js?
how is your command handler setup
also if you're using slash commands / is the prefix
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');
const clientId = "848292306088230922"
const commands = [{
name: 'ping',
description: 'Replies with Pong!'
}];
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: commands },
);
console.log('Successfully reloaded application (/) commands.');
} catch (error) {
console.error(error);
}
})();
const Discord = require('discord.js');
const client = new Discord.Client()
// I have intents but didnt put
client.on('ready', () => {
console.log(Logged in as ${client.user.tag}!);
});
client.on('interactionCreate', async interaction => {
if (!interaction.isCommand()) return;
if (interaction.commandName === 'ping') {
await interaction.reply('Pong!');
}
});
client.login(process.env.token);
Console
Sucsesfully reloaded (/) comannds
/ping
no response
Whats my error
I’m trying to send a buffer as a file, but I get this error.
Code: https://sourceb.in/7qnPjkxC6D
Registered commands can take up to 1 hour until they're pushed.
You should not register commands anytime you start the script.
Is there other way?
Sure fetching the registered commands, comparing them to yours and if they're match, return, if they don't match each other, update them, if they're missing, create them.
the error is that your discord needs a few seconds to reload commands before you can use them
It has been nearly 20 minutes
news flash detritus encourages you to do exactly that (not necessarily for slash commands tho)
Still didnt respond
did you literally type /ping or type / then use the slash command UI
And i just copy pasted what includes djs npm page
I know, but it's trash
There's no slash command registered
Try message.channel.send({ files: [attachment] });
Aight
If so the UI would pop up
You need to wait up to 1 hour until global commands are deployed
or pushed
why do global commands update instantly for me?
is it just registering a fresh new command that takes time
BECAUSE updating is NOT registering
Yes.
Sometimes updating a command can result in a interaction command failed.
no it appears instantly when i type /newcommand and wait only 5 seconds
cry
You might be lucky then, idk doesn't work for me even if I usually don't need to wait an hour at all
Works! Tysm
im crying because my tictactoe command is complete non working spaghetti
skill issue
Does the app even has permissions to create slash commands?
applications.commands is missing
How do i give this perm
you need both bot scope and applications.commands
invite the bot again
Its the first time i am using application commands
Changing the scope for your invite
=bot%20applications.commands
=bot+applications.commands
Why isnt there eaiser way
An easier way of what?
...
Because guild owners need to grant the permission
Imagine every bot could register like 200 slash commands

without your permission
I’m doing some canvas stuff, but when I try to do var someImgIdk = new Image(); I get the error, “Image isn’t defined.”
Morning, someone here understand anything about the new handlers with aliases and etc?
Im trying to study them
but i cant understand anything about it
new handlers with aliases
huh?
Is there a specific issue you're running into?
client.application.commands.create commands is null
syscall: 'scandir',
code: 'ENOENT',
path: './ARCHERSBOT/Commands'
}```
Code:
fs.readdirSync("./ARCHERSBOT/Commands")
.filter(file => file.endsWith(".js"))
.forEach(file => {
/**
* @type {Command}
*/
const command = require(`./Commands/${file}`);
console.log(`Command ${command.name} loaded`);
client.commands.set(command.name, command);
});
errno: -4058,
syscall: 'scandir',
code: 'ENOENT',
path: '__ARCHERSBOT/Commands'
}
What do you mean by
commands is null?
const commands = client.application?.commands
commands?.create({
name: 'ping',
description: 'pong',
})
.then(console.log)
.catch(console.error);
client.on('interactionCreate', async interaction => {
if (!interaction.isCommand()) return;
if (interaction.commandName === 'ping') {
await interaction.reply({ content: 'Pong!', ephemeral: true });
}
});
I did this and it worked
wtf is this optional chaining... these properties always exist
let command = {
name: 'test',
description: 'A test command',
};
client.application.commands.create(command);
Each command needs to be registered by it's own, using the mentioned djs method.
Create an object of all your commands, then loop through it, register each one in the loop.
Or an array... whatever you like.
It's an object in JS anyways 
I'm gonna give you an example:
let commands =
{
{
name: 'test',
description: 'A test command'
},
{
name: 'test2',
description: 'A test command2'
}
};
for(const command of commands) client.application.commands.create(command).catch(console.error);
Unexpected token '{'
Oops... accidentally put a ,
How can I fix this?
var lastEditted = await bot.users.fetch(server.lastEdited).catch(() => null);
.setFooter(lastEditted ? lastEditted.displayAvatarURL({ dynamic: true, size: 4096, format: 'png' }) : null, `Settings last edited by ${lastEditted ? lastEditted.username : "no one"}.`)
Not sure how I can code this properly. :/
Fixed the code already.
huh, gimme a screenshot, please
lol put { } instead of [ ] around

I mean you can also use a map.
Better to work with
Are you on v13 already?
You're client is already logged in when calling the methods?
Yes
Watching your first screenshot, it isn't.
You're calling the method before login in.
Make sure to register commands for example in the ready event
Or later...
Okay it doesnt give any error in console but didnt load commands also
guys can someone help me (if you can help me its a discord bot, DM me for the github code idk why it doesnt work (+ server invite for test))
Global commands still take up to one hour to be deployed in all guilds.
My bot just in 1 guild
If you wanna experiment with them, create guild commands.
its an email verify bot
Doesn't matter in how many guilds it is.
client.application.guilds.commands.create ?
There are two ways... guilds.commands.create()
Or passing the guild ID like so:
client.application.commands.create(command, guild_id).catch(console.error);
let commands =
[
{
name: 'test',
description: 'A test command'
},
{
name: 'test2',
description: 'A test command2'
}
];
for(const command of commands) client.application.commands.create(command, "guild-id").catch(console.error);
So annoying
That's why you build a proper command handler once, like for casual commands, and that's it.
You need to be careful registering the same commands over and over again, as well as mixing guild ones with global ones.
It's tricky but once you got it, it's actually easy
I removed slash commands from my bot a while ago and they are still showing up
let x = await client.application.commands.fetch()
x.forEach(a => a.delete())
Something like that
Is there a way to fix this? To force caching of users?
client.application.commands.set([]);
Will update any to "nothing" aka. removing them
😔
What was the point of even writing user interactions if I can't do this
You can of course fetch users.
Since you can't right click these users to get the Apps menu entry
If you got the user IDs you can force fetch them from the API
They'll show up on some clients but won't on others, I have no control
It didnt work
Oh nwm i made my commands guild commands
Can’t actually tell you if the update is immediately or will take some time, too
(speaking about global commands)
Can someone explain to me why this won't work?
I am using MongoDB and want to display the current amount of documents as the name of a voice channel.. if I console.log the amount it logs the 1 but the channel name does not update :/
Do you know how can i delete guild commands also
I tried guild.commands.set([]) but didnt work
that looks like mongoose, not mongodb
yeah .. I mean mongoose. sorry
FakE will be right back, please hold the line
Well if you wanna use the guild obj/class then define it
Or fetch the guild you're trying to work with
Or get it from the cache etc.
const guild = client.guilds.cache.get(guildId)
I'm new to cogs so can someone tell me what self is used for and when to use it
Also what do I put in def init
I made it message.guild and worked
Can't tell you if set([]) still works but you will notice when catching the errors
But it should
Registering them as guild commands is mostly for testing porpuse only
I wanna make them public
They need to be registered as global commands then.
Than i should use this right?
I have my python bot hosted on heroku and want to be able to change text files in the repository. How can I make the changes from say f.write(“foo bar”) persist and not reset?
It's up to you, it was just an example.
Ill change it to command files
But register time is really much i think
And my bot relogs 4 5 times in a day
A proper command handler will load your (export) modules, fetch the ones already registered, compare them to each other, register/update/delete new/old ones, and that's it.
If i use it like normal command file will it cause any problem?
Ahh nope, I'm doing the same
const cmdF = ["moderation", "info", "others", "config", "giveaways"]
cmdF.forEach(x => {
const command = fs.readdirSync(`./commands/${x}`).filter(file => file.endsWith('.js'));
for (const file of command) {
const command = require(`./commands/${x}/${file}`);
if (typeof command.name === "object") {
command.name.forEach(x => {
client.commands.set(x, command);
});
} else {
client.commands.set(command.name, command);
}
}
});
I'm taking the command name and description as slash command name and destription
It will take much time ||bc i am all alone||
Using the same structure to build slash commands
With additional properties like options etc. for components
i thought of rythm and made this
let channels = guild.channels.cache;
textchannels = channels.filter(c => c.type == "text");
cnl = textchannels.map(c => c.id);
console.log(cnl)
ch = guild.channels.cache.get(cnl[0]);
console.log(ch);
const Embed = new Discord.MessageEmbed()
.setTitle('')
.setDescription(``)
.setColor(`RANDOM`)
.setURL(``)
.setThumbnail(``)
.setTimestamp();
ch.send({embed: Embed}).catch((e)=>{console.log(e)});
})```
Huh
What's the point of all those variables when you can just use const channel = guild.channels.cache.find(c => c.type === "text")
Too many unnecessary mutations
Also sending an empty embed, wut?!
its not empty
its got stuff in it
its just that it will look long asf if i had the text in it
Ah alright
Also keep in mind what flazepe mentioned
true
thats just what i found worked
i didnt try anything els i just did that first tbh lol
Yeah just to say, creating vars makes sense only if you use then multiple times
tbh, if you are speed coding something and do that its fine, but always clean them up if possible.
ye true
Like counting an array 10 times for example is ineffective, creating a var once, then using the var is effective
its just im trying to add simple little things for new version
which api call can get me the count of members that belong to a guild?
This endpoint doesn't have the info https://discord.com/api/v9/guilds/{GUILD_ID}
Aparently it's only sent in some cases
https://discord.com/developers/docs/resources/guild#guild-object-guild-structure
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
Only on guild create
client.commands = new Discord.Collection();
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(./commands/${file});
client.commands.set(command.name, command);
console.log(command.name)
}
client.on('interactionCreate', async interaction => {
if (!interaction.isCommand()) return;
const command = client.commands.get(interaction.commandName);
if (!command) return;
try {
await client.commands.get(interaction.commandName).run(client, interaction)
} catch (error) {
console.error(error);
await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
}
});
const Discord = require('discord.js')
module.exports = {
name: "ping",
descriptio: "pong",
async run(client, intereaction) {
intereaction.reply("Pong!")
}
}
Why command didnt load
noo, not the gateway!
Itsnt importnt that
So i defined it intreaction everytime lol
but description is not going to be correct if spelled "description"
Yes i fixed it
anyways any errors?
Yes
I moved it(intereaction executer) to event files it doesnt respond now
module.exports = {
name: 'intereactionCreate',
execute (client, intereaction) {
if (intereaction.author.bot || intereaction.guild) return;
if (!intereaction.isCommand()) return;
const command = client.commands.get(intereaction.commandName);
if (!command) return;
try {
client.commands.get(intereaction.commandName).run(client, intereaction)
} catch (error) {
console.error(error);
intereaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
}
}
};
what was the error though?
The event is called interactionCreate
i think that broke my brain
not intere
i mean his way of doing it
Already it is it
there should be an error in your console
This is the similar for me lol
what is the error
No error
have you registered slash commands?
there's the issue
you moved executor to the event files
the executor grabs the code from the event files. an executor would not work in the event files
İnteraction?
so you put the command as "interactionCreate"
interaction
intereaction
It was
**```
intereactionCreate
It’s not a command, the module represents his event listener
ok take back a step
So i do it interaction
Without the extra E yes
i said that earlier
Weird to move the events to modules, but why not everybody has its own style
Have to i use async function in execute thing
I dont want crowd in my bot.js
I need to use it for my pleasures lol

Okay once again what’s not working and what are you trying to do?
In a Short Version
This is my code
I wanna move INT execute commands SHIT to event files
I have event file loader
And you fixed that code already?
Because you sometimes added the extra E to the var name and sometimes not
Check all vars again
They did i just copy and paste
who?
interaction
Discordjs
Sometimes there are typing intereact
Sometimes interact
Check guide
i think you're reading the wrong guide
djsv12 to v13?
The parameter is called async interaction =>
You’re using intere as var name below which can’t work
Man just fix all those wrong var names and the code should work
Can’t see any real issue but watching code on mobile is the worst thing to do anyways
interACTION
Then what is InteReaction
send a link to the guide you read
And i found the issue
const command = require(`./commands/${file}`);
I made int.guild not !int.guild
that doesn’t exist, the last E is one too much
Even tho it will still fail
If I define a var called interaction, I can’t use intereaction later on
let x;
console.log(y);
client.on('interactionCreate', async intereaction => {
if (!intereaction.guild) return;
if (!intereaction.isCommand()) return;
const command = client.commands.get(intereaction.commandName);
if (!command) return;
try {
client.commands.get(intereaction.commandName).run(client, intereaction)
} catch (error) {
console.error(error);
intereaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
}
});
Ill define int
So similar
The property guild is always present, check if guild.available
If used in guilds of course
Instead of getting the element of your map twice
Dw i alreay dont have dm intents
It failed
whats the minimum time you can temp ban? i would guess its as short as you want
less than 1 microsecond
no less than your ping 👀
"temp ban" is a concept not a well estabilished thing
although you're physically limited to planck time
so...well...there you have it, planck time
I get: free ban
you receive: demotion
i like this deal
Anyone know how to implement a push_front function for a Vector without using insert
(c++)
you make a temp ban like this right?js user.ban({ days: time reason: 'reason' });
ahh
temp bans are bans you unban after a certain time, youll need to track that in a database.
sounds like a bad idea tho, whats your use case?
then i think ill just stay away from that for now
Just an assignment req
It definitely is a bad idea but I just wanna know how efficient I can get with it
I have one implementation of it but it's very slow
(as it should be)
well i dont think there is any way to do it other than resize + move
or alloc a new one and copy

unless...
you make a vector implementation using raw buffers
and alloc more memory than needed, but keep adding data to the end
lol

I'm in my first month of c++ classes, please go easy on me
I'm a python programmer so my intelligence is severely lacking
Well if I'm gonna put in numbers from 10 to 1, it should be like, in order yea
I'm assuming that's what you mean
ye
another way would be to push all the items, then reverse everything at the end
What I'm doing is just
but thats not really a push front implementation
yeah, thats another way
if you didnt need the order, you could just swap one item xd





