#development
1 messages · Page 934 of 1
you dont need any of that
thisIsACollectionOfMembers = {
47593875983 => GuildMember
92798728034 => GuildMember
29749497264 => GuildMember
...
}
for(let entry of thisIsACollectionOfMembers) {
console.log(entry) // [92749276497,GuildMember]
}
for(let [a,b] of thisIsACollectionOfMembers) {
console.log(a) // 27364972649
console.log(b) // GuildMember
}
for(let [id,member] of thisIsACollectionOfMembers) {
console.log(id) // 7928749827
console.log(member) // GuildMember
console.log(member.id) // 7928749827
console.log(member.user.username) // someusername
}
I have everything working, all I don't know how to do is set an interval correctly, when I did it it would just end up looping, how do I set it to wait the interval before sending the next message?
1 second
is this code inside an async function?
Yes
you can use the await keyword, combined with a promise and a timeout
to define an arbitrary amount of waiting
for example
await new Promise(resolve => setTimeout(() => resolve(),1000))
haven't used await before, where do I put the console.log in?
what do you want to log?
console.log(id)
anywhere in the loop
await new Promise(resolve => setTimeout(() => resolve(),1000)) {
client.users.cache.get(id).send("test")
console.log(id) // 7928749827
so like this?
you have the entire member object, you can send directly to it
member.send
and you did your promise wrong, its not a function you put things inside
It worked, thank you!
https://sourceb.in/a71a001c58
that is my battle command
the only problem is that it spams if they decline the battle
where user is the mentioned user
and your message.reply mentions the user
so it keeps mentioning the user, which keeps collecting
^
Well i didnt know what to do so i just copied the way it accepts it and copied and pasted and change it for declinding
hey quick question, does anybody know how long the verification on top.gg takes? heard it's about 1-4 weeks
there are a ton of things in there that could be done in a better way, but your problem will most likely go away if you simply fix your filters
what you want is for the filter to check if the message author matches the mentioned user, not if the mentioned user matches itself, which just makes it match all messages
hey quick question, does anybody know how long the verification on top.gg takes? heard it's about 1-4 weeks
@earnest phoenix yeah its true
but wrong channel
thanks for confirming and sorry
1-2 weeks usually
np
@quartz kindle so it would be for both filters const filter2 = m => m.content.includes('decline') && message.author.id === user.id
oh
because m is the message that the collector will collect
so if the author of the collected message matches the mentioned user
then do this
wait
@upper hinge your bot description is injected into the existing top.gg website, it is not a standalone page
so you have to account for all the existing html and css that the website already has
use the element inspector / dev tools in your browser, to check the existing css rules of your bot page
and modify them in your style tags
So it's part of the class content. How would I modify. I tried ```html
content {
background-color: blue;
}
nope
nvm
.
Well, more context please, can you show us the code?
you need a module.exports help = { name: "your name here" }
It came with another error
what is it
can someone tell me what i nede to do to upgrade this code https://hasteb.in/rehasinu.js to v12 other than changing RichEmbed to MessageEmbed
https://gyazo.com/608a7074d97e3c7707db5ecc5cb8d99c @rough walrus
I mean there's this list: https://discordjs.guide/additional-info/changes-in-v12.html
For example, message.member.voiceChannel is now message.member.voice.channel
It shouldn't be a challenge to just find whats changed with some control + f
@rain jacinth I don't know, I'm kinda new to discord.js so...
@rain jacinth you're inside a function body. You can't have key/values like that unless you're doing it for an object.
So i need to remove category?
No, you need to place it where it should be. I don't know what your intentions are for each key.
You should be able to export an object easily but you don't seem to be doing that and instead mixing it in the function body.
https://sourceb.in/be4bdbaeaa @sudden geyser
what
like that?
did you change anything? It doesn't look any different nor does it look like it'll work.
I took off the comma after the description
Do you have well knowledge on JavaScript?
Not really
Then you should learn more JS then attempt it again.
I have a question...
So Tim told me to type enable-pnpm in my terminal.
Does it need "npm" in front of it?
Anyone know how to fix this?
Does it need "npm" in front of it?
@clear wraith just try
Does it need "npm" in front of it?
@clear wraith no
Yes @rain jacinth
Are you trying to host your bot?@wild mist
Iam trying to host lavalink node
hi, does anyone know why i'm getting ```js
(node:12008) UnhandledPromiseRejectionWarning: DiscordRESTError [50035]: Invalid Form Body
embed.fields.1.value: This field is required
code: ```js
{
name: 'Mods',
value: ${mods},
inline: true
}
and mods is ```js
message.channel.guild.members
.filter((e) =>
e.roles.includes(
guild.mod.roles
.map((e) => message.channel.guild.roles.get(e))
.sort((a, b) => b.position - a.position)
.map((e) => e.id)
.join(' ')
)
)
.map((e) => e.mention);
is this d.js?
no, eris
does anyone have any good tutorials on how to setup ur bot on a vps
Uhh, I might be an idiot for asking this, but how exactly do bots use animated emojis?
Like :reeee: only returns :reeee: like a user
Ugh, I mean with <a:[emojiname]:[emojiid]>
<a:name:id>
then ur bot ain't in the server which the emoji came from
Nvm, I fixed it, sorry for not chilling, I've been trying to do it for an hour without asking my dev team first.
Turns out they have a better idea than me^^
does anyone have any good tutorials on how to setup ur bot on a vps
u can ask here, i don't think there r tutorials on how to set it vps up
There are better options....
Digital ocean is kinda over hyped
how do i have mutliple if statements in 1 line
@clear.error async def clear_error(ctx, error): if isinstance(error, commands.MissingRequiredArgument): await ctx.send('Please Specify The Number Of Messages You Want To Clear Example: +clear 10``')
if isinstance(error, commands.CheckFailure):
await ctx.send("You are not allowed to kick people")``
Else if?
hum
retype the code for me?
lol
No thx
ok ill do it myself thanks for your help
Unm ok
bruh
how do i make a role
like with my bot
as if i have a mute command
Check the docs
mkay
spoonnnnnn
you're not helping so dont even answer @earnest phoenix
Well I'm
You expecting to get spoon fed isnt gonna happen
if i wanted to create a role with my bot how would i do it? my current code is @client.command() @commands.has_permissions(administrator=True) async def mute(ctx, member: discord.Member): role = discord.utils.get(ctx.guild.roles, name="Muted") await member.add_roles(role) await ctx.send(f'{member.mention} Has Been Muted')
shush

Make me :)
simple as a block
lmao
glee

