#development

1 messages · Page 809 of 1

earnest phoenix
#

if you don't do super() you don't get access to the BaseCommand shit

sinful lotus
#

I need to call super to call the base command constructor

#

and inherit base command functions or methods

#

or properties

#

everything on it

#

is inherited

earnest phoenix
#

yea

crimson vapor
#

I see

sinful lotus
#

basically

earnest phoenix
#

extending a class

#

basically is like your class is that class but you can add some other shit

sinful lotus
#

or override the base class functions

crimson vapor
#

so its kind of like a database where you define fields then fill them with ones specific to each command

quartz kindle
#

in a way, kind of

sinful lotus
#

discord.js client has login() method

#

but my WumpusClient has login() method as well

#

so it overrides the original login() method

#

but notice the super.login()

crimson vapor
#

so you call it in yours?

sinful lotus
#

yess basically, I extended the original login() method to do my thing first before calling the original login()

crimson vapor
#

this is so smart

#

so classes allow for configuring of other classes, which is good for bot specific data

#

if I am correct

quartz kindle
#

then, classes are also good for using getters and setters

#

notice the get keywords

#

a getter is like a property that can do stuff before it returns a value

amber fractal
#

I never liked getters and setters personally

#

Because if you have a get x then you cant have a this.x

#

Gotta call it something else

sinful lotus
#

that getter is accessed via this.getterName

#

although you cant this.getterName = owo

#

cause getters are read only

amber fractal
#

Yeah thats what I don't like

sinful lotus
#

because its behaving like a property but it executes the function before returning a value

amber fractal
#

Like if I have a

 this.y = t
}

get x(){
 return this.y
}```
has to be like this iirc
sinful lotus
#

but I wont use getters

quartz kindle
#

for example ```js
a = {
date: Date.now()
}

b = {
get date() {
return Date.now()
}
}```

a.date will always return the same date, because the date is resolved when the code runs the first time
b.date will always return the current date, because the date will resolve whenever the code is called

amber fractal
#

I dont work with functions all the time

crimson vapor
#

alright classes and constructions and super, am I missing anything?

sinful lotus
#

if I want something like that

#

just use this.prop = value

#

totalPlayers and queue size is not always the same value, but I also dont want to make 2 properties just for them

#

so instead I can use getters

#

it always depends on your use case

#

if you want a property in class that is constant and never changes, as well hidden, then use Object.defineProperty()

crimson vapor
#

I would like to attempt to learn about classes by testing them, anything else I should know?

sinful lotus
#

should be fine now

#

all you need to do is to get used to it

#

and memorize the basics of it

crimson vapor
#

do you have any suggestions for parts of the basics I should learn first?

sinful lotus
#

hmm create class

#

then try extending it

#

on your own

crimson vapor
#

ok

quartz kindle
#

also this: create two classes, and add them to each other

regal saddle
#

discord.js broke

quartz kindle
#

?

crimson vapor
#

so class creates objects?

regal saddle
#

i tryed to fix my mute command and it says „member is not defined“

#

and i cant fix it

crimson vapor
#

bruh

#

try defining member?

regal saddle
#

member is defined

#

Thats the thing here

quartz kindle
#

show code

regal saddle
#

gimme sec

crimson vapor
#

im sorry for being rude

regal saddle
#
module.exports = {
    run(client, message, args) {
      if(!message.member.hasPermission("KICK_MEMBERS")) return message.reply("du hast keine Berechtigung!")
  let member = message.mentions.members.first()
  if (!member) return message.reply("bitte gebe einen Benutzer an!")
  let reason = args.slice(1).join(" ")
  if (!reason) reason = "Keine Begründung angegeben."
  let muterole = message.guild.roles.find(m => m.name === "muted")
  member.roles.add(muterole)
  .then(() => {
  message.reply(`der Nutzer <@${user.id}> wurde gemuted` + (args.slice(1).length ? ` wegen: ${args.slice(1).join(' ')}` : "!"));
  member.send("Du wurdest gemuted" + (args.slice(1).length ? ` wegen: ${args.slice(1).join(' ')}` : "!"));
})
  .catch(console.error);
}}```
#

its german im sorry for you guys

crimson vapor
#

can you copy and paste the error?

regal saddle
#

member is not defined.

quartz kindle
#

on what line?

#

does your bot accept dms?

regal saddle
#

nope

#

dms are closed

quartz kindle
#

what line is the error

regal saddle
#

ah shit

#

wait a sec

#

on the first line

earnest phoenix
#

Wtf

crimson vapor
#

I have successfully created a and extended a as b

earnest phoenix
#

@regal saddle what is your version of d.js??

crimson vapor
#

time to add more to it

regal saddle
#

Its the newest

#

V12

earnest phoenix
#

Oh sorry i cant help u

#

:/

quartz kindle
#

the error is "member is not defined" or "cant read property of undefined"?

#

show the full error

crimson vapor
#

I thought he fixed the error

#

guess I misundestood

regal saddle
#

TypeError: Cannot read property member of undefined

#

if you want the full error i could dm you

#

If you want

quartz kindle
#

that means message is undefined

regal saddle
#

message?

quartz kindle
#

yes

regal saddle
#

lol

#

but, wtf

quartz kindle
#

your message is not defined

#

show the part where you call the run function

crimson vapor
#

is it possible you only passed message through the function

regal saddle
#

wait i need to start my pc real quick smirk

quartz kindle
#

.>

#

im gonna go sleep

regal saddle
#

rip

#

ok, good night

amber fractal
copper cradle
#

@regal saddle show your command handler

#

the only way message can be undefined is by not passing it when calling the function

regal saddle
#

ill dm you then just gimme some time rn

copper cradle
#

bruh

crimson vapor
#

I assume tim and Saya are gone now?

#

if not, how do you push an object such as client through all of the classes?

earnest phoenix
crimson vapor
#

thank you kind sir

outer niche
crimson vapor
#

what is the file type?

outer niche
#

.lua

#

I think it is CSS?

copper cradle
#

it's lua

#

the lang is lua

topaz fjord
#

.lua
I think it is CSS?

outer niche
#

Can you run Lua on virtual studio code

earnest phoenix
#

Yes

copper cradle
#

vIrTuAl

#

you can run any language on your computer, you just need their compiler or their interpreter

#

you should try to learn to code

#

and stop ignoring us

digital ibex
#

Hi

