#development

1 messages · Page 1560 of 1

tired panther
#

I heard of the .lean() method in mongoose , will this really save ram in query and give me the same object?

copper cradle
#

move the target constant above the rest of the function

cobalt spruce
copper cradle
#

yes

earnest phoenix
#

Ohhhhh, lol

cobalt spruce
#

lol

earnest phoenix
#

Now I understand, because it has on the top to make everything work with target with it

cobalt spruce
earnest phoenix
#

@copper cradle thanks u learnt me something again lol

cobalt spruce
#

i think that is better

earnest phoenix
#

Thanks too lol

earnest phoenix
#

Yes, now it all makes sense

cobalt spruce
copper cradle
#

yes

#

I used sharex

earnest phoenix
#

Hessss! Worked

#

And my unban, it says it can’t find the Id and then unban

pale vessel
earnest phoenix
cobalt spruce
#

is binary encode or hash

#

lol

earnest phoenix
#

Lol

#

neither

cobalt spruce
#

Triangle walking

#

il die away

copper cradle
cobalt spruce
mellow kelp
#

real programmers use binary

copper cradle
#

and it's saying it can't find the user bc that's what you're logging

#

you're not logging the actual error

#

I suggest you go learn how to debug, and to not attempt to code a bot until you can fix this kind of issues

#

your problem is the exact same as before

earnest phoenix
#

Debug how do I do that?

cobalt spruce
# mellow kelp real programmers use binary

00111100 01000000 00100001 00110101 00110011 00110111 00110100 00111000 00110110 00111000 00110101 00110110 00110011 00111000 00110100 00110110 00110111 00110101 00111000 00110101 00110010 00111110 00100000 01111001 01101111 01110101 00100000 01110010 00100000 01100111 01100001 01111001

#

yes

copper cradle
#

you're trying to use a variable called target, which doesn't exist in that scope

copper cradle
#

log the goddamn error

earnest phoenix
#

Tbh, it’s shit it never logs anything

cobalt spruce
pale vessel
earnest phoenix
#

@copper cradle so at the top const target = message.Id.members.first();

#

?

copper cradle
#

no

cobalt spruce
copper cradle
#

you don't need that target variable

earnest phoenix
copper cradle
#

just remove the word target. from that code

earnest phoenix
#

Alr, I’ll just add member

#

Would that work too?

copper cradle
#

no

cobalt spruce
earnest phoenix
#

Lol..

earnest phoenix
copper cradle
cobalt spruce
copper cradle
#

remove target. <-- dot

earnest phoenix
#

Alr

copper cradle
earnest phoenix
#

@earnest phoenix You still haven't fixed that issue when we literally told you that 30 times? Wtf KEKW

copper cradle
#

oml

#

don't make it worse please

#

brb

cinder patio
#

someone has to explicitly tell him what to do step by step otherwise he can't

earnest phoenix
copper cradle
#

bro

earnest phoenix
#

Unban worked...

copper cradle
#

yeah...

earnest phoenix
#

Thanks again

copper cradle
#

you're not ready to do such project my guy

#

why don't you try to play with the language a bit before trying to do such a project

earnest phoenix
#

True.., but if I’m gonna be honest it harder to read docs than getting explained

cinder patio
#

of course it is, it's always easier when somebody else does it for you

copper cradle
#

yeah

earnest phoenix
copper cradle
#

that doesn't sound like the case

#

since you did the same mistake twice

#

just try to play with the language a bit

#

you'll get used to it and you'll see how easy it is

#

() => {} <= what it that

earnest phoenix
#

It’s uh semicolons, and uh yea..

copper cradle
#

there aren't any semicolons there...

rocky hearth
cinder patio
#

👁️ 👄 👁️

mellow kelp
earnest phoenix
earnest phoenix
rocky hearth
copper cradle
#

there are a lot of good youtubers

#

there's fireship

earnest phoenix
#

Is it a youtuber?

mellow kelp
#

fireship explains many useful concepts

copper cradle
#

traversy media

#

fireship is a really good one

#

and his videos are short and easy to follow

earnest phoenix
#

Is there any that explain the basics or does he have a basic js video?

#

If you could send me link through DM’s would be appreciated

cinder patio
#

I don't think fireship is for beginners, though

#

this is everything you need to know... in 3 hours

earnest phoenix
#

@cinder patio thank you sor

#

If I actually learn something thanks

rocky hearth
#

are you still not sure?

earnest phoenix
#

I’m sure I’ll learn something

tight plinth
#

according tow3schools, the format for a new date is new Date(year,month,day) but it seems to be kinda broken...

#

format is MM/DD/YYYY

pale vessel
#

months start from index 0

#

So d[0] - 1

tight plinth
#

wtf naniok

pale vessel
marble juniper
#

lol

bold dock
#

Thanks Java

zenith terrace
earnest phoenix
#

you know how they show those before and after pics when people do crystal meth
javascript is the after

slow halo
restive furnace
#

it's not inherited from Java

bold dock
#

It is tho

pale vessel
#

it is

restive furnace
#

smh

#

why

opal plank
#

not only months, the fuckind days of the week too

#

cuz fuck logic

#

sorry, that brings PTSD's from when i was fucking with manual time manipulation

#

not fun times

#

spent around 15h total just to get the conversion done properly

#

time is NOT my forte, at all

viral mortar
#

heh

crisp osprey
#

I need a member who can help me with the Carl bot or any toher bot

#

For self roles

#

Please

#

In my server (u can ping me)

viral mortar
#

lol thats not really bot development

crisp osprey
#

But someone told me to tell bere @viral mortar

#

Here*

viral mortar
#

no this is for making bots

#

no bot usage support

rocky hearth
#

How do I run a script which is defined in a subfolder, from my current folder in package.json?

mellow kelp
#

some-folder/another-folder/script.js

rocky hearth
#

The script is dev: next dev which is defined in current package.json, and I want to use it from parent's package.json

#

do u got the idea??

mellow kelp
#

wdym by parent's package.json?

#

o

#

well you could do something like "dev": "cd the_folder && yarn dev"

rocky hearth
#

will the terminal actually change path?

mellow kelp
#

pretty sure it won't

cinder patio
rocky hearth
#

oh ok just got it

#

so with p flag, we specify the path of the folder to compile, right?

cobalt spruce
#

hey

#

how i tell the bot to accept only numbers when posting letters it reply You cant use Letters For Example

#

uhh

#

u are dead

#

will this work?

let binary = args.slice(0).join(" ");
if (!binary) return message.channel.send("Please input some text.");
let outputStr = binary.split(' ') //Split string in array of binary chars
   .map(bin => String.fromCharCode(parseInt(bin, 2))) //Map every binary char to real char
   .join(''); //Join the array back to a string
   
try{
  parseInt(outputStr)
}catch(e){
  message.channel.send('this is not a number')
}



cinder patio
#

Use isNaN

cobalt spruce
#

uhh

rocky hearth
#

do u want the string "10001011" to be a number like 10001011?

cinder patio
#

or parseInt/float and then check if parseInt returned NaN

cobalt spruce
cinder patio
#

He definitely copied that from somewhere lol

cobalt spruce
#

i use if and then

rocky hearth
#

what are the expected inputs and outputs?

cobalt spruce
#

idk what to do

cobalt spruce
cinder patio
#

I already told you, use isNaN or parseInt/parseFloat

rocky hearth
#

so u want the argument to be any number?

cobalt spruce
cobalt spruce
#

