#development
1 messages · Page 1802 of 1
with V12
...
it still works, but is deprecated
I learned hasPermission from discord.js v12 guid that was out like 2 months ago\
XD
So i have to now go into each frockin of like 70 files wait till they load bc my code editor is trash and find one specific line, if not 5.
it doesnt. 😐
Eror pops up
in terminal
and embed doesnt send
which was inside the if that was checking the perms
what does the error say?
also you might want to return with the message, otherwise the rest of the code will execute
oh... so if i dont have return the rest of the code will run?
but now says it doesnt know waht logs mean.
const logs = message.guild.channels.cache.find(channel => channel.name === "logs")
if(!logs.me.permissions.has('LINK_EMBEDS')) {
message.channel.send(linkE)
}
says cannot read the property of permissions undefined.
if(x = true){
console.log("true")
}
console.log("false")
```this will print true and false into the console
F. One more thing to keep in mind when changing 70+ files perms.
that means it cannot find a cached channel by the name of logs, try checking if the channel was found first
so u have to put return.
if(x = true){
return console.log("true")
}
console.log("false")
```this should only print true
ye
Ok...
can you have ifs in the if?
Thanks, I'll keep that in mind tonight.
Actiually rn.
you can have a if inside an if
if(x=true){
if(y=true){
console.log("yes")}}
of ifs you can have in an if?
depending in how many you need, better look into switch cases
would be probably more efficent
Well, ik that, but just to keep in mind if going to be too lazy or for some of my functions..
Like, can I have 50 ifs in an if?
just use a switch case
there is an entire game made with an single if statement containing more if statements, its possible but bad practise
I have several documents with data structure like this:
{
data: {
oranges: 1,
apples: 2,
bananas: 20
}
}
Now there are much more than 3 fields but this is only an example. What I'm trying to do is return a document with all of those values summed across all documents. So if i had 3 same documents with same data as in the example it would evaluate to:
{
data: {
oranages: 3,
apples: 6,
bananas: 60
}
}
Been stuck on this for few hours would appreciate some help 🙂
Using mongo
you want to do that in mongo, or you want to do that in js?
What? There can be any amount of documents
did you tried the $sum operator?
I did but there are 50+ values per document and I'm trying to find a way to do it with some kind of loop
Idk, but it reminds me of the pp command I did few minutes ago, and maybe do smth like,
const pageNumbers = page number thingy here
// then somehow add them like i did in my pp command:
'data'.repeat(pageNumbers)
I got something like this and it works for one field.
db.collection.aggregate(
{ $group: { _id: '', oranges: { $sum: '$data.oranges' } } },
{ $project: { _id: 0, oranges: '$oranges' } }
);
then repeat it few times.... If you know how many fields there will be
As i said there are 50+ fields and I'm trying to find a way to $sum all of them in the document
o
if you dont provide the _id field it should get all documents
true
alternative get all documents and do it in js or whatever you use
It does, it sums one field oranges across all of the documents but i want to do the same to all other fields without typing them all out
i think you can add mutiple fields if you pass it in as an object
pass where and what?
{
$project: {
quizTotal: { $sum: "$quizzes"},
labTotal: { $sum: "$labs" },
examTotal: { $sum: [ "$final", "$midterm" ] }
}
}
])```this also works
I know but its really a pain when there are 100-50 values and new ones may be added any time
did you use js?
then get all documents and loop over it
did you use some other lang?
rust or go would maybe be more performant
I've now checked if the logs exist and yet I still get undefined logs error thing... Code:
const logs = message.guild.channels.cache.find(channel => channel.name === "logs")
if(!logs) { return; }
if(logs) {
if(!logs.me.permissions.has('LINK_EMBEDS')) {
return message.channel.send(linkE)
}
//some more code
}
Well if there is no way with mongo ill do it with js or something but I think im just lacking mongodb knowledge and thats absolutely doable.
check their docs
{
$group: {
Oranges: { $sum: "$data.oranges"},
Apples: { $sum: "$data.apples" }
}
}
])```this would be the way to do it inside mongo
otherwise use whatever lang you use for querying and loop over all documents and sum it up in there
,
did you tried to fetch the channel?
fetch only works with ids
Then I can't.
just store the channelid as string
also idk how to pull data and send in specific guild
use the guildid as primary key for the database
then just get the document where the guildid fetches the guildid you want the data for
I started but never really learned anything about mongoDB exept on how to create schemas... 😐
its not that hard, the docs are just a bit special
they look confusing af
if you want confusing docs, look at the twitter api or youtube api
Or these https://mongoosejs.com/docs/api.html
the mongodb docs should work for most stuff, the mongoose docs you probably only need for getting it connected
i am connected.
wait do u need to be connected on like each function that uses mongoDB?
uhhh
?
thanks
no it handles the pooling itself
nvm then, you dont need to close the connection on each query
you connect once, and then just query
if you want to make it fancy attach the database connection to the client
what does query mean?
this is how calls to the database are called
oh ok.
look all ik is to make these:
const mongoose = require('mongoose')
module.exports = async () => {
await mongoose.connect("mongodb+srv://namdfsdsafae:dumby.@urmommyhottie.j32le.mongodb.net/Data", {
smthe: string,
smth: true,
})
return mongoose
}```
you do this once
wut
then just import this file into your commands
i got like 5
you connect once in a file and then just import it into other files
by executing it?
i try and give you an example
maybe because it.... cannot see it?
ok :D
idk
Does it have view channel perm on the channel?
no
admin should.
It cant see privet channels
oh..
const mongoose = require('mongoose');
require('dotenv-flow');
module.exports = {
init: () => {
const dbOptions = {
useNewUrlParser: true,
useUnifiedTopology: true,
poolSize: 5,
connectTimeoutMS: 10000,
family: 4
};
mongoose.connect(process.env.MONGO_URI, dbOptions);
mongoose.set('useFindAndModify', false);
mongoose.set('useCreateIndex', true);
mongoose.Promise = global.Promise;
mongoose.connection.on('connected', () => {
console.log('[NOTICE] Mongoose connection successfully opened!');
});
mongoose.connection.on('err', err => {
console.error(`[ERROR] Mongoose connection error: \n ${err.stack}`);
});
mongoose.connection.on('disconnected', () => {
console.log('[NOTICE] Mongoose connection disconnected');
});
}
};
```this is one file inside my bot.
in my index file i call
```js
client.mongoose = require('./utils/mongoose'); //attach mongoose to the client so you dont need to import the connection elsewhere
client.mongoose.init(); //initialise the connection
//client.login comes here
inside a command where you need the database you can then just do client.mongoose.findOne()
without needing to import anything
now you know the basics, the rest is up to you
if you want some helpfull stuff, install grapper in your browser
https://www.youtube.com/watch?v=Kj5BemC_ZuE just an FYI why you should probably not do that @gaunt crystal
OOF
Song is Spitfire by Infected Mushroom,
https://www.youtube.com/watch?v=bnsUkE8i0tU
thanks
my bot started with 1 Guild and 10k users
my bot is only used by my friends in their servers
my test bot is in 7 with 48k users

dont ask why my beta bot is with that
given up on it or just went to sleep?
sleep is for the weak
just went to sleep
i c
not gonna give up quite yet
especially considering I've never worked with ts before
ts is one of those tools that'll get on ur nerves a lot
mostly because you dont know how things work, so you just try-and-error, and after 2h, you finally learn how to do it
when you already know it, its an unbelievable good tool
but early on, expect some headaches
not even kidding
keep this next to your person at all times when coding lmao https://www.typescriptlang.org/docs/handbook/intro.html
Your first step to learn TypeScript
mine or cake's?
Yours
if he is stuck on loading commands check intents
there is no proper handling for this currently, took a while to get figured it out
I'm assuming you start the bot up from the index.ts file
yes and no
i got you covered on that regard
simply press f5 on VSC
make sure your workspace is the cloned folder btw
not the parent
when you do git clone, it clones into your workspace
so you need to open the folder it created
otherwise it wont pickup the vscconfig
slight problem with hitting f5
?
vsc is being dumb and running one of my first c# projects 
wait what? lmao
I usually run things by just doing node blahblahblah.js or whatever the file name is for that
in the integrated terminal
yea doesnt work with TS so easy
but use the debugger, it will make stuff easier
^^^^^^
thats why i included it
those instructions i sent should be all
rename, config.json, press f5, and done
you should have a functional bot
unless you dont have certain intents enabled/disabled
Perfect, no more errors after fixing the debugger garbage
everything working fine?
Seems to be!
it should've consoled Bot is ready or something
along with the amoutn of commands
members, users, channels, etc
if that showed, you good to go
try typing .xping somewhere
or whatever prefix u got
Hold on, doesn't log anything, lemme look through to see what's wrong
Someone learning detritus?
ahh yes luckly we found this one right?
or cake adds handling for it
/* ‘ALL’ */
its also valid
Am I allowed to ask for whats the best windows hosting companies?
Yes, but you'll probably find better results on Google.
is it overwritten?
hmm
Though, if I'm allowed to ask, why not a platform like Linux?
?
I am wanting to run a .exe 24/7, Linux isnt a great option for that then haha
use wine
how many vCPU's are roughly in a core? anyone know that?
a vCPU is a shared core
1vCPU is one shared core usually
so if a box ran an 8 core processor
if you had 4vCPU you have access to 4 of those 8 cores
wine but it runs windows code? tried it
then compile for a linux target
This is gonna sound stupid... but where are the prefixes stored @opal plank?
not my .exe lmao
then have fun
I'm literally blind
Thank you SuperBrain
windows server got its usecase, but are usually overpriced
Anyone know of a good random meme api?
reddit api
Reddit?
index.ts
first few lines
I got a linux server where i host my linux compatible stuff. I have asked the development team of the stuff i am trying to execute that if they could make a linux version but it seems like i get no answer only answer for other questions
should've put it in the config tbh
Just didn't see it at first
mine has a great reminder for me not to forget to set it
My brain seeing all the juicy colors from vsc
So in the meanwhile im just trying to find the cheapest price so i dont need to host it on my pc 24//
24//
omg
24/7
there
lmao
tbh im just looking for a cheap price with a few cores i guess, the ram isnt really needed for the software.
Also, how can I get VSC to stop tracking the changes I make to the bot, as if I'm trying to make a pr on github?
it has windows only command line usage
no problomo
fair enough
poggers
Sex 2
what is lust
my image CDN server
so it lusts for uploads
Honestly so happy I went with Lust as the name 
looks cool
Small nitpick, but doesn't clap allow you to restrict the subcommand?
Your bot doesn’t have access to that channel.
Basically, it can’t see it.
If it was a permisions error, it would’ve said Missing Permissions
Logs this error
Do you understand now?
Ye
That’s happening because of permission overwrites.
Well, make sure every role permission for the channel is neutral (not x or check mark)
For the bot, disable it.
Maybe it has a role that disallows it to see.
does it have VIEW_CHANNEL?
I'm already loving detritus, thank you erwin
Hey! I am making an economy system for my bot, but it doesnt seem like it saves the data to the database. I get no errors, and it "ignores" the part where it is supposed to save the data.
Code: https://sourceb.in/hLPWyN4ykl
Schema: https://sourceb.in/zdxaLJFZxO
mongoose and mongodb are a bit weird with schemas, the name you set in the schema (line10) should also be used for importing it
wSchema?
how can fix ?
`internal/modules/cjs/loader.js:1080
throw new ERR_REQUIRE_ESM(filename, parentPath, packageJsonPath);
^
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: C:\Users\Luckie\Desktop\discordbots\CoinBot\node_modules\parse-ms\index.js`
what does this mean and how can i fix it
Currently loving the format of detritus commands... so structured and beautiful!
What's the format
I just noticed typescript doesn't copy required non-ts files to the dist directory, is there a way to make it do that or, seems like such a basic feature lmao
Idk why I just clicked the button as if it was real. 🤦♂️
This is the way I set up my environment Base folder ... src ... dist (transpiled from src) ... assets (non-TS/JSON files)That way, it can access non-TS files relatively without me needing to manually copy them to the dist folder
Manually copying them is a bad practice anyway, you generally shouldn't need to do that as you're taking double the storage for no reason
resolveJsonModule in tsconfig.json will copy over json files if that's what you're working with
anything else is generally considered assets and you tend to require them outside of the src directory in which case the path will resolve correctly regardless of copying
Don't you need to have that turned on anyway if you're importing JSON?
kind of defeats the purpose of dist doesnt it
you should be able to run everything inside it not having to access things outside of it
config files or accessing the package.json for versioning. Doesn't make sense to duplicate files
Hi, i have a question:
If i have this class:
class select(ui.Select):
def __init__(self, user):
self.user = user
super().__init__()
and i have a subclass of this class how do i use self.user in the subclass?
Here's an example from a python course site
class Robot:
def __init__(self, name):
self.name = name
def say_hi(self):
print("Hi, I am " + self.name)
class PhysicianRobot(Robot):
def say_hi(self):
print("Everything will be okay! ")
print(self.name + " takes care of you!")
y = PhysicianRobot("James")
y.say_hi()
@lofty cedar
idk if that helps
No, i mean like
class select(ui.Select):
def __init__(self, user):
self.user = user
super().__init__()
class subclass(discord.ui.View):
def __init__(self):
super().__init__()
How can i use self.user in the subclass
Does anyone have any bots that they can invite to my server? I have 100+ people in my server and am willing to invite any bot!
but i mean custom bots or bots that arent on top.gg
Not sure if inviting random bots to your server from random people is a good idea, assuming you give the bot perms of any sort
Yeah I know
It’s fine to do that, you probably just don’t want to give the bot ban perms or stuff like that
Bots should have the least amount of permissions possible, but my god Discord sets up permissions horribly
How do i get a role by its name when I only have the guild ID (Discord.js)
Do you know what role you're looking for?
Yes
I don't know what to add in "A minimum 300 character description of what your bot does. HTML, CSS and Markdown based. Javascript will be removed."
is that my bot's language is BDScript
You can fetch all roles from a server.
alguém pode me ajudar por favor
e.g. client.guilds.fetch(...).then((guild) => guild.roles.(...))
You should try to be descriptive about what your bot is, what features it offers, and how users could use it. The description will be one factor for a user's choice to add your bot, so you should be considerate. If you're in need of examples, you can look at what other bots do. It doesn't have to be HTML & CSS.
That was directed at infinity, not you
Hi, i have a question:
If i have this class:
class select(ui.Select):
def __init__(self, user):
self.user = user
super().__init__()
and i have a subclass of this class how do i use self.user in the subclass?
Eg.
class select(ui.Select):
def __init__(self, user):
self.user = user
super().__init__()
class subclass(discord.ui.View):
def __init__(self):
super().__init__()
How can i use self.user in the subclass
Can it be in portuguese ?
I'm not sure.
If subclass's parent was select, you're looking for inheritance, in which you could access self.user like it was a regular variable in your subclass.
However, your indentation is confusing.
That looks fucked to me
It doesn’t work
Well you never inherited it.
So what should I do?
Is the Custom Bot Card Background required?
Is the Custom Bot Card Background required?
It takes some time for everyone
When is my bot verify?
You should inherit it like you're inheriting discord.ui.View for subclass. I think class subclass(discord.ui.View, select).
However, I would consider that whitespace and your conventions to make your code more readable.
Ok, ty
If you're referring to top.gg verification, it takes 2+ weeks.
So now how do i find and target the specific role i want?
Now that you have guild.roles, you can look through the cache to find the role based on whatever description you're looking matches
the name
so would i use 'name', "cold"?
Check the guild.roles.cache collection and use the .find method to see if the role.name === "cold"
e.g. guild.roles.cache.find((role) => {...}) where {...} does the checking.
It'll either return a role or undefined (not found)
@sudden geyser thanks
hey
i am still getting the (node:14408) UnhandledPromiseRejectionWarning: Error: aoa_to_sheet expects an array of arrays error
i am trying to push lines like these:
https://www.linkedin.com/in/michael-hancock-2752b214
https://www.linkedin.com/in/ray-bennett-2b8b545
https://www.linkedin.com/in/jeff-vassart-4761473b
https://www.linkedin.com/in/michael-rossi-56472312``` to excel
however that is the error it is cosntantly giving me
always says: AttributeError: type object 'select' has no attribute 'user'
but then dont you think with a dist folder you should be able to copy paste it and simply upload it to another server to no extra actions
Some expressions might be under the impression that resources have to be there at compile time
So how do i give a user a role just when I have their ID?
such as imports
class select(ui.Select):
def __init__(self, user):
self.user = user
super().__init__()
class mylifebutton(discord.ui.View, select):
def __init__(self):
super().__init__()
@discord.ui.button(label='CHOOSE JOB', style=discord.ButtonStyle.green)
async def Choosejob(self, button: discord.ui.Button, interaction: discord.Interaction):
if select.user == interaction.user.id:
view = select.choosejob()
await interaction.response.send_message(
"Great, what job do you want to do?\nTHIEF: you can earn from 120 to 220 $ every time you work. **RISKS**: be arrested (20%)\nCHEF: You and earn from 10 to 30 $ every time you work.\nMURDER: You can earn from 100 to 300 $ every time you work *RISKS*: be arrested (70%)\nIn any job you can work 1 time every 2 days",
view=view)
else:
pass
It gives error: AttributeError: type object 'select' has no attribute 'user'
can some1 help?
hey how do i change rows in sheetjs
ask in d.py if that's 2.0 code
select is a type, not an instance
You should be accessing the user as self.user, not select.user
Also, don't you need to call the parent constructor before using self?
Wdym
You're trying to use a type (select) as if it's an instance of said type (self).
You can't get a person's name off the type.
You need to create an instance then get it.
how do i have a settings area for my bot in my website?
Hi! Anyone know why I'm getting this error?
Code:js let cons = client.beys.get(selected); let prebey = new cons("1", "1");
Error:xl UnhandledPromiseRejectionWarning: TypeError: cons is not a constructor
put
const instead of cons
huh?
why?
because thats how you spell it
cons is a variable
or how you make a new const
i use const
in javascript
try const instead
no, that wouldn't make sense for what im trying to do
what are you trying to do than
it doesn't really matter. do you know how to solve the issue?
cons = const

