#development

1 messages · Page 1802 of 1

quaint wasp
#

when?

lusty quest
#

with V12

quaint wasp
#

...

lusty quest
#

it still works, but is deprecated

quaint wasp
#

I learned hasPermission from discord.js v12 guid that was out like 2 months ago\

trail finch
#

its permission.has() lol

#

hasPermission works no more

quaint wasp
#

ye i figured.

#

F

trail finch
#

XD

quaint wasp
#

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.

lusty quest
#

weird, docs doesnt say anymore its deprecated

#

so it might still work

quaint wasp
#

it doesnt. 😐

#

Eror pops up

#

in terminal

#

and embed doesnt send

#

which was inside the if that was checking the perms

lusty quest
#

what does the error say?

#

also you might want to return with the message, otherwise the rest of the code will execute

quaint wasp
#

oh... so if i dont have return the rest of the code will run?

quaint wasp
#

I changed how yall told me

quaint wasp
#

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.

lusty quest
#
if(x = true){
console.log("true")
}
console.log("false")
```this will print true and false into the console
quaint wasp
wary flame
#

that means it cannot find a cached channel by the name of logs, try checking if the channel was found first

lusty quest
#
if(x = true){
return console.log("true")
}
console.log("false")
```this should only print true
quaint wasp
#

ye

lusty quest
quaint wasp
#

can you have ifs in the if?

quaint wasp
#

Actiually rn.

lusty quest
quaint wasp
#

thanks

#

is there smth like a max limit?

lusty quest
#
if(x=true){
if(y=true){
console.log("yes")}}
quaint wasp
#

of ifs you can have in an if?

lusty quest
#

depending in how many you need, better look into switch cases

#

would be probably more efficent

quaint wasp
#

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?

lusty quest
#

just use a switch case

quaint wasp
#

no no no, im asking because of chiriosity

#

Ik how to switch case and that its good

lusty quest
#

there is an entire game made with an single if statement containing more if statements, its possible but bad practise

quartz kindle
#

which intents are you using?

#

you said only guild members

earnest phoenix
#

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

quaint wasp
#

oh..

#

Hmm

#

Maby try adding all 3 times?

quartz kindle
#

you want to do that in mongo, or you want to do that in js?

earnest phoenix
#

What? There can be any amount of documents

lusty quest
earnest phoenix
#

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

quaint wasp
#

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)
earnest phoenix
#

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' } }
);
quaint wasp
#

then repeat it few times.... If you know how many fields there will be

earnest phoenix
#

As i said there are 50+ fields and I'm trying to find a way to $sum all of them in the document

quaint wasp
#

o

lusty quest
#

if you dont provide the _id field it should get all documents

quaint wasp
#

true

lusty quest
#

alternative get all documents and do it in js or whatever you use

earnest phoenix
#

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

lusty quest
#

i think you can add mutiple fields if you pass it in as an object

earnest phoenix
#

pass where and what?