when you blocked someone bc they won't give you a code
while you haven't read the rules
lol
Plus I dont code in python

waiting for player number 2 to respond
How would i get my bot to delete the message it sent after a specific amount of time?
timeout option in v12
Would I do a .then(m => m.delete(amount));
that's v11
Ok
Ill check it out
for v12
delete({timeout:...})
I did the timeout option
But... It deleted the message I sent. Not the message It sent
Are you calling it on the right message?
Oof
Ok
But I think you can just do message.delete(time)
how to track who invited someone to my server using bot

@sudden geyser any guide ?
Read that wrong sorry

@earnest phoenix
Try this
@earnest phoenix already tried and check issues of this project at top my name

please help
Stop spamming
did i spam ?
Interested in free source code, bot ideas, or want to share your projects/commands? Check out https://sourcecode.glitch.me/
==== [ Source Code ] ====
https://discord.io/plexidev-sourcecode
➤ Patrons:
Mio
Duy
Respire
Matthias
LUAN
Conrad
Zhin
dndrhead
Far
Zoro
Julien-Alexandr...
See if you can get some help from this
*old
Well you should get the idea of the basic logic needed


If you want to track what invite a member used to join the server (I assume this is what you're asking for), keep a collection of all the invites in a guild and find the one where the usage count has increased. You'll also need to manage how you can access the old/new collection as well as updating it
@clear wraith if you still having the problem, you could just make let msg = await message.channel.send("whatever is in here")
then just do msg.delete
Ok
Didnt you need a timeout?
that's not how it works..
options is an object
so if it's options.timeout then it's object.timeout, which is { timeout: 3000 }
how do i make a listener for votes is js?
Reaction collector?
he’s talking about dbl votes
Oh
yes
The api
the same question as in #topgg-api btw
I would help but I'm on mobile.... plus I'm reading.....
ok thanks anyway
is there a way to purge DMs from a bot?
I've been testing with this account for some stupid reason and now it's just filled with unneeded messages in DMs
@ancient comet go to #topgg-api
i was reading it uwu
I defined a channel, in v12 how can i get that channel ?
Huh
like i have
let chx = db.get(`welchannel_${member.guild.id}`);
and i want to get this channel, like member.channel.get but this doesn't work
What is db?
it doesn't matter the db
def __init__(self, bot):
self.index = 0
self.bot = bot
self.update.start()
def cog_unload(self):
self.update.cancel()
@tasks.loop(seconds=60.0)
async def update(self):
await self.bot.change_presence(
activity=discord.Activity(application_id=686460052982464522,
name='something',
type=discord.ActivityType.playing)
)
self.index += 1```
(discord.py 1.3.3)
I wrote this code for my bot to change presence, but sometimes it stops working and outputs this error.
Traceback (most recent call last):
File "C:\Users\USER\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\tasks\__init__.py", line 73, in _loop
await self.coro(*args, **kwargs)
File "C:\Users\USER\Desktop\MaruBot\Cogs\BotUpdater.py", line 39, in update
await self.bot.change_presence(
File "C:\Users\USER\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 943, in change_presence
await self.ws.change_presence(activity=activity, status=status, afk=afk)
File "C:\Users\USER\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\gateway.py", line 512, in change_presence
await self.send(sent)
File "C:\Users\USER\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\gateway.py", line 482, in send
await super().send(data)
File "C:\Users\USER\AppData\Local\Programs\Python\Python38\lib\site-packages\websockets\protocol.py", line 555, in send
await self.ensure_open()
File "C:\Users\USER\AppData\Local\Programs\Python\Python38\lib\site-packages\websockets\protocol.py", line 803, in ensure_open
raise self.connection_closed_exc()
websockets.exceptions.ConnectionClosedError: code = 1006 (connection closed abnormally [internal]), no reason
I tried setting logging level to DEBUG, but it outputs so much error text that I'm not able to realize what is wrong.
How do I fix this :(
member.guild.channel @earnest phoenix
wdym sabin?
nvm
Then do I just have to reconnect if that error happens?
If a guild is unavailable and you do guild.owner.send(), will you get Cannot read property 'send' of null?
probably,
not everything is executed in a 'message' event @earnest phoenix, so is this piece of code
thats what he's doign
I should try it thanks
Angelo, it normally works but now it didn't. I got that error so I want to know what caused it
the guild ur trying to access is either unavailable or the owner isn't cached
should I first fetch it using client.users.fetch(guild.owner.id)?
no
oh okay
message.guild.members.get() would work, or with a cache in between
oh that's not the problem tho
wha
the syntax
what r u trying for the syntax to be incorrect?
Does anyone have a free hosting site other than heroku?
Do not. use a free hosting site
and a staticman (github app)
It also says 550 hours, which means you haven't verified your heroku account by adding a debit card
they work good
If you add one, you get 1000 hours a month
my bot will stop on 20 May
yes they are
IMO glich are bad :c
Why do you say Heroku is bad? Plenty of people use it without any issues
Not all people can afford vps
i use glich for tests
Let's not say free hosting is bad
Cause you have an issue right now lol?
what r u trying for the syntax to be incorrect?
@digital ibex you said you don't exactly know how to code it to get a member. I said that I know that so that's not the problem
Thanks for your help as you said what the solution should be
lmfao
there has only been two major downtimes since the start of this year

What do you use?
soo, its not free?
no, its free
you are just leeching of somebody else
Lmfaooo
no
^
no, but sure
So what happens if they decide they don't want to keep paying for it?
bot dies
Do you have a back up option ?
@candid granite just add a credit card on your account to verify it and you can get more hours
@candid granite just add a credit card on your account to verify it and you can get more hours
@earnest phoenix wait that’s all I need to do?
Perhaps I should have read the email
The host has to keep its lights on somehow.
lol yeah thats why i dont want to get a "free hosting site"
@rain jacinth have you tried defining it.
exact same thing, idk y ur saying it as a host u host ur bot on doesn't pay their billings
where your bot can be destroyed at any time
ok, please
Let people choose their hosting lol
No need to dis others hosting
Everyone got circumstances
nah, im dissing free hosting
please
you could use an aws server? that uses a free trial
Free trials require credit card
get a burner credit card then
uh lol
ok, then get a credit card
Not everyone has one.....
Not everyone here is a working man or women
So are kids
i dont have a job either
I dont either
@turbid bough hi hello, define a good host 2 host ur bot on plz
Lol
uh, anything that is official and is not expensive, and has 100% uptime with full support
aws google or whatever im using rn
digitalocean
I mean there's this pinned message: https://ptb.discordapp.com/channels/264445053596991498/272764566411149314/576818380498010112
Dont use digital ocean lol
Was sent almost a year ago.
Overhyped af
dg is overrated
Google Cloud tbh is a great choice in my opinion. The trial is $500 for an entire year
idk digitalocean works fine?
Galaxy gate is good
if u like dg, may aswell use heroku since ur bot dies like, after a few days
They have good pricing
Not all free hosts are bad.
There are some like heroku that many bots use.
A host is a host after all, ain't any different from the rest. Some extra perks, maybe yeah.
The main difference is that paid hosts are more reliable and might have some extra perks.
Beginner developers would choose free hosts, and that's not a bad thing. They're only starting off so that's fine.
Advanced programmers might choose paid ones over free ones because they're more reliable and most of the paid ones have extra perks that catch our eyes.
After all, it's just a user preference, it's an opinion so I won't say "All free hosts are good".
People can view things differently so whatever it is, a host is a host, unlike any others, with either less or more perks.
gg is good when it works
Thx for the summary
@digital ibex What are you talking about with bots dying in a couple of days? lol
Specifically in terms of heroku
I had my bot running on heroku for 5 months
r u like
Honestly this convo about free hosting vs. paid hosting always goes no where. if you want to use free hosting do so but know what you're getting
Damm mobile auto correct
you could use paid hosting whilst you have the free credits too
oh wait, you need a credit card riiight
Lol
costs go up as you scale dynos vertically, adds more ram cpu, and those costs increases like A LOT as ur ram & cpu increase since most web apps can't run on a single dyno, the rapid price increase is something almost all heroku users have to face at some point
(literally copied into my own words from google)
oh btw, if you have the github education pack, you get one free hobby duno for 2 years
no they're not
especially if you choose to host a bot
aws you get like 100$
what is a good free host?
ok, for ur host, what do u look for?
TypeError: fields.flat is not a function Why do i get this error?
Simo what Node.js version are you using.
whatever is free means either YOU'RE the product, or the free product has so many limitations it isn't even worth it
What do you want people to do? Sell their kidneys or some?
And not use free hosting
???
what do you even mean
sell kidneys for 5$ a month??
If they cant afford paid hosting
a vps is like 3 bucks a month
Let them use free hosting
Stop saying it's bad
it's not that deep
what is a good limit for a bots ram?
IT IS bad though
Not everyone has 3$ everymonth to spare
you cannot argue that it isn't because it's proven it is
You might
everyone has 3$
Not everyone
I sure as hell dont
if you don't have 3 bucks a month to spare you should look into maybe not hanging out on discord making a bot...?
Unless you work or get your parents to pay for it
how long is this convo gonna last
what is a good ram limit tho
Not all parents are that generous
3 dollar is GENEROUS?
Simo what Node.js version are you using.
@sudden geyser v10.15.3
which u'd expect for $3
Upgrade to Node.js v12.
no matter how bad you say free hosting is, people are still going to use it and you cant change that
keep in mind, that is MONTHLY and not WEEKLY
Lol your parents might give you money
🗿
if you eat dinner with your familiy you should be more generous than asking for 3 dollars
Not others
Upgrade to Node.js v12.
@sudden geyser How can i upgrade it?
You can just mow your neighbors lawn lol
Dont assume others are in the same situation as you
Alright time to see how this shitshow ends.
i think you have a money problem then if you cant afford 3 dollars
You might want to end this conversation here since it's not getting anywhere
I think you are ungrateful for those 3$
Every month lol
if you're complaining about not having 3 dollars to spend a month, uhm, maybe find a temp job?? help out your neighbours
3$ a month is what i spend as a student, is nothing
i worked in retail for 4 months because i didnt want to leech off my parents money anymore
Some families work differently
it's not that deep
Retail is oof
do your family earn 3$ an hour?
My dad doesnt give me money as a student
Then work for it
thuan, have you even read https://discordapp.com/channels/264445053596991498/272764566411149314/71220978438399597:)
Some people make compromises lol
the problem is that you want to invest into your bot but not do the giving money part of investing lol
Investment doesnt have to be money lol
I don't see what's stopping you from doing odd jobs
And it kinda does
You gotta have good hosting
I doubt you can make something great for absolutely 0$
Ok just to be clear I have a paid host
let target = message.mentions.users.first() || message.author;
.addField("Roluri:", `${target.roles.filter(r => r.id !== message.guild.id).map(roles => `\`${roles.name}\``).join(" **|** ") || " No Roles"}`, true)
error
Cannot read property 'filter' of undefined
We ain't talking about me
We talking about other people
why are u guys doing off topic in here ?
we're talkin' bout me 🙂
it's still about development kinda
i mean
not at all
Take a one month job and you can host a bot for 2 years or more
Then he is fucked in life
disabled people can still work
That's not nice
Disabled people can still work
You might want to end this conversation here since it's not getting anywhere
- shivaco
Please keep this for development issues only, and continue this somewhere else.
i got a good host, works perfectly fine for me, no issues with it, i got enough memory and storage is perfectly fine for me
so
im not gonna get into that with you lol
anyways, yeah. imma stop talking about this
I told you guys you are doing off topic
this whole thing started just cuz i said my free host is gud lmao
So, can somenone help me please?
hm?
@earnest phoenix roles are undefined
Sabin an instance of User does not have the property .roles
You're probably looking for a GuildMember
User is just a generic "id, name and icon"
User isnt part of a guild
You can get the guild member object then get the user object.
and that's why guild.users and client.members don't exist, while client.users and guild.members do
uhm, ok
message.guild.members?
yes that exists
that is every user in this server, with properties belonging to this guild (roles, permissions)
ah nvm, message.guild.members.cache
no, message.guild.members.cache (in v12)
yeah
nvm xd
with discordjs, how to know the number of ppl connected into a vc? I tried looking at message.guild.me.voice.channel when the bot is connected to a vc, but cant find anything related to that
that voice channel should also include a list of members in that channel
pretty much
hm
yeah, it is
ye it is
thats weird coz the only mention of members I can found is here https://cdn.lumap.me/ur58tolg.png
well
thx!
probably because members is a getter
Why this is not working
I want the bot image to move
img.vert-move {
-webkit-animation: mover 1s infinite alternate;
animation: mover 1s infinite alternate;
}
img.vert-move {
-webkit-animation: mover 1s infinite alternate;
animation: mover 1s infinite alternate;
}
@-webkit-keyframes mover {
0% { transform: translateY(0); }
100% { transform: translateY(-10px); }
}
@keyframes mover {
0% { transform: translateY(0); }
100% { transform: translateY(-10px); }
}
Is anyone here?
I do not understand JavaScript
that is not javascript
I don’t know much what languages libraries are.
That's okay. You can always learn.
this.activeConnections[conn.id].lastPing = Date.now();
if (this.activeConnections[conn.id].timeout) clearTimeout(this.activeConnections[conn.id].timeout);
else this.activeConnections[conn.id].timeout = setTimeout(() => {
conn.close(4991);
this.activeConnections[conn.id] = undefined;
}, (50 * 1000))
so this is my server side sort of thing for heartbeats, will this work
the interval is 45s so every 45s a client sends a ping
it's a hard thing to try smfh
trial and error
Is it here to ask for help ?
Is it possible to do this: https://discordjs.guide/command-handling/#dynamically-reading-command-files
but in TypeScript
I have issues creating and assigning a role with the same command
whats your code
Hang on
if (command == 'setcolor') {
if(message.channel.guild == client.guilds.cache.get('600516863688048640')) {
var eenGuild = message.channel.guild.channels;
console.log(args[0]);
if(args[0].length == 6){
goodHex = 1;
console.log("testing");
eenGuild.roles.create({
data: {
name: args[0].toUpperCase(),
color: args[0].toLowerCase(),
}
});
message.member.roles.add(message.member.guild.roles.cache.find(role => role.name == args[0].toUpperCase()));
}else{
message.reply("The color you specified is invalid !");
}
}
}
It's a color role, and I'm trying to create it with the supplied hex, and assign it to the member that entered the command
Well, the issue I have is that it doesn't assign the role
It creates it, but it fails to assign it
whats a bit after?
ok well
you need to await
For the Promise ?
yes
just do
let createdRole = await eenGuild.roles.create({
data: {
name: args[0].toUpperCase(),
color: args[0].toLowerCase(),
}
});
await message.member.roles.add(createdRole);
but it wouldn't even get there
In here have anyone whoes are best music bot maker??
as ur doing if(message.channel.guild === id)
In here have anyone whoes are best music bot maker??
@arctic juniper ??
ok, same thing
It does work though
kinda, but doesn't change anything
the cache stores guilds not ids
u should really use ===
Can do
so
i'm just a bit confused, how, js message.channel.guild = Guild message.channel.guild.id = GuildID and ur checking Guild === GuildID
or am i dumb, idk, i don't use d.js
read the docs
I do if(message.channel.guild === client.guilds.cache.get('600516863688048640'))
Which is basically Guild === Guild
Works, thank you all 
@white anvil would that import just work on just .js files? or does it also work if the commands are in ts?
for the path just omit the file extension
like i do this
files.forEach(async (file) => {
if (file.includes('template') || file.includes('category_info')) return;
const command: any = await import(`../commands/${folder}/${file}`).then((v: any) => v.default);
and it works fine
with ts files
Hi. I decided to learn javascript and I wanted to test something i learned yesterday out on my existing bot so I changed the log in to
var BotOn = `Logged in as ${client.user.tag} with a uptime of ` + client.uptime;
client.on("ready", () => {
console.log(BotOn);
});
TypeError: Cannot read property of 'tag' null
I'm new to programming so if this is basic stuff I'm sorry
what version of discord.js?
12.2
Hey guys, quick question. Do you also experience what seems to be memory leaks with Discord.js?
ok, soo, how do i fix this? https://img.thaun.dev/rr1zh.png
i have set my node verson to 12.16.3 but still getting the same error, if anyone knows
i managed to fix it
@glass crag they are not memory leaks, they are just how discord.js is designed to work
it caches everything it can to be able to provide all the functionality it offers
using intents and cache sweeping can help control a big part of it
@turbid bough use NodeJS.Timer
I DBScript
@white anvil Its from discord.js tho
You Russian?
but i think i should just not use typescript anymore
js you have like everything working
and with typescript everything breaks lol
pretty much lmao
like it is its own language trying to make a wrapper, but that wrapper requires some weird ass setup
the Object is possibly 'null/undefined' errors are usually very useful
stops you from calling properties on undefined values
having it strict actually forces you to exhibit good code practices
ok wtf i fixed it
it works
it actually launched
hmm, but it cant find the .ts file
does it work? https://prnt.sc/sjm2n4
though, the thing i like with typescript atleast, that it has nice autocomplete
@earnest phoenix https://tryitands.ee
@earnest phoenix https://tryitands.ee
@tight plinth 🙂
@white anvil so, ive tried your import function for those files, and it does not seem to want to import it.
Or is there something missing on the ts file that might hinder it to compile?
do you have a default export in the file you are importing
i dont think so
you need a default export
const myThingThatIWantToExport = {};
export default myThingThatIWantToExport;
ts sucks
esm is weird as well, i mean, isnt require perfectly fine? what is the need for having a complicated esm system?
esm uses static importing and throws errors that it finds when parsing instead of at runtime
@white anvil so, something like this:
import { Message } from 'discord.js';
import { Command } from '../app';
export class PingCommand implements Command {
execute(message: Message, args: string[]) {
message.reply('pong');
}
}
const command = new PingCommand();
export default command;```
in fact u can just do
import { Message } from 'discord.js';
import { Command } from '../app';
export default class PingCommand implements Command {
execute(message: Message, args: string[]) {
message.reply('pong');
}
}
aight
then then when u import
const commandFile = await import('path to file').then(i => i.default);
const command = new commandFile()
wait, import returns a promise?
ok, so im still getting the same error message
"Error: Cannot find module 'commands/ping.ts'"
u have a syntax error then
that doesnt give me very much info
i press start
wait
you are trying to run a typescript file with node?
dont use typescript smh
you mean app.ts?
what does your typescript config look like?
i took it from the discord.js config
it seems that it is transpiling into an esm module
{
"compilerOptions": {
"strict": false,
"moduleResolution": "node",
"declaration": false,
"removeComments": false,
"alwaysStrict": false,
"pretty": false,
"module": "commonjs",
"target": "es2019",
"lib": [
"esnext",
"esnext.array",
"esnext.asynciterable",
"esnext.intl",
"esnext.symbol"
],
"sourceMap": false,
"skipDefaultLibCheck": true
}
}```
yeah thats a weird one lol
or idk i cant remember where i took it from
i still think youre just trying to execute typescript code with node
the stack trace has app.js in it
probably compiles to a .js?
could be tbh
probably has source and build on the same folder?
ill try and see if it is able to search for js files
can you try compiling this from cli and using node to run it
so, it managed to find ping.js
where are you hosting your bot
thats the problem
no im not even joking
its an issue with glitch
ip ban iirc
literally anything else

ok, so it definetly does compile the ping.ts file
soo, the js file looks like this:
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class PingCommand {
constructor() {
this.guildOnly = false;
this.args = [];
this.name = "ping";
}
execute(message, args) {
console.log("Command Executed: Pong");
message.reply('pong');
}
}
exports.default = PingCommand;
okay but does app.js import that file
fun fact, no it doesnt
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.ts'));
also please get a build directory
tell that to visual studio who made it default that way
you can edit your tsconfig 

._.
somewhere in user..presence.activities
Probably need the precense intent as well
yup
Hey. Is any of these better?
str.split(/ +/)
str.split(' ')
is there a way to include files to build with tsconfig?
docs says str.split(/ +/) is better
ow okay thanks
@nocturne grove the first one will treat any number of consecutive spaces as one
the second one will treat each space independently
oh that's useful. Thanks
that's why the first one always was in my index for splitting message.content to arguments
yup
alternatively you can also use \s
to match any kind of space-like character, not only regular spaces
oh well I think nobody would use that in their Discord message
probably not

thats the cache size
the cache only contains users that you receive data for, ie: online users, users that interact with discord, send messages, etc
whenever a user "shows up", your bot will receive information about it and put it in the cache
so your cache grows over time as users come and go
part of the guild_members intent right?
stop
if (fn(val, key, this))
^
TypeError: fn is not a function
👀
Classic.
its a problem with the discord.js node
and don't copy paste blindly
I DIDNT COPY PASTE
never heard of fn in discord.js
C:\Users(name)\Desktop\qBot\node_modules@discordjs\collection\dist\index.js
thats a file path if it helps
Why would that help
not much
u g h
send the whole code file
what node.js version?
node --version
and discord.js version while you're at it
Your package.json
12.2.0
and now the whole code
sure you havent read the stacktrace upside down?
yeah?
p-pastebin?
hastebin*
h
posted the first letter of hastebin
means that he person is sending small bytes of the link after time
must be lagging
did you create an event for every command
@earnest phoenix process.setmaxlisteners(12);
why not
It's an error for a reason
cause you should never have multiple on messages
yikes
It prevents memory leaks
??
What the fuck

why are you adding an eventlistener to each command lol
You only need 1 listener
how else do i use it
I have 1 listener and 20 commands...
do you read the docs lol
Make a command handler
The docs shows you how to make a commandhandler is what i meant
u g h
pepega fucking clap
client.on('message', (message) => {
if(message.content === 'ayy') {
message.reply('lmao');
} else if(message.content === 'bruh') {
message.reply('moment');
}
});
there is 2 commands in 1 listener
daym only one eventhandler
big brain i know
btw, im kinda struggling with this class command here
and im trying to give it values
but it just returns undefined
@earnest phoenix process.setmaxlisteners(12);
@pure lion hmm
app.ts
export interface Command {
default: Command;
command: string;
guildOnly?: boolean;
args?: string[];
usage?: string;
aliases?: string[];
cooldown?: number;
execute(message: Message, args: string[]);
}
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
commandFiles.forEach(async (file) => {
if (file.includes('template') || file.includes('category_info')) return;
console.log("Loading Command: " + file);
const command: Command = await import(`./commands/${file}`).then((v: Command) => v);
commands.set(command.command, command);
});```
ping.ts
```ts
import { Message } from 'discord.js';
import { Command } from '../app';
export default class PingCommand implements Command {
default: PingCommand;
cooldown: 2;
command = "ping";
execute(message: Message, args: string[]) {
console.log("Command Executed: Pong");
message.reply('pong');
}
}
or is it like i need to create a new object for it to work?
you need v.default in the import
yeah, but same result.
@earnest phoenix process.setmaxlisteners(12);
@pure lion heyy ```(node:1090) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 message listeners added. Use emitter.setMaxListeners() to increase limit
@earnest phoenix dont do this bruh
again failed
he has 11 commands, thats why
makes sense
do you have mutliple .on('message') statements
Where do the dbl events go?
I am using a command handler
They are client based if im not mistaken and cause I have two folders, one for client one for guild
do you have mutliple
.on('message')statements
@white anvil no
wel lyou have 11 message listeners defined somewhere
do you have one nested in something
if (perms < cmd.conf.permLevel) return;
cmd.run(client, message, params, perms);
client.setMaxListeners(100);
}```
Nesting issues make code harder to read and slow your code down generally...
@earnest phoenix where is your message listener
@feral pivot deeply nested code isnt usually slower its just ugly
@earnest phoenix update node
Tq
anyhow, how does dbl events work, do they work when the bot comes online or like seperate events?
dbl events have no relation to discord bot clients
so they are seperate events then?
yes
@earnest phoenix where is your message listener
@white anvil events/message.js
show
Jacher, i understand now. I can feel my brain melting of my stupidity like "what am i doing wrong".
i found my answer, it is now stuck in my brain.
now, can eslint not be more annoying? https://img.thaun.dev/8jri2.png
yeah, strict is kinda too strict for me
looking for a web developer. dm me pls (:
go to fiverr.com
-needdev @waxen current
@waxen current
DBL is not a place to find developers for jobs. You can try and put a request on Fiverr or Freelancer. Please do not post the request again. Doing so may result in punishment.
you don't use phpstorm?
php?
webstorm?
Yeah my bad, webstorm
No, webstorm is from intellij, i usually use visual studio community
Do you prefer it over webstorm?
and i feel like every intellij is like always its own program, not like "all in one"
well, i use vs community the most, and i havent used webstorm at all
I just use phpstorm for anything related to js, node & web dev (since it has support for them)
A bit overkill but I feel like it helps me write better code ngl ¯\_(ツ)_/¯
I'm not a bot I swear
I don't know, dont you also have to pay for it yearly?
Yeah you do; I have Jetbrains student license though
It's pretty expensive >.> But it does have a lot of good features
hey guys i have a question, what version of discord.js use ffmpeg-static?
so, my music bot works fine using links however when I send my response to try to get a video the bot would wait for the 10 seconds to be up and then time out
let response;
try {
response = await message.channel.awaitMessages(msg => 0 < msg.content && msg.content < videos.length + 1 && msg.author.id == message.author.id, {
maxMatches: 1,
time: 10000,
errors: ['time']
});
} catch(e) {
const noselection = new Discord.MessageEmbed()
.setColor('#de0000')
.setTitle(" Video selection timed out.")
return message.channel.send (noselection)
}
const videoIndex = parseInt(response.first().content)
video = await ytdl.getBasicInfo(videos[videoIndex - 1].videoId) ```
for reference
hmmm
Why does this not output my results? Any MongoDB guys know how to properly do this? This just returns parent process info and the collection of guilds
client.database.collection('guilds').find().sort({
fcount:-1,
limit: 3
})```
@earnest phoenix v11 or v12? v12 uses max instead of maxMatches
v12
use max in favor of maxMatches like Tim said
thanks tim and Flaz
ever since i started using visual studio + typescript, im beginning to vision that im writing c# again
someone who will help my FIveM is set in Japanese I tried reinstal again it is the same
ask dream to change it for you
hi
message.channel.guild.members.filter((e) => e.roles.includes(guild.mod.roles.map((e) => message.channel.guild.roles.get(e))
.sort((a, b) => b.position - a.position).map((e) => e.mention)))
``` anyone have any ideas its getting the last role? so it'd return
[ '<@&1234235678678>', '<@&123456787653>' ]
``` but it only return the second values properties in the array, any idea why's that?
i'm trying to access both
what the heck
i dont even know what that code does
well
why are you double mapping plus sorting inside a filter function?
i have two arrays, ```js
[ 'id1', 'id2' ];
// and
[ '1id', '2id' ];
