#development

1 messages · Page 450 of 1

wild tide
#

npm install ffmpeg works

earnest phoenix
quartz kindle
#

To use this library requires that ffmpeg is already installed (including all necessary encoding libraries like libmp3lame or libx264)

earnest phoenix
#

I didn't install ffmpeg

#

i just installed ffmpeg-binaries

#

And it worked

sullen path
#

ThatTonybo - Today at 9:32 PM

ThatTonybo :: Today at 10:55 AM
It's fine, fixed it myself.

earnest phoenix
#

🤔

sick cloud
#

lol

earnest phoenix
#

can anyone help me with my play command. when ever i play a song and it ends and try to play another song it says add to queue instead of playing the song can anyone help me?
heres the code:https://hastebin.com/egerexofez.js

earnest phoenix
#

don't use ytdl

#

i think it doesn't work anymore

shy rose
#

works rn for me

earnest phoenix
#

it didnt work for me a few months ago

#

maybe it got updated

shy rose
#

it can break time to time with YT as noted in there package

earnest phoenix
#

I'd rather make my own player

shy rose
#

¯_(ツ)_/¯

#

jsut means whenever yt updates you need to update for it

earnest phoenix
#

I need help with json file writing

#

yeah ik

shy rose
#

js?

#

@earnest phoenix what lang?

quartz kindle
#

whats the problem rax?

earnest phoenix
#

yea discord.js

#

so

#

I'm doing a money system

#

and I have a json file for it

tepid thorn
#

everyone used discord.js for their bot?

earnest phoenix
#

but it's not writing the money

#

use a database

quartz kindle
#

im using discord.js yes

shy rose
#

makes it easy

earnest phoenix
#

json is unreliable for such things

quartz kindle
#

depends on how you use it

earnest phoenix
#

I have jsonfile

quartz kindle
#

my bot uses json

shy rose
#

oh for that system should use a db

earnest phoenix
#

db?

shy rose
#

write locks will get you

#

db = data base

earnest phoenix
#

if your money system is very simple u can use jsob

#

json*

#

oh yea

#

but i wouldn't recommend it

#

I have a db

#

but its a json db

#

inside the dir

shy rose
#

uh

earnest phoenix
#

¯_(ツ)_/¯

shy rose
#

you wot

earnest phoenix
#

specially because it can get messy while multiple writes occur

#

¯_(ツ)_/¯

shy rose
#

write locks

earnest phoenix
#

most bots out there use dbs

#

you should too

#

My bot doesn't have many users

shy rose
#

db's are pretty easy to rig

earnest phoenix
#

idk how though

#

so you're saving data to a json file @earnest phoenix

shy rose
#

some hosting platforms even provide a lil weak one

earnest phoenix
#

correct

#

yes

#

what's your problem then?

#

this is just for testing

quartz kindle
#

the trick with a json database is to limit i/o operations as much as possible, for example, when your bot starts, load the entire file into memory and keep it there and do transactions in memory. only save to json when you need to save new information, and even then if that happens many times, put it in a timer so it only does so every once in a while

earnest phoenix
#

the data isn't writing to the json file

quartz kindle
#

and always always keep json backups

earnest phoenix
#

show code?

#

ok

#

Are you using node

#

ignore the messiness

#
client.on('message', async message => {
  const prefix = jsonfile.readFileSync("memory/coins.json")[message.author.id]
    if (message.content.startsWith("snipers beg")) {
   let prefixNew = 400
    try {
    let res = jsonfile.readFileSync("memory/coins.json");
    res[message.guild.id] = prefixNew;
    jsonfile.writeFileSync("memory/coins.json", res);
      message.channel.send("Coins successfully changed!");
    } catch (e) {
      message.channel.send("An error has occured.")
    }
  }
  if (message.content === "snipers coins") {
                         message.channel.send(jsonfile.readFileSync("memory/coins.json")[message.author.id])
                        }
}

                );
#

also the money is set to 400 at the moment

#

what's jsonfile?

quartz kindle
#

see thats a bad practice right there

shy rose
#

jsonfile is a lil module that makes working with json ezy

earnest phoenix
#

is that a fs variable

#

oh

#

idk why its not writing

#

Well i havent heard of it before

quartz kindle
#

you're doing 4 disk operations in that code

earnest phoenix
#

I have the exact same thing for prefixes

quartz kindle
#

dont do that ever

earnest phoenix
#

and it writes

#

wot

#

4 disk operations?

quartz kindle
#

yes

shy rose
#

read file is a disk op

quartz kindle
#

you're opening the file multiple times

#

dont do that

earnest phoenix
#

true

#

that uses memory

#

but i mean

#

welp

quartz kindle
#

do it like this

earnest phoenix
#

If your bot is small

#

Shouldn't hurt much

#

my bot is tiny

#

no i meab

#

How many servers use it

#

14

#

oof

#

are you running on localhost

#

no

#

vps

heady zinc
#

scale doesn't matter, you should always aim for the most performant code

earnest phoenix
#

hm

shy rose
#

best code now means less re factoring later

heady zinc
#

^

earnest phoenix
#

welp

#

idk how to do this database thing

#

I like me some good code but for small bots perfection is not rly needed

shy rose
#

like i jsut had to re write my entire bot due to lib having mem leaks

earnest phoenix
#

My hits are full of bad code i bet

#

But i don't mind em

shy rose
#

they add up thou

earnest phoenix
#

yes

#

whats a good free database?

#

I'd recommend using fs to write to json

#

not whatever lib ur using

#

lol

heady zinc
#

yee that's the same way of thinking than "i don't need to prepare about sharding now, my bot is too small" but then when you need to do it you do twice the work you would have done if you had prepared for it right away

earnest phoenix
#

mongo, mysql...

