#development

1 messages · Page 702 of 1

valid frigate
#

i'm thinking there is a better way to do this but idk mmulu

#

if it's relevant the package i'm using to commuicate is https://veza.js.org/ (id call august but hes on mobile omegaLUL)

mild escarp
#

(Discord.JS)
How do I make a report command like, the input is /report @someone (reason) and I want it to be sent in an embed to a channel in my Discord server.
The output will be like:

User#0000 has been reported
(Reason)
Reported by UserWhoReported#0000

#

If someone could help that’d be great!

slender thistle
#

I'd suggest using two fields for that
Field1 name: Reported User
Field 1 value: (the reported user's name and tag)
Field2 name: Reported By
Field2 value: (the person who reported)

mild escarp
#

ok

grim aspen
#

Keep a database of the user and store it somewhere into another channel too

earnest phoenix
#

TR

if (!message.content.startsWith(ayarlar.prefix)) return; Bu Komutta
if (!message.content.startsWith("." && `<@${client.user.id}>`)) return; Bunu Yapınca Çalışmıyor. Yardım Edebilir Misiniz ?

ENG

if (!message.content.startsWith(ayarlar.prefix)) return; In This Command
if (!message.content.startsWith("." && `<@${client.user.id}>`)) return; Not Work . Please Help ?

#

does somebody know how to wait for a foreach loop to end in js?

#

need it ASAP

amber fractal
#

Afaik you cant

#

You can return a promise and get data out of it, but you still cant wait for that data specifically.

earnest phoenix
#

like i want to do something when a loop ends

amber fractal
#

Yeah ik

earnest phoenix
#

like sending results of whathappened in the loop

amber fractal
#

Im saying that isnt a possibility

copper cradle
#

@earnest phoenix that's not how && works

#

nor ||

#

you need 2 conditions

earnest phoenix
#

&& is one condition, they need two booleans

earnest phoenix
#

How can i fix this error? Its a error when i do !warn <mentios> Reason>

(node:6624) UnhandledPromiseRejectionWarning: TypeError: message.member.hasPremission is not a function
at Object.module.exports.run (C:\Users\wesle\Desktop\Funny bot\Commands\warns.js:8:25)
at Client.bot.on (C:\Users\wesle\Desktop\Funny bot\index.js:71:28)
at Client.emit (events.js:198:13)
at MessageCreateHandler.handle (C:\Users\wesle\Desktop\Funny bot\node_modules\discord.js\src\client\websocket\packets\handlers\MessageCreate.js:9:34)
at WebSocketPacketManager.handle (C:\Users\wesle\Desktop\Funny bot\node_modules\discord.js\src\client\websocket\packets\WebSocketPacketManager.js:105:65)
at WebSocketConnection.onPacket (C:\Users\wesle\Desktop\Funny bot\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:333:35)
at WebSocketConnection.onMessage (C:\Users\wesle\Desktop\Funny bot\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:296:17)
at WebSocket.onMessage (C:\Users\wesle\Desktop\Funny bot\node_modules\ws\lib\event-target.js:120:16)
at WebSocket.emit (events.js:198:13)
at Receiver.receiverOnMessage (C:\Users\wesle\Desktop\Funny bot\node_modules\ws\lib\websocket.js:789:20)
(node:6624) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:6624) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

#

If you will help me slide in my Dm or say it in this channel

#

@earnest phoenix message.author.hasPermission

#

i go to check it

loud salmon
#

that is the reason why its failing

earnest phoenix
#

if (!message.author.hasPremission("MANAGE_MEMBERS")) return message.channel.send("Sorry jij kan dit niet doen");

modern elm
#

premission

earnest phoenix
#

this don't work

modern elm
#

is spelled permission

#

;)

loud salmon
#

you have the incorrect spelling

#

it tells you

#

that the function does not exist

#

because

earnest phoenix
#

sorry my spelling is very bad

loud salmon
#

Premission

earnest phoenix
#

but thank you

#

Hey Im having a problem with something on my bot if anyone is aviable to help can you dm me.

sudden geyser
#

message.author won't work btw.
meow can you explain it

earnest phoenix
#

So basicly
im trying to get the bot help command into catagorys like !help fun !help info !help mod
but its not woroking when i do the !help (cat)

copper cradle
#

you should read that

earnest phoenix
#

you need to use arguments

#

hello

#

can someone tell me

grim aspen
#

@earnest phoenix is there an error?

earnest phoenix
#

Please enter at least 300 characters excluding special characters in your detailed description. Add your commands. Spaces or empty spaces are not counted.

grim aspen
#

300 words spaced

earnest phoenix
#

and it says that

grim aspen
#

simple as i can put it

earnest phoenix
#

but what i need to do i dont get it?

lusty dew
#

How can I make my purge command show the correct amount of messages deleted

#

D.js master

earnest phoenix
#

count the amount of messages you pass to the bulk delete method

#

what?

#

i dont understand

#

Please enter at least 300 characters excluding special characters in your detailed description. Add your commands. Spaces or empty spaces are not counted.

grim aspen
#

put a total of 300 words with spaces, and have; what it does, it's main help command, it's specialty

lusty dew
#