lusty quest
#
   {
     $project: {
       quizTotal: { $sum: "$quizzes"},
       labTotal: { $sum: "$labs" },
       examTotal: { $sum: [ "$final", "$midterm" ] }
     }
   }
])```this also works
earnest phoenix
#

I know but its really a pain when there are 100-50 values and new ones may be added any time

lusty quest
#

did you use js?

earnest phoenix
#

Yes js is an option

#

But uh i don't like putting heavy stuff like that on JS

lusty quest
#

then get all documents and loop over it

#

did you use some other lang?

#

rust or go would maybe be more performant

earnest phoenix
quaint wasp
#

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
}


earnest phoenix
#

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.

quaint wasp
#

check their docs

lusty quest
# earnest phoenix
   {
     $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

lusty quest
quaint wasp
#

? What do you mean?

#

Like guild.channels.fetch('logs') ?

lusty quest
#

fetch only works with ids

quaint wasp
#

Then I can't.

lusty quest
#

why?

#

using names is quite unreliable

quaint wasp
#

Ik

#

But Idk how to do that with mongodb

#

Wait no ik but too lazy

lusty quest
#

just store the channelid as string

quaint wasp
#

also idk how to pull data and send in specific guild

lusty quest
#

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

quaint wasp
#

I started but never really learned anything about mongoDB exept on how to create schemas... 😐

lusty quest
#

its not that hard, the docs are just a bit special

quaint wasp
#

they look confusing af

lusty quest
#

if you want confusing docs, look at the twitter api or youtube api

quaint wasp
#

wow ok..

#

or mongoose

lusty quest
#

these

#

mongoose uses the same query stuff

quaint wasp
lusty quest
#

the mongodb docs should work for most stuff, the mongoose docs you probably only need for getting it connected

quaint wasp
#

i am connected.

#

wait do u need to be connected on like each function that uses mongoDB?

earnest phoenix
#

is there a bot to see ark players online#/

#

?

#

@quaint wasp

quaint wasp
#

uhhh

earnest phoenix
#

?

quaint wasp
#
GitHub

ARK Survival Evolved application that monitors and extracts data from local ARK servers and exposes this data through a Web App, Web API and Discord Bot. Provides important functions to players: di...

earnest phoenix
#

thanks

quaint wasp
#

Welcome?

#

Wait I thought you were asking to like teach me smth lol

earnest phoenix
#

well that too i guess

#

if u can

quaint wasp
#

i can learn

#

😄

lusty quest
quaint wasp
#

I dont understand

lusty quest
#

nvm then, you dont need to close the connection on each query

quaint wasp
#

good.

#

Can you be connected to all commands using cmd handler?

lusty quest
#

you connect once, and then just query

#

if you want to make it fancy attach the database connection to the client

quaint wasp
lusty quest
#

this is how calls to the database are called

quaint wasp
#

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
}```
quaint wasp
#

wut

lusty quest
#

then just import this file into your commands

quaint wasp
#

i got like 5

lusty quest
#

you connect once in a file and then just import it into other files

lusty quest
#

i try and give you an example

quaint wasp
#

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..

lusty quest
#

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

quaint wasp
#

o..

#

Thats pretty good ngl

lusty quest
#

now you know the basics, the rest is up to you

quaint wasp
#

alr. thanks

#

wait wiat wait

lusty quest
#

if you want some helpfull stuff, install grapper in your browser

opal plank
quaint wasp
#

Basics..

#

In find one do u put string? like a name of the thing ur trying to find

lusty quest
quaint wasp
#

thanks

opal plank
#

just 2 more

wheat mesa
#

damn

#

impressive

#

bet you can't beat this though

lusty quest
#

my bot started with 1 Guild and 10k users

wheat mesa
#

my bot is only used by my friends in their servers

opal plank
#

dont ask why my beta bot is with that

wheat mesa
#

speaking of which

#

instead of swapping to detritus sleep deprived I decided to sleep!

opal plank
#

given up on it or just went to sleep?

lusty quest
#

sleep is for the weak

wheat mesa
#

just went to sleep

opal plank
#

i c

wheat mesa
#

not gonna give up quite yet

opal plank
#

indeed, you should be fully awake when dealing with typescript

wheat mesa
#

especially considering I've never worked with ts before

opal plank
#

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

wheat mesa
#

I'm currently just trying to get the example bot to start up

opal plank
wheat mesa
#

Yours

lusty quest
#

if he is stuck on loading commands check intents

opal plank
#

which part u stuck at?

lusty quest
#

there is no proper handling for this currently, took a while to get figured it out

wheat mesa
#

I'm assuming you start the bot up from the index.ts file

opal plank
#

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

wheat mesa
#

slight problem with hitting f5

opal plank
#

?

wheat mesa
#

vsc is being dumb and running one of my first c# projects KEKW

opal plank
#

wait what? lmao

wheat mesa
#

I usually run things by just doing node blahblahblah.js or whatever the file name is for that

#

in the integrated terminal

lusty quest
#

yea doesnt work with TS so easy

wheat mesa
#

Nevermind, got it to stop doing that

#

I hate vsc sometimes

lusty quest
#

but use the debugger, it will make stuff easier

opal plank
#

^^^^^^

#

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

lusty quest
#

unless you dont have certain intents enabled/disabled

opal plank
#

yes, that reminds me i need to remove some intents

#

the priviledged ones

wheat mesa
#

Perfect, no more errors after fixing the debugger garbage

opal plank
#

everything working fine?

wheat mesa
#

Seems to be!

opal plank
#

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

wheat mesa
#

Hold on, doesn't log anything, lemme look through to see what's wrong

crimson vapor
#

Someone learning detritus?

opal plank
#

probably same thing as feud

#

yes

#

disable the extra intents

