#development

1 messages · Page 705 of 1

short portal
#

ok kool

slim heart
#

Redirect uri is already for callback

amber fractal
#

I think dbl would have you lock it to nsfw channels tho

slim heart
#

I mean like after all the login is over, atm it goes to the home page

amber fractal
#

It redirects with a query param in the url doesnt it?

#

I did oauth stuff like 5 months ago, I forgot how it worked though

slim heart
#

I don’t think it passes on the query from previous if it just passes on code

earnest phoenix
#

what do you want to actually do

slim heart
#

Sorry. Sooo, ok, people can go straight to my dashboard with server already filled in. If they’re not logged in or login fails it redirects to the oauth login to properly login. I want to make it so ONCE they properly login, if they logged in through that, redirect them back to that page they originally weren’t logged into rather than just redirects back to home

earnest phoenix
#

you might be looking for the state parameter

slim heart
#

Let me check it out

#

Yup that worked thanks

narrow kettle
#

i keep on getting bash: null: command not found
on glitch... anyone know how to fix it? (discord.js)

sudden geyser
#

how are you getting it

narrow kettle
#

what do you mean how?

#

the debugger tells me

shadow dust
#

well whats your bash script

stray garnet
#

help pls

narrow kettle
#

whats a basg script?

amber fractal
#

Did you mean bash?

worn remnant
#

lol

narrow kettle
#

Yeah, bash

stray garnet
#
const mongoose = require("mongoose");
const botconfig = require("../botconfig.json");
mongoose.connect(botconfig.database, { useNewUrlParser: true }, err => {
  if (err) console.error(err);
  console.log(mongoose);
});
const RP = require("../models/rp.js");

exports.run = async (neko, message, args) => {
  const user = message.mentions.users.first() || message.author;

  RP.findOne(
    {
      serverID: message.guild.id,
      userID: user.id
    },
    (err, bio) => {
      if (err) console.error(err);

      if (!bio) {
        const NewBio = new RP({
          bio: args[1],
          userID: user.id,
          serverID: message.guild.id
        });
        NewBio.save().catch(e => message.channel.send(e));
      }
      if (bio) {
        const Bio = new RP({
          username: user.username,
          userID: user.id,
          bio: args[0]
        });
        Bio.update().catch(e => console.log(e));
      }
    }
  );
};
module.exports.help = {
  name: "setbio",
  aliases: []
};

so i tried some ways now to update something if it already exists. None of them worked. Please Help

mossy vine
outer tulip
#

So my friend had a question and I just wanted to ask here because i'm not sure with it
His professor told me to make a discord bot that lists out 3 most popular discord servers when you write a subject
So for example, if you write Physics, it's gonna send 3 most popular servers about Physics server

#

I told him its impossible, literally impossible but can someone clarify

mossy vine
#

not really impossible, but you need to gather a database of servers. you would essentially be making a server list but in a discord bot

outer tulip
#

oh

#

how can we even do that

#

like the possibility is probably getting 3 popular servers for every subject?

mossy vine
#

find servers related to the subject, and ask the owner(s) if they are fine with your bot including the server in its list

#

then its as simple as sorting them by member count or whatever you define as popular

west spoke
#

^

outer tulip
#

ok thanks guys

stray garnet
#

@mossy vine so at if (bio) change Update to updateOne()?

#

@outer tulip lmao your Professor told you to make an dc bot?

mossy vine
#

updateOne finds and updates the document

stray garnet
#

so i instead of update, updateOne ?

#

or at save

outer tulip
#

@stray garnet no its my friend who was told, he made a music bot and the professor said to make a bot that lists server cuz making music bot is "too easy"

stray garnet
#

oh

#

ok srly music bot is ez

outer tulip
#

i mean yea, you just connect to google console APIs

#

get youtube data api

#

ez clap

#

but yea thats what he was told to do

stray garnet
#

well use ytdl-core

#

ur done

unique nimbus
#

Saying something is easy is different per person

#

Everyone has their own experiences

outer tulip
#

tru dat

stray garnet
#

@mossy vine

mossy vine
#

try commenting out the entire thing and using updateOne

#

it does what you want to do but in 1 function basically

narrow kettle
#

if any of want to take a look of the bot code or package.json tell me

slim heart
#

This isn’t glitch support

unique nimbus
#

oh

#

thats not the right glitch

fading wigeon
#

true but this is the development channeö

#

people can talk about development stuff

slim heart
#

For bots

narrow kettle
#

it is a problem with my bot

slim heart
#

But it’s not really development it’s a platform issue

fading wigeon
#

there is no platform channel tho

slim heart
#

That you should bring up with the people who actually use the platform because it’s not your bot that’s the issue

narrow kettle
#

so its not a problem with the code?

slim heart
#

Yes that’s why you go to glitch support

#

Your bot shouldn’t be running any bash commands so best bet is yes this has nothing to do with the code

narrow kettle
#

can you give me an example of bash command realy quick? so i can check if i used any

slim heart
#

It’s literally just a command ran in bash. I can guarantee pretty much that you have not because it’s not even starting in the first place

#

It’s a glitch issue bring it to glitch please

narrow kettle
#

i will. thanks

earnest phoenix
#

Does anybody know any general tips to help reduce memory usage with discord.js?

smoky spire
#

Sweep caches regularly

mossy vine
#

^

earnest phoenix
#

oh uh

#

thats something

#

I forgot to add

#

😳

#

thanks for the info tho @smoky spire

narrow kettle
#

wait... how do i do it? im using discord.js too

mossy vine
#

Collection#sweep

narrow kettle
#

tnx

viral spade
#

Is it normal that my bot with 5k servers needs approx. 3gb of memory after a few hours and rises to 6gb within a few days? Or do i have a memory leak?

slim heart
#

Is it normal? Yes, should it be the case? No. Like what was just said, sweep caches regularly

earnest phoenix
#

I'm kind of confused on that, is it like, a manual thing you should do through commands, or should it be automated in some way, I honestly have no idea

quartz kindle
#

there are many ways to optimize djs

#

but its not an easy thing to do

#

my bot uses 60mb ram with 1600 guilds

earnest phoenix
#

woah

#

mine uses

#

100mb

#

for

#

70 guilds

#

👀

quartz kindle
#

djs caches everything by default

#

including users, members, guilds, channels, emojis, roles, presences, voice states

earnest phoenix
#

so like

#

make it not

#

cache all of those?

#

or smthn

quartz kindle
#

thats what i did

#

but you have to know what you're doing

#

for example, disabling roles, will also break all permission checking methods

#

disabling channels caching will break sending and receiving messages

earnest phoenix
#

Is eris better

quartz kindle
#

i made a library that handles most of those problems, at the cost of losing some features

smoky spire
#

Eris doesn't cache at all, so memory-wise yes

quartz kindle
#

eris does cache

#

just not as aggressively

smoky spire
#

Yeah

quartz kindle
#

and its structure is different

#

i prefer djs because i've learned it well enough to modify it to my own needs

#

if anyone is interested in the changes i did, my library is on github lul

earnest phoenix
#

dm me a link @quartz kindle