I already have
.then(messages => {....}

earnest phoenix
#

where i need to enter 300?

#

oh

#

wait

grim aspen
#

the long description

earnest phoenix
#

well did you fetch the messages?

#

in brief description of your bot?

lusty dew
#

But when I do true (the second param of bulkDelete) it returns 0 messages deleted when I’ve deleted 20

earnest phoenix
#

hello?

#

do you fetch messages?

lusty dew
#

The deleting of the messages work out

earnest phoenix
#

do you fetch messages to purge?

#

IS ANYONE helping me here?

lusty dew
#

Yes I fetch messages

earnest phoenix
#

no

#

ok so

#

if you put in !purge 20

#

Please enter at least 300 characters excluding special characters in your detailed description. Add your commands. Spaces or empty spaces are not counted.

#

then the first arg is the deleted count

#

dudes what i need to do

#

wth

#

it means exactly what it says

#

use your brain

#

@earnest phoenix enter 300 characters

#

but where

#

about your bot

#

in brief description?

#

no

lusty dew
#

Okay but that’s not accurate @earnest phoenix

grim aspen
#

in the long description

earnest phoenix
#

where then?

lusty dew
#

They can put 100 but in reality it only deletes 20 messages

earnest phoenix
#

@lusty dew ok, but when you fetch messages their should be a count

#

yes

#

but there is no any other description

#

HELP

#

@lusty dew the second parameter is whether to filter old messages because you can't bulk delete messages older than two weeks, setting the second parameter to true will filter it out

#

limit: integer

#

THERE IS NO OTHER

#

description

#

SOMEONE HELP ME

loud salmon
#

yall be nice

#

@earnest phoenix the black bar is where you need to add the long description

grim aspen
lusty dew
#

I know but when I put true then I do

.then(messages => {message.channel.send(messages.size)})
``` it returns 0
earnest phoenix
#

have you read what i said

#

well i know

#

jesus christ can no one use their brain today

lusty dew
#

Yes I’ve read it

#

I understand that

earnest phoenix
#

i use something similar but i can’t recall how i got the message count lmao

#

i know it’s simple but

#

lol

lusty dew
#

So my next question is if you would stop being so damn ignorant

earnest phoenix
#

ohh @loud salmon thanks

lusty dew
#

Is how can I get the actual number of messages deleted while still having true

earnest phoenix
#

so spider what should i write in brief description?

#

yes you can

loud salmon
#

@earnest phoenix write about your bot. talk about its features, its commands, and how it works

earnest phoenix
#

in both descriptions?

loud salmon
#

if you cant reach 300 characters, then you need to add more features

earnest phoenix
#

do i have to explain it like i should explain it to a kid?
set true on the second parameter
it will make old messages that can't be bulk deleted go boom from the collection
it returns the amount of messages that can and were bulk deleted

loud salmon
#

yes

#

in both

earnest phoenix
#

ok thanks

#

if it returns 0 it means that 0 messages have been bulk deleted

#

so, none

lusty dew
#

But that’s false

grim aspen
#

cry's right

lusty dew
#

It returns 0 when 5 messages have been deleted

#

That are old

earnest phoenix
#

you can't bulk delete messages older than 2 weeks

lusty dew
#

I know

earnest phoenix
#

so you probably have some other code deleting it too

#

using the DELETE request on the message itself

lusty dew
#

:facepalm:

#

Sigh

earnest phoenix
#

does it return 0 regardless in which channel, regardless of whether there have been recent messages or not

#

cry did explain it

lusty dew
#

It returns 0 when any messages have been deleted

earnest phoenix
#

you use messages.size right?

#

after using js bulkDelete().then(messages => { // code that you have });

#

@lusty dew

lusty dew
#

You don’t have to ping me wtf

earnest phoenix
#

well you weren’t responding...

#

a ping isn’t going to kill you either-

lusty dew
#

You just sent the message

earnest phoenix
#

ok

lusty dew
#

Give a person time to respond

earnest phoenix
#

sorry for harming you by pings

loud salmon
#

hey hey hey, clearly everyone in this conversation is worn out. My suggestion is that everyone take a 5-10 minute break

grim aspen
#

found this

lusty dew
#

No I just don’t like being pinged for no reason

loud salmon
#

go in a different discord channel, watch a youtube video, or just try and walk around for a bit

lusty dew
#

🤷

#
            const fetched = await message.channel.messages.fetch({limit: args[0]});
            message.channel.bulkDelete(fetched, true)
                .then(messages => {
                    message.channel.send(`:check: Deleted ${messages.size} messages`)
                });
#

This is my bulkDelete code

sullen yacht
#

He's helping you chill a ping won't kill you

earnest phoenix
#

is args[0] an integer or string

lusty dew
#

If it is a string it becomes an int

loud salmon
#

any more toxicity from anyone here and they get a break much longer than 10 minutes, kthx

lusty dew
#

:/

#

I have been muted before already

loud salmon
#

you can be muted again if the toxicity continues

earnest phoenix
#

my suggestion is to go to the official discord.js server

loud salmon
#

oh yea

#

that too

#

fug

lusty dew
#

🤷 whatever

earnest phoenix
#

yeah not that many boosters

#

lol

loud salmon
#

damn

lusty dew
#

If you guys don't want to help then don't have a development channel

earnest phoenix
#

???

loud salmon
#

people have been trying to help you though, but its just been a bit unclear

#

due to 3 people asking questions at once

lusty dew
#

🤷

loud salmon
#

if you summarize what you have done so far, and what you need help in one message, then it may be a bit of use

lusty dew
#

Eh idc anymore

loud salmon
lusty dew
#

Im just not gonna worry about it and leave it as it is

loud salmon
#

ok

grim aspen
loud salmon
#

oh wew

lusty dew
#

I am already in it

loud salmon
#

gg

lusty dew
#

I have asked there as weel

#

but no one responded

#

It's been a day

earnest phoenix
#

when?

#

what?

lusty dew
#

Yesterday

earnest phoenix
#

you can’t expect anyone to respond after a day...

#

even see the message after a day-

lusty dew
#

sigh

earnest phoenix
#

👌

loud salmon
#

people responded to help his problem

earnest phoenix
#

lmao

#

it wasn’t even yesterday

#

oh well time zones may be different

unkempt ocean
#

is there any way to reload an event ?

sudden geyser
#

what lib

west spoke
#

How dare a fellow neko be mean

sudden geyser
#

you don't have time to be mean

unkempt ocean
#

js

valid frigate
#

idk how to do it but id assume you would have to unbind then rebind the callback for an event

quartz kindle
#

js is not a library, its a language

#

if your library is discord.js, all events are saved in client._events, you can add/edit/remove them from there

hoary helm
#

uh help
is there any reason that discord.js v12 would consume way more memory than v11
i just migrated to discord.js v12 and i'm getting upwards of 100 MB RAM usage

#

meanwhile on discord v11 it was only around 25 MB

slim heart
#

Well there’s a lot more instances of a lot more things in master

#

Make sure to sweep messages to make sure your cache is gigantic

hoary helm
#

i just rebooted it and its at 25 again
and i do sweep messages

#

hopefully it doesn't go up again

unreal junco
#

discord.js
CODE
index.js


    // this channel is the assigned channel where the bot will play Guess The Number!
    let gsnChan = message.guild.channels.find(channel => channel.name === `guess-the-number`);
    let gsnc;
    if (!gsnChan){
      gsnc = "There is no **Guessing Channel** set for this server!"
    } else {
      gsnc = `<#${gsnChan.id}>` // gsnChan.id = get the id of that channel || gsnChan.name = get the name of the channel
    }

    let gchannels = JSON.parse(fs.readFileSync("./guesschannel.json",  "utf8"));
    if(!gchannels[message.guild.id]){
      gchannels[message.guild.id] = {
        gchannels: gsnc
      };
    }
    let gsnChannel = gchannels[message.guild.id].gchannels;
    console.log(gsnChannel)```
#

command

  if(!message.member.roles.find(r => r.name === botCommanderRole) || !message.member.permissions.has("MANAGE_CHANNELS")) return message.channel.send(`${emote.cross} You do not have access to use this command! (if this is a mistake tell us in our discord with **support** command)\nhint: bot commander role!`);
  if(!args[0] || args[0 == "help"]) return message.channel.send(`how do you use this command? example: ` + "`" + `${prefix}setchannel [#channel | channel id]` + "`")

  let gtnChannel = JSON.parse(fs.readFileSync("./guesschannel.json", "utf8"))
  gtnChannel[message.guild.id] = {
    gtnChannel: args[0]
  };

  fs.writeFile("./guesschannel.json", JSON.stringify(gtnChannel), (err) => {
    if (err) console.log(err)
  });

  message.channel.send(`${emote.tick} Successfully set the guessing channel to ${args[0]}`)

#

it keeps coming back as undefined

earnest phoenix
#

@unreal junco what exactly comes back as undefined?

unreal junco
#

just says undefined i

#

i think it means

#

the gsnchannel

#

it doesnt read the channel it was set to

#

in the command

#

the default works

#

but not when u use the command

#

once command is used it goes to undefined

valid frigate
#

first of all is there any chance you can use anything other than json for your db?

unreal junco
#

no 😦

valid frigate
#

json read/writes are subject to corruption

#

oh

unreal junco
#

any way to solve?

broken shale
#

use a database

unreal junco
#

arent i doing that already?

valid frigate
#

json is not a database

#

if you need one-file databases, you could look at sqlite

modern elm
#

if you like json, quick.db works pretty much the same way

unreal junco
#

quick.db doesnt work for me

sick cloud
#

@unreal junco why can't you use a real db

unreal junco
#

it doesnt work on my mac for some reason

sick cloud
#

you can host a database anywhere

#

just pay for a cheap vps and put a db on there

spark kelp
#

why i cant get shards with client.shards it returns undefined ?

zealous veldt
#

]] moreinfo

covert turtleBOT
#

If you want people to be able to assist you, please provide more information, such as what library and language you're using, the code in question and what you are trying to do and/or what is causing the error.

spark kelp
#

sorry im just trying to use dblapi js setInterval(() => { dbl.postStats(this.client.guilds.size, this.client.shards.Id, this.client.shards.total); }, 1800000); but here client.shards returns undefined | also client.guilds.size okay

zealous veldt
#

you capitalized the I in id @spark kelp

#

Is that it?

spark kelp
#

nope all shards property is undefined | and i get this code from dbl api docs

viral spade
#

When the discordjs shardingmanager starts a new shard, will servers from the already existing shards be moved to the new shard?

sullen yacht
#

The buttons do nothing although they should

short siren
#

I'm assuming it's your html code?

#

If so show the code

sullen yacht
#

Yeah I put the whole code in the description box

mossy vine
#

you are trying to execute javascript

#

which you cant

sullen yacht
#

No, theres no js

#

Just html and css

mossy vine
#

onclick triggers js iirc

sullen yacht
#

Oh right

#

How do I do it without onclick? I can't find much that covers it

#

Ok nvm I changed it up and i like it now.

quartz kindle
#

@viral spade shards never change while the bot is running, only if the bot is restarted/disconnects

earnest phoenix
#

connect econnrefused 127.0.0.1:27017 on mongo compass

#

How do i fix

quartz kindle
#

where is mongodb hosted?

#

where are you running compass from?

amber fractal
#

In this server? You dont.

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

sudden geyser
#

idk maybe you'll catch pokemon hiding in the code

ornate shoal
#

Since some people here seem to have experience with digitalocean

#

they say 'Inbound bandwidth to Droplets is always free.'

#

So incoming Discord events do not count for the 1tb transfer limit?

#

I'm considering moving my bot to a vps instead of my home server, i did read the pin

sinful lotus
#

from what I understand from your explanation, download is free, upload is capped

copper cradle
#

@sullen yacht just use a div and style it

#

then you can add a link inside of it

#

<a href="idfk">pitucas</a>

stray garnet
mossy vine
#

its correct

stray garnet
#

huh

copper cradle
#

that's not a weird output

stray garnet
#

ok

unkempt arch
#

Hey yall. In sharding, do some of you get Error 1001?

mossy vine
#

what is the description of the error

unkempt arch
#

Wrong one wait

#

[2019-09-26 03:23:01]: LOG Shard 1/1 disconnected with the error Error: 1001: ,
at WebSocket.ws.onclose (/usr/src/app/node_modules/eris/lib/gateway/Shard.js:1655:67),
at WebSocket.onClose (/usr/src/app/node_modules/ws/lib/event-target.js:124:16),
at WebSocket.emit (events.js:209:13),
at WebSocket.emitClose (/usr/src/app/node_modules/ws/lib/websocket.js:191:10),
at TLSSocket.socketOnClose (/usr/src/app/node_modules/ws/lib/websocket.js:850:15),
at TLSSocket.emit (events.js:214:15),
at net.js:588:12,
at TCP.done (_tls_wrap.js:479:7) ,

inner jewel
#

close code 1001 should be cf load balancing

unkempt arch
#

So it cant be fixed?

amber fractal
#

Load balancing.

inner jewel
#

all libraries should be able to handle that

unkempt arch
#

So its pretty much normal?

wheat jolt
#

why formChan.type is undefined

#

d.js

cobalt umbra
#

Id is integer not a string. At least in d.py

warm marsh
#

In Java am I better off statically loading commands or is dynamically fine?

eternal mesa
#

In djs they are strings

slender thistle
#

They are sent as strings but discord.py converts IDs to integer

eternal mesa
#

^

grim aspen
#

@wheat jolt did you ever define formChan in the first place?

#

i feel like you've never defined

wheat jolt
#

nvm anyways

grim aspen
#

wait

wheat jolt
#

it's defined

agile needle
#

Help me please

spare goblet
#

how

grim aspen
#

that doesn't look right

agile needle
#

`` if(message.content.startsWith(prefix + "clear")) {
message.delete();
if(!message.guild.member(message.author).hasPermission("MANAGE_MESSAGES")) return message.channel.send("Vous n'avez pas la permission !");

    let args = message.content.split(" ").slice(1);

    if(!args[0]) return message.channel.send("Tu dois préciser un nombre de messages à supprimer !")
    message.channel.bulkDelete(args[0]).then(() => {
        message.channel.send(`${args[0]} messages ont été supprimés !`);
        clear.clear().then(member => {
          var clear_embed = new Discord.RichEmbed()
          .setColor("#40A497")
          .setTitle("Clear :")
          .addField("Messages supprimés:", `${args[0]}`)
          .addField("Dans le salon :", `${message.channel.name}`)
          .addField("Modérateur :", `${message.author.username}`)
          client.guilds.get("481105805161005066").channels.get("488344143047819282").send(clear_embed)
          console.log("Un modo a supprimé des msg !")
      });
    });
}
    ``
grim aspen
#

i don't think you're supposed to use of

agile needle
#

Help me

warm marsh
#

Of is correct.

spare goblet
#

what's your error?

agile needle
#

Do you speak French?

spare goblet
#

no

warm marsh
#

@wheat jolt what version of djs?

wheat jolt
warm marsh
#

Alright.

slim heart
#

Whats really the best way to do counter things in a database? Im doing it for a punishment system, and it works, but i feel like theres a much better way to do it. At the moment of the punishments database like this: {amount: #, role: "id", users: {}}, and .users will be filled like {id: amount_of_offences}, ex: {"142408079177285632", 2};
and i've a feeling theres a much better way of doing it but i dont know

mild escarp
#

how do i edit a message that has already been sent of a bot in discord.js ?

slim heart
#

@mild escarp Message#edit()

grim aspen
earnest phoenix
#

discord.js how can i check if someone is in a voice channel

grim aspen
earnest phoenix
#

thanc

mossy vine
#

if i declare a variable with const will it not be usable outside of the current scope?

valid frigate
#

cyber const just means the value is immutable and can't be changed unlike let

#

but you must initialize it

mossy vine
#

yes, i know

valid frigate
#

also it's not like global so yeah

#

outside of whatever scope you're talking about

mossy vine
#

ah

valid frigate
#

you can't use it mmLol

mossy vine
#

well thats fucked

valid frigate
#

let/const are scoped yes

mossy vine
#

cuz ts is stopping me from declaring it outside of the scope

#

does ts not let me call my variables node or some shit

#

@valid frigate ^

valid frigate
#

lmao whta

eternal mesa
#

Wot

mossy vine
valid frigate
#

d

#

cyber

mossy vine
#

i dont understand okay

eternal mesa
#

Wot

valid frigate
#
const node: any
const nodee = new Server('main')
stone robin
#

Instead of js can I make a bot in java

valid frigate
#

why are you declaring node lmao

mossy vine
#

yeah but i dont have node declared anywhere before that

#

so like

#

what

valid frigate
#

no cober around the error

#

cyber

#

at the beginning

eternal mesa
#

const node: any = new Server(‘main’)

loud salmon
#

@stone robin it doesn't matter what language you make a bot in

stone robin
#

Is js better or py?

valid frigate
#

wait wait cyber

eternal mesa
#

Both are good

slender thistle
#

Subjective

valid frigate
#

is that veza

mossy vine
#

yes

eternal mesa
#

It depends what you are better at

valid frigate
#

veza has types lmao

amber fractal
#

@stone robin it's preference

mossy vine
#

i know

#

but im trying to avoid types right now

#

and just get the entire thing to work

stone robin
#

Js

valid frigate
#

therefore

#

const node: Server = new Server('main')

mossy vine
valid frigate
#

no

#

cyber

#

import {Server} from 'veza'

mossy vine
#

oh there we go

#

only 9 more errors left

valid frigate
#

what are you tryna do

#

cluster?

mossy vine
#

i already managed to do it at the smallest possible scale

#

do i do it similarly in the file where i create the veza client?

valid frigate
#

yes

#

except obviously you need to do new Client

mossy vine
#

wait, so how would i create my Client in the d.js ready event

#

and use it outside of the scope

valid frigate
#

create an extended client using extends

#

like class YourClient extends Client

#

then give it a property with the veza client in it

mossy vine
#

is that really necessary

valid frigate
#

probably not

amber fractal
#

Typed langs for ya

valid frigate
#

lmao

amber fractal
valid frigate
#

yes mmLol

eternal mesa
#

Typed is better

amber fractal
#

OtherClient client extends Client implements ClientsClient

#

I hate typed langs

#

The amount of redundancy is annoying

mossy vine
#

node: any fixed it cosmicbrain

#

this is the part where i pretend i understand what im doing, right?

amber fractal
#

Yes

sullen yacht
#

How do you change simple stuff on your bots profile? Like the color of buttons etc?

west spoke
#

css

sullen yacht
#

Yeah but how do you reference them

#

It might be easy but i don't use css so i might need to learn it

west spoke
#

ctrl-shift-I and get them

sullen yacht
#

Okay

void saffron
#

?help

eternal mesa
earnest phoenix
#

hey i am trying to reslove that problem but i cant any help please

#

discord.js

quartz kindle
#

invalid permission string or number

#

what permission did you try to use?

copper cradle
#

^

earnest phoenix
#

@quartz kindle
for(let i = 0; i < Categories.length; i++){
server.createChannel(Categories[i][0], {type,
permissionOverwrites: [{
id: server.id,
deny: Categories[i][2],
allow: Categories[i][1]
}]
}
)
}

lunar crystal
#

When we do the bot, we dot it on Visual studio code or directly in the developement discord topic ?

#

( I'm a begginner ^^' )

twilit rapids
#

I'm not exactly sure what you mean, but I can hit you up with a guide to get started on the basics and which explains what to do and what not to do

lunar crystal
#

Ok thanks u very much 😄

quartz kindle
#

@earnest phoenix what is Categories[i][2] and [1]?

#

are you using discord.js v11 or v12?

earnest phoenix
#

v12 i think uhm cat1 is a jason file that make catergories and cat 2 makes channels

unkempt arch
#

So for error 1001, its normal to recieve that kind of error?

west raptor
#

uh

#

no?

earnest phoenix
#

error 1001 where

west raptor
#

that's not even a valid error code afaik

earnest phoenix
#

it's not a http code

#

@unkempt arch 1. where error 2. screenshot pls 3. Please explain which lib u using pls thanks

#

1001 errors for a websocket are normal, it's usually just cloudflare

inner jewel
#

not really an error

#

just a close code

earnest phoenix
#

^

unkempt arch
#

So its cloudflare's fault?

#

And not my side?

earnest phoenix
#

simplified, yes

unkempt arch
#

Any other way to at least reduce the error?

inner jewel
#

no

unkempt arch
#

So i should expect that this will spam my console when shards are increasing in number right?

inner jewel
#

you should complain to your lib devs for not properly handling a normal close

unkempt arch
#

Eris tho has proper close for it tho? It aint crashing.

quartz kindle
#

which lib are you using?

unkempt arch
#

Eris?

quartz kindle
#

are you listening to the error event?

unkempt arch
#

Yeah. Full process.

quartz kindle
#

well you could simply not log that error when it comes

#

if the process is not crashing, and the shard reconnects successfully, then the lib is handling it correctly, your choice to log it or not

unkempt arch
#

Ill take the no logging one

quartz kindle
#

you can log it as a single line info text, instead of the full warning/error object

unkempt arch
#

Will do, thanks!

heavy marsh
#
const activities = [{
        "text": `${prefix} | ${client.guilds.size} servers!`,
        "type": "STREAMING"
    },
    {
        "text": `${prefix} | ${client.users.size} users!`,
        "type": "STREAMING"
    }]

setInterval(() => {
    client.user.setStatus('dnd')
    const activity = activities[Math.floor(Math.random() * activities.length)];
    client.user.setActivity(activity.text, { type: activity.type , url: "url"}); 
}, 20000);

CAN anyone help to fix this ... - as the status doesnt update when the bot joins or leaves a guild ... - its on ready.js

sudden geyser
#

well, it's in ready.js, so it wouldn't occur when your bot joins/leaves a guild (unless you have it wrapped inside a listener, but that's a big no no).

drowsy sentinel
#

Why would you need to set the status to dnd every 20 seconds?

quartz kindle
#

@heavy marsh if you want to update the numbers on an interval, you have to get their sizes again

#

the way you're doing it now, you're saving them in activities and then reusing the same saved value on every loop

heavy marsh
#

thanks

languid dragon
#

@earnest phoenix no, you should not use this channel for general conversation, it doesn't matter how long slowmode is, you shouldn't be misusing channels if you want to stay unmuted tbf

frank plinth
#

im tryin to make a server but it say memberCount is undefined

earnest phoenix
#

what the fuck did i just witness

oak imp
#

@earnest phoenix what library?

#

Oh, well I assume Py has a function similar to JavaScripts setPresence()

#

You should start your search there.

#

I would try to be more helpful but I know Py about as well as a blind person knows what the colour red is.

west spoke
#

I could help.

loud salmon
#

@west spoke he got muted for a week so it doesnt matter oof

west spoke
#

OH LOL

earnest phoenix
#

Is Eris better than discord.js?

valid frigate
#

depends on what you want

sinful lotus
#

if you want straight out low memory usage

#

go for eris

valid frigate
#

generally less utilities than discord.js but much better for sharding

#

you have to reference the actual discord api docs for some cases

#

but it's fine really mm

sinful lotus
#

if you are willing to modify d.js for memory usage while keeping the ease of access then d.js

#

d.js is good on sharding now

valid frigate
#

is it really

sinful lotus
#

I dont see it inferior to eris now

#

specially with Kurasuta like Eris Sharder

valid frigate
#

ah fuck

sinful lotus
#

the trade offs is the memory Usage

#

if you are not willing to modify d.js for memory

#

then go use eris

valid frigate
#

eris is ok

sinful lotus
#

its already modified for less memory after all

#

but if you are williing to spend a lot of time studying d.js

#

then I doubt you will use eris

valid frigate
#

ah fuck

#

i already built a process manager for eris mm

#

cant switch

sinful lotus
#
  • Kurasuta's ipc is better than Eris Sharder
#

which makes me seamlessly transfer data from one shard to another

valid frigate
#

preference? mmLol

sinful lotus
valid frigate
#

also i have no idea what kurasuta is

sinful lotus
#

if you know what to do on d.js

#

Kurasuta is inspired by eris sharder but for d.js

#

so if you know eris sharder thats what kurasuta is

valid frigate
#

cba to touch eris sharder mmLol

sinful lotus
#

Im just lazy to rewrite my whole code to eris last year

#

thats why I took the more longer route

#

lmao

#

but the results is great

#

so now I have no reasons to switch

valid frigate
#

i switched to eris in like 2 days

#

i guess it's just what you build around tbh

sinful lotus
#

I dont want rewriting 250 files to eris

valid frigate
#

changing libs is unfortunate since it requires a rewrite of everything

sinful lotus
#

thats why why not just turn d.js to be better in cache

#

iinstead of rewriting

valid frigate
#

i have like a cache size of 5

sinful lotus
#

I dont uncache members and users

#

my cache for messages is 100

#

sweeps every 10 mins

drowsy sentinel
#

neat, what's your cachelifetime at?

#

and wouldn't sweeping interfere with the accuracy of your logging? (msgDelete, msgUpdate)

spark kelp
#

can users vote with bot commands using dbl api ?

sinful lotus
#

@drowsy sentinel 30 minutes lifetime and not really

drowsy sentinel
#

Ah, I figure 30min is enough time to be considered cached.

nimble creek
#

Could someone please give me a decent guide on how to make a ban command in discord.py? I keep searching but can't find any :P

slender thistle
#

@spark kelp no

earnest phoenix
#

@nimble creek we won't spoonfeed

nimble creek
#

I'm not asking for someone to sponfeed me, I'm asking if someone could give me a guide sice I can't find one

indigo geyser
#

@Proxy's Alt#5703

#

Rip

covert tartan
#

my 12k guild bot uses 550mb ram with discord.js, its up to you to be clearing your cache (although d.js could be giving better controls over it)

quartz kindle
#

my 1.5k guild bot uses 50mb ram with djs-shenanigans (200-300mb with normal discord.js)

grim aspen
#

@indigo geyser next time I suggest not to spoon feed, no one really learn from it

indigo geyser
#

I only wanted to help him

grim aspen
#

Yeah, I can understand. The best you can do is give him a tutorial website and a library website like discord.js.org

indigo geyser
#

attack beginners

#

@grim aspen wait, spoon feed = give the code without explaining?

grim aspen
#

No, attacking a beginner is basically harassing them

indigo geyser
#

And spoon feed?

grim aspen
#

Spoon feed is basically what you said

indigo geyser
#

Ok

rugged berry
#

Hi, I fixed my bot problem, what do I need to do now for it to enter the server? Who do I talk to?

#

Anybody know?

quartz kindle
#

if it was muted or kicked, contact the mod who did it.

#

if it was not approved, submit a new application on the website

rugged berry
#

thanks

abstract crow
cursive dagger
#

Good tutorial ^ (recommended for beginners)

abstract crow
#

Thanks

#

I felt things like choosing a code editor just has to go in there. It was big for me and stuff like that.

sudden geyser
#

Guide looks nice. You could add some basic code for js and py from the homepage too.

vernal basin
#

I just began my first discord bot project and this guide is going to save me thanks

valid frigate
#

Vinnie did you include how to shard

#

haven't read it yet but will in a sec

mossy vine
#

@abstract crow here is some feedback ig

  1. you arent really mentioning that js can be used outside of the web with node.js
  2. visual studio can also be used for js development (and its quite a powerful tool for the job, but also quite heavy)
  3. recommend more learning resources
  4. telling people to add their non-unique bots to dbl might not necessarily be a good idea. there is already an oversaturation of mediocre non-unique bots
  5. mention how important it is to secure your token before publishing to github
  6. the server recommendation part includes too many information that a beginner might not know or care about, such as ip addresses, bandwith, custom image support, etc.
  7. as vysion said, sharding
valid frigate
#

but it makes documentation much easier

devout chasm
#

idk about sharding for beginners lul

abstract crow
#

^^^^

#

@mossy vine Thanks for the honest feedback. The servers part I said was for when you get more advanced, and I don't think sharding is anywhere on a beginners mindset, and as a mod for DBL we are supposed to encourage adding your bot so I added that in there. It doesn't really matter if they are all the same, its just we want to welcome them type of thing. I will take a look tho. Thanks 🙂

#

Docs going up on gitbook soon

valid frigate
#

@abstract crow my feedback

  • better formatting: text is hard to tell apart (lists, etc)
  • w3schools isn't really a good resource
  • like cyber, tell people to think about what other tusers would want before creating a bot to avoid generic bot making
mossy vine
#

there are some very generic ideas at the bottom

abstract crow
#

Updated the pins

#

Working on gitbook rn

valid frigate
#

i should make an entire seperate guide for sharding

#

djs docs don't cover it

#

well*

mossy vine
#

discordjs.guide covers it very well tho

valid frigate
#

hmm

mild escarp
#

@abstract crow that is a nice website

abstract crow
#

Well it really isn't my website, but rather just a guide hosted publicly but thx

mild escarp
#

i know but its good for begginers

abstract crow
#

Thanks 🙂

copper cradle
#

@abstract crow can I see?

abstract crow
#

pins

#

Still transfering from gdocs to gitbook

#

Ok its fully up now

valid frigate
#

@abstract crow can you invite me as a collaborator, i could help format the docs mm

abstract crow
#

Can't I have to get pro

valid frigate
#

f

abstract crow
#

nvm got a trial

earnest phoenix
#

has anyone some ideas for my bot / what i should add?

#

Bc im stupid and cant come over with original ideas

abstract crow
#

Check pins

stray garnet
#

how to do an prefix with space between prefix and command?

earnest phoenix
#

Should a movie command be limited to NSFW Channels ?

sudden geyser
#
  • General: if it can return nsfw info, yes.
  • Woah: Add a space at the end of the prefix (assuming it's in a value or something)
glad herald
#

I have an idea.

#

You can have webcams on discord servers. When Fred boat joins and in a webcam call it should try to make it show the video. Just an idea

loud salmon
#

we arent really a suggestion discord @glad herald 🤷

glad herald
#

well do something with that idea. Its a great idea.

loud salmon
#

also

#

bots aren't allowed to broadcast video, its user only @glad herald

earnest phoenix
#

What!?

#

Bots can‘t use the purple status?

#

Or have I misunderstood something?

loud salmon
#

no, bots can use streaming/purple status, but broadcasting video to a channel is only for users @earnest phoenix

#

also yea we aren't the fredboat support server @glad herald

earnest phoenix
#

Aight!

soft eagle
#

how fast can a bot change game status online status and pfp on milaseconds?

loud salmon
#

@soft eagle absolute minimum is 12 seconds. But we would prefer that you do something like 120 seconds

soft eagle
#

i have game as 1 minute, status 3 minutes and pfp 1 hour

earnest phoenix
#

Auto changing pfp!?

#

How‘s that

loud salmon
#

thats good @soft eagle

#

@earnest phoenix every 15 minutes or so you can change the pfp

earnest phoenix
#

That‘s nice didn‘t know that

slim heart
#

how would one go about formatting a database update of a key in "whatever.key.etc" into the actual update object

#

so like set("thing.value", true) would do update({thing:{value: true}})

quartz kindle
#

if your input is a string, you can split it on "."

#

and iterate over the array and build a json obj

#

another option is to use eval

slim heart
#

but how would i be able to go even further

#

like "whatever.thing.otherthing.value"

#

like idek where to start

amber fractal
#

What db are you using

#

Wait

quartz kindle
#

a recursive function or a loop

slim heart
#

im trying a for loop but im lost in how i can go into a newer object

quartz kindle
#

if you split it on dots, you get an array, you can loop over it infinitely

slim heart
#

like i can get it like {a: {b: value}} but not {a: {b: {c: value}}

#

the issue isnt making the loop ive no idea the logic behind how i could actually do what i need

quartz kindle
#

it is a bit tricky, but there are many ways to do it

slim heart
#

What about setting the value after cuz that was the big part for me? I guess checking against the index and seeing if it’s the last one?

amber fractal
#

That would probably make the most sense

sick cloud
#

wew one more day

jade thistle
#

Reviewed the bot rules again (cause i forgot half of them)
Bots will receive a mute if they:
• Spam testing channels
does that include if the bot is commanded to spam? (ex: pref!spam "text" 12)

unique nimbus
#

yes

jade thistle
#

okk

unique nimbus
#

spamming is not allowed

jade thistle
#

good to know

mossy vine
#

how is a spam command even allowed

#

isnt it breaking tos

loud salmon
#

@jade thistle if you have a spam command in your bot, its going to get declined

jade thistle
#

okk

#

then im gna remove

loud salmon
#

thank you

jade thistle
#

thanks for the explaination

loud salmon
#

also cyber is right

#

its against discord tos

dusky mist
#

guild.owner returns a member or an user?

valid frigate
#

returns the owner as a member of the guild iirc

dusky mist
#

Ok ty

timber cloud
#

can you make python not?

#

bot

jade thistle
#

i heard that it is possible

split hazel
#

What's the best way to add a timeout to eval()

#

so for example if i start an infinite loop, it will timeout and stop after 10 seconds or so

#

pretty much to any code

quartz kindle
#

the only way i see to do that would be to run the eval in a worker thread or a child process

steel cloak
#

what's like the best way to do image manipulation with nodejs?

amber fractal
#

canvas

#

but just a warning, the canvas api is really dumb (atleast imo)

steel cloak
#

yeah i worked with it a little and didn't really understand it so i was just wondering if there was something better lol. thanks though,, time to learn c a n v a s

quartz kindle
#

its not dumb lul

amber fractal
quartz kindle
#

there are alternatives tho, if you want easy to use but terrible performance, go for jimp

#

if you want best performance but difficult to set up, go for sharp

amber fractal
#

I hate working with canvas because it's more complicated than it needs to be

quartz kindle
#

if you want flexibility and full control, go for canvas

#

if you want to go external, go for graphicsmagik or imagemagik

#

i like working on canvas because it lets me do literally anything i want

abstract crow
#

Do you guys code directly off your server or just locally?

reef anchor
#

Locally, generally use git local build/test and CI pipeline to build docker image and push to prod when merged.

hushed berry
#

errr

#

locally

#

No sane person edits production code live on the server

abstract crow
#

No I meant like beta

hushed berry
#

even still

abstract crow
#

I didn't know if that was easier in case you are on the go and forgot to push on github

limpid flower
#

I'm pondering ways to bypass the 100 message limit on TextChannel.bulkDelete in discord.js. I've thought of just getting a huge collection, filtering out old messages, splitting up the collection into pieces of size 100, then using a for loop to await bulkDelete each piece. Does this seem like a decent idea, or would it ultimately fail?

knotty steeple
#

isnt that just api abuse

limpid flower
#

Maybe

hushed berry
#

The max is discord imposed afaik

earnest phoenix
#

SamuraiStacksToday at 12:04 AM
isnt that just api abuse
it isn't

#

api abuse would be to automate that process and keep it running for x amount of minutes/hours

#

some libraries do the same as proxxa proposed; split the requests into batches of 100 messages/request

hushed berry
#

I mean, you also can retrieve in groups of 100

#

so like

#

prechunked for ya

knotty steeple
#

ok im just dumb

earnest phoenix
#

the problem comes when you need to do filtering

abstract crow
sudden geyser
#

you're assigning it, not comparing

knotty steeple
#

^

abstract crow
#

omg I am so stupid

sudden geyser
#

big brain

abstract crow
#

thx guys 🙂

#

jk I just want to implement it for the future. Thanks though guys. I am so stupid lol

knotty steeple
abstract crow
knotty steeple
#

vinnie

#

are u worse than me

abstract crow
#

I said I was going to make it one line now lol

knotty steeple
#

ok good

#

smh

abstract crow
#

if(thumbnail) newEmbed.setThumbnail(thumbnail);

earnest phoenix
#

i mean if you have trouble reading code it's not wrong to place brackets to distinct it

knotty steeple
#

huh

abstract crow
#

Good point. Its just I want cleaner code, so for me it isn't about lines or anything, but I want to learn and utilize Javascript in how it usually is coded in

sudden geyser
#

I like keeping the brackets even if it's one very short line.

#

but I hate this:

if (true) return true;
else { ... }```
abstract crow
#