lusty quest
#

ahh yes luckly we found this one right?

opal plank
#

exactly, i really need to remove that from the repo

#

so that this doesnt happen

lusty quest
#

or cake adds handling for it

wheat mesa
#

Perfect!

#

Works now

crimson vapor
#

/* ‘ALL’ */

lusty quest
#

its also valid

regal creek
#

Am I allowed to ask for whats the best windows hosting companies?

sudden geyser
lusty quest
#

is it overwritten?

lusty quest
#

hmm

sudden geyser
#

Though, if I'm allowed to ask, why not a platform like Linux?

lusty quest
#

?

regal creek
lusty quest
#

use wine

regal creek
#

how many vCPU's are roughly in a core? anyone know that?

plain talon
#

a vCPU is a shared core

lusty quest
#

1vCPU is one shared core usually

plain talon
#

so if a box ran an 8 core processor

#

if you had 4vCPU you have access to 4 of those 8 cores

regal creek
lusty quest
#

then compile for a linux target

wheat mesa
#

This is gonna sound stupid... but where are the prefixes stored @opal plank?

regal creek
wheat mesa
#

Oh my god

#

Disregard that

lusty quest
#

then have fun

wheat mesa
#

I'm literally blind

regal creek
#

Thank you SuperBrain

plain talon
#

compiling for linux will save you a lot of time and money

#

windows server is trash

lusty quest
#

windows server got its usecase, but are usually overpriced

cosmic forum
#

Anyone know of a good random meme api?

lusty quest
#

reddit api

sudden geyser
#

Reddit?

regal creek
wheat mesa
#

Haha

opal plank
#

should've put it in the config tbh

wheat mesa
#

Just didn't see it at first

opal plank
#

mine has a great reminder for me not to forget to set it

wheat mesa
#

My brain seeing all the juicy colors from vsc

regal creek
#

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

opal plank
wheat mesa
#

lmao

opal plank
#

if i ever forget my prefix

#

we got a default one

regal creek
plain talon
#

it is needed to run the server tho

#

it is windows remember

wheat mesa
#

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?

opal plank
#

erm

#

hmmm

#

probably delete .git folder

#

its sually hidden

wheat mesa
#

ah, good idea

#

That worked, thanks!

regal creek
opal plank
#

no problomo

plain talon
#

fair enough

modest maple
#

poggers

lament rock
#

Sex 2

sudden geyser
#

what is lust

modest maple
#

my image CDN server

sudden geyser
#

so it lusts for uploads

modest maple
#

Honestly so happy I went with Lust as the name bloblul

lament rock
#

looks cool

sudden geyser
#

Small nitpick, but doesn't clap allow you to restrict the subcommand?

modest maple
#

It does, that error technically should never be reached

#

It's a just in case handle

stable eagle
#

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.

opal plank
#

does it have VIEW_CHANNEL?

wheat mesa
#

I'm already loving detritus, thank you erwin

tribal crow
lusty quest
#

mongoose and mongodb are a bit weird with schemas, the name you set in the schema (line10) should also be used for importing it

tribal crow
#

wSchema?

earnest phoenix
#

how can fix ?

timber fractal
#

