#development

1 messages ยท Page 686 of 1

earnest phoenix
#

im getting confused by your methods :/

#

i dont use mongo

valid frigate
#

ah ok

earnest phoenix
#

i use quick.db

valid frigate
#

similar concept across all databases

wanton nova
valid frigate
#

if you do need any additional help Google is also a thing

late hill
#

On the site

#

In the edit tab of your bot

wanton nova
#

oh

valid frigate
#

this might be a better question to ask in #topgg-api mmulu

wanton nova
#

thanks

#

oh i forgot that exists ๐Ÿ˜”

#

sorry

earnest phoenix
#

still confused ๐Ÿ˜‚

#

can u show me an example

late hill
#

uhh

#

But does that rly help you

#

On each update I get the current time and compare it with the previously saved time

#

(lastupdate)

earnest phoenix
#

nothing shows up on console :/

late hill
#

what

#

even

#

what code

#

are you using now

earnest phoenix
#

my original one

#

on index

late hill
#

Well

#

Your previous codeblock sent in this channel

#

Is wrong

earnest phoenix
#

:/

#

so where would i put this

#

index.js or message.js

#

?

late hill
#

You put a timeout in the foreach

#

While you probably meant to put a foreach in an interval

#

index.js is fine

#

Just follow your code in your head

#

You posted

