#development

1 messages · Page 1454 of 1

opal plank
#

yes

crimson vapor
#

alr

mellow kelp
#

a sub-class probably

#

yea

crimson vapor
#

why are you extending a class smh

opal plank
#

cuz sanity?

crimson vapor
#

I mean what are you doing that requires you to have ~30 extentions?

south sinew
#

some of my classes are nice and neat and beautiful and make sense, however about 70% is crackhead energy level stuff

opal plank
#

a full on API wrapper?

crimson vapor
#

oh

#

I see now

south sinew
#

thatll do it

mellow kelp
#

are classes in typescript better?

#

like which one would you rather use:

crimson vapor
#

in ts can you make multiple constructors with different inputs like you can in java?

mellow kelp
#
class MyCommand extends Command {
  public constructor() {
    super('meme', 'Sends a dank meme');
  }

  public async execute(event: CommandEvent) {
    // Stuff
  }
}

or:

const myCommand: Command = {
  name: 'meme',
  description: 'Sends a dank meme',
  async execute(event) {
    // Stuff
  }
}
#

like idk if one has something better over the other

crimson vapor
#

I would do classes since you can configure more as you go

mellow kelp
#

yea makes sense

crimson vapor
#

say you want it to be a ToggleCommand type you can just set requiredPerms and toggle and it will work

#

instead of duplicating code

#

wait thats ts?

mellow kelp
#

yeah

crimson vapor
#

o

mellow kelp
#

o

crimson vapor
#

I made a smol ts project

mellow kelp
#

cool

#

whats it about

crimson vapor
#

just to understand syntax I built a url shortener

mellow kelp
#

pog

#

i should try that out

#

i think google has an api for that right?

crimson vapor
#

idk

#

what would you need the api for?

mellow kelp
#

for shortening urls i guess

#

i think i read google had a url shortener service or something

crimson vapor
#

I mean im taking a url and returning http(s)://<link>/U<ID>

#

and saving it in a DB

mellow kelp
#

ohh aight

#

so then you redirect requests from your own api?

crimson vapor
#

not quite sure what you mean but thats because im tired and can't think straight

mellow kelp
#

ah yes

#

programmer syndrome

crimson vapor
#

there are 2 methods
post: /url
get: /U:id

#

/url saves the link in the DB with a corresponding ID

#

/U:id checks the DB for params.id and redirects

mellow kelp
#

yea thats more or less what i meant

#

sounds pretty cool

crimson vapor
#

ok

#

took like 10 minutes to write

#

but I kinda just wrote js

#

only thing different was import not require()

mellow kelp
#

well most small scale typescript looks like actual js lmao

crimson vapor
#

alright

mellow kelp
#

typescript shines when scaled

#

then you don't have to worry about your coworker storing phone numbers as an int and getting errors when operating on em

#

well nevermind who does that

crimson vapor
#

[000, 000, 0000]

#

best of both worlds

mellow kelp
#

indeed

crimson vapor
#

anyway

#

I need to understand this tsconfig before I upload to github

#

not gonna post code I don't understand

mellow kelp
#

oh that thing

#

it's kinda simple

#

what's your tsconfig?

crimson vapor
#

idk lemme go turn on my pc

mellow kelp
#

ight

crimson vapor
#

I also have a question for you

mellow kelp
#

wut

crimson vapor
#

I have a file, lets cal it placeholder and I want it in the output directory, how can I tell ts to place it there

mellow kelp
#

if it ain't a ts or json file the compiler won't do it

#

sucks

crimson vapor
#

hmm

#

what about json files

mellow kelp
#

you can import them from typescript

#

and add resolveJsonModule to your tsconfig

crimson vapor
#

but I have to import them for it to work?

mellow kelp
#

yea

crimson vapor
#

it won't just realize I want a file

mellow kelp
#

well technically yes

#

but ts doesn't know how to compile an html file or an image, for example

#

so you'll probably get an error if you import other files

crimson vapor
#

so how would you add an image to the output directory?

#

to be used

mellow kelp
#

well in short, you can't freerealestate

crimson vapor
#

hmm

mellow kelp
#

i just put other files on an assets folder or something

#

to read them with fs

