#development
1 messages · Page 1560 of 1
move the target constant above the rest of the function
```message.author.id !== 376064908317425677
Ohhhhh, lol
Now I understand, because it has on the top to make everything work with target with it
i always put const's in the top
@copper cradle thanks u learnt me something again lol
always put var, const and shit on the top
i think that is better
Thanks too lol
did u edit the image lmao
why

i thnk binary is binary
real programmers use binary
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
Debug how do I do that?
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
you're trying to use a variable called target, which doesn't exist in that scope
using the mighty console.log
log the goddamn error
Tbh, it’s shit it never logs anything
i wonder how did u get verified dev (no offensive am Stupid on coding )

no
no
wat
you don't need that target variable
Idk my commands worked..
just remove the word target. from that code
no
lol
Lol..
If I remove target then what else can I do?
do know how i tell the bot not to reply on message that are not numbers
remove target. <-- dot
Alr
try to parse the message into an int, if it fails then that means the message contains other chars
@earnest phoenix You still haven't fixed that issue when we literally told you that 30 times? Wtf 
Which lol?
someone has to explicitly tell him what to do step by step otherwise he can't

bro
Unban worked...
yeah...
Thanks again
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
True.., but if I’m gonna be honest it harder to read docs than getting explained
of course it is, it's always easier when somebody else does it for you
yeah
I mean yes.. but if someone can explain to me I learn better 
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
It’s uh semicolons, and uh yea..
there aren't any semicolons there...
There are some people on YouTube, they will explain you for free
👁️ 👄 👁️


Really, there’s not many good youtubers
find LearnWebCode, he's having a good bootcamp series
Is it a youtuber?
fireship explains many useful concepts
traversy media
fireship is a really good one
and his videos are short and easy to follow
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
I don't think fireship is for beginners, though
\https://www.youtube.com/watch?v=PkZNo7MFNFg&ab_channel=freeCodeCamp.org
this is everything you need to know... in 3 hours
are you still not sure?
I’m sure I’ll learn something
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
wtf 
lol
lol
Thanks Java

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

It is tho
it is
I FUCKING KNOW! this shit was the main bug in my fucking reminders
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
heh
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)
lol thats not really bot development
How do I run a script which is defined in a subfolder, from my current folder in package.json?
some-folder/another-folder/script.js
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??
wdym by parent's package.json?
o
well you could do something like "dev": "cd the_folder && yarn dev"
will the terminal actually change path?
pretty sure it won't
A very high-level overview of the CLI compiler options for tsc
oh ok just got it
so with p flag, we specify the path of the folder to compile, right?
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')
}
Use isNaN
uhh
do u want the string "10001011" to be a number like 10001011?
or parseInt/float and then check if parseInt returned NaN
meh dont care about code
He definitely copied that from somewhere lol
i use if and then
what are the expected inputs and outputs?
idk what to do
i just want the bot , not allowing letters only number
ex: !command Hello
Reply : You Can Only Use Numbers
I already told you, use isNaN or parseInt/parseFloat
so u want the argument to be any number?
yes
idk how to inploment thoes
i saw this shit but nothing come to mind
It's a simple function call - if you don't know how to do that then maybe you should revisit a tutorial or two
y isNaN returns false for empty strings?
let binary = args.slice(0).join(" ");
function isnotnumbers(binary) {
if (isNaN(binary)) {
return message.channel.send("its not a number")
}
}```
sure, try it. That function is super unnecessary, though
make sure to call it
or just remove it
No... I was talking about the isNaN function
if (isNaN(binary)) {
return message.channel.send("its not a number")
}```
this all i did
and it worked
good
hello, how to get that server code in a string in this style for example: hello https://discord.gg/dbl teste
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.
Can you give more context? Why are you receiving these errors in the first place
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
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"
Ooh ok. lemme try
do u want invite link for any server, ur bot is in?
I want to isolate the code server on string
@cinder patio
uhh
if (isNaN(binary)) {
return message.channel.send("its not a number")
}```
What's binary defined as
binary might not be defined
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
isNaN accepts a string, though. You need to remove the wpace somehow
Yea i know, they can simply use a regex instead of checking if it's a number
/^[10 ]+$/.test(binary)
Does anyone here actually use GO for their discord bot?
Go compare?
Only asking because I'm thinking of lifting and shifting from DiscordJS to DiscordGO
Well how well do you know Go lang
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.
i mean sure but you'll suffer with it 🤷♂️
i advise you try Go before starting the lib
Oh, 100%
I would choose C over go for most things lol
Why?
Not trying to start a debate or anything, just genuinely curious why you'd want to hurt yourself
I mean C is fine if you know what you're doing
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 🤷♂️
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 != nilon. 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
wait there's no generics?
Nice things about go:
- Simple concurrency
gasp
Its a weird system
I dont entirely hate it
but i disliked it enough when using it to drop it
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?
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
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 😄
Oh, gotcha
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
Yeah, I'm used to that from using Python / JS lmao
I commonly see people try to compare Go with Rust
do I need to change something near
client.ws.ping
as I don't want it checking websocket
I don't think that's accurate, tbh
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
Yeah, they're just completely two different languages with different goals (as you stated)
There is no built in method for that
in the end its Speed of development vs Code security
Exactly
You can write code very quickly in go but it's maintainability can be incredibly low
You have to start a timer, send the message, then see how long the pronise took
Also, that's why I'm contemplating GO. For the lowered cache usage of NodeJS / DiscordJS & for the speed.
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
Granted, I know Tim has a great library regarding the cache 😄
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;
ah ok
Go and JS' speeds are actually a lil closer than alot of people think tbh
Cant really argue about the caching d.js is really bad at that
while DiscordGo is on the opposite end of the spec
i thought PermissionResolvable is array too*
you have d.js which is very high level and DiscordGo being very low level
If the issue is caching, its not a language problem, just use a different library or code a barebones one yourself
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
Agreed; however, GO does actually outperform NodeJS when RAM is compared
well...
sorta
when you're using it for discord you're not gonna notice any of that if you cache equal amounts
Correct. But, I probably won't.
I believe the DiscordGO library is a little lighter on 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)
}
}```
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
Caching will be the same in all languages unless you can make use of more efficient data types
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
How would you call for a user input using slash commands?
Like taking the message content.
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
But, Tim, I just wanna learn go 😢 -- someone tell me it's a good idea so that I can do it
Lol, kidding. Does anyone know of anyone who uses GO?

lol
Bot.TotalMembers = 0
Bot.guilds.cache.map(guild => Bot.TotalMembers = Bot.TotalMembers + guild.memberCount)
```Bot's total members is 0? This cannot be right.
Well, it’s your choice learning GO. Its a fast language and pretty useful. Error handling sucks tho
guildOnly: false,
what exactly is the feature of this command
Error handling is by far the biggest issue with go
Yeah, truth.
Some commands only work in DMs. guildOnly means that that command can only be run though a guild, aka a server.
Doesn’t the name explain it? The command can’t be used in dms.
literally chill lmao
I mean use it as like usually
Bot's members are uncached. You need to fetch them.
Not me.
should i say wrong or right
Feels bad man
f
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?
First of all, whoa Milo Murphy! Second, It is catched? Bot.guilds.cache??
do you actually have intents set though to actually allow it or tell it to cache 👀
No, I meant the users who are in one of the bot’s guilds.
Ooooooh!
So like this? guild.cache.memberCount
What did you command did you use?
Returns a single guild's member count
In order to get every guild's members count,
I upgraded discord.js from 11 to 12
Is this a glitch problem?
@stable eagle Didn't work. Still shows 0.
You have to do smth like this:
<client>.guilds.cache.reduce((res, guild) => res + guild.memberCount)
Oh
That's not needed for guild.memberCount
I've never heard of .reduce before.
It's <client>.guilds.cache.reduce((res, guild) => res + guild.memberCount, 0)
Thanks
Can anyone point me to a well-document command handling system for DiscordJS? I may actually entertain Tim's light library
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
@pale vessel Would this work? Bot.TotalMembers = Bot.guilds.cache.reduce((res, guild) => res + guild.memberCount, 0)
I think so
Please use markdown :)
Why assign it to Bot.TotalMembers ?
So I don't have to do that each time lol.
Make it a function
I am trying to be as efficient as posible.
Oh?
Otherwise the value is going to be static
Yeah
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;
}
isn't PermissionResolvable is also array of permissions? https://i.imgur.com/ZExbLUx.png
It could be
but not always
Maybe that's why it errored
Maybe no wtf?.length won't make it error
you mean !.length
@pale vessel Still 0.
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
I can use many command handler yea ?
@pale vessel PermissionResolvable[]
the type for cmd.botPermissions?
yes it should be PermissionResolvable[] lul
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?
isnt node-fetch deprecated
I guess this type is not supported anymore
isnt it request?
.-.
node-fetch isn't deprecated
request are looking for maintainer(s) iirc
dead lib tbh
o ok
im using node-fetch/axios
axios gang
I saw it in a bot yesterday
high five
thats simply a codeblock my dude
1 - this
but they got one in each thing
if you dont know the answer, please refrain from spreading misinformation
did you see this https://github.com/axios/axios/issues/2130
How do I make blocks side by side?
i never really noticed axios didnt have a logo
```lua
1 text
```
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
multiple fields
lua, ts and js should all work and be like that one you sent in the picture
Thank you very much I've been dealing with this since yesterday
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)
const getEmbed = await getChannel.messages.fetch({ limit: 1 })
console.log(getEmbed.id)``` am i doing something wrong? its undefined everytime
i gave you an example, do not copy paste
code?
ill pastebin, want my main and my usercount.js?
usercount
ok
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
whats your main file called
mint.js
@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?
mint is my bot name
try const client = require('../mint.js')
above module.exports
ok
Hah, that's not true.
do it also keep the client var in module.exports, probably dont but i get things wrong all the time
what
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)
h
h
you could just do message.guild.memberCount
i can?
yea .-.
whatever you named your message, yes
^
i would recommend NOT using embed builder
why not?
#development message i sent an example how to pass the object directly
````new Discord.MessageEmbed()``` literally just creates an object
thats literally it
and then each method adds another key on it
lol