#

mariadb, postgres

shy rose
#

mysql is best imo

earnest phoenix
#

I use mariadb and mongo

#

mariadb is a fork of mysql btw

quartz kindle
#

@earnest phoenix do something like this (dont copy and paste, read to understand whats going on and why)

  const coins = jsonfile.readFileSync("memory/coins.json") //load file once

client.on('message', async message => {
    let prefix = coins[prefix]
    if (message.content.startsWith("snipers beg")) {
   let prefixNew = 400
    try {
    coins[message.guild.id] = prefixNew;
  save(coins);
      message.channel.send("Coins successfully changed!");
    } catch (e) {
      message.channel.send("An error has occured.")
    }
  }
  if (message.content === "snipers coins") {
                         message.channel.send(coins[message.author.id])
                        }
}

                );

function save() {
    code to save file only when you need to
}```
earnest phoenix
#

ok

#

basically you load the json file once, change it and save it

#

ill look at it thoroughly

#

If u need help just say so dblSmile

quartz kindle
#

also, always make backups of json files, if you do anything wrong, you will lose everything because node will save an empty json if the json data has an error

earnest phoenix
#

so the save function would be part of what is in my current script?

#

I'm not an expert but i like to help

#

the saving part

#

Rip json

quartz kindle
#

yes, you can make a separate save function to write to disk, and call it only when the coins object is changed

#

this way the database is in memory, and the json file is only used for persistence, like a backup of the memory

earnest phoenix
#

so the json file will always be opened in memory basically

#

am i correct

#

and perform actions when needed

quartz kindle
#

not the file itself, but the contents of the file yes

earnest phoenix
#

shouldn't it be let prefix = coins[message.author.id]?

quartz kindle
#

yes, just put prefix for you to get it yourself

#

using your own names

earnest phoenix
#

yea yea yea ik

#

also i have a quick question

#

how would i do a regexp for removing white spaces?

#

i can do a case insensitive regexp

#

but i want to remove whitespaces

quartz kindle
#

all whitespaces or only excessive white spaces?

earnest phoenix
#

all

quartz kindle
#

something like replace(/\s/g,"")

#

idk from memory, regex is weird af to remember

earnest phoenix
#

nice, cuz I'm trying to do a mongodb query that searches for data and it's easier to make sone regexps for it

quartz kindle
#

but basically use the whitespace selector and the /g flag to target all instances

#

and replace all with nothing

earnest phoenix
#

Cool

#
const coins = jsonfile.readFileSync("memory/coins.json")

client.on('message', async message => {
  let prefix = coins[message.author.id]
    if (message.content.startsWith("snipers beg")) {
   let prefixNew = 400
    try {
    coins[message.guild.id] = prefixNew;
    save(coins);
      message.channel.send("Coins successfully changed!");
    } catch (e) {
      message.channel.send("An error has occured.")
    }
  }
  if (message.content === "snipers coins") {
                         message.channel.send(coins[message.author.id])
                        }
}

                );
function save() {
  jsonfile.writeFileSync("memory/coins.json", coins);
}
#

this look any better?

quartz kindle
#

yeah, looks good

#

of wait

#

function save(coins)

#

else the coins inside the function will be undefined

earnest phoenix
#

ok

#

wait

#

so

#
function save(coins) {
  jsonfile.writeFileSync("memory/coins.json", coins);
}
#

?

quartz kindle
#

yes

earnest phoenix
#

ok thanks

#

GWsplOof not working

#

Show code again

quartz kindle
#

any error?

earnest phoenix
#

found

#

the problem I think

#

lemme see if its fixed

#

ayy

#

thanks guys

#

Good luck

#

now I just need to make it so that it sets the users coins to 0 if they don't have any data in the json file

#

else when they type snipers coins it doesn't send a message

#

wait

#

I think ik how

quartz kindle
#

alright, remember to be careful with your json files and always keep backups

#

i've had my fair share of my bot crashing and finding myself with empty json files

#

lmao

earnest phoenix
#

sucks xd

#

that's why databases are safer for these tasks

#

if something goes wrong at least the entire table won't be erased

#

Lol

#

so I just save the file like once a day?

#

or auto backups?

quartz kindle
#

yeah, i'll switch to a real db eventually, but for now json is fine. i made a function to save a backup copy and to load from the copy in case the json breaks

earnest phoenix
#

cool

#

you can set your bot to auto back it up i believe

#

yes

#

then if it detects all the data changing to 0 or something then it will stop backing up

#

idk

#

¯_(ツ)_/¯

#

You mean when it crashes

#

yea

#

oof

#

if it does crash your data may be gone

#

I'm stuck

#

That's the risk

quartz kindle
#

if the json is empty, the json loading function should return an error

#

because even an empty json needs to contain {} to be compatible with json

#

and a broken json doesnt

earnest phoenix
#

JavaScript objects are defined by {} so it makes sense

#

Since it's based on that

quartz kindle
#

yeah thats what json stands for

#

javascript object notation

earnest phoenix
#

Yup

#

fixed it

#

aka better than xml

quartz kindle
#

xD

earnest phoenix
#

math.random a thing in js?

#

cbb searching it up

quartz kindle
#

yes

earnest phoenix
#

ok

quartz kindle
#

math functions are with capital M

earnest phoenix
#

it's a math lib sort of

#

so Math.random?

quartz kindle
#

Math.random()

earnest phoenix
#

ye ik

#

Math.random(22,30)

#

would that work?

#

what do you want it to do

quartz kindle
earnest phoenix
#

umm

#

ok then

#

I need it to pick a number between 22 and 30

quartz kindle
#

js is awesome because you can literally press F12 in any browser and test js code directly in the console

#

Math.Random always returns a number between 0 and 1

earnest phoenix
#

oh

#

Thonk how do I get between22 and 30 fro m random between 0 and 1

#

so I need to then times it?

quartz kindle
#

yes

earnest phoenix
#

divide it by 0 ofc

#

ok

quartz kindle
#

Tom trying to end the world

earnest phoenix
#

tru

#

it gave infinity XD

#

how do i return a number smaller than 1 but bigger than 2 using js

#

Math.random(0,1) * 100

#

seems to work

quartz kindle
#

no need for the 0,1

earnest phoenix
#

ok

quartz kindle
#

smaller than 1 but bigger than 2?

earnest phoenix
#

gotta use splice

#

Lol

quartz kindle
#

lmao

earnest phoenix
#

It was a joke

#

so I don't have those nasty numbers

#

nodemon is pretty useful tho

#

Finally decided to install it

quartz kindle
#

you can use parseInt() to remove decimals

#

or toFixed(), but toFixed turns it into a string

earnest phoenix
#

integers inside strings lol

#

well numbers

quartz kindle
#

yeah a string of numbers

#

most math functions will work on strings, except +

#

"10" - "5" = 5
"10" + "5" = "105"

#

xD

earnest phoenix
#

where do I put parseInt()?

#

also i need some "help" with async

#

when i'm sending the message?

#

thats cos - will coerce types

quartz kindle
#

parseInt(number)

earnest phoenix
#

ok

#

since u cant substract strings so it assumes its number

quartz kindle
#

^

earnest phoenix
#
let number = Math.random() * 100
let prefixNew = parseInt(number)
#

?

#

that?

#

no need to parse it

quartz kindle
#

thats a trick people use to convert strings to numbers, they do something like string*1 because its shorter than Number() or parseInt()

earnest phoenix
#

+string

#

I'm confused

quartz kindle
#

i told him to parseInt it

#

because he doesnt want decimals

#

from the math.random

earnest phoenix
#

eh

#

it works

#

yay

#

are u guys experts on async functions

#

no

quartz kindle
#

not really lmao

earnest phoenix
#

lol

#

i wanna make sure im doing this one function correctly

quartz kindle
#

send it away

earnest phoenix
#

k

#

if u wanna remove decimals use bitwise operators

#

fastest method

#

or math.floor

#

parseint is terrible

#
var init = async () => {
    var app = new hapi.Server()
    app.connection({
        "host": "localhost",
        "port": 3000
    })
    await app.start()
    mongoose.connect(url, {
        "useNewUrlParser": true
    })
    dbo = mongoose.connection
    loadRoutes(app)
}

init()```
#

