#development

1 messages ยท Page 946 of 1

earnest phoenix
#

Pls bal

clear wraith
#

So put the ID in "ID HERE"

cinder patio
#

yes

clear wraith
#

Ok

#

I thought something was wrong, Just had to clarify. Thanks.

neat ingot
#

@clear wraith there is a test feature on dbl website. your users dont have to actually vote for you to test ๐Ÿ™‚

clear wraith
#

Wait.... Wtf

#

Really?

paper phoenix
#

On your bot's edit page

clear wraith
#

Ahhhhhh

paper phoenix
#

That's how you also set your password

clear wraith
#

I'm dumb

#

Ok

#

Thanks

paper phoenix
#

And where you put in your IP/address

#

Your bot running on a VPS or local machine?

clear wraith
#

VPS

slender thistle
#

@earnest phoenix import traceback

paper phoenix
#

So input your VPS IP, unless you've got a domain etc

earnest phoenix
#

cool! got it

#

me bot

paper phoenix
#

http://vpsIP:5000/dblapi

fresh hatch
#

i fixed the status, but can someone tell me how to make a role for the bot

lyric mountain
#

a role?

fresh hatch
#

like when he join in server to get it auto like MEE6, role Mee6

lyric mountain
#

just give a role to the member inside a join event

fresh hatch
#

Noo, i mean role SyntaBOT and when he join the server to get it without my touching in the settings

quartz kindle
#

you need to define the permissions your bot needs in the invite link

hasty sparrow
#

The bot receives a role automatically based off of it's permissions

lyric mountain
#

ah, that's given to your bot whenever you invite it with at least one permission

quartz kindle
#

use an invite generator

fresh hatch
#

omg, im really that much stupid ? ๐Ÿ˜„

neat ingot
#

oooohh, i was actually wondering about that. my latest bot didnt get a custom role when i added it to my main server, was wondering why. guess its cause he asked for no perms ๐Ÿ˜„

dire obsidian
#

somebody know how the bot send a DM message to people who voted?

neat ingot
#

pretty sure you just .send() to the specific user rather than a channel

#

something like client.users.cache.get('userid').send('you voted')

dire obsidian
#

ok

clear wraith
#

Where would I find the webhook url for my bot?

#

Dumbest question ever ๐Ÿ˜‚

tired nimbus
#

When I awaitMessages, it seems that the content it gets is toLowerCase. how can I keep the caps? Djs v11

neat ingot
#

you define the webhook url you want in the config for the dbl api

#

and on the bot edit page on dbl site

clear wraith
#

Huh

#

Is that on the docs?

quartz kindle
#

the url depends on where your bot is hosted

clear wraith
#

I can't understand where to get it...

quartz kindle
#

its the url for top.gg to find your bot

clear wraith
#

That's the webhook url?

#

Hmm

quartz kindle
#

if your bot is hosted on a vps, the url is the vps ip address and the port you define in your dblapi.js

neat ingot
#

ewww, gforce update for valorant :/

#

any valorant api yet? like for getting game stats?

#

google says 'not yet' ๐Ÿ˜„

unique nimbus
#

@neat ingot

neat ingot
#

oh, neat

#

ty ๐Ÿ™‚

amber fractal
#

only actual products though

#

They aren't accepting other applications yet

