#development
1 messages · Page 1947 of 1
Error: Top.gg token is missing
at AutoPoster (C:\Users\ADMINISTRADOR\Downloads\Clash-Chest\node_modules\topgg-autoposter\dist\index.js:20:15)
at Object.<anonymous> (C:\Users\ADMINISTRADOR\Downloads\Clash-Chest\index.js:58:15)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:17:47
throw new Error('Top.gg token is missing');
^
Do people here plan on trying to implement the new timeout feature into their bots? If so, I have a few questions about it:
- Timeouts are indeed cool, but how exactly should one go about logging when they expire? Discord doesn't send a gateway event when the member's timeout expires, only a
GUILD_MEMBER_UPDATEevent when the timeout is created. My initial thought was to have a background service that checks every 30 seconds, but I could end up looping through thousands of members needlessly.
const dotenv = require('dotenv')
dotenv.config();
const apost = AutoPoster(process.env.DBL_TOKEN, client);
??
Console log
don't post your token here, just try to log it and see if it works.
You could have it backed by a db
idk why but vsc is much comfortable than replit
When you mute also add the user to the db with the timestamp
That is true, I'd just refactor abit. I was already using postgres for storing timed infractions(temp mutes, temp bans), etc.
Ah, so it really isn't any different. Thanks!
Cuz it's a step above vsc when it comes to the term IDE
It's not an ide, but it's more ide than replit
yeah
dotenv.config();
console.log(process.env.DBL_TOKEN)
``` i'm console logging it but nothing's appearing, just the error
The good thing is that it'll be way less hack job than we used to do since it'll all be handled by discord now
Indeed. I like especially that timeouts persist even when they leave.
in your .env file is there a DBL_TOKEN = <value> ?
yeah
can you send a screenshot? Blurring out the token ofc.
did you make sure that the file was saved?
vsc doesn't automatically save. so try making sure all your envs are set, then doing ctrl + s
Yea, re save everything and try again.
It’s probably 0kb because you’re storing like 100 bytes of data

dblapi? bro use https://www.npmjs.com/package/@top-gg/sdk
so lets say im using discord.js and getting the number of guilds my bot is in using something like client.guilds.cache.size. If my bot is then kicked from a server, will that server remain in the cache? 👀
C:\Users\ADMINISTRADOR\Downloads\Clash-Chest>git init
'git' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\ADMINISTRADOR\Downloads\Clash-Chest>heroku git:remote -a clash-chest2
» Warning: heroku update available from 7.53.0 to 7.59.2.
» Error: Git must be installed to use the Heroku CLI. See instructions here: https://git-scm.com
bruh
I've installed git
why does this never return as equal?
if args = 1 it still says its not
i have tried using '' and just no marks at all
without the !
What in the name... is that syntax
backticks can't be used tho
its me being out of ideas and trying random stuff to see what happens
if(number !== "1" && number !== "2" ...) return
i did try '' and "" and [] as well just didnt put it back to what it was orriginally
oooooh
i put the ! in the wrong place
thx
not OR not is logical nonsense
!number == 1 will work if number is 0
mmm its still not working
error: src refspec main does not match any
error: failed to push some refs to 'nope'
i think I'll just do it the other way around instead of using the ! and using return
Just show what you did
who, me? or the other guy?
You
you need to use members not users
Look at what I wrote
users dont have permissions
yeah but if you use and that means it wil only work if it is all of them
dont do that!
[1, 2, 3, 4].includes(number)
do that.
np, might need to parseInt(number) to make sure its not a string 🙂
that will only check if they have ban members, not kick or admin
You could use any
<member>.permissions.any(["KICK_MEMBERS", "..."])
Using the flags, bitfields etc.
Anything works
I always forget any
I mean you can complicate things a little bit more, too
let permissions = member.permissions.toArray();
How can i add event listener on a module
Then checking if permissions.includes("...")
Well the method return a boolean
true if the permissions contain any of the one you're looking for
If not it returns false
Well if the target has any of the permissions the message will be send
That's what you check
You need to provide the permission flags
Strings will not work anymore
I just wrote an example for you
The array needs to contain the numeric permission flags
any([Discord.Permissions.FLAGS.KICK_MEMBERS, ...])
"dependencies": {
"discord-giveaways": "^5.0.1",
"discord-nsfw": "^1.3.0",
"discord.js": "^13.3.1",
"moment": "^2.29.1",
"ms": "^2.1.3",
"quick.db": "^7.1.3"
},
thats my moduls
Log the targets permissions
They might not be cached
.toArray()
What's target then
Is he the guild owner?
Check if the mentioned member is the right one
<dm channel>.send().then(ban())
Or simply
await message.send()
await member.ban()
You await the message at first
send the message befor ethe ban
await target.send("message") #send message
await target.ban() #then ban, reason is optional```
what language
try {
//send
}
catch {
//whatever the js equivelant of pass is
}```
Not any user accepts direct messages
If he doesn't you obviously can't send a message to him
Hey! The Discord docs says this should work, but when i try to execute it i get an error saying it isnt a function. Does anyone know y?user.timeout(ms(time + string), reason);
You can supress the error as well... catch(() => {});
Not needed to log the fact some users don't accept DMs
Hey how should i make premium system to my bot? (Per-user/per-guilds and etc, just tell way how i should make it)
have a database of premium users or guilds
and then check if they are there
based on id
I didnt ask HOW to code it
I asked what method
I said
Per-user, per-guild
using a database
What will be best
ohhhh
BRUH
per user
Should i make it like dankmemer??
And what's your reason behind per user
So like dankmemer
per user = more people likely to look at it
if per guild then they will only buy if they are a server owner
Pricing:
Premium without server upgrade:
1 month - 2$
1 year - 20$
Premium with server upgrade:
1 month - 2.50$
1 year - 25$
Upgrade when have premium:
1 month - 1$
1 year - 10$
Upgrade when dont have premium:
1 month - 1.50$
1 year - 15$
if per user than multiple people would buy
for capyhost i'm just storing images on a vps located in Europe, is it worth using geodns to have a second vps located in the US for faster image speeds?
How else can i do it lol, there are just few ways how you can make premium system
bruh we can do only per guild, per user, per user but you can upgrade server
Multipurpose
Then last option
Dank memer did like that
Most profit tbh
I think its great pricing, it gives alot discounts when have premium for user
it's replying to itself
if(message.author.bot) return; isn't working o-o
because its not a message
hm?
but it is a message 
How can i fix this? I create youtube together link from discord api
show your code
Does anyone know why this happends?
I fixed it.
Is that thing already available in the library you’re using, if you’re using one at all?
what's user?
if it's a User object then that's why
Yee it has to be a guild member of course
Does anyone know why an error has came up saying something is wrong with the string of this when it been checked by 2 other people and they say there is nothing wrong?
new SlashCommandBuilder().setName('updateVersion').setDescription('You are able to see the current updateVersion of the bot with this.'),
new SlashCommandBuilder().setName('update').setDescription('The owner of the bot will write updates on the bot here.'),
new SlashCommandBuilder().setName('status').setDescription('If the owner detects a lag this will be updated by him.'),
new SlashCommandBuilder().setName('developer').setDescription('Lets you know who made the bot.'),```
ig it is an object, but idk how to make it a non-object
xd
i think its only channel.topic
Thanks. Ive tried that.
Imma sleep then fix this tmrw
It has to be a guild member object not an user object
That’s what we mean
Use the getMember() method
is that a thing?
Djs will get the guild member using the user ID
ah
one last thing
does the duration of the timeout matter?
Like does it have to be 60s, 5m, 1h, 1d or 1w?
Or can it be anything
Idk which timeout you’re speaking about
what Procfile needs?
idk what to put in there, the tutorial ain't providing me it
I would guess it can be anything just not in the GUI of Discord
ah ok
client.on('interactionCreate', async interaction => {
if (!interaction.isCommand()) return;
if (!interaction.isButton()) return;
if(interaction.customId === 'claim'){```
Does that not work?
Because I'm trying to make a button in a index.js file
but uh, failing
client.on('interactionCreate', async interaction => {
if (!interaction.isCommand()) return;
if (!interaction.isButton()) return;
if(interaction.customId === 'claim'){
const cl1 = new MessageEmbed()
.setAuthor(message.author.tag, message.author.displayAvatarURL({
dynamic:true }))
.setDescription(`<@${interaction.user.id}> Claimed this Thread.\n ${message.author.tag} Opened a Thread.`)
await db.set(`claimed_${interaction.channel.id}`, interaction.user.id)
await chan.send({ embeds:[cl1], components:[claimed] })
}```
You’re sure your component ID is "claim"?
Also instead of returning non button interactions wrap the button code inside an if statement checking if(interaction.isButtion())
the property customId doesn’t exist for slash command and your code will error then
Saying customId is undefined
Well not erroring as non existent properties are magically exist in JS but you know what I mean
At least I hope you know
I just actually checked the ID and it worked lol
Now its just saying "interaction failed" on another one of my commands
interaction.deferReply;
const claimed = db.fetch(`claimed_${interaction.channel.id}`)
if(claimed === interaction.user.id) {```
Is that the way to do it
or is it interaction.user.id ==== claimed
You don't seem to be calling the deferReply() method there, you just seem to be using it as a property instead
Well, not its not registering my commands period
yeah its not registering my commands
You've probably registered the slash-commands correctly, but not handling them correctly, you can log the list of the slash-commands you've registered to see if they're actually registered or not by using <Client>.application.commands.fetch() and logging it's value after resolving it's promise
Huh Voltrex in development? General chat must be dead…
Ahh, yep works
Idek what I did wrong here
Mind taking a look at this
It'll send the embed to the user.
not the channel
could it be like interaction.editReply?
I think it'd just be reply
but not sure.
Huh, FakE not driving 24/7? Odd
Wtf is that indentation
I just fixed it 
That’s like posting a code block for mobile clients
You can guess by the error message, it means that the interaction either doesn't exist or it's expired
LMFAOO
wym?
All I did was interaction.deferReply() > interaction.reply
You only have 3 seconds to respond to an interaction if the interaction is not deferred, you don't seem to be calling the deferReply() method as I've mentioned earlier, you seem to be using it as a property instead
It's been right there.
The whole time.
Then resolve it's promise...
hm?
Do you even respond to a slash command or a button?
It's not in a index.js file anymore.
interaction.deferReply()
const claimed = db.fetch(`claimed_${interaction.channel.id}`)
if (claimed === interaction.user.id) {
let topic = interaction.channel.topic;
let user1 = client.users.cache.get(topic)
let reply = interaction.options.getString('message')
const embed = new MessageEmbed()
.setAuthor(interaction.user.tag, interaction.user.displayAvatarURL({
dynamic: true
}))
.setColor('#7289DA')
.setDescription(`${reply}`)
.setFooter(`Lightning Staff Team`)
const embed1 = new MessageEmbed()
.setAuthor(interaction.user.tag, interaction.user.displayAvatarURL({
dynamic: true
}))
.setFooter(`Lightning Staff Team`)
.setColor('#7289DA')
.setDescription(`${reply}`)
interaction.reply({ embeds: [embed1] })
user1.send({ embeds: [embed] })```
The <CommandInteraction>.deferReply() method returns a promise, resolve it
Resole it.... like interaction.editReply?
You can resolve a promise by using async/await, as await <CommandInteraction>.deferReply()
Voltrex has left the channel
That's the pain of the development channel sadly, yes

Oh no… do you register the commands at any restart?
Idfk
I went off the docs
I don't think the code inside of that if statement is even being executed at all, have you tried logging something in it?
So yes.
Yeah, console.log(claimed)
It logs the user id
It's the same error
unknown interaction
Can you show your new code including the execute() method?
Okay omfg
This thingggggg
Okay
So
Once I moved the commands up
for them to register
the buttons don't work in the index.js
Which is why the claimed user in the DB is null
interaction.deferReply()
client.on('interactionCreate', async interaction => {
if (!interaction.isCommand()) return;
const command = client.commands.get(interaction.commandName);
if (!command) return;
try {
await command.execute(interaction, client);
} catch (error) {
if (error) console.error(error);
await interaction.channel.send({ content: 'There was an error while executing this command!', ephemeral: true });
}
if (!interaction.isButton()) return;
if (interaction.customId === 'claim') {
const claimed = new MessageActionRow().addComponents(
new MessageButton()
.setLabel("Claim")
.setStyle('PRIMARY')
.setDisabled(true)
.setCustomId('claim2'),
new MessageButton()
.setLabel('Unclaim')
.setStyle('DANGER')
.setDisabled(false)
.setCustomId('unclaim2'))
const cl1 = new MessageEmbed()
.setAuthor(interaction.user.tag, interaction.user.displayAvatarURL({
dynamic: true
}))
.setDescription(`<@${interaction.user.id}> Claimed this Thread.`)
await db.set(`claimed_${interaction.channel.id}`, interaction.user.id)
await interaction.channel.send({ embeds: [cl1], components: [claimed] })
}
})
})```
The buttons don't work, the commands do.
I should add a return; {} huh?
Hold on do you listen to the events multiple times?
You're returning if the interaction isn't a button component in the first place, so it never reaches to the bottom
ahhh
So.... how does one fix that?
I needa clean the bot's ears with a q-tip to make it listen?
Damn, I wish it was that simple.
No FakE, it's just why it doesn't work
You can simply fix it by not returning...
You can do this I believe in your…
Gotta some work to do
Still doesn't work.
if (interaction.isCommand()) {
// Code for slash-commands.
} else if (interaction.isButton()) {
// Code for button components.
}
...
I removed return
ahh
Okay, now one problem down
Another to go
where is quick.db being saved and how can i revert the dattabase like it's new
It saves them in an SQL file in your project directory, the documentation should mention where it is located
Voltrex idk what im doing wrong man
The claimed if{} works, it's just not sending to the interaction channel
does it save in json.sqlite?
Yes
Show your new code I guess
const claimed = db.fetch(`claimed_${interaction.channel.id}`)
console.log(claimed)
if (claimed === interaction.user.id) {
let topic = interaction.channel.topic;
let user1 = client.users.cache.get(topic)
let reply = interaction.options.getString('message')
const embed = new MessageEmbed()
.setAuthor(interaction.user.tag, interaction.user.displayAvatarURL({
dynamic: true
}))
.setColor('#7289DA')
.setDescription(`${reply}`)
.setFooter(`Lightning Staff Team`)
const embed1 = new MessageEmbed()
.setAuthor(interaction.user.tag, interaction.user.displayAvatarURL({
dynamic: true
}))
.setFooter(`Lightning Staff Team`)
.setColor('#7289DA')
.setDescription(`${reply}`)
await interaction.reply({ embeds: [embed1] })
await user1.send({ embeds: [embed] })
```
I deleted it, does that mean that it removed all info?
So i am basically starting of fresh
awesome
It seems like you're logging the claimed variable, what does it log exactly?
The user's ID
Try logging something inside of the if statement and see if it logs anything
if (...) {
// Log it here.
}
Yeah it logs the ID still.
What exactly do you mean by that?
Try logging it right before calling the <CommandInteraction>.reply() method and see if it still logs it
Interactions carry a channel instance with them, so you can just access it and do whatever you want
Yes
Still logs the User ID @earnest phoenix
Ahh
Didn't mean to ping
My baddd
Wait, did you remove the <CommandInteraction>.deferReply() call at the start?
Wait
Could it be something do do with my execute()?
No, at least it doesn't seem to be
Ah alr
Now it works without deferReply()
help....
Then there you go
Ty lmfao
With?
I deployed my bot today on heroku with git and heroku CLI
how do I apply changes?
or it automatically changes when the file changes in my laptop?
You just commit the changes and it automatically restarts and applies the changes for you, if it doesn't; you might have to do some configurations
oh
thx
Yes, but global slash-commands take an hour to be cached
Then it's not being registered, show code
so I do ```cmd
git add .
git commit -m "Message"
You'd also have to push the changes
where
to heroku?
To your GitHub repository, you can't push to Heroku
In a tutorial they didn't make a repo tho they used Heroku CLI and git
It seems like you're doing it correctly, does it log that it successfully reloaded the slash-commands?
and they made me install heroku and git in my laptop
oh
The Git CLI is made to work with GitHub repositories, not Heroku; you can just link Heroku to watch the changes of your GitHub repository, pull the changes and apply them
pass me a good tutorial
then what would you recommend me to use? freely
Buy a VPS, cheap, way better than free hosting platforms and full accessibility
It is not a good idea to leech onto free stuff
i'm broke
Heard the same thing from 95% of the bot developers in Discord (
), if you don't want to spend a few dollars on a VPS, then sure; you can use Heroku, but there are lots of downsides on hosting a Discord bot on Heroku, but anyway, you can just Google ways of linking your GitHub repository to Heroku instead of watching lame tutorials
ok
I honestly just recommend using the client itself for registration of the slash-commands instead of using the REST module
// Guild to register the slash-commands to.
const guild = client.guilds.cache.get(/* Guild ID */);
// Register the slash-commands to the guild.
await guild.commands.set(/* An array of slash-command data */);
"An array"
You're iterating through the slash-commands so just
await client.application.commands.set(commands);
You can just use the ESM side of our Node.js runtime to get that juicy Top-level await 
You're supposed to get the guild, you're calling that method on a string which is guildId variable's value
Or by working with the inbuilt methods instead of using that weird builder functions
<guild>.commands.set([…]);
As well as create() delete() etc
Okay, so this bot is just a instant struggle rn lol, so its main purpose is what you and I were talking ab FakE, I got it to create the channel & send the message w/the buttons.
But it's supposed to check if the channel already exists and if not create the channel, if the channel does exist, it just sends the message.content but it keeps creating multiple channels.
Okay nvm, now it just doesn't send the message to the already made channel.
let channel = guild.channels.cache.find(c => c.topic === message.author.id)
Can it locate a channel using the topic?
All channels should be cached by default iirc and yes you can filter or find for any property
let channel = guild.channels.cache.find(c => c.name === message.author.tag)
let topic = message.channel.topic;
let user1 = client.users.cache.get(topic)
if (client.users.cache.get(user1) && !message.author.bot) {
let user = client.users.cache.get(user1);
let attachs = [];
const mm1 = new MessageEmbed()
.setAuthor(message.author.tag, message.author.displayAvatarURL({
dynamic: true
}))
.setDescription(`${message.content}`)
.setImage(message.attachments.forEach(attach => attachs.push({ name: attach.name, attachment: attach.url })))
channel.send({ embeds: [mm1] })
```
It doesn't send the message to the channel
Did you log channel to see if it’s the right one?
The conditional on that if statement won't pass because you're getting the user a second time unnecessarily using a user object
if (user1 !== undefined && !message.author.bot) { ... }
It should as it’s a string, or not?
Even if that’s unnecessary
It's not a string
Yea, you just focus on your driving 
How can I make a command that auto-deletes embeds sent from the bot? discord.py
Like auto-deletes all embeds that contain the same message
function submitReport() {
return false;
$('form#report').submit();
document.getElementById("before").style.display = "none"
document.getElementById("after").style.display = "block"
}```
why doesn't that work
true
maybe if you want to prevent redirecting after submit, try
<form>.preventDefault()
yea that worked t
ty
function submitReport() {
$('#report').submit(function(event) {
event.preventDefault();
var form = $(this);
console.log(form.serialize());
$.ajax({
type: form.attr('method'),
url: form.attr('action'),
data: form.serialize()
});
});
document.getElementById("before").style.display = "none"
document.getElementById("after").style.display = "block"
}```
was my final code
np 
let category = client.channels.cache.find(c => c.name == cc && c.type == "category");
interaction.channel.setParent(category.id)```
How come that doesn't move the current channel?
o-o
Because you're searching over generic Channels
You want something more specific, like searching the guild channels.
Rather than every channel your bot has access to
@earnest phoenix*
Yeh
Was a channel with the name found?
Does it have to be the full category name or just the channel?
That worked^^, how would I make it so that it moves if it also just has like the first part of the cateogry name?
.startsWith ik there is something like that...
You can adjust the finding.
oh?
let category = interaction.guild.channels.cache.find(c => c.name == cc && c.type == "GUILD_CATEGORY");
find works by returning the first item in the collection that returns logical true
c.name.starsWith?
And since the channel name is a string, you can use it like a string
So c.name.startsWith(...)
Notice how it returns a boolean
Yeah
let category = interaction.guild.channels.cache.find(c => c.name.startsWith == cc && c.type == "GUILD_CATEGORY");
So I should have (cc) in it?
Yeah, since startsWith is a function
Most issues can be resolved by searching the docs
Since it'll usually has good details
ahh
Tysm
wait
let category = interaction.guild.channels.cache.find(c => c.name.startsWith(cc) && c.type == "GUILD_CATEGORY");
That didn't work? 🤣
You may want to check the value of cc and the channel name then
Question when people send embeds in discord.js
How would you check if the message is an embed would you just check the embeds field and see if it is empty?
Yeah
if(!message.embeds.length) no embeds
The embeds property is an array
Means it’s never "empty"
But the array can be empty not the property
don't you dare go back to djs misty >:C
It was just an example.
I am curious if I could use smth like msg instanceof MessageEmbed(or Embed if using detritus)
But then I realized that wouldn't work
since it is still a message just with an embed prop populated
The detritus infection spreads 
not an infection if its a good thing
Remember that it takes up to an hour to propagate updates
though existing commands shouldn't be affected
Can you show where you're loading the commands
but commands is empty
Then what did you have before to set the global commands?
Unless I'm misinterpreting this.
As the array is obviously empty, there are no global commands. But there are per-guild commands as expected.
Yet you're asking why commands aren't updated globally despite reseting the list.
Does the command already exist?
If not create() is the method to go with
You don’t register commands on any startup
You fetch the commands, compare them with your loaded ones and register/update/delete them if needed
That’s what a proper command needs to include
await message.delete(msgID);
delete message by ID 🤔
Updating global commands can take a while, too
fetch message first then call delete
or maybe discord.js has a specialized method that doesn't require prefetching
Its python.
all the examples of fetch .then use => and it throws something about unexpected syntax something about pylance
Generally updating the commands on any startup is nonsense
Why would you do that?
They are registered globally or in the guild until you change them.
Also there are limits how many registrations can be fired
because that's not python...?
Also it does create new ones, set() just updates already existing commands
You dont update the registered commands on any startup, just if they require an update cause of changes you made
I use Python and I can tell you
Ah, then you'll need to fetch the message first and delete it (e.g. <TextChannel>.fetch_message https://discordpy.readthedocs.io/en/latest/api.html?highlight=message#discord.TextChannel.fetch_message).
It's not Python
But it has dots and letters, doesn't that sound like Python?
Oh hold on did I miss a message or a few here
okay well theres my problem 😂
That doesn’t include the registered commands name or description as you don’t change it on any startup.
Meh I can't be bothered to play detective here I'm out cya
Because there are rate limits you probably break cause of your update/register spam and even updates sometimes take up to an hour for global commands (at least in my experience)
There is, yes
200 iirc
That includes all, not just each one
5 cmds x 20 startups are already 100
I am speaking about guild limits
Not sure about global ones
But you will receive an API error if you run into the limits
What’s the code of the guild command which doesn’t appear?
Do you register or update it?
Guild commands or global commands?
i dont use python but thats not py
The bot has the right scope?
Do you register or update it?
*the commands
set only updates registered commands as I said before
yea thats definitely an issue
I really wanna troll and ask how to import js into python but I dont wanna cause any rage quitting xD
client.application.commands.create(…);
Guild commands:
client.application.commands.create(…, guildID);
Nope it only requires the name and the description
Any other parameter is optional
create() requires an object
await message.delete(msg)```
plz tell me Im being retarded
client.application.commands.create({ name: "test", description: "test123");
You don’t need (privileged) intents for slash commands
Do you actually read what I wrote?
A slash command name and description is always required
As I wrote create() requires a command object
Like the example I wrote
You can simply loop your loaded command files, and use the name and description to register the command
By passing them as object like I wrote in my example
for(const command of youtCommands)
{
client.application.commands.create({ name: command.name, description: command.description );
}
Because the guild is absolutely bullshit, waste, trash, nonsense …
Anyways even the builder examples, any of it has a setName() and setDescription() method
As both are required for commands
Djs docs also show that both parameters are required (not optional)
hey
presence intent is just used to track the status/profile update of guild users right?
discord.js became such a clusterfuck they had to do this...
fucking unbelievable lmao
when I disabled presence intent, the bot's streaming status was removed. was this normal?
I thought that intent is used to track guild members' presence update
whatever happened to using maps and arrays'
why do we need special manager, util, xchannel, blah
the idea of managers is not bad, its a way to organize api and non-api stuff
but how on earth did they manage to introduce circular dependencies
then added weird hacks to fix them
lmao
no its not normal
Can you Tell What Mean Of Message.client.db.settings.selectprefix
idk, its your code
its obviously getting some kind of prefix
intents only matter for what data you receive
your bot's own activity has nothing to do with it
just check if your activity code is correct
and make sure its reset when needed, since disconnects can remove it
How to delete Db.sqlite
Ive finished my first bot V1 thanks to a lot of ppl in this group ❤️
I can barely read tnat error message
Come dm
I did
const Schema = require('mongoose')
in my setlogs cmd as I needed to save more then just 1 Schema in the command.
Now I get an error
Schema is not a constructor
Code: https://sourceb.in/t8Hh2I8CtJ
If you can help me, thank u. Im like new to using mongodb lol
You are requiring the entire mongoose package when you do Schema
you probably want to either do Schema.Schema or just deconstruct tthe package
const { Schema } = require('mongoose')
new Schema(...)
from adding new Schema(...)
.setDescription(`:stopwatch: ┃ <@${message.author.id}> You are on cooldown. Please wait for `)]})
does any1 know how to use ms to say how much time is remaining ?
So if I have a class, called Foo and I want to store a static list of Foo objects in a map, how would I do that in TypeScript? This is what I'm trying to do, but it's not working ```ts
class Foo {
public static fooList: Map<string, Foo>;
constructor(id: string) {
Foo.fooList.set(id, this); // Not working, no idea why
}
}
works fine for me
hmmm
what's "not working"?
let me try something rq
ok so basically I have a MusicPlayer class that looks something like this: ```ts
export class MusicPlayer {
private connection: VoiceConnection | undefined;
private guildId: string;
private state: AuxVoiceState;
private encoder: Encoder;
public static musicPlayers: Map<string, MusicPlayer>;
constructor(guildId: string, state: AuxVoiceState) {
this.guildId = guildId;
this.state = state;
this.encoder = new Encoder({ channels: 2, sample_rate: 48000, application: 'audio' });
this.encoder.complexity = 10;
this.encoder.signal = 'music';
MusicPlayer.musicPlayers.set(guildId, this);
}
// other methods like play, stop, connect, etc
}
``` and it works perfectly fine if I remove the MusicPlayer.musicPlayers.set(guildId, this); line, but for some reason my code never executes past creating a MusicPlayer object if I have that line in there
oh wait I'm stupid
I didn't initialize the Map
if I do ts class Foo { public static fooList = new Map<string, Foo>(); } will it instantiate a new map every time a Foo is created?
EDIT: seems like it doesn't
You don't literally put ... inside the parentheses it was a placeholder
that just means you fill in the parameters required
yea I fixed it.
and now got this

Can you show me your schema
Whatever one requires a guild id then
all of em
Just show me one of them then
const mongoose = require('mongoose');
const memberSchema = new mongoose.Schema({
GuildID: String,
ChannelID: String,
})
const memberModel = module.exports = mongoose.model('memberupdates', memberSchema);
you prob tried to pass a number when it wants a string
yes.
iirc Discord.js Snowflakes are now of type BigInt
which isn't a string persay
It outputs as a stringified bigint iirc
sooo, how do I fix that 
Might be wrong though I haven't read the docs in a while so they might of changed it again
I get type bigint
what djs version
13.1.0
try msg.guild.id.toString() ig
Might work
But if it is indeed already a string then it shouldn't matter I dont think
in my schema
or the command
Im a bit braindead now
when you are setting the id
the type will still be String in the schema
just whenever setting the id it would be .toString()
so,
new Schema({
GuildID: message.guild.id.toString(),
ChannelID: channell.id,
}).save();
like that?
yeah
wait what

Unless you named your model Schema which is bad idea
When making a new schema the type will still be String
when inserting int othe model you will set the value of GuildID to be that
ok,
well my bot isnt going online rn-
is it some sort of rate limit
or what
it happens to me alot of times
const mongoose = require('mongoose');
const memberSchema = new mongoose.Schema({
GuildID: String,
ChannelID: String,
})
const memberModel = module.exports = mongoose.model('memberupdates', memberSchema);
//later on
memberSchema.create({GuildID: <Message>.guild.id.toString(), /* and so on */})
for the later on part, do I place it in the command where the old code was or in the Schema.
ok bet.
Keep in mind if this works it probably isn't the best method to solving the problem tho :p
I just can't think of anything else
also reading mongoose's docs is a good idea
yea,
Hi guys,
Does any of you know a way to scrape a website that requires authentication in Node.js? I've found solutions for python such as robobrowser, however, I don't mess with that language.
find out how it does authentication. Usually through cookies or authorization header
no need for a browser
It's a <form>
Hard to tell how they're authenticating. I might be too blank to try and bypass this 😄
look at the request and try to replay it in an http client like insomnia or postman. Uncheck different headers/cookies until your request fails
I'll try this out, thanks.
hey guys can someone tell how to send message to all guilds that have a channel named "Iceland" in discord.py
thanks I'll use that on topgg
somebody please help me
🆘
Iterate over each guild, and for each iterated guild, over its text channels. In order to send a message, you'll need to apply logic and use an if statement
how do i show in what folders i can find the pm2 list processes?
basically, how can i identify the folders of these namespaces
@eternal osprey you can look at my setting
maybe it would help you
btw out-source since 2020 :>
and then use this to start pm2 start ecosystem.config.js
how can i check if my bot has application.commands scope for the current guild? is this a thing?
that last index.js is coming from a deleted folder
how the fuck should i retrieve it?
retrieve what? the code gets loaded into memory before execution
i deleted the operating folder after starting it with pm2
so now i can't even close the pm2 process either as i can't locate that folder
so that's why i need the folder back
if you deleted this with rm -rf ... then you're not getting that back if you dont have a copy
Anyone? 
There's no direct way to check the scope your bot has but you can fetch the commands for each guild (try/catch) and notice whiches ones throw an error, meaning you don't have the scope to fetch application commands.
That doesn't matter...
ie, that, only works for the guilds that have specific guild commands defined (my support server)
They work the same.
If you can register a guild command, global commands wont appear, too
then why does every other guild return error? even when they are defined
As the bot does not have the scope to register commands (in the guild)
And the guild can't access global commands
but they can, this is what im saying.
in a guild that has application commands for my bot, that call returns an error
only in the support server, which is the only one that has guild specific commands defined, does the call return any data. the call to discord api for guild commands list
client.application.commands.fetch()
and how does that then help for checking if a guild has commands defined?
but you can fetch the commands for each guild
can you kindly show me how to then?
sure
Make sure to do it kindly, not aggressively 😛
for(const [id, guild] of client.guilds.cache) guild.commands.fetch().catch((error) => console.log(`You can't fetch commands for guild [${id}] (missing scope) - ${error}`));
Oh yeah
Might cause a rate limit if you're in many guilds
Thanks
There you go Sir
ty, im sure i already tried similar code and threw an error, sec
Hold on
Do you may speak about guild commands which aren't registered by your bot? You can't fetch them, never
yea i dont want to
i only want my ones
but there are more than one bot registered commands in that guild, including mine
and no commands are being returned by guild.commands.fetch()
It doesn't throw an error but an empty collection?
correct 😦
Okay I've seen many weird issues in the past... You may try to reinvite your bot making sure the scope is correct
sigh, im trying to detect when the bot has already been reinvited and the commands are registered, so i can display the appropriate support message (between kick and reinvite, or use slash commands)
i cant ask the 750 guilds that just kicked and reinvited him to do so again
lol
Yeah I got that but that's tricky
Discord should automatically add the scope in April (once again)
For existing bots
i have made sure that all channels my bot is in have a bot-logging channel. Am i allowed to notify my servers on the bot updates in that specific channel?
oh, they are going to auto add the scope for existing bots? interesting, i was expecting them to all just break lol
I got told they already did the that once in the past
When they introduced the new feature
What you can do to make a 100% sure you have the right scope, is to actually register a slash command per guild (and delete it after)
~even after kicked/reinvited, still showing an empty collection 😦
If that throws an error you can send the guild owner a message to reinvite the bot to use slash commands
im sure that would only get guild specific commands
yes, it only gets guild specific commands.
Clear the cache and/or remove the local web story of Discord
~ just tested
Some have shown for me, too even after I deleted them
Ok for the server returning an empty collection do the following:
<guild>.commands.set([]);
hey guys can someone tell how to send message to all guilds that have a channel named "Iceland" in discord.py
Which will update the guild commands with an empty array, means it clears them all
i tried it but didn't work
how would that help though? I'd still get an empty collection returned for future calls
Just in that specific case as something seems to be weird...
Like I said, to make a 100% sure per guild do this:
For all guilds with a huge timeout between each action to make sure not running into any rate limits
ok so it seem thats umm
You may wanna share your code then in here.
If somebody here understands "snakish" he can help you.
if a guild doesnt have the applications command scope, the fetch to guild commands will throw an error, but otherwise returns an empty collection
i can use that 🙂
You can't check the scope, so that's your only solution atm
ty for your helpings ❤️
Yeah fetching the guild command will throw an error if the scope is missing
i didnt realise that lol, been stressing out for hours over this 😄
That's what I told you in the beginning 
yea... i realize that now 😐
what is snakish
python
What have you tried?
Guess you can continue driving then
I thought you drive all day long
How did it not?
It may take an hour
nah just always at t he same time, the people asking me
Try clearing your cache etc.
Sometimes it's a client issue
You can fetch the global commands
S-sure 
Shhhhhh, stop blaming me for working all day long to KEEP UP the fucking economy while anybode else sits at home saying they have covid
All I can say is, stay in lane 
Break them
While 1st choice sounds good, too
dude
Look at WHAT I wrote
Compare that to this
And you will see some differences
just a few major differences
Correct
That means they are NOT registered
Pushed to guilds is a different story
ALSO
Your code example will register commands to a guild
Can't repeat that more often...
D O N O T use that guide bullshit code, it's BULLSHIT; SHIT SHIT; WASTE; TRASH; GARBADE ...
Yeah because guildId isn't defined anywhere in your code
You just copied something out of context
If you read the guide until the end, it shows how to register global commands even if the guide is SHIT as I said
Take a look at there, no need to include builder structures etc.
All inbuilt into djs
Load your commands from your files, save them in a map (or array), loop through them and push them
for(const command of yourLoadedCommands) client.application.commands.create({ name: command.name, description: command.description, options: command.options });
(non-aggressive version just for flazepe)
This registration needs to happen ONCE only, never again
Updating commands will then happen using set() instead of create()
Correct
Build a proper command handler, fetching the global commands ONCE on the startup, compare the collection to your (local) loaded files, then update/register/delete them if needed
Just a few lines of code will solve all your slash command issues forever
Registering them over and over again will sometimes overwrite existing commands causing them to show twice or multiple times all using the slash commands, will result in an error "unknown command interaction" in Discord
I share parts of a command handler in here a while ago
But you can't search for images (screenshots) if I'm not wrong
And nope I'm coding offline... there's no platform or service I'm using to upload my code
Just bare npp and copying files as backup sometimes...
I mean I can share the image again but I doubt you really see what's going on
@earnest phoenix
A method I created, part of my utils
just a different editor and theme
One message removed from a suspended account.
Notepad++
Because it's just like writing code like in the default Windows editor
hardcore
That clearCache function exists to reload the commands (on force) while the bot is running
Which would not work since the imported files are cached by default by nodejs
Means you gotta clear them before importing the command files
(again)
huh? No you actually delete the cached file really easy
You just need the full path + file name
thats a long ass if at the bottom lmao
yeah I mean that's less code than checking any property in a single statement
@quartz kindle I think I asked you before but does catch also catches errors appearing in the then clause?
Or do I need to catch them as well?
promise.then(() => inline.promise).catch((error) => log);
If inline.promise fails, does catch throws the error or does my process error handler catch that one?
the catch will work yes
If I add catch to the inline.promise, let's say with a different error message, will that catch the inline.promise then?
I mean regarding the hierarchy it should, shouldn't it?
yes, if you add another catch, that one will have priority
then the outer catch will not work if the inner already did, unless the inner catch throws another error
alright, ty
catch seption

imagine that's a 16x16 icon, please
*96x96
a random question, JDA or Discord4J? wich better for bot creation on Discord?
JDA is more popular, so people tend to pick that.
Discord.js vs detritus moment
I've never used Discord4J, but it does make some bold claims, like being modular and reactive
I'd suggest trying it out to see if you like it.
how to verfy my bot
Head to the developer portal and follow the instructions
Personally I don't like JDA since to do anything on an entity you basically have to fetch it first
https://discord.com/developers/<urbotid>/verification
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
is eris dead? havent seen people talk about it in a while
Not really
It's not updated often, but it does have the features most bots need
including interactions and newer things like autocomplete
Eris always felt like abal's project rather than a "for the community" project, so that's probably why it's rarely active.
it feels like its popularity dropped quite a bit tho
and that's why you should use detritus
That suspiciously sounds like "Tim-discord"
you better be careful with Tim's never released API v1 collecting your personal data
lmao
I can't belive my old commit message are starting with fixed ....
sometime just "fixed"...
"ok time to get serious" would've been the best commit message
nah lets just spam a
... while I'm sitting here to press confirm overwrite when manually backing up my files
well I don't use github at all
ew
I don't like new things, you know
ok fine but categorized stars is killer
Am I supposed to answer yes or no? No clue what you're talking about 
it's supposed to confuse you 🙃
github has stars
you know those things
that people think they can eat for breakfast and live off of
but now we can categorize (aka list) them, so they're more useful
therefore use github :)
be less dizzy
nah
there's actually no reason to, no advantage
also the time to figure out all the shit and how it works, eww
don't even know if that shit is compatibile with notepad++
So a is the alias for "damnit i need a commit msg" 
Or "Update"
let snippetName = interaction.options.getString('name')
let snip = db.get(`snippets.${interaction.guild.id}.${snippetName}`)
if(snip === null) return; interaction.reply({ content: `No Snippet Found Matching That Name!`, ephemeral:true })```
It sends that even tho it did find a snippet.
does topggpy work with disnake?
db.get() may returns undefined then if it wasn't found
you better change the statement to if(!snip)
or literally to if(snip) interaction.reply(...)
means if snip exists and is anything but not undefined, null etc.
Fixed! I was passing it even though it was null.
I was using return; instead of return
yeah didn't read that response message
if(!snip) return interaction.reply(...); then
why...
function isWin(type){
const h={"Common":0.2,"Rare":0.1,"Epic":0.05,"Legendary":0.001,"Champion":0.001}
return (h[type]<=Math.random())?"chr":"nada"
}
``` this worked in replit but now it doesn't
it always returns chr
and people getting all the characters/cards in a few seconds
ok
! [rejected] main -> main (non-fast-forward)
error: failed to push some refs to 'https://github.com/DragonTahmid1/Clash'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help
I've changed git's master branch to main (default one)
and it's returning this
2000 Lines changed "minor refactoring"
coding without a plan
as you change more and more things, more generic messages are needed
fixed
It’s actually not really needed to install that stuff
You just have to adjust the GitHub links a little to download the packages as archives
hes using 32 bit node
there are no prebuilt binaries for that
so he needs visual studio to build them
How can you calculate this:
If something is ran every 100 MS, how many times does it run per minute?
6000 times?
no heck
100ms * 10 = 1000ms (1s)
1000ms * 60 = 60000ms (60s)
Wait what
10 per second if 100 ms?
What is it
Add variables if you can for me to understand
600/min
And what if its every 5 ms?
60000ms / 5ms = 12000 times
google calculator always helps
heroku/replit/glitch issue
How can I check if just a normal message contains any 16 digit number, such as a ID?
arent most ids 18 chars now?
{16,18}
though I think restricting the max length is bad
since they can continuously grow in that direction
astrisk
so setting the minimum based on discord epoch and verifying the format would do better
That forces you to update your shit! 
any solution?
my id is 18 of length
Wait, so how would I tell if its a ID?
someone could just post 0000000000000000
the only way to test if its a valid id is to try and use it
Isn’t there a djs helper function checking for valid IDs?
for example if its a user id, try fetching the user
yeah there should be
bruh then better I re-move to replit and use mongoDB atlas
all the time in work is wasted
get a vps then
well...going free always has 1 or more drawbacks
I got a VPN yesterday but dunno how to use it