Same same

#

But I mean I guess it all just depends

#

idc really but

hushed berry
#

"e"

limpid flower
#

Nikki, you referring to the screenshot SamuraiStacks posted?

frozen wyvern
#

bonjour

#

jai une question urgente

#

je voudrais metre un bot sur mon discord et qu il me dise les kilometre sur le discord

#

les kilometre de eurotruck simulator

knotty steeple
#

wrong channel

hushed berry
#

yesh @limpid flower

limpid flower
#

P sure it says e because in the if statement, it actually sets e to "e" instead of checking if e is "e"

hushed berry
#

yeah ik

knotty steeple
#

and im referring to this

limpid flower
#

mmk

#

ah

#

didn't read the entire conversation

paper dagger
#

Hey new to bots here. I want to add the Mudae (Mudamaid) bot to my server how can I

earnest phoenix
west raptor
#

qt faq 1 -c @paper dagger

covert turtleBOT
west raptor
#

oh wait

#

to your server

#

uhm

paper dagger
#

Im like halfway there but im too tired to keep trying lol

#

I think

loud crypt
#

2b join

mild escarp
#

does someone know how to make a bot send a message whenever a youtube video is posted in discord.js

amber fractal
#

I dont know if you can do it as soon as it's uploaded, but if you use the yt api, you can get the latest vid of a creator and see if it's the same as the last time you checked