`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

wheat mesa
#

Currently loving the format of detritus commands... so structured and beautiful!

sudden geyser
#

What's the format

split hazel
#

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

feral aspen
pale vessel
#

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

woeful pike
#

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

pale vessel
#

Don't you need to have that turned on anyway if you're importing JSON?

split hazel
#

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

lament rock
#

config files or accessing the package.json for versioning. Doesn't make sense to duplicate files

lofty cedar
#

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?

plain talon
#

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

lofty cedar
#

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

noble bough
#

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!

sudden geyser
noble bough
wheat mesa
#

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

plain talon
#

random bots from random people

wheat mesa
#

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

sudden geyser
#

Bots should have the least amount of permissions possible, but my god Discord sets up permissions horribly

limber mica
#

How do i get a role by its name when I only have the guild ID (Discord.js)

sudden geyser
#

Do you know what role you're looking for?

modest gorge
#

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

sudden geyser
#

You can fetch all roles from a server.

modest gorge
#

TDF_SUCO alguém pode me ajudar por favor

sudden geyser
#

e.g. client.guilds.fetch(...).then((guild) => guild.roles.(...))

sudden geyser
sudden geyser
lofty cedar
#

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

modest gorge
sudden geyser
#

I'm not sure.

sudden geyser
#

However, your indentation is confusing.

slender thistle
#

That looks fucked to me

sudden geyser
#

Well you never inherited it.

lofty cedar
#

So what should I do?

modest gorge
#

Is the Custom Bot Card Background required?

modest gorge
coral coral
#

My problem is bot verification

lofty cedar
#

It takes some time for everyone

coral coral
#

When is my bot verify?

sudden geyser
# lofty cedar So what should I do?

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.

lofty cedar
#

Ok, ty

sudden geyser
limber mica
sudden geyser
#

Now that you have guild.roles, you can look through the cache to find the role based on whatever description you're looking matches

limber mica
#

so would i use 'name', "cold"?

sudden geyser
#

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)

modest gorge
#

@sudden geyser thanks

eternal osprey
#

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

lofty cedar
split hazel
lament rock
#

Some expressions might be under the impression that resources have to be there at compile time

limber mica
#

So how do i give a user a role just when I have their ID?

lament rock
#

such as imports

split hazel
#

eh i guess it depends who you ask

#

i've opted into just using ts-node

lofty cedar
#
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?

eternal osprey
#

hey how do i change rows in sheetjs

latent heron
sudden geyser
#

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?

lofty cedar
#

Wdym

sudden geyser
#

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.

earnest phoenix
#

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

earnest phoenix
#

why?

#

because thats how you spell it

earnest phoenix
#

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

earnest phoenix
earnest phoenix
#

cons is a variable

#

bruh

sudden geyser
#

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.

earnest phoenix
#

something to do with this then js client.beys.get(selected);

sudden geyser
#

What is beys in the first place?

earnest phoenix
#
  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

digital ibex
#

hi, can someone send me the link to get a users / members presence. i cant seem to find it in the discord docs

lofty cedar
sudden geyser
#

You already have one (self)

lofty cedar
#

yes but self is another thing

#

i mean

#

self is in select class and is in subclass too

sudden geyser
lofty cedar
# sudden geyser You may want to learn more about inheritance. - <https://www.programiz.com/pytho...

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?
shadow lynx
#

Hello anyone can help me
Why in all embeds log me this
embeds[0].description: This field is required

lyric mountain
#

you probably have an empty embed

#

but showing some code might help

shadow lynx
earnest phoenix
#

does available.length get the number of characters inside available?

wheat mesa
#
  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?
limber mica
#

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

lofty cedar
sudden geyser
#

Which you never did

lofty cedar
# sudden geyser 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'

limber mica
limber mica
#
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 ^'

latent heron
#

It also might be telling you which line(s) in your code trigger the error

lofty cedar
# latent heron can you please give the full traceback error stack instead of one 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
latent heron
#

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

lofty cedar
#

yes

lofty cedar
#

and instead of if self.user there were select.user

#

but it vas sayng that type object select has not attribute user

limber mica
#

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

sudden geyser
#

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.

limber mica
sudden geyser
#

But for some reason it's using the guild name as the guild ID

limber mica
#

So how can i fix it?

sudden geyser
#

So what's guildtarget

limber mica
#

lemme ghet it

#

client.guilds.fetch(args[0])
.then(async guildtarget => {

#

The guild ID

#

args[0]

sudden geyser
#

So you're passing a guild instance then trying to get it again

lofty cedar
limber mica
#

So im inputing the guild ID and it gives the user a role

#

in that guild

latent heron
#

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

lofty cedar
#

but dpy2 it's not the point, i'm having troubles with python

latent heron
#

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

limber mica
#

ive been struggling to fix it

sudden geyser
# limber mica Im passing the guild ID

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

limber mica
#

RIP

#
let member = guildtarget.members.fetch(id)
#

wait

#

nope

#

did not work

sudden geyser
#

That's interesting. guildtarget should be a Guild instance, which has a .members property that shouldn't be undefined.

limber mica
#

its just the number

#

like 12345678912013

limber mica
sudden geyser
#

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.

limber mica
#

so that parts correct

#

So is it an API error or a code error?

limber mica
limber mica
limber mica
sudden geyser
#

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.

limber mica
sudden geyser
#

be more luckier

limber mica
#
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

sudden geyser
#

I don't think your bot is in the server

limber mica
#

Yes it is

sudden geyser
#

You may want to verify that.

limber mica
sudden geyser
#

With the matching ID of 574445866220388352

sudden geyser
#

Hmm

limber mica
#

lemme try smthn real quick

#

nope

limber mica
sudden geyser
#

Can you share more of your code?

limber mica
#
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

sudden geyser
#

So, if I'm getting this right,

  1. You're fetching both the guild provided by the user via args[0] (dynamic) and a guild you've picked out (let id = "...") (fixed).
  2. You're creating a role in the fixed guild.
  3. You're trying to find a role by the name MEE7 in the dynamic guild.
  4. 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).
  5. 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:

  1. client.guilds.fetch(args[0])
  2. client.guilds.fetch(id)
  3. 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.

quartz kindle
#

its either 1 or 2

#

the error is from GET /guilds/:id

limber mica
#

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)

lament rock
#

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;

limber mica
lament rock
#

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

limber mica
lament rock
#

No

#

Just change find to get

limber mica
#

Ok

limber mica
lament rock
limber mica
errant flax
#

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?

bright thorn
#

Noice i did 😘

errant flax
#

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?

earnest phoenix
#

Wouldn’t it just be data.info.list.push(dataToAdd)

errant flax
#

im using findOneAndUpdate method

#

and idk if that actually updates it in the the db noobthonk

earnest phoenix
#

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()

errant flax
#

oh ok lemme try that

#

nope it doesn't save

#

wait nvm i found an alternative hmm

#
const newArr = data.info.list.push(args.join("-"))

why tf does this returns a number instead of the new array?

bright thorn
#

how can follow announcements channel discord.js

#

Like i need to do my bot create a channel and follow has support server announcement channel

earnest phoenix
errant flax
#

how do i get around that then noobthonk

earnest phoenix
errant flax
#

thx hmm

earnest phoenix
errant flax
#

omg it works THX

#

i have been debugging this for a while now lmaoCry

opal plank
#

@clear marlin hows the post?

clear marlin
#

haven't done it yet

#

lol

#

okay, I'll work

latent heron
#

i remember why i hate java

opal plank
#

lmao

latent heron
#

handlers make you jump through 30 different files because they call all one another

#

just to find 3 lines of code

opal plank
#

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

clear marlin
#

lol, alright I'm writing it

earnest phoenix
#

what probleam

lusty quest
#

error is not defined, define error

runic depot
#

resolve an issue process:

requirements:

  1. code
  2. error
  3. description

What u have:
2. error

You can resolve it by just learning basic js.

feral aspen
#

Hey.

#

Are there tuples in javascript?

pale vessel
#

no

runic depot
#

of objects

feral aspen
#

Why did it return in

const oof = ("oof");
console.log(oof[0]); // o
runic depot
#
const oof = ["oof"]
console.log(oof[0])
feral aspen
#

How did it return though?

pale vessel
#

Its interpreted as "string"[0]

feral aspen
#

OH

#

so..

#

const oof = "hi";

#

console.log(oof[0]);

#

?

cinder patio
#

h

runic depot
#

is correct

feral aspen
#

Yes.

#

.. I can also find a letter with regexes, right?

runic depot
#

string[0] returns first letter

runic depot
feral aspen
feral aspen
#

Thanks all.

runic depot
feral aspen
#

Ah.

low river
#

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

errant flax
#

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

slender thistle
#

Does d.js cache users along with the guild members intent

pale vessel
#

No

low river
cinder patio
#

Use Guild#memberCount

#

loop through all guilds and add all of the member counts

runic depot
errant flax
#

or loop through the guilds and add all the member counts

runic depot
cinder patio
#

no it's not...

pale vessel
#

Slay stop

low river
#

😩

errant flax
cinder patio
#

guilds.reduce((acc, g) => g.memberCount + acc, 0)

#

there

slender thistle
#

Discord sends approximate member count along with the guild object

runic depot
#

yes.

slender thistle
#

So, no. It's not a fetch specifically, since all you receive is a number

low river
runic depot
#

loop is the best way tho

slender thistle
#

👍 it's all good

cinder patio
#

Idk how that's stopping you

low river
#
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);
})```
cinder patio
#