#
message.channel.guild.members.filter((u) => u.status === 'online').size
``` any ideas why that returns undefined? (eris)
#

im dumb, fixed^

zenith orchid
#

I think message.guild is it worked.

digital ibex
#

no

#

its .length

zenith orchid
#

idk eris.

floral bloom
#

Discord.js
Okay, I have been trying to set a role's position for a long time not. I have it based off of another guild's role position. I don't see the problem, I get no error, and I can get the role position of both roles. The problem is just that it doesn't actually set the position.

await message.guild.roles.forEach(async function (r) {
  let otherRole = client.guilds.get(guild.id).roles.find(role => role.name === r.name).position;
  await r.setPosition(otherRole);
});
earnest phoenix
#

message.guild not work I think

#

no

#

it does

floral bloom
#

@earnest phoenix Did you make sure that it's actually message and not msg or something similar? Also, what are you trying to do with message.guild?

earnest phoenix
#

message.channel.guild.members.filter((u) => u.status === 'online').size
any ideas why that returns undefined? (eris)

#

@floral bloom

digital ibex
#

uh

#

really

earnest phoenix
#

wtf

floral bloom
#

Lol

earnest phoenix
#

Wait

#

What

zenith orchid
#

@floral bloom otherRole = r

earnest phoenix
#

@earnest phoenix what are you trying to do

#

@floral bloom

#

Fail ping

zenith orchid
#

Why?

earnest phoenix
#

he's trynna be that edgy helper probably

#

@zenith orchid no you

zenith orchid
#

Oky 😉

#

@floral bloom try find with id.

earnest phoenix
#

I am don't understand how to get used ram bro can you say

#

dude

#

don't send your question in like 3 channels

#

Bro I need help

digital ibex
#

HIS

earnest phoenix
#

Bro

digital ibex
#

question

#

??

#

or MY question

#

when i said i figured it out

zenith orchid
#

process.memoryUsage()

digital ibex
#

he posted my question for some reason when i said i figured it out

#

dont ask y

earnest phoenix
#

lmao

floral bloom
#

@zenith orchid I can't find with ID as the IDs are different. I am trying to set one role the same position as the role from another server.

#

Basically I'm duplicating the server's roles.

#

I was able to programmatically create the roles and set permissions, but I need to set the role position to be the same from the other server.

zenith orchid
#

All roles?

floral bloom
#

Correct.

zenith orchid
#

Wait

#

So 2 roles don't equals this position . It is impossible.

#

My idea but i'm trying.

#

Aaa

#

I understand.

#

You trying somerole in a guild, somerole in b guild and names equals.

#

This correct? @floral bloom

#

So you tried set position.

floral bloom
#

Guild A has a role named Moderator. I duplicated the roles so now guild B has the same role, Moderator, just out of order. I want to order them the same, but I am having trouble setting the role position to match so that the Moderator role are both the same position on both guilds. I am searching by the name, checking the position, and trying to set the new position the same.

await message.guild.roles.forEach(async function (r) {
  let otherRole = client.guilds.get(guild.id).roles.find(role => role.name === r.name).position;
  await r.setPosition(otherRole);
});
#

@zenith orchid Pinging in case you didn't see this or have the server muted. If this disturbs you, I apologize. Also, neat profile picture (off topic but whatever).

zenith orchid
#

I'm trying.

#

You have any error?

floral bloom
#

@zenith orchid Not that I know of, no. And that's what's weird.

#

Hm, using the eval command I get this error:

- Cannot read property 'position' of null
zenith orchid
#

Djs version? @floral bloom

floral bloom
#

11.5.1 I didn't know there was an update available. I'll update it and see if it works.

zenith orchid
restive furnace
#

wait... 12.0.1 is stable?

digital ibex
#

uh yes

mossy vine
#

yes

digital ibex
#

does anyone know how to get the presence of a user

#

(eris)

mossy vine
#

Member#game maybe?

#

so when you do console.log(<Member>.game) you just get [object Object]?

digital ibex
#

yes

#

well, eval

mossy vine
#

try console.log

digital ibex
#

ok

mossy vine
#

eval can be a mess

digital ibex
#

yea lol

#

ah

#

yes

mossy vine
#

eris is so weird sometimes

digital ibex
#

im really bad with objects and methods and stuff but, would it be something like <member>.game ? <member>.state : <member>.name or something

restive furnace
#

true/false ? (if true) do something : (if false) do something

digital ibex
#

oh

#

yea, im bad at them

earnest phoenix
#

or

#

(statement) ? true : false

restive furnace
#

member.game ? state and name combined : "not playing"

digital ibex
#

uh

#

what would go in the middle bit?

restive furnace
#

(statement) ? true : false

digital ibex
#

oh

restive furnace
#

so if member plays the game then in the middle disolays, else in the right side.

digital ibex
#

yh im confused

earnest phoenix
#

its basically a shortened verison of if() {} else {};

digital ibex
#

oh

earnest phoenix
#

heres an example

restive furnace
#

var x = (statement, like member.game) ? (if statement is true, this will be the variable value) : (else, this will be variable value)

earnest phoenix
#
const age;
var x = (age > 18) ? "wow you're old" : "wow you're young" 

// if age is bigger than 18 x returns "wow you're old" but if it isn't bigger than 18, it will return "wow you're young"
restive furnace
#

age probably would better to be defined

#

i meant like = 30

digital ibex
#

oh

floral bloom
#

Hm, is there a reason that it says my token is invalid, even though I changed it?

digital ibex
#

you need to update it onto ur code

#

and save etc

floral bloom
#

Yes, I did.

tight plinth
#

Retry

digital ibex
#

just keep on doing it, then it'll work

#

thats what u have to do sometimes

tight plinth
#

Regenerate it, copy and paste in ur code

#

And then restart

floral bloom
#

Nope. It's an issue with v12.0.1.

digital ibex
#

its not

floral bloom
#

I went back to v11.5.1 and it works just fine.

digital ibex
#

because you tried again...

tight plinth
#

^
Nope, works for everyone

floral bloom
#

I updated the token, changed it in the code, and restarted the program many times.

digital ibex
#

u were 1 too short then

tight plinth
#

Are you sure the code itself isn't broken

#

Not the token, the code

floral bloom
#

@tight plinth I am sure. I never changed anything when changing the version number.

restive furnace
#

the things are bit different on v12 so you might need to change some codes before geetting ur bot on.

vagrant tree
#

is it possible to have a link to dm for your bot?

restive furnace
#

wdym

vagrant tree
#

my bot can be used in DM and not just in a guild so i want to provide a link so that a user click and it will add the bot as a DM

restive furnace
#

so you mean mass-dm bot? (thats illegal btw)

mossy vine
#

no

#

you can dm the user tho

lilac wharf
#

he means bot commands in dm's

scarlet bane
#

to DM a bot you need to share a server with the user

#

thats how discord works

lilac wharf
#

^

scarlet bane
#

there is no work around, if you find one it's a bug

vagrant tree
#

ah i see

lilac wharf
#

and abusing that bug is against t&s.

vagrant tree
#

ok thanks! anyone can just dm the bot like they dm a normal user i guess and all bot commands will be available?

mossy vine
#

yes

scarlet bane
#

if they are sharing a server with the bot

lilac wharf
#

as long as it has no errors in dm's as the same as guild channels then yes.

#

for example, if you have a guild property in a command make sure it can't be used in dm's

slender thistle
#

Why would I be able to scroll around on my HTML page 🤔

lilac wharf
#

huh?

vagrant tree
#

thank you!

cursive dagger
#

hey saya, you clicked on the wrong channel dw 😄

sinful lotus
#

oops ty

vagrant tree
#

is it possible to redirect a unknown command to a default command? im using python and i currently only am able to do something like this: ```py
@bot.event
async def on_command_error(ctx, error):
if isinstance(error, CommandNotFound):
await ctx.send('Invalid command. For a list of valid commands, type ' + bot.command_prefix + 'help.')
else:
raise error