client.users.forEach(user => {
setTimeout(function(){                                      
      db.add(`currency_${user.id}` , 100)
      console.log('GIVEN 100 COINS')
   }, 10000)
});```
#

What does that do

#

For each user you're setting a timeout

#

What's a timeout

#

It means you're waiting x before doing y

#

For each user you're setting a timeout to give them some money

#

Meaning you have hundreds/thousands of timeouts running

#

That will only trigger once

earnest phoenix
#
client.users.forEach(user => {
let timestamp = new Date());
let auto = timestamp-client.lastUpdate / 60000
client.lastUpdate = timestamp
setInterval(function(){                                      
      db.add(`currency_${user.id}` , 100)
      console.log('GIVEN 100 COINS')
   }, 1 * 1000)
    

});
late hill
#

Well

#

The point of our timestamp mechanism is avoiding the loops

#

It's one or another

#

๐Ÿ‘€

#

On top of that

earnest phoenix
#

should i remove

late hill
#

You're still setting an interval for each user

earnest phoenix
#

setInterval

late hill
#

Meaning if more users get added

earnest phoenix
#

and forEach?

late hill
#

Or some leave

#

The intervals will remain the same

earnest phoenix
#

oh

#

so remove setInterval and forEach?

late hill
#

Make a choice as to what you're willing to do first

#

๐Ÿ‘€

earnest phoenix
#
let timestamp = new Date());
let auto = timestamp-client.lastUpdate / 60000
client.lastUpdate = timestamp
      db.add(`currency_${user.id}` , 100)
      console.log('GIVEN 100 COINS')
 
#

now what ๐Ÿ˜‚

#

im a noob

#

:/

late hill
#

If you're using the timestamp method

#

You should have a timestamp saved per user

earnest phoenix
#

hm

late hill
#

So client.lastUpdate doesn't make much sense there

#

idk what your code is like

#

You'd need some place, some action on which you'd want to update their stats

#

That's where you'll put your timestamps code

broken shale
#

I got a feeling that's quick.db

earnest phoenix
#

hm

#

it is

#

quick.db

#
 const request = require('request')
 request('https://discordbots.org/api/bots/BOTIDHERE', async function (error, response, body) {
                 var veri = JSON.parse(body);
      message.channel.send(new Discord.RichEmbed()
                    .setDescription(veri.monthlyPoints)
                    .setColor('#bf1818'))
})
#

Answer; undefined

#

what is the problem

sudden geyser
#

unauthorized?

earnest phoenix
#

So how can I pull this data @sudden geyser

sudden geyser
#

add the authorization header

earnest phoenix
#

how?

#

Can you give an example?

#

@sudden geyser

sudden geyser
earnest phoenix
#

which part should I add? @sudden geyser

copper cradle
#

have you ever done a post req?

earnest phoenix
sudden geyser
#

The docs for request tells how to add headers

wanton nova
#

he didnt put his bot id in though

slender thistle
#

botidhere MegaThonk

barren crest
peak quail
#

how can i edit/replace console.logs
||(example when i m installing somthing like npm i discord.js)||

earnest phoenix
#

you cant

peak quail
#

๐Ÿ˜ฎ

#

:(

earnest phoenix
#

because npm is a cli program like any other

barren crest
#

@peak quail u mean the install msg when installing a pkg?

earnest phoenix
#

Any1 know if you can just send a msg to every guild a bot is in (d.js) ?

slender thistle
#

Why

barren crest
#

yez u can

#

๐Ÿ™‚ dont recommend thow

earnest phoenix
#

Anonymous chatting

hollow saddle
#

Thatโ€™s called api spam bro

barren crest
#

^ ๐Ÿ˜„

earnest phoenix
#

Lol

barren crest
#

that would possibly be the worst anonymous chat ever having to switch between discords ๐Ÿ˜„

inner jewel
#

!anonymouschat discord dot gg slash my server

earnest phoenix
#

Pseudo anonymous ๐Ÿ‘Œ

#

Just thought it be fun to chat through a discord bot with ppl you don't share a server with

barren crest
earnest phoenix
#

For fun

barren crest
#

meh

#

there is a bot soon to come that does that but in a srv ๐Ÿ˜

earnest phoenix
#

You're already making one ?

barren crest
#

i alr have one ๐Ÿ˜„

#

not verified yet ๐Ÿ˜„

#

its FLUFFY

earnest phoenix
#

Didn't you just call the idea "meh" and reccomend against it ?

barren crest
#

yep

#

the cross srv is MEH

#

to much effort to switch between discords to read a msg ๐Ÿ˜„

earnest phoenix
#

What do you mean by switching server ?

barren crest
#

going inbetween 2 discords to read a msg

#

when u could do in 1 srv

#

its not effeciant imagine switching apps on phone to have a conversation ๐Ÿ˜„

#

its not that bad i lied but its still bad ๐Ÿ˜„

earnest phoenix
#

That's not how I imagine it either

earnest phoenix
#

Like the bot would repeat everything said to it from all the servers it's in,

#

Serv 1: msg 1, serv 2: msg 2

barren crest
#

that would be aids

earnest phoenix
#

Bot: msg 1, msg 2

barren crest
#

i mean its a thing but y 2 dif srvs?

#

imagine some kid on one side spamming NAUGHTY words what would the other side do?

#

if they cant ban or mute him

earnest phoenix
#

Idunno, maybe the bot would support multiple " rooms"

barren crest
#

still not a fix

earnest phoenix
#

Of connected servers

barren crest
#

he would switch ๐Ÿ˜„

#

then do again ๐Ÿ˜„

#

but in the same srv they can look at mod log and ban

earnest phoenix
#

Oh I think I understand your idea ish ?

#

Or maybe I got a new idea,

barren crest
#

k

#

hit me

earnest phoenix
#

What if you had a server

#

Only populated by 1 bot

barren crest
#

k

earnest phoenix
#

Ppl can join and read but not write

barren crest
#

w.h.y?

earnest phoenix
#

Everyone has to write through the bot lol

barren crest
#

WHY ๐Ÿ˜„

#

what benefit does that have?

earnest phoenix
#

Like in the dm channel between the user and the bot

barren crest
#

yeah

#

i see were ur goin

#

for half a sec it was like ok avoid making a million channels but they would still have to switch pages

earnest phoenix
#

I'd think it would be an interesting experiment at the very least

barren crest
#

it would

#

it would be ez

earnest phoenix
#

That too

barren crest
#

same thing im doing but thru dms instead of channels

#

but its inconvenient

#

for the user

earnest phoenix
#

The lines of code to interesting ratio is dank

barren crest
#

lol

#

ill dm u a srv u can see the bot in

earnest phoenix
#

Sure

#

Would hopefully help me completely understand your bot idea

barren crest
#

lol

shy rose
#

anyone know /recommend some free localisation management services?

ember atlas
#

like bot hosting?

shy rose
#

no more like localisation management eg i18n translations

brave elm
#

I'm getting "Error: Cannot find module '/app/js/Main.js'
at Function.Module._resolveFilename (module.js:548:15)
at Function.Module._load (module.js:475:25)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/app/bot.js:7:15)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)"

#

On glitch

#

I have installed node.js

#

ANd have a bot.js (my bot from discord bot maker)

#

Can someone help me

#

please

shy rose
#

you have a require Main.js somewhere that leads to a non existent location

brave elm
#

do I need to rename the bot.js to main?

#

will it work then?

hushed quarry
#

without your code, we can't say...

brave elm
#

I can send the code to you in pm's

#

if you want

hushed quarry
#

post the relevant code here

brave elm
#

/*

  • Discord Bot Builder Bot
  • Version 1.2.0
  • Robert Borghese
    */

const Files = require(require('path').join(__dirname, 'js', 'Main.js')).Files;

if(!process.send) {

Files.initStandalone();

} else {

process.on('message', function(content) {
Files.initBotTest(content);
});

}

sage bobcat
#

One message removed from a suspended account.

brave elm
#

That is bot.js

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

brave elm
#

I don't know how to code all of it lmao

sage bobcat
#

One message removed from a suspended account.

brave elm
#

There's nothing on what I need

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

brave elm
#

Okay

#

Can I speak to you tomorrow about it then>

#

?

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

brave elm
#

Oh okay

sage bobcat
#

One message removed from a suspended account.

brave elm
#

Really?

hushed quarry
#

mood

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

earnest phoenix
#

as the error says

brave elm
#

lmao

#

Well, if anyone can help me.

earnest phoenix
#

there's no file named Main.js in /app/js

brave elm
#

That would be great.

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

shy rose
#

the require you have at the top is calling a non existant file

sage bobcat
#

One message removed from a suspended account.

shy rose
#

as said at start
so to fix you need to update the require or make the file

brave elm
#

okay

#

I made a file called app.js

earnest phoenix
#

the code asks for Main.js

brave elm
#

okay]

earnest phoenix
#

please read your own code

#

and your errors

hushed quarry
#

the problem is he used discord bot maker

brave elm
#

Yeah, so I need Main.js

sage bobcat
#

One message removed from a suspended account.

brave elm
#

Yeah

sage bobcat
#

One message removed from a suspended account.

brave elm
#

All I need is it to be on 24/7

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
#

i don't think anyone here offers support with bot makers ๐Ÿคท

brave elm
#

np

earnest phoenix
#

if you have an issue with the bot maker, go complain to the app creator

shy rose
#

discord bot maker specifically

brave elm
#

ye

shy rose
#

every green name is a bot maker

earnest phoenix
#

that's a bot developer ๐Ÿ™ƒ

shy rose
#

who has made a bot

brave elm
#

Okay

earnest phoenix
#

i know, that's why i put the upside down emoji

brave elm
#

Well if someone wants to help me out when I'm on tomorrow and guide me through the basics, only if you want to and have time. Feel free to pm me. I'll respond to it tomorrow if I see you online.

#

All I need it to do is stay online 24/7 and display a status.

#

Thanks

shy rose
#

glitch auto sleeps btw

brave elm
#

I can use another free vps then I guess.

#

Just to keep it online.

earnest phoenix
#

there's no free hosting that'll stay up 24/7 and allow hosting a discord bot

brave elm
#

Okay

earnest phoenix
#

if you want constant uptime, pay for it

brave elm
#

I'll use my pc then lmao

hushed quarry
#

that's what i used to do when i was smaller -- i had an extra PC in my room that i'd keep on 24/7

jagged birch
#

Glitch doesnโ€™t auto sleep if you use uptimerobot

brave elm
#

I have one that is really small and uses no power tbh.

#

19V == 3.42A Rating.

#

So really low.

jagged birch
#

Just google how to configure uptimerobot with glitch

brave elm
#

Yeah

jagged birch
#

It pings your bot every 5 mins to keep it online

brave elm
#

Thanks

#

Anyways

#

I'm off

#

So thanks guys

shy rose
#

might wanna read the glitch docs

brave elm
#

I love the friendly community ๐Ÿ™‚

jagged birch
#

Which is why you use uptimerobot which pings it every 5 minutes. I have a bot that has been online for 5 months on glitch 24:7

shy rose
#

uptime will wake it up but its still being forced sleep and can result in downtime

#

glitches docs say right there any project is forced sleep if its been running 12 hours

#

uptime can wake it back up but its still downtime

jagged birch
#

Well maybe thatโ€™s new because I donโ€™t remember my bot ever sleeping

shy rose
#

been there since day 1

jagged birch
#

:/

shy rose
#

yeah

earnest phoenix
#

no one will allow you to spend their power and machine resources for free 24/7

shy rose
#

if they do then its either a free trial or a scam

earnest phoenix
#

amazon ec2 ๐Ÿ‘€

shy rose
#

that costs

earnest phoenix
#

i mean, aws is one year free trial

#

and even that plan is limited to what you can do

shy rose
#

its also worth noting that uptime isnt always reliable on ping times https://oh-mah.ga/LXzybKzZ.png
thoughout the last period it only got 3 points in a row right

#

if it done all on time then all points would be clustered like that

#

so in terms of monitoring its good
but if you depend on it for uptime like anti sleep then your gonna have potential issues

zealous veldt
#

Google cloud free tier too

shy rose
#

gotta pay for data though

#

you get a f2 micro i think thats its name but yeah data costs

earnest phoenix
#

they're generally overpriced

shy rose
#

azure is the overpriced one lol

earnest phoenix
#

google's 1-2 gb vm machine with a virtual cpu will last you through the entire trial though

#

true that

#

they wasted all of my student credits within a week

shy rose
#

things like vultr are more popular
and a few other gem providers if you can find them

#

you actually get to keep it

earnest phoenix
#

ah

shy rose
#

but its a potato and network costs

hushed quarry
#

what are the specs of the free one

quartz kindle
#

i had no problems running 1500 guilds on it with djs

#

but your mileage may vary

#

now i use it to host my api

unique nimbus
#

Python on its own is retarded as it wants so much ram

brave anvil
#

How would I make a viewer for e621 for my bot?

unique nimbus
#

You can get an api if it's available or use addons to grab the images

brave anvil
#

Hmm

#

Iโ€™m wondering

#

An api?

unique nimbus
#

There might be however idfk

brave anvil
#

Hmm

sick cloud
#

probably best to ask elsewhere though since it's an nsfw website and dbl doesn't allow nsfw

earnest phoenix
#

isn't it fine as long as nsfw is restricted behind nsfw channels

#

i remember when my bot was accepted, it had a notable category of nsfw commands

#

but it didn't list nsfw commands nor allowed the usage of nsfw outside of nsfw channels

amber fractal
#

bots on dbl can have nsfw features, just cant be listed, unless you're dank memer because you drive too much traffic for the rules to apply

earnest phoenix
#

ads ๐Ÿค‘

#

are dbl ads using google's adsense

#

because that's even worse

#

cause trackers and tailored content

amber fractal
#

idk the thing in the top right says adchoices

#

I prefer tailored ads though because then I might find a product I actually like, even though I rarely click ads anyways

inner jewel
#

i dont care what type of ad it is because i'm blocking it anyway mmLol

abstract crow
#

You want to know what the pos does?

#

Every time he imports a group thing, he just says ok let me import this and bam 15 things are imported

#

Every time he adds multiple styles "looks at second monitor" cuts video to after

#

WHY DO YOU PURPOSELY CUT EVERY 3 SECONDS

idle basalt
#

link the video this seems like quality content

abstract crow
#

Aw the poor YT guy got back to me when I mentioned it

#

Now I feel like a dipshit

#

nvm deleted it instead of editing -_-

earnest phoenix
#

Maybe a dumb question, but with discordjs, will client.users.size get a count of all the members the bot is helping?

topaz fjord
#

@abstract crow passport is cool

#

There's a discord passport module

#

@earnest phoenix no

#

it will get the cached users

#

to get all users you need to filter through all guilds and get their member count

earnest phoenix
#

ohhh, that's what I thought was happening, thanks :)

opaque eagle
#

Ooh youโ€™re learning React

#

Good use of ur time

earnest phoenix
#

When getting member count, it currently would count the same member for each time they happen to be in a guild, is there a better way to get member count, where it doesn't end up counting the same member multiple times. Currently I have client.guilds.map(g => g.memberCount).reduce((a, b) => a + b);.

#

you'll have to download all users from your guilds and then you can use client.users.size, with filtering applied

#

it can hang for a while though if the guild has a lot of members

#

that seems like it would be a bit inefficient

#

but it would work

#

its the only way if you want to filter users

#

you need to have a reference to the user if you want to filter them out of other guilds

#

and to have a reference to the user you have to download all members (because it's a collection, if it wasn't you could just use fetchMember)

#

Even though it's a bit inefficient, i'm still gonna use it, thanks for your assistance ๐Ÿ‘

viscid sable
#

Hey, I was wondering if there would be anyway on making and extended audit log bot?

earnest phoenix
#

you can't really make extended audit logs

#

the api doesn't provide enough info for you to extend on anything

viscid sable
#

Oh that sucks.

#

Also how could I devolop bots?

opaque eagle
#

They should update it to discordjs.guide now since AnIdiotsGuide is spoonfeed heaven.

viscid sable
#

Is there anybots that notify me when somone is banned or kicked

opaque eagle
#

Lots, those are called mod logs

#

Search for bots on the website and youโ€™ll find one that does it... most likely, one of the bots you already have in your server might already do it.

#

However, weโ€™re not a bot curation discord, so please refrain from asking such questions from now pls

viscid sable
#

Oh sorry, is there any channels where i can ask them?

opaque eagle
#

Nope.

#

This server primarily serves as a community hangout for programmers who create Discord bots, so such conversations often turn into devs just advertising their own bots.

keen harness
#

Any one help me pls invite mannager is not working

dusky marsh
#

Go to their support server

opaque eagle
#

Has anyone tried out this logDNA thing before? it showed up in the github dev pack list and it seems to do the same thing as sentry

wheat jolt
#

MySQL or Redis?

opaque eagle
#

Redis isn't a database

wheat jolt
#

:/

#

where I said that redis is a database

opaque eagle
#

You're comparing it to a database?

#

Also personally I like KeyDB over Redis. It's a multi-threaded fork of Redis.

hushed berry
#

redis is a db ๐Ÿ‘€

#

its just a completely different type of db from mysql

quartz pollen
#

Does anyone have any automatic bot notifications when the new episode anime is released?

devout chasm
opaque eagle
#

oliy DISCORD BOT LIST, AKA THIS SERVER

weirdsip What We Are
tickYes The Official Discord Server for https://discordbots.org
tickYes A community hangout for programmers who create Discord bots.
tickYes Place to post stale memes.
tickYes Admire Crazy Rich Asians in #bids.

pepowot What We're Not
tickNo Place to shitpost, spam, or have heated discussions.
tickNo Place to complain about the bot approval queue.
tickNo Bot curation service to recommend Discord bots.
tickNo Server curation service to recommend servers.
tickNo Support server for random bots you find online.

lusty dew
#

I wonder if there is a Netflix API

hushed berry
#

for what

weary lark
lusty dew
#

Netflix?

weary lark
opaque eagle
#

Come on no one appreciates the time and effort I put into my message

unreal oxide
#

i thought it was cool

opaque eagle
#

ay ty fam

devout chasm
#

pffft

opaque eagle
#

netflix api sucked even when it was not deprecated

lusty dew
#

To send something to someone in a ban cmd wouldnโ€™t I do it before I actually ban em?

opaque eagle
#

I remember using it before

#

Yes

#

After u ban, that user is unavailable to ur bot, unless u share another guild with them

lusty dew
#

Okay

#

Also does anyone know anything about better-sqlite3

#

Iโ€™m trying to make a function to pull data from a specific table

#

But I canโ€™t figure out what other param I need to pass.

#
db.prepare(`CREATE TABLE IF NOT EXISTS promo (
  id TEXT PRIMARY KEY,
  credits SMALLINT NOT NULL DEFAULT 0,
  guild_premium BOOL NOT NULL DEFAULT FALSE,  
  expiration BIGINT NOT NULL DEFAULT 0,  
  uses SMALLINT NOT NULL DEFAULT 0
)`).run()

Db table

  get(table, cond = {}, sel = "*", id = "id") {
    if (Array.isArray(sel))
          sel = sel.join`, `
      let p = Object.keys(cond)
      let ins = db.prepare(`
        INSERT OR IGNORE INTO ${table}
        (${p.join`, `})
        VALUES (${p.map(k => "@"+k).join`, `})
      `);
      let sQ = db.prepare(`
        SELECT ${sel} FROM ${table}
        WHERE ${p.map(k => k+" = @"+k).join` AND `}
      `)
      //return (...a) => (ins.run(a), sel.run(a))
      return (ins.run(cond), sQ.get(cond))
  }```