crimson vapor
#
{
  "compilerOptions": {
    "module": "commonjs",
    "esModuleInterop": true,
    "target": "es6",
    "noImplicitAny": true,
    "moduleResolution": "node",
    "sourceMap": true,
    "outDir": "dist",
    "baseUrl": ".",
    "resolveJsonModule": true,
    "paths": {
      "*": ["node_modules/*"],
    }
  },
  "include": ["src/**/*"]
}
``` is current but idk what most of it means
#

ik resolveJsonModule

#

thats it

mellow kelp
#

aight

#

so

#

module indicates the target module (bruh)

#

idk that much about it

#

but most of the time i leave it at commonjs

crimson vapor
#

alright

mellow kelp
#

esModuleInterop makes ts compatible with ES modules

#

Something about module.exports and that stuff

crimson vapor
#

so that would be required to use packages built for js?

mellow kelp
#

So most likely you always need it to use npm libraries

crimson vapor
#

ok that makes sense

mellow kelp
#

ight

#

target is the compile EcmaScript version

#

So stuff like promises will be sort of "pollyfilled" for compiling to versions like es3, for example

crimson vapor
#

so its recommended to use es6?

#

or another different one

mellow kelp
#

hmm

#

i guess if you're running node it doesn't really matter that much, since its up to date with ecmascript for the most part

#

but just in case i put es5

crimson vapor
#

ok

mellow kelp
#

ight next one

#

That one is something about function params i think

#

maybe it applies to other stuff

#

basically forces you to add types to your function params

#

so i always have it on

crimson vapor
#

ok that makes sense

mellow kelp
#

i'm not really sure about moduleResolution

#

But I think it's needed for some options

crimson vapor
#

and sourceMap?

mellow kelp
#

that one makes the compiler emit sourcemaps to the output

#

which track errors from the compiled code to your ts

#

i think they're mostly used for debugging and finding errors quicker

crimson vapor
#

oh so good for testing

mellow kelp
#

yea

crimson vapor
#

and is it unnecessary for prod?

mellow kelp
#

hmm maybe

#

dunno about that tho

crimson vapor
#

o

mellow kelp
#

well outDir is pretty self explanatory

crimson vapor
#

yea

#

I was gonna say that but couldn't think of the word

#

what is the standard outDir?

#

out?

mellow kelp
#

i think by default ts compiles each script next to its original file

#

so i don't really recommend leaving it blank

crimson vapor
#

what do you use for your projects?

mellow kelp
#

mostly dist/

#

or lib/ for npm packages

crimson vapor
#

ok

#

alright makes sense

mellow kelp
#

ight

#

baseUrl is the base for the paths option

#

resolveJsonModule lets you import json files

#

and paths act as sort of "alliases" for importing stuff

crimson vapor
mellow kelp
#

yea im on it

#

so

#

you could add this for example:

#
{
  "paths": {
    "commands": "./src/some/folder/commands/*"
  }
}
#

So now you can do

#
import PoggersCommand from 'commands/PoggersCommand';
crimson vapor
#

o

mellow kelp
#

so thats also what baseurl is for

crimson vapor
#

do you normally use "*": ["node_modules/*"], in paths?

mellow kelp
#

nah

crimson vapor
#

ok

summer torrent
mellow kelp
#

indeed

crimson vapor
#

loggers

mellow kelp
#

e p i c j o k e

#

im gonna name logger functions like that from now on

wicked sapphire
#

pogger logger

crimson vapor
#

loggers

mellow kelp
#

loggers

mellow kelp
#

LMFAO

mellow kelp
crimson vapor
#

yep

#

typings confused the living hell out of me

mellow kelp
#

dang

#

well typescript can also make em for you

#

poggers isnt it

crimson vapor
#

ye

#

ok now onto the last one I think

#

include

mellow kelp
#

hmm

#

oh yea

#

um

#

i think that one makes typescript compile the stuff in that folder and thats it

crimson vapor
#

ok

#

well

earnest phoenix
crimson vapor
#
{
  "compilerOptions": {
    "module": "commonjs",
    "esModuleInterop": true,
    "noImplicitAny": true,
    "sourceMap": true,
    "outDir": "dist",
    "baseUrl": ".",
    "resolveJsonModule": true,
  },
  "include": ["src/**/*"]
}
``` new and improved
mellow kelp
#

Fixed a bug

#

Fixed a bug

earnest phoenix
#

XDDDDDD

mellow kelp
#

Fixed a bug

crimson vapor
#

added bug whoops is my favorite tbh

mellow kelp
#

lmao yes

crimson vapor
#

so well now I have big brain question

#

I wrote this code with a json db

mellow kelp
crimson vapor
#

cuz fuck people

#

y'know

#

anyway

#

json no want to save reeeee

mellow kelp
#

darn

crimson vapor
#

so I kinda just like

mellow kelp
#

smashes keyboard

crimson vapor
#

dw about .jason

mellow kelp
#

ah yes

#

my favorite extension

#

jason

crimson vapor
#

so now the question is

#

do I add function where if the file doesn't exist it makes it

#

or

#

not

mellow kelp
#

you can check fs.existsSync('loggers.json')

earnest phoenix
crimson vapor
#

I already check if it exists

#

but atm I throw

mellow kelp
#

"who tf told you that you should be here, test file"

mellow kelp
crimson vapor
#

lemme ss code

south sinew
#

I have a streak of 22 commits that all read "why isn't this working" in a repo

south sinew
#

The last one is "holy fuck"

earnest phoenix
mellow kelp
earnest phoenix
#

Mood

crimson vapor
#

no it works

mellow kelp
#

oh k

#

so wut

crimson vapor
#

but I might make it so it just writes the file instead of erroring

#

so if you are using ts you don't have to deal with fucky wucky code

mellow kelp
#

fs.writeFileSync('pogchamp.txt', 'yo whats up')

crimson vapor
#

exactly

#

if(this.saveFile) fs.writeFileSync()

mellow kelp
#

yea

crimson vapor
mellow kelp
#

First thing i see:

#

DO NOT USE THIS IT WAS MADE AS A JOKE

crimson vapor
#

dw

#

no corruptions™️

mellow kelp
#

"This package stores JSON data which is prone to potential corruption and data loss."

crimson vapor
#

no testing™️

mellow kelp
#

best data storage system ever

#

gonna use it on all my projects