its working

#

but yeah

#

im new to async

quartz kindle
#

hey if it works it works

earnest phoenix
#

ik this is easy to do

#

but my brain isn't working rn

#

its not adding the coins on

#

just changing the coins

quartz kindle
#

and yeah, Tom is right, Math.floor/round/ceil are much faster than parseInt

earnest phoenix
#

I need help

quartz kindle
#

i forgot about those for a moment

earnest phoenix
#

send code

#

my brain isn't working

#

ik this is really easy

#

but my brain is being stupid af

#

ik why this is happening

#

I just dk how to fix it

quartz kindle
#

from your previous code let prefixNew = 400 will always replace the value

earnest phoenix
#
function save(coins) {
  jsonfile.writeFileSync("memory/coins.json", coins);
}
``` is changing the coins, not adding on
#

ah

#

you're updating the values to 400, not adding 400

#

i think

#

yes

#

but I don't remember how to add the values together

#

you'd have to do coins + 400 or smth

quartz kindle
#

+=

earnest phoenix
#

and save it

#

yeah +=

#

no

#

my script is different now

#
const coins = jsonfile.readFileSync("memory/coins.json")

client.on('message', async message => {
  const currentprefix = jsonfile.readFileSync("memory/prefix.json")[message.guild.id]
  let prefix = coins[message.author.id]
    if (message.content.startsWith(currentprefix + "beg")) {
   let number = Math.random() * 100
   let prefixNew = parseInt(number)
    try {
    coins[message.author.id] = prefixNew;
    save(coins);
      message.channel.send("Here, have " + prefixNew + " coins!");
    } catch (e) {
      message.channel.send("An error has occured.")
    }
  }
  if (message.content ===  currentprefix + "coins") {
                         message.channel.send('You have ' + (coins[message.author.id]) + ' coins (If it says undefined it means you have no coins)')
                        }
}

                );
function save(coins) {
  jsonfile.writeFileSync("memory/coins.json", coins);
}
#

idk what part to change

#

well

quartz kindle
earnest phoenix
#

depends on whats not working

#

u said its not adding

quartz kindle
earnest phoenix
#

tim posted the fix

quartz kindle
#

lmao

earnest phoenix
#

read the file once when you load the bot, and save it whnev you need. dont read the file every time pls

#

ignore that lol

quartz kindle
#

we just told you not to do that

#

xD

earnest phoenix
#

shut up

#

lol

#

ill do that later

#

i need to work on this rn

#

lol

#

2muchiq

quartz kindle
#

anyway

earnest phoenix
#

im still confused

quartz kindle
earnest phoenix
#

ok

quartz kindle
#

you get the old value, and save it while adding the new value to it

earnest phoenix
#

yea

#

thats what I was trying to do

#

but as I said

#

my brain broke

quartz kindle
#

or if you want to make it more readable:
let final = prefix + prefixNew;
coins[message.author.id] = final;

#

or something like that

earnest phoenix
#

still broken

#

restart brain process

quartz kindle
#

go slep

earnest phoenix
#

no u

#

node brain.js

quartz kindle
#

actually, its 1am here, i need sleep

#

go figure it on your own lmao

#

you can do it

earnest phoenix
#

just eat some snickers

#

and youre good to go

#

you'll be typing js so fast and so well

#

THIS

#

ISN'T WORKING

#

Just use a database..

#

It's much easier

#

but thats not the problem

#

its the adding system

#

if you use a database none of that'll be a problem

#

It's super easy to increment integers

#

So making a money system is a piece of cake

#

You can make your own in like what 2 hours

#

Without having to worry about it ever again pretty much

#

but I wanna get this right

#

😄

#

I got it working

#

nice!

wild tide
#

I can't get the bot to check if a member has a role on another guild. The bot is on both servers.
Here is the code I wrote

var accepted = false


const checkguild = client.guilds.get("id-hidden-is-correct");

const acceptedRole = checkguild.roles.get("id-hidden-is-correct");

    if(message.member.roles.has(acceptedRole)){

        accepted = true

        message.channel.send("Accepted!").catch(error => console.log);

    } else if(!message.member.roles.has(acceptedRole)){

        accepted = false

        message.channel.send("Denied!").catch(error => console.log);

    };```