i use that i literally make a new discord.embed
-30 respect
is that embedbuilder and im just stupid?
yes
ok well im gonna usee it in spite of you

well, warning was given, you can give water to the horse, but you cant force him to drink it
do i just do const { Channel, MessageEmbed } = require("discord.js");
anyone know why I might be having mongoDB connection errors on an AWS ubuntu server?
this is my first bot(in a while) i have lost all my skill so its back to day one
idk, im not smart
then why not optimise it and stop being stubborn?
idk, but you got that second part right, i am really stubborn, just ask people who have helped me code!
you should listen to them i came here yesterday with a mess and left actually understanding stuff
being stubborn wont help you improve lol
i never said i wasnt going to listen to them, im just trying to get a basic understanding of disc.js
Oh, I can recommend some vids
dont
dont use videos to learn js
#development message click here to see the whole convo i went about it
yea
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
i mean i am doing it as a little hobby
then its fine
ill work on it 3 - 4 times a week
There is some good vids
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

if you'd really like me to link me documentation on sending an object
There’s a 3 hour video, that learns you all the basics
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
you sounds like you didnt even read what i sent baldski
Yes, yes, I’m reading rn
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?
*closes google* nah i - i wasnt looking at video tutorials dont even worry
True, true, but yk sometimes they can be useful @royal laurel