crimson vapor
#

lol

#

anyway time to pr that code

mellow kelp
#

yo

#

Is this a communist initiative

earnest phoenix
#

Ourcord start with js yes?

crimson vapor
#

wdym

#

ourcord is great

mellow kelp
#

soviet anthem plays

crimson vapor
#

I don't remember forking it tho

#

LOL nice issue

mellow kelp
#

indeed

#

i consider it a very urgent matter

earnest phoenix
#

No

#

Ourcord first start with js?

#

Then turn into ts?

mellow kelp
#

hmm maybe

crimson vapor
#

I don't think so

mellow kelp
#

bruh i hate having to manually install types for 50% of my packages

#

packages that include typings with them have my respect

somber wigeon
#

you speak spanish right @mellow kelp

crimson vapor
#

do not worry I include typings

mellow kelp
mellow kelp
crimson vapor
#

ok

#

I finished my pr

#

shit should work now

#

but im off of my pc :sad:

mellow kelp
crimson vapor
#

lol

#

im like 50% sure I used valid js

mellow kelp
#

hmm

hollow sedge
#

Yo million

crimson vapor
#

lemme test rq

hollow sedge
#

Update your readme

crimson vapor
#

why?

#

whats wrong?

hollow sedge
#

Options

crimson vapor
#

o

#

wanna pr?

hollow sedge
#

Lol sure

#

I'm that guy who gets added as a contributor for fixing the readme ig

mellow kelp
#

imma pr too

#

im gonna make a great contribution

#

perhaps the greatest contribution github has ever seen

hollow sedge
#

oh no

crimson vapor
#

shit

#

fuck

#

not valid js

#

I repeat not valid js

mellow kelp
#

aight pr done

hollow sedge
#

million what exactly does that do

#

the writeFile option

crimson vapor
#

check my last commit

hollow sedge
#

i see it

mellow kelp
#

im gonna be that guy to get onto the contributors section for adding the license

hollow sedge
#

could you just explain it a bit

#

LOL

crimson vapor
#

basically

#

if writeFIle: true, write the file
else error

#

now on ts you can just cd into /dist/ and add writeFile as true

#

ez pz

hollow sedge
#

i dont understand, why would you ever pass in writeFile: false now

crimson vapor
#

no more fucky wucky code

mellow kelp
#

hmm

hollow sedge
#

million

#

why would someone write writeFile: false

crimson vapor
#

umm

#

idk

#

but its an option now

hollow sedge
#

LOL

#

ok

mellow kelp
#

you should make a "philosophy" section on the readme

crimson vapor
#

why?

mellow kelp
#

"Keep everything as configurable as possible, even though only 5% of people will configure it"

crimson vapor
#

lol

mellow kelp
#

That way you can throw away pull requests and issues saying that they don't apply to you philosophy

#

Cough Cought CREATE REACT APP cough cough

crimson vapor
#

still waiting for a schema wrapper

mellow kelp
crimson vapor
mellow kelp
#

"This is a placeholder"

hollow sedge
#

the default is false, correct?

crimson vapor
#

yes

#

actually

#

ik why

earnest phoenix
#

it's so much bloat

mellow kelp
#

well

#

its useful for learning react

crimson vapor
#

because who the fuck wants a random file somewhere in some random dir

#

say you mess up directories

#

no big deal just error

earnest phoenix
#

there are far better resources for learning react other than CRA

mellow kelp
#

hmm maybe

crimson vapor
#

realistically the file should already be saved

mellow kelp
#

i ain't using it anymore anyways lmao

mellow kelp
crimson vapor
#

unless you are using ts

#

then you can either do some weird shit with import or just use my new feature

mellow kelp
#

ah yes

#
/**
   * Read the Collection
   * @returns {object}
   */
  _read() {
    return this.options.caching ? this._data ? this._data : (this._db._read())[this.name] : (this._db._read())[this.name];
  }
#

the ternary operator

crimson vapor
#

that hurts my brain to read

#

I must have just woken up when I wrote that

small prairie
#

any way to find out who "Initiated" a reaction?

crimson vapor
#

reaction.member or something

#

maybe .user

hollow sedge
#

why would you write that

crimson vapor
#

.author

hollow sedge
#

whats wrong with you

crimson vapor
#

wdym

small prairie
#

there is a reaction.users manager lol thats it

vague sky
small prairie
#

aw

#

i need this

mellow kelp
#

poggers theres and emoji for that here

#

wait

vague sky
#

Nitro vs gif

mellow kelp
#

nevermind

#

dang it

crimson vapor
#

if caching if data return data
else return read
else return read

#

best understood like that

#

anyway I have got to go

mellow kelp
#

confused confusing confusion

hollow sedge
#

it should probably be written like that lol

crimson vapor
#

maybe you could make a poggers schema wrapper

#

thats what I really want

#

gn

hollow sedge
#

gn

#

wait

#

accept my PR first

mellow kelp
#

lmfao

hollow sedge
#

noooooooooooooooooooooooooooooooo

#

thats it

#

im stealing jason.db

#

nvm

#

you HAD to add a license

#

nvm

#

its MIT

mellow kelp
#

steals code

#

Im gonna make a PoggersCollection

hollow sedge
#

i like how you kept your fork even though you only added a LICENSE