Get func
```js
getPromoCode(something, sel = "*"){
   this.get("promo", {something}, sel)
}

Func Iโ€™m trying to create

opaque eagle
#

Ik this won't help you but normally i prefer using an ORM

lusty dew
#

?

#

Orm?

opaque eagle
#

Like Sequelize or TypeORM

lusty dew
#

Oh

opaque eagle
#

It abstracts the SQL queries for u

lusty dew
#

Ehhh

opaque eagle
#

useful in a large project

lusty dew
#

I really donโ€™t feel like rewriting the db again ;-;

#

Not on a tablet anyway kek

opaque eagle
#

Like js // SELECT modLogChannel FROM guild WHERE id = 'ID_HERE' LIMIT 1; Guild.findOne({ select: ["modLogChannel"], where: { id: "ID_HERE" } });

#

Kinda easier to look at

lusty dew
#

Bruh....

#

That looks like stuff from Momgo

opaque eagle
#

or ```js
/*

  • equivalent to: CREATE TABLE tags(
  • name VARCHAR(255),
  • description TEXT,
  • username VARCHAR(255),
  • usage INT
  • );
    */
    const Tags = sequelize.define('tags', {
    name: {
    type: Sequelize.STRING,
    unique: true,
    },
    description: Sequelize.TEXT,
    username: Sequelize.STRING,
    usage_count: {
    type: Sequelize.INTEGER,
    defaultValue: 0,
    allowNull: false,
    },
    });```
lusty dew
#

Mongo*

opaque eagle
#

That first example was TypeORM

#

This second one is Sequelize

#

idk ur call, just saying... i like ORMs in large projects

lusty dew
#

The TypeORM looks like Mongo

opaque eagle
#

yes it does, i guess

#

but it's much better

lusty dew
#

Hm

#

I really donโ€™t wanna rewrite but damn that does look easier

#

Lmfao

opaque eagle
#

Defining structures in TypeORM (using TypeScript, JavaScript has similar syntax with some differences)```js
import {Entity, PrimaryGeneratedColumn, Column, BaseEntity} from "typeorm";