earnest phoenix
#
1|audio    |     at WebSocketManager.handlePacket (/root/audio/node_modules/discord.js/src/client/websocket/WebSocketManager.js:386:31)
1|audio    |     at WebSocketShard.onPacket (/root/audio/node_modules/discord.js/src/client/websocket/WebSocketShard.js:436:22)
1|audio    |     at WebSocketShard.onMessage (/root/audio/node_modules/discord.js/src/client/websocket/WebSocketShard.js:293:10)
1|audio    | TypeError: Cannot read property 'host' of undefined
1|audio    |     at Function.load (/root/audio/node_modules/lavacord/dist/lib/Rest.js![14](https://cdn.discordapp.com/emojis/639810922835214336.webp?size=128 "14")52)
1|audio    |     at MusicManager.getSongs (/root/audio/src/structures/MusicManager.js:82:35)
1|audio    |     at Object.run (/root/audio/src/commands/play.js:7:48)
1|audio    |     at MusicClient.<anonymous> (/root/audio/src/structures/MusicC```
#

Help

turbid bough
#

host is undefined

earnest phoenix
#

Uhmm

viral spade
#

For a discord.js statistics bot, that records textmessages etc. i want to keep a log of the sent messages ([guildId, channelId, userId, data]).

But as i dont want to call the database (mysql) every time a message is written, i want to cache the changes and flush them together in one transaction.

How should i store the cache for these statistics? I was thinking attach a Map to the client object. Then i could also easily periodically retrieve the data in the shardingManager and even send all shards in one transaction.

quartz kindle
#

sure, a map, an object, an array

#

whatever suits you better

cinder patio
#

You could write all entries to the database when it exceeds a certain amount

viral spade
#

okey and add it to the client object is safe? using the sharding manager to collect the data from all shards for this node is also ok?

quartz kindle
#

should be fine, if you dont accidentally duplicate data across shards

earnest phoenix
#

Is it possible to check if a user is joined to a server by a self-created Invite-Link?

#
"The reason is" + reason ? `${reason}` : 'no reason' + "by" + message.author.tag

// This will return
// 1. The reason is ${reason}
// 2. The reason is no reason by ${message.author.tag}

// But I want it to be
// 1. The reason is ${reason} by ${message.author.tag}
// 2. The reason is no reason by ${message.author.tag}

How can I do that?

short idol
#

hello I will have a question for you EVERYONE after 2 days, if we do not pass v12 the boots will close this truth

quartz kindle
#

@earnest phoenix put it in parenthesis

#

sometihng + (reason ? reason : no reason) + something else

earnest phoenix
#

thanks ๐Ÿ™‚

spice smelt
#

hi back! it's about mongoose again.
I created a variable with a model that is supposed to be saved in the 'crumble' collection. BUT in Mongo Compass, I don't see anything. But when I use the <model>.find() method, I can see all the things I added with the model! Why isn't that displayed in Compass? js var userSchema = new mongoose.Schema({ id: String, tag: String, coins: Number, xp: Number, bio: String, msgCount: Number, meanMsgCount: Number, meanWordsCount: Number, dblVotes: Array, upvotes: Number, givenUpvotes: Number, lastUpvote: Number }) js const userModel = mongoose.model('crumble', userSchema) ```js
async function updateUser(userID) {
let user = await client.users.fetch(userID)
let newUser = new userModel({
tag: user.tag,
coins: 0,
xp: 0,
bio: ``,
msgCount: 0,
meanMsgCount: 0,
meanWordsCount: 0,
dblVotes: 0,
upvotes: 0,
givenUpvotes: [],
lastUpvote: 0
})

newUser.save(function (err, newUser) {
  console.log(`user saved in crumble.`)
  console.log(userModel.find()) // THE PART I WAS TALKING ABOUT RIGHT ABOVE
})

}```

viral spade
#

ok nice.
about the datastructure.. i could make an array of objects,with the fields guildId, channelId, userId, data.

However, i of course want to add the stats from the same user to his already existing entry in the array. So if i do it that way, wouldnt it cause too much searches, if every messages need to search the whole datastructure?

To solve this i could maybe make an object, where each field is one entry, or a map, whereas the key of that field is string concatenated guildId+userId+channelId. Would that be faster?

Also, i could simply add every single event to my cache, without stacking events from the same user/channel (and have duplicate keys in my cache), and do the sum up at the point of saving the cache to database?

earnest phoenix
#

Is it possible to check if a user is joined to a server by a self-created Invite-Link?

spice smelt
#

@earnest phoenix , the Discord API doesn't provide this data as far as I know.

neat ingot
#

@spice smelt did you refresh your compass after adding the data? it doesnt auto refresh unfortunately

#

also, you can design your schema like this:

#

notice: i have required fields, and default values. so when im creating an instance of a model i dont need to provide all fields, it will auto populate them with default values. i only need to give the required fields ๐Ÿ™‚

#

(if i do give a value for a property that has a default value, the given value will overwrite the default)

topaz fjord
#

that formatting hurts

neat ingot
#

my schema formatting? why?

#

lol

restive furnace
#

that formatting is ok

#

its easy to understand

#

hehe

neat ingot
#

โค๏ธ

digital ibex
#

hi

#

how can i get the last message my bot sent in a specific channel?

#

using eris

#

even id, anything which is unique about the message or the actual content

earnest phoenix
#

!ping

digital ibex
#

wrong channel

earnest phoenix
digital ibex
#

the way u use an api

#

its a promise

#

u have to fetch it, using node-fetch

#

so like

#

fetch('url').then

#

but don't use callbacks doe

fresh hatch
#

hey, whats the code for pinging user used the command

#

the fuc+ im sleeping all day and can not remember nothing ๐Ÿ˜„

digital ibex
#

which language

#

and library

fresh hatch
#

js

digital ibex
#

what language glassykiller?

#

@fresh hatch the library?

#

if(message.content.includes('<@!id>')) do whatever

fresh hatch
#

Officially what?

digital ibex
#

which library r u using

fresh hatch
#

im on glitch

digital ibex
#

thats not a library

fresh hatch
#

you mean JS, PY ? :?

sudden geyser
#

that's a programming language

fresh hatch
#

yes, but what he mean

wicked pivot
#

how to clear a JSON?

digital ibex
#

language?

wicked pivot
#

node.js

digital ibex
#

tony kun ^^

#

o ok

#

i believe its uhhh

#

delete.json[key]

#

orr.... u can use splice

#

i'm not too sure

pale vessel
#

if (message.content.includes("<@id>") || message.content.includes("<@!id>")) @earnest phoenix

wicked pivot
#

key =?

pale vessel
#

it's delete something.key

wicked pivot
#

I want to clean it at 0

#

only "{}" remains

digital ibex
#

oh, i was close ๐Ÿ—ฟ

wicked pivot
#

before:

{"418087389337223169":{"pseudo":"418087389337223169","nombre":0},"353425485516242944":{"pseudo":"353425485516242944","nombre":0},"296303601490329600":{"pseudo":"296303601490329600","nombre":0},"581912619359666196":{"pseudo":"581912619359666196","nombre":0},"451373987469983752":{"pseudo":"451373987469983752","nombre":0},"435459271438761995":{"pseudo":"435459271438761995","nombre":0},"370781128258486283":{"pseudo":"370781128258486283","nombre":0},"508709897345433602":{"pseudo":"508709897345433602","nombre":0},"552228849245749258":{"pseudo":"552228849245749258","nombre":0},"697530944785088643":{"pseudo":"697530944785088643","nombre":0},"697092345711296574":{"pseudo":"697092345711296574","nombre":0},"152048666486636544":{"pseudo":"152048666486636544","nombre":0},"528556830490886154":{"pseudo":"528556830490886154","nombre":0},"576120314048675890":{"pseudo":"576120314048675890","nombre":0},"339473820723445760":{"pseudo":"339473820723445760","nombre":0},"566437516639469585":{"pseudo":"566437516639469585","nombre":0}}```

after
```json
{}``` you understand ?
digital ibex
#

oh, then

quartz kindle
#

redeclare it

#

unless you defined it with const, then it wont work

wicked pivot
#
const mutedjson = require("./data/muted.json")```
quartz kindle
#

you want to clear it and save it in a json file again?

#

you can simply save an empty object and overwrite the file

wicked pivot
#

I just want the clear to be 0

quartz kindle
#

fs.writeFileSync("./data/muted.json","{}")

#

then you also need to clear the require cache

digital ibex
#

its something like

const data = fs.readFileSync('./data/muted');
const json = JSON.parse(data);
fs.readFileSync('./data/muted', JSON.stringify(json, null, 2);
``` (i got this from <https://stackoverflow.com/questions/40537990/removing-json-object-from-json-file> )
#

tim

#

do u know how i get the last message my bot sent in a specific channel?

#

using eris

#

id, content, anything about the last message it sent

quartz kindle
#

you have to fetch messages and filter them

digital ibex
#

o ok

#

ty

#

how do i fetch messages?

quartz kindle
#

probably channel.messages.fetch()

digital ibex
#

i can't find anything in the Message class about it

pale vessel
digital ibex
#

i'm not trying to get the last message of a channel

#

i'm trying to get the last message of a user

pale vessel
#

yes

neat ingot
#

thats another way to check if bot was mentioned.

digital ibex
#

oh

#

oki

quartz kindle
#

thats what you probably want

#

also

#

what the fuck is this

wicked pivot
#

@digital ibex @quartz kindle neither works: /

quartz kindle
#

what did you do?

wicked pivot
#

I tried : js writeFileSync("./data/muted.json",JSON.stringify("{}"))

or

const data = fs.readFileSync('./data/muted.json');
const json = JSON.parse(data);
fs.readFileSync('./data/muted.json', JSON.stringify(json, null, 2);```
clear wraith
#

I have a question... How can I remove a user from my team in the Discord Developer Portal?

slender thistle
#

What's that unsend message method

quartz kindle
#

@wicked pivot did you just copy and paste it or what? also Lost's code has a typo

#

if you just copy and paste then it wont work

#

and your JSON.stringify() is wrong

#

it just deletes it without a reason

#

lmao

mossy vine
#

hang on why is it .call

slender thistle
neat ingot
#

i had a feeling it was gonna be a poorly worded 'delete' function ๐Ÿ˜„

quartz kindle
#

The call() method calls a function with a given this value and arguments provided individually.

mossy vine
#

but... why not just .deleteMessage(args)

neat ingot
#

apply() does the same but you provide arguments in the form of an array.

mossy vine
#

oh

#

with a given this value

#

im blind ok

digital ibex
#

oh, thank u tim

hardy vector
#

my music bot stopped working when it joins the vc channel nothing plays

#

0|npm | ... 4 common frames omitted
0|npm | Caused by: java.io.IOException: Invalid status code for video page response: 429
0|npm | at com.sedmelluq.discord.lavaplayer.source.youtube.DefaultYoutubeTrackDetailsLoader.load(DefaultYoutubeTrackDetailsLoader.java:39) ~[lavaplayer-1.3.47.jar!/:na]
0|npm | at com.sedmelluq.discord.lavaplayer.source.youtube.DefaultYoutubeTrackDetailsLoader.loadDetails(DefaultYoutubeTrackDetailsLoader.java:26) ~[lavaplayer-1.3.47.jar!/:na]
0|npm | ... 7 common frames omitted

#

it was working this morning

earnest phoenix
#

you got ratelimited

#

by youtube

hardy vector
#

for how long

earnest phoenix
#

how can you .replace(); multiple words with something?

#

for how long
@hardy vector, probably a few hrs

hardy vector
#

oh

quartz kindle
#

you can use regex with the g flag

hardy vector
#

thats it/

#

ok goood

quartz kindle
earnest phoenix
#

how if i want to replace "]"

#

๐Ÿ˜ฌ

pale vessel
#

does using the i flag rather than toLowerCase() affect performance?

quartz kindle
#

regex is generally slow, toLowerCase() creates a copy of the string

#

so idk

#

but probably toLowerCase() will be faster

earnest phoenix
#

nvm

#

thanks

hardy vector
#

does anyone have any good resources to learn regex

mossy vine
#

more of explaining the regex than teaching

#

but very useful

quartz kindle
#

regex is hell

earnest phoenix
#

no u

quartz kindle
#

no ur pfp

earnest phoenix
#

why

quartz kindle
#

it looks like its as shocked at regex as i am

#

:^)

mossy vine
#

regex is good

quartz kindle
#

regex is what happens when mathematicians try to program

hardy vector
#

lmao

indigo tapir
#

I'm getting an Error: ENOENT: no such file or directory, scandir '../Comandos/Miscelaneo/' on Javascript

#

my code: const Comandos = readdirSync(`../Comandos/${Directorios}/`).filter(d => d.endsWith('.js'));

quartz kindle
#

no such file or directory

earnest phoenix
#

-owner @splash

gilded plankBOT
#

tickNo Please include a bot mention or ID

copper cradle
#

@indigo tapir the error literally says what your problem is

#

you don't have a folder called 'Miscelaneo' inside of your 'Comandos' folder

neat ingot
#

regexp is corona

sinful belfry
#

-botcommands @earnest phoenix

gilded plankBOT
#

@earnest phoenix

Hey! Bots aren't given permissions to send responses in this channel. Please use #commands or #265156322012561408 to run commands. In addition, bots with commonly used prefixes cannot read or send messages in any channel. This is done to prevent spam and bot abuse.

sinful belfry
#

keep bot commands in testing channels

quaint sedge
#

my code: const Comandos = readdirSync(`../Comandos/${Directorios}/`).filter(d => d.endsWith('.js'));
@indigo tapir are you spanish bro?

indigo tapir
#

Yeah

#

you don't have a folder called 'Miscelaneo' inside of your 'Comandos' folder
@copper cradle I actually do

copper cradle
#

show your files

empty owl
#

i have raw events on

#

nvm

#

raw events dont work

fresh hatch
#

guys, can someone tell me the code for pinging user who used the command

#

like !hey
Hello @fresh hatch

earnest phoenix
#

how do i add a reaction to a message? Discord.js

fresh hatch
#

Also why this is not working?
client.createMessage(msg.channel.id, "Hello ${user}, and welcome!") // Send a message in the same channel with "damn it"

wicked pivot
#
(g.maxUses).replace("0", "โˆž")```(node:517) UnhandledPromiseRejectionWarning: TypeError: g.maxUses.replace is not a function
quartz kindle
#

@fresh hatch which library are you using?

fresh hatch
#

Discord.js

quartz kindle
#

discord.js doesnt have createMessage()

wicked pivot
#

(fetchInvites)

fresh hatch
#

๐Ÿ˜ฆ

quartz kindle
#

discord.js uses message.channel.send()

#

and to mention people you just need to send <@USERIDHERE>

fresh hatch
#

yes, but i want the guy who use the command

#

not like only one guy to be pinged

quartz kindle
#

yes

#

you get his id from message.author

fresh hatch
#

t appears your bot, SyntaX Bot, has connected to Discord more than 1000 times within a short time period. Since this kind of behavior is usually a result of a bug we have gone ahead and reset your bot's token.

#

the hell? ๐Ÿ˜„

quartz kindle
#

what did you do lol

fresh hatch
#

nothing, just my bot is hosted on glitch and after all words its restarting

quartz kindle
#

then thats why

paper phoenix
#

Using PM2?

quartz kindle
#

why is it restarting on all words?

fresh hatch
#

idk act ๐Ÿ˜„

paper phoenix
#

So I'm guessing it tried to start, errored out, repeat 1000x. Lol

fresh hatch
#

@quartz kindle Hello <@USERIDHERE>, and welcome!

quartz kindle
#

yes

fresh hatch
#

its writing that in the chat

quartz kindle
#

of course, you need to put a valid id

#

you can get the author's id from message.author as i said

paper phoenix
#
message.channel.send( `Hello <@${ message.author.id }>, and welcome.` );
quartz kindle
fresh hatch
paper phoenix
#

Backticks, not single quotes

quartz kindle
#

string templating requires backticks

#

otherwise you need to use concatenation

fresh hatch
#

this is the code

paper phoenix
#

Not quotes. Backticks

fresh hatch
quartz kindle
#
let id = "12345";
"this is " + id + " concatenation"; // "this is 12345 concatenation"
'this is also ' + id + ' concatenation'; // "this is also 12345 concatenation"
`this is ${id} templating`; // this is 12345 templating
#

notice the different quotes

paper phoenix
#

Fack

fresh hatch
#

Backticks - `
quotes "

earnest phoenix
#
message.channel.send(`Hello <@${message.author.id}>, and welcome`)
message.channel.send("Hello <@"+message.author.id+">, and welcome")
message.channel.send('Hello <@'+message.author.id+'>, and welcome')
```all 3 are the same
fresh hatch
#

nope

earnest phoenix
#

all 3 result in the same

fresh hatch
#
    if(message.content.includes('test')) {               
message.channel.send('Hello <@'+message.author.id+'>, and welcome')
    }
});
#

this is the code, right?

paper phoenix
#

Should be using DJS v12, which is just message, not messageCreate

fresh hatch
#

just message

neat ingot
#

@fresh hatch does your bot use some kind of auto restarting thing like node.js's nodemon? i had the same issue whenever a file got changed cause of autosave, my token got reset a few tiems

fresh hatch
#

yes...

#

cuz glitch is banned or something and they locate the bot and yea...

neat ingot
#

๐Ÿ‘€

sudden geyser
#

If you sent 1k login requests you're doing something wack.

#

Such as constantly editing your files without a watch.json file to set a time before it restarts

true gulch
#

I'm on websites top.gg Gadi Jesse would like to turn back from the bot for me.

#

What do I do?

sudden geyser
#

what

neat ingot
#

make more sense plz?

true gulch
#

a site where bots called top.gg are clustered.

#

I want to add my bot to that.

neat ingot
#

you mean, how do you get your bot on the top.gg website?

true gulch
#

No,

#

My bot

#

I want to register there.

neat ingot
#

so you want to add your bot onto top gg like i said?

true gulch
#

Yeah.

neat ingot
#

see link above ๐Ÿ™‚

true gulch
#

I tried it.

#

But an error.

#

There was an error of 4000.

neat ingot
#

then i dont know im afirad ๐Ÿ˜ฆ

earnest phoenix
#

how to upload a bot xD

sudden geyser
true gulch
#

That's an error.

sudden geyser
#

wut

true gulch
#

If you interpret that,

neat ingot
mossy vine
true gulch
#

The code returned by the discode has expired or is not valid Please try again.

#

An error ...,

neat ingot
#

are you logged in? maybe you need to be logged in first?

#

hmm, it tried to log me in automatically lol

mental furnace
#

@scenic kelp so I didnโ€™t know in what chat to ask this, but Iโ€™m working on a moderation bot... and if it gets accepted, do you guys want me to disable it here? (Iโ€™m not done yet and havenโ€™t uploaded it yet but just a heads up)

scenic kelp
#

there's no need to disable it here unless it attempts to post messages without a user's input

mental furnace
#

Well it deletes messages.... thatโ€™s the thing

scenic kelp
#

It won't be able to delete messages here

mental furnace
#

Probably you arenโ€™t even gone give that perm to a bot tho and ye I tought that

#

Ok

#

Thanks

#

Now that I think about it, it does send messages... like if I say a swear word it sends a message to not use that word again but it does delete that message after 5 sec

quartz kindle
#

you will need to disable that for this server

mental furnace
#

Ok

#

Was probably gonna disable it anyway cause this server spammed my other bot for some reason and idk why lol

quartz kindle
#

this server does a lot of bad things to bots

sterile minnow
#

Hi, A Quick Question. I made a code that if the Voicechannel is empty it should leave it but that doesnt work.

Here is the Code:

let voiceconnection = "false"
     setInterval(function(){
       
     let members = 0;
     client.channels.cache.get("714808804294000672").members.forEach(m => {
       if(m.user.bot) return;
        if(m.id == bot.user.id) return;
       members++
     })
     console.log(members)
       console.log(voiceconnection)
       if(members < 0 && voiceconnection == "true"){
         console.log("false")
       
       client.channels.cache.get("714808804294000672")
       
       .leave()
         voiceconnection = "false"
     }
 
     if(members > 0 && voiceconnection == "false"){
       client.channels.cache.get("714808804294000672")
        .join()
       .then(connection => {
         var playing = new Discord.MessageEmbed()
           .setTitle(":musical_note: | Now Playing")
           .setDescription(
             `Connected\nPlaying: โ–ถ Blueflame Radio\nYou hear nothing? Please use [prefix]contact`
           )
           .setFooter("To set the volume use: r>vol [volume]")
           .setColor("GREEN");
       // client.channels.cache.get("609313142194962442").send(playing)
         connection.play("URL");
         voiceconnection = "true"
      
     })}
       
     
   }, 3000)```
#

no error given. nothing

earnest phoenix
#
let user = message.mentions.members.first();
${user.tag}``` idk why but the output is undefined when the message gets sent.
#

nvm

#

it's supposed to be users not members smh

#

@earnest phoenix user.user.tag

#

No?

#

I just said I realized I put members instead of users

quartz kindle
#

@sterile minnow why are you using an interval?

#

there are much better ways to do that

#

and you're checking if members is smaller than 0, but i dont see how it could ever be smaller than 0

sterile minnow
#

Oooh. Cuz its a bit laggy

quartz kindle
#

you should be using the voiceStateUpdate event instead of that interval

#

and you can check the member's size, no need to count them

opaque seal
#

What's the best language for a discord bot?
Is it true that java is one of the best ones, expecially with sharding?

smoky spire
#

There's no best language

opaque seal
#

I mean, there are some which are more efficient in some cases

smoky spire
#

Yeah but it all depends on what you specifically want for your bot, there's no objective best

amber fractal
#

All depends on what you plan to do

topaz token
#

someone created a welcome bot for me

opaque seal
#

All depends on what you plan to do
what do you mean with that, what the bot does on discord?

amber fractal
#

yes

#

like music, complex documents, little games, etc

opaque seal
#

Uhm, my bot creates temporary voice channels, you know what that is?

unborn steeple
#

whats the best way to make a music system using discord.js?

lyric mountain
#

Uhm, my bot creates temporary voice channels, you know what that is?
Note that channel creation has a quite small quota per hour

#

You might hit the ratelimit very quickly

opaque seal
#

Seriuosly?

lyric mountain
#

Yep

opaque seal
#

Wait, there is a bot who does this and it's in over 22000 servers

#

and I don't even know if it uses sharding

unborn steeple
#

Anyone know the best way to create a music system using discord.js 11.5.1

opaque seal
#

there isn't a "best way"

#

You might hit the ratelimit very quickly
does sharding fix that?

unborn steeple
#

There is so many ways, im just wondering which is the best option.

#

im fixing to add music to my bot

opaque seal
#

It's just "good code"

lyric mountain
#

Sharding just splits your bot in N versions of itself, each dealing with their own slices of guilds

#

Maybe, MAYBE it might affect ratelimit quotas

#

But I've never sharded, so idk

amber fractal
#

put a high cd on it

#

I believe it's per guild

lyric mountain
#

Yeah, cd is the safest way

opaque seal
#

cd?

lyric mountain
#

Cooldown

opaque seal
#

yeah that's for sure

earnest phoenix
#

I've tried to invite the bot to my server but it won't join

mystic violet
#

the for statement is suppost to do that

quartz kindle
amber fractal
#

what am I looking at

quartz kindle
#

i equals 1
while i is bigger than 14
i++

amber fractal
#

oh

#

well yeah

#

but like

quartz kindle
#

i is never bigger than 14

#

lmao

amber fractal
#

that will never run

quartz kindle
#

exactly

#

which is the problem of the above question

amber fractal
#

probably meant to be a <

#

but why not a for loop?

#

considering it was made for counting mmLol

quartz kindle
#

well

#

he did say its a for statement, but in the code its not lmao

neat ingot
#

bot just asked me that for a quiz question ๐Ÿ˜„

earnest phoenix
#

can someone help me make a bot!

sudden geyser
#

As in what. Help develop it from scratch? Solve an issue you're having?

neat ingot
#

what means help?

winter basalt
#

if you havent started at all, then head over to google to find some guides

neat ingot
#

and if you dont know any programming, and really want to write your own, learn some programming first ๐Ÿ™‚

earnest phoenix
#

i need help making one from scratch @sudden geyser

winter basalt
#

we only help people with errors and stuff here, we cant really help to make from scratch, though you can find guides online

lyric mountain
#

bot just asked me that for a quiz question ๐Ÿ˜„
Errr....not that there's a common iterator for arrays

#

Depends on what you want to do

neat ingot
#

i was thiinking the same tbh. like, i guess most common is a for loop, but ive iterated over arrays with while, as i shift or pop them off the array many times

magic jackal
#

@quartz kindle Do you know how to use cheerio?

#

I have a few question on how it works but I'm parsing over 200k lines and its hard to figure out what I need to select.

neat ingot
#

isnt that just the same as regular jquery ?

magic jackal
#

yeah I dont know jquery

#

I am trying to find this data here

<script type="application/ld+json" id="videoObject">```
floral lynx
magic jackal
#

Do I select it like this $('script.id[videoObject]')

neat ingot
#

been a while since i jqueried, but im sure $('#videoObject') is sufficient

#

yea it should be

#

so you could do something like $('#videoObject').text() to get the content of the html element

earnest phoenix
#

what is like the code for it to have a prefix for the commands?

sage orbit
#

what language

earnest phoenix
#

English

sage orbit
#

coding language....

earnest phoenix
#

idk

sage orbit
#

Javascript

#

C#

#

erm

#

you dont know what language you coded your bot in?

earnest phoenix
#

java

sage orbit
#

java or javascript

earnest phoenix
#

javascript

sage orbit
#

ok

#

Make a new file called config.js

#
  "token": {"your bots token"},
  "prefix": {"prefix"}
}```
#

and then put that in it

#

dont put the {}

earnest phoenix
#

wait so in {
"token": {"your bots token"},
"prefix": {"prefix"}
}
dont put the "{"

sage orbit
#
  "token": "your bots token",
  "prefix": "prefix"
}```
#

there

#

sorry for the confusion

#

you need the { } around the code

earnest phoenix
#

dont forget to load it in your main .js file your executing or it wont work

sage orbit
#

^^

#

or index.js

#

ye

#

thats what it will be called

#

is what i mean

earnest phoenix
#

thats why i just said main .js people call them random stuff i did mine ๐Ÿ˜„

sage orbit
#

i thought u said main.js

#

lol

#

i didnt see the space

#

ye that works too

#

you have to download the package tho

#

Its called dot env

#

i think....

#

o

earnest phoenix
#

meanwhile my bots hosted on a pi3 , can i use .env instead too ?

sage orbit
#

erm

#

idk

earnest phoenix
#

is it a module package?

#

no im using java to run my bot on a raspbery pi3

sage orbit
#

bruh

earnest phoenix
#

wdym

winter basalt
#

wdym how

earnest phoenix
#

wait i got this msg after putting in the token

Unexpected token, expected ; (17:9)

#

you want inv to my server?

sage orbit
#

put ;

#

after }

#

js is gae

#

C# is where its at

#

or ye python

#

i havent done python doe

#

nO!

winter basalt
#

dont post your token

#

bro

sage orbit
#

dont share that here

winter basalt
#

regenerate

#

your yoken

#

immediately

#

lol

sage orbit
#

delete it

earnest phoenix
#

@earnest phoenix id change my token now if i was you

sage orbit
#

and refresh your token

#

on the dev portal

earnest phoenix
#

i did

winter basalt
#

ah ok

earnest phoenix
#

wait but did i do the coding right?

winter basalt
#

i think so

earnest phoenix
#

wait it keeps saying
Unexpected token, expected ; (16:9)

#

so is the .env a module for discord .js can i install it with npm then alter my code to load it from the .env file instead of .json?

earnest phoenix
#

oh sweet ty

#

i havnt done it yet but i will soon , can i just leave rest of data in the .json like prefix yes?

#

because im planning on using api's for other things

lyric mountain
#

An api for prefix?

earnest phoenix
#

no , but what im asking is can i not just leave my prefix in the .json too or im going to have to change alot of code

#

i have it load commands from separate files ie the functions are all seperate and all depends on the .json for the prefix

#

im sure ill figure it out thanks though

clear wraith
#

Ok so... I just coded a messageUpdate and a messageDelete command for my events folder. And when i go to edit a message it spams that I edited the message 200000 times. Why?

earnest phoenix
#

no break?

clear wraith
#

No. It doesn't stop

#

It keeps doing that, and then it stops after it sends it 2 million times

earnest phoenix
#

2 possibilities

  1. Discord has a seizure
  2. You misconfigured the event handler and edit the log message, resulting in the bot entering a infinite loop
clear wraith
#

Ill grab the code

#

This is what is in the Index.js file for both of them.

    require("./events/messageUpdate")(oldMessage, newMessage);
  });

  client.on("messageDelete", async (message) => {
    require(".events/messageDelete")(message);
  });
#

That's right... Isn't it?

earnest phoenix
#

events/messageUpdate file please

#

my bot doesnt work ๐Ÿ˜ญ

final jay
#

:p

earnest phoenix
#

@earnest phoenix can you send us the code for it (please make sure to censor all important information such as bot token and api keys please)

#

ok

#

so we can take a look on what's wrong

#

if (!message.content.startsWith(prefix) || message.author.bot) return;

if (message.content.startsWith(prefix + "ping")) {
message.channel.send("pong!");
} else
if (message.content.startsWith(prefix + "foo")) {
message.channel.send("bar!");
}
});

client.login("SuperSecretBotTokenHere");
client.on("ready", () => {
console.log("I am ready!");
});

client.on("message", (message) => {
if (message.content.startsWith("ping")) {
message.channel.send("pong!");
}
});
client.login("token");
client.on("message", (message) => {
// This code runs when the event is triggered
});
client.on("message", (message) => {
// This code runs when the event is triggered
});

#

i gtg so i will be back tmr

#

uh

#

this is wrong on so many fucking levels

clear wraith
#

@earnest phoenix here is the messageUpdate file.

const { MessageEmbed } = require("discord.js");
module.exports = async (oldMessage, newMessage) => {
  let embed = new MessageEmbed()
    .setTitle("Message Edited")
    .setColor("GREEN")
    .setDescription(
      `**${oldMessage.author.tag} Edited a message in <#${oldMessage.channel.id}>**`
    )
    .addField("Old Message", oldMessage.content, true)
    .addField("New Message", newMessage.content, true);
  let channel = oldMessage.guild.channels.cache.find(
    ch => ch.name === "โ”‚server-log"
  );
  if (!channel) return;
  channel.send(embed);
};
earnest phoenix
#