#

I'd just have that on an interval every so often

limpid flower
#

@amber fractal Seems like api abuse

amber fractal
#

I'm saying like 10 minutes

limpid flower
#

That's better than what I thought you meant

abstract crow
toxic oracle
#

@abstract crow u should look into notion

#

its v nice

abstract crow
#

I'll take a look. Thanks 🙂

hushed berry
#

@toxic oracle notion is more for wiki kind of stuff tho

#

@abstract crow i use clubhouse for task tracking. ive also heard that asana is decent

abstract crow
#

oo clubhouse looks pretty

toxic oracle
#

@hushed berry it has good support for literally everything

#

i know that because i use it in a lot of different cases

hushed berry
#

ye me too

#

its just not a great fit for task tracking though

abstract crow
#

I mean I have heard of notion I think and I have also heard of Asana but never ClubHouse. I don't get the stories part though

toxic oracle
#

That will be your project app

#

ie front-end, backend

hushed berry
#

no

#

thats not true at all

#

stories are basically the medium tier of tasks

hushed berry
#

Is anyone here proficient with fluxlang?

lunar crystal
#

I can't start my bot

#

i'm coding on visual studio

mossy vine
#

any error messages?

#

and the editor doesnt matter, the language does

lunar crystal
#

Ok

#

I'm on node.js