@Entity()
export class User extends BaseEntity {

@PrimaryGeneratedColumn()
id: number;

@Column()
firstName: string;

@Column()
lastName: string;

@Column()
age: number;

}```

lusty dew
#

Thatโ€™s Typescript?

opaque eagle
#

But TypeORM in JavaScript sports a similar format

#

yeah, that's typescript code

lusty dew
#

Wait whatโ€™s the point ofTypescript

#

Whatโ€™s it used for

opaque eagle
#

Strong typing

#

Everything has types

#
function add(x: number, y: number): number {
   return x + y;
}``````ts
class MessageUtils {

static async getPrefix(message: Message): Promise<string> {
        if (message.channel instanceof TextChannel) {
            return Guild.findOne({
                where: { id: message.channel.guild.id }
            }).then(g => g!.prefix);
        } else {
            return settings.prefix;
        }
    }

}```
lusty dew
#

I may use Sequelize

opaque eagle
#

Yeah

#

Sequelize is a good fit

lusty dew
#

Whatโ€™s the benefit of making your own classes?

opaque eagle
#

Classes are just abstractions of how classes are made with prototypes

#

So they just make it easier

lusty dew
#

Ah mk

#

I was wondering what the point of classes are and how they can help you

#

I saw someone making a class that extended onto Client

languid dragon
#

it's like a glorified function

#

especially in javascript

opaque eagle
#

^

languid dragon
#

1 sec

opaque eagle
#
function Apple(type) {
    this.type = type;
    this.color = "red";
}
 
Apple.prototype.getInfo = function() {
    return this.color + " " + this.type + " apple";
};``````js
class Apple {

   constructor(type) {
      this.type = type;
      this.color = "red";
   }

   getInfo() {
      return this.color + " " + this.type + " apple";
   }

}```
lusty dew
#

The only class Iโ€™ve made is a LavalinkQueue class that extended into Lavalink

opaque eagle
#

Those two codeblocks do the same thing

lusty dew
#

Hm classes look easier and nicer

#

Sequelize uses sqlite3?

opaque eagle
#

Sequelize just makes queries look easier to the eye

#

it uses sqlite3/pg/any-relevant-db-pkg in the background

#

About the classes stuff... Here's my Discord bot that makes rather extensive use of classes.
It's actually in TypeScript, but TypeScript is just JavaScript with the extra Map<K, V> etc, just ignore those.
https://github.com/SinistreCyborg/Penelope

lusty dew
#

Nice

#

So can it use better-sqlite3?

opaque eagle
#

Nah it uses sqlite3

lusty dew
#

Ah mk

languid dragon
#

hey guise my code is br0ke can i get some help plz

const __=Symbol,___=Object.assign,_____=Array.isArray,____=Object.keys,_=(_=[])=>___({},...(_____(_)?_:____(_)).map(_=>({[_]:__(_)})))
opaque eagle
#

seriously

lusty dew
#

Uhm

opaque eagle
#

i mean its kinda boring now

lusty dew
#

Walks away Nope

languid dragon
opaque eagle
#

find and replace does the trick @languid dragon

languid dragon
#

still fun to do

opaque eagle
#

ok

lusty dew
#

I donโ€™t even know what that is so

languid dragon
#

my favourite project ngl

lusty dew
#

Uhm

#

Okay then

#

Ima go figure out how to use sequelize

opaque eagle
#
function foo(arr = []) {
    
    let thing_to_assign;
    if (Array.isArray(arr)) {
        thing_to_assign = arr;
    } else {
        thing_to_assign = Object.keys(arr).map(makeSymbol);
    }
    
    return Object.assign({}, ...thing_to_assign);
    
}

function makeSymbol(e) {
    return { [e]: Symbol(e) }
}```
#

@languid dragon

languid dragon
#

pog

lusty dew
#

Hm

opaque eagle
#

ppl made fun of my old commands all the time... if only u showed these functions then lmao @languid dragon

lusty dew
#

Would I put localhost if itโ€™s on a server?

opaque eagle
#