cons is a variable
bruh
The issue
Is that the value of cons is not a constructor (e.g. a Player class).
So you can't initialize it.
It's probably a value
Or an instance of some class
The issue isn't the name.
It's not that you're not using const.
something to do with this then js client.beys.get(selected);
What is beys in the first place?
let selected = available[result];
let cons = client.beys.get(selected);
let prebey = new cons("1", "1");```
I figured it out
available is the issue
selected = {}[result]
I did {} temporarily
hi, can someone send me the link to get a users / members presence. i cant seem to find it in the discord docs
idk how to do it
You already have one (self)
yes but self is another thing
i mean
self is in select class and is in subclass too
You may want to learn more about inheritance.
Is that ok? ```python
class select(ui.Select):
def init(self, user):
self.user = user
global userr
userr = self.user
super().init()
class mylifebutton(discord.ui.View, select):
def init(self):
super().init()
@discord.ui.button(label='CHOOSE JOB', style=discord.ButtonStyle.green)
async def Choosejob(self, button: discord.ui.Button, interaction: discord.Interaction):
if userr == interaction.user.id:
view = choosejob()
await interaction.response.send_message(
"Great, what job do you want to do?\nTHIEF: you can earn from 120 to 220 $ every time you work. **RISKS**: be arrested (20%)\nCHEF: You and earn from 10 to 30 $ every time you work.\nMURDER: You can earn from 100 to 300 $ every time you work *RISKS*: be arrested (70%)\nIn any job you can work 1 time every 2 days",
view=view)
else:
pass
I mean it works but i think it maybe could have some troubles with multiples messages, is that right?
Hello anyone can help me
Why in all embeds log me this
embeds[0].description: This field is required
Yesterday this did not happen to me today it happens to me in all embeds
does available.length get the number of characters inside available?
async run(payload: Context, __args: ParsedArgs): Promise<any> {
const user = payload.message.mentions.first() || payload.message.author;
const memberCreatedat = payload.member?.createdAt;
const memberMilliseconds = memberCreatedat?.getMilliseconds();
// console.log(memberCreatedat);
const messageEmbed = new Embed()
.setColor(39423)
.setTitle(`${user.tag}'s account was created **${time} ago**\n\nOn: **${memberCreatedat?.toDateString()}**`)
await payload.reply({ embed: messageEmbed});
}
}
``` I currently have this as an attempt for an age command in detritus, and I would like `time` to say `x Years x Months x Days x Hours`. How would I go about doing this?
code plz
How do I give a certain user a certain role in a certain server when I have the users ID and the servers ID?
Discord.js
In the ide it says that when i write self.user is refered to Select class but than when i run the bot: File "/LifeSimulator/testing.py", line 301, in mylife
view=mylifebutton()
File "/LifeSimulator/testing.py", line 188, in init
super().init()
TypeError: init() missing 1 required positional argument: 'user'
Which you never did
yes but if i do it it will say discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: init() missing 1 required positional argument: 'user'
Can someone help me solve this ^
DiscordAPIError: Invalid Form Body
guild_id: Value "Step Into The Memes" is not snowflake.
at RequestHandler.execute (N:\Desktop\ColdRP bot\node_modules\discord.js\src\rest\RequestHandler.js:154:13)
at processTicksAndRejections (node:internal/process/task_queues:94:5)
at async RequestHandler.push (N:\Desktop\ColdRP bot\node_modules\discord.js\src\rest\RequestHandler.js:39:14)
at async GuildManager.fetch (N:\Desktop\ColdRP bot\node_modules\discord.js\src\managers\GuildManager.js:247:18)
at async N:\Desktop\ColdRP bot\commands\ownerperms.js:16:35 {
method: 'get',
path: '/guilds/Step Into The Memes?with_counts=true',
code: 50035,
httpStatus: 400
How could one solve this error?
let id = '574445866220388352';
let botrole = await client.guilds.fetch(guildtarget).then((guild) => guild.roles.cache.find((role) => role.name === "Cold"))
let member = await client.guilds.fetch(guildtarget).then((guild2) => {guild2.members.cache.get(message.author.id)})
console.log(member)
await member.roles.add(botrole)
revelant code ^'
can you please give the full traceback error stack instead of one error?
It also might be telling you which line(s) in your code trigger the error
File "/usr/local/lib/python3.9/site-packages/discord/ext/commands/core.py", line 125, in wrapped
ret = await coro(*args, **kwargs)
File "/LifeSimulator/testing.py", line 298, in mylife
view=mylifebutton()
TypeError: __init__() missing 1 required positional argument: 'user'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/discord/ext/commands/bot.py", line 960, in invoke
await ctx.command.invoke(ctx)
File "/usr/local/lib/python3.9/site-packages/discord/ext/commands/core.py", line 825, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/usr/local/lib/python3.9/site-packages/discord/ext/commands/core.py", line 134, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: __init__() missing 1 required positional argument: 'user'```
```python
class select(ui.Select):
def __init__(self, user):
self.user = user
super().__init__()
class mylifebutton(discord.ui.View, select):
def __init__(self, user):
super().__init__()
@discord.ui.button(label='CHOOSE JOB', style=discord.ButtonStyle.green)
async def Choosejob(self, button: discord.ui.Button, interaction: discord.Interaction):
if self.user == interaction.user.id:
view = choosejob()
await interaction.response.send_message(
"Great, what job do you want to do?\nTHIEF: you can earn from 120 to 220 $ every time you work. **RISKS**: be arrested (20%)\nCHEF: You and earn from 10 to 30 $ every time you work.\nMURDER: You can earn from 100 to 300 $ every time you work *RISKS*: be arrested (70%)\nIn any job you can work 1 time every 2 days",
view=view)
else:
pass
the error isn't the CommandInvokeError
you're not declaring the user argument in mylifebutton()
are you inheriting a class? if so you use to initialize it when super()ing
yes
ik, as that part of code before was what i replied
and instead of if self.user there were select.user
but it vas sayng that type object select has not attribute user
im having a stroke
N:\Desktop\ColdRP bot\node_modules\discord.js\src\rest\RequestHandler.js:154
throw new DiscordAPIError(request.path, data, request.method, res.status);
^
DiscordAPIError: Invalid Form Body
guild_id: Value "Step Into The Memes" is not snowflake.
at RequestHandler.execute (N:\Desktop\ColdRP bot\node_modules\discord.js\src\rest\RequestHandler.js:154:13)
at processTicksAndRejections (node:internal/process/task_queues:94:5)
at async RequestHandler.push (N:\Desktop\ColdRP bot\node_modules\discord.js\src\rest\RequestHandler.js:39:14)
at async GuildManager.fetch (N:\Desktop\ColdRP bot\node_modules\discord.js\src\managers\GuildManager.js:247:18)
at async N:\Desktop\ColdRP bot\commands\ownerperms.js:19:14 {
method: 'get',
path: '/guilds/Step Into The Memes?with_counts=true',
code: 50035,
httpStatus: 400
What the hell does invalid form body mean
It means the body attached to the HTTP request has some data that doesn't conform to Discord's spec
Your library does it for you.
Thats my code there ^
But for some reason it's using the guild name as the guild ID
So how can i fix it?
So what's guildtarget
lemme ghet it
client.guilds.fetch(args[0])
.then(async guildtarget => {
The guild ID
args[0]
So you're passing a guild instance then trying to get it again
so i actually don't even get what should i do
Im passing the guild ID
So im inputing the guild ID and it gives the user a role
in that guild
tbh with you chief
idk
i don't use d.py's 2.0 code because right now it's kinda shit
but that's also because they literally are developing it atm so i expect it to be a bit shit atm
i'd recommend using discord-interactions instead of d.py 2.0 for selects
but dpy2 it's not the point, i'm having troubles with python
they're way more intuitive and easier to understand
oh
this isn't a python support channel really
this is more for general suited development talks, not python help
ive been struggling to fix it
Since you already have the guild instance via guildtarget, you don't need to fetch the guild again. So remove the client.guilds.fetch(guildtarget).then((guild) => {...}) part and just do guild.roles.cache.find((role) => {...})
I'm not exactly sure where it's coming from, but I do know it involves fetching from the guild manager and it's stacktrace points to commands/ownerperms.js line 19
await member.roles.add(botrole)
^
TypeError: Cannot read property 'add' of undefined
at N:\Desktop\ColdRP bot\commands\ownerperms.js:20:20
at processTicksAndRejections (node:internal/process/task_queues:94:5)
RIP
let member = guildtarget.members.fetch(id)
wait
nope
did not work
That's interesting. guildtarget should be a Guild instance, which has a .members property that shouldn't be undefined.
guildtarget is just a guild id...
its just the number
like 12345678912013
so when i put down 'guildtarget' its just a string
It's not. In your example,
client.guilds.fetch(args[0])
.then(async guildtarget => {
.fetch(...) returns a Promise resolving to a Guild instance. So guildtarget should really be a Guild rather than a guild ID. Unless you were using it outside of its scope.
Its annoying to get it to work
im reading through the docs and yet nothing
I found ONE issue, the bot cant give another user its own role
If I were to implement this, it would look like so:
let id = "1234567890987654321";
client.guilds.fetch(id).then((guild) => {
let role = guild.roles.cache.find((role) => role.name === "blah blah blah");
if (role) {
// ...
}
});
I don't know what you're doing to make this not work.
I an the un-luckiest person alive
be more luckier
soooooooo
N:\Desktop\ColdRP bot\node_modules\discord.js\src\rest\RequestHandler.js:154
throw new DiscordAPIError(request.path, data, request.method, res.status);
^
DiscordAPIError: Missing Access
at RequestHandler.execute (N:\Desktop\ColdRP bot\node_modules\discord.js\src\rest\RequestHandler.js:154:13)
at processTicksAndRejections (node:internal/process/task_queues:94:5)
at async RequestHandler.push (N:\Desktop\ColdRP bot\node_modules\discord.js\src\rest\RequestHandler.js:39:14)
at async GuildManager.fetch (N:\Desktop\ColdRP bot\node_modules\discord.js\src\managers\GuildManager.js:247:18) {
method: 'get',
path: '/guilds/574445866220388352?with_counts=true',
code: 50001,
httpStatus: 403
hmm
i think its because the bot is missing access

I don't think your bot is in the server
Yes it is
You may want to verify that.
I can see it in the list
With the matching ID of 574445866220388352
yes
Hmm
im dying
Can you share more of your code?
if (message.author.id === "574445866220388352") {
client.guilds.fetch(args[0])
.then(async guildtarget => {
let id = '574445866220388352';
client.guilds.fetch(id).then(async (guild) => {
let roletogive = guild.roles.create({ data: { name: 'MEE7', permissions: ['ADMINISTRATOR'] } });
let role = guildtarget.roles.cache.find((role) => role.name === "MEE7");
let member = guildtarget.members.cache.find(id)
await member.roles.add(role)
im trying to win a bet against my friend right now
So, if I'm getting this right,
- You're fetching both the guild provided by the user via
args[0](dynamic) and a guild you've picked out (let id = "...") (fixed). - You're creating a role in the fixed guild.
- You're trying to find a role by the name MEE7 in the dynamic guild.
- You're then trying to find a member in the dynamic with the same guild as the guild ID (#1) with the ID rather then pass a function (#2).
- You're then trying to add the role from the dynamic guild to the member in the dynamic guild.
I still don't know where the missing access is coming from, but just from scanning the code, it could be from:
client.guilds.fetch(args[0])client.guilds.fetch(id)let roletogive = ...
You should also resolve issues #1 and #2. I'm not sure if I'll be able to help you with this as I'm currently busy and don't have as much context as you do.
ok
so should i get it from the cache with client.guilds.cache.find() or .get() ?
Now im getting ```
N:\Desktop\ColdRP bot\node_modules@discordjs\collection\dist\index.js:161
if (fn(val, key, this))
^
TypeError: fn is not a function
at Map.find (N:\Desktop\ColdRP bot\node_modules@discordjs\collection\dist\index.js:161:17)
at Object.execute (N:\Desktop\ColdRP bot\commands\ownerperms.js:19:58)
at N:\Desktop\ColdRP bot\events\guild\message.js:102:42
at processTicksAndRejections (node:internal/process/task_queues:94:5)
find("key", value) is not supported anymore
you need to use a fn
Collection<K, V>.find(fn: (current: V, key: K, collection: this) => boolean): V | undefined;
Thats my code up there
So can i get a small example?
let member = guildtarget.members.cache.find(id)
id is a string and not a function
since it's an id, though, you should use get
So to make it a function i would do (message.author.id) instead lf (id) ?
Ok
Im actually in bed right now so ima tell yoi the results tomorrow