can you help me tmr @earnest phoenix

#

I can not

#

but this can

#

@clear wraith that looks okay to me

#

then its just discord having a seizure

#

try killing all processes your bot runs on and completly restart it

clear wraith
#

So.. I can't do anything about it?

earnest phoenix
#

As far as i see no

#

just restart the bot and hope it doesnt fuck itself

clear wraith
#

So... Redo the Index.js file?

earnest phoenix
#

restart everything and hope

clear wraith
#

Or restart it in the terminal

earnest phoenix
#

restart the node process

clear wraith
#

Ok

earnest phoenix
#

like kill off node entirely and start it over again

wanton nova
#

this might seem like a weird question, but does anyone know a good solution on how to make a countdown?

#

i dont want to edit the message every second for obvious reasons

#

and i tried using an emoji for a countdown

#

only problem is that if they leave the channel the emoji resets

#

and i cant really find any consistent gif designs cause I have different times for countdowns

earnest phoenix
#

you can change the interval of the message being edited

warm marsh
#

You could edit the message in jumps, E.g. every 10 seconds until you get to like 10 then use a gif

earnest phoenix
#

it counts down every second but only edits it every 10 secs or so

wanton nova
#

its a 30 second countdown

#

ah

#

well i guess doing 30, then 20, then 10, then (maybe) 3, 2, 1 would be a good idea