lilac wharf
#

You don't want an unknown command since it'll be declined instantly and people don't really want it for something which would be like:
!ping -> bot1: 10ms -> bot2: Unknown command.
And people get annoyed at the bot.

spare goblet
#

It won't be declined for having unknown command errors, only muted.

#

You can, but I don't suggest it cuz it's hella annoying lol

#

(and obviously we will mute your bot)

lilac wharf
#

oh my bad, sorry ^-^

vagrant tree
#

im kinda looking to default an unknown command to an existing command which does do something as in all likelihood that is what the user meant

finite bough
#

how do u even send a image file without the download file option

quartz kindle
#

best practice is for unknown commands to simply be ignored

#

either use the image url, or download it into memory instead of into a file

finite bough
#

how about

#
 
	channel.send(`Welcome to the server, ${member}!`, attachment);
});
#

I tried to send to as a individual file instead of an attachment

quartz kindle
#

What is that?

#

Youre trying to send 2 images?

tight plinth
#

Erm

finite bough
#

1

tight plinth
#

Is you copy paste canvas example code from djs guide it should work

quartz kindle
#

Why are you using that asset link?

finite bough
#

that's how to save images on glitch

#

lmao

#

apprantely

#

I made a directory for it

#

assets

quartz kindle
#

But...

finite bough
#

and inserted the image there

#

using wget

quartz kindle
#

Youre sending the canvas image, not that file

#

Which one do you want to send?

finite bough
#

image

#

I can send the full code if it helps

quartz kindle
#

Im just confused because you have 2 images there

#

The canvas image and the image in assets

#

Also, you can rename images you download

#

They dont need ?v=4884839595

finite bough
#

it sends the canvas image as a file

quartz kindle
#

Or whatever

finite bough
#

like

#

and if u wonder, yes its the canvas edited image

tight plinth
quartz kindle
#

The second argument of messageAttachment is the file name

#

That means

summer sedge
#

Read that

quartz kindle
#

Its a name you give to the file before sending to discord

#

Not the file name on your bot

#

Change it to something normal

finite bough
#

oh

#

oki

quartz kindle
#

ie "image.jpg"

#

The preview is broken probably because of the long and weird filename

finite bough
#

oh oki

#

tyy

tight plinth
#

How to make a bot self deaf? I cant find anything with google

#

Discordjs v12

summer torrent
tight plinth
#

il, I just can't use it without crashing my bot

amber fractal
#

Is there any reason why you would need to?

regal saddle
#

my mute command for v12 js is still broke 😦

