#development

1 messages Β· Page 954 of 1

copper cradle
#

and

#

that's the wrong eay tho

magic jackal
#

o

quartz kindle
#

you want to redefine the value of a variable you passed?

copper cradle
#

you want to call the function

#

so _cb(values)

magic jackal
#

I just wanna map the error from the try catch block to the function callback

quartz kindle
#

if callback is a function, then you need to call it, not define it

magic jackal
#

or THROW an error idk

quartz kindle
#

but like

copper cradle
#

that's literally what I just said

quartz kindle
#

its an async function, why use a callback?

copper cradle
#

yeah

magic jackal
#

I'm not very good with async sorry, the promise never fails thats the issue I think

#

I cant seem to get .catch to work on it

copper cradle
#

...

magic jackal
#

sorry bro lmao, I know I'm stupid rn, sometimes my brain doesnt work

gritty bolt
#

hey can someone look at my message above this?

#

im still stuck

quartz kindle
#

@magic jackal ```js
async function bla() {
throw 123;
}

try {
await bla()
} catch(e) {
console.log(e) /// 123
}

bla().catch(e => console.log(e)) // 123

copper cradle
#
async function f() {
    return 1;
//this does not wait at all, but I'll just prove a point
}

let x = await f(); //assuming the current scope is async
this is the same as doing
f().then
#

I'm on my phone

#

holy fuck

#

I guess Tim's got this lol

magic jackal
#

mk I see

quartz kindle
#

well, i showed the error, you showed the non-error

#

we both did half of it

#

xD

magic jackal
#

lmao

copper cradle
#

lol

gritty bolt
#

Honestly not sure whats wrong here, all of the files are formatted the same, anyone know whats wrong?

    at C:\Users\Samst\IdeaProjects\ClockMaster\index.js:64:41
    at Array.forEach (<anonymous>)
    at C:\Users\Samst\IdeaProjects\ClockMaster\index.js:61:16
    at FSReqCallback.oncomplete (fs.js:155:23)```

```js
 jsfile.forEach((f, i) => {
            let props = require(`./Commands/${f}`);
            console.log(`${f} loaded!`);
            bot.commands.set(props.help.name, props)
        })
    });```
```js
module.exports.help = {
name: "wcsetup"
}
module.exports.help = {
name: "convert"
}```

@gritty bolt

quartz kindle
#

are you sure all of them are?

#

and all of them are properly saved?

#

maybe one of them doesnt have a help object or you forgot to save it

gritty bolt
#

hold on let me see

#

i've tried saving them a few times

pure lion
#

how do i remove content from a string

#

ive tried (string - "word") but returned NaN

quartz kindle
#

if you want to remove it from the middle, string.replace("word","")

pure lion
#

ok so you know dadbot

quartz kindle
#

from the beginning or end, you can use string.slice()

pure lion
#

alright thanks

gritty bolt
#

nope still not working @quartz kindle

#

I have no idea what could possibly be wrong

#

they all look the same

quartz kindle
#

@gritty bolt well thats what the error says it wrong, and errors dont lie

#

you can add a console.log to see which one is it

gritty bolt
#

i've found which ones they are

#

it goes in order

#

but i've sifted through all of them and it's the same piece of code just with different stuff in the "s

quartz kindle
#

add a console.log

#

console.log(props.help)

gritty bolt
#

aha i found it

quartz kindle
#

also check if you didnt misspell module.exports somewhere

gritty bolt
#

i messed up putting it somewhere my fault

#

sorry for the hassle

tired nimbus
#

can you no longer create emojis using discord.js?

warm marsh
misty sigil
#

boys

#

quick question

#

how do i leave a vc in discord.js

earnest phoenix
#

s

copper cradle
#

<vc>.leave()

misty sigil
#

thank

copper cradle
#

@earnest phoenix you can't just yardim botum outside of #commands

#

@misty sigil iirc ofc

#

I'm not sure tho

merry shuttle
#

How do you guys make your admin web panel's for bot's over 1k servers?

green kestrel
#

ugh, i think my admin dashboard needs a hell of a lot of work

#

the copyright notice at the bottom says 2004, and it certainly looks like it

merry shuttle
#

1k servers how?

green kestrel
#

in case youre wondering, this is ALL table layouts and colours/styling inside the html tags as color attributes.

tulip ledge
#

Anyone knows how I get the data from my MYSQL database where id = a certain value and item is not?
I tried WHERE id = "id" AND NOT item = "item"Β΄

#

But that doesnt work

slender thistle
#

<>

tulip ledge
#

?

slender thistle
tulip ledge
#

So WHERE id = id AND item <>"item"

slender thistle
#

Yeah

green kestrel
#

you can also use !=

#

which i find more readable, but thats because of C++, PHP, javascript

cerulean hornet
tranquil drum
#

Try npm i?

cerulean hornet
#

I use the glitch: c

small prairie
#

how do i convert
[ [ 'hello', [ 'How', 'Are', 'You' ] ] ]
to
[ { 'hello': [ 'How', 'Are', 'You' ] } ]
(Array to object)

#

Is there a way or do i have to custom code it?

tranquil drum
#

you probably have to implement it yourself

#

although if the outer structure is still an array you don't really get any benefit of using an object inside

small prairie
#

aight thanks

cerulean hornet
#

someone help me pls

honest perch
#

name checks out

slender thistle
#

-ask2ask

gilded plankBOT
#

Don't ask to ask.
Just ask your question, it wastes time if you say "i need help" or "can someone help me?" instead of just saying what the problem is. Save your time and other people's time and just ask the question.

Please read https://dontasktoask.com/ for an explanation on why this is an issue.

honest perch
#

they asked above

#

smh

river terrace
#

module.exports = {
  name: "warn",
  description: "Warn a user",
  category: "mod",
  usage: "<User mention> <Reason>",
  run: async (bot, message, args) => {
    let user = message.mentions.users.first();
    if (!user) return message.channel.send(`You did not mention a user!`);
    if (!args.slice(1).join(" "))
      return message.channel.send(`You did not specify a reason!`);
    warns.findOne(
      { Guild: message.guild.id, User: user.id },
      async (err, data) => {
        if (err) console.log(err);
        if (!data) {
          let newWarns = new warns({
            User: user.id,
            Guild: message.guild.id,
            Warns: [
              {
                Moderator: message.author.id,
                Reason: args.slice(1).join(" "),
              },
            ],
          });
          newWarns.save();
          message.channel.send(
            `${user.tag} has been warned with the reason of ${args
              .slice(1)
              .join(" ")}. They now have 1 warn.`
          );
        } else {
          data.Warns.unshift({
            Moderator: message.author.id,
            Reason: args.slice(1).join(" "),
          });
          data.save();
          message.channel.send(
            `${user.tag} has been warned with the reason of ${args
              .slice(1)
              .join(" ")}. They know have ${data.Warns.length} warns.`
          );
        }
      }
    );
  },
};```
#

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:268) [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.

#

error ^

#

da fuq did i do wrong

mossy vine
#

you didnt show the error

river terrace
#

i didnt?

mossy vine
#

you didnt

river terrace
#

uh let me try to realod it and see if it shows it

#

hol dup

#

both successfully load without error

#

when executed they dont work and they throw an error

#

idk what the error is tho

honest perch
#

you need mongo/mongoose

river terrace
#
    at Client.emit (events.js:310:20)
    at MessageCreateAction.handle (/home/runner/nypsi/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
    at Object.module.exports [as MESSAGE_CREATE] (/home/runner/nypsi/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
    at WebSocketManager.handlePacket (/home/runner/nypsi/node_modules/discord.js/src/client/websocket/WebSocketManager.js:386:31)
    at WebSocketShard.onPacket (/home/runner/nypsi/node_modules/discord.js/src/client/websocket/WebSocketShard.js:436:22)
    at WebSocketShard.onMessage (/home/runner/nypsi/node_modules/discord.js/src/client/websocket/WebSocketShard.js:293:10)
    at WebSocket.onMessage (/home/runner/nypsi/node_modules/ws/lib/event-target.js:125:16)
    at WebSocket.emit (events.js:310:20)
    at Receiver.receiverOnMessage (/home/runner/nypsi/node_modules/ws/lib/websocket.js:800:20)
    at Receiver.emit (events.js:310:20)
    at Receiver.dataMessage (/home/runner/nypsi/node_modules/ws/lib/receiver.js:436:14)
    at Receiver.getData (/home/runner/nypsi/node_modules/ws/lib/receiver.js:366:17)
    at Receiver.startLoop (/home/runner/nypsi/node_modules/ws/lib/receiver.js:142:22)
(node:268) 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:268) [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.```
#