i saw this shit but nothing come to mind

cinder patio
#

It's a simple function call - if you don't know how to do that then maybe you should revisit a tutorial or two

rocky hearth
#

y isNaN returns false for empty strings?

cobalt spruce
cinder patio
#

sure, try it. That function is super unnecessary, though

#

make sure to call it

#

or just remove it

cobalt spruce
#

i dont need function?

#

POG

#

IT WORKED

cinder patio
#

No... I was talking about the isNaN function

cobalt spruce
cobalt spruce
#

this all i did

#

and it worked

cinder patio
#

good

wicked pivot
#

hello, how to get that server code in a string in this style for example: hello https://discord.gg/dbl teste

rocky hearth
#

Feud, is it possible to not exclude a folder/file and still it not complains about errors?
I don't want to, use @ts-nocheck as it'll not validate the file entirely.

cinder patio
#

mmmm, what about @ts-expect-error?

#

or @ts-ignore

rocky hearth
#

these just ignores the next line

#

something like @ts-ignore-file

cinder patio
#

Can you give more context? Why are you receiving these errors in the first place

rocky hearth
#

I hv a dummy test file. Which is not used in the actual codebase

#

Changing the codebase, make this file to complain, which I only use for testing purposes

cinder patio
#

hmmm... you could exclude the test file, and if you want to run it, you can setup a script

#

do you have ts-node as a dependency? You could make a script "runTest": "ts-node path/to/file.ts"

rocky hearth
#

Ooh ok. lemme try

rocky hearth
wicked pivot
#

I want to isolate the code server on string

cobalt spruce
#

@cinder patio

#

uhh

#
if (isNaN(binary)) {
    return message.channel.send("its not a number")
  }```
earnest phoenix
#

What's binary defined as

cinder sandal
#

binary might not be defined

earnest phoenix
#

binary variable is a string and you also entered a space, spaces don't count as a number, isNaN() function will always return true in that case

opaque acorn
#

Hello, somebody can tell me how can I create the join command?

#

for voice channel

cinder patio
earnest phoenix
#

Yea i know, they can simply use a regex instead of checking if it's a number

#

/^[10 ]+$/.test(binary)

long marsh
#

Does anyone here actually use GO for their discord bot?

zenith terrace
#

Go compare?

long marsh
#

Only asking because I'm thinking of lifting and shifting from DiscordJS to DiscordGO

modest maple
#

Well how well do you know Go lang

long marsh
#

None at all, lol. I didn't know NodeJS either before - and that was pretty solid. I have 4 years of software dev experience. Learning a new language shouldn't be too challenging.

modest maple
#

i mean sure but you'll suffer with it 🤷‍♂️

#

i advise you try Go before starting the lib

long marsh
#

Oh, 100%

modest maple
#

cuz Go is like marmite

#

you either love it or hate it

long marsh
#

I've programmed in C before

#

Can't be any worse than that 😄

modest maple
#

Idk

#

I would have to argue i prefer writing C lol

long marsh
#

Have you used C?

#

I find it hard to believe that you would choose C over GO, lmao

modest maple
#

I would choose C over go for most things lol

long marsh
#

Why?

#

Not trying to start a debate or anything, just genuinely curious why you'd want to hurt yourself

modest maple
#

I mean C is fine if you know what you're doing

long marsh
#

Yeah, but you have to know what your doing. At least GO extracts that part out.

#

If anything, C would be more challenging than GO.

#

I don't follow that logic, ha. That's all I'm saying. My mistake

#

Btw, hopefully I'm not coming off as rude. Maybe I'm the idiot 🤷‍♂️

modest maple
#

my reasons for not liking go:

  • File structure makes you have everything all in one file
  • Lack of generics
  • You either strictly type or use a blanket interface which has no way of determining the type directly other than trying to cast it
  • Pass by value on a GC runtime for what ever reason they chose to allow the user to do instead of doing everything by reference
  • Limited ability to easily interface with other languages
  • Lack of compile time checks for things like race conditions and deadlocks
  • Locks OMFG the lock hell is mind boggling because its so easy to use the concurrency wrong
  • camelCase naming convention (which for you on JS might be fine but god it drives me nuts)
  • having to check if err != nil on. every. fucking. line.
  • Litterally no type checks, you got a null pointer? prepare to face the wrath of the runtime error
  • For some reason stack traces are 60% memory addresses that you will never need and want other than the 1 line after the whole trace that tells you the error
mellow kelp
#

wait there's no generics?

modest maple
#

Nice things about go:

  • Simple concurrency
mellow kelp
#

gasp

modest maple
#

Its a weird system

#

I dont entirely hate it

#

but i disliked it enough when using it to drop it

earnest phoenix
#

So I need help with a discord bot I want to get the ping of my bot I have this command


module.exports = {
  info: {
    name: "ping",
    description: "To see the ping of the bot",
    usage: "[ping]",
    aliases: ["pg"],
  },
  
  run: async (client, message, args) => {
    
    let embed = new discord.MessageEmbed()
    .setDescription(`Pong - ${client.ws.ping}ms`)
    .setColor("RANDOM")
    .setFooter(`Requested by ${message.author.username}`)
    
    message.channel.send(embed)
  }
}```
But that is for the websocket Not the latency does anyone know what I need to change?
modest maple
#

especially when you have

foo, err := someFunc()
if err != nil {
  // handling...
}
#

on every function call

#

which ends up just becoming

#
foo, err := someFunc()
if err != nil {
  return nill, err
}```
#

because you're just moving the error back up the hill of stacks

#

goroutines are nice though when used correctly

#

though many seem unable to grasp the fact that sometimes you dont need everything to be a goroutine

long marsh
# modest maple my reasons for not liking go: - File structure makes you have everything all i...

Hey! I really appreciate you writing all of that out. To be fair though, the camelCase convention is okayish .. and the err != nill is actually a great way, in my eyes, to enforce proper error handling (which you can argue shouldn't be up to the language ... fair point). Generics don't really bother me, I don't realistically use them much anyways. The type casting is interesting - I didn't know about that problem. Also, no type checks ... sounds much like JavaScript 😄

modest maple
#

oh no thats not enforced

#

in anyway

long marsh
#

Oh, gotcha

modest maple
#

its the same as JS pretty much

#

if you dont remember to or you dont expect the function to return it, you will crash and burn

long marsh
#

Yeah, I'm used to that from using Python / JS lmao

sudden geyser
#

I commonly see people try to compare Go with Rust

modest maple
#

idk why people do that tbh

#

its a generally a really dumb argument they have

earnest phoenix
long marsh
sudden geyser
#

There are some similarities between the two, but they both target different goals. Really, I'm surprised there's always a new medium article about Go vs. Rust every week

#

No joke

long marsh
#

Yeah, they're just completely two different languages with different goals (as you stated)

quartz kindle
modest maple
#

in the end its Speed of development vs Code security

long marsh
#

Exactly

modest maple
#

You can write code very quickly in go but it's maintainability can be incredibly low

quartz kindle
#

You have to start a timer, send the message, then see how long the pronise took

long marsh
#

Also, that's why I'm contemplating GO. For the lowered cache usage of NodeJS / DiscordJS & for the speed.

modest maple
#

on the other hand it takes a programmer much long to become experienced enough with Rust to write it at the same pace as go

long marsh
#

Granted, I know Tim has a great library regarding the cache 😄

heavy marsh
#

In D.js [v 12] is there a way to check if a message has 2+ discord invte links.

I already have a reg const inviteRegex = /discord(?:app\.com\/invite|\.gg(?:\/invite)?)\/([\w-]{2,255})/i;

modest maple
#

Go and JS' speeds are actually a lil closer than alot of people think tbh

long marsh
#

Speeds are a secondary goal of mine

#

It's really the caching 😬

modest maple
#

Cant really argue about the caching d.js is really bad at that

summer torrent
modest maple
#

while DiscordGo is on the opposite end of the spec

summer torrent
modest maple
#

you have d.js which is very high level and DiscordGo being very low level

quartz kindle
#

If the issue is caching, its not a language problem, just use a different library or code a barebones one yourself

modest maple
#

tbh yeah

#

oh yeah

#

Go lang docs

#

are

#

interesting

#

they're not bad per say

#

but from what i found, they either contain some info or absolutely none

#

Luckily DiscordGo is pretty well documented but most libs are very much not

long marsh
modest maple
#

well...

#

sorta

#

when you're using it for discord you're not gonna notice any of that if you cache equal amounts

long marsh
#

Correct. But, I probably won't.

#

I believe the DiscordGO library is a little lighter on that

earnest phoenix
# quartz kindle There is no built in method for that

would this work I tried it and it does show the ping ||from what I know||


module.exports = {
  info: {
    name: "ping",
    description: "To see the ping of the bot",
    usage: "[ping]",
    aliases: ["pg"],
  },
  
  run: async (client, message, args) => {
    
    let embed = new discord.MessageEmbed()
    .setDescription(`Pong ${Math.floor(client.ws.ping)}`)
    .setColor("RANDOM")
    .setFooter(`Requested by ${message.author.username}`)
    
    message.channel.send(embed)
  }
}```
modest maple
#