sullen yacht
#

I don't do js but isn't it like const <name> = require("discord.js");

lunar crystal
#

I thinks it was const require = ("discord.js")

vernal willow
#

it is const <name> = require("discord.js");

#

How mine is setup:
const Discord = require('discord.js');
const client = new Discord.Client();

lunar crystal
#

Ok thank u

vernal willow
#

No..

lunar crystal
#

I made it like that

vernal willow
#

do it like this

lunar crystal
#

ok

vernal willow
#

const Discord = require('discord.js')

lunar crystal
#

Is it better ?

vernal willow
#

yes

lunar crystal
#

Ok

#

and then client.login ("<Token>")

quartz kindle
#

variables are case sensitive. you should probably learn some basic javascript first

#

and its not the id the goes there, its your bot token

slender thistle
#

That sounds like a funny thing to do
Make client.login support IDs but require token when the script is run and then if the ID under entered token does not match, close the program

lunar crystal
#

Ok

#

@quartz kindle Yes that what I was trying to say sorry :/

lunar crystal
#

For activate the bot ? What i'm suppose to do ?

quartz kindle
#

run the code?

earnest phoenix
#

(node:6230) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, stat '/app/ImageGenv2'

#
const Discord = require('discord.js')
const { get } = require('snekfetch')

module.exports.run = async (client, message, args) => {
  let url = `https://nekobot.xyz/api/imagegen`;
  get(url)
  .query({ text:`${args.join(' ')}`})
  .end((err, response) => {
    message.channel.send({ file: response.body.message })
  })
}```
#

Nvm fixed

sudden geyser
#

psst, snekfetch's deprcated. Maybe use node-fetch 👀

stray garnet
#

Im trying to make an Setbio Command but it dont saves it.

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

exports.run = async (neko, message, args) => {
  
  if(args[0] === "setbio") {
    const NewBio = new RP({
  bio: args[1]
        });
        await NewBio.save().catch(e => console.log(e));
    message.channel.send("Succes")
    return
   }

  RP.findOne({
            bio: args[1]
        }, (err, bio) => {
            if (err) console.error(err);
            const memberInfo = new Discord.RichEmbed()
                    .setAuthor(`${message.author.username}`, `${message.author.displayAvatarURL}`)
                    .setThumbnail(`${message.author.displayAvatarURL}`)
            .setColor("#ff0000")

            if (!bio) {
                memberInfo.addField('Bio', `Has no Bio`);
            }
            else {
                memberInfo.addField('Bio', bio.bio);
            }

            return message.channel.send(memberInfo);
        });
  
}
module.exports.help = {
  name: "profile",
  aliases: []
}
  

Output:

late hill
#

You're saving the bio and that's it

#

If you want them linked to a user

#

You're gonna need to save some kind of reference to the user together with the bio

#

user id would be perfect for that

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

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

  const user = message.mentions.users.first() || message.author
  
  if(args[0] === "setbio") {
    const NewBio = new RP({
  bio: args[1],
  userID: user.id,
  serverID: message.guild.id
        });
        await NewBio.save().catch(e => message.channel.send(e));
    return
   }

  RP.findOne({
      serverID: message.guild.id,
      userID: user.id
        }, (err, bio) => {
            if (err) console.error(err);
            const memberInfo = new Discord.RichEmbed()
                    .setAuthor(`${message.author.username}`, `${message.author.displayAvatarURL}`)
                    .setThumbnail(`${message.author.displayAvatarURL}`)
            .setColor("#ff0000")

            if (!bio) {
                memberInfo.addField('Bio', `Has no Bio`);
            }
            else {
                memberInfo.addField('Bio', bio.bio);
            }

            return message.channel.send(memberInfo);
        });
  
}
module.exports.help = {
  name: "profile",
  aliases: []
}
 

is that better? @late hill

late hill
#

yes

#

but setbio will allow people to create multiple bios

#

and fill up your database

#

So you should do something about that

stray garnet
#

but what

late hill
#

Instead of always creating a new entry

#

You can check if there's already one created

#

If so, just edit that one

stray garnet
#

but how

late hill
stray garnet
#

but how

#

xd

late hill
#

Use findOne in your setbio to check if they already have one

#

if yes, edit the bio, save

#

if no, create a new one

quartz kindle
#

just assign it to some unique key

#

like guildID+userID

#

or just userID if its not guild specific

#

i can see that you're already using them, there should be a way to set them as the primary key no?

#

so if they already exist, it will be updated, if not, it will be created

stray garnet
#

any Example please?

quartz kindle
#

i dont use mongo

#

but looking at their docs, you should be able to achieve that by creating a unique index

late hill
#

Using Mongo's unique indexes will most likely throw an error when you try to create another document with the same index

#

So you'd still have to check yourself

quartz kindle
#

he should be able to use update with upsert:true

#

instead of insert

#

but i dont use mongo so idk

#

also depends on how mongoose handles it

#

you should look into the mongoose docs

earnest phoenix
stray garnet
#

Its dispatcher.end

#

Its Ends all

warm marsh
#

DJS, Am I better using sharding or cluster?

paper dagger
#

I was able to do it , was way simpler than i thought

#

My prob anyway

earnest phoenix
#

I’m using quick.db leaderboard on my website but all the data is all in one line how do I make it like 1. Is in a box 2. Is in a box ect

#

?

stray garnet
#

Anyone Knows how i can Update an Object in MongoDB?

steel heath
#

.findOneAndUpdate()?

#

.findOneAndUpdate({ name: "Old Name" }, { name: "New Name" }); iirc

quasi forge
#

Guys, is it possible for discord bots to listen to the voice activity. If yes, child you please provide links to where I can learn more about this? If yes again, please provide those links.

earnest phoenix
#
i tried : 
  <div class="card-columns">
          <%for (var i = 0; i < resp.length; i++) {%>

          <div class="card">
            <h3 class="card-header"><%=id%></h3>
              </div>
          </div>
      <% } %>

resp.length is = 10
id is = to the IDs of top 10
but all the IDS are all together how to i push each ID to a sepearate card / box

steel heath
#
<div class="card-columns">
    <% for (var i = 0; i < resp.length; i++) { %>
    <div class="card">
        <h3 class="card-header"><%=id%></h3>
    </div>
    <% } %>
</div>``` try this @earnest phoenix
west raptor
#