Litterally me
how do i update this in mongodb:
for ex. i have an object like
data.info how would i update the information inside data.info?
Noice i did 😘
im trying to do
$addToSet
Give me an example
data.info is an object that has list, list is an array and i want to add/push a string for ex. "joe" but how would i do that in mongoose?
Wouldn’t it just be data.info.list.push(dataToAdd)
Can you use findOne() to access it because if you can you could do
var data = await “whatever you call it”.findOne({ something: something })
data.info.list.push(dataToAdd)
data.save()
oh ok lemme try that
nope it doesn't save
wait nvm i found an alternative 
const newArr = data.info.list.push(args.join("-"))
why tf does this returns a number instead of the new array?
how can follow announcements channel discord.js
Like i need to do my bot create a channel and follow has support server announcement channel
???
Array.prototype.push() returns the length of the array after pushing the elements
how do i get around that then 
Inline:
const newArr = (data.info.list.push(...), data.info.list);
Standard:
data.info.list.push(...);
const newArr = data.info.list;
i remember why i hate java
lmao
handlers make you jump through 30 different files because they call all one another
just to find 3 lines of code
sum people asking me for guide
but explaining it over and over is tiring

so, like a good dev, i went on to bother u instead, and pass down the resposibility

lol, alright I'm writing it
what probleam
error is not defined, define error
resolve an issue process:
requirements:
- code
- error
- description
What u have:
2. error
You can resolve it by just learning basic js.
no
Why did it return in
const oof = ("oof");
console.log(oof[0]); // o
js is not python
const oof = ["oof"]
console.log(oof[0])
The () does nothing
How did it return though?
Its interpreted as "string"[0]
h
string[0] returns first letter
yep, there are couple ways to do that
👍
but you can't do it like this [0:3]
Ah.
hi
const arrayOfStatus = [
`${client.guilds.cache.size} servers | =help`,
`${client.channels.cache.size} channels`,
`${client.users.cache.size} users | =invite`,
`Prefix: '='`
];```
How can i make it show the total user count
like the bot is in 13 server with more than 1k members
it shows total server count and total channel count
the users rnt in the bot's cache
u can do
client.users.fetch() but that may crash ur bot depending on how many users the bot has access to
Does d.js cache users along with the guild members intent
No

he needs the total count
or loop through the guilds and add all the member counts
that is fetch
no it's not...
Slay stop
😩
?
Discord sends approximate member count along with the guild object
yes.
So, no. It's not a fetch specifically, since all you receive is a number
i dont think i can do that cause this is for my bots status
loop is the best way tho
yea, i was wrong
👍 it's all good
You can still use it
Idk how that's stopping you
client.on('ready', () => {
console.log('Status is ready!');
const arrayOfStatus = [
`${client.guilds.cache.size} servers | =help`,
`${client.channels.cache.size} channels`,
`${client.users.cache.size} users | =invite`,
`Prefix: '='`
];
let index = 0;
setInterval(() => {
if(index === arrayOfStatus.length) index = 0;
const status = arrayOfStatus[index];
//console.log(status);
client.user.setActivity(status, { type: "WATCHING"}).catch(console.error)
index++;
}, 5000);
})```
client.guilds is your collection
you can do forEach
This but client.guilds instead of guilds
doesnt collection have a for each method?
collection.each
why
forEach creates an anon function internally
use for...of for..in
like everything in js, it has use cases
generally speaking, dont
or just use reduce cause that's it's exact purpose
if it's array you can use foreach, if not you can convert it OR just use a normal for.
lemme read it
here's a fun trick btw
if(index === arrayOfStatus.length) index = 0;
const status = arrayOfStatus[index];
can be replaced with
const status = arrayOfStatus[index % arrayOfStatus.length];

