#development

1 messages ยท Page 1145 of 1

cinder patio
#

If you are storing a session ID

pure lion
#

okay cool easy good

#

cant be too hard right? mmLol

cinder patio
#

Just generate a uuid and set it as the cookie's value and as the document's sessionId key

pure lion
#

the document's sessionId key
the what

#
        res.cookie('sessionID', ses, {secure: true, httpOnly: true})

cooki

#

(ses is uuid)

#
        let ses = session()
        console.log(user.id)
        console.log(ses)
        let thisSession = await UserSession.findOne({ userID: user.id })
        if (!thisSession) {
            let sessionDoc = new UserSession({ userID: user.id, sessionID: ses })
            console.log(sessionDoc)
        } else {
            thisSession.updateOne({ sessionID: ses })
        }
```update i assume this is good (after i set cookei)
cinder patio
#

looks good

pure lion
#

and then on my /home i can get the userID by a UserSession query and then findOne of my User schema and display necessary info when needed

opal plank
#

@quartz kindle are you busy by any chance?

cinder patio
#

exactly!

pure lion
#

:D

#

its almost as if im becoming a better full stack developer uwu

misty sigil
#

owo

pure lion
#
        res.cookie('sessionID', ses, { secure: true, httpOnly: true })
        res.status(301).redirect('/home')

i assume this is good

fallow zephyr
#

Hello Iโ€™m looking for someone who knows how to make a RCON like discord webhook bot so I can control my mcpe server from discord

pure lion
#

this channel is not for that kind of stuff

#

much sorry very sad

fallow zephyr
#

Yes it is

#

The mod told me to ask here

sinful belfry
#

its fine, it is still development related

#

you're just less likely to find help here, since this is a bot list

opal plank
#

ugh fml

#

i'll ask just in case

#

its crashing when PRIVMSG is being emitted
index referencing the same chat instance

#

anyone got any idea why 2 listeners is causing the emitter to error?

pure lion
#

when i do console.log(req.cookies) it logs as undefined

sinful belfry
#

@pure lion are you using express?

pure lion
#

yup

#

is there a cookie parser boi i dont know about

sinful belfry
#

try using the cookie-parser middleware

pure lion
#

knew it

#

app.set('cookie-parser' /*what goes here lmao*/)

sinful belfry
#

i think you can just do app.use(require('cookie-parser')());

pure lion
#

bruh omg i think that im going to scream

#

this works

#

and its so cool

sinful belfry
#

lmao awesome

reef crescent
#

hi

#

can i get some help

pure lion
#

dont ask to ask

#

also i need help too, can i use the client to fetch users that it doesnt share any guilds with?

reef crescent
sinful belfry
#

yep

reef crescent
#

Im new to coding and shit

#

But how to get the Verifiedbot badge

solemn latch
#

If your making a bot just to get the badge, probably won't ever get the badge

reef crescent
#

not for that only

sinful belfry
#

you'll need to worry about discord's developer privacy stuff tho

solemn latch
#

^^^

#

Was about to say that

sinful belfry
#

lol

reef crescent
#

a guy dont have a phone number and wants to talk here

#

he dmed me

#

@west shard

#

him

solemn latch
#

Probably should buy nitro then.

sonic lodge
#

for your bot to get a verified bot badge, you must make a bot, have it in 75 or more guilds, and then get discord to verify it

reef crescent
#

what if you make fake servers?*

solemn latch
#

You get rejected

reef crescent
#

aight

#

ty btw

#

im gonna sleep

#

cya

pure lion
#
res.render('home.ejs', { user: client.users.fetch(findUser.userID).username || 'User not found' });
```it always renders as undefined
sinful belfry
#

you need to await the user fetch

#

since you're making a request to discord's api

pure lion
#

oh got it

#

thanks

quartz kindle
#

@opal plank that happens if you have 2 listeners to PRIVMSG?

pure lion
#

whats the url for getting discord avatars?

solemn latch
#

Discord developer docs covers all that

sinful belfry
#

you're using discord.js, right?

opal plank
#

@quartz kindle indeed, as soon as theres a new message it crashes

#

i spent the past 2h trying to figure out whats happening

quartz kindle
#

have you tried not adding something to the message object you get from it?

opal plank
#

ngl, i gave up

#

i have not

#

lemme give that a try rq

#

it might break a ton of stuff though

sleek gull
#

              <span class="bot-name">

                Discord Bot List

              </span>

            </p>

            <p class="bot-description">```
opal plank
#

@quartz kindle yeah that was error'ing, though its still not getting it though

#

yep, still crashes

quartz kindle
#

even with nothing attached to message?

opal plank
#

indeed

quartz kindle
#

shitty lib then

#

make your own event

opal plank
#

im gonna log message rq just to triple check

#

definetly nothing attached

#

full error if it helps

#

i see command: in the bottom though im unsure if its related

amber fractal
#

what are you doing?

opal plank
#

me? trying to listen to an event outside of the index

#

though it crashes once its emitted

#

its not even that small of a lib to be doing this shitty thing

pure lion
#

Bot list ever nearing completion uwu

quartz kindle
#

and literally the only difference is an extra .on("PRIVMSG")?

opal plank
#

that is suppose to be the event name

quartz kindle
#

i mean

#

you could always

midnight blaze
#

I tried to include kick in my anti spam detection

    if(message.member.kickable) {
            message.member.kick({reason:"spamer"})
            return

It doesnt work. It doesnt react and there is no error with try and catch

#

๐Ÿค”

quartz kindle
#
...on("PRIVMSG", message => {
  client.emit("MYMESSAGEHA",JSON.parse(JSON.stringify(message)))
})
#

lmao

opal plank
#

can i do that? 002_think

#

i was thinking of re-emitting

#

but that looks like one hell of a bad idea

quartz kindle
#

re-emitting under the same event is probably a bad idea

#

but making a new event should be less bad

faint zenith
amber fractal
#

yeah, if you use a new event it's different so it doesnt loop

opal plank
#

then listen of that new event under collector?

earnest phoenix
#

@faint zenith that's just markdown

faint zenith
#

like the black background and the number color

earnest phoenix
#

i cba

drifting wedge
#
async def on_member_join(ctx, wgrole, member):
    with open('wrole.json', 'r') as f:
        wrole = json.load(f)
    role = discord.utils.get(member.server.roles, id=f"{wgrole}")
    await client.add_roles(member, role)```