@quasi forge what library?

quasi forge
#

Serenity

west raptor
#

hmm

earnest phoenix
#

EJS

west raptor
#

serenity I'm not sure about

earnest phoenix
#

@steel heath same output

#

all IDs are still together

quasi forge
#

Welp any is fine, I can understand the basic theory and I might be able to translate. @west raptor

steel heath
#

maybe theres something wrong with your css?

#

because code looks just fine

#

seperate divs for each ids

earnest phoenix
#

hm

west raptor
#

when you say "listen to voice activity" do you mean detect when someone is speaking or like take-in what they're saying?

quasi forge
#

Take in what they're saying

#

As in recording the voice chat and storing it in a mp3

west raptor
#

hmm

#

I know bots have done it before

#

but most of them have used d.js iirc

quasi forge
#

Welp, I am quite familiar with d.js I just wanted to y'know feel adventurous

west raptor
#

yeah understandable

quasi forge
#

That's why going for serenity

stray garnet
#

How to Update Objectssssssss in MongoDB? 😩

west raptor
#

hf with rust and stuff

quasi forge
#

@stray garnet lang

stray garnet
#

@quasi forge d.js

quasi forge
#

Lib?

west raptor
#

speaking on serenity i need to update the docs link in pins

quasi forge
#

Woah