client.guilds is your collection

runic depot
#

you can do forEach

cinder patio
opal plank
#

no forEach

errant flax
#

doesnt collection have a for each method?
collection.each

runic depot
#

why

opal plank
#

forEach creates an anon function internally

#

use for...of for..in

#

like everything in js, it has use cases

#

generally speaking, dont

cinder patio
#

or just use reduce cause that's it's exact purpose

runic depot
#

if it's array you can use foreach, if not you can convert it OR just use a normal for.

opal plank
woeful pike
#

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];
low river
low river
#

we do it the long way

#

anyways ty

woeful pike
#

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

low river
cinder patio
pale vessel
#

Nop

#

Accumulated value first

cinder patio
#

ah ok

prime mist
#

Reduce ❤️

earnest phoenix
#

How do I check if the profile picture has been changed?
In the event we have: oldmember and Newmember

pale vessel
#

oldMember.user.avatar !== newMember.user.avatar

#

if the avatar hash is different then it's changed

earnest phoenix
#
        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

earnest phoenix
#

he changed his profile image

pale vessel
#

very weird

dusk narwhal
#

hello

hot schooner
#

I was trying to get raw git url for my bot logo, but idk how... can someone pls help?

scarlet ember
#

pls follow me

tired panther
#

?

errant flax
#