earnest phoenix
#

        require('child_process').exec("node bot.js", function() {
            bot.destroy();
            process.exit(1);
        });
        const embed2 = new Discord.RichEmbed()
            .setTitle('Done!')
            .setDescription(`I'm back!`)
            .setColor(0x00ff00)
            
        m.edit(embed2)
    })
}``` with this after i run the command the bot starts a new instance for example ping command it runs it twice help i beg
tight plinth
#

        __**require('child_process').exec("node bot.js", function() {
            bot.destroy();
            process.exit(1);
        });**__
        const embed2 = new Discord.RichEmbed()
            .setTitle('Done!')
            .setDescription(`I'm back!`)
            .setColor(0x00ff00)
            
        m.edit(embed2)
    })
}``` with this after i run the command the bot starts a new instance for example ping command it runs it twice help i beg

@earnest phoenix

#

Well....

#

If you destroy client...

earnest phoenix
#

yah with and without it the same problem

tight plinth
#

well, wait more

crimson vapor
#

That is normal

#

You need patience

earnest phoenix
#

lol its right there in the picture

#

please be patient us humans take time to verify bots

cold lion
#

xd

earnest phoenix
#

yh so wait lol there is alot of bots they have to deal with

blissful scaffold
#

Waiting for 2 weeks
@cold lion you added your bot 2 DAYS AGO

earnest phoenix
#

lol

#

we have a big liar here

crimson vapor
#

lmfao complaints 2 days in

pale vessel
#

d.js 12 is pissing me off

#

why do i have to add .cache to everything

mossy vine
#

downgrade to 11

#

ez

wooden lance
#

i haven't switched for that one reason

#

i cant be assed going through all command files and adding cache

pale vessel
#

@mossy vine i'll need to upgrade it soon anyway

mossy vine
#

why

limber hawk
#

@cold lion 👀

earnest phoenix
#

i cant be assed going through all command files and adding cache
if you used a proper IDE or even a text editor you could write regex to do it for you lol

cold lion
#

eHeHeHE

limber hawk
#

2?

pale vessel
#

because old things will not work over time

#

unless i'm wrong then i might consider downgrading

vagrant tree
#

does anyone host their bot on glitch using python?

#

trying to figure out how to keep it running - it keeps timing out after some time

grim aspen
#

i think glitch only does js

earnest phoenix
#

No

#

You can use py

#

You can run py on glitch

#

This is really good

vagrant tree
#

how do you keep it running?

earnest phoenix
#

With the package.json

grim aspen
#

pm2 or uptime robot

earnest phoenix
#

This work

#

Oof pm2 isn't for py

#

And yeah you can use uptimer bot if you use express for a response :/

grim aspen
#

pm2 isn't for py

earnest phoenix
#

Oh

#

Sorry :)

vagrant tree
#

is it necessary to run a flask?

restive furnace
#

no if you have vps.

earnest phoenix
pale vessel
solemn quartz
#

Guys can someone give me a Giveaway Cmd?

#

I have Visual Studio Code, Node.js , Discord.js

quartz kindle
#

commands are not given, they are coded

pale vessel
#

wise words from the one and only tim

blissful scaffold
#

commands are not given, they are bought

summer torrent
#

Guys can someone give me a Giveaway Cmd?
@solemn quartz code it

finite bough
#

imagine specifying ur editor while asking for a code

earnest phoenix
#

hey he at least specified that he's using djs

blissful scaffold
#

@finite bough at least he didn't say notepad

earnest phoenix
#

Are you saying notepad is bad???

blissful scaffold
#

There might be better solutions

earnest phoenix
#

pssh

blissful scaffold
#

But I'm no JS developer, so I won't be surprised if notepad is the best for JS 😛

earnest phoenix
#

tbf you can code in notepad it's just not advised FLooshed

solemn quartz
#

.-.

blissful scaffold
#

I know, when we learned Java during my study we had to use notepad during the first lessons

#

No build in error checking means you need to pay a lot more attention to your code

quartz kindle
#

notepad is a good introduction to prove that code can be coded anywhere

solemn quartz
#

I think im just gonna do it in a month

#

or something

earnest phoenix
#

My first ever program i wrote in fucking batch was coded on notepad

quartz kindle
#

same

blissful scaffold
#

I still use notepad for small batch files

quartz kindle
#

same

blissful scaffold
#

notepad++ that is

quartz kindle
#

i use notepad++ for html files lol

#

or for stuff i just want to take a quick look at

blissful scaffold
#

same, if I want to check one file without starting the entire IDE then notepad++ is a lot quicker

earnest phoenix
#

As we dont have vs code or anything at our schools i'm forced to use notepad++ for school projects

#

I hate it.

#

I absolutely hate it.

#

npp isn't the worst

#

It is pretty bad tho

restive furnace
#

its better than notepad

earnest phoenix
#

Well yes

blissful scaffold
#

at least npp has colored text, basic notepad would be worse

quartz kindle
#

npp is pretty damn good tho, its fast af, supports a shit ton of plugins and is themeable

earnest phoenix
#

wait it supports plugins

blissful scaffold
#

I think almost every developer uses npp

#

yes

earnest phoenix
#

Bruh

ocean frigate
#

wait it supports plugins
@earnest phoenix yes

earnest phoenix
#

almost every dev uses npp

#

wut

#

kind of doubt that peepoWeird

finite bough
#

lmO

earnest phoenix
#

at least used

#

yeah used is a better term

blissful scaffold
#

im not saying they use it for normal programming, but they have it installed and might use it sometimes

finite bough
#

vsc has a more programming friendly environment

earnest phoenix
#

I use it only when i dont have anything else so

#

I don't have it installed nor do I use it anymore EZ

#

ye

quartz kindle
#

vsc is a truck, while npp is a bike

earnest phoenix
#

npp is a turtle and vsc is a plane

#

visual studio is an orbital space laser in that case

blissful scaffold
#

you don't want to start a full IDE like vsc when you quickly want to check a single file

ocean frigate
#

code editors/ide wars?

earnest phoenix
#

Yes

#

i dont think vsc is a full ide tho

blissful scaffold
#

they both have their own use cases

restive furnace
#
const client = new Discord.Client();

client.on("ready", () => {
  client.guilds.forEach(g => {
    g.leave();
    console.log("left "+g.name);
  })
})``` why this doesnt work? it says client.guilds.forEach isnt function
earnest phoenix
#

First off why tf do you want to leave each guild on startup and 2. i dont see a problem here

restive furnace
#
  1. cause its on 3 guilds and i am not there and i dont want to anyone test my test bot 2. ok, me neither.
blissful scaffold
#

I heard with djs 12 you need to add .cache everywhere?

earnest phoenix
#

you can try a for loop

restive furnace
#

yep it works.

#

ty @blissful scaffold

earnest phoenix
#

v12 made a lot of odd decisions ngl

#

that .cache thing is gonna annoy me so hard

quartz kindle
#

its not odd, it makes a lot of sense

earnest phoenix
#

Not wise words from tim this time

quartz kindle
#

not my fault if you cant understand them :^)

earnest phoenix
#

Tim out here speaking the language of the gods

#

Anyways ima make a discord wrapper bc im bored

#

tbf it's kind of fun

#

But the websocket connection is a pain

restive furnace
#

i've used master mostly but now switched to stable cause 12 is now stable

quartz kindle
#

so you basically didnt change a thing

grizzled raven
#

i used to eat strawberries with 40 seeds but now i only eat them with 39 because its more stable

finite bough
#

so

#

vsc is a truck

#

npp is a bike

#

and tim is the guy who goes to the hospital after getting ran over by both of them

#

:^)

earnest phoenix
#

What

hollow saddle
#

How much should I charge to host a bot for someone?

finite bough
#

@hollow saddle depends

modest maple
#

How much does it cost you to run :P

finite bough
#

what the guy wants

#

and how much it will cost u

hollow saddle
#

It’ll probably cost me like $5-10 a month

#

So like $10?

finite bough
#

nah

modest maple
#

A cheap vps is like $3

finite bough
#

what does he or she wants in the bot

modest maple
#

If it's just a private bot it won't require any real reasources

hollow saddle
#

Music, moderation, custom features

finite bough
#

around 13$ a month sounds fair

modest maple
#

Are you making it or has it already been built

finite bough
#

ilike

#

3$ + the vpn cost

modest maple
#

Das is le question

summer sedge
#

I pay 10 euro a month for proton vpn plus

hollow saddle
#

I’ve already made it, it’s my code but he wants his own process and asked me to host it