#

I am really confused

#

It says Denied, even if you have the role every time

#

The command should check the author, no args or mentions for other users

latent heron
#

whta lang is this

#

php?

wild tide
#

discord.js

latent heron
#

oh

#

wow

hasty terrace
#

--avatar

#

hm

wild tide
#

no bot commands here

jovial sigil
#

Does anyone know how to build a url for an image stored on the server the bot is hosted on? im trying to create an embed (with discordjs) that has a thumbnail, but its asking for a url.. a filepath doesn't work

earnest phoenix
#
// Send an embed with a local image inside
channel.send('This is an embed', {
  embed: {
    thumbnail: {
         url: 'attachment://file.jpg'
      }
   },
   files: [{
      attachment: 'entire/path/to/file.jpg',
      name: 'file.jpg'
   }]
})
  .then(console.log)
  .catch(console.error);

from https://discord.js.org/#/docs/main/master/class/TextChannel?scrollTo=send
literally in the examples

wild tide
#

upload your image to a file website, you can make one your own pretty easy. Just upload your image there and use the url

jovial sigil
#

i tried the above example but it just spits out the image outside of the embed instead of inside

#

file website as in tinypic, etc?

#

i have about 500 images

wild tide
#

yes

jovial sigil
#

wouldn't be fun

wild tide
#

try Google Drive or something

jovial sigil
#

hmm

wild tide
#

then just rightclick the image, and click "Copy Image Address"

sick cloud
wild tide
#

^^

jovial sigil
#

i see okay

#

thanks

wild tide
#

No one answered my question as well anyway

#

I assume no one knows how to do it anyway lol

earnest phoenix
#

help-me?

#

how do I have a subdomain on the site?

#

Hey sorry to be a pain but does anyone know how to integrate html into your bot like MEE6 or Saftey Jim does to give it a slick look when it says something?

fluid basin
#

any examples that you might be referring to?

earnest phoenix
#

like having this box

fluid basin
#

oh those are called embeds

#

May I know what coding language/ discord library that you are using so I can give you some useful resources?

earnest phoenix
#

python3

fluid basin
#

oh I see

earnest phoenix
#

thanks I will have a look anyways. What language do you use for your bots? Java?

fluid basin
#

I mostly use NodeJS so I don't think I can go down with the details for python, yeah but I'll try my best to help

earnest phoenix
#

thats fine was just curious thats all

earnest phoenix
wild tide
#

oh thats smart

#

using linux and hosting from there

earnest phoenix
#

indeed @wild tide

warm sleet
#

Hmm nice choice. Linux mint

full pivot
#

how do make a bot?

earnest phoenix
#

Learn

#

I learned from evie.codes on YouTube

full pivot
#

thx hooh waaw

earnest phoenix
#

...

full pivot
#

k im bringin that back

wild tide
#

how to sprint

quiet bobcat
slender thistle
marble terrace
#

Pkay

earnest phoenix
#

question how do you do the server status thing

#

Like Dyno's serverinfo?

earnest phoenix
#

why can i type here

neat falcon
blazing gorge
#

Nope

fossil pagoda
#

I feel like making a bot...

zenith vector
#

Hi

neat falcon
#

ok found the error

earnest phoenix
#

Lurn dude

zenith vector
#

I want to, but IDK how

neat falcon
#

latest node goes oof btw

simple bramble
#

in discord.net, whats the task used to put a "rating" (like a rate this 1-5) in an embed, and you choose which number it is

fossil pagoda
#

Called.... Um.... Aha! PastelBot!

zenith vector
#

?

neat falcon
#

original name i like

earnest phoenix
#

Can I get some help with a library?

zenith vector
#

Which one?

earnest phoenix
#

eris

zenith vector
#

Hmm

earnest phoenix
#

hmm

zenith vector
#

What do you need help with Eris?

earnest phoenix
#

get the amount of text/voice channels a server has

zenith vector
#

Ok

#

Lemme see

earnest phoenix
#

There are multiple ways to fetch that

zenith vector
#

Lemme see

#

Internet problems btw

#

That's why I'm sending double messages

#

😂

earnest phoenix
#

ik there are multiple ways

#

I just dont know how i get to the actual part

#

🤔

zenith vector
#

:GWfroggyBlobWokeThink:

earnest phoenix
#

I tried msg.guild.channels.filter

#

I don't use Eris but that doesn't sound right

zenith vector
#

Idk stuff bout eris

#

But I'll try

#

Idk

#

I'm still learning 😂

#

IDK tbh roman

#

@earnest phoenix it's hard

earnest phoenix
#

ehh

zenith vector
earnest phoenix
#

what

slender thistle
#

what

zenith vector
#

What??

slender thistle
zenith vector
#

Cause idk

#