#

its giving me errors

#

missing 2 required positional arguments: 'wgrole' and 'member'

opal plank
#

@quartz kindle i'll give it a try, ty tim

slender thistle
#

why are you putting an ID in a string

drifting wedge
#

it gets from a json

#

ill use a db

#

i know

solemn latch
#

so, i recently swapped to everything being in its own modules.
my mysql stuff is still in my index, with the stuff that handles disconnects.
previously, everything worked fine, if mysql disconnects, it reconnects no problem.

now, if mysql disconnects the bot crashes with a
Error: Cannot enqueue Query after fatal error.

https://hastebin.com/gihegomedo.js
^ mysql connection in index.
^ CON is a var, typed let whoops

drifting wedge
#

but i already had the code

slender thistle
#

Remove ctx parameter

#

alsoooooooo........................

drifting wedge
#

how do i checl?

slender thistle
#

Why is there member.server

drifting wedge
#

i got that from interwebs

slender thistle
#

where did you get this code snippet fro-

#

yeah alright

earnest phoenix
#

smh

drifting wedge
#

i had most of it

slender thistle
#

Advice for the future: don't just copy paste everything

drifting wedge
#

i know

amber fractal
#

I copy code and it dont work, now what :(

drifting wedge
#

but the part that GIVE the role

#

i copy

#

but the rest i did

slender thistle
#

it's wrong.

drifting wedge
#

wow, i didnt know that

earnest phoenix
#

I copy code and it dont work, now what :(
@amber fractal lmaoo

slender thistle
#

in d.py 1.0.0+ you do member.add_roles(role)

drifting wedge
#

oooh

#

im retart

slender thistle
#

but yeah, to fix the error ITSELF,

Remove ctx parameter

pure lion
#

why you shouldn't and can't use json as a database:

  1. you're writing to a file. it isn't and doesn't support async, you can't do two operations on the same file at the same or close to the same time.
  2. it's a file, it's size will buff up to very huge sizes in a very shot timespan
  3. it's lacking with data types
  4. it has strict formatting rules, mess up one character and your ""database"" is invalidated
    :pogu:
slender thistle
#

Anything that isn't a command doesn't have a ctx

drifting wedge
#

o ook

earnest phoenix
#

Dice he knows

#

he did say hes gonna switch to db

drifting wedge
#
async def on_member_join(wgrole, member):
    with open('wrole.json', 'r') as f:
        wrole = json.load(f)
    role = discord.utils.get(member.add_roles('{wgrole}')
    await client.add_roles(member, role)```
pure lion
#

Oops

drifting wedge
#

i know

pure lion
#

Ok good

#

Good know

solemn latch
#

i have a feeling ill have to make a connection in each module if i can figure it out, which isnt the best, but its not the end of the world

drifting wedge
#

i ami

solemn latch
#

๐Ÿคทโ€โ™‚๏ธ

drifting wedge
#

u jsut had the code on hand

#

so ill use it for now

#

i alreadt started making the table

slender thistle
#

way

earnest phoenix
#

bruh i might learn py

slender thistle
#

wayyyy off the course

#

i-

drifting wedge
#

so super wrong?

slender thistle
#

literally nothing you did was correct

drifting wedge
#

omfg

#

i know

slender thistle
#

well

solemn latch
slender thistle
#

apart from removing ctx

drifting wedge
#

i realised

#

im dumb

slender thistle
#
async def on_member_join(wgrole, member):
    with open('wrole.json', 'r') as f:
        wrole = json.load(f)
    role = discord.utils.get(member.add_roles('{wgrole}')
    await client.add_roles(member, role)```

role = discord.utils.get(member.add_roles('{wgrole}') this will not make sense, as you could've seen previously

drifting wedge
#

on_member_join
member.add_roles('{wgrole}')
NameError: name 'member' is not defined

slender thistle
#

client.add_roles(member, role) you were supposed to edit this with member.add_roles stuff

drifting wedge
#
async def on_member_join(wgrole, member):
    with open('wrole.json', 'r') as f:
        wrole = json.load(f)
    member.add_roles('{wgrole}')
    await client.add_roles(member, role)```
#

ppph

slender thistle
#

yeah right

drifting wedge
#

oooh

slender thistle
#

what's wgrole

drifting wedge
#

role to give upon welcome

slender thistle
#

so it's not a parameter

drifting wedge
#

no

slender thistle
#

it's a variable you will create

#

so remove wgrole from function parameters

#

d.py only passes one parameter, which is supposed to be saved under member

drifting wedge
#
async def on_member_join(member):
    with open('wrole.json', 'r') as f:
        wrole = json.load(f)
    client.add_roles(member.add_roles('{wgrole}')
    await client.add_roles(member, role)```
#

yes?

#

or no

slender thistle
#

How do you manage to fix one thing and break the rest even worse

#

where did I tell you to replace discord.utils.get with anything?

drifting wedge
#

jesus im dumb

#

role = discord.utils.get

slender thistle
#

what's the full line

drifting wedge
#

role = discord.utils.get(client.add_roles(member.add_roles('{wgrole}'))

#

....

#

๐Ÿ’ฉ

opal plank
#

adding that crashed

#

same error

drifting wedge
#

its so wrong the bot isnt even startnig

#

lmao

slender thistle
#

to no surprise

#

scroll up to your first code snippet and copy the line from there

#

scroll up

#

not "send your code"

drifting wedge
#

?

#

oh ok

drifting wedge
#

role = discord.utils.get(member.server.roles, id=f"{wgrole}")

slender thistle
#

yes but replace server with guild and don't put wgrole in a string

opal plank
#
  const EventEmitter = require('events'),
  collector = new EventEmitter();
  client.collector = collector;
   chat.on('PRIVMSG', (message) => {
    message.chat = chat;
     client.collector.emit('COLLECTOR', JSON.parse(JSON.stringify(message))); 
   });
``` crashes
earnest phoenix
#

await client.change_presence(game=discord.Game(name="on " + str(len(client.servers)) + " Servers.", type=0))
AttributeError: 'Bot' object has no attribute 'servers' how do i fix this?

slender thistle
#

guilds

#

not servers

earnest phoenix
#

ty

slender thistle
#

also just use f-strings

#

easily readable and more performant

drifting wedge
#

wait

#

so where do i put wgrole?

#

role = discord.utils.get(member.guild.roles, id=f"{wgrole}")

#

thats what i have

slender thistle
#

I don't get what wgrole is supposed to be

#

you just get it outside of a string

drifting wedge
#

the role the bot gives

slender thistle
#

wgrole is the ID?

drifting wedge
#

yes'

slender thistle
#
>>> my_id = 1234
>>> f"{my_id}"
'1234'
>>> my_id
1234

let's take a step back and think logically

drifting wedge
#

ok

slender thistle
#

what does f"{my_id}" return in the code I sent

#

a string or an integer?

drifting wedge
#

my_id

#

oh

#

str

slender thistle
#

and what does just doing my_id return? A string or an integer?

drifting wedge
#

wait wut

#

oh ok

#

and int

slender thistle
#

Correct

quartz kindle
#

@opal plank you cant add chat to it

#

not before stringifying

drifting wedge
#

int

quartz kindle
#

if you want to add it, add it after cloning

slender thistle
#

so how do you pass wgrole as an argument to id=?

opal plank
#

lemme give that a try

drifting wedge
#

wgrole=roletogive

#

id=roletogive

#

?

slender thistle
#

id=wgrole

#

but you'd have to define wgrole somewhere first

drifting wedge
#

oh ok

#

so what i would do is remove the {}

#

define wgrole

slender thistle
#

pretty much

drifting wedge
#

and to define wgrole

#

i would do {wgrole} = wgrole?

slender thistle
#

that would error out

drifting wedge
#

oh ye

slender thistle
#
>>> {yeet} = 1
  File "<stdin>", line 1
SyntaxError: cannot assign to set display
drifting wedge
#

bc you cant start with {}?

slender thistle
#

{1, 2 ,3} is a set

#

so yes, you can't use {} when assigning

opal plank
#

still nothing

#

though tbh it did emit it without issues this time, but when listening to it, it crashed

drifting wedge
#

but can i do without the {}

#

wgrole = wgrole?

quartz kindle
#

not like that lul

slender thistle
#

that'd just say "assign value under variable wgrole to variable wgrole"

opal plank
#

how come?

slender thistle
#

which... doesn't do anything

drifting wedge
#

but i have this

slender thistle
#

the other way

#

the left part is where you are assigning something
the right part is what you assign

drifting wedge
#

wgrole[strblabla- = wrole?

quartz kindle
#
let clone = JSON.parse(JSON.stringify(message))
clone.chat = chat
client.collector.emit("COLLECTOR",clone)
slender thistle
#

Discord what the fuck

opal plank
#

not sure i get it

#

wouldnt that just reference?

drifting wedge
#

role = discord.utils.get(member.guild.roles, id=f"wgrole")
AttributeError: 'Member' object has no attribute 'server'

#

1 sec

slender thistle
#

nope

quartz kindle
#

no

drifting wedge
#

ill restart all instances

slender thistle
#

w-

#

i-

quartz kindle
#

JSON.parse(JSON.stringify(object)) is a deep clone

slender thistle
#

a?

quartz kindle
#

it will leave the original object untouched

opal plank
#

aight, lets give that a try

slender thistle
#

id=wgrole, without any quote marks

quartz kindle
#

you dont want to touch message, since its apparently crashing the lib

#

so you clone it, and then do your stuff to the clone

drifting wedge
#

then that should work:

opal plank
#

did i fuck it up again?

#

cuz it did crash with the same error

drifting wedge
#

role = discord.utils.get(member.guild.roles, id=wgrole)
NameError: name 'wgrole' is not defined

#

same error

slender thistle
#

how are you defining wgrole

drifting wedge
#

role = discord.utils.get(member.guild.roles, id=wgrole)

opal plank
#

i technically dont need chat referenced in the clone since its only used in the collector

slender thistle
#

defining

#

not using

drifting wedge
#

wdym

#

and here:
await client.add_roles(member, role)

#

do i change role to id?

slender thistle
#

member.add_roles(role)

opal plank
quartz kindle
#

you're still adding chat to message

#

dont touch message

opal plank
#

gimme 5 then, i gotta patch a couple commands

#

cuz ive been referencing almost everything in message

quartz kindle
#

do the same, but with the cloned object instead

#

like whats your starting point? where is the message first received?

#

clone it there, then add chat to the clone, and send the clone forward to the rest of your code, instead of sending message

opal plank
#

that is where the message is recieved

drifting wedge
#
async def on_member_join(member):
    with open('wrole.json', 'r') as f:
        wrole = json.load(f)
    role = discord.utils.get(member.guild.roles, id=wgrole)
    await client.add_roles(role)```
opal plank
#

on the index

drifting wedge
#

so this?

opal plank
#

client.on('PRIVMSG') is where message is created

#

i dont touch it anywhere else, i just append chat onto it, which contains client which contains a lot of jazz

quartz kindle
#

just do this

opal plank
quartz kindle
#
.on("PRIVMSG", bad => {
  let message = JSON.parse(JSON.stringify(bad))
  message.chat = chat
  ...
})
opal plank
#

im passing chat separated now

quartz kindle
#

thats what im saying, dont pass message

#

pass the clone instead

#

make the original message die there

#

use the clone for everything

drifting wedge
#

something broke

#

sivaco

opal plank
#

this, right?

quartz kindle
#

yes

opal plank
#

aight, lemme give it a try

quartz kindle
#

well idk then

#

does it still happen if you just console.log it and do nothing else?

opal plank
#

everything i tried thus far just lead to the same error

#

nah, it ONLY happens when its emitted

#

actually

#

not even

#

only when its listened to

#

this works

#

remove the two // and it doesnt

#

once the event is listened under collector it crashes

#

even added collector onto client to make sure it wasnt messing with it

quartz kindle
#

collector is your own code right?

opal plank
#

yes, this bit

#
const EventEmitter = require('events'),
  collector = new EventEmitter();
  client.collector = collector;
   chat.on('PRIVMSG', (message) => {
    message.chat = chat;
     client.collector.emit('COLLECTOR', JSON.parse(JSON.stringify(message))); 
   });```
#

theres a lot of stuff in between but thats the collector bit

#

now i switched to the bad as you said to deep clone

quartz kindle
#

wait, is that another PRIVMSG?

#

or is it the same one?

opal plank
#

nah thats before you told me to change

#

lemme get whats actually there now

#
const EventEmitter = require('events'),
  collector = new EventEmitter();
client.collector = collector;
chat.client = client;

 chat.on('PRIVMSG', (bad) => {
    let message = JSON.parse(JSON.stringify(bad));
    client.collector.emit('COLLECTOR', message);
    message.chat = chat;
    client.globals.get('global').execute(message, chat);
});

#

this is whats currently there

#

regarding the index on collector

#
function collector(filter, timer) {
      return new Promise((resolve) => {
        let collection = new Map();
        let handler = (message) => {
          console.log(message);
          if (filter(message)) {
            collection.set(message.id, message);
          }
        };
        chat.client.collector.on('COLLECTOR', handler);
        setTimeout(() => {
          message.chat.client.removeEventListener('COLLECTOR', handler);
          resolve(collection);
        }, timer);
      });
    }
    const filter = (m) => {
      m.content.length > 1;
    };
    console.log(await collector(filter, 5000));
``` this is the collector
#

forgot to mention, client is attached to chat, which is attached to message up there fixed it

quartz kindle
#

this error is not making any sense

amber fractal
#

twitch-js is written in ts from what I can see

quartz kindle
#

does it still happen if you remove all 3 lines except the first?

amber fractal
#

I cant actually find the lib

quartz kindle
#

keep only the json json line

#

and then do nothing

#

does it still crash?

opal plank
#

lemme check

amber fractal
opal plank
#

remove emitter, listener and what else?

quartz kindle
#
 chat.on('PRIVMSG', (bad) => {
    let message = JSON.parse(JSON.stringify(bad));
   // client.collector.emit('COLLECTOR', message);
   // message.chat = chat;
   // client.globals.get('global').execute(message, chat);
});
#

like this

opal plank
#

that in itself doesnt crash it

#

im assuming its something when it listens to event. if i enable all those lines but comment out the listened on collector it wont crash either

quartz kindle
#

thats from a timeout right?

drifting wedge
#
async def on_member_join (member):
    with open('wrole.json', 'r') as f:
        wrole = json.load(f)
    role = discord.utils.get(member.guild.roles, id=wgrole)
    await client.add_roles(role)```
quartz kindle
#

from waiting for the collector

drifting wedge
#

im e=getting an error

#

it says wgrole not defined

#

how do i define it?

opal plank
#

im not sure actually

#

yeah timeout

#

thats not from the collector.on

quartz kindle
#

remove the message from there

opal plank
quartz kindle
#

there is no message inside the collector timeout

opal plank
#

usually when i send the first 'dsa' it crashes

#

oh, right

quartz kindle
#

chat.client.collector

opal plank
#

my bad

#

same deal

#

im not quite sure i understand why that is there tbh

#

wouldnt it just be smarter to void the emitted events?

quartz kindle
#

this is getting nowhere

#

i'd need to see the full code

opal plank
#

lemme dm you then

long hare
#

how much time can bots change their status in 60 seconds? what is the limit

sudden geyser
#

There's no real limit defined, but last time I checked (months or a year ago), it was around once per 12 seconds. You should set it to something reasonable, like 1 or 2 times per minute.

long hare
#

thanks.

knotty steeple
#

the least u can do is like every 5 or 10s

amber fractal
#

well it was 5 per min max

#

which is once per 12 seconds

drifting wedge
#
async def on_member_join (member):
    with open('wrole.json', 'r') as f:
        wrole = json.load(f)
    role = discord.utils.get(member.guild.roles, id=wgrole)
    await client.add_roles(role)```
wgrole not defined
honest perch
#

You need to define it

drifting wedge
#

how tho @honest perch

honest perch
#

By defining it

earnest phoenix
#

is it possible to make it so only 1 certain ID can run a command?

honest perch
#

Yes it is possible

#

Read the docs

sudden geyser
#

What is the ID exactly. A user iD?

earnest phoenix
#

ye

#

idc abt the docs @honest perch

honest perch
#

Lmao

#

Then goodluck

#

In doing basic things

sudden geyser
#

Are you using the command framework. And you should care about the docs

#

The docs will be your best friend.

earnest phoenix
#

ye command

honest perch
#

Link them to docs spoonfeed

sudden geyser
#

Is the ID supposed to be you or just anyone you pick

solemn latch
#

doesnt care about docs? then why should we care about your questions ๐Ÿค”

earnest phoenix
#

me

sudden geyser
glossy elk
#
TypeError: str.replace is not a function
honest perch
#

Its not a function

glossy elk
#

it is..

sudden geyser
#

if it says it's not it's not

#

log what str is

glossy elk
#

Thats what i dont know

sudden geyser
#

then log it

glossy elk
#

I DONT KNOW

#

WHAT STR IS

sudden geyser
#

Did you define a variable called str?

glossy elk
#

no

solemn latch
#

then why .replace something you dont know about

#

๐Ÿค”

glossy elk
#

i didnt

#

my god

sudden geyser
#

Okay, look at the stacktrace and go to where it points and you'll probably find where .replace(...) is coming from

solemn latch
#

probably should start with that.

glossy elk
#

will substring do

sudden geyser
#

You should first know what it is

glossy elk
#

๐Ÿคฆ

#

substring splits

#

so i would considering that replacing ish

sudden geyser
#

Yeah I know that part but the first priority should be solving the error by inspecting where the error is coming from. You can then decide if you need substring instead

glossy elk
#

I have substring

#

its coming from my args

sudden geyser
#

can you share some of your code

glossy elk
#

Yeah

#
if (!phrase) return null;
            phrase = Util.cleanContent(phrase.toLowerCase(), message);
            const tag = await Tags.findOne({
                where: {
                    guildID: message.guild.id,
                    [Op.or]: [
                        { name: phrase },
                        { aliases: { [Op.contains]: [phrase] } }
                    ]
                }
            });

            return tag ? null : phrase;```
#

this is one of the args

#
    if (!phrase) phrase = '';
            phrase = Util.cleanContent(message, phrase);
            if (message.attachments.first()) phrase += `\n${message.attachments.first().url}`;

            return phrase || null;``` this si that other
sudden geyser
#

is replace possibly coming from Util.cleanContent()?

glossy elk
#

yeah im trying to see if thats it

#

Util is from discord

quartz kindle
#

why do you have phrase,message on one and message,phrase on the other?

glossy elk
#

i-

#

im dub

#

dumb

sudden geyser
#

yeah that's probably the issue

#

if you inspect the code as well the first argument is being .replace(...)'d

glossy elk
#

nope its not it

#

wait

#

i forgot to restart

#

i think its message, phrase

#

nope

#

it worked

#

thank you

strange trout
earnest phoenix
#

I'm currently in the process of creating a service called ForgeDiscord, and I have a question: "If you could see a plugin that is quick to install and that updates itself, and that makes the Discord experience endless, would you download?"

sudden geyser
#

Everyone will have their own answers. For me, it depends on what it does.

amber fractal
#

sounds like client mods

earnest phoenix
#

it allows the creation of html element with a simple function (function which can be deactivated by the user because it is dangerous), and flawless functions which allow to create 2d or 3d games for the craziest. Alerts, notification like on the phone. And too much more.

#

currently I only do security because this kind of service has a lot of flaws

#

I works 10hours per day for this

thick gull
#

sounds like client mods again mmulu

earnest phoenix
#

Its possible with html element wow (sounds)

#

Create a while

#

Or includes this in description ?

#

(Of embed sure)

#

yes

steel heath
#

just send request and get the body?

earnest phoenix
#

idk how lol

#

this is what i have so far

drifting wedge
#

can i do like

if bla bla = true
or bla bla = true
say hi
else say no

solemn latch
drifting wedge
#

just an example

#

in python

#

how would i like do if or else

solemn latch
#
a = 200
b = 33
if b > a:
    print("b is greater than a")

elif a == b:
    print("a and b are equal")

else:
    print("a is greater than b")
drifting wedge
#

but like or?

#

bc basicly im doing if author has permisson or role, do this

amber fractal
#

literally use or

drifting wedge
#

if not do this

#

it doesnt work

#

im using python

amber fractal
#
    ...
else:
    ...
drifting wedge
#

does that work?

#

or no?

#

ooh

#

ok

#

ok ok great

amber fractal
#

you should probably learn some python before doing a bot

solemn latch
#

imagine a bunch of js devs answering python devs questions

drifting wedge
#

@welcome.command()
if @commands.has_any_role("adminperms","welcomeperms") or @commands.has_permissions(manage_messages=True)

#

?

#

the or doesnt seem to work

regal saddle
#

that looks not right

amber fractal
#

no, it doesnt

regal saddle
#

Im pretty sure that this is copy pasted code, i saw that before

drifting wedge
#

no

#

i did it myself lol

amber fractal
#

it's not something you can use in an if statement

drifting wedge
#

it says if is invalid syntax

regal saddle
#

when you did it yourself why dont you know if it will work or not?

drifting wedge
#

i did

#

it game me error

amber fractal
#

because it is invalid syntax

regal saddle
#

seems sus

drifting wedge
#

@welcome.command()
if @commands.has_any_role("adminperms","welcomeperms") or has_permissions(manage_messages=True)

#

thats the benning

amber fractal
#

@ is the decorator symbol (or whatever the py equiv is)

drifting wedge
#

yea it is

amber fractal
#

Yeah you cant just put an if for decorators

drifting wedge
#

so i would do or has permission?
like im lost

regal saddle
#

I tried python for a school project some years ago, but idk how it works probably

amber fractal
#

idk how d.py works, you'd probably have to put it in the command itself if you want to do that

solemn latch
#

ive been learning because of this channel

earnest phoenix
#

just send request and get the body?
@steel heath how

solemn latch
#

people ask questions that are super quick google searches

regal saddle
#

stackoverflow intensifies

solemn latch
#

^ pretty much

amber fractal
#

that just seems like more of a thing you'd want to actually put in the command itself instead. Idk if you can do ors for decorators

merry grove
#

i forgot how to save guild settings

solemn latch
#

depends on the lib

regal saddle
#

What guild settings?

steel heath
#

@steel heath how
@earnest phoenix don't really know that much about python, try google

thick gull
#

use a databasewaitWhat

earnest phoenix
#

should be the same way

thick gull
#

wdym you forgot how to save guild settings waitWhat waitWhat

#

js this an ad

amber fractal
#

@modern sable

regal saddle
#

oi

modern sable
#

@magic night why did you randomly send that channel?

regal saddle
#

in this channel*

#

sorry

earnest phoenix
#

smh

modern sable
#

oh nvm

#

they just changed their username to the channel name

earnest phoenix
#

agreed

regal saddle
#

people are something in 2020

earnest phoenix
#

bruh it's a fortnite channel

quartz kindle
torn ravine
earnest phoenix
#

send the link @quartz kindle

earnest phoenix
#

So i've made a few functions, but when the parameters are 0, they come out as false and trigger the if statement which leads to saying, no parameter was provided, how's possible to prevent this from happening?

quartz kindle
#

depends what type the parameter accepts

earnest phoenix
#

Both parameters must accept a number

#

But when one of them is 0 it counts like that parameter doesn't exist for some reason

quartz kindle
#

if(isNaN(number)) throw ...

#

if it needs to be integers, then
if(!Number.isInteger(number)) throw ...

#

if you have somewhere if(number) or if(!number), then 0 does count as false

glossy elk
#

How can i find

earnest phoenix
#

Oh

glossy elk
#

the file directory

#

of where a unhandled rejection

#

was executed

quartz kindle
#

you need to catch your promises

#

otherwise its hard to find the origin

#

is there nothing in the stack? show the full error

glossy elk
#

its a discordapierror

#

[UNHANDLED REJECTION] 404: Not Found || DiscordAPIError: 404: Not Found
at RequestHandler.execute (C:\Users\sadie\OneDrive\Desktop\Dummy\node_modules\discord.js\src\rest\RequestHandler.js:170:25)
at runMicrotasks (<anonymous>)

#

dont mind

#

onedrive

#

quick heads up if you are responding to a question ping me

quartz kindle
#

yeah you need to catch them

glossy elk
#

how?

#
process.on('unhandledRejection', err => {
    Logger.error(`[UNHANDLED REJECTION] ${err.message} || ${err.stack}`);
});
#

thats my current code

quartz kindle
#

all discord.js methods that interact with the rest api return promises, and these promises need to be caught

#

for example

#
message.channel.send("bla") // bad
message.channel.send("bla").catch(console.error) // good
glossy elk
#

there is the thing

#

i dont know where its coming from

quartz kindle
#

same with .edit(), .add(), .remove(), .ban(), .fetch(), etc...

glossy elk
#

but i know its an event

quartz kindle
#

you need to do this for everything

#

you need to review your code and properly handle promises

glossy elk
#

what could be causing

#

404 errors

quartz kindle
#

its a generic error for when something is not found

#

could be anything

glossy elk
#

cant i use try

quartz kindle
#

for example this happens if you try to fetch a user and give undefined as id

#

you can use try catch with await

#
try {
  await message.channel.send("bla");
} catch(e) {
  console.log(e)
}
#

if you dont use await, the try-catch doesnt work

glossy elk
#

i thought there was code inspectors?

quartz kindle
#

well you can try

#

but promises are complicated

glossy elk
#

the error code isnt effecting anything i can see

bitter carbon
glossy elk
#

but well see

quartz kindle
#

because a promise is basically a function in a limbo,

bitter carbon
quartz kindle
#

if you dont await or catch, when the error happens the promise doesnt know what it belongs to anymore, its lost in limbo

#

it doesnt know where it came from

glossy elk
#

ok im trying try

#

:/

#

that was a fail

quartz kindle
#

@bitter carbon in discord.js v12 avatarURL is a function

bitter carbon
#

@bitter carbon in discord.js v12 avatarURL is a function
@quartz kindle ok

glossy elk
#

@quartz kindle cant i do

#

--trace-warnings

bitter carbon
#

@bitter carbon in discord.js v12 avatarURL is a function
@quartz kindle now its another erro

quartz kindle
#

displayAvatarURL is also a function

earnest phoenix
#

@bitter carbon You have DIscord.js

#

const Discord = require("discord.js")

glossy elk
#

@quartz kindle faster way?

karmic compass
#

oh thank you Tim you helped me indirectly, try{} catch{} wasn't working, couldn't figure out why, then i realized that i wasn't using await

drifting wedge
#

how do i define a guild in the message its being set in?

karmic compass
#

which lib

#

@drifting wedge what langauge are you coding it?

paper cliff
#

discord.js bot.guilds.cache.get('Server ID').send('Message')
discord.py: bot.get_guild(Server ID).send('Message')

karmic compass
#

op

#

he beat me to it

drifting wedge
#

python @karmic compass

karmic compass
drifting wedge
#

ok

#

cool

karmic compass
#

cool

ionic dawn
#

TheCatAPI lolok

thick gull
#

does anyone have any good resources I can use to learn mongo?

earnest phoenix
#

YouTube...

#

๐Ÿ˜‚

#

Does anyone know how to make a simple website?

thick gull
#

imo youtube videos dont really teach you much

#

they're mostly copy this, paste this

#

unless you have a good video (which is basically what im asking for)

earnest phoenix
#

Catgirl API > CatAPI @ionic dawn

#

Flask if in Python @earnest phoenix

#

ยฏ_(ใƒ„)_/ยฏ

#

?

thick gull
#

does anyone have any good resources I can use to learn mongo?
:(

crystal socket
wanton dew
sudden geyser
thick gull
#

okay

fluid basin
#

does anyone have any good resources I can use to learn mongo?
w3schools also

earnest phoenix
#

heeeyo

paper cliff
#

oyeeeh

#

What language do you use for your bot & website?

earnest phoenix
#

Bot

#

js

#

html & php

paper cliff
#

any database or any other external thing?

earnest phoenix
#

i can connect mysql

#

but just connect

#

idk how to use mysql

paper cliff
#

The thing I would have done is a Linux socket that your bot creates and your website can connect to
May be located at /tmp/yourBotName.socket for instance

#

or a normal TCP server on any port

#

or even easier, create an HTTP server in your bot itself that will be served as an API

earnest phoenix
#

last section pls

paper cliff
delicate shore
#

i need urgent help

paper cliff
#

i mean there a lot of ways to do this anyway

delicate shore
#

plesse my bot won't go

paper cliff
#

@delicate shore what

delicate shore
#
    at WebSocketManager.destroy (/rbd/pnpm-volume/d627e943-fbaa-4cab-abab-a4178d6f915d/node_modules/.registry.npmjs.org/discord.js/12.2.0/node_modules/discord.js/src/client/websocket/WebSocketManager.js:335:54)
    at Client.destroy (/rbd/pnpm-volume/d627e943-fbaa-4cab-abab-a4178d6f915d/node_modules/.registry.npmjs.org/discord.js/12.2.0/node_modules/discord.js/src/client/Client.js:235:13)
    at Client.login (/rbd/pnpm-volume/d627e943-fbaa-4cab-abab-a4178d6f915d/node_modules/.registry.npmjs.org/discord.js/12.2.0/node_modules/discord.js/src/client/Client.js:224:12)
    at processTicksAndRejections (internal/process/task_queues.js:88:5)
(node:4310) UnhandledPromiseRejectionWarning: Response: Bad Gateway
    at RequestHandler.execute (/rbd/pnpm-volume/d627e943-fbaa-4cab-abab-a4178d6f915d/node_modules/.registry.npmjs.org/discord.js/12.2.0/node_modules/discord.js/src/rest/RequestHandler.js:158:11)
    at processTicksAndRejections (internal/process/task_queues.js:88:5)
(node:4310) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:4310) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.```
#

My bot isn't going uP!

paper cliff
#

"MANAGER_DESTROYED" dang

delicate shore
#

means?

paper cliff
#

Node.js is so rude

#

Did you change something recently?

delicate shore
#

yeh

#

i enable-npm

paper cliff
#

?

delicate shore
#

enable-pnpm

paper cliff
#

what

delicate shore
#

enable-pnpm

#

that's it

paper cliff
#

?

#

what is that

earnest phoenix
#

@paper cliff i have no idea about create a api or like something

#

do you have any example

delicate shore
#

dk

opal plank
paper cliff
#
const Discord // ...
const bot // ...
// ...

const express = require('express')
const api = express()

api.get('/server_count', (req, res) => {
  res.end(bot.guilds.cache.size.toString())
})

api.get('/user_count', (req, res) => {
  res.end(bot.users.cache.size.toString())
})``` 
It's pretty simple actually
#

Like I said you can implement that in a lot of ways

#

@earnest phoenix ^

delicate shore
#

@paper cliff what should i do

paper cliff
#

wait a min

delicate shore
#

i did

paper cliff
#

what is your thing enable-pmnp,?

delicate shore
#

it stIll says that

#

nothing ignore thta

paper cliff
#

what

delicate shore
#

yes

#

enable-pnpm is

#

just a

fluid basin
#

(node:4310) UnhandledPromiseRejectionWarning: Response: Bad Gateway

#

you sure you didn't break anything?

paper cliff
#

just a what

#

:x

delicate shore
#

yo @paper cliff i cloned my project into new one on glitch and it's online now

paper cliff
#

oh

#

ok lol :x

delicate shore
#

lol

still cliff
#

I would suggest using a rendering engine if you are building a complete website and not just an API, @earnest phoenix.

earnest phoenix
#

sorry for private

fluid basin
#

I meant that they're using the wrong variable

#

in the routing functions

#

should be client instead of bot

still cliff
#

They are not.

#

Oh yes. I just saw that.

fluid basin
#

XD

earnest phoenix
#

wait what

still cliff
#
const express = require("express");
const app = express();
const Discord = require("discord.js");
const client = new Discord.Client();
app.get("/server_count", (req, res) => {
  res.json({"online": client.guilds.cache.size});
});```
earnest phoenix
#

we created new subdomain

#

we can't do it into main.js

#

we need login with token and post it to website

fickle dune
#

Air

#

for some reason idk why i made a bot which is kind of useless but no body has made it either

#

so uh im thes 1st one

still cliff
#

You can run multiple instances, Ben.

#

Or integrating this won't be much of a hassle.

sick cloud
#

my own version of discord's dev portal in progress for my own app

fluid basin
#

damn neat

sick cloud
thick gull
sick cloud
#

nothing final, just making it to test the completed oauth2 api

#

๐Ÿ‘Œ

still cliff
#

Looks neat!

sick cloud
#

ty

#

and it's fully functional ofc

#

all oauth2 apps loaded from the db, login is done using the oauth2 api i made w/ client_credentials flow

still cliff
#

What rendering engine do you happen to use?

sick cloud
#

ejs, nothing fancy as its just a test run

fickle dune
#

why my wifi is so slowww ddadsfafa

still cliff
#

EJS is very powerful. It can handle production builds too.

sick cloud
#

can't handle my final production app sadly, gonna use nuxt for that probably

#

because i like the smooth page loads

fluid basin
#

vue?

#

wew

sick cloud
#

yeee

still cliff
#

Oh. Well.

sick cloud
#

way better anyways

#

but ejs is pretty good

earnest phoenix
#

@still cliff i just try your code on glitch

#

im still on this screen

still cliff
#
const express = require("express");
const app = express();
const Discord = require("discord.js");
const client = new Discord.Client();
app.get("/server_count", (req, res) => {
  res.json({"online": client.guilds.cache.size});
});


client.login(process.env.token);

const listener = app.listen(3000, () => {
  console.log("Online on " + listener.address().port);
});
#

Here is the complete code.

#

@earnest phoenix ^

sick cloud
#

fyi not the best way to do it

#

if i can step in and make some improvements ๐Ÿ˜Ž

still cliff
#

The simplest one.

#

Sure!

paper cliff
#

Using JSON there is unecessary
Don't recommend him to use a redenring engine for an API (like wtf?)
That code looks weird

still cliff
#

I would suggest using a rendering engine if you are building a complete website and not just an API, @earnest phoenix.
@still cliff
Read messages properly, @paper cliff.

#

if you are building a complete website and not just an API

sick cloud
#
/*
  requires the following modules:
  express, discord.js, helmet, compression
*/

const express = require('express');
const { Client } = require('discord.js');

let ready = false;
let port = 80; // change to modify port

const app = express();
const client = new Client();

app.use(express.json());

// adds a few extras to make it more safe
app.use(require('helmet')());
app.use(require('compression')());

client.on('ready', () => {
  // make the api ready
  ready = true;

  console.log(`Connected to Discord`);
});

app.get('/servers', (req, res) => {
  // error if not ready yet
  if (!ready) return res.status(500).json({ error: 'Not connected to Discord yet' });
  
  return res.json({ servers: client.guilds.cache.size || 0 });
});

app.listen(port, console.log(`Listening on port ${port}`);
client.login(process.env.TOKEN);
#

i know it's chunky for something so simple, lmao, but it's better ig

paper cliff
#

@still cliff and?

sick cloud
#

makes sure it can't error

still cliff
#

And what, @paper cliff?

paper cliff
#

Read messages properly
He already have a website with php or whatever
He just want a way to embed usercount and guildcount

#

@sick cloud i think you can use client.ready ?

#

i think it's a variable you can use :)
(it's readyAt*)

still cliff
#

I have happened to miss that because I received a private message from the author.

#

Excellent handling of common errors, @sick cloud!

sick cloud
#

๐Ÿ‘Œ

#

and yeah technically you could use readyAt but using the ready event is fine

drifting wedge
#

Does SQLite work with heroku?

thick gull
#

no iirc

drifting wedge
#

Iโ€™m thinking about using heroku while my bot is small

#

Iirc?

thick gull
#

if I remember correctly

drifting wedge
#

What is that tho?

thick gull
#

??

#

I just answered you

drifting wedge
#

Iirc

thick gull
#

iirc

#

if i remember correctly

drifting wedge
#

What is that

#

Ooooooh

sick cloud
#

its an acronym or whatever

paper cliff
#

@drifting wedge heroku supports MySQL/Mongo/... addons

#

use that maybe?

drifting wedge
#

Well Iโ€™ll get a actuall host

#

What do you guys recommend?

fluid basin
#

check pins

delicate shore
#

O

#

Well Iโ€™ll get a actuall host
@drifting wedge
I know a good VPS it's free but not for huge bots as it only gives 250 mb memory

#

Bruh

drifting wedge
#

@drifting wedge
I know a good VPS it's free but not for huge bots as it only gives 250 mb memory
@delicate shore what is it?

delicate shore
#

I can DM u

fluid basin
#

bruh

drifting wedge
#

There

#

Send it

earnest phoenix
#

If you have a credit card, GCloud gives you 1 year or $300 credit for free

fickle cloak
#

anyone know how to create a discord bot? i want it linked with google sheets

earnest phoenix
#

Are you asking for someone to make you one, or looking to find out how to make one? @fickle cloak

fickle cloak
#

well i dont know how to make one and looking on utube i dont understand. also i want the bot linked with google sheets because from google sheet responses people will get roles

sonic lodge
#

you need knowledge of a programming language to program your own bot

thick gull
#

        if (!message.member.hasPermission('MANAGE_SERVER')) {
            message.channel.send('You do not have the `MANAGE_SERVER` permission.')
        } else {

RangeError [BITFIELD_INVALID]: Invalid bitfield flag or number.

can't figure it out man hecc its 2am and slepe boy

#

the thing says its this line

#

so/shrug

sonic lodge
#

MANAGE_GUILD

thick gull
#

oh ๐Ÿ™ƒ

sonic lodge
#

๐Ÿ˜›

delicate shore
#

hey

#

how is everyone doing

#

I had a question regarding a command

#

the command is called roleall it gives roles to all
I wanted to ask how much limit will this use out of 1000

sudden geyser
#

"how much limit will this use"? What is "limit"? What exactly are you using?

#

Trying to add roles to everyone in a server or large group is typically prone to hitting a rate limit when done unproperly

delicate shore
#

nvm

#

i figured it out

pallid igloo
#

NodeJs Eval method is called eval or evaluate?

worthy glacier
#

how do i make my bot run 24/7

#

without having to run it constantly locally

golden condor
#

@pallid igloo eval

pallid igloo
#

@worthy glacier a vps.

#

Or a host

worthy glacier
#

ok

delicate shore
#

Hey

#

I cannot export my bot to github

#

is there any other way i can do so ?

#

pls tell kthnx

golden condor
#

What have you tried to do

delicate shore
#

there is a option

#

in glitch to export

worthy glacier
#

are there any good free vps options?

delicate shore
#

are there any good free vps options?
@worthy glacier your own pc

golden condor
#

Is it connected to your GitHub account?

delicate shore
#

yes it is

worthy glacier
#

yea ik that

#

but any non local options

misty sigil
#

no

delicate shore
#

problem is it was earlier imported from github but i changed whole code so can it be reason?

#

it already has a gitgnore should i delete that?

misty sigil
#

any """""""""""free""""""""""" hosting is either:

  1. not intended to be used as hosting
  2. not actually suitable for hosting
  3. not actually free
golden condor
#

@worthy glacier not really, you won't find many free hosts that are good.

worthy glacier
#

got it thanks

#

ill just run it on a second pc for now

delicate shore
#

problem is it was earlier imported from github but i changed whole code so can it be reason?
it already has a gitgnore should i delete that?

golden condor
#

You can try DanBot ig

delicate shore
#

U can use Dum host

golden condor
#

@delicate shore glitch should send it to a glitch branch in the repo

delicate shore
#

no it didn't

golden condor
#

I said should

#

Can you show what comes up when you try send it? Or send like a video of what happened

delicate shore
#

Can you show what comes up when you try send it? Or send like a video of what happened
@golden condor nothing

#

it keeps loading

#

then it says

#

Weโ€™re sorry, something went wrong! Please try again, or try refreshing the editor

golden condor
#

try a different repo

delicate shore
#

i have been trying for over 30 days now

#

try a different repo
@golden condor over 6 tried

golden condor
#

Have you signed in with your GitHub

#

?

delicate shore
#

yes

golden condor
#

Hm

#

Weird

#

One other way I can think of

#

You see that git URL?

#

On the project

delicate shore
#

You see that git URL?
@golden condor sorry?

#

i can see my glitch project link

golden condor
#

So

#

When you go down to export

delicate shore
#

on export and import

#

on glitch

golden condor
#

Do you see a git url

#

There should be one

delicate shore
#

um

#

```
#

this is what i see

#

yeh

#

now @golden condor ?

golden condor
delicate shore
#

i found it

golden condor
#

Copy that url

delicate shore
#

done

dusty shale
#

Hello

golden condor
#

Do you have "git" installed your computer?

#

Can you try just typing git in a console

delicate shore
#

yes

#

i have

golden condor
#

Ok

#

Good

delicate shore
#

but idk how to use git

#

;-;

golden condor
#

It's fine, I'll run you through this

#

So

delicate shore
#

ok

#

hold on

#

lemme get on my pc

dusty shale
#

I am Making a website for my team's bot.
I wanted to show the number of servers and members the bot serves on the website but am not sure on how to do it.
Can anyone help me out?

golden condor
#

:+1:

delicate shore
#

u can leave here i will see and thanks in advance

golden condor
#

No if you don't know how to use git, I'll happily run you through it and I can explain what it means

delicate shore
#

okie

golden condor
#

So make a new folder on your pc

#

And cd inside it

delicate shore
#

kk

golden condor
#

Just lemme know once u did that (u can use mkdir)

delicate shore
#

yeh my pc turning on

paper cliff
#

@dusty shale How did you make your website and your bot?

dusty shale
#

Website is html and bot is js

golden condor
#

You can make a small API for communication

dusty shale
#

Could you help me out with it?

delicate shore
#

@golden condor back

golden condor
#

Ok

delicate shore
#

i cd into my folder

golden condor
#

@dusty shale something simple inside your bot would work. Like getting /guilds returns the guilds and /members returns members

#

now do

#

cd ../

#

And

#

git clone <git url from glitch> <folder name>

delicate shore
#

why?

#

why cd.//

#

it brings me back to desktop

golden condor
#

So it goes inside the folder you just made

delicate shore
#

oh ok

golden condor
#

Look above

delicate shore
#

it says

#

FATAL

#

TOO MANY ARGUMENTS

golden condor
#

o

#

Nvm

delicate shore
#

ok

golden condor
#

git clone <git url from glitch> "<folder name>"

#

That will work

delicate shore
#

it says cloning into sheep

golden condor
#

Ok

delicate shore
#

holy crap its 300 mb

golden condor
#

Just wait for that to finish

delicate shore
#

k

thick gull
#

300 mb is nothing

golden condor
#

Is there a node modules folder inside there now?

delicate shore
#

it's installing

golden condor
#

ok

delicate shore
#

should i open folder?

golden condor
#

Yes

delicate shore
#

ok

#

it says done

golden condor
#

If there is a node modules folder

#

Delete it

delicate shore
#

it's not

golden condor
#

Ok

#

Now

delicate shore
#

now ?

golden condor
#

Open your terminal

delicate shore
#

but wait

#

callum

golden condor
#

Yes

delicate shore
#

i had a env folder