#development

1 messages Β· Page 1428 of 1

pale vessel
#

or same position too iirc

crimson vapor
#

Forgot about that stupid rule

#

makes organizing roles a bit harder imo since if you want bots below members you have to move their own role above people

silent cloud
#

bot higher

pale vessel
#

who are you kicking

silent cloud
#

mashiro

molten yarrow
silent cloud
#
at RequestHandler.execute (/home/container/node_modules/discord.js/src/rest/RequestHandler.js:154:13)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async RequestHandler.push (/home/container/node_modules/discord.js/src/rest/RequestHandler.js:39:14)
(node:57) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:57) [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.
(node:57) UnhandledPromiseRejectionWarning: DiscordAPIError: Missing Permissions
at RequestHandler.execute (/home/container/node_modules/discord.js/src/rest/RequestHandler.js:154:13)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async RequestHandler.push (/home/container/node_modules/discord.js/src/rest/RequestHandler.js:39:14)
(node:57) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode).```
silent cloud
#

not

molten yarrow
silent cloud
#

yep

#

i now made it

fervent goblet
#

anyone know a way to dynamically update all documents to match new fields from the model?

#

mongodb^ js

earnest phoenix
#

mongoose?

#

@fervent goblet try the update method

#

it should update all documents found/matched

fervent goblet
#

hmm ok

fierce ether
#
            id: users.userId,
    allow: ['VIEW_CHANNEL', `SEND_MESSAGES`],
        })))``` ```Unhandled promise rejection: TypeError [INVALID_TYPE]: Supplied parameter is not a User nor a Role.``` its meant to put the channel perms for two users in array?
hidden lynx
#

guys anybody having problems with ytdl-core as well?

sterile lantern
#

how would we do something like this;

db.fetch(money)
db.fetch(bank)

total balance: money + bank```
#

just an example, not actual code fyi

#

i just want to add two db values

#

together

#

and print that

tranquil drum
#

Have you tried it already?

wise quartz
#
File "c:Users\Name\Documents\Visual Studio Code\Bot Name\core.py", line 84

SyntaxError: unexpected EOF while parsing

(Py)

#

Whats that?

lyric mountain
#

syntax errors probably

wise quartz
#

My file is 83 lines long btw

tranquil drum
#

There's probably some block that's not lined up right

lyric mountain
#

wrong line terminator maybe?

wise quartz
#

How can i fix it?

tranquil drum
#

Parser tried to read line 84 cause it expects something but got EOF

wise quartz
#

Aha

tranquil drum
#

Check your code and make sure all the code blocks are lined up right

wise quartz
#

So it thinks there should be a 84 line

#

Alr got it

#

Thanks

tranquil drum
#

EOF = end of file btw

wise quartz
#

I fixed it

#

I had @client.run

#

It doesn't need "@"

sturdy gazelle
#

how do you set the bot status to idle or dnd? i tried client.user.setStatus('dnd') but that didnt work (discord.js)

rustic nova
sturdy gazelle
#

it isnt working

#

await client.user.setPresence({ activity: { name: '=connect-4 in ' + client.guilds.cache.size + ' servers' }, status: 'dnd' }).then(console.log);

sturdy gazelle
earnest phoenix
#

it is

#

there was a person with the same issue yesterday

#

maybe an issue with djs

sturdy gazelle
#

wheres UserStatus?

scarlet arrow
tranquil drum
#

Probably because there was an error in msg.guild.members.fetch

#

you could try logging err in the catch

tulip ledge
#

u need to do msg.guild.members.cache.fetch

sudden geyser
#

no you don't

#

members.fetch(...) is correct

#

I don't see why it'd say remove is undefined, because if an error did occur, it would say something like Cannot read property 'roles' of undefined

tranquil drum
#

true

#

You could try logging member to see what it is

earnest phoenix
#

remove is never going to be undefined it's a method

#

roles however, can be undefined

tranquil drum
#

Maybe fetch produced an error that wasn't thrown

#

oh wait yeah it would just say Cannot read property 'remove' of undefined

sturdy gazelle
#

is there a reason that despite status being 'dnd' it shows as online

earnest phoenix
#

not a topgg question but, when i got a server with alot of emojis etc [example; :lots:] , and my bot joins the server, can i use the emoji :lots: in the other servers
not good explained

sudden geyser
#

Yes, it should be in the format <:name:id>. If the emoji is animated, it should look like <a:name:id>

earnest phoenix
#

dayum thanks

quartz kindle
#

and your bot needs to have "use external emojis" permission in the servers where you want to use them

limpid bear
#

is there a possibility that i can limit a command to 1-2 people. for testing commands

rustic nova
#

i suggest limiting it to the testing server instead

#

or better yet, not limiting it at all

#

or what are you referring to? something like -eval?

limpid bear
#

like adding commands to the bot.

quartz kindle
#

you can check for the author id before running the command

jaunty surge
#

hey guy, I have a problem where I download google-images module, I did coding and stuff, but after that when I run node, it show the error cannot find module ./package How can I fix that

#

I have package.json in myfolder, I don't get the reason of the error

haughty mirage
#

Check path

jaunty surge
#

@haughty mirage but I have package.json there.

opal plank
#

clearly not

#

@jaunty surge

jaunty surge
opal plank
#

i never said it didnt exist

#

i said clearly not in the same folder you calling it

jaunty surge
#

it's inside the same folder-

#

it worked before

opal plank
#

im gonna take a wild guess and say you using something like inside a commands folder

jaunty surge
#

before I install google-image

opal plank
#

where is the file you calling that from?

#

show full error

jaunty surge
#

I just uninstall the module because of the error, let me reinstall it

drifting wedge
#
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x000001A3884CFA60>
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x000001A389FF0B80>``` whats this error?
opal plank
drifting wedge
#

bruh lmaook

hollow sedge
#

i dont have much experience with aiohttp but i think it's because you didnt close the session

static trench
#

Can I host 2 bots on 1 VPS?

rustic nova
#

ofc

static trench
solemn jolt
#

Why don't give role to all server member

message.guild.members.cache.forEach(M=>{
M.roles.add(role)
sleep(100)
})```
weary socket
#

Can someone help me installing java15 on my debian 10?

earnest phoenix
faint prism
#

Anyone doing the Advent of Code?

earnest phoenix
weary socket
#

What is JVM @earnest phoenix ?

earnest phoenix
#

java virtual machine ig

weary socket
#

I only see linux

#

I have a debian 10

earnest phoenix
#

debian is linux

weary socket
#

oh ok

earnest phoenix
#

if you dont want to bother with the tarball

weary socket
#

And how do I install it after I downlaoded it

earnest phoenix
#

install the openjdk-15-jdk package

#

with the tarball you gotta add to PATH

weary socket
#

But how can I install it? I downloaded this package

heady flint
#

Check my custom status w_pepeOMG

earnest phoenix
weary socket
#

tarball

earnest phoenix
solemn jolt
weary socket
earnest phoenix
#

πŸ€”

#

select your arch

hollow prawn
weary socket
#

@earnest phoenix It does work now...But i only can use one version at the time....So I cant use my old Java 8...It says that I have to choose

#

So I chose 15

#

How can i say that specific things start with java 8?

earnest phoenix
#

hm, never had a use case where i had to have two different versions

#

tried googling?

weary socket
#

nah not yet....Also I used another tutorial istead of yours...Maby I should use yours so I can use both versions

weary socket
#

Because mine does only show mac

earnest phoenix
#

it's the url i sent two messages above

#

πŸ€” screenshot it

weary socket
earnest phoenix
#

oh i also only have mac for openjdk 15

#

use the package i guess

weary socket
weary socket
earnest phoenix
earnest phoenix
weary socket
#

ok

#

Cant see an x64

earnest phoenix
#

you just install it via apt

#

it will pull the right arch for you

weary socket
#

@earnest phoenix Can i just use the 15 from adoptopenjdk and use the installation from jdk14?

earnest phoenix
#

πŸ€” what

weary socket
#

apt get install (what exactly)

earnest phoenix
#

use apt-get btw

weary socket
#

ok so "apt-get install openjdk-15-jdk" ?

earnest phoenix
#

yes

#

you might need to sudo

weary socket
#

Could not be found

earnest phoenix
#

did you update apt-get

weary socket
#

oh

#

no lol

earnest phoenix
#

sudo apt-get update

weary socket
#

ok now

#

But it didnt find it at all

earnest phoenix
#

that's weird

weary socket
#

sudo apt-get install openjdk-15-jdk

#

Thats what I put in

earnest phoenix
#

it should work

weary socket
#

hmmm

#

I am gonna restart my Server

#

It says anyway that it cant find that @earnest phoenix

#

@earnest phoenix ```sudo apt-get install OpenJDK15U-jdk_x64_linux_hotspot_15.0.1_9