Someone might know there

earnest phoenix
#

ill just ask here again later

zenith vector
#

Lol ok

slender thistle
#

If someone knew and had a will to help, they would already be here and helping

zenith vector
#

Idk so ye sorry

earnest phoenix
#

@earnest phoenix have you tried googling it

#

yes

zenith vector
#

I have as well

slender thistle
#

Okay, now my question:
Is it better if I open SQLite3 connection upon bot start or should I consider opening the connection when the command is used?

zenith vector
#

Hmm

earnest phoenix
#

bot start

#

And leave it open

zenith vector
#

Ye

slender thistle
#

Time to get rid of my 3 database files then

#

:p

zenith vector
#

have you tried Google it

#

?

slender thistle
#

#Lazy :^)

earnest phoenix
#

opening a database and closing on command trigger is bad

#

like pretty bad

deep inlet
#

@earnest phoenix Guild.channels.filter(c => c.type === 2).length

earnest phoenix
#

dont forget the msg.guild part

zenith vector
#

Lol

deep inlet
#

...

zenith vector
#

Google's answer

deep inlet
#

Nao, Guild with a capital G means a guild object

earnest phoenix
#

But he wanted to get a guild object from a message

deep inlet
#

...

zenith vector
#

What?

#

....

deep inlet
#

It's still a guild object

earnest phoenix
#

Yes

zenith vector
#

Hmhm

earnest phoenix
#

But i just thought it's better to clarify

deep inlet
#

Tru

earnest phoenix
#

mets

deep inlet
#

Yeah?

earnest phoenix
#

2 is?

deep inlet
#

2 is Guild_Voice

earnest phoenix
#

and 1 is text?

deep inlet
#

1 is DM

earnest phoenix
#

oh thanks

deep inlet
#

0 is Guild_Text

earnest phoenix
#

yeah lol why are dms channels

#

Does that mean we're all guilds? zoomeyes

#

¯_(ツ)_/¯

deep inlet
#

Wanna hear something weirder?

#

The channel ID you use to DM someone is not the same ID they use to DM you

earnest phoenix
#

wow

#

you mean the used id

deep inlet
#

Not the userID

earnest phoenix
#

Oh nvm

#

yeah

#

i get it

#

met mind if i ask one more thing?

deep inlet
#

Hm?

earnest phoenix
#

to change my bots username would i need to send a patch request?

#

or does the lib cover it?

#

djs does that so should eris

deep inlet
#

I think there's a function for it, but I think the new Discord Dev Portal allows renaming there

earnest phoenix
#

since?

#

you can rename your bot from the dev apps dite

#

site*

#

oh

#

I've tried it but it didn't update it

#

I couldn't before

deep inlet
earnest phoenix
#

so i use discordjs to change it

#

just the application name

#

yeah

deep inlet
#

That was for the old page

earnest phoenix
#

how did i not notice that

deep inlet
#

The new Dev Portal allows it

earnest phoenix
#

Not the actual username

ruby dust
#

the updated developer portal now has a way to update both application and bot names

deep inlet
earnest phoenix
#

when did that dev portal got updated

#

hm

#

well thanks mets

deep inlet
#

Np

#

Thank you for using the better JS lib

earnest phoenix
#

Ah it's different

#

Why is it the better?

#

@deep inlet 🤔

deep inlet
#

Because it is

earnest phoenix
#

hm

deep inlet
#

:)

earnest phoenix
#

what are the advantages?

#

There's no better lib reeee

deep inlet
#

It's kinda hard to explain, you need to use both libs to see the dif

earnest phoenix
#

just use what fits you the best

#

I just noticed discord js is more beginner friendly

deep inlet
#

I converted introduced it to 2 of my friends and they love it

#

Here's an advantage: DJS doesn't help you get better at JS

#

Eris does

earnest phoenix
#

they're both nodejs modules

#

yeah thats the thing

#

so in the end it dont matter

deep inlet
#

And this is a thing

earnest phoenix
#

mets if i need help again can i ask you?

deep inlet
#

Sure, just mention

earnest phoenix
#

ok

#

@deep inlet just because noobs use djs that doesn't mean you shouldn't?

#

as long as you like it

deep inlet
#

Did you not read the image I sent?

earnest phoenix
#

I read some

#

The first three paragraphs

#

yep

#

whats TCD?

ruby dust
#

I personally don't understand how js, or d.js, can be easier than python, maybe i'm just too used to python from the beginning

deep inlet
#

The Coding Den

earnest phoenix
#

well they are very different

deep inlet
#

A Discord community for (pretty much) all languages

earnest phoenix
#

oh

#

JavaScript in itself runs on the client side only

deep inlet
#

And there's also DAPI (Discord API) for most Discord libs

earnest phoenix
#

Node runs server side

#

Node is great for me because i already knew some stuff about JavaScript

#

So i avoided learning php for example

#

It saves me time

#

And a lot of headache probably

#

Anybody know a good D.JS NSFW API? I cant seem to look it up on google as my ISP blocks ponrographic content 😂

#

wat

#

you mean a image api?

#

Yes. But NSFW Images

#

...

#

idk

#

¯_(ツ)_/¯

#

@deep inlet Im getting errors 😦

deep inlet
#

What errors?

#

And what's the line that's erroring?

earnest phoenix
#

if i do msg.guild

deep inlet
#

msg.channel.guild

earnest phoenix
#

oh

#

let me add that

#

Anyone?

#

seems to work now

#

Beefy even if i did

#

I dont think i can share them here

#

Why cant you?

#

umm

#

"nsfw"

deep inlet
#

XD

#

Idk why people even have specifically pornographic bots on Discord

#

Like, just no

earnest phoenix
#

they get quite popular

#

There ya go

#

?

#

you found 1?