finite bough
modest maple
#

Galaxy gate iirc do a VPS at $3 / month

summer sedge
#

... I am a little bit lost, my apologies

modest maple
#

Depending on how effecient you've made your bot

hollow saddle
#

It’s relatively efficient

#

I moreso want to change him for using my code

#

Because yeah hosting would be pretty cheap

modest maple
#

Charge like $20 for a one off or somthing

hollow saddle
#

Ah alright

#

Seems fair

mystic violet
#

'java' is not recognized as an internal or external command,
operable program or batch file.

#

I downloaded Java SE 13.0.2

#

and added the bin to path

#

what else do I need to do??

#

nvm

#

I got it to work

#

lmao

#

restart cmd

golden condor
#

Can I have some help with setting up my SQL on discordjs

true ravine
golden condor
#

What if I just wanna use it for server settings?

true ravine
#

The principles are all the same

#

I used that tutorial but I have nothing to do with XP

#

Also, w3schools is a useful source for MySQL-specific terms

golden condor
#

I wanna use mysql

finite bough
#

then the vid

golden condor
#

Well, with my hosting I have a free MySQL account

#

And it won't allow me to connect to it

true ravine
#

The video walks you through the entire setup

finite bough
#

sqlite 3 is more efficient in some ways

#

but personal opinions

true ravine
#

I've had no issues using MySQL so far

finite bough
#

personal preference

golden condor
#

@true ravine I get this error

Db failed to connect Ouput:connect ETIMEDOUT

/rbd/pnpm-volume/0f5820b6-fa0f-4e8f-ba68-8ab021a8e3bf/node_modules/.registry.npmjs.org/mysql/2.18.1/node_modules/mysql/lib/Connection.js:74

    this._socket = (this.config.socketPath)

                                ^

TypeError: Cannot read property 'socketPath' of undefined

    at Timeout.connect [as _onTimeout] (/rbd/pnpm-volume/0f5820b6-fa0f-4e8f-ba68-8ab021a8e3bf/node_modules/.registry.npmjs.org/mysql/2.18.1/node_modules/mysql/lib/Connection.js:74:33)

    at ontimeout (timers.js:436:11)

    at tryOnTimeout (timers.js:300:5)

    at listOnTimeout (timers.js:263:5)

    at Timer.processTimers (timers.js:223:10)```
true ravine
#

What code have you got so far?

golden condor
#
const mysql = require('mysql');
const con = mysql.createConnection({
    host: 'my host',
    port: '',
    database: 'the name',
    user: 'user name',
    password: 'the pasword'
});

con.connect(function (err) {
    if (err) {
        console.log(`Db failed to connect Ouput:${err.message}`);
        setTimeout(con.connect, 2000);
    }
});

con.on('error', (err) => {
    if (err.code === 'PROTOCOL_CONNECTION_LOST') {
        console.log('DB disconnected attempting reconnection')
        con.connect((err) => {
            if (err) throw err;
            console.log('DB reconnected!')
        });
    } else {
        throw err;
    }
})
con.on('connect', () => {
    console.log(`Connected!`)
})

module.exports = {
    dbConnect: () => {
        return con
    }
}```
true ravine
#

I assume you have the connection correctly filled in on your real code

golden condor
#

Yes

true ravine
#

Cool

golden condor
#

Idk why I get errors

true ravine
#

Could you show what you entered for the connection apart from the password

golden condor
#

ok

slate oyster
#

That's alot more than I expected

#

Oof screenshotted badly

#

73 files though

#

5.7 Megabytes between all of those files

restive furnace
#

so where u need help at?

blissful scaffold
#

I hope those 5.7MB is not just code

slate oyster
#

imports too

#

Also includes the folder size
and any quirks about how the fs manages the disk

true ravine
#

I'm only up to 2.6mb rip

slate oyster
#

I know filesystems have some quircks though

#

like they have blocks

#

The size of a file is often larger than the size of it's contents

true ravine
#

Yeah that's true

#

How would I go about sending data to a website to act as a monitoring/stats site?

#

I'm using glitch to test my idea (ik glitch is trash, just don't want to invest anything yet) so the data I want to send isn't stored in the same place as the website

crimson vapor
#

Why not do the opposite and just pull from the storage at the website

#

If that makes any sense

#

I’m not good at explaining

true ravine
#

If that's a cooler way of doing it then that works too

#

How would I go about that? (just vaguely)

crimson vapor
#

I’m not sure tbh

true ravine
#

Fair enough

#

Thanks anyway

slate oyster
#

What if you just maintain a constant WebSocket connection?
And send events that way

#

Or you could make a request to your website

#

Like POST /newdata.html

true ravine
#

I'm new to this kinda stuff so I'll research websockets and see how far I get

#

Thanks for the suggestion

slate oyster
#

k

#

Your welcome

digital ibex
#

How would I make a user resolver in eris?

#

Does anyone know

lyric mountain
#

how do I use hyperlink markdown in embeds?

#

anyone knows how?

#

ah, nvm, just found out how

earnest phoenix
#

do webhooks work with http:// links

#

because it's not working for me rn