Very old ban command for the memes:js member.bannable ? await member.ban(days ? {days, reason: `[${message.author.tag}] ${reason}`} : `[${message.author.tag}] ${reason}`).then(()=>message.say(`${this.client.emojis.get("508827649229979648")} ${member} has been ${this.command.name}ed${reason !== "No reason provided." ? ` for reason: \`${reason}\`` : "."}`)) : message.reply(`${this.client.emojis.get("508827674110590998")} I can't ${this.command.name} that person!`);

languid dragon
#

there's a difference between shit code and meme code

lusty dew
#

That looks...messy

opaque eagle
#

Very old ping command:js module.exports = { description: "Check my connection to the Discord server.", execute: message => message.channel.send("Pinging...").then(m => m.edit(`Pong! (Roundtrip took: ${ping.createdAt - message.createdAt}ms. Heartbeat: ${message.client.ws.ping}.)`)) };

lusty dew
#

Would I put localhost if itโ€™s on a server?

twilit rapids
#

Talking about memes, I memed my whole bot. This was the ready event:

var a=['guilds','size','\x20servers\x20|\x20','users','\x20users','PLAYING','ready','user','setActivity','mwr\x20help\x20|\x20'];(function(c,d){var e=function(f){while(--f){c['push'](c['shift']());}};e(++d);}(a,0x128));var b=function(c,d){c=c-0x0;var e=a[c];return e;};mwr['on'](b('0x0'),async()=>{mwr[b('0x1')][b('0x2')](b('0x3')+mwr[b('0x4')][b('0x5')]+b('0x6')+mwr[b('0x7')][b('0x5')]+b('0x8'),{'type':b('0x9')});});
lusty dew
#

@opaque eagle

opaque eagle
#

wow

lusty dew
#

Okay wtf

#

That is a very big eyesore delete please kek

opaque eagle
#

My commands have tons of spacing now: ```ts
import { Command, Penelope } from "../..";
import { Message, PrivateChannel } from "eris";
import { oneLine } from "common-tags";

export default class extends Command {

constructor(client: Penelope) {
    super(client, {
        name: "ping",
        description: "Check my connection to Discord.",
        category: "๐Ÿ›  Utility"
    });
}

async exec(message: Message) {

    const ping = await message.channel.createMessage("Pinging...");

    const round_trip = ping.timestamp - message.timestamp;
    return ping.edit(oneLine`
        ๐Ÿ“ Pong!
        Round-trip took: ${round_trip}ms.
        Latency: ${this.latency(message)}ms.
    `);

}

private latency(message: Message): number {
    if (message.channel instanceof PrivateChannel) {
        return [...this.client.shards.values()][0].latency;
    } else {
        return message.channel.guild.shard.latency;
    }
}

}```

lusty dew
opaque eagle
#

Yes

lusty dew
#

Okay

twilit rapids
#

Yeah, this is my ping command now

const ShinkaCommand = require('../abstract/ShinkaCommand.js');
const { MessageEmbed } = require('discord.js');

class Ping extends ShinkaCommand {
    get name() {
        return 'ping';
    }

    get usage() {
        return 'ping';
    }

    get description() {
        return 'Basic ping and pong command';
    }

    async run(msg) {
        const embed = new MessageEmbed()
            .setColor(this.client.embedColor)
            .setDescription(`Pinging...`)
        const sent = await msg.channel.send(embed);

        const embed2 = new MessageEmbed()
            .setColor(this.client.embedColor)
            .setTitle('Pings')
            .setDescription(`Command Delay: **${Math.round(sent.createdTimestamp - msg.createdTimestamp)}ms**\nGateway Ping: **${Math.round(msg.guild.shard.ping)}ms**`)
        await sent.edit(embed2);
    }
}
module.exports = Ping;
lusty dew
#

My ping cmd is like 20 lines

twilit rapids
#

My actual ping code is 11 lines

#

But classes

opaque eagle
#

localhost is usually just fancy-talk for 127.0.0.0/8 (v4) or ::1 (v6) so I don't see why not

twilit rapids
#

Name, description and usage

lusty dew
#

Okay

twilit rapids
#

no u Ari

glad shell
#

what's the /8 at the end of 127.0.0.1?

twilit rapids
#

The port

lusty dew
#

๐Ÿ‘€

glad shell
#

Awww. TIL. Interesting

lusty dew
#

Like a fucking dictionary

#

Lmao

#

๐Ÿ‘€

twilit rapids
#

Magic, more like luck butok

#

I would never booli such qt

lusty dew
#

So Iโ€™m guessing storage is the file where all the database stuff will be saved?

opaque eagle
#

@glad shell Subnet mask of the ip

twilit rapids
#

uwu

lusty dew
#

Do I have to create the storage file? @opaque eagle

twilit rapids
#

no u

lusty dew
#

Or will it create it for me

opaque eagle
#

Try and see i guess

#

I haven't used sequelize in a while

lusty dew
#

Okay I know better-sqlite3 creates the file for you not sure about sqlite3

opaque eagle
#

Whoever asked the question about the slash, idk if I answered it in detail. Idk if you have a CS background or not, so I'll keep it short. The number to the right of the slash indicates the number of contiguous 1 bits in the netmask.
Example: 192.168.0.1/24 has a subnet mask containing 24 contiguous bits, which is 255.255.255.0.

#

Going to that specific IP I mentioned, 127.0.0.0/8 would have a subnet mask with 8 contiguous bits, which is 255.0.0.0

glad shell
#

That was me. Outside a Udemy Golang course for beginner programmers I have no CS background. I just recognized 127.0.0.0 as being off from the typical localhost ip of 127.0.0.1

opaque eagle
#

Yeah that's reasonable

lusty dew
#

Iโ€™m assuming in Sequelize there is no primary key?

opaque eagle
#

Anyways having that subnet mask makes sense for localhost b/c that would allow for roughly 16.7M IPs/applications, while Class A networks (medium-sized networks) have a default subnet mask of 255.0.0.0, which allows for only 256 connections

#

Sequelize assumes a primary key of id iirc

#

You can define your own, too: ```js
class Collection extends Model {}
Collection.init({
uid: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true // Automatically gets converted to SERIAL for postgres
}
}, { sequelize });

class Collection extends Model {}
Collection.init({
uuid: {
type: Sequelize.UUID,
primaryKey: true
}
}, { sequelize });```

lusty dew
#

I didnโ€™t see it

#

Lol

opaque eagle
#

np

lusty dew
#

Thanks

opaque eagle
#

there's a search button for future reference if you'd like

#

it's useful to have the docs open while you're following along with Discord.js's guide

lusty dew
#

I hope it doesnโ€™t matter that Iโ€™m using sequelize.define

opaque eagle
#

Nope doesn't matter

lusty dew
#

Okay

#

I saw d.js guide using it and the docs using init

opaque eagle
#

Yeah

#

All ORMs (Sequelize, etc) provide both an FP and OOP method to define models

lusty dew
#

Ah mk

#

This is what I have so far:

const Sequelize = require("sequelize")
const sequelize = new Sequelize('database', 'username', 'password', {
    host: 'localhost',
    dialect: 'sqlite',
    logging: false,
    operatorsAliases: false,
    storage: 'clap.sqlite'
})

module.exports = new class DB {
    constructor(){
        Object.defineProperty(this, "sequelize", {
            value: sequelize
        })
        this.define('users', {
            id: {
                type: this.text,
                primaryKey: true
            }
        })
    }
}
#

Hopefully Iโ€™m doing it right.

#

Iโ€™m copying the same format as my old db.js file

#

Whatโ€™s postgres

glad shell
#

forked version of mysql/mariadb with a few more features

lusty dew
#

I donโ€™t even know how to get a Postgres URI

opaque eagle
#

Don't worry about Postgres, I just copy-pasted that code from the docs

glad shell
#

^

opaque eagle
#

also the module.exports part isnt in the docs @lusty dew

lusty dew
#

Ik

opaque eagle
#

forget what I said about the connection URI stuff, it's just gonna make the learning curve harder

#

But yeah the syntax is a bit off

lusty dew
#

Iโ€™m not following the docs to the exact letter

opaque eagle
#

That's not how classes are made

lusty dew
#

Hm

#

How are classes made?

#

I forgot honestly

opaque eagle
#

new doesn't belong there```js
class ClassName {

// all the other stuff

}```

lusty dew
#

Isnโ€™t it just class ClassName or smth

opaque eagle
#

But tbh I don't see why classes are necessary in that case

#

You can just make that connection a property in ur bot

lusty dew
#

Wdym?

opaque eagle
#

wait a min

lusty dew
#

Okay

glad shell
#

Are you using a nodeJS framework @lusty dew

#

?

lusty dew
#

Huh?

glad shell
#

You're using discordjs?

opaque eagle
#
const db = new Sequelize('stuff here');
const Tags = db.define('more stuff');
const Guilds = db.define('more stuff too');

let client = new Discord.Client();
client = { ...client, db: { Tags, Guilds } };

// so now, you can do this anywhere, even if it's in a separate file:
client.db.Tags.findOne('stuff');```
#

No need to make a class

#

Even if you're using a command handler and the command is in a separate file, you could do: js // commands/some-cmd.js module.exports = { name: "some-cmd", run(message, args) { message.client.db.Guilds.findOne('stuff'); } };

glad shell
#

how does that set property work? Are you instantiating all instances by calliing ...client?

lusty dew
#

I was just gonna do const db = require('../library/seq_db.js')

opaque eagle
#

Yeah that also works

#

But that class still has some issues

lusty dew
#

Then I was gonna make functions for each thing I needed

opaque eagle
#

Yeah that works

lusty dew
#

Like getGuild, writeGuid, etc

opaque eagle
#

getGuild() would just be calling Guilds.findOne()

lusty dew
#

Yea ik

opaque eagle
#

you don't really need to write your own functions when using smth like sequelize

lusty dew
#

True.

opaque eagle
#

The point of sequelize is that you don't need to write your own functions

lusty dew
#

But I donโ€™t feel like writing blah.findOne all the time kek

#

Thatโ€™s my lazy side though

opaque eagle
#

ok ur call, I guess

lusty dew
#

Eh if I had a pc itโ€™d be different

#

But youโ€™re right

opaque eagle
#

In your class above, this.text and this.define are undefined btw

lusty dew
#

Huh?

opaque eagle
#

module.exports = new class DB {
constructor(){
Object.defineProperty(this, "sequelize", {
this.define('users', {
id: {
type: this.text,
primaryKey: true
}
})
}
}

lusty dew
#

How is it undefined

#

Define Lang?

#

Jk

opaque eagle
#

No

#

Don't use JSON as a database @woven sundial

weary lark
#

mysql, rethinkdb

lusty dew
#

An actual database

opaque eagle
#

this.define implies that class DB or its parent(s) has a method named define()

weary lark
#

redis

#

theres a lot of databases out there which are way better than json

glad shell
#

const configf did you mean to have the extra f there?

lusty dew
#

Ah okay

weary lark
#

and jsons can easily get corrupted

#

with fs if used multiple times

lusty dew
#

So wait how should I setup the file instead?

opaque eagle
#

I think you meant to do sequelize.define() and Sequelize.TEXT @lusty dew

weary lark
#

i mean the setup file is fine as is

#

but you can put that into a db if you want to

lusty dew
#

Didnโ€™t you say not to use a class?

opaque eagle
#

Yeah

lusty dew
#

That it was pointless?

opaque eagle
#

But I thought you wanted to do it

#

ok

lusty dew
#

I just wanna get this working kek

opaque eagle
#

lmao

lusty dew
#

Itโ€™s 1am and I am supposed to have been pushing the new update hours before now

weary lark
#

just if you read/write like every 5 seconds to json can easily make it corrupt lol

#

oof

opaque eagle
#

Most times, developers like to define their models in separate files, kinda like commandss

lusty dew
#

Yea. I donโ€™t wanna do everything in my main file

#

Itโ€™d get messy

#

So I split stuff up into separate files

weary lark
#

ye

opaque eagle
#

Yeah...

weary lark
#

modulate it

opaque eagle
#

Wait a min, I'll get some boilerplate code going

#
// main file
const db = new Sequelize('define ur db connection here');
module.exports.db = db;``````js
// modules/Guild.js (for example)
const db = require("../path/to/that/main/file.js");
const Guild = db.define(
   /* define that model here */
);
module.exports = Guild;```
#

Then you can write a command handler-type thing to get all ur models into one object

lusty dew
#

So I can do this instead:

const Sequelize = require('sequelize')
const sequelize = new Sequelize(blah blah blah)

module.exports = (client) => {
sequelize.define('users', {
name: {
type: sequelize.text
}
})
}
opaque eagle
#

don't do new Sequelize() in every file, that'll make a new connection each time

lusty dew
#

Wdym?

#

Iโ€™m not making separate files for each table

opaque eagle
#

oh ok

lusty dew
#

Yea

opaque eagle
#

then what did u mean by splitting stuff up into multiple files

lusty dew
#

Like my cmd handler

opaque eagle
#

lmao

lusty dew
#

I put it in a separate file so itโ€™s not messy

#

Cause itโ€™s long

opaque eagle
#

ok

glad shell
#

event handler?

lusty dew
#

I actually gotta fix my cmd handler

#

My other dev did something to it

glad shell
#

client.on, client.error.... etc

#

I couldn't initialize a lot of functionality cuz I wasn't calling the event handler
edit: you guys aren't even talking about the discordjs api. I'm tired..

opaque eagle
#

Then maybe just a db.js that looks like: ```js
const db = new Sequelize();

module.exports.Tag = db.define();
module.exports.Guild = db.define();
// etc etc etc``````js
// so in every file you need the db in, you can do:
const { Guild } = require("../path/to/db.js");
Guild.findOne();```

lusty dew
#

Hm

#

Seems less messy

#

Thanks

#

My way was gonna be hella messy kek

opaque eagle
#

Lol... this channel isn't supposed to be about just Discord**.js** @glad shell

#

It can be about anything related to development

glad shell
#

I know I know. I've been at it for like 18 hours. I'm exhausted and I'm not being helpful.

lusty dew
#

Hm

opaque eagle
#

I can be talking about pointers in C++ and no one can say a thing

lusty dew
#

Even a virus?

#

Jk

opaque eagle
#

Well that would be against Discord ToS

lusty dew
#

๐Ÿ‘€

#

Yea

#

Alright ima go tryout this sequelize thing

opaque eagle
#

Unless I was working with real-life stats of some deadly virus in MATLAB

lusty dew
#

Oh yea one more question

#

I donโ€™t wanna make a new column for each event there is like guildMemberAdd, guildMemberRemove, messageUpdate, etc

#

Is there a way I can condense it down

#

Some people where talking about arrays and such

opaque eagle
#

What would you want to store in each column

lusty dew
#

Well

#

For the logging events Iโ€™d like it to be a bool with the default being false

opaque eagle
#

logging events like sending it to a channel in a guild?

#

or logging it as in logging it to the console

lusty dew
#

So people can do like -settings guildMemAdd true

opaque eagle
#

Ok

#

So here's the thing with that

lusty dew
#

Ye guild channel

opaque eagle
#

It's not as many DB entries as you think.

  1. Member Join/Leave Messages use two events but they both go to the same channel, so you only need a single memberLogs entry.
  2. Moderation Logs use three events but they all go to the same channel, so you only need a single moderationLogs entry.
  3. Message Logs use three events but they all go to the same channel, so you only need a single messageLogs entry.
#

And to see if those logs are enabled or not, just check if the entry is null

#

This is the Guild model for my Discord bot (it's in TypeORM not Sequelize, but you can understand what it means)```ts
import { Entity, BaseEntity, Column, PrimaryColumn } from "typeorm";
import { settings } from "../..";

@Entity()
export class Guild extends BaseEntity {

@PrimaryColumn({ type: "varchar", length: 20 })
id!: string;

@Column({ default: settings.prefix }) prefix!: string;

@Column({ type: "varchar", length: 20, nullable: true })
modLogs!: string;

@Column({ type: "varchar", length: 20, nullable: true })
memberLogs!: string;

@Column({ type: "varchar", length: 20, nullable: true })
messageLogs!: string;

@Column({ type: "varchar", length: 20, nullable: true })
autorole!: string;

}```

lusty dew
#

Uhm I kinda understand it but kinda not at the same time.

#

How does that allow the, to individually turn off or on the events they want?

#

Like say they want guildMemberAdd but not guildMemberRemove active

opaque eagle
#

Well turning on and off individual events is really rare

#

Most bots don't offer that feature (besides welcome/goodbye messages)

lusty dew
#

I know a few bots that do

#

Dyno and logger does iirc

#

I just want to have it as an option in case people want it

opaque eagle
#

In that case, I'd just suggest having separate entries

#

It's good to make use of what's already provided, instead of trying to devise some home-brewed, half-baked solution

lusty dew
#

Okay

opaque eagle
#

People who work on large libraries or open source software take their time with optimizing all their code for performance/efficiency, etc. Using what's already provided for you in such scenarios is usually really beneficial. Well that first part isn't so true of JavaScript libraries these days, but it still holds for large OSS projects like SQLite or Apache

lusty dew
#

So basically:

sequelize.define('guilds', {
guildMemAdd: {
type: sequelize.boolean,
defaultValue: false,
allowNull: false
},
//etc
})```
opaque eagle
#

No I'd make it a string

#

and set allowNull to true

lusty dew
#

Why

opaque eagle
#

string so u can store the channel ID

lusty dew
#

Huh

opaque eagle
#

and if the string is null, that means the owner didn't enable the feature

lusty dew
#

Iโ€™m already gonna have a log_channel entry

#

Uhm okay

#

Makes sense ig

opaque eagle
#

Why have two entries for the same feature, ya know

lusty dew
#

๐Ÿคท

#

I see how it can be beneficial

#

Allows them to if they want to have specific channels for the events

#

And what not

opaque eagle
#

Yeah, that's already possible

lusty dew
#

Yea

#

Iโ€™ll have to edit my settings cmd then

opaque eagle
#

Make it a nullable string:

  • if it's null, it's not enabled
  • if it's not null, it is enabled, and the value is the channel id
#

Two "features" with the same entry

lusty dew
#

Actually

#

No I wonโ€™t have to change my settings cmd at all

#

Except for fixing the db thing

#

But everything else should work

#

Could I set the default value of it to a string

opaque eagle
#

No, I'd set the default value to null, cuz it wouldn't be enabled by default

lusty dew
#

Like ''

#

Mk

#

Iโ€™ll be back if I have anymore questions

#

Also sequelize looks so much cleaner then the db.prepare('CREATE TABLE IF NOT EXISTS guilds') thing

opaque eagle
#

Yep

#

Also gonna go on one small rant

#

Also just as a heads up/life advice type thing... making sense out of languages/libraries you don't understand is a valuable skill.
You don't need to know the syntax, but you should still understand what that code does just by using context clues. For example, about that TypeORM code I showed earlier. You don't need to know everything about TypeORM and TypeScript to understand that that said, because there are tons of context clues there to help you. There was:

  • varchar (a common data type in SQL databases)
  • nullable ("able to be null")
  • modLogs/memberLogs/messageLogs which are common words in Discord Bot dev
  • Column which means what it says.

Here's the code again if you want to take another look at it:
https://github.com/SinistreCyborg/Penelope/blob/master/Internals/Models/Guild.ts

But anyways, that skill comes in really really handy... Real-life example:
Tons upon tons of devs look to Discord's official docs in their own code, but Discord's game SDK docs give code in C#... not all devs, however, use C#.

Here's an example from the Discord docs: https://discordapp.com/developers/docs/game-sdk/applications#getticket-example
Even in code as seemingly complex as that, you can see several context clues, like:

  • Discord.User which is a Discord User
  • timestamp wonder what could that be
  • ticket.Split('.') use what you know about String.split() in javascript
  • parts[0] == "2" woahhh isn't that just like js code??
  • Console.WriteLine("some string") sounds just like console.log() in js
lusty dew
#

Hm okay

#

Wait I have to do tableName.sync()

#

To have the bot make the table right?

lusty dew
#

Okay I remember seeing it just forgot what it did

lusty dew
#

Gn everyone

opaque eagle
#

Just for the record, I didn't know a thing about Sequelize except for the fact that it existed. I answered all those questions just by reading the documentation + google.

earnest phoenix
#

How can I run two bot applications on the same code and same database? This is my config file:{ "prefix": "*", "token": "secret", "dbl": "secret" }

Would it be possible to have two different tokens to run two instances of the bot with the exact same code and database? (If anyone replies, please mention me in the response.)

slender thistle
#

token1, token2 keys containing different values

quartz kindle
#

@earnest phoenix yes its perfectly possible

earnest phoenix
#

Thanks, would I do it as shivaco mentioned above?

quartz kindle
#

you can do it in a million different ways

slender thistle
#

Well, I suggested the way I use, at least mmulu

quartz kindle
#

we cant give you an answer just from you config file, we dont know how your code accesses your config file and how it logs into discord

#

and do you want to run two bots in the same process or in two separate processes?

#

also which library

earnest phoenix
#
"prefix": "*",
"token1": "secret", 
"token2": "secret", 
"dbl": "secret" 
}```~~This gives me an error:  "No token was provided." ~~ I see why.

two separate processes, discord.js master
quartz kindle
#

if its two separate process, just make two config files

#

but if you're running two instances of exactly the same code, then you need to detect which process was currently fired

#

for example, when running node, you can add arguments

#

node myfile.js argument here

#

then inside the code you can get the argument from process.argv

#

so basically when you run your bot you have to do node myfile.js bot1 then node myfile.js bot2 or something like that, and from inside the code you check which bot was run, and load the correct config file

earnest phoenix
#

this is my sharding file```const { ShardingManager } = require('kurasuta');
const { join } = require('path');
const { token } = require("./config.json")
const { isMaster } = require('cluster');

const sharder = new ShardingManager(join(__dirname, 'index'), {
"token": token
"timeout": 240000
});

sharder.on('debug', message => {
console.log(message);
});

sharder.spawn();


i created `config1.json` and `config2.json`. how would i declare the constant here?  `const { token } = require("./config.json")`
quartz kindle
#

assuming you run your bot like this node myfile.js bot1 this is one of the possible ways ```js

const { token } = process.argv[2] === "bot1" ? require("./config1.json") : require("./config2.json")```

#

process.argv gives you an array of all arguments, like this ["node","myfile.js","bot1"]

#

so get the 3rd argument (index 2), and check if it contains "bot1" and load config one, else load config 2. this will always load config2 if you put anything else that is not "bot1" in the args

#

you can also make it like this

#
const { token } = require(`./${process.argv[2]}.json`)```
#

then you launch it using the config file as the arg: node myfile.js config1

#

this is probably a better way to do it than what i said before

earnest phoenix
#

~~i see you mentioned index 2 but the file name is index - i want to use the same already existing files for both bot applications.

i also have no idea what i should put into the config files for the second method.~~

ah, i see, thank you

peak quail
#
        for (let member of message.guild.voiceChannel.members) {

            console.log("Hmmm")
            
        }

TypeError: Cannot read property 'members' of undefined
i want to loop something for the voice Channels members in the guild
so for all members that are in a voice channel

stray garnet
#

Guys tiny Question, how can i do for Example !play creeper awww man

so how to search with Words?

#

i already got an Play command

mossy vine
#

@peak quail are you using stable or master

#

oh wait

#

yeah guild.voiceChannel isnt a thing

peak quail
#

Mmmmm

quartz kindle
#

you need to specify which voice channel

earnest phoenix
quartz kindle
#

503 - service unavailable

topaz fjord
#

basically discord dead

earnest phoenix
#

With a richembed, how do you change the setColor?

#

It wonโ€™t let me change it of 0x00bfff

stray garnet
#

.setColor("your hex code")

#

or use .json files

#

@earnest phoenix

valid frigate
#

rich embed is deprecated in v12

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

amber fractal
#

use messageEmbed

#

it's the same thing

valid frigate
#

it's not actually that stupid

amber fractal
#

just with a different name

valid frigate
#

ok im probably dumb

#

on a side note the methods in richembed wee moved into messageembed

earnest phoenix
#

Thank

amber fractal
#

it's basically the same

#

just on master has more methods and properties

earnest phoenix
#

hey, im trying to make a blacklist system and i want to do that if the user have the permission manage messages the bot will not trigger and im always getting this error

stray garnet
#

how can i do an play command that uses tags and links?

earnest phoenix
#

code, mind byoe?

#

the second line is the error line

#

is this inside a DM?

#

no

#

i blocked DMs in the bot

#

and the block DMs code is before the blacklist system

#

message.member can be null in stable

#

try fetching the author as a member in the server, then calling hasPermision

#

preferably <guild>.fetchMember()

#

as .get() relies on cache

#

so fetch member is better?

#

you could say that

#

ok

#

thank you ill try that

#

the fetch member takes a id?

#

UserResolvable

#

so it could be just message.author

#

ok

#

thx

#

i need to do await message.guild.fetchmember?

#

yeah, you need to resolve the promise fetchMember() creates

#

ok

pine jacinth
#

You should rather read the error by yourself. It directly states the problem

earnest phoenix
#

ok its now working thanks

#

meh, not really

#

ok i think i fixed it

brave anvil
#

How would I make a ban list

#

For my bot so certain people cant use it

earnest phoenix
#

use a database

#

cache the blacklisted members on bot start

#

if the message author is in the blacklist, return

brave anvil
#

I use a database

#

So I would have to make another table for blacklisted users. Then Every Time Someone runs a command it checks there message.author.id .

stray garnet
#

use json files lol

#

its ez

#

no

brave anvil
#

Mainly requires more resources

stray garnet
#

just 4 lines in indes

#

index

earnest phoenix
#

please don't use a json

brave anvil
#

Exaclty

#

Its memory consuming

#

And slower

earnest phoenix
#

also prone to corruption

brave anvil
#

Yes

stray garnet
#

i just use it for storing custom prefixes

brave anvil
#

...

#

Just Saying

stray garnet
#

it works lol

brave anvil
#

Its bad tho

stray garnet
#

no err ever

earnest phoenix
#

please stop trying to promote the use of json as a db

brave anvil
#

Its just easier

#

And We all know how discord doesnt like json files

stray garnet
#

i only just db for coin sytem

earnest phoenix
#

one concurrent read/write and you have lost all your prefixes/coins/blacklist

copper cradle
#

json != db

brave anvil
#

Just use db for everything

#

A DB is basically json files

#

But Its more organized

copper cradle
#

no

brave anvil
#

Yes

copper cradle
#

no

brave anvil
#

Cause you can make a database out of a bunch of json files

#

XD

earnest phoenix
#

can we stop arguing about json and get back to support angeryBOYE

brave anvil
#

I wonder

#

How to make a music bot hmmm

earnest phoenix
brave anvil
#

Thx

#

Well first of all its in the code

#

Some stuff is undefined

#

In your ready.js

earnest phoenix
#

how can that be the case though if shard 0 and 1 is logged in without issues

brave anvil
#

Hmm

#

How many guilds is your bot in

#

May I ask

earnest phoenix
#

3300

brave anvil
#

Hmm

#

Is your bot using auto sharding?

#

Hmm

#

Idk

#

I dont need to shard yet Idk much about sharding yet still learning

earnest phoenix
#

i use kurasuta with sharding manager

brave anvil
#

I would wait for a response by someone smarter than me heh

inner jewel
mossy vine
#

@inner jewel as they said it only occurs on shard 2, not 0 and 1

inner jewel
#

and?

#

the error clearly points to their code

mossy vine
#

how is that possible

last copper
#

My bot is erroring ฤฑ am turkish ฤฑ understand some english

#

Help me

inner jewel
#

just because it happens to work on two shards, doesn't mean it's correct

mossy vine
#

have you tried reading the error

inner jewel
#

posting the exact same wall of images 1 minute after posting them the first time won't make you get help faster

#

also, copy the text and send it in a codeblock

last copper
#

Sorry ๐Ÿ˜•

mossy vine
#

it clearly says that incorrect login details were provided

#

also that code is literally a mass dm command

earnest phoenix
#

it cannot be the code @inner jewel

#

shard 0 and 1 is logged in perfectly fine

inner jewel
#

it definitely is the code

#

that's where the error happens

earnest phoenix
#

surely no shards should work then?

inner jewel
#

it's easier to debug if you send the code in question

earnest phoenix
#

well i dont know which code it is in the file, the error just tells me that it is in ready

quartz kindle
#

send the code in your sharding manager, and send the code of the file the sharding manager runs

#

its probably a problem during process spawning

inner jewel
#

the error says more than just "it's in ready"

#

it says the line and column number of where it happened

stray garnet
#

how can i let my bot leave the voice channel when a song finishes

quartz kindle
#

your library probably has an event for when a stream ends

earnest phoenix
#

i reverted to my normal method (which hosts one instance) when i started getting this error @quartz kindle

sharding file```const { ShardingManager } = require('kurasuta');
const { join } = require('path');
const { token } = require("./config.json")
const { isMaster } = require('cluster');

const sharder = new ShardingManager(join(__dirname, 'index'), {
"token": token,
"timeout": 300000
});

sharder.on('debug', message => {
console.log(message);
});

sharder.spawn();


config file```{
"prefix": "*",
"token": "secret",
"dbl": "secret" 
}
quartz kindle
#

question

#

why exactly are you using the cluster module?

#

doesnt the manager handle that for you?

earnest phoenix
#

sharding manager wasnt working alone on discord.js master

#

which is why i am using kurasuta

#

which is why i need the clusters

quartz kindle
#

your code looks nothing like kurasuta examples on github and npm

earnest phoenix
#

it has been working for a long while

#

but suddenly broke

quartz kindle
#

it broken because either kurasuta has issues, or you are not using it correctly

#

the second option is more plausible

#

(although their docs are also not helping)

earnest phoenix
#

probably an issue with kurasuta because it was working for a long while, surely it cant just break out of nowhere

quartz kindle
#

it can, and many times it happens because the coder did not foresee a possibility

#

from what i understand from their docs, you dont need cluster unless you have some code that specifically needs to be run in the master process

rugged bramble
#

how i can get shards size?

earnest phoenix
#

i will remove cluster and see if that works

quartz kindle
#

can i see your index and ready files?

earnest phoenix
#

you can, though it would be too large to put here

quartz kindle
#

hastebin

#

or whatever bin

warm marsh
#

Does anyone know if it's possible to make dynamic command loader in java?

inner jewel
#

yes

warm marsh
#

I tried a few things but nothing seems to work.

inner jewel
#

but it's somewhat complicated and very easy to backfire

rugged bramble
#

someone can explain me what is sharding

earnest phoenix
#

could i just send you the files in dm? hastebin is refusing to save @quartz kindle

inner jewel
peak quail
#

that will work ?

if(message.channel.permissionsFor.has("MANAGE_CHANNEL")
warm marsh
#

Could you give me a little tip on how to do dynamic commands?

valid frigate
#

a messagechannel can't have permissionsFor

#

you can only use that method on a user iirc

peak quail
#

Hmmm

inner jewel
#

ClassLoader and reflection

rugged bramble
#

someone can explain me what is sharding and how can setup it

inner jewel
#

sharding is having multiple connections to discord, each one handling part of your bots' guilds

#

setting up sharding depends on your library

#

you should read it's docs for that

rugged bramble
#

the js docs have?

quartz kindle
#

yes, most libraries have sharding

earnest phoenix
#

Vysion, that's incorrect, guild channels do have the permissionsFor method

quartz kindle
#

sharding is recommended at 1500 guilds and required at 2500

valid frigate
#

no?

inner jewel
#

personally, i'd recommend having sharding setup from the beginning

#

because rewriting most of your code to work with sharding when you're approaching 2500 guilds is a bad experience

quartz kindle
#

@earnest phoenix your problem is probably this

#

shards are loaded sequentially, meaning more shards take more time for the bot to completely load. you cant wait a fixed amount of time, because you risk the bot not being completely ready by that point, which is probably what happened as your bot grew

#

as you have access to client in that file, all the code that requires the bot to be ready should be placed inside a client.on("ready") event

valid frigate
#

oh wait this applies to guildchannel

earnest phoenix
#

a message channel (TextChannel) extends GuildChannel, so it will have that method

quartz kindle
#

@earnest phoenix actually the problem is not exactly that, but its related to that

#

when you cluster your bot, clusters are also loaded sequentially, so one cluster become ready and fires the ready event before other clusters are ready

#

and you try to access data from clusters that are not ready yet

earnest phoenix
#

so removing the delay and clusters would possibly fix the issue?

topaz sphinx
#

@inner jewel overexaggerating a little? you dont really need to rewrite the whole code for sharding

#

unless you create the library yourself

inner jewel
#

depends on how the code is structured

quartz kindle
#

@earnest phoenix to fix the issue you should remove fetchClientValues and use broadcastEval instead, with a check if the target process is ready

topaz sphinx
#

give me an example

inner jewel
#

if everything relies on having one global client for example

#

and when sharding you have multiple

#

or eg multiple processes

#

you'll have to do considerable changes to have sharding