#

What you said lol

#

no

#

Do you really need one?

#

I want one yes

#

lol

deep inlet
#

Maybe if you search it on your school computer you'll get better results GWfroggyWeSmart

earnest phoenix
#

true

#

hehe I dont go to school noob

#

lol

deep inlet
#

Makes sense

earnest phoenix
#

mets what lib did you use?

#

😐

deep inlet
#

Eris, why?

earnest phoenix
#

just wondering

#

@earnest phoenix djs nsfw api??

#

lol

#

Yes

#

You mean a nsfw rest api

#

not djs

#

idk 😂

#

But I do

#

google it

#

sure you do

#

discord.js doesn't have nsfw apis

#

Beefy im just wondering but what category of images?

#

Djs only connects to discord api

#

k

#

and if his isp blocks nsfw he has to use a proxy

#

and i thought my isp was shit, what kind of isp blocks porn

#

...

#

All my isp blocks is piratebay and its proxies

#

Sky Broadband apparently 😂

#

that's in the usa correct

#

UK

deep inlet
#

Who is your ISP, Nao?

earnest phoenix
#

@earnest phoenix same timezone lol, but rip eu

#

mine?

#

mets i gtg its quite late

deep inlet
#

Uhhh

#

Ok?

earnest phoenix
#

NOS, @deep inlet

deep inlet
#

Never heard of it

earnest phoenix
#

Okay, what the hell do I search on Google to get the API thing? I searched up NSFW rest api and idk what it all is 😂

#

it's the biggest provider here

deep inlet
#

Verizon ftw baybeeeee

earnest phoenix
#

i live in portugal, you know that small ass country that everyone thinks belongs to spain

#

Lmao

#

All our isps only block sites like piratebay really

#

I've never heard of an isp blocking porn sites lol

#

Sky Shield is the server that protects it

#

You can always pay for a vpn

#

I think the best thing to do is go to Google Images and search up porn gifs... I can seem to find the thing im looking for

#

Rofl

#

You're trying to make an nsfw command for your bot or something?

#

Yes

#

an NSFW Module

#

Hm

#

Do you mean a node module

#

I want something, that is simple, that would post NSFW Images whenever a command is used.

#

Thats all I want

#

Do you know how to make http requests

blazing gorge
#

??

earnest phoenix
#

there's no nsfw modules for node

#

Using the request module?

#

yes

#

For example

#

Think ill figure it out

#

It's easy

#

I have the yo momma command using a request api thingy

#

You can try making requests to reddit

#

bet they have a bunch of nsfw there

#

hmm

#

How do NSFW Bot and BoobBot Get theirs then?

#
#

I don't know those bots

#

But usually the way these commands work is that they make http requests to a website

#

And return the data, then send it as message

#

ok

#

do you have programming experience?

#

Not a lot but quite a bit

#

If you don't then this stuff will be confusing

#

I mean you were asking for nodejs nsfw modules

#

Lol

#

lol

#

I managed to find porn images on tumblr, can I do anything with that?

#

@earnest phoenix

#

that's a library for nodejs which allows you to interact with the tumblr api

#

ok

#

should be easier than making http requests through Request

#

As i said if you're new to coding then this'll be confusing

#

Meh, Ill see if I can grab some gifs images etc off google images and make a huge collection of them 😂

#

Then post a random one on command

#

if you have the space and are willing to save that stuff on your drive

#

then sure

#

lol

#

Would it be worth it though?

#

you said you wanted a nsfw command, that's the easiest way to make one

#

Okay lol

#

but you have to save the pics somewhere and have access to them

#

Ill just put their links in a .json file and name them from 1 to however many I have.

#

I could also simply steal some from other bots 😂

short siren
#

I'm about to buy a VPS of time4vps but not sure how to set it up because not sure if it comes with windows or linux or somin if u know plwezzz dm me lol

earnest phoenix
#

Use Google VM

#

does the os really matter

#

Google Platform

short siren
#

Not sure how to do it lol tho

earnest phoenix
#

If you're building a discord bot then it doesn't matter much

short siren
#

Yes

#

But im not sure how to do itt

earnest phoenix
#

unless you're using a really old os version

#

Like windows xp

quick ivy
#

Discord.js
Should this work? I saw the 'activity type' thing on a reddit thread.