#

im not sure about the ratelimits though

earnest phoenix
#

more to do with html & php, but how can you have a file that can only be downloaded if you're logged in?

magic jackal
#

How would I access the children key in this object? Sorry kinda still trying to get the hang of this

initialize {
  '0': <ref *1> {
    type: 'script',
    name: 'script',
    attribs: { type: 'application/ld+json', id: 'videoObject' },
    children: [ [Object] ],
    next: {
      type: 'script',
      name: 'script',
      attribs: [Object],
      children: [Array],
      next: [Object],
      prev: [Circular *1],
      parent: [Object]
    },```
#

I think is obj[0].children[0]

cinder oxide
#

next.children[0]?

earnest phoenix
#

@earnest phoenix check if the user is logged in and the session key is valid, then send the file

#

else send a null byte or send nothing

#

or send status 403

#

no but

#

if they just visit the link, for example text.exe

#

you mean per ftp server

#

or per express server

#

with express you can check if a cookie was sent, if yes, check that cookie

#

if not, 403

#

mk ill try that

gritty bolt
#

how do bots make status pages for their shards?

magic jackal
#
msg.channel.send(new Discord.Attachment(videoMeta.videoUrl, 'video.mp4')).catch(console.error);```

TypeError: Discord.Attachment is not a constructor
#

wot

steel drum
#

@magic jackal its Discord.MessageAttachment

magic jackal
#

oh

gritty bolt
#

how do bots make status pages for their shards?
@gritty bolt

#

anyone know anything about that?

small prairie
#

do we get on update webhooks from mongodb?

halcyon ember
#

whats the way to add roles to a user

pale vessel
#

click on their avatar

magic jackal
#

Any regex masters? I want to remove everything starting at ? in my url here however this is my current code, is this smart?

const string = "https://www.tiktok.com/tesdt/video/6822417395412520198?lang=en"

let urlRegex = /(https?:\/\/[^ ]*)/;
let url = string.match(urlRegex)[0];

console.log(url.substr(0, url.length - 8))```
pale vessel
#

why not just split?

magic jackal
#

idk that is why I asked

pale vessel
#

so basically you just want Lang=en?

magic jackal
#

I want to remove that part

pale vessel
#

oh

magic jackal
#

I just dont know regex that well

pale vessel
#

would split("?")[0] work?

magic jackal
#

yea, should work fine

#

I just worry if its gonna contain it anywhere else in the link by mistake

#

but its a url so it shouldnt

pale vessel
#

you should try to avoid regex since it tends to be slow

magic jackal
#

I c. thanks

graceful dock
#

Does anyone know why my wavelink music player doesnt play youtube music sometimes?

pale vessel
#

rate limited?

graceful dock
#

Apparently lavalink cant get rate limited

pale vessel
#

no way

graceful dock
#

idk saw that on reddit

#

If it a rate limit problem, how long do i have to wait for it to comeback to normal?

limber swan
#

Someone knows how to reduce ram usage?

queen needle
#

with discord js is there a way to fake a member joining using my eval command

summer torrent
#

yes

queen needle
#

how could i do that?

summer torrent
#

just emit "guildMemberAdd" event

#

<Client>.emit("guildMemberAdd", message.member)

queen needle
#

thank you

wary raft
#

Would any user here happen to know the box name of whatever is behind the img for bot's icons on top.gg pages?

#

Having an issue with the line on the right and bottom from what the default "Shadow" box sort of looks like, but can't seem to find the name of what I'm looking for in Aspect View to try and get it removed

#

OIII never mind i finally found it after removing the image source. it was .columns .bot-img, agh

earnest phoenix
#

was about to look it up from my css

wary raft
#

awe, i appreciate it X3

autumn compass
#

.get('https://corona.lmao.ninja/v2/countries/${args}'); do i do something wrong, its not returning anything

earnest phoenix
#

full code maybe?

autumn compass
#

check your dm

earnest phoenix
#

just send a pastebin

high geode
#

help please

restive furnace
#

user isnt defined

autumn compass
#
const Discord = require('discord.js');
const superagent = require("superagent");


exports.run = async (client, message, args) => {

  let {body} = await superagent
  .get('https://corona.lmao.ninja/v2/countries/', args);

  const embed = new Discord.RichEmbed()
  .addField('Statistic1', '**Total Cases**: ' + body.deaths + '\n' + '**Cases**: ' + body.deaths + '\n' + '**todayCases**: ' + body.todayCases, true)
  .addField('\u200b', '**Deaths**: ' + body.deaths + '\n' + '**Cases**: ' + body.deaths + '\n' + '**todayCases**: ' + body.todayCases, true)
  .setTimestamp()
  .setColor(0x00ccff);
message.channel.send(embed);


}

any idea why is not working, its returning undefined

restive furnace
#

how do you run it?

#

corona us for example?

autumn compass
#

wtih command

restive furnace
#

but what command and what args you pass there?

#

some apis just support 2 letter name of the country

#

like us, fi, se, ee, de, ru, au, ca

autumn compass
#

! command nad the country name

restive furnace
#

try !command us

autumn compass
#

same problem, undefined

restive furnace
#

isnt args array?

#

.get(`https://corona.lmao.ninja/v2/countries/${args[0]}`)

#

and try to go urself to that url with country does it return anything

autumn compass
#

well thank you for now everything work

#

ignore the double names its jsut for testing ๐Ÿ˜„

desert phoenix
#

Hello!
I'm having some issues with the code me and a friend are trying to use

#
# Say
@client.command()
async def say(ctx, *, content):
    await ctx.message.delete()
    #channel = discord.TextChannel.name('test')
    #channel = client.get_channel(715038598361120779)
    await ctx.channel.send(content, channel)
#

We're trying to use the say command to try and send the message into a different channel according to the channel's name

earnest phoenix
#

any error?

tight plinth
#

get_channel("id")

#

@desert phoenix

midnight remnant
#

Do you have to put the ID?

desert phoenix
#

Hes the other bot coder

mossy vine
#

no, d.py will magically guess what channel you need

#

a recent update includes machine learning features

#

soon it will also guess what you want your entire bot to do

midnight remnant
#

...

#

Guess no help here ok

mossy vine
#

of course you need the id why wouldnt you ๐Ÿ˜ฉ

desert phoenix
#

Alright to confirm

#

lmao, machine learning algorithms yes.

#

I'll also remember to use my neutron cyclotron to calculate the derivatives of the acceleration of the third moon of jupiter as well

#

ALright fr, tho, I was thinking if it was possible to use a name to identify it

#

but its only possible for using the Channel id right?

mossy vine
#

idk how d.py handles things but you might be able to fetch the channel from cache by name

desert phoenix
#

What about

#

I was thinking that some bots have this sort of commandline that allows for the user

#

to specifically set a channel

slender thistle
#

Channel converter

#

In function args you set an argument's type annotation to discord.Channel

wild mist
tight plinth
nocturne grove
#

Hey. Is the guildMembersChunk event ever used? And will guildMemberAdd be fired for every individual guildMember that got added? (discord.js v12)

tight plinth
#

@nocturne grove 1- idfk
2- yes

wild mist
#

@tight plinth how to get video id ?

tight plinth
#

what u use to get video

wild mist
#

lavalink

tight plinth
nocturne grove
#

okay thank you @tight plinth!

tight plinth
#

np

wild mist
#

ok lemme try

#

It say undefined

tight plinth
#

wait

#

check what song.info returns, and use ur brain to determinate what is the id

wild mist
#

object object

tight plinth
#

.then(o => o)

#

or console.log it

tight plinth
#

lavalink is trash
ytdl-core is trash
what should I use to do music?

earnest phoenix
#

lavalink

restive furnace
#

make ur own lib

#

to log objects, simply console.log({object})

#

or convert them to arrays

earnest phoenix
#

wut

#

own lib

high geode
#

brobro

#

fast

#

how can i write a command

#

for a giveaway bot

#

message.channels.react

#

or how

#

i need when he sends the giveaway message, autoreact to it with ๐ŸŽ‰

#

pls help me

earnest phoenix
#

Bro, chill

#

chat library?

#

what*

#

aka what language

#

glad i could help :,)

wild mist
#

That guy cant chill lol

earnest phoenix
#

and then doesnt even respond

#

i hate these people, wanting something so desperate, then spamming to get attention

#

then not responding after answering

wary raft
#

that's generally how folks are on Discord, sadly

glossy elk
#

Hey

#

@hollow gale

#

Oops

earnest phoenix
#
var string = "Hello this is a test sentence";
['hello', 'this', 'is', 'a', 'test', 'sentence']; // after splitting it
// wanted result (breaking after every 3 words)
'hello this is
a test sentence'
#

anyone knows how i can do thit

tight plinth
#

.join(' ')

pale vessel
#

no lol

#

read

earnest phoenix
#

I want to break it after every 3 words.

#

๐Ÿ™‚

tight plinth
#

use your brain

#

like with a for loop

quartz kindle
#

you will need a loop with indexes and the modulo operator

earnest phoenix
#

I did, can't figure it out that's why I asked - use your brain if you can't seem to understand the purpose of this textchannel.

pale vessel
#

toxic

tight plinth
#

we're not gonna spoonfeed code

earnest phoenix
#

don't need to?

quartz kindle
#
a = "this is a test string";
b = a.split(" ");
for(let i = 0; i < b.length; i++) {
  // this is a "for" loop. it defines i as 0, then loops while i is smaller than the length of b.
  console.log(i); // this will give you the current index
  b[i] // this will let you access the item of the array that exists in this index
}
earnest phoenix
#

thanks

quartz kindle
#
1 % 5 // this is a modulo operator, it returns the remainder of division. this returns 1
4 % 5 // returns 4
5 % 5 // returns 0
6 % 5 // returns 1 again
golden condor
#

Wait so that is what % means?

earnest phoenix
#
// text was a string
text = text.split(" "); // -> array
let txt = "";

for (i = 0; i > text.length; i += 2){

    txt += `${text[i].toString()} + ${text[i+1].toString()}\n`;

};
golden condor
#

ohhhhhhhhhhhhhhhh

tight plinth
#

8%4 returns 2

earnest phoenix
#

If I console log it, it just returns some empty text

golden condor
#

wht

quartz kindle
#

8%4 returns 0

tight plinth
#

why +=2

#

oh ye

golden condor
#

That returns 0

#

Is it the remainder?

earnest phoenix
#

why +=2
@tight plinth trying to split it every 2 words

winter basalt
#

% is remainder

#

iir

golden condor
#

ohhhhhhhh

#

makes more sense

tight plinth
#

@earnest phoenix it wont work

#

orr

#

lemme see

earnest phoenix
#

no it doesnt

quartz kindle
#

@earnest phoenix you dont change the i

#

else you screw up the indexes

earnest phoenix
#

i +=2?

quartz kindle
#

you dont want to skip indexes, you want them all, else you will be skipping words, not putting them in new lines

tight plinth
#

i>text.length

quartz kindle
#

what you want is, if the index reaches an amount that can be divided by 2, then you add the new line character "\n"

#

otherwise you dont add it

tight plinth
earnest phoenix
#

thanks guys ๐Ÿ˜„

restive furnace
#

@tight plinth better discord EyesCross

tight plinth
#

i dont see the problem

restive furnace
#

its illegal

#

but ok

#

not my business

pale vessel
#

the only problem i see is the furry background

#

off topic sorry

still merlin
#

can someone help, my guilds are undefined. my code is
.addField("Guilds", client.guilds.size)
and result is:

tight plinth
#

client.guilds.cache.size

still merlin
#

ok tysm

neat ingot
tight plinth
#

f

neat ingot
#

quite ๐Ÿ˜ข

neat ingot
#

if you host a bot on glitch, is anyone then able to view the source code for it?

mossy vine
#

yes

neat ingot
#

ooft

#

lol

opaque seal
#

How do you guys handle custom prefixes?
Do you query the database each time a message is sent and check if it starts with the prefix that's on the database?

fallow steppe
#

So I'm using glitch to code a bot, and uptime robot to host them 24/7. However, whenever I shut down the glitch project, the bot stays up for a while and shuts down. I correctly provided the live app link to uptime robot but still is not working. Any ideas? ( if this belongs here )

pale vessel
#

does the bot still respond after being shut down?

neat ingot
#

@opaque seal yes. I check for guild specific custom config when each message is sent, if none is found it uses the default config

opaque seal
#

Doesn't that lead to too many disk operations?

neat ingot
#

no, because i implemented a cachebase, which is basically a wrapper around my database that stores objects via id (guild id in this case). my cachebase will either give me existing data (and update the time that data was last used), or it will fetch the data from database, and set the time the data was used. then, i use my cachebase as the database, and fetch data from that. so really, it only reads from the database when it needs to get new guild information, then it holds it in memory until it hasnt been used for x minutes (configurable).the cachebase saves the data to database each minute, and then clears any that are past the time limit

#

tbh, its just a decently written database manager. i just call it a cachebase as its like, the main brain of the db, and i care about file hierarchy in my directories, and c is higher in the list than d. I could have easily called it datacache, or db_cache, or w.e ๐Ÿ˜›

quartz kindle
#

@opaque seal you dont need anything that complicated, it can be a lot simpler for only prefixes

neat ingot
#

๐Ÿ˜„

quartz kindle
#

the general idea is: when you receive a message, check if you have a prefix already stored somewhere, if not, get it from the database and store it somewhere for future uses

#

with somewhere being a variable, array, map, object, etc inside the program

opaque seal
#

Yeah I know what cashing is

quartz kindle
#

cashing lmao

opaque seal
#

?

#

Is that not the right term?

neat ingot
#

cachรฉing

quartz kindle
#

the correct spelling is cache

#

cash = money

opaque seal
#

Oh sheat

#

Haha

quartz kindle
#

hahah

opaque seal
#

Idk about it though

#

I'll have to thing about it

quartz kindle
#

it shouldnt be hard to implement

neat ingot
#

tbh, just read it from the database each message for now

quartz kindle
#

it can be as simple as a 1-2 liner

neat ingot
#

yea, it doesnt need to be over the top

#

my solution is for portability, its a module i wrote that ive used in a few projects

opaque seal
#

No that's not the problem, the problem is that it would require RAM and it would still query the database a lot if the bot is in many servers

neat ingot
#

not much ram tbh

opaque seal
#

tbh, just read it from the database each message for now
@neat ingot atm this is causing my bot CPU usage to go above 100

neat ingot
#

๐Ÿ‘€

#

ooft

#

what database are you using?

#

(please dont say json)

#

lol

fallow steppe
#

@pale vessel no it does not

opaque seal
#

Wasn't only that there reason, I was querying the db on the message event and on the command file too, now I changed it so the message event passes the db values it got to the command

#

what database are you using?
@neat ingot mongoDB

fallow steppe
#

It shuts down completely, won't come back until I re-open the project

neat ingot
#

oh, mongo โค๏ธ

opaque seal
#

Should switch to SQL in the future

quartz kindle
#

imagine you have 5000 servers. you receive messages from 500 of them over a couple minutes, you will make 500 requests to the database, yes, but its a simple read request which is usually done in 1 millisecond. then all those 500 guilds will never need to touch the database anymore for prefix lookup, because they will be stored in the ram. how much ram would a prefix cost? its a simple 1-2 char string, 500 prefixes will not cost more than 1-2kb ram

neat ingot
#

no no, mongo is scalable af!!!

#

^

#

i use mongodb/mongoose as part of my database/cache system ๐Ÿ™‚

pale vessel
#

@fallow steppe then it's just discord being slow at updating the bot status. your bot is actually offline

opaque seal
#

imagine you have 5000 servers. you receive messages from 500 of them over a couple minutes, you will make 500 requests to the database, yes, but its a simple read request which is usually done in 1 millisecond. then all those 500 guilds will never need to touch the database anymore for prefix lookup, because they will be stored in the ram. how much ram would a prefix cost? its a simple 1-2 char string, 500 prefixes will not cost more than 1-2kb ram
Right

quartz kindle
#

@fallow steppe is there any error in the logs?

#

how do you start your bot?

fallow steppe
#

No, aslong as I open it it starts as "Logged in as Test Bot#0110"

#

Then the rest of logs is spammed with null

quartz kindle
#

what

arctic juniper
#

I have a query. Can anyone help me?

fallow steppe
#

No errors are logged

quartz kindle
#

why does it spam with null?

arctic juniper
#

I have a query. Can anyone help me?

fallow steppe
#

Idk, it's surely something related to glitch

quartz kindle
#

@arctic juniper dont ask to ask

arctic juniper
#

Help me plzz

quartz kindle
#

@fallow steppe it shouldnt be logging null lol

fallow steppe
#

Hold Ill take a ss

arctic juniper
#

๐Ÿ˜ญ

quartz kindle
#

@arctic juniper dont ask to ask

#

just ask

opaque seal
#

@arctic juniper just ask

arctic juniper
#

Ok

still merlin
#

im trying to get my bot to react to the help message embed i tried
sentMessage.react("๐Ÿ™‹โ€โ™‚๏ธ");
and it dont work, anyone know what i need to put?

neat ingot
#

is it ok to ask if im allowed to ask a question?

quartz kindle
#

you're trying to react with two reactions?

#

dek smh lmao

neat ingot
#

my cachebase, for 1 player, 1 server, and 1 minigame record (bot specific) is 13106 bytes.

opaque seal
#

no no, mongo is scalable af!!!
isn't SQL too?

quartz kindle
#

all databases are scalable

fallow steppe
neat ingot
#
function roughSizeOfObject( object ) {
    var objectList = [];
    var stack = [ object ];
    var bytes = 0;
    while ( stack.length ) {
        var value = stack.pop();
        if ( typeof value === 'boolean' ) {
            bytes += 4;
        }
        else if ( typeof value === 'string' ) {
            bytes += value.length * 2;
        }
        else if ( typeof value === 'number' ) {
            bytes += 8;
        }
        else if
        (
            typeof value === 'object'
            && objectList.indexOf( value ) === -1
        )
        {
            objectList.push( value );

            for( var i in value ) {
                stack.push( value[ i ] );
            }
        }
    }
    return bytes;
}

^ used that function to get bytes

quartz kindle
#

why does a boolean use 4 bytes?

neat ingot
#

no idea, found the first function on SO for 'how to calc bytes of a js object

#

lol

opaque seal
fallow steppe
#

@quartz kindle screenshotted above

quartz kindle
#

@fallow steppe you have some console.log somewhere in your code doing that

fallow steppe
#

Wait, actually, sorry. It's a glitch outage that keeps dropping project hosting throughout the day

#

Just noticed

quartz kindle
#

oh

#

lmao rip glitch

neat ingot
#

theres a private server for agar.io i play on sometimes, and its hosted on glitch...

#

it is not performant at all.

quartz kindle
#

xD

neat ingot
#

so, i noticed that my minigame bot has a little bit of lag it seems when more than one person is playing it at a time. is there some issue with awaiting messages/reactions from multiple users at the same time within discord js?

#

or perhaps it was due to awaiting multiple messages in the same channel?

golden condor
#

It could be, maybe a more economic thing to use would be a message collector

neat ingot
#

isnt that what await reactions/messages does behind the scenes anyway?

golden condor
#

Yeah

#

You could make it so it doesn't just await 1 message, but instead waits as many as you need

neat ingot
#

~ reaction turn based minigames system

#

lol

#

so you react, game updates, repeat.

earnest phoenix
#

or you can build your own much lighter solution by using one single listener and your own collection of messages that need listening

#

then simply check for those in the event

opaque seal
#

Do you guys know any open source bots to help understand a good code structure for a java bot?

earnest phoenix
#

how can i place text in the middle of a canvas ?

golden condor
#

you use node.js

#

?

earnest phoenix
#

no

#

discord.js & canvas package

neat ingot
#

...

#

then yes, you use node js

earnest phoenix
#

did i get the question wrong

#

ok then

golden condor
#

There is a guide on their site

earnest phoenix
#

ok
thanks

golden condor
neat ingot
#

oh neat wtf

#

i had never noticed that lmao

quartz kindle
#

if you want to center the text, you need to either use measureText and then apply an offset, or you need to set the text to align center and middle

fiery hill
#

Hey guys, i'm a beginner in discord.js, and i keep running into a certain problem => client.ping returns undefined and i can't find information in the documentation.... do you have any ideas?

paper phoenix
#

@fiery hill client.ws.ping

fiery hill
#

๐Ÿ‘Œ

earnest phoenix
#

if you want to center the text, you need to either use measureText and then apply an offset, or you need to set the text to align center and middle
@quartz kindle how can i set the align to middle?

#

on d.js

#

i used to do it on html

paper phoenix
#

@earnest phoenix - context.textAlign = 'center'

context.textBaseline = 'middle'

You mean that?

earnest phoenix
#

i used it but it doesnt seem to work

#

im trying to fix that

#
ctx.font = '28px sans-serif';
  ctx.textAlign = "center";
    ctx.fillStyle = '#ffffff';
    ctx.fillText("ABCD", canvas.width / 2.5, canvas.height / 3.5);```
#

i used this line

#

but i dont see the text

paper phoenix
#

Console log your canvas.width/2.5 and the height

#

Make sure they're valid values

earnest phoenix
#

width console => 700
height console => 250

#

what does the /2.5 and /3.5 mean actually

#

is it gonna be 700/2.5 and 250/3.5 and place it there?

paper phoenix
#

Yeah

earnest phoenix
#

so why wont it work

#

i dont see the text

paper phoenix
#

You're not drawing white text on a white BG are ya? Lol

earnest phoenix
#

oh

#

how can i change the color?

#

of the text

#

im so dumb lmao

paper phoenix
#

Fill style

#

ffffff is white

earnest phoenix
#

will change

#

thank you

quartz kindle
#

dividing by 2.5 and 3.5 will not give you the center of the canvas

earnest phoenix
#

ik i did it /2

#

how can i change the size

#

of the text

quartz kindle
#

in the font

earnest phoenix
#

oh
change the px ?

quartz kindle
#

yes

earnest phoenix
#

it wont change it i think

#

i changed from 28px to 64px

#

nvm it did

#

how can i run multiple file in visual studio code

golden condor
#

pm2

acoustic wigeon
#

Hm

earnest phoenix
#

os.system kinda dont working

golden condor
#

use pm2

earnest phoenix
#

oh

#

its javascipt

#

whatever

mossy vine
#

how can i run multiple file in visual studio code
@earnest phoenix ???

earnest phoenix
#

whatever

opaque seal
#

Is there a big difference in performance from discord.js and jda libraries?

golden condor
#

@earnest phoenix you can use pm2 with basically everything

earnest phoenix
#

is it python

golden condor
#

no it is node.js

earnest phoenix
#

my bot is python ๐Ÿ˜ฆ

summer torrent
#

pm2 supports python

earnest phoenix
#

how i get the time of the song?

 const song = {
      title: songInfo.title,
      url: songInfo.video_url,
      author: message.author.tag
    };```
#

duration

#

thanks

#

songInfo.duration right?

#

dont work xd

summer torrent
#

console.log(songInfo) and check

earnest phoenix
#

@summer torrent tam ben yazฤฑyordum onu

#

ok

#
{
  likes: 757,
  dislikes: 72,
  video_id: 'xmZZb-313D4',
  video_url: 'https://www.youtube.com/watch?v=xmZZb-313D4',
  title: 'Cantando con DOKI Sentado debajo de un Mango',
  length_seconds: '128',
  age_restricted: false,
  html5player: '/s/player/4583e272/player_ias.vflset/en_US/base.js',
  full: true
}
summer torrent
#

length_seconds

earnest phoenix
#

but is just the seconds :c

summer torrent
#

you can convert to minute ยฏ_(ใƒ„)_/ยฏ

#

divide by 60

earnest phoenix
#

math.trunc(result)?

summer torrent
#

no

limber flume
#

hey, wondering how to add reaction to a embed discord.py

pale vessel
#

d o c s

limber flume
#

i cant find it in d o c s

tight forum
#

lol

royal portal
#

@wise prairie so

wise prairie
#

Hi

royal portal
wise prairie
#

yes

royal portal
#

are you just doing it in a normal message

#

like message.channel.send

wise prairie
#

yes

royal portal
#

you can't do it that way

#

you'll need to use it in an embed

wise prairie
#

! help here list of all commands for example

royal portal
#

yea use embeds

wise prairie
#

Is embeded showing web page prewiws ?

#

preview*

royal portal
#
const embed = new Discord.MessageEmbed()

.setDescription("[click here](www.google.com)")

message.channel.send(embed)
#

and that will have a text that says 'click here'

#

and when you click on it, you will go to the link

wise prairie
#

ohh

#

okey

#

thank you so much

royal portal
#

np hopefully it helped

cosmic girder
#

Does anyone know how to make a ping cmd

#

Like

#

t+ping

#

pong! 222ms