mellow kelp
#

lmao

#

cuz i wanna make my poggerscollection class

#

It stores that in a poggers format

#

With a .poggers extension

hollow sedge
#

uh

#

ok

mellow kelp
#

trust me its gonna be epic

#

(not that its gonna be useful)

lucid prawn
#
 if (message.content.startsWith(prefix + "slap")) {
      return message.channel.send("Please mention someone");
     var embed = new Discord.MessageEmbed()
      .setDescription(message.author.username + ' slapped ' + message.mentions.users.first().username)

      .setTimestamp()
      .setImage('https://media1.tenor.com/images/af36628688f5f50f297c5e4bce61a35c/tenor.gif?itemid=17314633')
     message.channel.send(embed);
  }```
it will not send the embed
opal plank
#

@lucid prawn dont use vars, avoid using embed builders

lucid prawn
#

ok

storm dove
#

ye

opal plank
#

also mentions.users might not exist

#

check it before sending

#

also that image url doesnt look like it'll load

#

im fairly certain it needs to be a .extension ending

mellow kelp
#

well it probably does

earnest phoenix
#

@opal plank why avod embed builder

storm dove
#

python?

mellow kelp
#

i also used some query params for tenor

opal plank
lucid prawn
opal plank
#

what

mellow kelp
#

why tho?

#

well maybe an object might be more readable

earnest phoenix
#

Its only 100msss

opal plank
#

you can send it directly

#

wdym only 100ms

#

its legit 20x slower

#

it went from 13ms to 263

lucid prawn
opal plank
#

well yeah, but if you remove it only it wont send the embed

#

pass the object directly onto channel.send(object here)

earnest phoenix
#

return statement

opal plank
#

im still fairly certain that image url is borked or the mentions.user is error'ing

opal plank
earnest phoenix
#

@opal plank return statement

#

See?

#

There is no any trigger for thst return

#

It will always return

opal plank
#

yeah also that

earnest phoenix
#

Yup

lucid prawn
earnest phoenix
#

I was about to say that

opal plank
#

hayper and barnie esxplained

earnest phoenix
#

Please learn js before you make a bot angeryBOYE

#

You must add any trigger for that return

opal plank
#

how does your IDE not shadow the rest of the code?

mellow kelp
#

like

earnest phoenix
#

Notepadd++ ide for sure

#

like if (!user) return message.channel.send("Please mention someone");

mellow kelp
#
if (someConditionNotToSendMessage) {
  return message.channel.send('bruh thats cringe')
}
earnest phoenix
#

actually

mellow kelp
#

if not its always gonna return

earnest phoenix
#

message mention

earnest phoenix
#

Also no need for bracket, can convert it to one line.@ElCholoGamer#3291

mellow kelp
#

yea

earnest phoenix
#

No

mellow kelp
earnest phoenix
#

That's an example, you must define the user's mention

#

Alright we got person expect spoonfeed

mellow kelp
#

more or less

lucid prawn
earnest phoenix
storm dove
#

can anyone help me in getting this kinda page ?
i dk anything bout html/css

mellow kelp
#

oh thats markdown

#

there's this handy cheatsheet

lucid prawn
earnest phoenix
#

Uh

mellow kelp
#

oh ik why

earnest phoenix
#

Send SS

mellow kelp
#

probably

earnest phoenix
#

probably what?

mellow kelp
#

why it doesnt work

storm dove
earnest phoenix
#

Ok so

mellow kelp
earnest phoenix
#

Tell us

mellow kelp
#

its message.mentions.users.first()

earnest phoenix
#

Ya

#

And...?

#

Wair

#

Wut

mellow kelp
#

like

earnest phoenix
#

No

mellow kelp
#

u said message.members.mentions

#

or something

earnest phoenix
#

It should be message.member.mentions.first();

opal plank
#

message.mentions

earnest phoenix
#

There is something else that doesn't let the code run

opal plank
#

not the other way around

mellow kelp
earnest phoenix
#

Oh

opal plank
#

mentions is part of emssage payload

mellow kelp
#

wait i just realized

earnest phoenix
#

Oh

#

My error

#

Sorry

mellow kelp
#

you speak spanish

earnest phoenix
#

Sí we

mellow kelp
#

Awebo

earnest phoenix
#

Hablemos en inglés q luego nos regañan bn culero

mellow kelp
#

a si

#

aight we back

earnest phoenix
#

Ok so

#

That was my error

#

Sorry

#

Xd

#

@lucid prawn try this:

#

let user = message.mentions.member.first();

#

Or msg

#

Idk how did you define the message

mellow kelp
#

yea that

earnest phoenix
#

I usually use message

#

althought i never use the await i always make my commands as an async function

mellow kelp
#

lmao

#

i just kinda use await for meme commands

earnest phoenix
#

like client.on('message', async message => { Some code });

#

Today i tried to use guild.displayAvatarURL();

#

Lmao

#

That was an epic error

#

"guild.displayAvatarURL is not a function"

#

Lol

lucid prawn
earnest phoenix
#

Wait

#

Why nullM

#

just use if (!User) {

#

And pay attentios for cases

#

JavaScript is case sensitive

#

Attention*

#

Lmao

lucid prawn
# earnest phoenix Wait

i fix it
look

 if (message.content.startsWith(prefix + "slap")) {
       if (User == null) {
      return message.channel.send(`You did not mention a user!`);
      }else{
    var embed = new Discord.MessageEmbed()
      .setDescription(message.author.username + ' slapped ' + message.mentions.users.first().username)

      .setTimestamp()
      .setImage('https://media1.tenor.com/images/af36628688f5f50f297c5e4bce61a35c/tenor.gif?itemid=17314633')
    message.channel.send(embed);
       }
  }
earnest phoenix
#

What did i say about that null?

#

And the user var must be defined at the same if

#

Why var

#

And not const

#

The same thing on this case

#

var, let , const

#

Nope

#

They are not the same

#

It gonna be a local var, it's not neccesary to use const

#

I believe

#

🤔

earnest phoenix
#

Its better practice to use const lol

#

Is your choice @lucid prawn

#

Now what did i say about that null

lucid prawn
#

i will fix the null part

earnest phoenix
#

It's better to use !user and not user == null

lucid prawn
#

ok

earnest phoenix
#

this is what i pulled from various docs, if you're still wondering const vs var vs let

#

Ik that const's values cannot be changed

#

on another line i mean

rocky hearth
#

Does anybody use oh-my-zsh here?

atomic vault
#

some one know free node js hosting?
lifetime

hollow sedge
#

Heroku

#

@atomic vault

atomic vault
#

other then heroku?

queen hamlet
#

Hm?

atomic vault
#

change let to var

#

or const

queen hamlet
slender thistle
#

why

pale vessel
#

const

queen hamlet
#

'args' is not definded.

pale vessel
#

you should define args at the top

#

Because args is supposed to be message content

queen hamlet
#

hOW?

final lava
#

Do you know how to define args

#

with const args = x

atomic vault
queen hamlet
#

I'm sorry I'm dumb idk.

queen hamlet
atomic vault
#

args is not in code

final lava
#

Specifically this page

restive furnace
atomic vault
#

why?

final lava
#

there really isn't a difference

#

except var is function scoped and let is block scoped

restive furnace
#

var is deprecated also

#

on modern js

marble juniper
#

just replace var with let and done

#

lol

queen hamlet
#

break

#

Unsyntatic break

earnest phoenix
#

what

queen hamlet
#

?

earnest phoenix
#

also, you should get a linter

queen hamlet
#

uhhh

earnest phoenix
#

Oh shit my bot's AI can think

#

Ignore that command

#

It's an spanish bot

queen moss
#

saved you an hour of headache

rain orbit
#

mine is just fine, v4.1.5

earnest phoenix
rain orbit
#

if anything, my quality is better

earnest phoenix
#

ok

rain orbit
earnest phoenix
#

No

sand walrus
final lava
#

I'm trying to create a webhook server to catch votes and stuff from Top.gg for my Discord Server listed on there.
I've tried Ksoft.si, and DBL Vote, but they don't really meet what I am looking for.
I want to code a webhook system into my Custom Discord Bot for the Discord Server using express or whatever.

I've taken a look on google but it doesn't really help.
Can someone point me in the right direction?

vague imp
#

let is equivalent of var. ES6 buddy

earnest phoenix
#

it isnt

#

they have different scoping rules

vague imp
#

i didn't say equal

#

equivalent

#

also there was no need for that change

lusty quest
#

var doesnt respect the scope let does

earnest phoenix
#

found 1 moderate severity vulnerability
run npm audit fix to fix them, or npm audit for details

how do i fix this while installing dblapi.js?

#

i ran npm i dblapi.js

glass nacelle
#

that's a warning

#

you can ignore it

pulsar bone
#

hey guys how to display author pic in .setauthor i tried displayurl and avatarurl but it doesn't work

old cliff
#

no

#

message.author.displayAvatarURL()

#

use this

knotty prawn
#

oh right, i was looking at thumbnail, sorry

static matrix
#

I'm having lots of error with opusscript

#

Any ideas?

earnest phoenix
#

use @discordjs/opus

delicate shore
#

Hi so

#

umm

#

Idk how to explain this

#

but

#

On starting bot

#

I get this error

#

just node .

earnest phoenix
slender thistle
#

Can you have the will to learn?

#

Also, you can use your browser's developer tools to get the CSS

earnest phoenix
#

how 😄

#

im so bad on css

#

i work on Js

delicate shore
#

yes

#

ok

#
onst interaction = new DiscordInteractions({
    applicationId: "",
    authToken: "",
    publicKey: "",
  })
   interaction
  .createApplicationCommand(command, "774875404698910731")
  .then(console.log)
  .catch(console.error);```