#
client.on("typingStart", function(channel, member){
    //client.user.setActivity(type === "WATCHING");
            client.user.setActivity("you type.");```
#

Disregard!

#

client.user.setActivity(`you type`, {type: "WATCHING"})

warm prairie
#

Yeah I was going to say... lol

quick ivy
#

Is there a limit for how often, or how many times in x minutes it can change activity?

earnest phoenix
#

use client.user.setPresence({ "status": "online", "game": { "name": "whatever" }})

quick ivy
#

It stopped doing it.

#

Hm.

earnest phoenix
#

There is a limit

#

In the discord api

quick ivy
#

Damn

earnest phoenix
#

wait

#

how do you see the names of the servers your bot is in?

ruby dust
#

you request it

earnest phoenix
#

it client.guild.size

#

but thats the number

#

wait

ruby dust
#

get a list of servers and return their names

earnest phoenix
#

ok

untold otter
#

How can I put the Server-counting on for my bot with Discord Bot Maker?

quick ivy
#

Do you guys have a suggestion for how to make my discord.js bot appear to be typing?

ruby dust
#

it should be in docs

slender thistle
#

Should I define <Connection>.cursor() after a command is used or upon bot start in SQLite3? GWfroggyBlobWokeThink

ruby dust
#

define it once on startup before defining the class

earnest phoenix
#

SmaRT PeOPle HerE

ruby dust
#

also, I noticed in discord.py there is message.mentions representing a list of members that were mentioned in the message

#

is it a list of unique mentioned members or will members repeat if they were mentioned multiple times in one message?

slender thistle
#

Seems to be unique

earnest phoenix
#

if i either:

  1. Had my laptop, or
  2. Had a microphone to use with this desktop computer
    i would impart my D.js knowledge on the VC people, but here i am, right?
ruby dust
#

this reminded me of mee6's voice recording thing feature

earnest phoenix
#

cool. i didn't know it had that. i wonder how the developers pulled that off

ruby dust
#

iirc mee6 is open source Thonk

earnest phoenix
#

yay ima go check it out rn

slender thistle
#

The code is old, afaik

earnest phoenix
#

idc

#

i can translate old code to new code

ruby dust
#

also I think mee6 is written in python

#

and some people say python can't do much

earnest phoenix
#

did i mention i built a whole social network in python?

ruby dust
#

no

earnest phoenix
#

ik\

#

i gtg eat cya

ruby dust
earnest phoenix
#

Lol

#

Always a ladder

ruby dust
#

oh wait, I also forgot to try the await mmLol

#

even further building the ladder

earnest phoenix
#

Lol gl

#

Python am i right?

ruby dust
#

yes

earnest phoenix
#

Main reason that im switching my social network to run on ruby

#

Ruby on rails to be exact

#

i was running on django, but now i am doing what my username says i am doing, running on rails lol.

upper ember
#

how do I console log

 ________      ___           ___      ___      ___  _______       ________     
|\   __  \    |\  \         |\  \    |\  \    /  /||\  ___ \     |\   __  \    
\ \  \|\  \   \ \  \        \ \  \   \ \  \  /  / /\ \   __/|    \ \  \|\  \   
 \ \  \\\  \   \ \  \        \ \  \   \ \  \/  / /  \ \  \_|/__   \ \   _  _\  
  \ \  \\\  \   \ \  \____    \ \  \   \ \    / /    \ \  \_|\ \   \ \  \\  \| 
   \ \_______\   \ \_______\   \ \__\   \ \__/ /      \ \_______\   \ \__\\ _\ 
    \|_______|    \|_______|    \|__|    \|__|/        \|_______|    \|__|\|__|
#

(nodejs)

cinder patio
#

you don't bloblul

upper ember
#

:^)

cinder patio
#

so a question for those who use other libs than discord.js: Do you have to "shard" your bot?

upper ember
#

yes

#

you should create shard.js file

#

and write in it "PLEASE SHARD MY BOT :^)"

#

and type node shard.js

cinder patio
#

I'm not asking how, just asking if other libs have a shard feature

upper ember
#

of course...

ruby dust
#

it's a discord limitation that you have to shard your bot if it gets involved in too many servers

#

"too many" means a single shard can handle up to 2.5k servers

#

but of course you can shard earlier than that limit if your bot is losing performance

cinder patio
#

aha

#

good to know

earnest phoenix
frail harness
#

because linters arent very smart

warm prairie
#

If I want to mention someone to the bot, how can I get the entire mention? right now it comes in as a string with just the '@' and either the username or nickname

split lantern
#

@warm prairie in d.js u can send the user obj or
<@userid> works everywhere

#

@warm prairie
Copy paste that

#

Will @ u

#

@warm prairie

warm prairie
#

I just want a user to be able to do @warm prairie

#

and not have to put the <>

split lantern
#

yep

#

copy that <@id>

#

when sending it it will transform to a @

warm prairie
#

thats the thing, its coming to the bot as just "@earnest phoenix"

#

woops

#

@someone

#

oh wait

#

maybe its because i'm using cleanContent

split lantern
#

yeah if you are using user inout and use cleanContent then yeah

warm prairie
#

yep, thats it. neverminddd 😃

earnest phoenix
#

can anyone her help me do the vote to access command?

blazing gorge
#

Which command u need help with?

#

@earnest phoenix

earnest phoenix
#

Hi

#

I am going to end my Discord Bot project. The bot is in over 1k servers, I want the bot to leave all 1000+ servers. How do I do this?

#

Why anyway?

blazing gorge
#

@earnest phoenix why u want to end?

#

It

earnest phoenix
#

@earnest phoenix will u be able to recover it after?

#

No

#

I don't want it to be recoverable

#

Ok

blazing gorge
#

Why?

#

What's ur bot

earnest phoenix
#

Ill claim your bot 😂

blazing gorge
#

No

quartz kindle
#

you're getting rid of a bot thats in 1k servers?

#

why not passing it on or even selling it?

warm prairie
#

w/ discord.js it seems like some promises are actionable, and some aren't. Has anyone else noticed this?

blazing gorge
#

A little for me

#

Lmao

heady zinc
#

wdym actionable

warm prairie
#

for example

// this works
guild.members.get(member).addRole(role).then(() => { /* do something */});

// this doesn't
guild.roles.get(id).delete().then(() => { /* do something */});
earnest phoenix
#

i want to see a neural network api for discord

heady zinc
#

because

#

wait what version of d.js are you using first

warm prairie
#

latest

heady zinc
#

latest stable or latest master?

earnest phoenix
#

Lol neural network for discord

warm prairie
#

^11.3.2

earnest phoenix
#

best ideas

heady zinc
#

oh latest stable then

#

are you sure it doesn't work cuteThink

warm prairie
#

Well I have an async message being sent if the promise goes through, on the addRole the message goes to the server, on the delete the message doesn't

heady zinc
#

was the role deleted though

#

the promise may be rejected

warm prairie
#

yep

earnest phoenix
warm prairie
#

I am catching them too, on the catch on all the promises I only seem to be able to use console.log()

earnest phoenix
#

My bot just crashes

night imp
#

No error?

earnest phoenix
#

Nope

#

Im using pm2 tho

night imp
#

Console.log each line to see where it fails

earnest phoenix
#

Wha?

night imp
#

See where it fails

earnest phoenix
#

Each line?

night imp
#

Of the selected code that is broken

earnest phoenix
#

How?

night imp
#

console.log("part 1 works")

earnest phoenix
#

Ah oki

night imp
#

Should help with debugging

earnest phoenix
#

Alright and ill just do node not pm2 right?

warm prairie
#

when-in-doubt console log it out

earnest phoenix
#

Ye

heady zinc
#

pm2 doesn't discard logs

#

you can still see logs with pm2

earnest phoenix
#

It seems to

#

Oh yea

warm prairie
#

should have a wait to tail them somehow

#

pm2 logs app

heady zinc
#

pm2 start <path_to_app> --name="name" && pm2 logs name

earnest phoenix
#

Uggh i just hate doing that and getting the first 15 lines

heady zinc
#

it gives you a stream

warm prairie
#

you don't have to use pm2 for local testing

heady zinc
#

and the first 15 precedent lines if you don't specify the --lines option

warm prairie
#

I would only locally use pm2 for things I don't need to constantly watch

earnest phoenix
#

Ik i just do everything in a cloud ide sincei have many local computers and i dont always have access to all of them

#

And that ide is directly hooked up to my vps

warm prairie
#

thats what github / bitbucket is for

earnest phoenix
#

And thats what parents Are for... to tell you to GET OFF RIGHT THIS INSTANT!!!

warm prairie
#

can't help ya there

earnest phoenix
#

in other words, github/bitbucket take too long

magic bane
#

Take too long? :0 I have all my bot code hosted on GitHub

earnest phoenix
#

oki. i give up. i guess i just have very different preferences than everybody on every discord server i go to.

warm prairie
#

¯_(ツ)_/¯

earnest phoenix
#

¯_(ツ)_/¯

#

idc anymore

pale bison
blazing gorge
#

?

pale bison
#

im trying to say that some images load and some don't

warm prairie
#

not for me either

cunning orchid
#

@earnest phoenix What's the issue you're having with the command?

blazing gorge
#

Lol

#

Nvm

#

I can see them

earnest phoenix
#

here:

#

this is what i have:

snekfetch.get(`https://discordbots.org/api/bots?limit=1&search=username:${args.join('+')}`).then(res => {
if (res.count != 1) return msg.channel.send(`Couldn't find a bot that matched the query \`${args.join(' ')}\``)
    return msg.channel.send(`https://discordbots.org/api/widget/${res.results[0].id}.svg`)
  })