#
  bot.channels.get("685189040470753301").send("Webhook activated.")
});
  dbl.webhook.on('vote', vote => {

    bot.channels.get("685189040470753301").send(`User with ID ${vote.user} just voted!`)
  });```
honest perch
#

how quickly can a bot edit a message for it to not abuse discord api

amber fractal
modest maple
#

@earnest phoenix what is the actual link

earnest phoenix
#

const dbl = new dbl1('my token was here', { webhookPort: 5000, webhookAuth: 'my auth was also here' });

modest maple
earnest phoenix
#

oh

#

just tested

#

didn't work

modest maple
#

is the url http or https

earnest phoenix
#

http

modest maple
#

then dont have the s at the https

earnest phoenix
#

alright

#

doesn't work still

#

no console output either

modest maple
#

new dbl1( is that supposed to be dbl1

earnest phoenix
#

yeah

#

it works because my bot's game status includes how many votes it has

#

and it's uploading the servercount just fien

modest maple
#

posting servercount and runing the webhook server are very diffrent things

#

whats ur current code

earnest phoenix
#

?

tight plinth
#

Discordjs version? (v11 I think)

sweet spade
copper cradle
#

that won't work

#

cuz glitch big gay

sweet spade
#

-_-
Can someone help me ???

earnest phoenix
#

ftr, if you copy and paste your code in code blocks its a lot easier to read

sweet spade
#

hmm I cant bc my idiot phone cant copy at all (note 2 oliypls )

digital ibex
#

can someone help me make a user resolver (eris)

finite bough
#

@sweet spade do u have a file inside another file?

sweet spade
#

yea

earnest phoenix
#

i figured out what was going on

#

apparently on dbl you have to save the details before the test button works

#

;/

modest maple
#

lmao

sweet spade
digital ibex
#

does anyone here use eris lol?

sweet spade
earnest phoenix
#

??

#

oh i wasn't talking about your issue

#

learn to debug your code

#

i was talking about mine

#

go through the code one step at a time and see where it breaks

sweet spade
#

.-. ok

vernal yoke
#

@earnest phoenix is a hidden mastermind coder giving actual good advices GWbruhSquidWoke

earnest phoenix
#

i dont know what you're being weirded out about because debugging is a normal part of developing which so many people here avoid for no apparent reason

#

honestly yes tuty

#

xD

#

we aren't here to find the issue among hundreds of lines of code for you

#

we're here to help you with the issue

vernal yoke
earnest phoenix
#

i mean when all someone does it plop it in glitch and codes on mobile can they even debug?

#

if you take a few hits of cocaine maybe

vernal yoke
#

cry, is glitch thing okay to use? i mean better than heroku?

earnest phoenix
#

neither is okay

modest maple
#

both are equally not the ebst

#

best*

vernal yoke
#

in terms of small apps

modest maple
#

both are equally meh

earnest phoenix
#

they simply aren't meant for bot hosting and instead are meant to be used for websites

modest maple
#

pretty sure the specs u get are nearly identical

vernal yoke
#

cry, i said small apps, who hosts bots on heroku GWbruhSquidWoke

earnest phoenix
#

oh

#

depends on what the app is

modest maple
#

quite a few people host on heroku

earnest phoenix
#

e.g a small webserver will run fine

vernal yoke
#

i mean can you have private projects in glitch? all i see is people posting their dbl tokens public lel

earnest phoenix
#

no what yu Actually do

#

is get a minecraft server host

true ravine
#

For bots a free hosting service like AWS or google cloud platform will serve you much better than glitch

earnest phoenix
#

and make a mod to run code on it

true ravine
#

True

vernal yoke
#

"free" my ass

#

12 months then go pay

earnest phoenix
#

gcp has a freee teir, genius

#

*free tier

#

so does aws

#

and gcp's free tier is pretty damn good

true ravine
#

I mean you don't have to pay after 12 months if you don't want to

earnest phoenix
#

technically they are free if you exploit the fact that neither of those two check for duplicate credit cards

#

Use google cloud free trial

#

not helping

#

and cry, ye

vernal yoke
#

and gcp's free tier is pretty damn good

earnest phoenix
#

but i mean thats a lotta work

vernal yoke
#

dansgame

earnest phoenix
#

it is

#

i ran a bedrock mc server on it when my credits expired. not super great, but not terrrible

#

i won't even talk about how many times i exploited gcp's 12 month trial

#

xD

#

see. i use those credits in 6 months

#

same

#

4-6 months then switch to another account

#

xD

#

and besides, you can always upgrade aws and gcp, pretty easily

#

no moving from heroku to a paid host]

#

i am not encouraging this behaviour by any means since it's probably illegal but whatever floats your boat

#

having to transfer everything

#

and xD

vernal yoke
#

i mean i host a simple api on heroku, works fine GWchadThinkeyes

earnest phoenix
#

simple

vernal yoke
#

i said simple apps, above.

earnest phoenix
#

true

#

but again, theres no reason to not use gcp or aws and upgrade later

#

yeah like i said small webservers run fine

vernal yoke
#

mister dan, for changing the api to host it on gcp, is it actually 24/7 on or do i have to ping the damn thing like heroku to wake it up

earnest phoenix
#

24/7

#

you get your own vps

vernal yoke
true ravine
#

Any real webserver is 24/7

earnest phoenix
#

i did say it was better

vernal yoke
earnest phoenix
#

i feel like this is worthy nothing; whichever service claims that their products are free - you become the product

vernal yoke
#

^ true that

earnest phoenix
#

i mean

#

tho

#

cough google

#

gcloud is just putting that out for free cuz they make enough money from paid

#

i mean a lot of apps use them; discord, snap

#

google is really interested in your data

#

mmmm

#

eh, doubt they can/would get at shit on a vps.

vernal yoke
#

^

#

but the amount of lazyness i have right now, still keeping heroku ffs GWrjkKappaLUL

digital ibex
#

so

#

can someone please help me set up a user resolver, eris

earnest phoenix
#

does eris have a discord

#

cuz you've asked that multiple times, and no one has been able to help or has responded and you might have better luck finding someone in the libs discord if it exists @digital ibex

digital ibex
#

Okay

earnest phoenix
#

Oof

#

what

#

huh

#

can you not randomly ping

#

@earnest phoenix

#

i cant help if 1) idk what you're wanting
2) idk what you're wanting

#

o..k?

#

you're here now?

#

copy you id

#

o

#

you must get you correct id

#

ye

#

but @earnest phoenix what exactly is going on?

#

cuz you're here now

#

so you should be able to submirt

#

try from pc or rdp

#

ahh

#

also laptop?

#

I have a question. In css, is it possible to create some kind of tail? For example: A object slides along a track. I want annother object to follow that object just with a little bit of delay. Is this possible in css and if yes, how?

amber fractal
#

only because idk how to explain it myself

earnest phoenix
#

too

#

😄

neat ingot
#

what would be the best way to check if a given string is/seems like a valid discord id?

earnest phoenix
#

fetchUser().catch

#

i think

neat ingot
#

like lets say a user can input a string of random numbers, how do i differentiate that from an actual discord id?

earnest phoenix
#

pls no bulli

mossy vine
#

but just because its valid doesnt mean its an id that exists

neat ingot
#

ok i think ill be able to get enough info from just reading that

#

yea idm if its not real

#

just has to be within the given parameters

#

and with discord max id length of 19, with min 14, thats enoguh

#

i couldnt find info on min/max anywhere 😄

#

that seems to actually lookup if its valid though

#

which is a little more than i need 🙂

#

but ty for link, was helpful 🙂

#

/^[0-9]{14,19}$/ ez

vestal star
#

I get this error whenever dbl api starts running:

(node:3870) UnhandledPromiseRejectionWarning: Error: 400 Bad Request
    at IncomingMessage.<anonymous> (/rbd/pnpm-volume/6323fd81-f605-40d1-9545-4304110da25b/node_modules/.registry.npmjs.org/dblapi.js/2.3.1/node_modules/dblapi.js/src/index.js:118:25)
neat ingot
#

same line some dude had an issue with the other day: 118

#

sec

#

probly cant connect with the given credentials

vestal star
#

sooo... wrong token?

neat ingot
#

your getting a 400 error

#

or id or such yea

vestal star
#

um

#

so what should i do... is this a discord.js 12 issue?

neat ingot
#

dont think so, sure dudes in here been using v12

#

i'd maybe reset your token, and make sure its correct in the botzz code

vestal star
#

Okkay

neat ingot
#

if that failz ~ 🤷‍♂️

vestal star
#

same error

smoky spire
#

It's a different error if the token is bad

neat ingot
#

and your setting your token as a string right? not just a line of text?

#

oh? my bad 😄

smoky spire
#

It's related to the dbl module not djs

vestal star
#

Literally my dbljs code:

const DBL = require("dblapi.js");
const dbl = new DBL(process.env.DBLAPI, client);
#

Also, if token is wrong, I would get a 401

quartz kindle
#

dblapi.js is not compatible with v12 yet

vestal star
#

awww great -_-

#

just spent 2 hours updating

quartz kindle
#

you can workaround the issue by removing client from the arguments

#

and using .postStats() instead

vestal star
#

oh ok, ill just fix dbljs code

quartz kindle
#

the problem only affects dblapi.js' auto posting feature, everything else is fine

vestal star
#

Wtf, everything is fixed, but 3 ppl need to approve

mossy vine
#

yeah

#

approve it

quartz kindle
#

its already been approved by a bunch of people lol

mossy vine
#

has it

vestal star
#

@gritty dagger pls approve

mossy vine
#

can someone link the pr

vestal star
#

3 ppl with write access need to approve not just anyone

quartz kindle
#

the problem is not approval

#

only tonkku has write access

#

he just needs to merge and release

vestal star
#

heck

#

so, we have an update, but everyone is too scared to fix

#

🤦‍♀️

mossy vine
#

isnt it untested

amber fractal
#

Well d.js v12 just went stable how long ago

#

yesterday?

#

2 days ago>?

vestal star
mossy vine
#

imagine making an issue instead of commenting on the pr

vestal star
#

🙂

amber fractal
#

why not just clone tonkku's clone?

#

wait

#

wrong link

#

Wait

#

it's the same repo

#

different branch

#

lol

copper cradle
#

quick

#

someome make a fork and fix it

#

then you can share the repo

#

I'd do it, but I'm not home

vestal star
#

there is already a fix

amber fractal
#

or you could clone the repo and switch the working branch then require it

vestal star
#

anyway

earnest phoenix
#

approve bot will take 2 week ?

vestal star
#

wait nononono

earnest phoenix
#

new bot ?

copper cradle
#

wot

amber fractal
earnest phoenix
#

index so small

#

eh like nothing in index.js

copper cradle
#

ah yes

#

git checkout

quartz kindle
#

i mean

#

just use postStats

peak venture
#

how would i read this in message.guild.members
Collection [Map] {

'282961872758505473' => GuildMember {

quartz kindle
#

at least until the update is released

peak venture
#

if i want to check the member specific..

quartz kindle
#

what do you want to read?

peak venture
#

in the end i wish to check which voice channel he is in

quartz kindle
#

do you have the user's id?

peak venture
#

ahm

#

its either via 2 ways xD

#

So.. i'm working on a webpage here where the user logs in and yes, then i have a user id

quartz kindle
#

message.guild.members.get(id)

#

or if you're using v12: message.guild.members.cache.get(id)

peak venture
#

but i want to check which voice channel he is in

quartz kindle
#

get the member, then check his voice channel

peak venture
#

and on discord; i want to check his id based on the message he sent

#

?

#

would that make sence?

quartz kindle
#

if he sent the message, you can use message.member

peak venture
#

would that just be message.member?

quartz kindle
#

to get the member of the one who sent the message, yes

#

message.member is the same as message.author, but gives you a member instead of a user

#

then you can use member.voiceChannel in v11

copper cradle
#

👏 learn 👏 fucking 👏 oop 👏

vestal star
#

Temp fix for discord.js 12 dblapi.js
Also client.dbl is just new DBL(yourTokenHere)

client.dbl.postStats(client.guilds.cache.size)
setInterval(() => {
  client.dbl.postStats(client.guilds.cache.size)
}, 1000000);

Put this in your onReady event

regal saddle
#

TypeError: fs.readFileSnyc is not a function

#

wtf?

quartz kindle
#

read that again

#

slowly

summer torrent
#

^

amber fractal
#

when you snychronously read files

quartz kindle
#

sounds like he wants to sneak on his files

crimson vapor
#

I have learned a bit about classes and stuffs today

#

but I am struggling to make a command handler

#

how would one go about that?

quartz kindle
#

depends how you want to structure it

#

do you want to make all your commands into classes?

crimson vapor
#

I think

#

I would like to learn more about this so I am attempting to create one

quartz kindle
#

well, you could create a class

#

and then a command loader that loads your command files, and uses the class on them

#

like

grizzled raven
#

seeing he's asking how to make one, id let him start with a simple collection array or object

crimson vapor
#

no I know how to make a command handler

#

I would like to learn classes

grizzled raven
#

oh wait

#

sorry

#

i zoned out

crimson vapor
#

all good

grizzled raven
#

lol i was thinking of someone else

crimson vapor
#

oh lol

grizzled raven
#

oh wait no i wasnt

#

i just zoned out thats all

crimson vapor
#

oh

quartz kindle
#
class Command {
  constructor(name,file) {
    this.name = name;
    this.file = file;
    this.function = require(this.file);
  }
  run(args) {
    return this.function(args);
  }
}

client.commands = new Map();
fs.readdirSync("./commands").forEach(file => {
  let name = file.split(".")[0];
  let command = new Command(name,"./commands/"+file);
  client.commands.set(name,command);
})```
crimson vapor
#