setActivity() is the most used
thank you, but how do you get it show how many servers it’s in?
for example
playing !help in [insert number] servers
client.guilds.cache.size will give you the number
Watching 737373738388282 servers
that IS the status baldski
Oh ok
setActivity() IS setting status

thank you
np
also i’m not sure who baldski was calling he but i’m not a he sorry 😭
qt shiv is qt
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?
is your for loop in the ready function?
aye @slender thistle ye see that, bloodeh true?
that too 👀
Nae I don't I'm feeling too fucking bad
it is. this works ```const guild = client.guilds.cache.get(${guildId});

tim has ceert dev
thats booli
I want that pfp bloody clarckson
because thats a map
.get() is extension of a map, not a fetch
this doesn't work though const guild = await client.guilds.fetch(`${guildId}`);
i dont think fetching is possible until the client is ready.
woo better notable 
this is happening after the login event
as in after client.login? or your doing it inside the event?
that wouldnt matter
after client.login
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
i thought it is a promise, just a promise for the login, not the ready.
not checking internals, but i assume it should return when its ready
well being ready and logging in are diffrent right?
logic would say no
i made it a promise
ready happens after guilds and channels are cached, logged in is after the token is verified.
maybe im wrong on that
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
i havent looked at the internals, but d.js is notorious for having spaguetti noodle code
login is the last step for me
even not djs, its probably best to use events anyway.
the code is invoked from the message event so the client is ready
i want it to use fetch so it has the fallback to getting a live copy if the cache is empty

im out of ideas as to why that'd be erroring
where is that line of code?
show some context around it
this works
clientPromise?
what is clientPromise?
clientPromise
module.exports = Promise.resolve(new Discord.Client());```
useless
but i made it
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
//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
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
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?
maybe your ubuntu has a firewall rule that doesn't allow outbound traffic
@gritty bolt ^
its allowing everything
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
Oh my holy what's that?
awaits
TypeError: fields.flat is not a function```
That's what I call a patient code
Update node
it says im on the latest version
Do node --version
anyone know mongodb on nodejs?
i need opinions on something
(don't remember if that's the right cmd)
v10.19.0
Yeah, definitely, update node
You need to set a version because it won't update major versions
ohh
Go with 14
im on 15 now
Now it should run fine
//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 });
});
}
Why do you want to close the connection
Usually after an operation of some sort, you'd want to close the connection, right?
No
It doesn't reconnect or anything
ye but not like this ofc
You just terminated the connection for the entire process
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?
But you're passing mongo into the function
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
Right good haha
You never need to close the connection
it's not as if something bad would happen if you don't close it
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?
That's horribly inefficient
anyone else having problems with the thumbnail and images displaying improperly in embeds atm
I thought so lol
discord is completely ignoring them
The cdn is taking a shit
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
Discord is as stable as GME
Hello pls help me i how to unban all ban's for discord.js v12
module.exports = class BaseEvent {
constructor(client, {
name = null,
botPermissions = new Array()
})
}``` syntax error bottom line?
but my commands file works like that?
constructor(client, {
name = null,
guildOnly = false,
aliases = new Array(),
botPermissions = new Array(),
memberPermissions = new Array(),
nsfw = false,
ownerOnly = false,
cooldown = 3000
})```
that works?
that code makes no sense, its not even a valid object
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
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?
nothing wrong with this
ok thanks
[ERROR][registry:38][01:46 am] TypeError: Cannot read property 'set' of undefined```
but idk why?
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?
list is list, dict is dict.
imagine
Never the twain shall meet?
huh
client.t("general/ping:CONTENT")``` how can i pass this through as a param instead of client?
anyone happen to have an opinion on an effective way to deprecate a bot in favor of another?
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.
yo, whenever i try making a music bot it shows this error
FFmpeg/avconv not found!
what's wrong?
did you install ffmpeg
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.
is it another library
are you on windows?
bot.on('guildMemberAdd', async member => {
if(member.id == 'whatever your bot id is'){
console.log(`I am in the server ${message.guild}!`)
}
})```
oh alright
cannot import name 'checks' from 'utils' (/opt/virtualenvs/python3/lib/python3.8/site-packages/utils/init.py)
how do i fix this??
thats... incorrect
idk never did that
i thought it's the way of doing
anyways you need the guildCreate event
is that an event
yup
oof
cannot import name 'checks' from 'utils' (/opt/virtualenvs/python3/lib/python3.8/site-packages/utils/init.py)
there is a github that shows a lot of events lol, idk if its all of them
✨ the docs ✨
too lazy to check as well lol
or alternatively the actual client class
that works too
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?
that is entirely subjective and dependent on your use case
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
thanks for the input! ill probably stick to python then since i definitely have more experience with it, i was just wondering if there was some big advantage to js that i was missing, i guess for my use case of less, smaller servers python will do just fine
Hey is this the correct code of a user join date in a server?
message.author.joinedAt
The only, benefit I see for using js is better documentation + the guide to use it.
yeah thats something ive noticed, discord.js just seems more developed with a bigger community base. it should be fine though, ive had decent luck finding documentation and stackoverflow posts (so, so many stackoverflow posts) that can help me out with discord.py, i think i have a fairly good grasp on it now, at least for my needs (which, admittedly, arent much haha)
JDA is also a good choice with a fairly good community behind it
anyone know how to fix 403 error?
status code 403 means unauthorized
you need some sort of authentication on your request
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 theirrunfunction ... how would I mandate that? If it's even possible at all?
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
??
you could do something like an abstract "actualRun" method, and implement a "run" method in the base class that calls preRun and actualRun
Interesting.
Can you call an abstracted method, assuming it's implemented from the extended class?
yea
Well, I guess you can do anything in JavaScript 😄
something like
public abstract class BaseRunner {
public void preRun() {}
public void run() {
preRun();
actualRun();
}
public abstract void actualRun();
}
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.