#

Lang = d.js

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

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

  const user = message.mentions.users.first() || message.author
  
  if(args[0] === "setbio") {
    const NewBio = new RP({
  bio: args[1],
  userID: user.id,
  serverID: message.guild.id
    
        });
        await NewBio.saveAndUpdate().catch(e => message.channel.send("e"));
    return
   }

  RP.findOne({
      serverID: message.guild.id,
      userID: user.id
        }, (err, bio) => {
            if (err) console.error(err);
            const memberInfo = new Discord.RichEmbed()
                    .setAuthor(`${message.author.username}`, `${message.author.displayAvatarURL}`)
                    .setThumbnail(`${message.author.displayAvatarURL}`)
            .setColor("#ff0000")

            if (!bio) {
                memberInfo.addField('Bio', `Has no Bio`);
            }
            else {
                memberInfo.addField('Bio', bio.bio);
            }

            return message.channel.send(memberInfo);
        });
  
}
module.exports.help = {
  name: "profile",
  aliases: []
}
  

code

#

@quasi forge I meant Js

quasi forge
#

Mongoose. Lemme get the link

amber fractal
#

use the mongo docs

stray garnet
#

cant find anything there

quasi forge
#

Personal recommendation tho, don't use mongoose, it's slow af

amber fractal
quasi forge
amber fractal
#