Well its about the same as @quartz kindle 's D.js light

#

potentially a lil more tbh

#

cuz again pass by value is allowed in Go instead of JS where everything is reference based

#

it is incredibly easy to get data duplication

quartz kindle
#

Caching will be the same in all languages unless you can make use of more efficient data types

modest maple
#

it also is pretty much the only think that will affect performance in Go

#

if you pass everything by value in go

#

you will suffer performance

#

When i was coding a webserver in go i ended up replacing everything following Python's referencing type GC system and got about a 50% performance increase or greater

stable nimbus
#

How would you call for a user input using slash commands?

#

Like taking the message content.

smoky thorn
#

can someone tell me the command for if I want to make a python program run without me having to use Cmd? When I run my bot the thing just closes and I Have to use CMd and it's annoying sometimes

long marsh
#

Lol, kidding. Does anyone know of anyone who uses GO?

modest maple
long marsh
#

lol

livid lichen
#
Bot.TotalMembers = 0

Bot.guilds.cache.map(guild => Bot.TotalMembers = Bot.TotalMembers + guild.memberCount)
```Bot's total members is 0? This cannot be right.
stable eagle
cloud warren
#

guildOnly: false,
what exactly is the feature of this command

modest maple
#

Error handling is by far the biggest issue with go

long marsh
#

Yeah, truth.

livid lichen
stable eagle
#

Doesn’t the name explain it? The command can’t be used in dms.

long marsh
#

But does anyone here use GO?

#

I'm assuming no since no one actually spoke up.

pale vessel
#

literally chill lmao

gilded olive
#

I mean use it as like usually

stable eagle
livid lichen
modest maple
pale vessel
#

f

urban surge
#
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:617:28)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/rbd/pnpm-volume/85a47698-9068-4ee7-b0d2-ac9b2b12dd4c/node_modules/.registry.npmjs.org/discord.js/12.5.1/node_modules/discord.js/src/index.js:8:11)
/rbd/pnpm-volume/85a47698-9068-4ee7-b0d2-ac9b2b12dd4c/node_modules/.registry.npmjs.org/discord.js/12.5.1/node_modules/discord.js/src/client/Client.js:42
    } catch {```

I get this error when I update the modules. How can I solve it?
livid lichen
modest maple
#

do you actually have intents set though to actually allow it or tell it to cache 👀

stable eagle
#

No, I meant the users who are in one of the bot’s guilds.

livid lichen
#

So like this? guild.cache.memberCount

livid lichen
stable eagle
#

In order to get every guild's members count,

urban surge
livid lichen
#

I'd have to .map

#

Right?

urban surge
#

Is this a glitch problem?

livid lichen
#

@stable eagle Didn't work. Still shows 0.

stable eagle
#

You have to do smth like this:

<client>.guilds.cache.reduce((res, guild) => res + guild.memberCount)

livid lichen
#

Oh

pale vessel
livid lichen
#

I've never heard of .reduce before.

pale vessel
#

It's <client>.guilds.cache.reduce((res, guild) => res + guild.memberCount, 0)

livid lichen
#

Thanks

long marsh
#

Can anyone point me to a well-document command handling system for DiscordJS? I may actually entertain Tim's light library

ashen sigil
#

if (!SafeCopy(kernelBuffer, &imageData->Buffer, safeData.Length)) {
ExFreePool(kernelBuffer);
*outStatus = STATUS_ACCESS_VIOLATION;
return STATUS_SUCCESS;
}

CHAR error[0xFF] = { 0 };
NTSTATUS status = MapImage(kernelBuffer, error);
SafeCopy(&imageData->Buffer, error, strlen(error) + 1);
ExFreePool(kernelBuffer);

*outStatus = status;
return STATUS_SUCCESS;

}

#

It works but the driver not working

livid lichen
#

@pale vessel Would this work? Bot.TotalMembers = Bot.guilds.cache.reduce((res, guild) => res + guild.memberCount, 0)

pale vessel
#

I think so

pale vessel
#

Why assign it to Bot.TotalMembers ?

livid lichen
#

So I don't have to do that each time lol.

pale vessel
#

Make it a function

livid lichen
#

I am trying to be as efficient as posible.

livid lichen
pale vessel
#

Otherwise the value is going to be static

livid lichen
#

Yeah

ashen sigil
#
if (!SafeCopy(kernelBuffer, &imageData->Buffer, safeData.Length)) {
        ExFreePool(kernelBuffer);
        *outStatus = STATUS_ACCESS_VIOLATION;
        return STATUS_SUCCESS;
    }

    CHAR error[0xFF] = { 0 };
    NTSTATUS status = MapImage(kernelBuffer, error);
    SafeCopy(&imageData->Buffer, error, strlen(error) + 1);
    ExFreePool(kernelBuffer);

    *outStatus = status;
    return STATUS_SUCCESS;
}
summer torrent
pale vessel
#

It could be

#

but not always

#

Maybe that's why it errored

#

Maybe ?.length won't make it error no wtf

summer torrent
#

you mean !.length

pale vessel
#

not sure

#

that sounds new

livid lichen
#

@pale vessel Still 0.

pale vessel
#

It could be
but not always

#

like an instance of Permissions won't have the length property

#

but I think you can just ignore the error if it works anyway

midnight spoke
#

I can use many command handler yea ?

summer torrent
#

@pale vessel PermissionResolvable[]

pale vessel
#

the type for cmd.botPermissions?

summer torrent
#

yes it should be PermissionResolvable[] lul

pale vessel
#

then it shouldn't error