#

Would that work?

earnest phoenix
#

i mean, i don't know, try it and see

weary socket
#

nvm doesnt

earnest phoenix
#

but the first command should've worked

weary socket
#

hmm

earnest phoenix
astral yoke
#

how would i do multiple intervals but in an order? this one gets all funky setTimeout(function(){ msg.edit('test1'); }, 5000) setTimeout(function(){ msg.edit(test2') }, 15000) setTimeout(function(){ msg.edit('test3') }, 15000); });

tranquil drum
#

you could put the setTimeout call inside the function of the last setTimeout

#

or have some value in the outer scope that tracks how many times the timeout has fired and do the appropriate action

weary socket
#

@earnest phoenix maby upload and then say apt-get install ./FileName?

tranquil drum
#

holy moly they're up to java 15?

weary socket
#

yes 😦

#

And i cant install it for unknown reasons

earnest phoenix
#

i can quickly spin up an ubuntu image to see if it works for me

weary socket
#

ok thx

#

But ubuntu is another system right?

earnest phoenix
#

ubuntu runs on debian

weary socket
#

ah ok

#

Step #1: Download @earnest phoenix

#

I think it has to be on the computer

#

/server

earnest phoenix
#

it doesn't

tranquil drum
#

is there not just an apt package for it?

#

lol i just scrolled up

weary socket
#

?

tranquil drum
#

it's saying not found?

weary socket
#

yes

tranquil drum
#

are you on debian sid?

weary socket
#

debian sid?

tranquil drum
#

or what distro are you on

weary socket
#

distro?

tranquil drum
#

of linux

weary socket
#

Im an on Debian 10

tranquil drum
#

ubuntu/debian

weary socket
tranquil drum
#

buster only has up to openjdk11 in their repo

weary socket
#

And 9?

#

The problem is that i have a lot of things which I spent many hours to work

#

on the server

tranquil drum
#

are you using java 15 features?

weary socket
#

yep

tranquil drum
#

yikes

weary socket
#

What am I going to do now?

tranquil drum
#

you probably just gotta keep trying to install from source like you were doing

weary socket
#

but I dont know how if its not finding it

#

I got it last Time...But i could only choose between 8 and 15

#

And not use both

tranquil drum
#

buster doesn't have 15 in it's official repo

weary socket
tranquil drum
#

it has 11

#

so it would support java 9

weary socket
#

whattttt

tranquil drum
#

or are you talking about debian 9

weary socket
#

debian 9

tranquil drum
#

only debian sid has openjdk 15

#

and bullseye

#

but they're not stable releases

#

debian sid is (unstable) and debian bullseye is (testing)

weary socket
#

and what about installing oracle java 15 on my Debian 10?

tranquil drum
#

are you sure you want oracle java?

weary socket
#

whats wrong with that?

tranquil drum
#

I thought oracle charged money for jre on servers

weary socket
#

IDK

#

There are 2 choices for the alternative java (providing /usr/bin/java).

Selection Path Priority Status

  • 0 /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1111 auto mode
    1 /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1111 manual mode
    2 /usr/lib/jvm/jdk-13.0.1/bin/java 1091 manual mode

Press <enter> to keep the current choice[*], or type selection number:

#

This was last time

#

just with 15

#

How can I say both?

tranquil drum
#

actually, what java 15 features are you using?

weary socket
#

Lamda express or what its called and for the rest i dont have the Name in my Head

tranquil drum
#

lambda expressions are java 8 features

#

you can just use any version of jdk after 8

weary socket
#

Text Boxes

tranquil drum
#

You'll have to recompile your class files to target jre 8

#

text boxes?

weary socket
tranquil drum
#

oh text blocks

weary socket
#

yes

#

My Project was Java 8....A Friend told me to upgrade to 15 and I did it and i liked it -_-

#

Now i hate it

tranquil drum
#

I guess you have an option to remove those and replace them with the old style string literals concatted with +

#

You could also try to get a docker instance running with jdk 15 already installed if you're comfortable with learning docker

#

Or just keep trying to get openjdk 15 installed on buster somehow

weary socket
#

nah im not

weary socket
tranquil drum
#

JDK 15 can run java 8 bytecode

weary socket
#

I already tried it

tranquil drum
weary socket
#

The problem is , it wants me to choose one java version. It says i have to choose between Java 8 and Java 15....And i need both

tranquil drum
#

Just choose 15

#

jdk 15 can run java 8

weary socket
#

But my Java 8 Minecraft Server doesnt work then hahaha

tranquil drum
#

it will

#

or have you already tried

weary socket
#

I tried it and it didnt work

tranquil drum
#

that's weird

weary socket
#

yes

tranquil drum
#

what's the error there

weary socket
#

IDK my cloud just says that its not working lol

#

Thats the Video who helped me installing java 15

tranquil drum
#

if you have multiple versions of java installed, the java command can only point to one of them

#

check if you still have jdk 8 installed somewhere

weary socket
#

I have

tranquil drum
#

you'll just have to change your minecraft server launch command

weary socket
#

-_-

#

ok 1s

#

What do I have to put in?

tranquil drum
#

The location of the java binary for jdk 8

weary socket
#

?

tranquil drum
#

/usr/lib/jvm/ somewhere in there

#

likely it'll be /usr/lib/jvm/your JDK 8 home dir/bin/java

weary socket
#

wait

#

I just updated to java 15

#

And now?

#

What do i have to change exactly?

tranquil drum
#

ls your /usr/lib/jvm/ and check if 8 is there

weary socket
#

/usr/lib/jvm/adoptopenjdk-8-hotspot-amd64

tranquil drum
#

sweet

#

now replace java in your minecraft server launch script with /usr/lib/jvm/adoptopenjdk-8-hotspot-amd64/bin/java

weary socket
#

screen -RS CloudNet /usr/lib/jvm/adoptopenjdk-8-hotspot-amd64/bin/java -XX:+UseG1GC -XX:MaxGCPauseMillis=50 -XX:MaxPermSize=256M -XX:+UnlockExperimentalVMOptions -XX:+UseCompressedOops -XX:-UseAdaptiveSizePolicy -XX:CompileThreshold=100 -Dfile.encoding=UTF-8 -Xmx456M -Xms256m -jar launcher.jar

#

Like that?

tranquil drum
#

uh probably

weary socket
#

nope does not work

#

maby in the other direction

#

my Bot with the path of 15

tranquil drum
#

true

#

what does java -version say right now

weary socket
#

8

tranquil drum
#

oh well then change your minecraft launch command back to how it was

weary socket
#

i did

tranquil drum
#

does it work?

weary socket
#

the minecraft yes

tranquil drum
#

cool

#

now you can look for jdk15 in /usr/lib/jvm/

weary socket
#

My start.sh for my Bot lookes way different

#

Fuck

#

I build it with distZip with Gradle

#

Its like that

tranquil drum
#

what's your jdk15 dir

weary socket
#

/usr/lib/jvm/jdk-15.0.1

tranquil drum
weary socket
#

WORKS

#

GREAT

tranquil drum
#

πŸ™‚

#
# Determine the Java command to use to start the JVM.
# if [ -n "$JAVA_HOME" ] ; then
#     if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
#         # IBM's JDK on AIX uses strange locations for the executables
#         JAVACMD="$JAVA_HOME/jre/sh/java"
#     else
#         JAVACMD="$JAVA_HOME/bin/java"
#     fi
#     if [ ! -x "$JAVACMD" ] ; then
#         die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME

# Please set the JAVA_HOME variable in your environment to match the
# location of your Java installation."
#     fi
# else
#     JAVACMD="java"
#     which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.

# Please set the JAVA_HOME variable in your environment to match the
# location of your Java installation."
# fi
JAVACMD="/usr/lib/jvm/jdk-15.0.1/bin/java"
#

I just commented out the logic that checks if JAVA_HOME is set

#

then manually configured the JAVACMD to use your jdk15 directory

weary socket
#

ok

stable nimbus
#

So I am using MySQL, how would I call for my database to get the custom prefix of a server? Here is my current code:

function getPrefixFunction(message, sql) {
            const prefixes = [
                            `<@!${message.client.user.id}> `,
                            `<@${message.client.user.id}> `,
                            message.client.user.username.toLowerCase(),
                            sql.guild.prefix,
                        ];
                        let thePrefixValue = null;
                        prefixes.forEach((prefix) => {
                            if(message.content.startsWith(prefix) || message.content.toLowerCase().startsWith(prefix)) {
                                thePrefixValue = prefix;
                            }
                        });
                        return thePrefixValue;
                    }

        const prefix = getPrefixFunction(message, sql);
        if(!prefix || message.author.bot) { return; }
#

Do I call for my DB connection inside of the function or how would I call to my DB?

tranquil drum
#

You could probably cache the prefix as you need them then update both the cache and DB when it changes

weary socket
#

@tranquil drum when do you think will Java 15 release official for Debian 10?

weary socket
#

whaaaaat

stable nimbus
#

I'm trying to keep everything on my DB as I can.

tranquil drum
#

I think people in industry who need jdk 15 will just use docker images

tranquil drum
#

unless you don't want to cache at all

tranquil drum
#

in which case you'll have to call the DB at least once per message

stable nimbus
#

IDK how to cache so I'ma keep it in the DB.

#

Still new to programming but have made a lot of headway.

tranquil drum
#

If you're using js you can just create a new object in some scope where both your getPrefixFunction() and the handler for your prefix change command exists

#
let guildPrefixCache = {}
weary socket
#

Thx @tranquil drum for your help....I think i would cry if havent got it hahaha

#

just kidding

#

But i would be sad

#

But THX for your help. Im going to bed now

#

After 15h of programming xD

tranquil drum
#

ur a machine

weary socket
#

nah im lost as fuck

#

I reworked my whole bot and wrote it in SQL in one day without knowing this language....

weary socket
#

After a couple of hours I realized I need prepared statements hahaha

weary socket
#

So guys...Im away now

stable nimbus
#

Same here .

weary socket
#

thx and c ya

stable nimbus
#

Have a good night.

stable nimbus
tranquil drum
#

do you close your db connections as you finish your queries?

stable nimbus
#

No.

#

I keep connected because I update info in the db constantly.

tranquil drum
#

ok

#

you should be able to use that connection to just make a query then

stable nimbus
#

Okay.

#

Do I put the function inside the query so it all runs?

tranquil drum
#

uh i'm not sure what you mean by that

stable nimbus
#
 botdb.query(`SELECT * FROM server WHERE serverid = ${message.guild.id}`, async (err, results) => {
            function getPrefixFunction(message, sql) {
                const prefixes = [
                                `<@!${message.client.user.id}> `,
                                `<@${message.client.user.id}> `,
                                message.client.user.username.toLowerCase(),
                                sql.guild.prefix,
                            ];
                            let thePrefixValue = null;
                            prefixes.forEach((prefix) => {
                                if(message.content.startsWith(prefix) || message.content.toLowerCase().startsWith(prefix)) {
                                    thePrefixValue = prefix;
                                }
                            });
                            return thePrefixValue;
                        }
                    const prefix = getPrefixFunction(message, sql);
                    if(!prefix || message.author.bot) { return; }
        });
#

Do I do this?

#

Or will it just die when this is done

tranquil drum
#

ah

#

if you put the function in there then you can only call it inside that query

#

you'll have to put the query inside getPrefixFunction

stable nimbus
#

Okay.

tranquil drum
#

and probably use a callback since botdb.query also uses a callback

stable nimbus
#

Ohhhhhh I didn't know I could do that.

#

That helps a lot.

#
// If the messagr author is a bot or doesn't start with the prefix
        async function getPrefixFunction(message, sql) {
            await botdb.queryPromise(`SELECT * FROM server WHERE serverid = ${message.guild.id}`).then(async function(results){
                const db = results[0].prefix;
                const prefixes = [
                    `<@!${message.client.user.id}> `,
                    `<@${message.client.user.id}> `,
                    message.client.user.username.toLowerCase(),
                    db,
                ];
                let thePrefixValue = null;
                prefixes.forEach((prefix) => {
                    if(message.content.startsWith(prefix) || message.content.toLowerCase().startsWith(prefix)) {
                        thePrefixValue = prefix;
                    }
                });
                return thePrefixValue;
            });
        };

        const prefix = getPrefixFunction(message, sql);
        if(!prefix || message.author.bot) { return; }
#

There we go, now I feel like progress is being made.

earnest phoenix
#

Whats a developers license and do you need one to make a bit

stable nimbus
#

No you don't.

#

I don't have one and I'm in over 500 servers with my bot.

earnest phoenix
#

Alrighty

stable nimbus
#

@tranquil drum just a heads up chief

weary socket
#

@tranquil drum Do you know how I can change the background of my Bots Top.geh Page?

tranquil drum
#

just make sure it doesn't obscure and interfere with existing buttons on the page and be aware of epilepsy inducing elements like flashing or rapid color changes

weary socket
#

Yes but I am not familier with it And i have an online Code where Snow Is flying around but I don’t know how to transfer that to my Bots Background

tranquil drum
#

as long as that code is pure css it will work

weary socket
#

THATS the Code

stable nimbus
#

I need to add a background lol.

weary socket
#

@tranquil drum What do I have to change to make it work on my Bot page?

quartz kindle
#

do you know how css works?

weary socket
#

No 😦

quartz kindle
#

then i suggest learning some basics first

#

its not too hard

#

for example, learn how selectors work

#

then you can inspect element on the top.gg page and find the right selectors

stable nimbus
#

HTML is actually very very fun to learn.

#

Unlike some languages.

earnest phoenix
#

it should be apt-get install libopus0 opus-tools but i get the root error

E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?

How do i install opus without root permission?

weary socket
quartz kindle
#

inspect element

stable nimbus
#

Literally said it.

weary socket
quartz kindle
#

then try better

weary socket
#

-_-

#

Tomorrow....I am now going to bed

quartz kindle
#

lmao

#

i mean, there isnt anything else to try

#

thats literaly how you do it

weary socket
#

Ok

quartz kindle
#

right click the thing you want to change

#

inspect element

stable nimbus
#

Quite literally.

quartz kindle
#

find its class name

#

or id

#

or tag

#

and write css for it

tranquil drum
earnest phoenix
#

ok is there any other way

#

to get opus

#

other than apt?

polar glacier
#

have you got sudo?

tranquil drum
#

yes but it's pretty annoying

#

it's way easier if you get su

earnest phoenix
tranquil drum
#

do you have docker on the machine?

earnest phoenix
#

idk what that is

tranquil drum
#

what is this machine you're running on?

floral rune
#

what do you need libopus for

earnest phoenix
#

update node

#

to v12 or higher

#

πŸ€·β€β™‚οΈ

quartz kindle
#

package managers always have old versions

#

you need to install from the website, or using nvm

stark abyss
#

So I am doing

    pool.query(query, (err, res) => {
      if(err) return console.log(err);
      pool.end()
    })```
in my afk file, and it gives me error of `Error: Cannot use a pool after calling end on the `. When exactly am i supposed to close the connection.
This is postgres
earnest phoenix
#

om

#

that's not how you're supposed to do pooling

stark abyss
earnest phoenix
stark abyss
#
const { Pool } = require('pg')
const pool = new Pool()
pool.query('SELECT $1::text as name', ['brianc'], (err, result) => {
  if (err) {
    return console.error('Error executing query', err.stack)
  }
  console.log(result.rows[0].name) // brianc
})```
This isn't much different that what I am doing πŸ€”
#

This is my code

    const query = {
      text: "INSERT INTO afkTable(id, msg)values($1, $2);",
      values: [message.author.id, afkMsg]
    }
    pool.query(query, (err, res) => {
      if(err) return console.log(err);
      pool.end()
    })
#

Still confused what you are pointing out to

#

~~@earnest phoenix ~~

earnest phoenix
#

you're ending the pool

#

when you shouldn't

stark abyss
#

ah

#

You made me think I was doing everythign wrong

#

alright thx that's a good resource

sudden geyser
#

good job

#

now find ways to improve it

drifting wedge
#

how can i import a file? py

sudden geyser
drifting wedge
#

ye a python file

#

i know how to

#

but its in the same folder

sudden geyser
#

import example?

drifting wedge
#

uuhhh

#

i tried that it gave me an error but mightve been for something else

#

lmao

#

alr thanks

sudden geyser
#

What was the error?

drifting wedge
#

nah its something i know how to fix

#

i have a list of things i need to pull one from

#

but i got that

#

thanks

sudden geyser
#

alright

drifting wedge
#

to pull a func from the file its self.filename.funcname?

#

py

sudden geyser
#

Think of the scope in the file.

#

If you have: ```py

file: funcs.py

def say_hi():
print("Hi!")In your other file, you should be able to:py
import funcs

funcs.say_hi()

You could also `import funcs.say_hi` to import only the function I believe.
drifting wedge
#

ye

#

umm its in a class tho

#

so i need to pass in self iirc

#

self.funcs.say_hi?

#
class normalquest(commands.Cog):
    def __init__(self, client):
        self.client = client```
#

lmao i really need to do some more basic py

#

i understand libs and stuff

#

but i need to get a hold of sort and lambda and shit lmao

sudden geyser
#

You shouldn't need self.

#

You could do import funcs.normalquest, and now you have access to the normalquest class.

drifting wedge
#

intresting

#

ok

#

hmm

#

intresting

#

would just importing the file work normally?

sharp rock
#

host app?

#

where?

pale vessel
#

VPS

drifting wedge
#

Extension 'cogs.quest.quest' raised an error: ModuleNotFoundError: No module named 'itemlist'

#

@sudden geyser

#

sorry for ping

#

i did import itemlist

#

its not a module

#

its a file

sudden geyser
#

show you directory tree pls

drifting wedge
#

1 sec

sudden geyser
#

oh god that censoring

drifting wedge
#

?

modest smelt
#

Can someone help?

#
      player = None
      for voiceClient in client.voice_clients:
        if voiceClient.guild == message.guild:
          player = voiceClient
      if player == None:
        await message.channel.send("You must be playing audio to pause.")
        return
      player.pause()
      await message.add_reaction("πŸ‘")
```when i use the pause command, it causes the bot to leave. what is wrong here?
drifting wedge
sudden geyser
#

What file are you trying to import itemlist from

modest smelt
#

thats all the code

drifting wedge
#

quest.quest

modest smelt
#
@client.command()
async def pause(message):
  player = None
  for voiceClient in client.voice_clients:
    if voiceClient.guild == message.guild:
      player = voiceClient
  if player == None:
    await message.channel.send("You must be playing audio to pause.")
    return
  player.pause()
  await message.add_reaction(":thumbsup:")
drifting wedge
#

quest file

modest smelt
#

@drifting wedge

drifting wedge
#

this never says leave

#

so its something else

modest smelt
#

exactly

#

but it leaves the thing

drifting wedge
#

maybe it gives an erorr

#

and it crashes

#

logs?

sudden geyser
#

Importing looks from the project root directory.

sudden geyser
#

So your import should look like import quest.itemlist

drifting wedge
#

yep

static trench
#

how long is the waitlist for privlidged intents?

modest smelt
#

lemme send error @drifting wedge

#

gimme a sec

drifting wedge
#

lmao my file path is a fucking mess lmao

#

i have like 10000 images in my bot folder

#

and shit

#

i need to get my shit together

static trench
#

lmao

drifting wedge
#

Extension 'cogs.quest.quest' raised an error: ModuleNotFoundError: No module named 'quest'

import quest.itemlist

sudden geyser
#

Remember, project root directory.

#

Looks like you're in cogs/quest/quest.py

drifting wedge
#

guys lite is what we call a person with a brain

#

we should be like him

delicate shore
#

I wanna make my bot message

#

In every server

#

That it restarted

#

Once it crashes and node process restarts

#

Automatically

#

Not manually

#

Not every server tbh , the server he was playing music in

lunar umbra
delicate shore
#

Is there any way I can make my bot leave the VC in every server which he has joined

#

Like he is in testing 1

#

In this server

lyric mountain
delicate shore
#

Music 1 in my server

#

It leaves both

#

The vc

#

Not server

lyric mountain
#

It's dark matter visualized

earnest phoenix
#

Could anyone remind me how to know if the user mentioned is a bot?

lunar umbra
#

what language/library

earnest phoenix
#

I can't remember how it does

#

discord.js

delicate shore
#

get the mention and check if it's a bot or no

#

You can do this

#

const user = msg.mentions.user.first()

#

Now check if it's a bot or no

#

Using user.bot

#

if(user.bot) return // thid will do nothing if bot is mentioned

earnest phoenix
#

That was exactly it! Thanks!

delicate shore
#

Anytime brother

cursive forge
#
        if (serverQueue.loopall === true) lMsg = 'On'
        if (serverQueue.loopone === true) lMsg = 'Once'```
clever vector
#

Hello !

cursive forge
#

I have no idea what to define lmsg as

clever vector
#
(node:2264) UnhandledPromiseRejectionWarning: TypeError: canvacord.Spotify is not a constructor
    at Object.exports.run (C:\Users\User\Pictures\Oppa\No workspace\commands\Information\spotify.js:31:12)
    at module.exports (C:\Users\User\Pictures\Oppa\No workspace\events\message.js:82:19)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:2264) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:2264) [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.
polar glacier
upper elm
#

is there any way to get the author of a deleted message?

tribal siren
#

wait you tryna code a message delete logs?

upper elm
#

no a sniper bot

tribal siren
#

oh

#

message.author

#

nothing hard

upper elm
#

wait

#

I am so dumb lol

#

yeah I just can't think thanks though

tribal siren
#

no worries ^^

long marsh
#

Has anyone here actually setup a DBLWebhook using Heroku?

#

I have everything working locally; however, I can't seem to get it to work in Heroku. It binds correctly, but I can't seem to get any payloads from the test event.

#

If you have, what was your ending url for heroku?

#

I physically typed in:
http://{app-name}.herokuapp.com:{port}/dblwebhoook

Here's the output from Heroku:

2020-12-04T03:01:20.700782+00:00 heroku[worker.1]: Starting process with command `node .`
2020-12-04T03:01:21.393377+00:00 heroku[worker.1]: State changed from starting to up
2020-12-04T03:01:24.384882+00:00 app[worker.1]: Webhook running at http://0.0.0.0:{port}/dblwebhook
clever vector
#

anyone pro on using canvacord here?

haughty bough
#

Hello, people. My doubt is a little difficult to explain, but I will try. If I create a variable that stores 5 values of a search, but after selecting one it will delete the rest. Is there a chance that another person who is executing the same command will lose data from his variable because the other has already finished his research and deleted the data? Or is everything done very fast and one ends up not interfering with the other?

long marsh
#

That entirely depends on the scope of the variable @haughty bough

sudden geyser
#

If the variable lives per that user's request, it can't be intercepted by another user's request. Like Thomas said, it matters on the scope of the variable.

earnest phoenix
#

globals πŸ™ƒ

clever vector
#
(node:2264) UnhandledPromiseRejectionWarning: TypeError: canvacord.Spotify is not a constructor
    at Object.exports.run (C:\Users\User\Pictures\Oppa\No workspace\commands\Information\spotify.js:31:12)
    at module.exports (C:\Users\User\Pictures\Oppa\No workspace\events\message.js:82:19)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:2264) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:2264) [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.
#

Help pls

sudden geyser
#

For example, if I have a variable called tick and set it to true/false on every command, I'd need it to live for longer than the user's request. Then, another user's command can intercept it.

#

TypeError: canvacord.Spotify is not a constructor

#

See line 31 of commands\Information\spotify.js

haughty bough
#

Understand. In my case, this variable is within a class that is accessible to everyone on the server

clever vector
#

i saw but

#

i dont know how to fix it

trim badger
#

Can I share something not related to bot development here, but related to js

clever vector
#

i will send code

sudden geyser
#

Yes

trim badger
clever vector
#

@sudden geyser

  if (message.author.bot) return

  let user;

  if (message.mentions.users.first()) {
    user = message.mentions.users.first();
  } else if (args[0]) {
    user = message.guild.members.cache.get(args[0]).user;
  } else {
    user = message.author;
  }

let status;
if (user.presence.activities.length === 1) status = user.presence.activities[0];
else if (user.presence.activities.length > 1) status = user.presence.activities[1];

if (user.presence.activities.length === 0 || status.name !== "Spotify" && status.type !== "LISTENING") {
  return message.channel.send("This user is not listening music");
}

if (status !== null && status.type === "LISTENING" && status.name === "Spotify" && status.assets !== null) {
  let image = `https://i.scdn.co/image/${status.assets.largeImage.slice(8)}`,
      name = status.details,
      artist = status.state,
      album = status.assets.largeText;

var card = new canvacord.Spotify()
  .setAuthor(artist)
  .setAlbum(album)
  .setStartTimestamp(status.timestamps.start)
  .setEndTimestamp(status.timestamps.end)
  .setImage(image)
  .setTitle(name);

card.build()
  .then(buffer => {
      canvacord.write(buffer, "spotify.png");

      let attachment = new Discord.MessageAttachment(buffer, "spotify.png");
      return message.channel.send(attachment);
  })}
}
cursive forge
#