I wanted to confirm that was a thing.
well that's more or less the idea
WAIT.
That looks like Typescript 👁️
I'm assuming the same thing can be applied to JavaScript as well though, right?
Same principle?
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 
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
that's a really good idea actually
Not really - I should just switch to TypeScript 😄
unimplemented methods by throwing an error
yeahhh that's a better option probably
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!
what
Flash gang
ohh flash
Yeah, it taught me a lot. It was basically Java.
~~seems 😔 ~~ would've seemed interesting if flash was still a thing
Yeah, it's too bad
how to make a command cooldown?
is it about database?
like
db.set(`cooldown_${message.guild.id}`, 1)
quick.db
Hey guys I want to make a special bot for my server
Yea everyone does const db = require('quick.db')
I know very base level
I want like if anyone registers it will show in show command
Like 1.SimpBoi 2.Sandy
Anyone their
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
postgres would be a bit better in certain circumstances than mongoose imo
Does this code mean, it is necessary to call the methods defined in run(), when implementng in child classes?
@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?
have you tested it? @cobalt spruce
there’s your answer
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
do i use return ?
That is not the correct way to handle errors
meh i dont need error
U need to learn handling errors for promises
ur program too
how i use else in if statments?
if (/^[10 ]+$/.test(binary)) return message.channel.send('good')
in this line
dudes
I got !kick to work
then everything else broke
xD
I hate the discord lib
xD
no, you're gonna need to learn JS or what ever you use for making bots BEFORE jumping into bots
.catch(err => //do something with err)
it's the libs fault, not mine!
guild.channels.cache.get(ch => ch.position === 1).send(embed)
Cannot read property 'send' of undefined
anyone knows how to deal with that?
is that get must be filter?
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
also, if you are in djs v12, it must be
message.guild.channels.cache.filter(x => x.rawPosition == 1)
incorrect. GuildChannel.position is a valid property
filtering by rawPosition can return a CategoryChannel
ohh
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
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"
Try using let instead of var
Oh. Hm. Log the value of it before it goes into the search. That error makes it seem like it's undefined
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...
the yt url and the typeof is the log there before the search
don't assign the qStr as something definite. Allow arbitrary input and log the values
ik
in here
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
Don't set it directly and log the values and see if they're the same
then idk 
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
try and read the source code to see why that error specifically is thrown
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
;-;
XD

the channel at 1st position doesn't exist
Feud, Do u hv answer for this?
How did you know I was here 
discord tricks
Do you have the types property in your package.json
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
You'll have to import the files you specifically export the interfaces/types in
accross files. Only exports some of them which are required in the other files
yeah
did you define guild correctly?
Importing types/interfaces is like importing actual objects
can it be..
const textCategory = await guild.channels.cache.filter(a => a.type == 'text')
textCategory.filter(x => x.position == 1).send('hi')
```?
unnecessary await. Also, you can chain conditionals in the filter.
cache.filter(x => x.type === "text" && x.position === 1);
ah yes, &&
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?
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
I wanted to say that, the get method is returning undefined because, the guild has no channel at position 1
i understood it
filter returns an array, use find instead

walking