hmm

#

smart

#

but still basic which is good for learning

copper cradle
#

yeah

crimson vapor
#

I will come back when I figure this out and configure it to my liking

#

thanks for helping me understand Tim

#

it is appreciated

quartz kindle
#

👍

crimson vapor
#

so, am I correct saying that all I would need to do would be search the commands for a command with a specific name then run the function of the command?

white anvil
#

yes

#

I use a Map for commands, which allows me to do .get(command name)

#

and each command here has its own execute function that can be called if the invocation message is one that should call that command

crimson vapor
#

hmm smart

#

I use a collection on my main bot, then I find a command with the name and run the function

#

but I want this to be a bit more modular

white anvil
#

Yes

#

well yeah

#

you can have whatever properties you like on the commands

quartz kindle
#

it also makes it easy to check if a message contains a valid command: ```js
let command = message.content.split(" ")[0].slice(prefix.length);
if(client.commands.has(command)) {
client.commands.get(command).run()
}

white anvil
#

I have quite a lot

#

who can use it, whether it can be disabled, the cooldown on it, etc etc

#

my client uses class inheritance for each individual command, but yours doesn’t have to

#

each command can just be instance of a Command class

#

which is exported and loaded in your client

unkempt ocean
#

can you guys please tell me what is this xd

#

TypeError: Cannot convert "null" to int

white anvil
#

well

unkempt ocean
#

it's about opusscript

white anvil
#

you have a value null and you’re trying to convert it to an integer

#

which can’t happen

quartz kindle
#

trying to do math with null

unkempt ocean
#

I checked it

#

nothing is null

white anvil
#

well something must be

#

otherwise this error wouldn’t be thrown

grizzled raven
#

if you

#

say if you installed djs, then you went into the source code and edited it, will it at some point reset back to normal?

neat ingot
#

having never worked with shards before, these are probably super dumb questions... are the shards numbered? or do they have some kind of unique id each? or both? can i name them? do they already have a name somehow?

white anvil
#

no

#

I mean

#

unless you updated it then maybe

#

but I would not recommend doing his whatsoever

#

@neat ingot each shard is numbered starting from 0

neat ingot
#

how else would a push request be made though? @white anvil 😛

#

ahh ok

#

regular numbers

white anvil
#

I’m assuming that they mean that you clone it and use it, and then edit the source in node modules

#

instead of forking it

#

which is what you should do

quartz kindle
#

shards have IDs

#

which are like array indexes

#

if you request 2 shards, you will get shard 0 and shard 1

grizzled raven
#

so editing source code isnt a good idea?

neat ingot
#

mmk, ty 🙂

white anvil
#

you can edit it if you fork it on git

grizzled raven
#

i mean

white anvil
#

don’t install it with npm and then edit it

#

this could just cause problems

neat ingot
#

is it possible to name them? or define which guilds go to which shards?

quartz kindle
#

no

crimson vapor
#

does this error mean that I didnt define something correctly? TypeError: Class extends value undefined is not a constructor or null

white anvil
#

fork it, edit it and then clone your fork

quartz kindle
#

guilds are sorted into shards automatically by their guild ids

#

discord uses a specific formula for it

neat ingot
#

ahh ok

white anvil
#

@crimson vapor what’s throwing this

quartz kindle
#

which you can use to know which shard a guild id goes to

crimson vapor
#

extending a class

neat ingot
#

ive seen a bot that had premium servers limited to 100 guilds per shard

#

which intreagued me

white anvil
#

can you paste the code

summer torrent
white anvil
#

my initial guess is that it’s extending a class that doesn’t exist

neat ingot
#

could be a custom instance of their bnot with unique bot id tho

unique nimbus
#

124.385

quartz kindle
#

there is a major network outage going on atm

crimson vapor
#

sure, should I paste the base and the extension?

quartz kindle
#

its affecting a big part of the east coast

white anvil
#

uhh just the few lines around where the error is being thrown

#

not the entire thing

crimson vapor
#
const { Command } = require(`../Base/Command`);
class test extends Command {```
#