quartz kindle
#

timotejroiko/djs-shenanigans

earnest phoenix
#

@quartz kindle for the most part, could I easily switch to that instead of djs, without doing much rewrite?

#

I mean my bot's pretty basic, mainly consisting of sending embeds

verbal basalt
#

Anyone know a way I can get the bot to run for longer in this code?

celest spear
#

how to make a bot send an error message if the bot isn't in a nsfw channel? (I use discord.js)

quartz kindle
#

possibly yes, as it says, you have to test it extensively to make sure everything works as it should

verbal basalt
#

`import discord

client = discord.Client()

@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))

@client.event
async def on_message(message):
if message.author == client.user:
return

if message.content.startswith('HELLO'):
    await message.channel.send('Hello!')

client.run('token')`

#

Forgot to say it's python

quartz kindle
#

you can run a second bot on the same token with a different prefix to test it, thats what i do lul

slender thistle
#

to run for longer in this code? What do you mean?

verbal basalt
#

I run the code and the bot doesn't run for long

#

5 minutes tops

slender thistle
#

Where are you hosting your bot

earnest phoenix
#

glitch probably

verbal basalt
#

Um. So far I've just made the bot and ran the code

slender thistle
#

locally?

verbal basalt
#

Yeah

slender thistle
#

Sounds interesting

#

There's nothing blocking in the code thonkku

pallid zinc
#

It must get off when u run some command

earnest phoenix
#

probably erroring out

verbal basalt
#

I haven't found a place to properly host this code other than the place I'm coding it

#

BTW I'm on mobile

slender thistle
verbal basalt
#

I will check

slender thistle
#

Uhh that might be the cause

pallid zinc
#

message.channel.send() exist in python??

celest spear
#

hey, i have a question.

#

how to make a bot sends an error message if the bot isn't in a nsfw channel? (I use discord.js)

verbal basalt
#

1.2

slender thistle
#

Yes that's valid syntax starting from discord.py 1.0

verbal basalt
#

Idk how to change it

slender thistle
#

@celest spear TextChannel should have nsfw property

verbal basalt
#

I'm using pydroid

west spoke
#

oh god

slender thistle
#

that is supposed to return a boolean value

west spoke
verbal basalt
#

Sorry I'm new to all this

#

Me and a friend have been doing it

slender thistle
#

Ehhh... not familiar with pydroid personally, sorry

west spoke
#

honestly if shivaco wouldnt hurt me, I would reccomend async version. It works best in pydroid imo

#

Since rewrite styling is.... weird

slender thistle
#

rewrite is more OOP AngryFroge

west spoke
#

Especially if you are doing it on mobile

#

Rewrite uses more tabs

slender thistle
#

I swear Neko I'll try to host a bot with pydroid just to show you it's easy

#

someday

west spoke
viral spade
#

Tim and Iawa thanks for your responses. i will add a cronjob to sweep the cache for now.

verbal basalt
#

Lol

#

So what can I do? I've tried a few different things

#

Nothing is working

slender thistle
#

Shrug I don't really want to poke holes in the ground with just my hands

#

I'm not familiar with pydroid but at least your code is alright

verbal basalt
#

Thank you

#

I will play around with it

verbal basalt
#

Anyone know if a while loop would work in the code I showed before and where would be a good place to put it?

slender thistle
#

What about the while loop

#

What's the task you're currently trying to complete

verbal basalt
#

Hm I'm trying to get it to run for longer so I thought while something is equal to something, it would run for longer

slender thistle
#

Ehhh

verbal basalt
#

Idk

slender thistle
#

Not sure that'd help

verbal basalt
#

As I say, I'm just playing around with it

#

Idk what would work and what wouldn't

quartz kindle
#

it doesnt need a while loop because the problem is probably not code related

#

a discord library does not exit for no reason, it keeps listening to discord messages forever

#

your program is exiting for some reason, you have to find out what it is, it can be disconnections / network issues

#

check if your library has some sort of debug events that might inform you of whats going on

#

your process might also be killed by your system for some reason, too much memory/cpu usage, or any other weird reason

verbal basalt
#

Oh okay

hushed berry
#

memory leak doesnt actually sound all that unlikely

lunar crystal
#

How do I do to keep my bot online ?

quartz kindle
#

keep the program running

hushed berry
#

dont turn it off lol

lunar crystal
#

I don't turn it off

#

But when I shut down my pc My bot is off line

amber fractal
#

Yeah

hushed berry
#

lmfao

amber fractal
#

Because you shut your pc off

#

You need a vps

#

And a process maanager

#

Or leave your pc on 24/7 and hog bandwidth

hushed berry
#

bots dont really use a lot of bandwidth lmao

quartz kindle
#

they do

#

especially with guild_subscriptions enabled

#

at some point my bot was using 400gb per month lmao

#

disabling guild subscriptions cuts its bandwidth usage by like 10-20x but you lose member join/leave events (hopefully discord fixes this)

amber fractal
#

I've received 5.8gb and transmitted 2.8gb

#

Idk how to check just bandwidth in linux mmulu

quartz kindle
#

i used nethogs

amber fractal
#

Do I need to download that or is that just in linux

quartz kindle
#

probably need to install via apt

#

but its like a couple hundred kb

lunar crystal
#

I don't know really know what is an VPS, can you explain me

quartz kindle
#

vps means virtual private server

#

its like a computer that you rent somewhere

#

then you connect to it and control it through the internet

#

an entry level vps costs around 3-5 bucks a month

#

and it runs 24/7

lunar crystal
#

Ouh ok

#

Thank u

quartz kindle
#

you can then install programs on it, upload files to it, etc

#

most of us use a vps to run our bots

#

google and amazon offer a free for 12 months deal

lunar crystal
#

Nice 😮

quartz kindle
#

so you could potentially have a vps completely free for 2 years, if you switch between them

#

but you need a credit card to create an account

#

there are also services such as glitch and heroku which have free plans, but they may have some limits and weird things

#

might be good for a start, but most developers dont recommend those

#

there are also many companies that have special offers for students

#

including free vps's

lunar crystal
#

Ok thanks u very much

#

Don't worry haha I've got a credit card ;D

earnest phoenix
#
p!-BOT - [02.10.2019 21:41:32] warn: Attempting to register an invalid command object: [object Object]; skipping.
p!-BOT - [02.10.2019 21:41:32] warn: Attempting to register an invalid command object: [object Object]; skipping.
p!-BOT - [02.10.2019 21:41:32] warn: Attempting to register an invalid command object: [object Object]; skipping.

The bot is getting crashed because of this error. Who knows the solution? discord.js-commando

tulip ledge
#

Anyone knows a good anime api?

drowsy grail
#

@tulip ledge i use nekos.life

hushed berry
#

bwahhahhaa

earnest phoenix
#

@tulip ledge what do u need it for

narrow kettle
#

hey, so i got a problem, my prefix does not work...(partly) the prefix is 'k!', now, what does not work? basicly i have to write 2 charcters(could be anything like '23', 'kr', '!%' or anything with 2 charcters in it) and the commend would work, how do i fix it to only work with the prefix k!