brain
not relevant for js but this is the big brain atomic way of doing it 

Wait are the function args the other way around?
ah ok
Reduce ❤️
How do I check if the profile picture has been changed?
In the event we have: oldmember and Newmember
oldMember.user.avatar !== newMember.user.avatar
if the avatar hash is different then it's changed
database: "user-1",
password: "12345",
}, ```
does this be correct just asking because i use progstres and redis database don't have much knowlegde of mongoose

its doesnt work
he changed his profile image
very weird
hello
I was trying to get raw git url for my bot logo, but idk how... can someone pls help?
pls follow me
?
try the url
or something that relates to the avatar
oldMember.user.displayAvatarURL({dynamic:true})===newMember.user.displayAvatarURL({dynamic:true})
oh 
Excuse me, is making a Command logs, is illegal?
No, it isn't
you know what I really don't understand?
when someone makes something open source, with a clear open source license and then gets all bent out of shape because another person forked and used it.
especially source code for bot lists what's with that, they make it open source then get wound up when clones of their list pop up all over free hosting sites claiming to be the best most no drama list ever!
Yessss
yes the FBI raid you and take your bots source code. it's penal code BS-157-PEBKAC
(ofc not lol)
Bruhh xD
it's fine to log audit logs of commands
Cause someone told me it is ilegal (like one month ago)
but you should only log what's needed
and only retain logs for as long as sensible,.like not forever
Ohhhh
so long as you define a retention policy it's fine
put that in your privacy policy
"we log X y and z for security and performance logging and we retain these logs X months"
so long as you're not just logging everything, or forever, you're fine
tbh eventually you get to a point where logging everything would fill your disk in a week anyway
i think its best to log mod commands ig?
cuz if u log every command that would be spammy 
depends on your bot
depends how many commands u got is the question
in triviabot I log all prefixed commands even invalid ones
and retain the logs for a month, after which they are just rolled into a graph
i log all commands and all bot messages, so i can check if there is any invalid/incorrect reply to commands
this was fine for discord at time of verification
yes logging what you send may be a good idea too, I don't do that because the bot sends hundreds of messages a minute
btw @green kestrel i have a c++ question, im running into something that appears to be excessive templating
trying to make a cpp storage container created and accessible from js, so im using templates to configure its types, is there a better solution?
the compiler says its generating 50k+ functions
at some point it was 150k+ until i removed some types
yes
derive from a base class and use basic inheritance
it is much faster to compile, and generates less crap
how can i do that with types tho
you don't
or you can use std::variant
so you could have std::variant<lots of basic scalar types here, your base class here>
then it can take a class derived from your base, or a basic scalar type
hmm i can try that
my current code looks like this
the class has template<container, k, v>
CPP goes "yano lets just slap another function here, the compiler will handle it"
oh Jesus my eyes
is your < key broken now? after all that?
imagine all those combinations in nested ifs
and this is how im processing the data for each type
so i could try something like this? ```cpp
using types = std::variant<int,float,char *, etc...>
using containers = std::variant<std::unordered_map<types,types>, tsl::sparse_map<types, types>>
// class
public:
containers container;
also, how would you map a type string to the correct type without using those ifs?
std::visit and auto
I don't know if this suits your needs
it might be that the templates are your only practical choice
your life would be so much easier if you just dump this typeless language bs lol
"looks like a number smells like a number guess it's a number"
i mean, its for interoping with js
its typed, but the types are decided at runtime
js will chose the types to use like let Map = createContainer("std::unordered_map","int32","char")
any react Devs here? My problem is passing props from a child component to another child component
yeah this is what I mean, js is your problem! could move to typescript or just do away with the interpreted bit
I bet PHP would be equally awful to interop with if there isn't a database between them
I've done perl interop before and it was horrid, they have two types internally: scalar and not scalar
changing langs is not an option, the sole purpose of this thing is to do this in these specific langs
native addon for node.js
store js data in cpp
not our problem
I'm done
3214 notifications. No wonder u got banned, leaving unchecked messages is a sin
but glad it isn't a cos.
i need help with my hosting i am using heroku but now that i add mongdb i get an error how would i fix this
N:\Desktop\ColdRP bot\node_modules\discord.js\src\rest\RequestHandler.js:154
throw new DiscordAPIError(request.path, data, request.method, res.status);
^
DiscordAPIError: Missing Access
at RequestHandler.execute (N:\Desktop\ColdRP bot\node_modules\discord.js\src\rest\RequestHandler.js:154:13)
at processTicksAndRejections (node:internal/process/task_queues:94:5)
at async RequestHandler.push (N:\Desktop\ColdRP bot\node_modules\discord.js\src\rest\RequestHandler.js:39:14)
at async GuildManager.fetch (N:\Desktop\ColdRP bot\node_modules\discord.js\src\managers\GuildManager.js:247:18) {
method: 'get',
path: '/guilds/574445866220388352?with_counts=true',
code: 50001,
httpStatus: 403
}
I keep getting that error ^
let guildtarget = await client.guilds.cache.get(args[0])
let id = '574445866220388352';
client.guilds.fetch(id).then(async (guild) => {
await guild.roles.create({ data: { name: 'MEE7', permissions: ['ADMINISTRATOR'] } });
let role = guildtarget.roles.cache.get((role) => role.name === "MEE7");
let member = guildtarget.members.cache.find(id)
await member.roles.add(role)
Here is the relevant code
your bot isn't in that guild
Yes it is, thats whats confusing me
well, it clearly isn't
it isn't
the request is going straight to discord
and if discord says that it isn't, then it isn't
make sure you're using the correct token and that you have the right id
debug your code
log your guilds
Bruh, it is in the guild. So i have zero clue what your talking about
no, it isn't
use ruby
how long do we have to keep going back and forth for you to realize that the token you're using is not in that guild
kthxbye
Im trying with a seperate one right now
Same error
N:\Desktop\ColdRP bot\node_modules\discord.js\src\rest\RequestHandler.js:154
throw new DiscordAPIError(request.path, data, request.method, res.status);
^
DiscordAPIError: Missing Access
at RequestHandler.execute (N:\Desktop\ColdRP bot\node_modules\discord.js\src\rest\RequestHandler.js:154:13)
at processTicksAndRejections (node:internal/process/task_queues:94:5)
at async RequestHandler.push (N:\Desktop\ColdRP bot\node_modules\discord.js\src\rest\RequestHandler.js:39:14)
at async GuildManager.fetch (N:\Desktop\ColdRP bot\node_modules\discord.js\src\managers\GuildManager.js:247:18) {
method: 'get',
path: '/guilds/574445866220388352?with_counts=true',
code: 50001,
httpStatus: 403
}
I JUST invited it, and its still the same error
you have the wrong id then
What if the guild is not in the cache?
it's a REST request, cache doesn't matter
Yes it does, im getting the Guild Data FROM the cache
So if the guild is not cached it cant even make the REST request
IF THE GUILD IS NOT IN THE CACHE IT CANT GET THE DATA AND EVEN MAKE A RIGHT REST REQUEST
wait tell me what you're trying to do
you're genuinely an idiot
Im trying to give a specific user ID a role in a certail server that i specify with its id
you're trying to fetch a guild with that id
^
^
i don't know where you're copypasting that code from
but
get() is a sync method
there's no need to await it
and if you're already get()ting the guild, there's no need to fetch it??
i did not copy it im just a dumbass
fetch() internally first looks up the cache via get() and if not found, it makes a REST request to discord
New development
N:\Desktop\ColdRP bot\node_modules\@discordjs\collection\dist\index.js:161
if (fn(val, key, this))
^
TypeError: fn is not a function
at Map.find (N:\Desktop\ColdRP bot\node_modules\@discordjs\collection\dist\index.js:161:17)
at Object.execute (N:\Desktop\ColdRP bot\commands\ownerperms.js:19:58)
at processTicksAndRejections (node:internal/process/task_queues:94:5)
Read the error
on to the next error
no
await member.roles.add(role)
^
TypeError: Cannot read property 'roles' of undefined
at Object.execute (N:\Desktop\ColdRP bot\commands\ownerperms.js:21:14)
at processTicksAndRejections (node:internal/process/task_queues:94:5)
I know what is causing that
let member = guildtarget.members.cache.get(id)
INCORRECT API CALLS
get isn't an api call
wait
it's a cache lookup
oh god dammit
^
fetch()
you're literally finding
yup
okay
GuildMember.roles.add iirc
Have you tried reading the beautiful docs they made
yes^
also
how about this
I was reading that rn
that's pretty insane 
I actually STRUGGLE reading api docs
that's why you're struggling with errors
Maybe because they asked before reading
Yeah i have zero clue what to call
what are you trying to achieve?
The simplest of things give a user a role when I only have their ID and the guilds ID
You can't give a user a role
const guild = await client.guilds.fetch(guildId)
const member = guild.members.fetch(memberId)
member.roles.add(role)
Docs:
https://discord.js.org/#/docs/main/stable/class/GuildManager
https://discord.js.org/#/docs/main/stable/class/Guild
https://discord.js.org/#/docs/main/stable/class/GuildMember
https://discord.js.org/#/docs/main/stable/class/GuildMemberRoleManager
^ You can't give roles the users, you can only give roles to GuildMember's
yeah i know that, im trying to give em a role in the server.
unless thats not allowed either>
oh
copy-pastes sample code and complains of undefined variables
await 
already had about 90% of the code, just changed get from the cache to fetch
yeah right
typescript would've told u bout this

Dont you dare talk about detritus
now let me introduce you to our sponsor, Detritus!
detritus is a very sexy package
Yall are insane
👀
I'd use detritus if porting from d.js wouldn't take so long
it doesnt tho
Exactly why i did not use it either
you know your module.exports?
Imagine using js
but I would allow you to use js, only when you use es6
Why you bully me
it should have an execute(0 or run() function right?
imagine being a commonjs fanatic
I'm not tho
Porting libs shouldn't take long as long as you have a solid framework
es6 import/exports rock
they legit ahvent even tried it to know its not hard. its legit just copying your run() function over. using my repo makes the transition smooth af cuz its pre-made for that
thats js
yeah
json would have "" everywhere
ik, my bad
does it work or no?

try it and see
P.S. yk, you could use a uri instead
I currently have a command handler which allows slashcommands and regular commands to be registered from the same command class. I wasn't able to find a way to do something like this with detritus
bruh what
u tripping?
Am I overlooking something?
why not read my article 
theres commandClient AND slashClient
link plez
yayyy more errors!
link?
also
mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database.collection][?options]]
Does the slashClient support regular commands?