How would I make a bot know when its disconnected by a user?

sudden geyser
#

Virak what can you show where you defined canvacord and what version of the library you're using? It looks correct.

clever vector
#

I use d. Js

#

@sudden geyser

sudden geyser
#

This isn't about Discord.js

#

It's about canvacord.

earnest phoenix
cursive forge
delicate shore
#

How to make my bot leave vc in every server which it is in

#

If it has joined

delicate shore
cursive forge
#

js

#

@delicate shore

delicate shore
#

Ok

#

So can anyone guide me

#

About

#

SIGINT event in nodejs

supple oriole
#
:x: | An error encountered: Error: play(havana) encountered:
Status code: 429
#

Explain why this happens. Im using distube's example bot.

wooden wigeon
#

I tried to centre-align an h1 in my long description but it's showing as left-aligned. The p which I aligned along with it is aligned properly though. It seems to work fine in my editor.

paper cliff
supple oriole
#

I just did !Play bandit

#

And that happened.

paper cliff
#

Did you just run his example w/o checking what's going on?

#

'cause you probably need an API to interact with YouTube Search feature

supple oriole
#

I ran the example with the command handler.

supple oriole
paper cliff
#

I don't even know what Distube is

supple oriole
#

its like lavalink

paper cliff
#

Oh ok I see