#

I am trying to make a slash command

#

so

#

maybe

#

thats why

#

the / commands

#

like /nickname

#

No

#

Leave it

#

Thanks for your help

#

No it won't help

#

I was trying to do something which breaks TOS

#

But now I won't

#

thanks

elfin tulip
#
const Discord = require("discord.js");
const User = client.users.fetch('302050872383242240');

msg.channel.send(User.id);```
delicate shore
#

Users are cached

outer wagon
#

u cant break tos

novel snow
#

what breaks tos?

elfin tulip
novel snow
#

with this;

#
client.users.cache.get("302050872383242240")
#

or fetch

#

i forgot which one

#

so;

#
const Discord = require("discord.js");
const User = client.users.cache.fetch('302050872383242240');

msg.channel.send(User.id);
tight plinth
#

@elfin tulip with fetch you have to use await

#

the code you used is correct, you just forgot to await it

pale vessel
#

it's users.fetch(), no cache

#

I recommend using fetch() since it looks in cache first and try to fetch it if it's not in cache

elfin tulip
#
const Discord = require("discord.js");
const User = await; client.users.fetch('302050872383242240');

msg.channel.send(User.id);```
@tight plinth so like this?
tight plinth
#

yep

zenith terrace
#

well I dont think you'd need to put a ; after await <_<