or something that relates to the avatar

#
oldMember.user.displayAvatarURL({dynamic:true})===newMember.user.displayAvatarURL({dynamic:true})
pale vessel
#

That just uses the user avatar hash

#

If that doesn't change so won't that

errant flax
#

oh noobthonk

ember wraith
#

Excuse me, is making a Command logs, is illegal?

pale vessel
#

No, it isn't

green kestrel
#

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!

ember wraith
errant flax
#

idk why u thought its illegal(not being rude)

green kestrel
#

(ofc not lol)

ember wraith
#

Bruhh xD

green kestrel
#

it's fine to log audit logs of commands

ember wraith
#

Cause someone told me it is ilegal (like one month ago)

green kestrel
#

but you should only log what's needed

ember wraith
#

And i just realise, that what he mean is "all" logs

green kestrel
#

and only retain logs for as long as sensible,.like not forever

green kestrel
#

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

errant flax
#

i think its best to log mod commands ig?

#

cuz if u log every command that would be spammy hmm

green kestrel
#

depends on your bot

errant flax
#

depends how many commands u got is the question

green kestrel
#

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

quartz kindle
#

i log all commands and all bot messages, so i can check if there is any invalid/incorrect reply to commands

green kestrel
#

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

quartz kindle
#

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

green kestrel
#

yes

#

derive from a base class and use basic inheritance

#

it is much faster to compile, and generates less crap

quartz kindle
#

how can i do that with types tho

green kestrel
#

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

quartz kindle
#

hmm i can try that

#

my current code looks like this

#

the class has template<container, k, v>

modest maple
#

CPP goes "yano lets just slap another function here, the compiler will handle it"

green kestrel
#

oh Jesus my eyes

quartz kindle
#

yup

#

it was worse before

green kestrel
#

is your < key broken now? after all that?

quartz kindle
#

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?

green kestrel
#

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"

quartz kindle
#

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")

earnest phoenix
#

any react Devs here? My problem is passing props from a child component to another child component

green kestrel
#

I bet PHP would be equally awful to interop with if there isn't a database between them

quartz kindle
#

its not for a personal project

#

its for a library

green kestrel
#

I've done perl interop before and it was horrid, they have two types internally: scalar and not scalar

quartz kindle
#

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

zealous vapor
#

I got banned, but i don't using glitch

vivid fulcrum
#

not our problem

zealous vapor
#

I'm done

opal plank
#

3214 notifications. No wonder u got banned, leaving unchecked messages is a sin

restive furnace
#

but glad it isn't a cos.

autumn rampart
#

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

limber mica
#
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

vivid fulcrum
#

your bot isn't in that guild

limber mica
vivid fulcrum
#

well, it clearly isn't

limber mica
#

umm

#

It is

vivid fulcrum
#

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

limber mica
vivid fulcrum
#

no, it isn't

clear marlin
#

use ruby

vivid fulcrum
#

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

clear marlin
#

kthxbye

limber mica
limber mica
#
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

vivid fulcrum
#

you have the wrong id then

limber mica
vivid fulcrum
#

it's a REST request, cache doesn't matter

limber mica
#

Yes it does, im getting the Guild Data FROM the cache

vivid fulcrum
#

you're making my blood boil

#

it's a REST request

limber mica
#