lemme check the require

white anvil
#

yeah Command will be undefined

quartz kindle
#

how are you exporting the class?

crimson vapor
#

module.exports

quartz kindle
#

module.exports what

crimson vapor
#

the require is pointing to a file that exists

white anvil
#

module.exports = Command?

crimson vapor
#

yes

white anvil
#

ok it’s just command then

#

not { command }

crimson vapor
#

gotcha

neat ingot
#

make it equal to your command class name

quartz kindle
#

because doing { Command } = require() implies that you're doing module.exports = { Command }

crimson vapor
#

I see now

#

I should have seen that that was the issue

quartz kindle
#

btw you can also do module.exports = class {

#

or module.exports = class Command {

crimson vapor
#

oh

white anvil
#

you don’t need to do it that way

quartz kindle
#

then you can name it anything you want when you require it

neat ingot
#

yea isnt that whats going on?

module.exports = classname;```
crimson vapor
#

thanks for helping

quartz kindle
#

@grizzled raven if you can, extend it or overwrite a part of it. otherwise, if you must absolutely modify the source, you'd better create your own fork

crimson vapor
#

oh btw, this is my normal command handler, my friend wrote it

function loadCommand(client, directory, module) {
    fs.readdir(`${directory}/${module}`, (error, files) => {
        // Written by 酒。#0001
        if (error) return console.log(`Load Commands: ${error}`);
        let jsFile = files.filter(f => f.endsWith('.js'));
        let jsonFile = files.filter(f => f.endsWith('.json'));
        if (jsFile.length <= 0) return console.log(`Load Commands: Couldn't find any commands in the module: ${module}`.red);
        console.log(colors.blue(`Load Commands: `) + colors.yellow(`loaded ${directory}/${module}!`));

        jsFile.forEach((f, i) => {
            let fileCommand = require(`${directory}/${module}/${f}`);
            client.commands.set(fileCommand.name, fileCommand);
        });
    });
}```
#

he is more of a give code than teach person

white anvil
#

this code is useless unless you can understand it

#

and that console colour dependency is bugging me

quartz kindle
#

well, if he wants fancy visuals...

crimson vapor
#

no, I do understand it

white anvil
#

it’s so unnecessary lol

crimson vapor
#

no, I have edited it

white anvil
#

that’s good

quartz kindle
#

there is one problem with this loader

#

is that is async

#

meaning you need you make your bot wait for it to load all commands

#

before attempting to login and use them