same db, different library

quasi forge
#

I agree with Steven

#

That one is officially made by MongoDB and it's optimised for production purposes

west raptor
#

@quasi forge ah I might have found something

steel heath
#

mongoose worked fine with my 50k server bot tho

quasi forge
#

Did you try using mongodb tho

stray garnet
#

findOneAndUpdate() so i would use that insetad of findOne()?

quasi forge
#

Yes

stray garnet
#

Ok

steel heath
#

nah but it's like 200us why would i use different library to get 100us faster time

#

i prefer async functions btw @stray garnet

quasi forge
#

It's more like 40-50ms

steel heath
#

and connecting to mongodb on each command is not good i think

#

i only had one connection and moved that through all of my commands

quasi forge
#

^

amber fractal
#

I connected in the ready event and added it as a variable to the client

steel heath
#

thats even more stonks

amber fractal
#

so like client.db

steel heath
#

using client is smart

amber fractal
#

It's the variable that should be in all of your bot related files mmLol

earnest phoenix
#

resp[i].ID.slice(5) how do i convert that to a username ?

#

that gives the ID resp[i].ID.slice(5)

steel heath
#

well you get can the user object from discord if your website is connected to your bot somehow

#

client.users.get(resp[i].ID.slice(5)) i think

earnest phoenix
#

why doesnt the client.fetchUser(resp[i].ID.slice(5)).username work?

steel heath
#

try js client.fetchUser(resp[i].ID.slice(5)).then(u => u.username)

earnest phoenix
#

your one works

steel heath
#

or js // only if your function is async const user = await client.fetchUser(resp[i].ID.slice(5)); return user.username

earnest phoenix
#

[object Promise]

#

im using this in EJS

steel heath
#

uhh

earnest phoenix
#

<%=client.fetchUser(resp[i].ID.slice(5)).then(u => u.username)%>

amber fractal
#

because fetch returns a promise

steel heath
#

yep

amber fractal
#

you could (await ...).username

earnest phoenix
#

any way i can define it

steel heath
#

await is not possible in ejs by default afaik

earnest phoenix
#

:/

steel heath
#

i suggest you do that back in your code

amber fractal
#

ah I didnt even look that he was using ejs

#

.then should work then

twin kestrel
#

Hello everyone!
I have a problem that happens more and more frequently.
I have an event called "guildCreate" and another called "guildRemove" and the problem is that it gives false positives, that is, it says that "x" server has expelled it (and coincidentally one of them I manage it) and then says it has been added.

I know they are false positives because something appears with this scheme:

guildRemove, guildCreate, guildRemove, guildRemove, guildCreate, guildRemove, guildCreate, guildCreate, guildCreate (Logically with the same server ID, same owner and same number of members)

I use discord.js

EDIT: Right now this is happening

earnest phoenix
#

<%=client.fetchUser(resp[i].ID.slice(5)).then(u => u.username)%>

#

returns

#

[object Promise]

steel heath
#
const user = await client.fetchUser(resp[i].ID.slice(5));

response.render("something.ejs", {
    userObject: user
});

/* ^^ is not gonna work */
``` i prefer doing it like this in your express route
earnest phoenix
#

i just did it

#

<%=users%>

steel heath
#

nice

earnest phoenix
#

object Promise?

loud salmon
#

@twin kestrel its because the guildRemove and guildCreate events are fired when a server looses connection and then goes back online.

#

i don't know much about discordjs

#

they are also fired when the bot is kicked/added to a server

twin kestrel
#

Seriously? Well, it happens to me constantly

loud salmon
#

thats what i think is the issue

amber fractal
loud salmon
#

ah yes

#

thank you

twin kestrel
#

Thanks I will try

loud salmon
#

discordjs doesnt differentiate those two occurrences by default

#

which is poopoo

earnest phoenix
#

K

loud salmon
#

huh

quartz kindle
#

discordjs does differentiate it

#

at least in v12, i havent used v11 in a while

loud salmon
#

oh kewl

#

i guess people just dont wanna update

#

or people are using the wrong methods

earnest phoenix
#

i use v11 :(((

quartz kindle
#

let me check v11

earnest phoenix
#

and yes discordjs does differentiate it in v11 too

loud salmon
#

oh derp

#

i guess people are just using the wrong methods mmulu

quartz kindle
#

it does in guildCreate, but im not finding anything in the guildDelete source lul

earnest phoenix
#

guildDelete works in v11

#

i use it

quartz kindle
#

ah i found it

loud salmon
#

oofers

quartz kindle
#

its handled in actions/guildDelete

earnest phoenix
#

<%=db.fetch(`short_${resp[i].ID.slice(8)}`)%> that returns objectPromise how do i get the data?

quartz kindle
#

same as you did before

earnest phoenix
#

i didnt get through the last one?

#

i just left it as users.get

quartz kindle
#

just do what EGGSY posted

earnest phoenix
#

i put that code in dashboard.js as well await db.fetch(short_${id})

but it only gets the top data

#

not everyones

#

``` db: await db.fetch(short_${id}),

#
    for (var i = 0; i < resp.length; i++) { 
    resp.length = 10
    console.log(resp)

is = resp[i].ID.slice(8)
quartz kindle
#

so db only contains one item?

#

needs more context tho, i dont know what your code is doing with only those snippets

steel heath
#

isn't that resp's source is coming from back-end

#

you don't have to do that in EJS

earnest phoenix
#

i did <%=db%>

#

still number 1's data

steel heath
#
// in your route:

const IDs = new Array(),
    users = new Array();

for (var i = 0; i < resp.length; i++) { 
    IDs.push(resp[i].ID.slice(8));
}

IDs.forEach(id => {
    const user =    await client.fetchUser(id);
    users.push(user.username)
});

response.render("page.ejs", { users });

// in your EJS file (` = for coloring):

`
<% for (var i = 0; i < users.length; i++) { %>
    <div class="card">
        users[i]
    </div>
<% } %>
`

// NOT SURE ANY OF THIS IS GONNA WORK 
``` i dont really have time right now sorry this is all i can do for now
#

and i bet there are better ways to do this