urban surge
#
const fetch = require("node-fetch");
const key = require("../config.json");
const discord = require("discord.js");
module.exports.run = async (bot, message, args) => {
  var output = new discord.MessageEmbed()
    // .setTitle('Some title') // tıklamalı başlık
    // .setURL('https://discord.js.org/') // tıklamalı başlık
    .setAuthor('Some name', 'https://i.imgur.com/wSTFkRM.png', 'https://discord.js.org')
    .setColor("RANDOM")
    .setDescription('Some description here') // başlık açıklaması
    .setThumbnail('https://i.imgur.com/wSTFkRM.png') // sağ logo
    .addField(
        { name: 'asdasdas', value: '3', inline: true },
      "`accuracy` `deaths` `kills` `resources` `stats`"
    )
    // .setImage('https://i.imgur.com/wSTFkRM.png') // BÜYÜK ORTA LOGO
    .setTimestamp() // FOOTER ZAMAN EKLER
    .setFooter('Some footer text here', 'https://i.imgur.com/wSTFkRM.png') // AÇIKLAMA + LOGO
  return message.channel.send({ embed: output });
};
module.exports.help = {
  name: "ak"
};
#

How do I get the bot to send such messages?

zenith terrace
#

isnt node-fetch deprecated

cloud warren
opal plank
zenith terrace
#

.-.

opal plank
#

its request thats deprecated

summer torrent
#

node-fetch isn't deprecated

opal plank
#

fetch comes built in already

#

in most browsers

#

no way it'd be deprecated

summer torrent
#

request are looking for maintainer(s) iirc

opal plank
#

dead lib tbh

zenith terrace
#

o ok

opal plank
#

everyone already ported over

#

doubt theres many still using it

summer torrent
#

im using node-fetch/axios

opal plank
#

axios gang

urban surge
opal plank
#

high five

opal plank
#
1 - this
#

but they got one in each thing

opal plank
summer torrent
urban surge
opal plank
#

i never really noticed axios didnt have a logo

opal plank
#

copy ^^ (english only here)

#

multiple fields

#

you use discord.js?

#

you do, nvm

#

.setFields([]) use that

#

or addFields(), forgot how d.js embed builder works

#

its bad

urban surge
#

I'm using discord.js

#

My friend used to build the boat, I don't understand much

opal plank
#

multiple fields

#

lua, ts and js should all work and be like that one you sent in the picture

urban surge
# opal plank

Thank you very much I've been dealing with this since yesterday

opal plank
#

no problem

royal laurel
#

hey i just want to know a quick way to fix my problem, its just that i am making a usercount.js command in another file using fs and the only problem is my variable which gets the current amount of users requires the variable const client = new Discord.Client()

#

is there a way i can get the variable in the other file aswell? can i just put the var above of module.exports?

#

oh and im getting this error