So if the guild is not cached it cant even make the REST request

vivid fulcrum
#

meaning it goes straight to fucking discord

#

with the id you have it

limber mica
#

IF THE GUILD IS NOT IN THE CACHE IT CANT GET THE DATA AND EVEN MAKE A RIGHT REST REQUEST

vivid fulcrum
clear marlin
#

wait tell me what you're trying to do

limber mica
#

ok

vivid fulcrum
#

you're genuinely an idiot

limber mica
#

Im trying to give a specific user ID a role in a certail server that i specify with its id

vivid fulcrum
#

you're trying to fetch a guild with that id

limber mica
vivid fulcrum
#

your user id

#

switch to the guild id

#

stop trying to act smart

vivid fulcrum
#

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??

limber mica
vivid fulcrum
#

fetch() internally first looks up the cache via get() and if not found, it makes a REST request to discord

limber mica
#

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)
wary flame
#

Read the error

limber mica
#

i think i got it

#

ok so fixed that

#

hm

pale vessel
#

on to the next error

clear marlin
#

did you get the previous

#

error

limber mica
#

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

pale vessel
#

Right

#

how do you fix that

vivid fulcrum
#

get isn't an api call

clear marlin
#

wait

vivid fulcrum
#

it's a cache lookup

limber mica
#

oh god dammit

limber mica
#

fetch()

clear marlin
#

you're literally finding

vivid fulcrum
#

yup

clear marlin
#

a

#

member

limber mica
#

hmmm

#

another one

#

but its a bit better now

clear marlin
#

okay

limber mica
#

im trying to think how to give a user a role...

#

is it addRole

wary flame
#

GuildMember.roles.add iirc

pale vessel
#

Have you tried reading the beautiful docs they made

clear marlin
#

yes^

#

also

#

how about this

clear marlin
#

that's pretty insane woah

limber mica
#

I actually STRUGGLE reading api docs

clear marlin
#

that's why you're struggling with errors

pale vessel
#

Maybe because they asked before reading

limber mica
#

ooh

#

wait

limber mica
wary flame
#

what are you trying to achieve?

limber mica
pale vessel
#

You can't give a user a role

wary flame
#
#

^ You can't give roles the users, you can only give roles to GuildMember's

limber mica
#

unless thats not allowed either>

#

oh

wary flame
#

copy-pastes sample code and complains of undefined variables

pale vessel
#

await mmLol

limber mica
wary flame
#

yeah right

clear marlin
#

coo

#

l

opal plank
limber mica
clear marlin
#

now let me introduce you to our sponsor, Detritus!

opal plank
#

detritus too

clear marlin
#

detritus is a very sexy package

limber mica
#

Yall are insane

limber mica
wary flame
#

I'd use detritus if porting from d.js wouldn't take so long

opal plank
#

it doesnt tho

limber mica
clear marlin
#

detritus is easy, and you can use js too

#

smh

opal plank
#

you know your module.exports?

wary flame
#

Imagine using js

clear marlin
#

but I would allow you to use js, only when you use es6

limber mica
opal plank
#

it should have an execute(0 or run() function right?

clear marlin
wary flame
#

I'm not tho

pale vessel
#

Porting libs shouldn't take long as long as you have a solid framework

wary flame
#

es6 import/exports rock

clear marlin
#

es6 to da horizon

#

I can talk all day 'bout es6

opal plank
earnest phoenix
#
        database: "user-1",
        password: "12345678",
    },```
#

does this work?

#

for mongoose?

clear marlin
#

that's json

#

or wait

#

no

opal plank
#

thats js

clear marlin
#

yeah

earnest phoenix
#

yes

#

js

opal plank
#

json would have "" everywhere

clear marlin
#

ik, my bad

earnest phoenix
#

does it work or no?

opal plank
opal plank
earnest phoenix
#

if not work = help me

clear marlin
wary flame
wary flame
#

Am I overlooking something?

earnest phoenix
#

yes

#

lol

#

wrong msg

opal plank
#

yeah

#

a WHOLE client type

#

theres a slashClient

#

that handles all that for you

clear marlin
#

why not read my article mmLol

opal plank
#

theres commandClient AND slashClient

limber mica
#

yayyy more errors!

wary flame
#

link?

earnest phoenix
clear marlin
# earnest phoenix no

also
mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database.collection][?options]]

wary flame