supple oriole
#

I think

#

It does everything lavalink does

paper cliff
#

Oh yeah ok you don't need an API key

supple oriole
#

Ok

earnest phoenix
supple oriole
#

U need to request em to discord support or smth

earnest phoenix
#

smth and em means ? @supple oriole

paper cliff
#

@earnest phoenix As you can read, you need whitelisting for those privilegied intents

#

You had to ask them in the verification process

earnest phoenix
supple oriole
#

@paper cliff For the 429 error, it says I need a youtube cookie

paper cliff
#

You can still ask them by email

#

if you have good reasons of course

earnest phoenix
#

say, smth and em means ? @supple oriole

supple oriole
#

what,

paper cliff
#

@earnest phoenix something

earnest phoenix
#

em ?

paper cliff
#

@supple oriole Yes, it's almost like an API key in fact

supple oriole
#
const client = Discord.Client()
const DisTube = require('distube')
client.DisTube = new DisTube(client, {
  // You can read how to get it in the documentation
  youtubeCookie: '<Your YouTube Cookie>'
})
#

So how do I get one.

#

I tried googling

earnest phoenix
#

@paper cliff whats discord email adress ?

paper cliff
#

@earnest phoenix dude just look on the internet

supple oriole
#

@earnest phoenix ^

paper cliff
supple oriole
#