#
ReferenceError: client is not defined
    at Object.execute (C:\Users\fred\Desktop\Bots\Discord Bots\Mint\commands\usercount.js:6:23)
    at Client.<anonymous> (C:\Users\fred\Desktop\Bots\Discord Bots\Mint\mint.js:29:42)
    at Client.emit (node:events:379:20)
    at MessageCreateAction.handle (C:\Users\fred\Desktop\Bots\Discord Bots\Mint\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
    at Object.module.exports [as MESSAGE_CREATE] (C:\Users\fred\Desktop\Bots\Discord Bots\Mint\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
    at WebSocketManager.handlePacket (C:\Users\fred\Desktop\Bots\Discord Bots\Mint\node_modules\discord.js\src\client\websocket\WebSocketManager.js:384:31)
    at WebSocketShard.onPacket (C:\Users\fred\Desktop\Bots\Discord Bots\Mint\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)
    at WebSocketShard.onMessage (C:\Users\fred\Desktop\Bots\Discord Bots\Mint\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
    at WebSocket.onMessage (C:\Users\fred\Desktop\Bots\Discord Bots\Mint\node_modules\ws\lib\event-target.js:132:16)
    at WebSocket.emit (node:events:379:20)
fierce ether
#
const getEmbed = await getChannel.messages.fetch({ limit: 1 })
          
          console.log(getEmbed.id)``` am i doing something wrong? its undefined everytime
urban surge
#

Those starting with .set don't work

red tapir
#

um'

#

this looks like literal hcking

#

thats so confusing

opal plank
royal laurel
#

ill pastebin, want my main and my usercount.js?

zenith terrace
#

usercount

royal laurel
#

ok

zenith terrace
#

whats your main file called

royal laurel
#

mint.js

long marsh
#

@quartz kindle - Sorry for the ping - just curious on something. If you got hit by a bus tomorrow, are there other supporters of the lite version of discordjs that you created?

royal laurel
#

mint is my bot name

zenith terrace
#

try const client = require('../mint.js')

royal laurel
#

thomas is planning on killing you

#

ok

zenith terrace
#

above module.exports

royal laurel
#

ok

long marsh
#

Hah, that's not true.

royal laurel
#

do it also keep the client var in module.exports, probably dont but i get things wrong all the time

zenith terrace
#

what

royal laurel
#

oh wait

#

no nvm

#

i thought users var was a different var

#

just wait

#

ima test

#

sorry for my stupidioty

#

now i get a type error

#
TypeError: Cannot read property 'cache' of undefined
    at Object.execute (C:\Users\fred\Desktop\Bots\Discord Bots\Mint\commands\usercount.js:8:37)
    at Client.<anonymous> (C:\Users\fred\Desktop\Bots\Discord Bots\Mint\mint.js:29:42)
    at Client.emit (node:events:379:20)
    at MessageCreateAction.handle (C:\Users\fred\Desktop\Bots\Discord Bots\Mint\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
    at Object.module.exports [as MESSAGE_CREATE] (C:\Users\fred\Desktop\Bots\Discord Bots\Mint\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
    at WebSocketManager.handlePacket (C:\Users\fred\Desktop\Bots\Discord Bots\Mint\node_modules\discord.js\src\client\websocket\WebSocketManager.js:384:31)
    at WebSocketShard.onPacket (C:\Users\fred\Desktop\Bots\Discord Bots\Mint\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)
    at WebSocketShard.onMessage (C:\Users\fred\Desktop\Bots\Discord Bots\Mint\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
    at WebSocket.onMessage (C:\Users\fred\Desktop\Bots\Discord Bots\Mint\node_modules\ws\lib\event-target.js:132:16)
    at WebSocket.emit (node:events:379:20)
zenith terrace
#

h

royal laurel
#

h

zenith terrace
#

you could just do message.guild.memberCount

royal laurel
#

i can?

zenith terrace
#

yea .-.

royal laurel
#

:|

#

const users = msg.guild.memberCount;

#

like that?

opal plank
#

whatever you named your message, yes

zenith terrace
#

^

royal laurel
#

well fuck

#

ok now i need to require MessageEmbed and stuff

opal plank
#

i would recommend NOT using embed builder

royal laurel
#

why not?

opal plank
#

check performance

#

spits

#

trash

zenith terrace
#

cause Erwin gets mad at them KEKW

#

he has a fit

opal plank
#

````new Discord.MessageEmbed()``` literally just creates an object

#

thats literally it

#

and then each method adds another key on it

royal laurel
#

im gonna use it in spite of him

#

wait

#

yeah

misty sigil
#

lol

opal plank
royal laurel
#

i use that i literally make a new discord.embed

opal plank
#

-30 respect

royal laurel
#

is that embedbuilder and im just stupid?

opal plank
#

yes

royal laurel
#

ok well im gonna usee it in spite of you

opal plank
#

well, warning was given, you can give water to the horse, but you cant force him to drink it

royal laurel
#

do i just do const { Channel, MessageEmbed } = require("discord.js");

gritty bolt
#

anyone know why I might be having mongoDB connection errors on an AWS ubuntu server?

royal laurel
#

this is my first bot(in a while) i have lost all my skill so its back to day one

opal plank
#

whats the point of practicing if you refuse to use the proper way?

gritty bolt
#

oh wait

#

blocking all connections would cause connection errors nevermind

royal laurel
#

idk, im not smart

opal plank
#

then why not optimise it and stop being stubborn?

royal laurel
#

idk, but you got that second part right, i am really stubborn, just ask people who have helped me code!

gritty bolt
#

you should listen to them i came here yesterday with a mess and left actually understanding stuff

#

being stubborn wont help you improve lol

royal laurel
#

i never said i wasnt going to listen to them, im just trying to get a basic understanding of disc.js

earnest phoenix
#

Oh, I can recommend some vids

opal plank
#

dont

#

dont use videos to learn js

misty sigil
#

yea

royal laurel
#

so thats why i suck at most things

#

in code

opal plank
#

its all about commitment

#

code reflects how commited you are

#

if you dont put efford into coding, it shows

#

that boils down to the last thing i said in that message. If you doing it as a hobby? sure, go ahead, it might be useful someday. If you intend to be an ACTUAL dev? then put effort into it, its a career, dont underestimate developers

royal laurel
#

i mean i am doing it as a little hobby

opal plank
#

then its fine

royal laurel
#

ill work on it 3 - 4 times a week

earnest phoenix
opal plank
#

you dont need to optimse your app like im telling you to, both embedbuilder and sending an object directly, but the latter being more optimised

earnest phoenix
royal laurel
#

if you'd really like me to link me documentation on sending an object

earnest phoenix
#

There’s a 3 hour video, that learns you all the basics

nocturne parrot
#

i agree that some videos only tell you to copy and paste whatever’s in the description, they usually don’t tell you what does what tbh

opal plank
#

you sounds like you didnt even read what i sent baldski

earnest phoenix
#

Yes, yes, I’m reading rn

nocturne parrot
#

anyways back to my question i was about to ask, how do you get your bot to show in its status how many servers it’s in?

royal laurel
#

*closes google* nah i - i wasnt looking at video tutorials dont even worry

opal plank
earnest phoenix
#

True, true, but yk sometimes they can be useful @royal laurel

opal plank
nocturne parrot
#

thank you, but how do you get it show how many servers it’s in?
for example
playing !help in [insert number] servers

earnest phoenix
#

He means in the status

#

Like

opal plank
#

client.guilds.cache.size will give you the number

earnest phoenix
#

Watching 737373738388282 servers

opal plank
#

that IS the status baldski

earnest phoenix
#

Oh ok

opal plank
#

setActivity() IS setting status

earnest phoenix
nocturne parrot
#

thank you

opal plank
#

np

nocturne parrot
#

also i’m not sure who baldski was calling he but i’m not a he sorry 😭

opal plank
#

we are all developers here

#

except @slender thistle , he's just qt

solemn latch
#

qt shiv is qt

earnest phoenix
#

Wtf

#

Oh mb, I didn’t see what you guys were talking bout

proven lantern
#

TypeError: client.guilds.fetch is not a function

for (const {guildId} of ratings) {
  console.log("guildId")
  console.log(guildId)
  const guild = await client.guilds.fetch(`${guildId}`);
  guildNames[guildId] = guild.name;
}

why would client.guilds.fetch not be defined?

solemn latch
#

is your for loop in the ready function?

misty sigil
opal plank
#

why do you need to fetch a guild?

#

not cached?

solemn latch
#

that too 👀

slender thistle
#

Nae I don't I'm feeling too fucking bad

opal plank
#

why am i not nicknamed Nerf This! ?

#

Tim is nicked

proven lantern
#

it is. this works ```const guild = client.guilds.cache.get(${guildId});

opal plank
misty sigil
#

tim has ceert dev

opal plank
#

thats booli

earnest phoenix
opal plank
#

.get() is extension of a map, not a fetch

proven lantern
#

this doesn't work though const guild = await client.guilds.fetch(`${guildId}`);

solemn latch
#

i dont think fetching is possible until the client is ready.

opal plank
#

oh, yeah

#

good catch Woo

#

comepltely forgot about it

zenith terrace
#

woo better notable mmLol

proven lantern
#

this is happening after the login event

solemn latch
#

as in after client.login? or your doing it inside the event?

opal plank
#

that wouldnt matter

proven lantern
#

after client.login

opal plank
#

unless he's awaiting it, and i dont even think .login() is a promise

#

you NEED to wait for the ready event

#

it is a promise

solemn latch
#

i thought it is a promise, just a promise for the login, not the ready.

opal plank
#

not checking internals, but i assume it should return when its ready

solemn latch
#

well being ready and logging in are diffrent right?

opal plank
#

logic would say no

proven lantern
opal plank
#

unless they doing some messy shit internally

#

which is highly possible

proven lantern
#

i made it a promise

solemn latch
#

ready happens after guilds and channels are cached, logged in is after the token is verified.

#

maybe im wrong on that

opal plank
#

but login should happen after client has been constrcuted

#

it would seem highly wrong if they were doing the other way around

#

hmmm maybe not

#

still wouldnt do it, personally

solemn latch
#

its been awhile since ive looked

#

yeah

#

agreed

opal plank
#

i havent looked at the internals, but d.js is notorious for having spaguetti noodle code

proven lantern
opal plank
#

i'd still put it under ready

#

just to be safe

#

cuz d.js™️

solemn latch
#

even not djs, its probably best to use events anyway.

proven lantern
#

the code is invoked from the message event so the client is ready

opal plank
#

then there should be no reason for it not to work

#

client.guilds.fetch() is valid

proven lantern
#

i agree

opal plank
#

but once again, why do you need to fetch each guild?

#

you should have them in cache

proven lantern
#

i want it to use fetch so it has the fallback to getting a live copy if the cache is empty

opal plank
#

im out of ideas as to why that'd be erroring

#

where is that line of code?

#

show some context around it

proven lantern
#

this works

opal plank
#

clientPromise?

proven lantern
opal plank
#

what is clientPromise?

proven lantern
#

clientPromise


module.exports = Promise.resolve(new Discord.Client());```
#

useless

#

but i made it

opal plank
#

i dont get why you'd do that but okay

#

can you log client right after you await it?

#

i'd personally JUST emit client once its been passed on ready

proven lantern
#

that's the client

opal plank
#
//index.js
const client = new Promise((res) => {
IPC.on('client', (client) => res(client));
})



//export.js
const _client = new Client();
_client.on('ready', () => IPC.emit('client', client));

janky as fuck, but should give you an idea

#

this way you assure the client being sent is already ready

proven lantern
#

all my code is invoked by client.on("message",()=>{}) so i know the client will be ready

#

i was using msg.client.guilds.fetch originally

opal plank
#

im unsure why thats happeneding then

#

client not being ready was my last idea

gritty bolt
#

im getting failed to connect errors on mongoose after moving my code to my ubuntu server

#

everything works fine on my computer

#

any ideas as to what could be happening?

proven lantern
#

maybe your ubuntu has a firewall rule that doesn't allow outbound traffic

#

@gritty bolt ^

gritty bolt
#

its allowing everything

proven lantern
#

maybe there are environment variables set on your local machine that need to be on the ubuntu server

#

or maybe your ip address is whitelisted and the ubuntu server isn't

gritty bolt
#

how do I fix that

#

oh nevermind here we go

lyric mountain
zenith terrace
#

awaits

gritty bolt
#
TypeError: fields.flat is not a function```
lyric mountain
#

That's what I call a patient code

lyric mountain
gritty bolt
lyric mountain
#

Do node --version

earnest phoenix
#

anyone know mongodb on nodejs?
i need opinions on something

lyric mountain
#

(don't remember if that's the right cmd)

gritty bolt
#

v10.19.0

lyric mountain
#

Yeah, definitely, update node

gritty bolt
#

yeah isnt the latest 14 or 16?

#

20?

lyric mountain
#

You need to set a version because it won't update major versions

gritty bolt
#

ohh

lyric mountain
#

Go with 14

gritty bolt
#

im on 15 now

lyric mountain
#

Now it should run fine

earnest phoenix
#
//Create the mongo client
var MongoClient = require("mongodb").MongoClient;
const mongo = new MongoClient(settings.server.mongo, { useUnifiedTopology: true }, { useNewUrlParser: true }, { connectTimeoutMS: 30000 }, { keepAlive: 1} );

//Connect to mongo database and start listening for requests.
mongo.connect(err => {
  if(err) return console.error(`[Server] ${err}`);

  //User endpoints
app.get('/user/:discord_id', [router, jsonParser], (req, res) => { require("./endpoints/get-user.js")(settings, req, res, err) });
app.put('/user/:discord_id', [router, jsonParser], (req, res) => { require("./endpoints/update-user.js")(settings, req, res, mongo) });
app.delete('/user/:discord_id', [router, jsonParser], (req, res) => { require("./endpoints/delete-user.js")(settings, req, res, mongo) });
app.get('/all-users', [router, jsonParser], (req, res) => { require("./endpoints/get-all-users.js")(settings, req, res, mongo) });

app.listen(settings.server.port, console.log(`[Server] Server is now online and listening on port ${settings.server.port}.`));

})

Inside the get-user.js file, I do not close the connection with mongo.close(), is it bad to not close connections?

#

Here's the get-user.js file

module.exports = (settings, req, res, mongo) => {

  const collection = mongo.db("GameCord").collection("user-data");
  collection.find({ "discord_id": req.params.discord_id }).toArray()
  .then(user => {
    if(!user) return res.json({ code: 404, data: "The specified user could not be found in the database." });
    if(user) return res.json({ code: 200, data: user });
  })
  .catch(err => {
    console.error(`[Server] ${err}`);
    return res.json({ code: 500, data: err });
  });

}

pure lion
#

Why do you want to close the connection

earnest phoenix
#

Usually after an operation of some sort, you'd want to close the connection, right?

pure lion
#

No

earnest phoenix
#

Like inserting a user

#

Oh right

pure lion
#

It doesn't reconnect or anything

earnest phoenix
#

ye but not like this ofc

pure lion
#

You just terminated the connection for the entire process

earnest phoenix
#

ye ye but the old way I done it, was not to connect to it in the main file, but to connect to the db in get-user.js file

#

u get me?

pure lion
#

But you're passing mongo into the function

copper cradle
#

you shouldn't do that, just create the connection on your main file and then pass it to the rest

#

you don't need to close it

earnest phoenix
#

Right good haha

pure lion
#

You never need to close the connection

copper cradle
#

it's not as if something bad would happen if you don't close it

earnest phoenix
#

The way I done it before was so each endpoint would have to connect to the db and perform the action.
Rather than in the main file, connecting to it and passing it to the rest

#

Would there be a difference?

#

For that way, i'm assuming i'd need to close the connection, right?

pure lion
#

That's horribly inefficient

green kestrel
#

anyone else having problems with the thumbnail and images displaying improperly in embeds atm

earnest phoenix
#

I thought so lol

green kestrel
#

discord is completely ignoring them

pure lion
#

The cdn is taking a shit

green kestrel
#

ah.... but these arent on a cdn

#

theyre on my server, and its stripping out the urls from the embed

#

it was working until like a few minutes ago

#

and the code isnt changed

#

it even did it on a bot which has been running for months

pure lion
#

Probably the API then

#

Discord is a stable platform

opal plank
#

Discord is as stable as GME

toxic jolt
#

Hello pls help me i how to unban all ban's for discord.js v12

fierce ether
#
module.exports = class BaseEvent {
    constructor(client, {
        name = null,
        botPermissions = new Array()
    })
}``` syntax error bottom line?
quartz kindle
#

constructor(client) {}

#

not constructor(client, {}))

fierce ether
#

but my commands file works like that?

quartz kindle
#

and instance variables have to be set to this

#

otherwise they're global

fierce ether
#
    constructor(client, {
        name = null,
        guildOnly = false,
        aliases = new Array(),
        botPermissions = new Array(),
        memberPermissions = new Array(),
        nsfw = false,
        ownerOnly = false,
        cooldown = 3000
    })```
#

that works?

quartz kindle
#

that code makes no sense, its not even a valid object

fierce ether
#
const path = require("path");

module.exports = class Command {
    constructor(client, {
        name = null,
        guildOnly = false,
        aliases = new Array(),
        botPermissions = new Array(),
        memberPermissions = new Array(),
        nsfw = false,
        ownerOnly = false,
        cooldown = 3000
    })
    {
        const category = (dirname ? dirname.split(path.sep)[parseInt(dirname.split(path.sep).length-1, 10)] : "Other");
        this.client = client;
        this.conf = { enabled, guildOnly, memberPermissions, botPermissions, nsfw, ownerOnly, cooldown};
        this.help = { name, category, aliases };
    }
};```
#

thats the full code

quartz kindle
#

ahh

#

its a destructured argument

#

now it makes sense lol

fierce ether
#

i used to use this but i tried something new

#
module.exports = class Command {
  constructor(name, category, aliases, userpermissions, permissions, cooldown, hidden) {
    this.name = name;
    this.category = category;
    this.aliases = aliases;
    this.userpermissions = userpermissions
    this.permissions = permissions;
    this.cooldown = cooldown;
    this.hidden = hidden;
  }
}```
#

should i just revert?

quartz kindle
#

nothing wrong with this

fierce ether
#

ok thanks

#
[ERROR][registry:38][01:46 am] TypeError: Cannot read property 'set' of undefined```
#

but idk why?

hasty mulch
#
Ignoring exception in command weather-embed-test:
Traceback (most recent call last):
  File "/home/pi/.local/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "/home/pi/Documents/Room_Sealer/cogs/room-sealer-weather.py", line 404, in _weatherembedtest
    snowdepth = res6['response']['periods']['snowDepthCM']
TypeError: list indices must be integers or slices, not str

How do I get this read as a dict?

earnest phoenix
#

owoThink list is list, dict is dict.

long marsh
#

imagine

hasty mulch
earnest phoenix
#

huh

fierce ether
#
client.t("general/ping:CONTENT")``` how can i pass this through as a param instead of client?
near plover
#

anyone happen to have an opinion on an effective way to deprecate a bot in favor of another?

earnest phoenix
#

hey, all of a sudden my bot does not start at all?? i'm using discord.js and when i do node . it does not input any messages, even the start message. i believe this is because someone added it to a very big server and the bot can not handle it. is there a solution to this? thanks.

tribal siren
#

yo, whenever i try making a music bot it shows this error

#

FFmpeg/avconv not found!

#

what's wrong?

pale vessel
#

did you install ffmpeg

fresh verge
#

How could I detect whenever my bot is invited to a server, and get the server it was invited to, so I could make my bot have like a welcoming messaged whenever it is invited to a server.

tribal siren
pale vessel
#

are you on windows?

tribal siren
tribal siren
pale vessel
#

oh

#

then i can't help you with that

tribal siren
#

oh alright

sacred trout
#

cannot import name 'checks' from 'utils' (/opt/virtualenvs/python3/lib/python3.8/site-packages/utils/init.py)

#

how do i fix this??

tribal siren
#

idk never did that

earnest phoenix
#

so don't help if you don't know how to?

#

🙄

tribal siren
#

i thought it's the way of doing

earnest phoenix
#

anyways you need the guildCreate event

tribal siren
#

is that an event

rocky hearth
#

yup

tribal siren
#

oof

sacred trout
#

cannot import name 'checks' from 'utils' (/opt/virtualenvs/python3/lib/python3.8/site-packages/utils/init.py)

zenith terrace
#

there is a github that shows a lot of events lol, idk if its all of them

earnest phoenix
#

✨ the docs ✨

zenith terrace
#

too lazy to check as well lol

earnest phoenix
#

or alternatively the actual client class

zenith terrace
#

that works too

warm junco
#

my bot is written entirely in python, would you guys recommend i switch over to javascript or is there no significant benefits to doing so?

earnest phoenix
#

that is entirely subjective and dependent on your use case

rocky hearth
#

For TS: I'm trying to create a local package, which I could use in my other projects.
idk how do I import the typings which I have defined in that package. (just like we do for djs)
Do I have to export each interfaces/types I hv created?
I hv already enabled declaration and hv set its path to lib/typings.
So I hv my typings folder in my lib folder for that local package

warm junco
earnest phoenix
#

Hey is this the correct code of a user join date in a server?
message.author.joinedAt

rocky hearth
warm junco
near plover
#

JDA is also a good choice with a fairly good community behind it

sacred aurora
#

anyone know how to fix 403 error?

mellow kelp
#

status code 403 means unauthorized

#

you need some sort of authentication on your request

sacred aurora
#

hmmm

#

the script work from local

long marsh
#

A philosophical question:

  • If I had a base class that had a method named preRun ... that I wanted to mandate all extended classes call in their run function ... how would I mandate that? If it's even possible at all?
sacred aurora
#

but when on host it get that error

#

can i post a link here?

#

try to open it

#

maybe its banned from the server country

#

??

mellow kelp
long marsh
#

Interesting.

#

Can you call an abstracted method, assuming it's implemented from the extended class?

mellow kelp
#

yea

long marsh
#

Well, I guess you can do anything in JavaScript 😄

mellow kelp
#

something like

public abstract class BaseRunner {
    public void preRun() {}

    public void run() {
        preRun();
        actualRun();
    }

    public abstract void actualRun();
}
long marsh
#

ElCholo, are you saying this:

class A {
  processCommand(){
    run();
  }
}

class B extends A {
  run() {
    console.log('does some shit');
  }
}
#

Damnit, I was typing that exact same thing out 😄

#

Nice.

mellow kelp
long marsh
#

I wanted to confirm that was a thing.

mellow kelp
#

well that's more or less the idea

long marsh
#

WAIT.

#

That looks like Typescript 👁️

#

I'm assuming the same thing can be applied to JavaScript as well though, right?

#

Same principle?

mellow kelp
#

yeah

#

anything that uses classes

#

well js doesn't have abstract

#

but you can just use an empty method or something

#

i was writing in java tho pEnSiVe

long marsh
#

Yeah, I can create an empty method that throws an error

#

So, if it's unimplemented by the extended class ... it won't override the error that's thrown.

#

big brain

mellow kelp
#

that's a really good idea actually

long marsh
#

Not really - I should just switch to TypeScript 😄

mellow kelp
#

unimplemented methods by throwing an error

long marsh
#

Yep

#

Just a thought 🤷‍♂️

mellow kelp
long marsh
#
const { Command } = require('discord.js-commando');

export default class CommandHandler extends Command {
  constructor(client, commandInfo) {
    super(client, { ...commandInfo });
    this.title = commandInfo.title;
  }

  async process() {
    this.run();
  }

  async run() {
    throw new Error('Method "run()" must be implemented');
  }
}
#

Nice.

#

Then I can control the flow however I want.

#

Thanks for that, ElCholo!

mellow kelp
#

no problem vibing

#

object oriented gang

long marsh
#

Lol

#

It was my first language

#

OOP

#

But, probably not a language you'd expect lol

mellow kelp
#

hm

#

c++?

long marsh
#

Nope

#

Actionscript 3.0

mellow kelp
#

what

long marsh
#

Flash gang

mellow kelp
#

ohh flash

long marsh
#

Adobe Flash's language

#

#rip

mellow kelp
#

that's pog

#

rip flash pEnSiVe

long marsh
#

Yeah, it taught me a lot. It was basically Java.

mellow kelp
#

~~seems 😔 ~~ would've seemed interesting if flash was still a thing

long marsh
#

Yeah, it's too bad

tribal siren
#

how to make a command cooldown?

#

is it about database?

#

like

#

db.set(`cooldown_${message.guild.id}`, 1)

long marsh
#

I use cache for cooldowns

#

Idk what db.set is

vague panther
#

quick.db

visual kettle
#

Hey guys I want to make a special bot for my server

zenith terrace
#

Yea everyone does const db = require('quick.db')

visual kettle
#

I know very base level

#

I want like if anyone registers it will show in show command

#

Like 1.SimpBoi 2.Sandy

#

Anyone their

tepid leaf
#

isn't quick.db a datastore?

#

that edits a json.squilt file or something like that?

#

if you plan using data store i recommend mongoose because on certain hosts you won't be able to use quick.db such as heroku

near plover
#

postgres would be a bit better in certain circumstances than mongoose imo

rocky hearth
cobalt spruce
#

@earnest phoenix js let binary = args.slice(0).join(" "); if (!binary) return message.channel.send("Please input some Numbers."); if (/^[10 ]+$/.test(binary)) return message.channel.send('good').catch(e){ message.channel.send(e) } will this work?

normal sage
#

have you tested it? @cobalt spruce

cobalt spruce
#

and it didnt

normal sage
#

there’s your answer

cobalt spruce
#
if (/^[10 ]+$/.test(binary)) return message.channel.send('good').catch(e){
                                                                         ^

SyntaxError: Unexpected token '{'
    at wrapSafe (internal/modules/cjs/loader.js:1053:16)
    at Module._compile (internal/modules/cjs/loader.js:1101:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
    at Module.load (internal/modules/cjs/loader.js:985:32)
    at Function.Module._load (internal/modules/cjs/loader.js:878:14)
    at Module.require (internal/modules/cjs/loader.js:1025:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at registerCommands (/home/runner/Eqhost/src/utils/registry.js:14:23)
(node:260) 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:260) [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 bobs

normal sage
#

remove the “{“

#

in front of (e)

cobalt spruce
#

do i use return ?

normal sage
#

i’m not sure

#

but that’s what the error says

cobalt spruce
#

how i define e as error

rocky hearth
#

That is not the correct way to handle errors

cobalt spruce
rocky hearth
#

U need to learn handling errors for promises

rocky hearth
cobalt spruce
#
if (/^[10 ]+$/.test(binary)) return message.channel.send('good')
#

in this line

restive furnace
#

please read about arrow functions

#

yes(x => x) is a arrow fn for example

rigid sandal
#

dudes

#

I got !kick to work

#

then everything else broke

#

xD

#

I hate the discord lib

#

xD

restive furnace
#

no, you're gonna need to learn JS or what ever you use for making bots BEFORE jumping into bots

pearl trail
#
.catch(err => //do something with err)
earnest phoenix
#

it's the libs fault, not mine!

tribal siren
#

guild.channels.cache.get(ch => ch.position === 1).send(embed)
Cannot read property 'send' of undefined

#

anyone knows how to deal with that?

pearl trail
#

is that get must be filter?

lament rock
#

yeah. That get needs to be a filter unless you have an ID you can pass to get.

#

get only accepts type K which GuildChannelManager type K is a string

pearl trail
#

also, if you are in djs v12, it must be

message.guild.channels.cache.filter(x => x.rawPosition == 1)
lament rock
#

filtering by rawPosition can return a CategoryChannel

pearl trail
#

ohh

tribal siren
lament rock
#

Then you possibly got a VoiceChannel or something else returned from the filter which doesn't implement the TextBasedChannel interface. In your filter, you should specify the x.type https://discord.js.org/#/docs/main/stable/class/GuildChannel?scrollTo=type

crystal wigeon
#

hey guys

#

umm anyone know about erelajs?

#

var qStr = args.join(" ");
if (!qStr) return;
let vc = member.voice.channel;
if (!vc)
return channel
.send("❌ You need to be in a voice channel.")
.catch((err) => {
console.log(err);
logger.error(err.stack);
return;
});
qStr = qStr.toString();
const res = await client.music.search(qStr, author);

#

this is doing weird stuff

#

if i a pass a YT uRL it says missing args

#

but when i put the url directly in the search it returns results

#

tf?

#

but it works when i type things like "sad music"

lament rock
#

Try using let instead of var

crystal wigeon
#

didnt work

lament rock
#

Oh. Hm. Log the value of it before it goes into the search. That error makes it seem like it's undefined

crystal wigeon
#

but if i do this
qStr = "https://www.youtube.com/watch?v=-7EZdOLWN18"
console.log(qStr, typeof qStr)
// qStr = qStr.toString();
const res = await client.music.search(qStr, author);

it works

Subscribe and hit the bell icon to get notified as soon as I release new content!

Spotify, iTunes, Soundcloud, Google Play, Amazon or MP3
http://bit.ly/gohanangertheme

Follow me on Social media
http://bit.ly/socialmediafhm

Please read before using my music in your own work
http://bit.ly/usageofmymusic

Credits:
Cover by: Friedrich Habetler...

▶ Play video
crystal wigeon
lament rock
#

don't assign the qStr as something definite. Allow arbitrary input and log the values

crystal wigeon
#

ik

crystal wigeon
#

you see the url? and "string"?

#

thats the logged value

#

that goes into search

#

i set the url directly to check if the search will return results and it is indeed returning

lament rock
#

Don't set it directly and log the values and see if they're the same

crystal wigeon
#

ye

#

the values are same

#

see the no tracks found?

lament rock
#

then idk 02shrug

crystal wigeon
#

its just straight up weird ;-; like bruh if i set the string in the search directly it works but when i send it as input it doesnt tf

lament rock
#

try and read the source code to see why that error specifically is thrown

crystal wigeon
#

this the same url

#

and it works th

#

they dont say anything about urls

#

just a spotify plugin

#

nvm

#

im stupid

#

i fiugured it out

#

the url sent in input is lowercased

#

;-;

#

thanks

#

;-;

lament rock
#

XD

crystal wigeon
rocky hearth
tribal siren
#

hm aight then

#

thanks

rocky hearth
cinder patio
#

How did you know I was here pepowot

rocky hearth
#

discord tricks

cinder patio
#

Do you have the types property in your package.json

rocky hearth
#

yes, it is set to lib/typings

#

I'm getting intellisense though. But I want to import types/interfaces, so I could assign it to other objects

cinder patio
#

ooh

#

Where do you define your interfaces? Is it all in one file or across files

lament rock
#

You'll have to import the files you specifically export the interfaces/types in

rocky hearth
#

accross files. Only exports some of them which are required in the other files

cinder patio
#

yeah

pearl trail
lament rock
#

That's not the error

#

it'd say cannot read property channels of undefined

pearl trail
#

oh ._.

#

yeah

cinder patio
pearl trail
#

try message.guild

#

or,

lament rock
#

That's also not the error

#

example: VoiceChannel.send isn't a function

pearl trail
#

can it be..

const textCategory = await guild.channels.cache.filter(a => a.type == 'text')

textCategory.filter(x => x.position == 1).send('hi')
```?
lament rock
#

unnecessary await. Also, you can chain conditionals in the filter.

cache.filter(x => x.type === "text" && x.position === 1);
pearl trail
#

ah yes, &&

lament rock
#

position 1 does exist.

#

Also wait. I just realized that Collection<K, V>.filter returns an Array

#

@tribal siren

#

What exactly are you trying to do, even?

tribal siren
#

oh rly

#
bot.on('guildCreate', async guild => {
  bot.channels.cache.get('806052726206627882').send(`UrgA is now in **${guild}**!\nThe total UrgA Servercount is ${bot.guilds.cache.size}.`)
  const embed = new Discord.MessageEmbed()
    .setTitle(`Hello **${guild}**!`)
    .setDescription(`I am UrgA, a great Discord Bot with over 130 Commands! Let me show you what I can do. My prefix is \`\`<\`\`, but you can change it on whatever you want simply by using \`\`<prefix {your new prefix}\`\``)
    .addField(`Just a little tip`, `If you have any questions about certain categories listed under, just do \`\`<help {that category}\`\` for more information!`)
    .addField(`Information`, `I can show Information about a Channel, User, Server and a Role! If something with the bot goes wrong, you can simply use \`\`<bugsubmit\`\` to submit a bug!`)
    .addField(`Moderation`, `I can Moderate Servers very well. For example, I can Kick, Ban, Unban, set Slowmode, Manage Nicknames, set your Welcome/Bye System Texts, set Autoroling, Mute/Unmute a user and so on. Great, isn't it?`)
    .addField(`Fun`, `I can show a Meme from Reddit, start a poll, show Zalgo version of a text, make some magic with your avatar (and not only). I can even show a cute Cat/Dog Picture!`)
    .addField(`Utility`, `I can show Coronavirus Statistics, set a Reminder and even do some math for you!`)
    .addField(`Roleplay`, `I can show some hug, kiss, slap and pat gifs, as well as show Simprate/Shiprate!`)
    .addField(`Logs`, `If you want to know whenever a Message is Deleted in the Server, whenever it is updated, whenever emoji is created/deleted, whenever a reaction is added and lots more? I have it all!`)
    .setFooter(`It's cool, isn't it?`)
    .setTimestamp()
    .setColor("BLUE")
  guild.channels.cache.filter(ch => ch.position === 1).send(embed)
    .catch(e => guild.members.cache.get(guild.ownerID).send(embed))
});```
#

this is what i try to do

rocky hearth
tribal siren
#

i understood it

cinder patio
#

filter returns an array, use find instead