elfin tulip
earnest phoenix
#

wait you can color text in Console API?!

pale vessel
#

Use ANSI escape code?

earnest phoenix
#

I saw this on a video by Fireship:

console.log("%c Test", "CSS style");
#

Hello

dreamy gulch
delicate shore
#

All guilds unavaialble

#

const client = new Discord.Client({ ws: { intents: 'GUILD_MEMBERS' }})

#

is this wrong way to define it ?

earnest phoenix
#

use the guilds intent too

delicate shore
#

I don't have acces to that

#

I can't use it

earnest phoenix
#

it isn't a privileged intent

delicate shore
#

Oh

#

It is

earnest phoenix
#

no it is not

delicate shore
#

Ok

#

Thanks

earnest phoenix
delicate shore
#

Yay it worked

earnest phoenix
#

not yet

#

but it should throw promise rejections or shit

#

hm

#

but how would i console log an entire chunk of code

#

you wouldn't

#

i think i got it

#
for (let filename of fs.readdirSync("./commands")) {
            let data = require(`./commands/${filename}`);
            bot.commands.set(data.name, data);
        }
#

you would place a bunch of console.logs throughout the code

#

fs is not required anywhere

#

ah

#

but how it doesn't throw an error idk

#

is execute awaited?

#

nope

#

it's getting swallowed then

#

This article has kindly been turned into a video by the folks at Webucator who do JavaScript training. When dealing with asynchronous code, JavaScript’s ES6 promises can make your life a lot easier. No more callback pyramids, no more error handling on every second line, and no more reliance on external libraries to do things... Continue reading ...

#

so the errors are thrown but the Promise ignores them?

#

kind of yeah

elfin tulip
earnest phoenix
#

why was i mentioned

#

lol

#

but if I await it wouldn't it make my main thread busy

#

but no problem!

tight plinth
#

h

earnest phoenix
#

and prevent other commands from running

#

h

earnest phoenix
elfin tulip
#

oof sorry

earnest phoenix
#

ok

zenith terrace
earnest phoenix
#

.catch((e) => errorHandler(message, e))

#

also everything is running on the main thread in node

elfin tulip
earnest phoenix
tight plinth
#

bruh

mellow swan
#

Discord is not defined

#

lol

near stratus
#

Maybe misspelled discord and Discord

earnest phoenix
#

not smth that requires discord.js

#

also @pale vessel WHY U LIE TO ME THAT IMPORTED PACKAGES CAN ACCESS VARIABLES IN MAIN FILE

near stratus
earnest phoenix
#

message is defined in my main file and sent to the function

#

duh

near stratus
#

are you embedding ?

delicate shore
#

Ok umm sooo

#

Where this error is coming from

near stratus
delicate shore
delicate shore
near stratus
delicate shore
#

what happend

earnest phoenix
pale vessel
earnest phoenix
#

it's one of those

#

probably

delicate shore
#
 let newData = new welcomeinfo({
const welcomeinfo = require('./models/welcome.js')

          GuildID: reply.guild.id,
          status: "yes" , 
          channel: channel , 
          message: welcomemsg
      })
      newData.save()```
My Code 

My schema 
```js
const mongoose = require('mongoose');

const setwelcome = new mongoose.Schema({
    status: {
        type: String
    },
    channel: {
        type: String
    },
    message: {
        type: String
    },
    GuildID: String
});

const MessageModel = module.exports = mongoose.model('welcome setting', setwelcome);

@near stratus

#

I will send whole code in hastebin just a sec

pale vessel
near stratus
#

lemme be sure

delicate shore
delicate shore
pale vessel
#

Do you need assign the model to MessageModel amandathink

near stratus
#

can you like redo the last line

#

it seems wrong

delicate shore
#

Last line?

near stratus
#

yeah

delicate shore
#

Like what should I change

#

I have all other schema in same way

#

And they work

near stratus
#

F

delicate shore
#