Write an email there.

paper cliff
#
      // You can find this by going to a video's watch page, viewing the source,
      // and searching for "ID_TOKEN".
      // 'x-youtube-identity-token': 1324,
supple oriole
#

I don't understand o-0

paper cliff
#

Basically, you just get the cookie by going on the youtube.com website with your account

supple oriole
#

what.

#

now what.

#

nvm

#

I found it

shell grotto
delicate shore
#

Hey guys

#

               const song = await getPreview(args[0])
               const songname = song.title
#

This is my coode

#

Keep getting this error

#

Error is on line 321 which is - const song = await getPreview(args[0])

twilit geode
#

my .json

{
    "suite": ["s", "d", "h", "c"],
    "1s": "781383820733710376",
    "2s": "781383847174471680",
    "3s": "781383879344521238",
    "4s": "781383909207572530",
    "5s": "781383945744547871",
    "6s": "781384004602429460",
    "7s": "781384215547215903",
    "8s": "781384241300111361",
    "9s": "781384270912028724",
    "10s": "781384305275961365",
    "11s": "781384334648934400",
    "12s": "781384358459736095",
    "13s": "781384462981922826",
    "1d": "781383820666601492",
    "2d": "781383847089668096",
    "3d": "781383879037550603",
    "4d": "781383908771627019",
    "5d": "781383945807331328",
    "6d": "781384004548952124",
    "7d": "781384215606067240",
    "8d": "781384271046246401",
    "9d": "781384271046246401",
    "10d": "781384305590665236",
    "11d": "781384334346158114",
    "12d": "781384358434439189",
    "13d": "781384463048638464",
    "1h": "781383820313755670",
    "2h": "781383847111688192",
    "3h": "781383879445184582",
    "4h": "781383909119229972",
    "5h": "781383945995812874",
    "6h": "781384004690903060",
    "7h": "781384215551410186",
    "8h": "781384241425547275",
    "9h": "781384270945583146",
    "10h": "781384305704173579",
    "11h": "781384334346682401",
    "12h": "781384358673907712",
    "13h": "781384463007350824",
    "1c": "781383820476678174",
    "2c": "781383846897123369",
    "3c": "781383879118290964",
    "4c": "781383909119754240",
    "5c": "781383945547415553",
    "6c": "781384004519723028",
    "7c": "781384215203807253",
    "8c": "781384241429872700",
    "9c": "781384271087534081",
    "10c": "781384305489477642",
    "11c": "781384334506196992",
    "12c": "781384358463799346",
    "13c": "781384462948106260", 
}