oh

#

lmfao

honest perch
#

and discordjs

river terrace
#

i have that lol

#

i dont have mongo tho

mossy vine
#

still everything but the error

river terrace
#

cyber lmao thats what pops up in my console

#

xD

mossy vine
#

the line above

#

is the one that says what the error is

honest perch
#

how did you not install mongoose/mongo and made a mongo save im guessing

mossy vine
#

what

river terrace
#

yeah what he sad

#

what

honest perch
river terrace
#

said*

honest perch
#

what package are you using to save it

river terrace
#

idk

mossy vine
#

are you just copying and pasting code

honest perch
#

@river terrace and are you using mongodb as the database

#

and do you have a schema located at ..models/warns

cerulean hornet
honest perch
#

did you do enable-pnpm?

#

or try to export it and import it into a new project

opaque seal
#

How do I add reactions, one after each other, fast?

            .then(msg => {
                msg.react(acceptEmoji)
                    .then(() => {
                        msg.react(denyEmoji)```
I'ver tried this but it is really slow to add reactions

I've tried with await and it is still slow

cerulean hornet
#

already exported to another project but the error continues

honest perch
#

can you show me your package file

quartz kindle
#

@opaque seal discord.js adds a delay between all requests, but since this delay is fixed, reactions suffer the most

small prairie
#

In ejs we do something like var something=<%-something%>
can we do it the other way
<% var something=%>something

quartz kindle
#

you can reduce this delay in the client options

opaque seal
#

@opaque seal discord.js adds a delay between all requests, but since this delay is fixed, reactions suffer the most
Because I saw a ModMail bot which added reacitons real fast

quartz kindle
#

restTimeOffset in your client options

opaque seal
#

Where can I find my client options?

quartz kindle
#

new Discord.Client({options here})

small prairie
#

when u are initializing your client

opaque seal
#

oh ok

cerulean hornet
#

can you show me your package file
@honest perch ```{
"name": "battlebot",
"version": "1.0.0",
"description": "",
"main": "index.js",
"engines": {
"node": "12.x"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"discord.js": "^12.2.0",
"moment": "^2.26.0",
"parse-ms": "^2.1.0",
"quick.db": "^7.1.1",
"dotenv": "^8.2.0",
"ytdl-core": "^3.1.0",
"yt-search": "^1.1.2",
"ffmpeg-binaries": "^4.0.0",
"node-opus": "^0.3.3",
"superagent": "^5.2.2",
"ms": "^2.1.2",
"random-puppy": "^1.1.0",
"youtube-info": "^1.3.2",
"simple-youtube-api": "^5.2.1",
"convert-seconds": "^1.0.1",
"jimp": "^0.12.1",
"node-fetch": "^2.6.0",
"number-to-words": "^1.2.4",
"merge-img": "^2.1.3",
"weather-js": "^2.0.0",
"gifencoder": "^2.0.1",
"snekfetch": "^4.0.4",
"table": "^5.4.6",
"array-sort": "^1.0.0",
"opusscript": "^0.0.7",
"node-gyp": "^6.1.0",
"mathjs": "^6.6.5",
"request": "^2.88.2",
"quick.hook": "^1.5.1",
"cpu-stat": "^2.0.1",
"os": "^0.1.1",
"mal-scraper": "^2.6.9",
"google-translate-api": "^2.3.0",
"node-superfetch": "^0.1.10",
"better-sqlite3": "^7.0.1",
"nekos.life": "^2.0.7",
"fs": "^0.0.2",
"request-promise-native": "^1.0.8",
"fs-nextra": "^0.5.1",
"youtube-api-v3-search": "^1.2.1",
"youtube-search": "^1.1.4",
"express": "^4.17.1",
"firebase": "^7.14.6",
"moment-duration-format": "^2.2.2",
"date-format": "^3.0.0",
"sqlite3": "^4.2.0",
"dblapi.js": "^2.4.0"
},
"devDependencies": {},
"scripts": {
"test": "echo "Error: no test specified" && exit 1"
},
"author": "",
"license": "ISC"

}```

opaque seal
#

And what's the downside of reducing the restTime?

small prairie
#

And what's the downside of reducing the restTime?
@opaque seal Probably more chances to get ratelimited

quartz kindle
#

you will be more likely to hit the rate limits

honest perch
#

did you install every package you could find

#

like jesus

small prairie
#

Ikr lmfao

opaque seal
#

Uhm, I'm gonna stick to the default value then

small prairie
#

ye

cerulean hornet
#

did you install every package you could find
@honest perch are all the bot uses: c

radiant estuary
#

How can I get the Usernamen with OAuth2?

mossy vine
#

you do the oauth flow with the identify scope

honest perch
#

@cerulean hornet idk then, try asking on the glitch forums

radiant estuary
#

you do the oauth flow with the identify scope
@mossy vine yes

mossy vine
#

yes

earnest phoenix
#

How can I remove the last comma from a string?

clever tree
#

How could I delete only one line from fs ? For example i want to delete only this line in a fs file "420686077070934016":{"leaveserverc":"false"}

earnest phoenix
#

delete object & then rewrite @clever tree

radiant estuary
#

How can I get the Usernamen with OAuth2?
@radiant estuary

clever tree
#

I want to delete a membersetting from a server when this person leaves

earnest phoenix
#

exactly what i said ye

#

check if the fs file containt the .id of the guild or member what ever

#

define delete []

#

then rewrite

clever tree
#

@earnest phoenix But how ? fs needs an input like :

serverlevel[message.guild.id] = {
                                serverlevel: "true"
                        }

Which input is for delete? Or which function fs.writeFile

earnest phoenix
#

require the data first

#

then

#
if (serverlevel[message.guild.id]) // do something
tulip ledge
#

Any idea why this happens?
So this is my querry:
SELECT * FROM reps WHERE repid = "${args[1].toUpperCase}"
Args[1] is set to 1.
It sais it can't find the row but when I do this in the command line:
SELECT * FROM reps WHERE repid = "1";
It finds a row

clever tree
#

@earnest phoenix yea. And now what is the delete function. serverlevel[message.guild.id].delete()

#

?

earnest phoenix
#

delete serverlevel[msg.guild.id]

#

@clever tree

radiant estuary
#

How can I get the Usernamen with OAuth2?

tulip ledge
#

Anyone know my solution?

clever tree
#

@earnest phoenix @earnest phoenix thx

#

allot :)

earnest phoenix
#

no problem πŸ˜„

grizzled raven
#

@quartz kindle if you set the restTimeOffset to, for example, 5000, will discord.js wait 5 seconds before every request?

misty sigil
#

hey

#

anyone got any idea how to use the bot's current voice channel for a connection

#

instead of message.member.voice.channel.join

tulip ledge
#

So I have thise message.createdTimestamp but when I use this: client.moment(time).format("MM/DD HH:mm"); it kinde gives a weird date. Anyone knows how to solve that?

quartz kindle
#

@grizzled raven i think so

#

never tried lul

tulip ledge
#

Does anyone know how to turn a discord timestamp into a date using moment.js?

fallen vessel
#
   "content":"{@user}",
   "embed":{
      "color":-9270822,
      "title":"welcome",
      "description":"hi {user} welcome",
      "author":{
         "name":"{user}#{user-discriminator}",
         "icon_url":"{user-avatar-url}"
      },
      "thumbnail":{
         "url":"{user-avatar-url}"
      },
    "footer": {
      "text": "userid: {user-id}"
    }
   }
}```

**embed for welcome**
quartz kindle
#

what weird date did it give you?

tulip ledge
#

11/18 12:20

#

And it was the current message.createdTimestamp

quartz kindle
#

console.log(message.createdAt)

misty sigil
#

does anyone know how to get current vc of bot?

tulip ledge
#

You know a solution?

misty sigil
#

anyone?

quartz kindle
#

on which guild?

tulip ledge
#

I know the problem

#

I'm putting a string in there

#

Not an integer

misty sigil
#

well, the only guild it's in

#

VC id : 709992213047672833
Guild ID : 709990437007392828

quartz kindle
#

guild.voice.channel in djs v12

misty sigil
#

ty

quartz kindle
#

or client.voice.connections.first().channel

astral yoke
#

i got this right

#

```let statuses = [${bot.users.size} users! | db!help, ${bot.guilds.size} servers! | db!help];

setInterval(() => {
let status = statuses [Math.floor(Math.random() * statuses.length)];

 bot.user.setActivity(status, { type: "WATCHING"})

// watching, stremaing, playing
}, 10000);```

#

how come it shows on the bot that theres 0 users

mossy vine
#

d.js v12?

astral yoke
#

11

mossy vine
#

wtf

astral yoke
#

ik ik i gotta switch

#

but can you help

earnest phoenix
#

How can you have an empty title for an addField()?

digital ibex
#

hi

#

i'm trying to log into the discord thing i'm making and uhh, im' getting an error, Error: Unknown authentication strategy "discord" i kno what it means but how can i make it not error and make me log in? the code passport.authenticate('discord')

tulip ledge
#

How do I remove the f irst 2 indexes of an array?

warm marsh
#

slice

round garden
#

pm2 says heap size is Code metrics value β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Heap Size β”‚ 49.70 MiB β”‚ β”‚ Heap Usage β”‚ 96.26 % β”‚ β”‚ Used Heap Size β”‚ 47.84 MiB β”‚ β”‚ Active requests β”‚ 0 β”‚ β”‚ Active handles β”‚ 8 β”‚ β”‚ Event Loop Latency β”‚ 0.09 ms β”‚ β”‚ Event Loop Latency p95 β”‚ 2.39 ms β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
but I've done pm2 start index.js --node-args="--max_old_space_size=4096"
node v12
How do I add more heap to pm2?

rocky lintel
#

How should I fix a 503 error/overloaded

blazing portal
#

@earnest phoenix in D.js v12 \u200b

grizzled raven
#

\u200b isnt at all related to discord.js, its a unicode character

astral yoke
#

on glitch

#

how do you update your node version

river terrace
#

@astral yoke on the sidebar you will see a file called "packages" click it and then click on the search bar at the top, or the little drop down box thingy, then type in "node" and see what comes up, install the one that you need and bam bam bam ur good to go

#

thats all i know lol

earnest phoenix
#

wHAt

indigo flax
#

who is good with python eval

#

what is the eval to make a webhook

river terrace
#

try google?

indigo flax
#

anyone?

river terrace
#

ill google it for you hang on

indigo flax
#

ty

river terrace
#

ok all i could find was this

indigo flax
#

um

river terrace
#

thats all i could find in reference to your question

#

WAIT

indigo flax
#

ty

river terrace
#

NO NO NO

#

wait

indigo flax
#

?

river terrace
#

found another thats way better

#

try that

#

that looks just about perfect

#

for the question u asked

sudden geyser
#

is that even relevant? That's from 2018

proven lantern
#

client.on('message', (msg) => {msg.content}); Will msg.content contain the command prefix?

grizzled raven
#

make your bot before submitting it to top.gg

honest perch
#

^

#

@proven lantern

strong tundra
#

sir can i code discord bot using html

#

bcause all i know right now is html

quartz kindle
#

nope

earnest phoenix
#

How's it possible to remove the very last string from an array that equals to a specified string?

strong tundra
#

darn sir

#

glad i used rust instead

earnest phoenix
#

If you didn't know what i was talking about... Well
["--dark", "--dark", "--dark"] you see that the array contains 3 of the same string... But how can remove the very last one of them that equals to a specified string?

tranquil drum
#

You could start from the back of the array and check each element until you find one that equals some other string and remove it

earnest phoenix
#

But there's the thing... How do you even start from the back of the array...

slender thistle
#

reverse the array

tranquil drum
#

You could use a for loop starting with the last index if you need to keep the array order

#

Or reverse, iterate, reverse again

earnest phoenix
#

Oh the array.reverse()

slender thistle
#

Or do what teemaw said

earnest phoenix
#

Yea well... Lemme try

quartz kindle
#

if you're wondering how to start from the last index: for(let i = array.length-1; i >= 0; i--)

proven lantern
#

@grizzled raven ^

#

@quartz kindle Trickier way to iterate backwards for(let i=x.length; i--;pi=3.14)

quartz kindle
#

good trick

tranquil drum
#

Lol JavaScript really be something else

#

Neat type coercion

quartz kindle
#

another trick ```js
let i = array.length;
while(--i) {

}

#

but this one will ignore index 0 lul

tranquil drum
#

Just do while(iβ€”) instead?

quartz kindle
#

yes

#

i need sleep

tranquil drum
#

Lol

quartz kindle
#

fun fact for(;;) does the same as while(true)

sudden geyser
#

isn't while faster than for o.o

quartz kindle
#

they both compile to the same thing afaik

tranquil drum
#

while(true) is certainly more readable though

quartz kindle
#

but for(;;) is shorter :^)

white anvil
#

I mean for arguments sake you could just do while(1)

ancient lichen
#

i love this "fight"

white anvil
#

this is real programming

ancient lichen
#

ikr uwu

tranquil drum
#

lol

proven lantern
#

to make it more readable you should use recursion or high order functions instead of looping

tranquil drum
#

LOL

quartz kindle
#
do
  goto hast
hast
  goto mich
white anvil
#

I love an infinite recursive routine

#

stack frame be like bruh?

deft condor
#

node v12.0.0, with pnpm

7:21 AM

Installing…

7:21 AM

Performing headless installation

7:21 AM

7:21 AM

Total install time: 2642ms
Nothing happened and nothing in console, how can I fix this?

#

is (node .) the problem

#

I try refreshing and now glitch doesn’t even load

forest pond
#

Which Bot Library Is Recommended?

white anvil
#

there is literally no vaguer question than that

forest pond
#

Which Is Recommended

white anvil
#

for what language

steel drum
#

there are ALOT of recommended libraries

#

^

forest pond
white anvil
#

choose one

forest pond
#

Java

tranquil drum
#

I use JDA

forest pond
#

Noice

white anvil
#

I suggest you learn java before writing a bot then

forest pond
#

What About HTML5

white anvil
#

that’s not a programming language

forest pond
#

But It’s A Coding Language

white anvil
#

no it’s not

#

it’s a markup language

forest pond
#

Look At Google

white anvil
#

have fun writing a bot in a language that’s meant for browser games

proven lantern
#

my friend programmed a flying pizza with the marquee tag

tranquil drum
#

HTML can only represent states, it doesn't handle any logic

white anvil
#

what the hell is that list anyway

#

half of those aren’t languages at all

tranquil drum
#

lol "Plain text"

#

I think that's a list of supported syntax highlights for some mobile app

forest pond
#

What About Python

white anvil
#

I think you should do some research into good programming languages for beginners

#

you clearly have no idea what you’re doing

forest pond
#

Anyway Gtg I’m Learning JavaScript

proven lantern
forest pond
#

Bruh

tranquil drum
#

that's some ancient HTML

misty sigil
#

anyone know how on earth i can add an uptime command

forest pond
#

Ok

#

No

white anvil
#

what language

ancient lichen
#

anyone know how on earth i can add an uptime command
@misty sigil what language?

misty sigil
#

djs, i shoulda specified that

tranquil drum
#

store the current time when the bot starts, and subtract that from the current time at the time the command is received

white anvil
#

process.uptime()

#

returns amount of seconds the process has been running for

misty sigil
#

suprisingly simple

forest pond
#

I’m Using Node.Js And Learning JavaScript

misty sigil
#

best thing is

proven lantern
#

is that the time the nodejs server has been running or the amount of time since the discordjs login?

misty sigil
#

i have ab!reload, i dont have to restart

white anvil
#

former

tranquil drum
#

nodejs process

white anvil
#

since the websocket can close without the process exiting

misty sigil
#

nodejs process, as if thats longer than login

tranquil drum
#

it probably is by a little bit

white anvil
#

you can get ws uptime as well

proven lantern
#

maybe there is reconnect logic

white anvil
#

I think djs has built in property for this

tranquil drum
#

I'd hope so @proven lantern

quartz kindle
#

discord.js has an uptime property

#

for socket connections

white anvil
#

the gateway reconnects all the time though

quartz kindle
#

true

white anvil
#

so process and ws uptime can become very disjoined

#

ws uptime shouldn’t go above like 12 hours

#

in discord’s case

#

but process can go on for as long as you want

quartz kindle
#

i actually use client.uptime in my code

#

never seen it get reset

white anvil
#

they probably only handle closure

#

And not reconnect

#

ws connections have to be reset every few hours otherwise discord closes the connection

quartz kindle
#

i remember looking at some source

#

but i think it was eris, not discord.js

#

and it did in fact reset client.uptime on every reconnect

white anvil
#

if you log gateway events you should get fairly common reconnects

quiet sedge
#

does anyone know how can i show all the roles that the user has ? tried with user.roles.find(roles => `${roles}`).join(', '), true) but didn't work

white anvil
#

that’s just because discord required it a few months ago

quartz kindle
#

yeah ik

#

but apparently discord.js doesnt make it reset the client.uptime getter

#

while eris does

white anvil
#

dumb

#

pretty easy to do that yourself

quartz kindle
#

Β―_(ツ)_/Β―

white anvil
#

not sure how easy it is to access the websocket conn with djs

proven lantern
#

@quiet sedge user.roles is a collection with all the users roles. you should be able to iterate over the collection to see all the roles for that user

white anvil
#

they like to make shit like that inaccessible for some dumb reason

quartz kindle
#

its js, you can pretty much hack anything via prototypes

white anvil
#

prototyping is really dumb

#

i immediately dislike any codebase that uses them

#

completely defeats the point of classes lol

quartz kindle
#

my lib has to use them in order to intercept some parts of djs that i couldnt make work with class extensions

tranquil drum
#

maybe you don't need a class

white anvil
#

strong oop is by far the best way to write code in this context

#

if it’s available

#

makes everything a lot easier to abstract

tranquil drum
#

as in the context of a Discord library?

#

or a bot

white anvil
#

well in the context of any package

tranquil drum
#

Ahh you're talking about libs in general

proven lantern
#

pure functional programming is better that oop

copper cradle
#

@quiet sedge use a map

fallow steppe
#

Is args[0] getting first argument of split message? ( in d.js )

copper cradle
#

instead of find

#

map

#

duh

white anvil
#

pure functional programming is a bit niche

copper cradle
#

well

#

it gets messy after a bit

white anvil
#

it’s not better, that’s completely subjective

#

it’s a damn lot more efficient at scale but very hard to work with for much else

wicked pivot
#
const GetLinkByModule = require('node-fetch')
const LinkDiscordP = ["discord.gg/", "https://discord.gg/"]
  if(LinkDiscordP.some(link => message.content.toLowerCase().includes(link))){
    let LinkGetDiscordApi = GetLinkByModule("https://discord.com/api/v6/invites/" + idk)
  }```hi, i would like to make it so that when a link and post on the server its sends me all kind of info. except that I've been stuck here for a while
copper cradle
#

@fallow steppe we don't know, how did you define args

#

you obvs followed a tutorial

#

since you're asking such thing

earnest phoenix
#

@wicked pivot discord.js has a function that can fetch invites already

#

no need to make extra work

copper cradle
#

@proven lantern it's subjective, as Jacher said, and imo pure functional programming gets messy after a bit

wicked pivot
#

can the fetch invite give me info on a link from a server or the bot es but not otherwise? @earnest phoenix

copper cradle
#

imo = in my opinion

tranquil drum
#

@white anvil I have to disagree that "oop is by far the best way to write code in this context" as like you said it's all subjective and different programming paradigms exist for a reason

copper cradle
#

just in case

white anvil
#

yeah on the subject of distributed open source packages, structures are usually beneficial

quiet sedge
#

@quiet sedge use a map
@copper cradle i tried. but i get TypeError: Cannot read property 'map' of undefined

copper cradle
#

then

white anvil
#

hence why djs is absolutely bursting with them

copper cradle
#

what are you trying ti map

#

show the code

#

as you used it

#

@quiet sedge

quiet sedge
#

embed.addField("Roles:", user.roles.map(roles => `${roles}`).join(' | '), true)

earnest phoenix
#

roles.cache

copper cradle
#

^

#

find gets just 1 element

cunning gorge
#

Hey, i gotta question
I have this

  try {
    message.channel.send(embed).then(m => m.delete({ timeout: 10000 }));
    db.set(`welcomeMessage_${message.guild.id}`, welcome);
    func.embed(message.channel, `**Successfully set a welcome message!**`);
  } catch (error) {
    message.channel.send(
      "Invalid Message: please re-type the command with a valid message!"
    );
  }

Its supposed to catch the error right? Well it doesnt do that, it gives me this

#

Ping me if ya have any solution

amber fractal
#

try/catch doesnt work with promises

#

unless you await them

#

use .then and .catch

copper cradle
#

and the error says

amber fractal
#

or just .catch

copper cradle
#

Not a well formed url

cunning gorge
#

Oh

#

so what should I change?

earnest phoenix
#

.setImage on the embed is probs malformed

copper cradle
#

2 things

#

what what steven said

#

and, show the url that you're trying to pass in

cunning gorge
#

ye i purposely made a bad image url to see if it would catch

copper cradle
#

ah

cunning gorge
#

since this is a feature for other people to add an image

copper cradle
#

then it's just what steven said

amber fractal
#

after sending a message, after your .then you can add a .catch(console.error)

cunning gorge
#

oh i see

#

alright ill try that

#

thanks mate

quiet sedge
#

thanks @earnest phoenix that did the job πŸ™‚

cunning gorge
#

gives me this

#

does paren not work?

tranquil drum
#

catch accepts a lambda i think

#

when it's on a promise

amber fractal
#

it's the {}

tranquil drum
#

it's not a control structure anymore

#

it's just a function

cunning gorge
#

ohh this is new to me lel

amber fractal
#

you can .catch((e) => { code }) if you want

cunning gorge
#

oh ok

#

thanks

amber fractal
#

Yep

cunning gorge
#

can i catch(e) or do i need to catch console.error

earnest phoenix
#

catch(function)

tranquil drum
#

do you want it to print to console?

cunning gorge
#

oh

#

thats what that does

#

i see thanks

#

And, is e the same as err the same as error?

amber fractal
#

it's just a callback, providing console.error just makes it log the error for you easily

proven lantern
#

catch is a higher-order function

tranquil drum
#

that's just the name you want the parameter to be

earnest phoenix
#

so catch(function(err) { /scope/}) has e as error in the scope

tranquil drum
#

lol tru @proven lantern

sick cloud
#

so say i have this

exports.engine = async function (data) {

}

in the same file, can i do this

module.exports = function (app) {
    engine(app.data);
}

or something like this.engine or exports.engine...

tranquil drum
#

exports.engine

misty sigil
#

developing question
i have ram usage, not CPU, how does one implement this

proven lantern
#

save everything to disk

earnest phoenix
#

os module

sick cloud
#

cool

tranquil drum
#

bro you're funny @proven lantern

quartz kindle
#

@misty sigil system ram or process ram?

misty sigil
#

process

#

but i got that working

quartz kindle
#

i mean cpu, sorry

wicked pivot
quartz kindle
#

system cpu or process cpu?

misty sigil
#

process would be preferred

cunning gorge
#
    await message.channel.send(embed).then(async msg => {
          await db.set(`welcomeMessage_${message.guild.id}`, welcome);
    await func.embed(message.channel, `**Successfully set a welcome message!**`);
      
    }).catch((e) => {
      return message.channel.send(`Invalid URL!`)
    })

For the then statement what has to go before the arrow function, it seems m and msg works, does js automatically know what that is?

tranquil drum
#

are you using node? @misty sigil

misty sigil
#

node? yes

tranquil drum
quartz kindle
#

process cpu is not an easy thing to obtain from node's internal tools

tranquil drum
#

oh you want process cpu

ancient lichen
#

do you know any api for spotify catch?

misty sigil
#

oh well ill stick with my ram

quartz kindle
#

node's internal tools will give you system time and user time at a specific point in time, you have to measure 2 points and compare system time and user time, and how much of each time was used

tranquil drum
#

@misty sigil you could spawn a top | grep and get process cpu that way

misty sigil
#

did someone say something similar to top gear

quartz kindle
#

lmao

tranquil drum
#

lol

#

something like top | grep node

cunning gorge
#

@amber fractal sorry for the ping mate just one thing

    await message.channel.send(embed).then(async message => {
          await db.set(`welcomeMessage_${message.guild.id}`, welcome);
    await func.embed(message.channel, `**Successfully set a welcome message!**`);
      
    }).catch((e) => {
      return message.channel.send(`Invalid URL!`)
    })

Is this a proper way of doing this? And I tried changing the then async message to then async randomblah it still works? So why do I need to specify message

amber fractal
#

if you're awaiting it, you can use try/catch, but if you're using .then you need to use .catch as well

#

you choose between them

cunning gorge
#

oh ok,

#

and whats the thing with message?

#

Why does it also work when i replace it with random

amber fractal
#

wdym

cunning gorge
#

Like

.then(async random => {});
quartz kindle
#

channel.send() returns a promise of the sent message

cunning gorge
#

like that

amber fractal
#

that's just a variable

cunning gorge
#

oh

#

so whats that for

quartz kindle
#

when you do .then(bla => {}) this bla is the message object that you just sent

amber fractal
#

like passing it to a function

sick cloud
#

so i fucked express that much if you try render a route it sends you an ocelot-stream.

cunning gorge
#

ohhh, so you could return it later on or something

sick cloud
#

uh

cunning gorge
#

Thanks steven! I understand

quartz kindle
#

ocelot stream? lmao

magic jackal
#

Hey tim is this the correct way to check in MS how long something took?

let before = new Date();
await reloadCommands(client)
let after = new Date();
let reloadTime = before - after;```
sick cloud
#

can someone try look at my renderer then ig?

quartz kindle
#

octet-stream is basically binary data, aka no mime type

tranquil drum
#

bro that's octet stream @sick cloud

quartz kindle
#

you need to set content-type to text/html or something

sick cloud
#

i'm using a custom ejs renderer so where

tranquil drum
#

octet = byte

amber fractal
#

like if you let x = await message.channel.send("x") x will be a message, same if you do message.channel.send("x").then(y => {//y would be the same message as x if you used this instead})

sick cloud
#
exports.engine = async function (filePath, options, callback) {
    const file = await fs.readFileSync(filePath);
    const defaultLayout = await fs.readFileSync(path.join(__dirname + '/../views/layouts/default.ejs'));

    const contents = ejs.renderFile(file, options);

    const data = {
        contents: Buffer.from(contents),
        layout: 'default'
    }
       
    const layouts = {
        default: {
            contents: Buffer.from(defaultLayout)
        }
    }

    const res = render(data, layouts);
    const rendered = res.contents.toString();

    console.log(rendered)

    return callback(null, rendered);
}
quartz kindle
#

set a content-type header in your express response

tranquil drum
#

text/html

sick cloud
#

ummmm

#

ok

#

so

#

res.header().render(...)?

quartz kindle
#

where does the callback return to?

sick cloud
#

the route

quartz kindle
#

and then the route sends it?

sick cloud
#
app.get('/', async (req, res) => {
    await res.render('index', { greeting: 'world' });
});
#

um express docs says the callback will auto send it

digital ibex
#

hi

sick cloud
tranquil drum
#

do it before the await

amber fractal
sick cloud
#

yes but i made a custom .render

#

to add layouts to ejs

digital ibex
#

i'm getting TypeError: OAuth2Strategy requires a verify callback for some reason. code: js const discordStrategy = require('./strategies/discordstrategy'); and the second function is a callback ```js
passport.use(new DiscordStrategy({
clientID: process.env.CLIENT_ID,
clientSecret: process.env.CLIENT_SECRET,
callbackURL: process.env.CLIENT_REDIRECT,
scope: ['identify', 'guilds']
}, (accessToken, refreshToken, profile, done) => {
console.log('e')
}));

quartz kindle
#

@sick cloud try this res.type("html").render()

#

it should be the default, idk if ejs is changing it somewhere

sick cloud
#

didn't change anything

#

still sending an octet

tranquil drum
#

set it with res.set('Content-Type', 'text/html');?

quartz kindle
#

wait are you sending html or json?

sick cloud
#

html?

sick cloud
#

i render the ejs content, then the layouts module just renders another ejs page with the original page's content jammed in

amber fractal
#

The first answer, it is for google, but oauth is basically all the same

sick cloud
#

as a layout

digital ibex
#

oo, thank u

sick cloud
quartz kindle
#

why is it using buffers tho

tranquil drum
#

try res.set('Content-Type', 'text/html'); @sick cloud

#

or try using dev tools and see what's actually being sent over the wire

sick cloud
#

i don't know but that's what the module wants

#

also no way to check dev as literally it sends the octet when you hit enter to /

nocturne dagger
#

Connot read property of find

#
exports.run = (Discord, clinet, message, args, config) => {
 if (!message.member.hasPermission("MANAGE_SERVER")) return  message.channel.send("**You do not have permission to run this. You need `MANAGE_SERVER` permission.**")
    let cat = args.join(" ")
    let category = message.guild.channels.cache.get(c => c.type === "category" && c.name === cat);
    if (!category) {
     message.channel.send("That category is not in the server. Please make sure you typed the exact catagory.")
     
    } else {

tranquil drum
#

open dev tools then press enter

sick cloud
#

no difference also with .set

#

that's what it does

amber fractal
#

Why did you pass a function to get? @nocturne dagger

tranquil drum
#

what are the headers? @sick cloud

nocturne dagger
#

what?

amber fractal
sick cloud
#

no idea Β―_(ツ)_/Β―

tranquil drum
#

you can check in headers tab

#

lol that's def not right

sick cloud
nocturne dagger
#

I asked how to get a category by name and that was what I was told

#

is that incorrect?

tranquil drum
#

response headers @sick cloud

#

not request headers

sick cloud
#

there's no response headers

tranquil drum
#

oh

amber fractal
#

use .find

tranquil drum
#

then it didn't send any

royal portal
#

is message.content.includes.toLowerCase("hi") possible?

nocturne dagger
#

I tried that

amber fractal
#

What was the exact error?

nocturne dagger
#

still exact same error cannot read property of find

sick cloud
#

@royal portal includes('hi'.toLowerCase())

#

and yes its sending no headers, idk

tranquil drum
#

did you set your render engine @sick cloud

sick cloud
#

yes

royal portal
#

makes the command incase sensitive?

sick cloud
#
    app.engine('ejs', exports.engine);

    app.set('views', path.join(__dirname + '/../views'));
    app.set('view engine', 'ejs');```
nocturne dagger
#

oh wait

#

TypeError: Cannot read property 'find' of undefined

tranquil drum
#

are you getting the correct html in console?

#

since you're logging it in the render function

sick cloud
#

nope nothing logs

#

it never gets to there

amber fractal
#

yeah, cache is undefined for whatever reason

#

what d.js version you on?

nocturne dagger
#

11.2.3

#

makes sence now

amber fractal
#

then it's just message.guild.channels.find(x)

earnest phoenix
#

Can someone explain to me how I add a bot in a server? Owo bc I'm dumb-

sick cloud
#

console.log(rendered)
so it never reaches this point of code

tranquil drum
#

weird

#

is there any error from express?

sick cloud
#

nope

earnest phoenix
#

I- no okay sorry for bothering yall o.O

quartz kindle
#

console.log after each block of code

#

see until where it goes

tranquil drum
sick cloud
#

yes

amber fractal
digital ibex
#

@amber fractal i'm getting the same error, but this time i'm doing: ```js
passport.use(new DiscordStrategy({
clientID: process.env.CLIENT_ID,
clientSecret: process.env.CLIENT_SECRET,
callbackURL: process.env.CLIENT_REDIRECT,
scope: ['identify', 'guilds']
}, function (accessToken, refreshToken, profile, cb) {
console.log(profile)
}));

sick cloud
#
const ejs = require('ejs');
const render = require('layouts');
const fs = require('fs');
const path = require('path');

const engine = async function (filePath, options, callback) {
    const file = await fs.readFileSync(filePath);
    const defaultLayout = await fs.readFileSync(path.join(__dirname + '/../views/layouts/default.ejs'));

    const contents = ejs.renderFile(file, options);

    const data = {
        contents: Buffer.from(contents),
        layout: 'default'
    }
       
    const layouts = {
        default: {
            contents: Buffer.from(defaultLayout)
        }
    }

    const res = render(data, layouts);
    const rendered = res.contents.toString();

    console.log(rendered)

    return callback(null, rendered);
}

module.exports = function (app) {
    app.engine('ejs', engine);

    app.set('views', path.join(__dirname + '/../views'));
    app.set('view engine', 'ejs');
}

then in the express server i do this: templateEngine(app) where app is the express server

#

sorry for wall of code lol

tranquil drum
#

@sick cloud it looks like you can just app.set('view engine', 'ejs'); without defining a custom one

nocturne dagger
#

Steven can you help me with something in DM's i dont want to flood the chat

sick cloud
#

i'm making a custom one for a reason

#

to use layouts

amber fractal
#

Sure, my dms should be open

tranquil drum
#

ahh

sick cloud
#

so yeah not that easy

#

just checked something, it doesn't even reach the fs readFileSync's in the engine

quartz kindle
#

so the entire function is not even being called

sick cloud
#

so yea somethings rly broken

tranquil drum
#

does it not like that it's async?

quartz kindle
#

you dont need async if you're using readFileSync lol

sick cloud
#

oh ok

tranquil drum
#

lol wait

#

that's probably why

sick cloud
#

removed async and stuff but it still sends an octet and no console.logs

tranquil drum
#

maybe try naming it something else since the default ejs also uses that name?

sick cloud
#

i tried a diff one, no luck

#

using ljs rn

tranquil drum
#

gotcha

sick cloud
#
// index.js
const ljs = require('./.src/templatingEngine');
const app = express();

//...
app.engine('ljs', ljs);

app.set('views', './views');
app.set('view engine', 'ljs');

app.get('/', async (req, res) => {
    res.set('Content-Type', 'text/html');
    return res.render('index', { greeting: 'world' });
});
// .src/templatingEngine.js
const engine = function (filePath, options, callback) {
    const file = fs.readFileSync(filePath);
    const defaultLayout = fs.readFileSync(path.join(__dirname + '/../views/layouts/default.ejs'));

    console.log(file)
    console.log(defaultLayout)

    const contents = ejs.renderFile(file, options);

    const data = {
        contents: Buffer.from(contents),
        layout: 'default'
    }
       
    const layouts = {
        default: {
            contents: Buffer.from(defaultLayout)
        }
    }

    const res = render(data, layouts);
    const rendered = res.contents.toString();

    console.log(rendered)

    return callback(null, rendered);
}

another code wall but that's exactly how it is right now

#

nothing else

earnest phoenix
#

How do you guys think this would place a space at the end of text?
args.join(" ").split("--dark").join(" --dark").split(" ").reverse().slice(1).reverse().join(" ").split(" --dark").join("--dark").split(" ").join("%20").........

sick cloud
#

so i'm super confused

tranquil drum
#

well you're not exporting the engine function @sick cloud

sick cloud
#

i am?

#

at the bottom

tranquil drum
#

o

sick cloud
#

module.exports = engine;

#

cut it out

amber fractal
#

@digital ibex try adding cb(null, user) after console.log(profile)

digital ibex
#

kk

tranquil drum
#

really weird that it's not even getting called

sick cloud
#

yeah

tranquil drum
#

what if you got rid of async in index for the / route

digital ibex
#

@amber fractal so like js passport.use(new DiscordStrategy({ clientID: process.env.CLIENT_ID, clientSecret: process.env.CLIENT_SECRET, callbackURL: process.env.CLIENT_REDIRECT, scope: ['identify', 'guilds'] }, function (accessToken, refreshToken, profile, cb) { console.log(profile) cb(null, profile) })); ?

amber fractal
#

mb

#

cb(null, profile)

tranquil drum
#

since it doesn't look like it needs it

digital ibex
#

kk

amber fractal
sick cloud
#

still nothing

digital ibex
#

i've already installed it

amber fractal
#

Ik

earnest phoenix
#

How when i eval this
args.join(" ").split("--dark").join(" --dark").split(" ").reverse().slice(1).reverse().join(" ").split(" --dark").join("--dark").split(" ").join("%20") there's no space at the end but in my supreme command... It places a space at the end for no reason

amber fractal
#

but in the docs it says to do that

#

so try to return cb(null, user) since you dont have it find errors anywhere

tranquil drum
#

@sick cloud also try not returning the result of res.render

sick cloud
#

still nothing, i've tried all those small weird things

#

alright dumb thing right here, seems my listener broke in the first place

tranquil drum
#

lol nice

sick cloud
#

however the layout logic is broken so

#

ignore the name but
app.engine('aaaa', function (filePath, options, callback) { logger.info(filePath)

that never logs still

#

but it is rendering now

#

ok cool, fixed it

#

express engines seem to be having issues so i'm just doing a func:

app.get('/', async (req, res) => {
    return res.send(await render('index', { greeting: 'world' }))
});
#

works well now

cunning gorge
#

For my VIP feature of my bot, how do I check if a user has a specific role in my support server, if so then they can run a command.

#

But I want this to work on any guild not just the support server

amber fractal
#

Get your support servers id, when they run the command, get the support server guild then check if they have a role on it.

cunning gorge
#

Ye thats what im trying to do, tho i can figure out the specific syntax

#

I did

  const partnerRole = client.guilds.cache.get("713260797891051540").roles.cache.get("714644627608698920").id
  console.log(partnerRole)
  if (message.author.roles.has(`${partnerRole}`)) {
#

tho thats wrong i think

forest mirage
#
const Discord = require("discord.js");
const client = new Discord.Client();
const embed = new Discord.RichEmbed()
.setTitle("Docs")
.setDescription("Please input a type!\n\n`.docs scripts`\n`.docs actions`\n`.docs mods`")

client.on("message", message => {
  if(message.content === ".docs") {
    message.channel.send(embed).catch(console.error);
  }
});```
v11.6.4 no errors in log
#

this is the simplest thing wtf

lyric mountain
#

V11 is deprecated, I'd update to v12 if I were you

forest mirage
#

As of October it will be unusable

#

But for now 🀷

#

But yes I am updating to v12

lyric mountain
#

Also, is v11 working with the new gateway system?

#

Because the old endpoint died a few months earlier

forest mirage
#

Ye

earnest phoenix
#

hmm

astral yoke
#

why do i get this

#
 1: 0xa2afd0 node::Abort() [node]
 2: 0x97a467 node::FatalError(char const*, char const*) [node]
 3: 0xb9d7aa v8::Utils::ReportApiFailure(char const*, char const*) [node]
 4: 0x7f5c941b2489 Require(v8::Local<v8::Object>, char const*) [/rbd/pnpm-volume/64a4d873-3972-4972-a7b7-61d54a6a4eed/node_modules/quick.eco/node_modules/better-sqlite3/build/Release/better_sqlite3.node]
 5: 0x7f5c941b28ee Integer::Init(v8::Isolate*, v8::Local<v8::Object>, v8::Local<v8::Object>) [/rbd/pnpm-volume/64a4d873-3972-4972-a7b7-61d54a6a4eed/node_modules/quick.eco/node_modules/better-sqlite3/build/Release/better_sqlite3.node]
 6: 0x7f5c941bb077 RegisterModule(v8::Local<v8::Object>, v8::Local<v8::Object>) [/rbd/pnpm-volume/64a4d873-3972-4972-a7b7-61d54a6a4eed/node_modules/quick.eco/node_modules/better-sqlite3/build/Release/better_sqlite3.node]
 7: 0xa025c9  [node]
 8: 0xa016bb node::binding::DLOpen(v8::FunctionCallbackInfo<v8::Value> const&) [node]
 9: 0xc06bab  [node]
10: 0xc08156  [node]
11: 0xc087d6 v8::internal::Builtin_HandleApiCall(int, unsigned long*, v8::internal::Isolate*) [node]
12: 0x13a9f19  [node]
/opt/watcher/app-types/node/start.sh: line 51:  3149 Aborted                 (core dumped) node src/index.js```
#

when trying to switch to v12

valid frigate
#

well given that you're using sqlite

cunning gorge
#

is there anyone, familiar with Glitch, Visual Studio Code, and Github, who is willing to teach me how to bring my glitch project into VSC so that I can upload it into a VPS. If so, your help is greatl appeciated, and pls ping me πŸ™‚

misty sigil
#

developing question of 3am

#

How do I make a bot send a message to a specific channel when my bot gets added.

#

pls ping me

sick cloud
#

@misty sigil depends whether you know the channel or not

misty sigil
#

i know the channel

#

its in my server

sick cloud
#

what lib

misty sigil
#

discord.js

sick cloud
#

client/bot.on

use the guildCreate event, it gives the guild it joined as the arg

#

so just fetch the channel and send to it

#
client.on('guildCreate', (guild) => {
  // v11
  const channel = client.channels.get(id);

  // v12
  const channel = client.channels.cache.get(id);

  // finally
  if (!channel) return;
  channel.send(`Joined ${guild.name}`);
});```
misty sigil
#

i shall inspect this

#

and ofc add my colour randomizer to it

#

like i ALWAYS do

atomic quarry
#

Ok, so now I have a problem

#

/home/runner/ZWrlds-Moderation-BotBeta/commands/ban.js:9
return await msg.channel.createMessage('You need to specify a user')
^^^^^

SyntaxError: await is only valid in async function

#

I don't know how I'm supposed to make that work

misty sigil
#

remove await?

#

idk

#

make it an async function

hexed storm
#

I'm looking to stop my bot from replying to other bots but I can't find much. Library is Eris if anyone can help

atomic quarry
#

hmm

misty sigil
#

here in discord.js its if(<message>.author.bot)return;

atomic quarry
#

@misty sigil I don't think I remember how to make it an async function

misty sigil
#

idk either lol

#

you could try removing await?

atomic quarry
#

No, I can't

sudden geyser
atomic quarry
#
const discord = require("discord.js");
const commands = require(".");
const info = require("../info.json");

const command = "ban";

 if (command === 'ban') {
      if (mentioned === false)
        return await msg.channel.createMessage('You need to specify a user')
      if (checkForMod(msg.channel.guild.members.get(mentioned.id)))
        return await msg.channel.createMessage('I cannot ban that user')
      let reason = msg.content.split(' ').slice(2).join(' ').length === 0 ? 'Unspecified' : msg.content.split(' ').slice(2).join(' ')
      try {
        let dm = await bot.getDMChannel(mentioned.id)
        await bot.createMessage(dm.id, `You have been **banned** by **${nickName}** for ${reason}`)
        let embed = createEmbedFields(null, mentioned, [{ name: 'User banned', value: `<@!${mentioned.id}> has been banned by ${nickName}` }, { name: 'Reason', value: reason }], 'Banhammer', true)
        await bot.banGuildMember(msg.channel.guild.id, mentioned.id, 7, `Banned by ${msg.author.id} | Reason: ${reason}`)
        await msg.channel.createMessage({ embed })
      } catch (e) { await msg.channel.createMessage('That user cannot be banned'); console.log(e) }
      await bot.emit('command', msg, command, mentioned)
    }
sudden geyser
#

What is require(".") supposed to do? What file is this? Where are you getting the msg object from?

atomic quarry
#

Well it's suppose to be a command that bans a person

sudden geyser
#

Okay, but do you know what you're doing with all those variables all around the place? Did you define them somewhere?

atomic quarry
#

I'm got that part of the code from a github repo I'm pretty sure

misty sigil
#

shouldn't you write your own code

atomic quarry
#

As long as you give credit to the original owner your ok

grand dagger
#

As long as u understand the code

misty sigil
#

^

#

you have to understand it

sudden geyser
#

If you don't have a good knowledge on the code or the programming language you're using, you should try learning it before attempting to make a Discord bot.

#

Like why you're using Eris properties yet require Discord.js at the top of the file.

earnest phoenix
#

message.guild.channels.create(${user.username}, {
is creating `{ TypeError [INVALID_TYPE]: Supplied parameter is not an User nor a Role.`` i dont understanf

#

ping me if u know

turbid bough
#

Uh. I cant see the second parameter

#

I can only see the first

earnest phoenix
#

watching undefined servers

steel drum
#

@earnest phoenix try js bot.guild.cache.size

radiant estuary
#

How can I get the Name, who used discord OAuth2?

earnest phoenix
#

instead of?

#

@earnest phoenix try js bot.guild.cache.size

turbid bough
#

Imagine saying that he should downgrade to v11 cause it does not work on v12

earnest phoenix
#

rip

coral stirrup
#

lol

turbid bough
#

@earnest phoenix bot.guilds.cache.size instead of bot.guilds.size

earnest phoenix
#

wait a min to try

#

like that?

feral peak
#

like that?
@earnest phoenix yes

#

that is correct for v12

golden condor
#

I know it a little bit yes

wide ridge
#

oooh

#

disabledEvents?

golden condor
#

Yeah that's client options

#

Put in there

#

ws: {
intents: [] //array of intents
}

wide ridge
#

ah

#

what is the ipcSocket 9997? @golden condor

#

and cluster count is always 1 right?

#

cause you only need to spawn 1 cluster

golden condor
#

Just depends on how many you need

wide ridge
#

sometimes my bot runs into api rate limits

#

could that help with it?

golden condor
#

No that's a discord thing

earnest phoenix
#

who know why i cant to connect heroku with github? when i try to connect the site say this message

#

Couldn't connect to GitHub
Error: remote was closed, authorization was denied, or an authentication message otherwise not received before the window closed.

wide ridge
#

did you connect to github properly?

#

correct username/password?

golden condor
#

Sure thats fine

earnest phoenix
#

idk,first try when i tried to connect i saw a new tab

#

i click connect and showed this error

golden condor
#

Did you authorise it?

earnest phoenix
#

yea

golden condor
#

Huh

#

That's weird

#

Try doing it again

#

It might have been an error on either end

earnest phoenix
#

i tried

#

same message

golden condor
#

Hmmm

#

Try contacting support

earnest phoenix
#

ok

#

general platform features

golden condor
#

I'm not sure

loud nebula
#

Hi

earnest phoenix
#

now worked

#

huhuhhh

#

i spammed

#

lol

loud nebula
#

huh? I dont need to verify my phone! YES

#

@earnest phoenix

#

Is my bot

#

and embed+ to

earnest phoenix
#

i dont speak engrish

#

why when i deploy branch i saw this error?

golden condor
#

You need to tell it what node version to use

earnest phoenix
#

i just installed now 14.4.0

ripe epoch
#

how do you do a permission check on a on_message event?

#

ive tried it but cant get it to work

earnest phoenix
#

how to reinstall package-lock.json and package.json?

cinder patio
#

if your package.json has been deleted, you can do npm init or npm init -y

earnest phoenix
#

on cmd?

cinder patio
#

to restore package-lock.json you have to do npm i afaik

#

ye

earnest phoenix
#

npm init and npm init -y

cinder patio
#

one of the two

earnest phoenix
#

to reinstall

#

ok

#

i want to reinstall package json

#

because i ve had problems with heroku

cinder patio
#

by reinstall you mean create, right?

earnest phoenix
#

yea

#

to delete old

cinder patio
#

I don't think npm init replaces your old

#

you'll have to delete it yourself

earnest phoenix
#

yea

#

@cinder patio package.json only?

#

and package.lock.json?

#

npm i

#

ok

earnest phoenix
#

How i can vertify my Heroku acc without Credit card : /

#

:))

pale vessel
#

get your dad's

earnest phoenix
#

:))

unique nimbus
#

bruh

earnest phoenix
#

but . . . . nvm

unique nimbus
#

Since when does Heroku require credit card

earnest phoenix
#

wait there is Credit generator xD

pale vessel
#

wouldn't work

unique nimbus
#

nope

earnest phoenix
#

ik

pale vessel
#

if you verify, you'll get extra hours that can get your bot up 24/7

earnest phoenix
#

yes

pale vessel
#

not really 24/7 but ye

earnest phoenix
#

cuz the free hours is only for 28 days

pale vessel
#

because it restarts every 24 hours

earnest phoenix
#

wut

#

rly

tight plinth
#

yes

earnest phoenix
#

so i dont need uptime anymore :((

#

i want to make my bot has 30 days uptime

pale vessel
#

you won't notice it though

earnest phoenix
#

:((

pale vessel
#

it restarts fast

earnest phoenix
#

:((

#

@pale vessel are u using Heroku πŸ€”

pale vessel
#

no

earnest phoenix
#

wrong emoji : /

golden condor
#

How can I use .pipe() for ffmpeg filters (in music)

earnest phoenix
#

ahm i dont have music bot so . . . nvm

#

can't help ya

#

if you don't know how to help then dont respond lol?

grand dagger
#

I can’t help you sorry man

earnest phoenix
#

@golden condor uh pipes are indefinite of filters

golden condor
#

Well they can be used for filters I think

earnest phoenix
#

what

#

do you know what is a pipe

golden condor
#

Yeah there is a bot that uses pipe with ffmpeg for filtrs

earnest phoenix
#

do you know what is a pipe

golden condor
#

Not quite

earnest phoenix
#

it's a way to transport data in a stream, there are 3 default pipes in ffmpeg

pipe 0 is std in
pipe 1 is std out
pipe 2 is std err

golden condor
#

Ok

earnest phoenix
#

there's also named pipes which are pipes on a system level and IPC works mostly via named pipes

#

pipes are irrelevant to filters

#

they're just a direction to transfer data

golden condor
#

Oh

earnest phoenix
#

you can apply a filter regardless whether you're using pipes or not

golden condor
#

So is there no way to use filters with ffmpeg?

pure lion
#

h o w t o s e n d d m ?

earnest phoenix
#

i-

#

@pure lion by sending the dm

golden condor
#

you can apply a filter regardless whether you're using pipes or not
Sorry didn't read this

pure lion
#

@pure lion by sending the dm
@earnest phoenix via bot lmao

earnest phoenix
#

send the dm via the bot

pure lion
#

say i wanted to rickroll someone-

pale vessel
#

you're a little late on that

earnest phoenix
#

i unfortunately broke my magic crystal ball during quarantine and I can't read your mind to know which lib you're using 😞

pure lion
#

discodrd.js

#

i can spell!1

pale vessel
pure lion
#

h

golden condor
#

Lmao

earnest phoenix
#

send method on the user

pale vessel
pure lion
#

uh

earnest phoenix
#

sending the dm is a 50/50 chance it will succeed since they need to have their dms enabled

pale vessel
pure lion
#

c:

golden condor
#

So is there anyway to use filters with ffmpeg then (with a discord.js stream music)

earnest phoenix
#

just pass the filter arguments to ffmpeg

strong tundra
#

what is an arc?

pure lion
#

a line

#

that curves

golden condor
#

just pass the filter arguments to ffmpeg
How

pure lion
#

like a parabola

strong tundra
#

oh i found it

#

seems cool

earnest phoenix
#

by... passing the arguments

#

you're probably looking for filter_complex

golden condor
#

Do I do that in discordjs or in ffmpeg?

pale vessel
#

ffmpeg you mong

#

sorry

earnest phoenix
#

@pure lion message.author.send("hi this dm")

golden condor
#

:c

#

So how would I alter an existing stream

#

Or send filters to a stream I mean

earnest phoenix
#

now that's where pipes come in

#

take input from pipe:0 and output it at pipe:1

golden condor
#

Do I do it in cli or in code?

#

Can you give an example?

earnest phoenix
#

in ffmpeg you need to tell it to take input from pipe:0 and send the output through pipe:1

in code you need to send your stream data to ffmpeg's stdin and read ffmpeg's stdout

#

no i cannot

pure lion
#

@pure lion message.author.send("hi this dm")
but i want to dm a mentioned user

pale vessel
#

then check for any mentioned users

pure lion
#

ok esdjghioshdgosuihfwsd

#

brb

pale vessel
#

lmao

golden condor
#

So how would I send a pipe to a stream that discord.js has started I'm a bit confused

earnest phoenix
#

you don't send a pipe

#

haven't we already established that a pipe is just a direction

#
let user = message.mentions.members.first()
user.send("This is DM")
golden condor
#

I am using wrong terminology sorry

pale vessel
#

yes

earnest phoenix
#

@pure lion

#

i wouldn't know how to do it in node because node is an absolute disaster to work with

golden condor
#

o

pure lion
#

ty

earnest phoenix
#

but you need to read the stream from d.js and send the data you read to ffmpeg's stdin

#

i know how to do it in java cpp and c# just not node because i hate working with trashy environments

#

i want to make this channel to be the SEC STACKOVERFLOW

pure lion
#

i agree

mossy vine
#

node is pretty garbage when you gotta do anything close to low level shit

earnest phoenix
#

@mossy vine 😑

mossy vine
#

eh?

earnest phoenix
#

u said NodeJS is garbage

pure lion
#

:oo

mossy vine
#

no

#

i said one aspect of node is garbage

golden condor
#

I'm confused a lot

earnest phoenix
#

me 2

sick cloud
mossy vine
#

thank you tony

earnest phoenix
#

tony ??

mossy vine
#

nah ok this guy is trolling im out

earnest phoenix
#

wut ?

sick cloud
#

lmao

golden condor
#

I'm confused by this

#

I found a package that I think helps

earnest phoenix
sick cloud
#

stop trolling man

earnest phoenix
#

: /

#

i am confusing

#

they're not trolling they're genuinely lost lol

#

lol

golden condor
#

I really am very confused by this, maybe I could do it via cli (exec)

earnest phoenix
#

that's how i do it

#

start ffmpeg

#

send data