:(

pale vessel
delicate shore
#

Wait what

#

Lmao

#

I'm stupid

earnest phoenix
#

get a linter

#

and you won't do dumb mistakes like that mmLol

delicate shore
#

No wait

#

It's just a typo here

#

In code it isn't there

near stratus
drifting wedge
#

is my nick back?

delicate shore
#

No no in code it's fine

earnest phoenix
#

If I have an Emoji object:

let emojis =  [...message.guild.emojis.cache.values()];
for (let emoji of emojis) {
  // ...
}

How can I convert it to a GuildEmoji object?
I tried doing:


emoji = message.guild.emojis.resolve(emoji.id);

But it didn't work

delicate shore
#

Just a typo here

#

So what do I do
Any idea

#

I googled it but it didn't help

pale vessel
earnest phoenix
#

yeah

#

lol

#

are you not seeing your code

#

talking to code913

earnest phoenix
#

emoji.author is undefined which should be for normal Emoji objects but not for GuildEmoji or ReactionEmoji

#

the author just isn't in cache

#

lol

earnest phoenix
#

shouldn't it be null instead of undefined

pale vessel
#

It should be null yeah

earnest phoenix
#

also why are you spreading values() into a new array

pale vessel
#

Yeah just put it in the for loop

#

Since .values() is iterable

#

You don't need to put it inside an array

earnest phoenix
#

bonk typescript for saying that'll throw an error

#

i guess it doesn't handle Iterator objects properly

#

you should just be able to use for of

crimson vapor
#

in ts, do you push the compiled code to github or do you leave it empty

earnest phoenix
#

transpiled*

#

and you just push your ts code

#

for a library, if you've got dependencies set up properly, you should have a build script that just runs tsc

crimson vapor
#

alright

#

whats the difference from something being transpiled and compiled?

earnest phoenix
#

transpiling is just transforming your code to another language that's similar in nature

#

Compiling is like java

#

Making the code into an executable

crimson vapor
#

ok that makes sense

earnest phoenix
#

compilation is compiling high level code into low-level code, something that would be annoying to code by ourselves

#

so we let the compiler do it for us

crimson vapor
#

@mellow kelp posted my ts code on github so if you want to rate my code

mellow kelp
#

oh cool

#

im gonna check it

#

Code review

crimson vapor
#

I didn't do anything wrong did I?

mellow kelp
#

haven't checked yet, hol up

#

got online classes

crimson vapor
#

o

crimson vapor
mellow kelp
#

oof

vale cairn
#

the node is not working

tardy hornet
#

install node

crimson vapor
#

^

vale cairn
#

i already did

mellow kelp
#

try restarting vscode

tardy hornet
#

^

mellow kelp
#

sometimes that makes recently installed commands work

earnest phoenix
#

when an item gets added to PATH you need to reload the thing that uses PATH

crimson vapor
#

or just delete the PS

#

because its a new powershell terminal

#

and if you create a new one it should have the updated PATH

vale cairn
#

yes thank you

mellow kelp
#

no prob

feral aspen
#

(node:14864) UnhandledPromiseRejectionWarning: FetchError: request to https://discordapp.com/api/v7/gateway/bot failed, reason: read ECONNRESET

#

What does that mean?

#

The bot won't start.

mellow kelp
#

that means an error when connecting the bot

#

i don't remember what econnreset meant but it's somewhere on the internet

feral aspen
#

Not API banned or something, right?

#

Hope not.

mellow kelp
#

nah dont think so

feral aspen
#

K! 👍 Phew..

elfin tulip
#

Does someone knows how I can get image url dominant color?

feral aspen
#

Wdym?

mellow kelp
#

to draw the image and get pixel data

feral aspen
#
            const m = await message.channel.send(embed);
                      ^^^^^

SyntaxError: await is only valid in async function
#

I'm not mistaken, but it is in an async function

#

But the const m = await message.channel.send(embed); is in an (if..) statement, does that affect anything?

mellow kelp
#

nope

#

you sure the last function before it is async?

#

it won't work if it's on a not-async nested function

feral aspen
#

Ill check something and reply to you.

mellow kelp
#

ight

feral aspen
#

Hm.. didnt work

#

The last thing before it is this. module.exports.run = async (bot, message, args) => {... all the stuff here ... }

#

Not sure why it's not working

earnest phoenix
#

share your entire code

mellow kelp
#

yea

#

if you got nested functons its most likely that

feral aspen
#
const reactions = ["🙂", "😀", "😄"]

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

    Data.findOne({
        userID: message.author.id
    }, (err, data) => {
        if(err) console.log(err);

        const noAccount = new Discord.MessageEmbed()
        .setColor(colors.red)
        .setDescription("❌ You do not have an economy account, be sure to create one by performing the **`!register`** command.")

        if(!data) return message.channel.send(noAccount)
        
        // Perform the command here...

        const embed = new Discord.MessageEmbed()
        .setColor(colors.cyan)
        .setTitle("Available Lootbox")
        .setDescription("These are the available lootboxes you have in your inventory. To open one, be sure to react with one of the reactions below. ")
        .addField("Loot Box", [
            `**🙂 - Mystery box:**`,
            `**😀 - Attitude box:**`,
            `**😄 - OP box:**`,
        ])
        //.addField("Current lootboxes left", `After opening this lootbox, you will have ${data.mysteryBox} left.`)

        const m = await message.channel.send(embed);
        const reacted = await promptMessage(m, message.author, 30, reactions);

        await m.delete(embed);

        if(reacted === "🙂") return message.channel.send("Hello1")
        if(reacted === "😀") return message.channel.send("Hello2")
        if(reacted === "😄") return message.channel.send("Hello3")
    })
}
earnest phoenix
#

does findOne not have an async counterpart?

mellow kelp
#

you got a nested function on Data.findOne

feral aspen
#

What can I do?

mellow kelp
#

You could just turn it async

earnest phoenix
#

make the callback async

mellow kelp
#

Since it doesn't have to return anything