is giving me this error for some reason:

SyntaxError: /home/runner/Aperture-Bot/commands/resources/pc.json: Unexpected token } in JSON at position 1559
    at parse (<anonymous>)
``` but I dont think anything is wrong
pale vessel
#

You have a comma at the last element

twilit geode
#

OMG

#

IM SO DUMMMMM

distant bramble
#

Lol

twilit geode
#

ty lol

#

now im confused as fuck why it ran a couple times with thtat

fiery creek
#

Hi, I try to get who is voting my bot unfourtunately its not working can somebody help

lusty quest
#

language?

fiery creek
#

js

#

const DBL = require('dblapi.js'); const dbl = new DBL(yourDBLTokenHere, { webhookPort: 5000, webhookAuth: 'password' }); dbl.webhook.on('ready', hook => { console.log(Webhook running at http://${hook.hostname}:${hook.port}${hook.path}); }); dbl.webhook.on('vote', vote => { console.log(User with ID ${vote.user} just voted!); });

#

this is the one which i used

lusty quest
#

3x ` gives you a codeblock -> easyer to read

#

did you set a webhook url at your bots page?

fiery creek
#

yes

lusty quest
#

did you set a password on your bots page? (same as webhookAuth)

fiery creek
#

Nope

paper cliff
#

@fiery creek Are you running this on your local machine?

#

By the way here is a codeblock syntax:

```js
console.log('Codeblocks example')
```

fiery creek
#

Yes

lusty quest
#

local is not that easy. did you know your external ip adress or did you use a VPN?

fiery creek
lusty quest
#

if you dont pay extra for your ISP contract you probably have a shared IP -> will not work

fiery creek
#

kk

lusty quest
#

either use a Server or a VPN to get a IP adress. then add to your webhook url on top.gg the correct ip adress

fiery creek
#

k thank u

paper cliff
#

Your router has a firewall that prevents you from exposing your webserver to the public

#

And anyway it's not recommended to open ports to the public on your own PC

earnest phoenix
#

Any one knows a good npm package to search things on yt... I'm making a music bot with ytdl core but i need a way to search videos by names

earnest phoenix
#

k

near stratus
earnest phoenix
#

oh thats even better

hollow sedge
#

Sounds illegal πŸ€”

#

Probably don't suggest that

hushed quarry
#

web scrawling isn't illegal

#

all it is is just HTTP requests to public pages

lunar sequoia
#

Scraping is legal as long as you are respecting protected routes for that site. Scraping for public information is fine.

tranquil drum
#

it's against YouTube TOS to scrape data from their site though

pale vessel
#

ah, yes, music bots should be banned

#

right...

weak parrot
#

Technically they should yes.

tranquil drum
#

It depends on the legal definition of a "public search engine" lol

earnest phoenix
#

hello i did a reaction role system, only there is a problem if the bot restarts then it doesn't detect the reaction.
can it be solved somehow?

lusty quest
#

the message is no longer cached. cache it again or use the reaction events

clever vector
#

How do i fix this?

#
(node:2264) UnhandledPromiseRejectionWarning: TypeError: canvacord.Spotify is not a constructor
    at Object.exports.run (C:\Users\User\Pictures\Oppa\No workspace\commands\Information\spotify.js:31:12)
    at module.exports (C:\Users\User\Pictures\Oppa\No workspace\events\message.js:82:19)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:2264) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:2264) [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.
#

Ping me if you know

earnest phoenix
#

somehow it is possible that you do not have to re-enter the response MSG on each server each time you restart, so the old response message will work anytime you restart

lusty quest
clever vector
#

How?

#

here is the code

lusty quest
clever vector
#
  if (message.author.bot) return

  let user;

  if (message.mentions.users.first()) {
    user = message.mentions.users.first();
  } else if (args[0]) {
    user = message.guild.members.cache.get(args[0]).user;
  } else {
    user = message.author;
  }

let status;
if (user.presence.activities.length === 1) status = user.presence.activities[0];
else if (user.presence.activities.length > 1) status = user.presence.activities[1];

if (user.presence.activities.length === 0 || status.name !== "Spotify" && status.type !== "LISTENING") {
  return message.channel.send("This user is not listening music");
}

if (status !== null && status.type === "LISTENING" && status.name === "Spotify" && status.assets !== null) {
  let image = `https://i.scdn.co/image/${status.assets.largeImage.slice(8)}`,
      name = status.details,
      artist = status.state,
      album = status.assets.largeText;

var card = new canvacord.Spotify()
  .setAuthor(artist)
  .setAlbum(album)
  .setStartTimestamp(status.timestamps.start)
  .setEndTimestamp(status.timestamps.end)
  .setImage(image)
  .setTitle(name);

card.build()
  .then(buffer => {
      canvacord.write(buffer, "spotify.png");

      let attachment = new Discord.MessageAttachment(buffer, "spotify.png");
      return message.channel.send(attachment);
  })}
lusty quest
clever vector
lusty quest
#

check who ive answered lol

supple oriole
#
Cookie header used in request, but unable to find YouTube identity token
#

What does this mean 0-o

earnest phoenix
#

is there any library of nodejs that have shards and uses 100mb ram for 1k servers

lusty quest
lusty quest
earnest phoenix
#

@lusty quest djs light have shards ?

lusty quest
#

d.js light is just normal d.js but with most caching removed. i still use some caching and run about 100MB ram with 300 Guilds. compared to normal js that ran with about 300MB while serving 80 Guilds

earnest phoenix
#

in my case djs use 300 mb ram for 39 server after 5 hours of uptime

lusty quest
#

yea its the caching

#

d.js light is way more ram efficent

#

the Dev of the lib is also here on the discord

earnest phoenix
#

yea ik

#

his name is tim on discord

clever vector
lusty quest
#

never used it

clever vector
#

R.I.P

earnest phoenix
#

@lusty quest did you ever uses C# or C++ to develop discord bot ?

lusty quest
earnest phoenix
#

This user ? 189759562910400512 @lusty quest

lusty quest
#

the Moderator yes

earnest phoenix
#

ok

#

@green kestrel can you help me plss

#

um

cinder patio
#

just ask... I'm sure Brain isn't the only one who knows C++ here

lusty quest
#

there are more but this is the only one im sure who uses it

earnest phoenix
#

@cinder patio you use C++ ?

cinder patio
#

yes, I've used it

earnest phoenix
#

@cinder patio curretly using ?

cinder patio
#

why does that matter

#

ask your question

earnest phoenix
#

ok

#

how much ram C++ use for 1k server ?

cinder patio
#

I haven't made any bots using C++, but it all depends which library you're using, what you cache, and how you're handling memory, just using c++ won't solve all your performance issues

earnest phoenix
lusty quest
#

just to say so 100MB ram for 1k guilds could be unrealistic tbh

earnest phoenix
#

alrgt

#

u mean not possible ? @lusty quest

lusty quest
#

its maybe possible if you cache nothing and dont use stuff that renders to the buffer

earnest phoenix
#

πŸ€”

cinder patio
#

I mean, if you don't cache ANY data coming from discord, then 100MB RAM for 1k guilds sound realistic even in node.js

lusty quest
#

sure but is it worth the Performance hit

#

the bot will feel like a brick

earnest phoenix
#

is there any way i can decrase my bot proformance?

lusty quest
#

why did you want to make it slower?

cinder patio
#

you mean increase?

earnest phoenix
#

so that it may use less ram @lusty quest

#

@cinder patio no

lusty quest
#

on js. use d.js-light and disable all caching.

#

will use next to no ram

#

but will be a pain in the ass to use

earnest phoenix
#

@lusty quest everything works ?

lusty quest
#

not everything. you cant do some stuff

#

like permission checks

#

atleast the easy way

earnest phoenix
#

like ban kick av works ?

cinder patio
#

Switching to c++ without any prior knowledge of c++ is not a good idea

lusty quest
#

we talk about js

cinder patio
#

Well he asked about c++ beforehand

earnest phoenix
#

i started using js when i dosent know anything about it

lusty quest
#

kick and ban works but you if you want to check permissions it will become annoying

earnest phoenix
#

@lusty quest like errors or tells everything wrong ?

lusty quest
#

well if its not cached it will error out

#

bcs its unable to find it

earnest phoenix
#

um

cinder patio
#

Best way to handle permissions in discord.js-light is catching the errors and just assume the bot doesn't have the required perms.

lusty quest
#

its normal d.js but without any caching

earnest phoenix
#

are you using djs light ?

lusty quest
#

yes

lusty quest
#

you could workaround it by fetching the spezific stuff you need for it first

cinder patio
#

you don't do permission checks.. you just try to do the thing and catch the error

earnest phoenix
#

@lusty quest if i put everything true in this.. everything works perfectly without using that much ram as djs ?

    cacheGuilds: true,
    cacheChannels: false,
    cacheOverwrites: false,
    cacheRoles: false,
    cacheEmojis: false,
    cachePresences: false
});```
lusty quest
#

this will work. if you want to check permissions enable roles and overwrites

cinder patio
#

If you put true for everything then it's just like discord.js

earnest phoenix
#

um

lusty quest
#

wait nvm

#

yea just try/catch will work

#

since it will error out if you dont have permissions

#

but config commands will be a different thing i guess

cinder patio
#

but it won't error if the person who requested the ban/kick doesn't have the right permissions

earnest phoenix
#

well what about py ? how much ram it use ?

lusty quest
#

py is not the most efficent language. if you want to have more efficent code use a compiled language

earnest phoenix
#

um

lusty quest
#

i dont get why are you wanting to cut down so much on ram usage

#

like for 5$/Month you get a VPS that can easy run normal d.js with 2 shards

earnest phoenix
#

cause i cant afford more than 500 mb vps

lusty quest
#

use d.js light. it will be good enough. if you can grow larger bcs of hardware restrictions i guess there will be the end for you at the point.

earnest phoenix
lusty quest
#

i use D.js light with currently ~300 Guilds and the bot uses about 100MB ram. i dont think with 1k guilds i will get past 500MB

#

even tho iΒ΄m planning to switch to C#

earnest phoenix
#

what about eris + discord.js

lusty quest
#

d.js-light uses less ram

earnest phoenix
#

ok

#

btw do you know about danbot ?

earnest phoenix
#

how can i exactly load an old message?

MY CODE not working

client.guilds.cache.get('781508242828165150').channel.get('781508242828165150').fetchMessage('784332080645537792');
neon heart
#
const { MessageEmbed } = require('discord.js')
module.exports = {
    name: 'voiceStateUpdate',
    async run(client, oldState, newState) {
        if (oldState.channel && oldState.channel.members.size === 1 && oldState.channelID === oldState.guild.voice.channelID) {
            const channel = client.queue.get(message.guild.id).textChannel //error in here ReferenceError: message is not defined
            const e = new MessageEmbed()
                .setColor('RED')
                .setDescription(`I will disconnect if no users join my voice channel after 1 menutes`)
            var em = await channel.send(e)
            setTimeout(() => {
                oldState.channel.leave()
                em.delete({timeout: 2000})
            }, 60000)
        }
    }
}
``` help me
earnest phoenix
#