cuz search param can contain many fields

blazing gorge
#

;-;

earnest phoenix
#

@cunning orchid

cunning orchid
#

I think that the best way to do it is to just pick one field to search by

#

have the command always search by username or by description or whathaveyou

sick cloud
#

you know snekfetch has .query

earnest phoenix
#

i did. i picked one field i just limited it to one result

sick cloud
#
const { body } = await snekfetch.get(`https://discordbots.org/api/bots`).query({ limit: 1, search: `username:${args.join(' ')}` });
peak chasm
#

do i need to put my bots code on github to become certified?

sick cloud
#

@peak chasm, no.

earnest phoenix
#

lol no

cunning orchid
peak chasm
#

just asked because of

Original code, not a fork of a bot with a new name.
#

thought u guys would want to check the code

unkempt ocean
#

is someone help me for this

#

data.dispatcher.once('end', function() {

earnest phoenix
#

Why does this look really strange on mobile discord

Admin's rgb has been turned on 🎄

It is embbeded as a title and it is blue on mobile and the 🎄 part just comes out as text

unkempt ocean
#

end is not working for music bot

#

finish and finished not worked too

sick cloud
#

@earnest phoenix, not a question for development, but it's because mobile emojis and UI are different.

unkempt ocean
#

I think I fixed it

jade tulip
#

How do i add commands, This is my first time doing this....

earnest phoenix
#

Learn how to code

jade tulip
#

I know how to code .-.

earnest phoenix
#

lul then knock urself out

sick cloud
#

Then learn the lib your using properly.

jade tulip
#

Gg

warm prairie
#

isn't snekfetch deprecated?

earnest phoenix
#

no. D.js even uses it

warm prairie
#

npm begs to differ

earnest phoenix
#

I use Request for sending http requests

#

@sick cloud what i do not understand is that bots like saftey jim doesnt have it being blue

sick cloud
#

They use the author field probably, the title field is always blue on mobile (android at least iirc).

earnest phoenix
#

it is

#

On embeds

ruby dust
#

can more than one running program have a separate connection to the same database file? I'm using sqlite3, to be exact

sick cloud
#

do you know about using codeblocks

#

```
code
```
they're more readable

unkempt ocean
#

soory let me fix

#

ops wait

peak chasm
#

sorry one more question regarding the certification. does the bot have to be part of the list for more than 3 days or me?

pale bison
sick cloud
#

I mean, that's kind of common sense to be here for a little while, but I don't think it's a requirement @peak chasm.

unkempt ocean
#

Hello everyone I need some help on dispatcher

data.dispatcher.once('end', function() {
      finish(client, ops, this);

when music ends it stops
don't plays next song
I changed finish to end
didn't work too

sick cloud
#

@pale bison, submit a GitHub issue if you think it's an actual issue.

pale bison
#

ok

earnest phoenix
#

@sick cloud i dont think it is author as it is the same colour and size as a title which is smaller and not bold

sick cloud
#

@earnest phoenix, dunno then.

earnest phoenix
#

@proper forum do you think you could help?

proper forum
#

Hello, help about what?

blazing gorge
#

Sup

earnest phoenix
#

Your bot saftey jim doesnt have blue text for the writing on mobile how did you do that?