twilit rapids
#

if(prefix !== "k!") return;

narrow kettle
#

tnx

sudden geyser
#

@tulip ledge what type of anime api?

#

images can be nekos.life
anime stats can be anilist

narrow kettle
#

Timo, i got no idea where to add it

#

can you add it on my code?

sudden geyser
#

pynter put it where you check the length

narrow kettle
#

instead of the length?

quartz kindle
#

post your code

#

then we can tell you what to do

narrow kettle
#

taking a while... is the anyway to do it with out hastebin?

#

hastebin isnt working from some reason...

earnest phoenix
#

hastebin's been down for a long time now

narrow kettle
quartz kindle
#

@narrow kettle you are not doing any kind of checking

narrow kettle
#

i realised that, i have no idea how to check the prefix, i tried and the bot just didnt react

quartz kindle
#

you remove the prefix from the message, then continue the processing, but you never check if the message actually starts with a valid prefix

narrow kettle
#

how do i check if its the actual prefix?

quartz kindle
#

one way is to use javascript's string.startsWith() method

grizzled jackal
#

I use if(!message.content.startsWith(prefix) prefix being the variable that holds my prefix

quartz kindle
narrow kettle
#

can you show me where exactly do i need to put it

wide ruin
#

@short forge

narrow kettle
#

i dont know if i should put it in the args or switch or anytthing like that

grizzled jackal
#

Well think about it logically, where would you want it to check

short forge
#

does anyone here know how to move windows quick.db to linux quick.db

knotty steeple
#

what

narrow kettle
#

i guess before the switch

short forge
#

wait nvm

wide ruin
#

Fixed?

short forge
#

its not bot related

grizzled jackal
#

Try it and test, all part of the developer experience

wide ruin
#

It can still go here

short forge
#

lets ask on the official discord

knotty steeple
#

this channel isnt specifically for bot development

wide ruin
#

It's still part of a bot

short forge
#

alright but i just read "Channel for chatting about (bot) development."

#

so does anyone here know how to move windows quick.db to linux quick.db

wide ruin
#

Bot is in brackets

knotty steeple
#

what does that mean

wide ruin
#

But yeah

quartz kindle
#

what do you mean with "move"?

wide ruin
#

Basically

quartz kindle
#

what backend are you using with quick.db?

wide ruin
#

We've been programming a bot for Windows and we're moving to raspberry pi

#

But the code has no errors on windows, and quickdb gives errors on raspi

quartz kindle
#

what backend/database are you using with quick.db?

knotty steeple
#

do you need to use paths

short forge
#

better-sqlite3 (if i understand you correctly)

knotty steeple
#

because paths are \ on windows but on linux its /

quartz kindle
#

then you can move the sqlite file

wide ruin
#

Yeah true

#

\ to /

quartz kindle
#

then you just need to install everything correctly

short forge
#

well, the paths are fine

quartz kindle
#

and yes, change all your paths, although windows supports / as well

#

what error are you getting on quickdb?

short forge
#

"promisify" isnt a function

quartz kindle
#

are you using util.promisify?

#

which node version?

knotty steeple
#

maybe util isnt installed or node is outdated yes

short forge
#

let me check

#

its above ten

#

i know that

#

but for some reason an error reporter said it wasnt when node said it was

quartz kindle
#

check again

narrow kettle
#

nope... cant get it to work

short forge
#

ok so its 7.7.2 yet i tried to update it and it said it was done

quartz kindle
#

linux repositories do not update node that often

#

you have to install node from a proper source

#

instead of using apt

short forge
#

thats what i tried to do

quartz kindle
#

look into nvm

#

node version manager

short forge
#

i saw that, i did it, refreshed the terminal and nothing happened (i'll try again though)

hushed berry
#

nevermind

narrow kettle
#

@grizzled jackal it tells me there is no such thing as startwith

quartz kindle
#

show code

#

no need to show everything, only the relevant part

narrow kettle
#

let args = message.content.startWith(PREFIX).split(" ");
switch (args[0]) {

#

thats the only part that is relevant

slim heart
#

how can i get the icon url of a guild with no icon as in like the ones with the abbreviated guild names

earnest phoenix
#

there isn't one

#

the thing you see on your client is just css

#

you have to generate an image

slim heart
#

idek how to go about doing that

slender thistle
#

Is the font known for that

slim heart
#

is there a better way of just somehow signifying the guilds name in icon form for guilds without icons for my dashboard server select?

earnest phoenix
#

oh it's on a website?

#

you can then just use css lol

slim heart
#

idk css that well ooof

#

but the text just escapes the the circle

#

its an alt which is probably the issue

#

i can just make it a different element cuz ejs

quartz kindle
#

@narrow kettle its not startWith

#

did you read the link i sent you?

#

everything is explained there, learn how to read documentation, its an invaluable skill to have

narrow kettle
#

ik, im fixing it rn

quartz kindle
#

also, startsWith returns a Boolean

#

meaning either true or false

narrow kettle
#

and it works

quartz kindle
#

so you cannot use .split on it

narrow kettle
#

yeah it told me that but the main problem was just a typo

#

i wrote startwith instead of startswith

grizzled jackal
#

@narrow kettle https://discordjs.guide I highly recommend you read this guide, I think it should be able to help you out a lot

narrow kettle
#

would probobly help me, im new to javascript and discord bots

slim heart
#

how can i fit the font to actually fit in the circle?

warm marsh
#

check the width of the text compared to the width of the circle?

quartz kindle
#

i dont think there is a way to measure text width in css

#

you'd need js for that

#

you can define font sizes in percentages, but thats it

earnest phoenix
#

you don't need to measure anything

#

wrap the text in a span element

#

you can then play around with the line-height property

quartz kindle
#

i understood he wanted to dynamically change font-size to keep it inside regardless of amount of characters

earnest phoenix
#

ah

#

that's bad UX design

#

you want to display as less text as possible to the user - so in this case just the relevant letters

slim heart
#

mm

#

idk

earnest phoenix
slim heart
#

the other issue is keeping the circle an actual circle

earnest phoenix
#

huh

slim heart
earnest phoenix
#

what's your css for the circle

slim heart
#

the behind one or the image one?

#

ill just send the whole thing here

body {
            background-color: #2C2F33;
        }
        .guild {
            float: left;
            background-color: #23272A;
            border-radius: 60px;
        }
        .guildPicture {
            border-radius: 64px;
            width: 100px;
            height: 100px;
            border: 1px black solid;
        }
        .guildText {
            font-size: 1.5vw;
            padding-left: 15%;
            padding-top: 5%;
            width: 100px;
            height: 35px;
        }```
quartz kindle
#

you can probably increase your border radius

#

use percentages

#

border-radius: 50%

slim heart
#

oh

quartz kindle
#

usually gives a circle 100% of the time

slim heart
quartz kindle
#

also are you sure you want font-size 1.5vw?

slim heart
#

its just to hold onto it for now until i start styling the text lol

#

idek what i would set that too some article i found said to use it

quartz kindle
#

the circle is like that because of the text padding

slim heart
#

removing it just moves the text

quartz kindle
#

you're giving the text a fixed 100px width plus 15% padding, that padding will be added to the fixed width, making the total width bigger than the 100px of the circle

slim heart
#

removing the padding does nothing but move the text out

#

and on laptop the same thing

quartz kindle
#

then you have some other shit going on lul

slim heart
#

issue is when i try to use perfects it make literally no difference

earnest phoenix
#

check out the fiddle i posted above

slim heart
#

what part about it?

quartz kindle
#

i would put the text inside a div with 50% size

slim heart
#

theyre all in the same classed div

#

but thats just the lil circle behind it

quartz kindle
#

circle => width: 100px
divInCircle => width:50%, display block, text align center
textInDiv => overflow: hidden, text-overflow: ellipsis

#

something like that

slim heart
#

mmk ill see

quartz kindle
#

margin 0 auto, and some fiddling around

#

to center it

#

there are many ways of doing it

slim heart
#

up yup that just worked shit

#

thank you 😅

slim heart
#

im adding little tool tip things to pop out the name on hover and theres these lines idk what they are and how to get rid of them?

#

nvrm found out

earnest phoenix
#

I have a stupid question can you use more than one API with a discord bot

eternal mesa
#

@earnest phoenix what does that mean

earnest phoenix
#

like if i want to use discords API and then another API within the same bot

slender thistle
#

That's possible but you will have to use HTTP libraries

earnest phoenix
#

is it possible to use both of them at the same time?

sage bobcat
#

One message removed from a suspended account.

quartz kindle
#

you can run as many things as you want in the same process

#

as long as you have cpu/ram for it

#

the only restriction is that you cannot bind to the same port multiple times, but thats only relevant if you're running multiple webservers or similar

opaque eagle
#

Nvm I just misunderstood the JSON result from Reddit

#

It goes json { "body": { "data": { "children": [ "data": {} ] } } }

#

I forgot that data object within the items of children

broken shale
#

HTML is easy, CSS is the hardest part

quartz kindle
#

css is not that hard

#

technically js is harder than css, because js is an actual programming language, while css isnt

sudden geyser
#

css is your best friend when it comes to error handling

opaque eagle
#

what are we talking about exactly

#

that was react

#

also css is easier than html

#

all you need to know is the syntax... how css selectors work, etc, and maybe some functions like translate(), etc... rest of it is just looking up selectors and what they do in the docs

quartz kindle
#

no way html is harder than css, html is literally just tags inside tags

lament meteor
#

i agree

#

css is hard

knotty steeple
#

css can be really ass

opaque eagle
#

If you think HTML is no more than just "tags inside tags", then CSS is also just "properties for selectors" @quartz kindle

earnest phoenix
#

what is css and html, I just use pen and paper

opaque eagle
#

Lmao

#

"HTML" also encompasses web standards like open graph protocol, SEO, and memorizing how each family of browsers and engines render different tags and which ones they support in the first place...

#

JavaScript is a lot more than just variables and if statements. Similarly, HTML is a lot more than just nesting tags.

#

CSS properties and flexbox and CSS grid are all really intuitive concepts that any serious person can pick up in roughly a day of solid learning.

autumn wind
#

why @cinder fractalis muted

#

thats my bot

opaque eagle
idle basalt
#

css is definitely more complicated than html

#

everything that you just said about html applies to css twofold

#

you have to know even more properties and even more about browser support

earnest phoenix
#

If people wanted to donate money to your bot, what would be a good method to go about this, is it even possible, I'm assuming it is, or should it be more of an external thing, like on a website, you could click donate for example

loud salmon
#

@earnest phoenix I use https://ko-fi.com for one time payments / tips. Patreon is fine but the integrations with discord suck ass and they clip off a significant chunk of your earnings. For subscription, both groovy and mee6 use https://www.chargebee.com/. I haven't worked with them at all but nik is very helpful and I'm sure he is able to answer any questions you have.

low wasp
#

There is also donatebot

loud salmon
#

thats gae

low wasp
#

Thanks spider

earnest phoenix
#

you should use those <> things

loud salmon
#

no thats gae

#

fine smh

earnest phoenix
#

also, thanks, I'll look at ko-fi

#

lol

hushed berry
#

@low wasp I would warn against any/all usage of donatebot

willow magnet
slender thistle
#

Post your server count, refer to API docs for more info

sick cloud
#

ok turns out it's a 403 from cloudfront.. ok

unreal junco
#
vtandard Time)
(node:22275) UnhandledPromiseRejectionWarning: Error: Incorrect login details were provided.
#

where am i ment to look?

sick cloud
#

@unreal junco update discord.js / check your token

narrow kettle
#

How to I make my but say he is playing (whatever)

twilit rapids
#

What library

narrow kettle
#

Discord js

twilit rapids
#

What version

narrow kettle
#

Newest

twilit rapids
#

Master?

narrow kettle
#

I'm lost, what's master?

granite tartan
#

I need help :(

twilit rapids
#

Run discord.version

#

@granite tartan hwat

granite tartan
#

okay so I started coding a bot

#

node.js

twilit rapids
#

woah surprise

granite tartan
#

ikr?

narrow kettle
#

Wait wat you mean run discord.version

twilit rapids
#

@narrow kettle what version of Discord.js are you using?

#

11.5.1?

#

12.0.0?

#

11.4.2?

narrow kettle
#

Probably 11.5.1?

granite tartan
#

i have an avatar command and I want the embed to be the coulour of my bot, how tf do i get my bots colour i'm like retarded rn

narrow kettle
#

I'm not home rn so I can't check

twilit rapids
#

What version yasmoon

narrow kettle
#

Should be the most recent one tho

twilit rapids
#

of 🅱iscord.js

#

Second one is more recommended since the first one is deprecated

granite tartan
#

I dont know

#

lol

narrow kettle
#

Tnx

granite tartan
#

the newest I guess

twilit rapids
#

@granite tartan you can check for the bot's highest role (<GuildMember>.roles.highest) and then just use .hexColor

#

And set that color for the color of your embed

sick cloud
#

but be careful because the highest role doesn't always have a colour

twilit rapids
#

True, so you can add || <A hex color you like>

granite tartan
#

tf do i put in here

twilit rapids
#

dId yOu ReAd tHe dOcs

sick cloud
#

assuming people always use message smh timo

granite tartan
#

shush

#

I did read a lot

#

and I couldnt find shit

#

but thanks thats what I was missing lol

twilit rapids
sick cloud
#

yardim

#

lol

twilit rapids
#

oh right

sick cloud
twilit rapids
granite tartan
#

i use msg

#

heh

sick cloud
#

messageum.guildum.meum

twilit rapids
granite tartan
#

alrighty

#

I did this for now

twilit rapids
#

Yep that works

granite tartan
#

cant wait till I'm a proper bot dev in here and dont have to live off from others adding me to their bot just so I'm not a white name 👀

earnest phoenix
#

How to do serialization? to make a backup system

quartz kindle
#

explain better

#

which language, library, database, backup of what, serialization of what?

earnest phoenix
#

javascript, json, backup servers system, serialization of servers datas so that after being able to restore them

quartz kindle
#

you want to backup the entire server?

#

most vps providers have backups

#

or you can just copy all your files somewhere, or setup something like google drive

earnest phoenix
#

Backup servers discords

quartz kindle
#

you're not making any sense

#

you mean guild configuration?

#

like prefixes and member settings?

#

store them in a database

#

like sqlite

earnest phoenix
#

No

#

Save verification level, channels, permissions, rôles, etc...

quartz kindle
#

save it in a database

earnest phoenix
#

The goal is to be able to backup the servers and restore them

#

Yes

#

I know this lol

quartz kindle
#

you can use JSON.stringify with a filter

earnest phoenix
#

Yes, I was planning to use json

quartz kindle
#

or you can use one of the many json serializers on npm

earnest phoenix
#

But do you have any idea how to backup a server?

quartz kindle
#

save it in a database

#

like sqlite

earnest phoenix
#

I have an sqlite database

#

And one json database

quartz kindle
#

make a table for backups, give it columns like "guildid","timestamp","data"

#

then store them in that table

earnest phoenix
#

Oh why not :)

#

Thank you Tim

earnest phoenix
#

Hi the team
I have a problem with my bot, which would be where it came from ^^

grizzled jackal
#

Can you show us your 'help' command?

earnest phoenix
tulip tundra
#

me is undefined

earnest phoenix
#

Lol

#

He use the atlantabot source

#

yes

#

You won't be able to publish your bot because of the use of a source

#

she is sharing ^^

near igloo
#

hiiih

tulip tundra
#

so you copy paste it

near igloo
#

hi

earnest phoenix
#

Even, a source betting on another bot brings the rejection of the bot

near igloo
#

oooff HI

tulip tundra
#

hey

earnest phoenix
#

Your bot will be refused.

tulip tundra
#

not me

earnest phoenix
#

@earnest phoenix Just learn to develop oui

#

Not me sorry

#

no

#

ok

grim aspen
#

can you please stop using caps

earnest phoenix
#

how old are you again

near igloo
#

im 14

earnest phoenix
#

inb4 "28"

#

right

#

good bye?

stray garnet
#

How is he still on here?

mossy vine
#

this channel is the funniest shit ever sometimes

stray garnet
#

@mossy vine lmfao

mossy vine
#

yes i am aware, anyways what do you need help with in <HTML>

near igloo
#

yeah

mossy vine
#

arrow buttons huh

stray garnet
#

Lmfao

mossy vine
#

an <img> inside a <div>

#

make the div do shit when you click it

near igloo
#

what?

mossy vine
#

wait you dont even need the img

stray garnet
#
const mongoose = require("mongoose");
const botconfig = require("../botconfig.json");
mongoose.connect(botconfig.database, { useNewUrlParser: true }, err => {
  if (err) console.error(err);
  console.log(mongoose);
});
const Money = require("../models/money.js");
const Bank = require("../models/bank.js");

exports.run = async (client, message, args) => {
  const user = message.mentions.users.first() || message.author;
  let amount = args[1];

  Bank.findOne(
    {
      userID: user.id,
      serverID: message.guild.id
    },
    (err, bank) => {
      if (err) console.error(err);

      Money.findOne(
        {
          userID: user.id,
          serverID: message.guild.id
        },
        (err, money) => {
          if (err) console.error(err);

          bank.bank = bank.bank + amount;
          bank
            .save()
            .then(result => console.log(result))
            .catch(err => console.error(err));
          money.money = money.money - amount;
          money
            .save()
            .then(result => console.log(result))
            .catch(err => console.error(err));
        }
      );
    }
  );
};
module.exports.help = {
  name: "deposit",
  aliases: []
};

When i deposit for example 1000 it outputs me that

mossy vine
#

just add a background-image property with css to the div

near igloo
mossy vine
#

where did you find that

near igloo
#

google

earnest phoenix
#

Logic

mossy vine
#

okay.. right click the image, click copy link address, and use it as your background-image for the div

near igloo
#

ok

#

its not going to next page

grim aspen
#

it needs a function on click

quartz kindle
#

@stray garnet make sure amount is a numbero

stray garnet
#

well uh i just throught that myself

mossy vine
#

bruh

stray garnet
#

Uh how can i check that again? @quartz kindle

near igloo
#

lose my brain cells

quartz kindle
#

@stray garnet Number(amount)

near igloo
#

i dea

slim heart
#

Please learn proper HTML

mossy vine
#

can an a tag have a background image? if yes, you can just use that instead of the div

near igloo
#

problem fixed

slim heart
#

And then do it

mossy vine
#

cool

near igloo
#

i can use this imag as hyperlink then it will go ti next page

#

lol IM SMART

#

THUG LIFE

mossy vine
#

yes thats what i was about to say

near igloo
#

What ever

#

im smarter then bot

mossy vine
#

..what

near igloo
#

?

mossy vine
#

eh whatever

#

good thing you fixed it

near igloo
#

lol

quartz kindle
#

Tone down the cringe lol

near igloo
#

umm spicy

#

some chilli souce

#

then fire upp

quartz kindle
near igloo
#

though NICE

quartz kindle
#

If you dont have any more development questions, you should probably move therw

near igloo
#

OK

#

then tell me what is the magic number?

#

any 1 can tell this simple question

loud salmon
#

-m @near igloo shitposting and spamming in #development | 3 days

gilded plankBOT
#

🤐 Muted Pgoldy#0229 (@near igloo)

earnest phoenix
#

thank you

quartz kindle
#

Oof

loud salmon
#

probably 12 might agebait later idk

tulip tundra
#

lmao

stray garnet
#

Oof

#

@quartz kindle well uh how can i reset data in my Cluster?

quartz kindle
#

What do you mean

stray garnet
#

So it shows me undefined, and i need to delete now data out of my Database, hoe can i do that

#

Cuz before i did that it was 0

quartz kindle
#

You probably have to loop over all entries and update them all to 0

#

In sql its easy to do that, idk mongo

narrow kettle
#

Any of you have a guild about how to clear cache?(I'm using glitch until bot is done so I'm realy limited with space and such)

quartz kindle
#

D.js?

#

v11 or v12?

earnest phoenix
#

Probably v11 lol

pallid zinc
#

Nah it's master

marsh frost
#

@sweet oak


        eb.addField("Shards:", e.getJDA().getShardInfo().getShardTotal()+"", true);
        eb.addField("Current Shard:", e.getJDA().getShardInfo().getShardTotal()+"", true);
earnest phoenix
#

That's a drastically different edit lol

marsh frost
#

'e' is the event, so whatever you created the event object is

#

I copy pasta'd from my info command and grabbed one of the wrong lines.

sweet oak
#

@marsh frost thank you I'll try that

marsh frost
#

It's pretty straight forward

sweet oak
#

yep looks like it !

earnest phoenix
#

Do collections and maps really use up a lot of ram, because I seem to be experiencing higher ran usage after using them, djs btw

quartz kindle
#

They probably use more than arrays and objects

stray garnet
#
const mongoose = require("mongoose");
const botconfig = require("../botconfig.json");
mongoose.connect(botconfig.database, { useNewUrlParser: true }, err => {
  if (err) console.error(err);
  console.log(mongoose);
});
const Money = require("../models/money.js");
const Bank = require("../models/rp.js");

exports.run = async (neko, message, args) => {
  const user = message.mentions.users.first() || message.author;
  if (!args) {
            return message.reply(`Why you wan't do Deposit Air? Enter An Number`);
        }

        const A = parseInt(args[1]);

        if (isNaN(A)) {
          const embed = new Discord.RichEmbed()
          .setAuthor("Error: isNaN")
          .setColor(0xff0000)
          .setDescription(`The Argument **${args[0]}** is Not a Number! Please enter a valid Number for the amount of Coins you want to gamble.`)
            return message.reply(embed);
        }

  message.channel.send(A)
  
  Bank.findOne(
    {
      serverID: message.guild.id,
      userID: user.id
    },
    (err, bank) => {
      if (err) console.error(err);

      Money.findOne(
        {
          serverID: message.guild.id,
          userID: user.id
        },
        (err, money) => {
          if (err) console.error(err);

          bank.bank = bank.bank + A;
          money
            .save()
            .then(result => console.log(result))
            .catch(err => console.error(err));
          money.money = money.money - A;
          money
            .save()
            .then(result => console.log(result))
            .catch(err => console.error(err));
        }
      );
    }
  );
};
module.exports.help = {
  name: "deposit",
  aliases: ["dep"]
};

it dont saves anything. help

earnest phoenix
#

maybe its just the way I do it but don't you need a file[object] kind of thing first

#

or maybe im not understanding

#

but

#

i tried

quartz kindle
#

@stray garnet you did money.save() twice

#

And no bank.save()

earnest phoenix
#

oh true

stray garnet
#

Still @quartz kindle

quartz kindle
#

Then idk, log bank and money before and after adding A

earnest phoenix
#

basically im using a command handler, fs.readdir("./commands/", kind of thing, should that actually be placed inside the ready function, so they are all gotten on ready? Or should I keep that outside of other functions, again, discordjs

buoyant onyx
#

How do u create a premium Command after we click the emoji

#

How to make it another embed

#

@earnest phoenix

#

Or anyone can help me

earnest phoenix
#

don't @ me for that

mossy vine
#

@earnest phoenix it doesnt matter afaik

earnest phoenix
#

just because i'm an embed god I'm not gonna help smh

#

oh

#

thats good

#

@buoyant onyx I use https://ko-fi.com/ for one time payments / tips. Patreon is fine but the integrations with discord suck ass and they clip off a significant chunk of your earnings. For subscription, both groovy and mee6 use https://www.chargebee.com/. I haven't worked with them at all but nik is very helpful and I'm sure he is able to answer any questions you have. I asked a similar thing yesterday, spider sent this

buoyant onyx
#

But I saw some people they make like then add an emoji check mark for payment after that it automatic activate

#

The premium

mossy vine
#

what

#

we dont spoonfeed code here

earnest phoenix
#

^

#

yeah it may be free, on google

buoyant onyx
#

How to do then

earnest phoenix
#
mossy vine
#

what do you want to do exactly

buoyant onyx
#

The premium funtion

#

For the premium user

#

And blocked some command for normal user

mossy vine
#

yeah then refer to ricochets previous message

grizzled jackal
#

Thought they wanted a collector function

mossy vine
#

same lmao

#

thats why ya ask twice

buoyant onyx
#

Wait I got some screenshots

#

How they make like this

#

This just some thai bot maker

#

They have there cpu

#

And memory usage

buoyant onyx
#

The link you send can refer right @mossy vine

mossy vine
#

wha

buoyant onyx
#

And then how they make database inside the visual private sefver

#

Server

#

I want to make the level bot also

mossy vine
#

how long have you been making bots for?

buoyant onyx
#

5month

grizzled jackal
#

That's a lot of different things you want lmao

mossy vine
#

^

buoyant onyx
#

😂

ember atlas
#

Is there a specific reason maybe internally that my bot keeps restarting randomly for no reason.

#

I thought maybe there was something before I go yell at the other dev

earnest phoenix
#

are you using glitch/heroku/free hosting

mossy vine
#

yeah there could be hundreds if not thousands of things causing that

#

maybe there is a loop running that calls process.exit

ember atlas
#

Cry I’m using a shared virtual machine.

#

Just keeps going online and online for no reason

#

Process.exit is the restart command Cyber

earnest phoenix
#

is it just gateway disconnects?

ember atlas
#

Not sure

#

Checking logs now

earnest phoenix
#

Hi , is rainbow roles against TOS?

mossy vine
#

yes as its api abuse

earnest phoenix
#

What if it’s at 60s

grim aspen
#

it is still abuse

earnest phoenix
#

2min,

mossy vine
#

bruh

amber fractal
#

Bro you're too fast.

earnest phoenix
#

rainbow roles with a big delay aren't api abuse... or rainbow roles at that point

ember atlas
#

Ok, so I’ll have to wait. There’s logs I can’t see on my phone

#

Seems to be on server.

earnest phoenix
#

So I can do 1min

ember atlas
#

It says 10 on one and 9 on the other login.

#

Would that mean a server is having issues?

earnest phoenix
#

So am I allowed do 1Min ??

ember atlas
#

Ya now I’m hella confused

vernal willow
#

Are spaces in channel names allowed or is it considered api abuse? I've seen a few bots doing this and was wondering if it's even allowed
Edit: pretty sure it's just some unicode character

amber fractal
#

Uh

#

It will just convert to a hyphen

#

You cant have spaces in text channel names

sweet creek
#

Is it possible to use a command to make all members in one group active in another?

vernal willow
#

Yeah you can lol

amber fractal
#

It's not a space then

vernal willow
#

It's a unicode character

#

As I said

amber fractal
#

Yes

#

Not a space

#

Why would they care MegaThonk

vernal willow
#

So it's allowed?

amber fractal
#

I dont see why it wouldnt be

mossy vine
#

is it an actual space or just a dumbass unicode character that looks like a space?

amber fractal
#

But tbh not sure

vernal willow
#

Ok lol

amber fractal
#

All it does is make it hard for users to mention.

quartz kindle
#

Its a unicode character, you can do many cool things with it

#

(also abusive things)

earnest phoenix
#

i mean, the client does, the api doesn't

amber fractal
#

Gotta be careful though, some phones (mine lol) render them as x boxes.

quartz kindle
#

The char im talking about is not in that list

earnest phoenix
#

are you referring to zalgo text

quartz kindle
#

Nop

earnest phoenix
#

huh ok then 🤷

#

the same effect can be accomplished with the chars in the list if your aim is to just have spaces in channel names

loud salmon
#

@earnest phoenix rainbow roles of any kind are frowned upon. the only one that I have seen a developer approve of is one color per day.

modern elm
#

lol

stray garnet
#
const mongoose = require("mongoose");
const botconfig = require("../botconfig.json");
mongoose.connect(botconfig.database, { useNewUrlParser: true }, err => {
  if (err) console.error(err);
  console.log(mongoose);
});
const Money = require("../models/money.js");
const Bank = require("../models/rp.js");

exports.run = async (neko, message, args) => {
  const user = message.mentions.users.first() || message.author;
  if (!args) {
            return message.reply(`Why you wan't do Deposit Air? Enter An Number`);
        }

        const A = parseInt(args[1]);

        if (isNaN(A)) {
          const embed = new Discord.RichEmbed()
          .setAuthor("Error: isNaN")
          .setColor(0xff0000)
          .setDescription(`The Argument **${args[0]}** is Not a Number! Please enter a valid Number for the amount of Coins you want to gamble.`)
            return message.reply(embed);
        }

  message.channel.send(A)
  
  Bank.findOne(
    {
      serverID: message.guild.id,
      userID: user.id
    },
    (err, bank) => {
      if (err) console.error(err);

      Money.findOne(
        {
          serverID: message.guild.id,
          userID: user.id
        },
        (err, money) => {
          if (err) console.error(err);

          bank.bank = bank.bank + A;
          bank
            .save()
            .then(result => console.log(result))
            .catch(err => console.error(err));
          money.money = money.money - A;
          money
            .save()
            .then(result => console.log(result))
            .catch(err => console.error(err));
        }
      );
    }
  );
};
module.exports.help = {
  name: "deposit",
  aliases: ["dep"]
};```


it dont saves anything. help
mossy vine
#

why are you still not using updateOne anyways

stray garnet
#

Instead of findOne, updateOne or what

mossy vine
#

instead of your findOne findOne save save mess

stray garnet
#

Aside from all that, why it dont saves the coins?

mossy vine
#

i have no idea

stray garnet
#

:/

#

When i do n.dep 1000 or sth i need to mention my Bot that i can use my bot again

vital lark
#

Oh

#

It's mangoose

#

You gotta do findOne to get the model

#

save isn't a promise iirc

stray garnet
#

so?

next grove
#

Hello, may I ask if a bot starts to get a lot of servers, are there any ways to make revenue?

twilit rapids
#

Add premium features that are only available to donators

earnest phoenix
#

patreon, microtransactions, web perks

next grove
#

Okay, thank you very much!

#

I also wanted to ask what sort of results people get from auctions?

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

mossy vine
#

lmao

grizzled jackal
#

Just put in lootboxes that require micro transactions where you can unlock random commands 🤣

amber fractal
#

I was going to make a bot dedicated to lootboxes and fake micro transactions

grizzled jackal
#

please name the bot EA

amber fractal
#

It was going to be called "Surprise Mechanics"

narrow kettle
amber fractal
#

Exports is better than one file

narrow kettle
#

exports?

short forge
#

Apparently "node-fetch" isn't secure, and npm wont let me download (debian linux)

amber fractal
#

Most developers will have one file per command

short forge
#

"CERT_UNTRUSTED"

narrow kettle
#

wait what... you mean a whole file just for ONE command?

quartz kindle
#

which url?

amber fractal
#

Yes @narrow kettle

narrow kettle
#

why?

amber fractal
#

Most developers will use one file per command

narrow kettle
#

isnt it way too much work

loud salmon
#

its easier

#

more compartmentalized

narrow kettle
#

easier?

loud salmon
#

yep

quartz kindle
#

because commands are complex

amber fractal
#

It's organized

earnest phoenix
#

say you have a 100 line command, would you rly want to try and search for another one, it is all clustered at that point

loud salmon
#

commands can grow large, and having it per-file will organize it

short forge
quartz kindle
#

my commands have hundreds of lines

narrow kettle
#

so basicly just so it would be more orginized for you?

loud salmon
#

yep

amber fractal
#

You can reload commands as well, turn them off for a time while you work on them, etc.

short forge
#

and more efficient

loud salmon
#

oh yea, reloading and disabling is good

quartz kindle
#

@short forge wait the npm install itself is failing with unsecure? check your system date

short forge
#

3rd october 2019, time is right as well

narrow kettle
#

i mean... im used to having realy long comands on switch so it feels orginized for me not matter what... is there any benefit from doing it?

short forge
#

npm error: CERT_UNTRUSTED

narrow kettle
#

(i can disable commands with switch too)

loud salmon
#

i used to do a switch for my first bot

#

it got very chaotic very fast

quartz kindle
#

@short forge whats your node and npm versions?

narrow kettle
#

i guess so, but making a file for each command feels like it gonna take me days just to make the files... i will have over 60 commands...

#

probobly well over 100

amber fractal
#

And then you wont ever find them in a switch command

quartz kindle
#

i have less than 10, but some of my commands take multiple files

mossy vine
#

the template is 4-10 lines of code, depending on your templating

short forge
#

0.10.13

#

for node

amber fractal
quartz kindle
#

@short forge wtf

short forge
#

1.3.2 for npm

quartz kindle
#

thats like prehistoric node

amber fractal
#

12.11.1 is node rn

quartz kindle
#

lmfao

amber fractal
#

Thats not even version 1

short forge
#

wow raspbian is broken then

narrow kettle
#

i can orginize the switch... i hope, the orginize thing does not matter to me too much at this point... but what are the benefits from making so many files?

short forge
#

i intalled 12 eailer with nvm and it said it was 12

quartz kindle
#

if your operating system is old, then its repository also contains old versions. and node is known to be outdated in most repositories anyway

short forge
#

os is latest in terms of updates

quartz kindle
#

you installed with nvm?

short forge
#

yep

quartz kindle
#

did you do nvm use 12.x.x?

short forge
#

yep

quartz kindle
#

with whichever numbers are the latest

#

are you running pm2

#

or nodemon?

short forge
#

i don't even know

#

how would i check

quartz kindle
#

if you dont know then you're not lol

narrow kettle
#

can any of you tell me the benefits that you get from making a file for each command(that swithc does not have)

quartz kindle
#

@short forge try restarting your pi

mossy vine
#

easier to maintain

#

more organized

#

less indentation bullshit

narrow kettle
#

waht do you mean easier to maintain?

amber fractal
#

It's typically just regarded as a good practice as well.

#

Single file bots are commonly looked down upon

short forge
#

file for each command
-proper structure
-easier to understand
-if one command breaks, usually the others wont
-faster and more efficient
-more organized

narrow kettle
#

when you say one command, do you mean lets say, !help (!help commands, !help donations, !help developers, !help bugs...on and on)
or literlly just one of them as !help commands or one of the other once

quartz kindle
#

faster and more efficient thats not necessarily true

amber fractal
#

Each file can export a help object

narrow kettle
#

you mean just one help command?

#

or the whole help catagory

amber fractal
#

My commands have a run, aliases and help

quartz kindle
#

you can do it however you want

amber fractal
#

You can sort the help by category, single command, or nothing and it will just show all

#

It's all modular too

narrow kettle
#

i think i will go with a file for each catagory cuz i know i will have well over 100 commands and my bot would look fkd up if i do a file for each command?

short forge
#

command handlers are probably faster since it's not a check every message kinda thing (sort of)

quartz kindle
#

my handler doesnt have aliases, because i dont see a need for them

short forge
#

remember the sort of is important

quartz kindle
#

you cant not check every message lol, all handlers do that at some level

narrow kettle
#

even tho, i will still need to use switch for each catagory, it would just be like 10x smaller switch then the one i have now

warm marsh
#

Switch per cat?

amber fractal
#

You can have one folder per category, and one file per command in that folder

narrow kettle
#

switch per catagory

amber fractal
#

That's a good practice too

narrow kettle
#

cuz rn i have one switch for the whole bot

warm marsh
#

I know, You don't require to make a switch though.

narrow kettle
#

then?

#

isnt it way easier with switch?

quartz kindle
#

@narrow kettle what you're refering to as category is just the command itself right? like !command

#

we refer to that as command, and whatever comes after as arguments

#

!thisisacommand thisisanargument

#

we dont usually make separate files for arguments

narrow kettle
#

lets say the whole !help catagory(!help commands, !help developers, !help donations...) or !market(!market list, !market buy)....

quartz kindle
#

but depends on what the commands to anyway

narrow kettle
#

that what i mean as a catagory

warm marsh
#

Yeah, That doesn't require a switch though.

quartz kindle
#

thats what we refer to as "command"

narrow kettle
#

oh, i was thinking that you mean just ONE command, like !market list

quartz kindle
#

i would refer to that as "market command" with a "list" argument

narrow kettle
#

but its still fine if i use switch for each catagory right? (each diffrent command file)

quartz kindle
#

whatever you want to do, all is fine

#

all of this falls into preference mostly

narrow kettle
#

im new to java script so its not like i know too much about other commands

#

so i will probobly stick to that for now, thanks guys!

quartz kindle
#

my first bot was also a gigantic chaotic file, everything felt much better after i started splitting the code into smaller files

#

its something you do to feel good about it, and feel more organized, not to please anyone, and not for performance reasons

narrow kettle
#

i feel like even after spliting it all it would still be some how chaotic but meh, at least less chaotic then just one file

quartz kindle
#

its still a step forward, slowly you learn how to organize it more efficiently

narrow kettle
#

do any of you have guilds about how to make "items", "charcters" and such on discord.js

#

or a big project like this would realy be no good as first project?

quartz kindle
#

guilds?

narrow kettle
#

yeah, guildsm tutorials, what ever teach me how to do it

warm marsh
#

RPG esk games?

quartz kindle
#

also, there are better things to do than a switch statement

narrow kettle
#

kinda

#

like?

#

@warm marsh basicly is make a bot somewhere between @earnest phoenix and @earnest phoenix but with original content(that i thought of) and it would be based on anime

#

and ik it would be a big project so yeah... i gonna have a bad time

warm marsh
#

That would fairly easy, Just your imagination that would make it severely challenging.

#

As you can always ask for code sided help within this channel.

narrow kettle
#

i already thought about the whole bot and system, even tho i dont have any idea how to code most of it

#

like, market, monsters and warriors appering... exploring(to get items)

quartz kindle
#

one common example that most command handlers do looks like this ```js
client.on("message", message => {
// do basic checking like bots and prefixes
let cmd = message.content.slice(prefix.length).split(" ")[0]; // example for extracting the command from the message content
if(commands.has(cmd)) { commands.get(cmd).run() }
});

#

then all your commands are organized into a big Map() object

#

and you dont need a switch to check each and every one of them

warm marsh
#

Map, Aren't collections better because of their extra methods.

quartz kindle
#

you just check if the map contains it, and then run its code/file

#

collections are maps, if you need the extra features, use them

#

if you dont, then stick with maps

#

i mean, it doesnt matter, but you're bloating your code with unneeded features

narrow kettle
#

mhm

quartz kindle
#

my first attempt at a command handler was way more rudimentary than that, it was basically an array of commands

#
commands = ["command1","command2","etc"];

client.on("message", message => {
    if(commands.includes(cmd)) {
        // run command
    }
})```
narrow kettle
#

i basicly have only 3 of my most simple commands and it takes like 100 lines

warm marsh
#

Oh no.

twilit rapids
#

I mean, that works

narrow kettle
#

OH

#

thats

#

hard...

quartz kindle
#

anything that takes lots of if/else or switch entries can be converted into some sort of looping

narrow kettle
#

but luckly, i got experince with c# and java so i know programming, just dont know to much about javascript

#

so i can use stuff like [] or switch or stuff like that

twilit rapids
#

I currently loop through every file inside my commands folder, if a "command" equals one of the one in that folder it runs that command

quartz kindle
#

of course, if/else/switch are faster than loops, but you probably dont need those extra nanoseconds, and you can potentially reduce your line count by thousands of lines

warm marsh
#

Are maps faster than loops?

narrow kettle
#

loop? can you give me an example?

#

btw i dont do it for the extra speed

quartz kindle
#

maps.has() (checking if a map contains an item) is a loop. it internally loops over all items looking for a match

#

same with array.includes()

narrow kettle
#

i do it cuz im more used to it and it feels comfortable

warm marsh
#

by chance you're used to it because of Java?

narrow kettle
#

that too, but even more from c#

quartz kindle
#

of course you can also go the traditional way js for(item in array) { if item matches, do stuff }

#

or even for(i = 0; i < array.length; i++)

warm marsh
#

Probably should break if matches.

quartz kindle
#

yeah

narrow kettle
#

in my case, i had no idea where to put a certain condition in the switch, so i just putted the condition in if

#

(the prefix condition)

quartz kindle
#

thats fine

warm marsh
#

Depending on the amount of commands you have that can get very hard to keep track of.

quartz kindle
#

what im talking about is trying to match a long list of things, in your case a long list of commands in a switch statement

narrow kettle
#

my bot do feel kinda slow tho... anyreason or its just my server? (half gv ram)

quartz kindle
#

you can safely devise a way to do that matching in a loop instead of a long switch

warm marsh
#

Your bot won't use half GB ram unless you're doing something mad.

quartz kindle
#

my bot uses 60mb on 1600 guilds lol

warm marsh
#

D.Js?

narrow kettle
#

oh boi, that means i will have ot buy a server at some point

quartz kindle
#

but because i made a heavily optimized lib for it

twilit rapids
#

Cough heavily modified discord.js Cough

quartz kindle
#

yes, it runs on d.js as a base

warm marsh
#

Nice.

sage bobcat
#

One message removed from a suspended account.

narrow kettle
#

lib?

warm marsh
#

I lost all interest in bot development so I just stopped.

sage bobcat
#

One message removed from a suspended account.

quartz kindle
#

sure, its on github

sage bobcat
#

One message removed from a suspended account.

quartz kindle
#

but it may break your bot

sage bobcat
#

One message removed from a suspended account.

quartz kindle
#

lul

narrow kettle
#

yeah but how do you use it? is it like ytdl and such?

warm marsh
#

What version of base djs?

quartz kindle
#

timotejroiko/djs-shenanigans

twilit rapids
#

My bot uses 300MB of RAM on 900 servers, but it's a music bot

quartz kindle
#

v12

twilit rapids
#

While playing music on 7 servers

narrow kettle
#

brb :/