undifend channels

neon heart
#

make sure the id of the channel is true

earnest phoenix
#
not a function```

the channel is good and the message is both the guild
```js
client.guilds.cache.get('779669294472626227').channels.cache.get('781508242828165150').fetchMessage('784331384587550760');
#

because fetchMessage is not a function

#

@earnest phoenix
i don't fully understand a fixed message i want to load after bot starts

clever vector
#

Anybody can go to my glitch and help me a sec

#

I dont know whats's wrong

earnest phoenix
#

working

#
client.channels.cache.get('781508242828165150').messages.fetch({ around: '784339411323846687', limit: 1 })

.then(async msg => {
console.log(msg)
})
#

)

#

πŸ˜‰

lunar sequoia
earnest phoenix
#

okey

pulsar bone
#
bot.on("message", message=>
{
  let args = message.content.split(" ");
  if(message.content.startsWith(`waheguru`))
  {
    let time = args[1]
    if(!time)
    {
      return message.channel.send("Please Specify Time")
    }
    if(!args[1].endsWith("d") && !args[1].endsWith("h") && !args[1].endsWith("m") && !args[1].endsWith("s") )
    {
      return message.channel.send("you need to use d(days), h(hours), m(months), s(seconds)");
    }

    let gchannel = message.mentions.channels.first();
    if(!gchannel)
    {
      return message.channel.send("you havn't specified the channel")
    }

    let prize = args.slice(3).join(" ")
    if(!prize)
    {
      message.channel.send("please enter a prize");
    }
    gchannel.send(":tada: **NEW GIVEAWAY** :tada:");
    let gembed = new Discord.MessageEmbed()
    .setTitle('New Giveaway')
    .setColor("RANDOM")
    .setDescription(`React With :tada: Top Enter The Giveaway \n Hosted By **${message.author}** \n prize:${prize}`)
    .setThumbnail('https://cdn.discordapp.com/attachments/774196226278293506/782981284329685033/61d82e93fe3f27d3b8a035e464415bb2.gif')
    .setTimestamp(Date.now + ms(args[1]))
    .setFooter('Will End At')
    let m = await gchannel.send(gembed)
    m.react("πŸŽ‰")
    setTimeout(() => {
      if(m.reactions.cache.get("πŸŽ‰").count <=1)
      {
        return message.gchannel.send("i cant select a bubble gum bitch");
      }
      let winner = m.reactions.cache.get("πŸŽ‰").users.cache.filter((u) => !u.bot).random();
      gchannel.send(`**congratulations** ${winner} you have won the ${prize} \n **now please DM **#6226**`)
    },ms(args[1]))
  }
})```
whats wrong with it
rustic nova
#

what's the error message

pulsar bone
earnest phoenix
earnest phoenix
lusty quest
#

@earnest phoenix you need also fetch the channel iirc

lusty quest
#

you want to load a message into the cache. after a restart you also need to load the channel into the cache

earnest phoenix
#

does it load doesn't it?
because it works perfectly on 5 servers

client.guilds.cache.get('779669294472626227').client.channels.cache.get('779681718746611722').messages.fetch({ around: '784308522506125332', limit: 1 })
.then(async msg => {
})```
lusty quest
#

wtf no

#

did you know what you are doing there?

earnest phoenix
#

why what's the problem

lusty quest
#

to quote an old teacher of mine idk what this is but its crap

earnest phoenix
#

but why would it be if it works perfectly

lusty quest
#

you have a duplicated line to start with

earnest phoenix
#

?

lusty quest
#

ohh wait nvm

#

but its a bit wired syntax

#

why 2 clients

earnest phoenix
#

and if I take one off it will be good for you

lusty quest
#

if it work its fine its just wired

earnest phoenix
#

works perfectly I don't understand what's wrong with it

lusty quest
#