earnest phoenix
#

or you can promisify findOne and avoid the callback approach

mellow kelp
#

yea

feral aspen
#

async findOne?

earnest phoenix
#

i-

#

no

feral aspen
#

ah wops.

mellow kelp
#

like

#

instead of using a callback

mellow kelp
#

use await with a promise instead

feral aspen
#

Ohh, but I'm just trying to know, How can I async the data.findOne thing?

earnest phoenix
#

read the doc link i sent you

feral aspen
#

Alright Thanks!

#

But wait, the Data.FindOne is the code to the database, I can't change that.

earnest phoenix
#

it... doesn't matter

mellow kelp
#

it should have a promise alternative to callbacks

#

if it definitely doesn't, just make the callback async

#

oh shoot i made a recursive thing and my vscode debugger crashed

feral aspen
#

So if I had this code only ```js
Data.findOne({
userID: message.author.id
}, (err, data) => {
if(err) console.log(err);
if(!data) {
const noAccount = new Discord.MessageEmbed()
.setColor(colors.red)
.setDescription("❌ You do not have an economy account, be sure to create one by performing the !register command.")

        return message.channel.send(noAccount)
    }
#

Oh wait, k, Ill work through it, I understood a bit.

mellow kelp
#

yea that should work

#

oh and add a return on the error check

feral aspen
#

I just copy pasted the code, I didn't do anything

feral aspen
mellow kelp
#

if not its still gonna execute the code after it even if theres an error

feral aspen
#

Alright, sure.

#

👍

earnest phoenix
#

How i can get the video formats with the link (youtube link)?

mellow kelp
#

wdym video formats?

crimson vapor
#

youtube can send lots of formats

#

or they only send mp4

mellow kelp
#

hmm

earnest phoenix
#

is the first format of the array

mellow kelp
#

what object is that?

earnest phoenix
mellow kelp
#

oh aight

#

it's a feature of ytdl-core

earnest phoenix
#

Yes but, i want to get the formats only with the link

#

Not with getInfo

elfin tulip
mellow kelp
mellow kelp
#

but there might be some package for that

elfin tulip
mellow kelp
#

well i don't think there's one to directly get the color of an image

#

but maybe sharp can help

#

shouldn't be too hard with canvas tho

earnest phoenix
lofty viper
#

hi do we have any bot for custom leaderboard?

elfin tulip
mellow kelp
#

oh poggers

#

there's really an npm package for everything

crimson vapor
crimson vapor
#

its kinda annoying how there is no requirements for a npm package

crimson vapor
#

kids make some discord-embed-generator or something and use shit code and boom their package

mellow kelp
#

i made a package that converts images into ascii art

crimson vapor
#

LOL

mellow kelp
#

it was pretty interesting ngl

crimson vapor
#

now that seems useful

mellow kelp
#

it has a command line interface too

#

indeed

crimson vapor
#

nice

mellow kelp
#

try npm i -g ascii-converter

crimson vapor
#

how do you do command line interfaces?

mellow kelp
#

and run ascii on some folder with pictures

mellow kelp
#

chalk for loggin colored text

#

and inquirer for asking questions

crimson vapor
#

o

mellow kelp
#

o

crimson vapor
#

and would the package name be a command as well

#

how do you set that up

mellow kelp
#

you gotta add a bin property on your package.json

#
{
  "bin": "./src/index.js", // If your command is the same as the package name
  // or:
  "bin": {
    "custom-command": "./src/index.js" // If you want another command name
  }
} 
crimson vapor
#

oh

#

thats cool

mellow kelp
#

ye

crimson vapor
#

jason.db command

mellow kelp
#

and you need to add #!/usr/bin/env node to the file

crimson vapor
#

imagine

mellow kelp
#

lmao

fiery trellis
#

im finding to do like the animated background thingy

mellow kelp
#

a cli to manage some json files

earnest phoenix
#

I accidentally hit my phone super gently on my bed and the whole thing restarted and the battery went down by 36% fuck you samsung

crimson vapor
#

you should add that?

dense skiff
fiery trellis
#

And the vote requirement

mellow kelp
crimson vapor
#

yes

earnest phoenix
#

@mellow kelp comments in json wait thats illegal

crimson vapor
#

the very best

#

btw what license did you add for my code?

mellow kelp
crimson vapor
#

ok

mellow kelp
#

Thats the one you had on ur package.json

crimson vapor
#

alright

fiery trellis
#

Hello anyone knows how to do the animated background thing

mellow kelp
#

and thats the story of how i got into the contributions section

fiery trellis
crimson vapor
#

yes

mellow kelp
#

alr lemme see

crimson vapor
#

good contribution

mellow kelp
#

im about to make a PoggersCollection

#

its gonna store stuff in some kind of special encoding

earnest phoenix
#

i use firebase real-time database to store user data (emojis, user IDs and names, and that's it) is that allowed or do i need to do some hackery to encrypt it

mellow kelp
#

which relates to poggers

fiery trellis
#

Did you see it?

mellow kelp
#

you should probably hash passwords

earnest phoenix
#

There are no passwords

mellow kelp
#

then i dont think theres any encryption stuff needed

earnest phoenix
#

ok

mellow kelp
#

my video player kinda sucks

elfin tulip
#

Use vlc media player