you go the way client -> guild -> client -> channel -> message.

#

its valid

#

but just wired

#

guild also got a channel Manager, the client Channel manager contains all channels the Bot is handling while the Guild Channel Manager all guilds in the one Guild you used.

#

you get what im on right?

#

you could also use client.channels.cache.get() instead of fetching the guild first. since it ends up using the same Manager

earnest phoenix
#

i understand it bothers you but it still works for me and i need the guild id separately

lusty quest
#

its your code so i dont have to care

earnest phoenix
#

why are you bullying me

lusty quest
#

?

earnest phoenix
#

what bothers you in my code

twilit rapids
#

Are these IDs fixed, do they ever change if you run the code in a different server for example

lusty quest
#

channel ids are unique across discord itself

#

but i guess with increasing size of the bot fetching the large map with all channels could become inefficent

earnest phoenix
#

good anyway i don't want to argue with me so good and ready

twilit rapids
#

Assuming they don't change, you can just remove the first part and start with client.channels.cache.get(...

lusty quest
#

the map that gets the guild first only loads the map that contains the channels for this one guild.

earnest phoenix
#

justify if I don't replace what happens

lusty quest
#

idk how the performance of the code gets affected if a bot serves 2500 Guilds in one shard.

#

but its possible that the larger map could affect it

twilit rapids
#

Discord.js caches all channels regardless so you can just use .get() on the client.channels.cache collection

lusty quest
#

mostly bcs the map could easy contain a few million ids

earnest phoenix
#

but old messages doesn't cache unless I ask for it

lusty quest
#

messages only get cached when send

twilit rapids
#

Fetching the message is correct

#

But the way you get the channel is a but scuffed

lyric lynx
#
const dbl = new DBL(process.env.TOPGG, { webhookPort: 5000, webhookAuth: 'password' });```

What to write in password?
lusty quest
#

generate a random sting

twilit rapids
lyric lynx
lusty quest
#

but yea the way he gets the channel is valid but he wants to use it this way

earnest phoenix
#

i am asking for an old messaget because of reaction role

twilit rapids
#

@earnest phoenix
client.guilds.cache.get('779669294472626227') -> you get your <Guild> object from your <Client> object
<Guild you just got>.client.channels.cache.get('779681718746611722') -> you get your <Channel> from the same <Client> object you just got your guild from you can get your <Channel> object straight from your <Client> object instead -> client.channels.cache.get('779681718746611722') and fetch the message from that

earnest phoenix
#

a fixed message is required

#

a fixed message is required

twilit rapids
#

Ugh the way you fetch your message is correct but the way you get your channel object isn't

earnest phoenix
#

but I think it's so good now

#

then if I have a problem with it I will fix it

#

but it works so i don't understand what's wrong with you

lusty quest
#

your code will contain unnecessary parts.

twilit rapids
#

That it works doesn't mean it's the best way to do something

earnest phoenix
#

and?

lusty quest
#

Β―_(ツ)_/Β―

earnest phoenix
#

it may not be the best method but for me it is good now

warm canyon
#

use partials to get reaction on old messages

#

i guess that is what bothering you πŸ€”

quartz kindle
#

lets say the channel you want is in your kitchen, instead of going to the kitchen to get it, you're leaving your house from the backdoor, going all the way around the block, enter your house again from the front door then enter your kitchen to get it. thats essentially what your code is doing lol @earnest phoenix

#

sure it works, but why go the all the way around then you can just go directly there?

slender thistle
#

You saying you wouldn't cut through the roof instead?

#

I'm disappointed

#

(In JS, that would be raising a custom exception for no valid reason and handling it with normal code)

dreamy parcel
#

Wkwkwkwkwk

quartz kindle
#

go to the airport, steal a plane, fly over your house, jump, parachute, land on your roof, dig through your roof with a shovel, fall into the kitchen, grab channel, win.

slender thistle
#

This man gets it

#

I love you Tim

quartz kindle
#

😘

slender thistle
#

❀️

earnest phoenix
#

before doing anything i want to make sure is it possible to make autorole if someone is streaming a specific game (discord.js)

pale vessel
#

Using the presenceUpdate event, I think it should be possible

earnest phoenix
#

alright sounds good

quick ridge
earnest phoenix
#

.addField(`Memory`, `${memory}`, true)

#

right?

green kestrel
#

by correct data structures a map/hash map, or even an R/B tree based storage is fine, so long as its not any type of O(n) array

#

i was pretty close to 2500 guilds per shard in mid september

#

when i hit 10k, and i only had 4 shards

#

well, i was at 9800

#

but i was away on holiday and couldnt scale it up πŸ˜„

lusty quest
#

good to know

#

but the idea was that the client.channel Manager contains all Channels the bot is serving vs client.guild.channel where the map only contains all channels of the guild. idk how performance wise the impact is if you run at 2500 guilds

quartz kindle
#

js Maps are good until about 10 million keys afaik

#

read speeds get significantly reduced at around 12-13 million

#

and it crashes at 15-16

#

write speed starts slowing down at 4-5 million

lusty quest
#

i guess its fine then. if of the 2500 guilds each got 50 channels you reach at max 125000 keys in the map

quartz kindle
#

by that point, your client.users.cache will likely be at 500k+

#

if you use fetchAllMembers or have presences enabled

#

there's an interesting package on npm called megahash

#

its a Map implementation in c++, the dude made benchmarks until 1 billion keys

lusty quest
#

i dont think with a discord bot you will get close to need this

quartz kindle
#

unless you use internal sharding with 100+ shards xD

lusty quest
#

if you can afford a 30k$ server to run it ok

delicate shore
#
process.on('SIGINT', signal => {
for (let channel of client.guilds.cache.filter(g => g.me.voice.channel).map(g => g.me.voice.channel)) channel.leave();
console.log(`Process ${process.pid} has been interrupted`) process.exit(0) })
#

My bot doesn't leave VC when I restart the nodejs process

restive pebble
#

i want to know sometimes the messageUpdate event fires up when a message is being sent , how do i fix it?

rustic nova
#

check if the message was just created by comparing the timestamps

#

but i dont think messageUpdate should fire on a sent message

earnest phoenix
#

@delicate shore u can try this:

for(let i of client.voice.connections.array()){

  i.channel.leave()

}
cinder patio
#

or alternatively:

for (const [, i] of client.voice.connections) {
  //...
}
halcyon linden
#

Hi

#

I have a problem, how can I block the emojis or weird characters in the args? as well as isNaN but so that it returns true if they are letters or false if they are not letters

#

Please I need help with that

lusty quest
#

you could use regex to detect such stuff

halcyon linden
#

Look, I'll explain, it's a search command with an npm but if you send emojis, the bot shuts down. It is a problem that I need to solve but now

lusty quest
#

try/catch block

#

if it errors out handle the error

halcyon linden
#

Ok

halcyon linden
#

I can't xd

#

Well, actually, I thought a solution

#

Thanks a lot @lusty quest

earnest phoenix
#

@halcyon linden yo hablo espaΓ±ol, que necesitas?

fleet dove
#

thi is a coomand in .js for ban !!!

if(message.content.startsWith("d.ban")){
    var BanUser = message.mentions.members.first();

    if(!message.member.hasPermission("BAN_MEMBERS")){
        message.channel.send("non hai i permessi");
        return;
    }

    if(!BanUser){
        message.channel.send("menziona qualcuno!")
        return;
    }

    if(!BanUser.bannable){
        message.channel.send("mettimi il permesso prima");
        return;
    }

    BanUser.ban()
        .then(() =>message.channel.send("<@" + BanUser + "> Γ¨ stato bannato"))
}
fleet dove
#

no?

#

it should only go in the .js

lusty quest
#

i dont get why did you send it then here?

fleet dove
#

I recommend it !!!