#development
1 messages · Page 1853 of 1
works for me
suspense works without ssr
no i thought the only way to use it was to ssr a module file and import it on the client
2021-08-23T07:17:59.697942+00:00 app[Worker.1]: (node:4) UnhandledPromiseRejectionWarning: DiscordAPIError: Missing Access
2021-08-23T07:17:59.697953+00:00 app[Worker.1]: at RequestHandler.execute (/app/node_modules/discord.js/src/rest/RequestHandler.js:154:13)
2021-08-23T07:17:59.697954+00:00 app[Worker.1]: at runMicrotasks (<anonymous>)
2021-08-23T07:17:59.697982+00:00 app[Worker.1]: at processTicksAndRejections (internal/process/task_queues.js:95:5)
2021-08-23T07:17:59.697995+00:00 app[Worker.1]: at async RequestHandler.push (/app/node_modules/discord.js/src/rest/RequestHandler.js:39:14)
2021-08-23T07:17:59.697996+00:00 app[Worker.1]: (Use `node --trace-warnings ...` to show where the warning was created)
2021-08-23T07:17:59.698007+00:00 app[Worker.1]: (node:4) 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)
2021-08-23T07:17:59.698070+00:00 app[Worker.1]: (node:4) [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.
How do I have my bot check when a user DM's them if its a attachment or not? and if so, how would I redirect that to a channel?
k
in which library
djs
v13, right?
Yeppers
a message has an attachments property (https://discord.js.org/#/docs/main/stable/class/Message?scrollTo=attachments)
if the .size of that is bigger than 0, then the message has an attachment
now to get the attachment, do first() on the attachments property
as for redirecting, you have two ways
sending the url and re-uploading
both have caveats
Put the url as the image property
Yeah, but how would I get the url from the user DMing the bot?
Attachment#url iirc
What is iirc?
if i remember correctly
Yes it's attachment.url
So get the attachment from message.attachments, get it's url and send it in an embed with the image property set to { url: "url" }
huh?
I am confused.
I don't even know how to get the message
lol
I know how to set it as a image in the embed.
Just don't know how to get the attachment from the DM
that's like the first steps of making a bot
client.on("message")
if (message.channel.type == "dm") {
const embed = new Discord.MessageEmbed()
.setColor('GREEN')
.setAuthor(`Pending Verification`)
.setimage()
}```
How would I get the literal IMAGE URL tho
How do I get a message a user sends to the bot
takes a deep breath
message.attachments
check if it has a size greater than 0
if it does get the first attachment
firstattchment.url
set this as your image url
Maybe you should take a deep breath for my next question
I still don't get the code behind it, maybe you could just show e by example...
why are you afraid to experiment and try whatever comes to your mind
you won't always get everything first try and that's fine
that's how you learn
you've got steps on what you have to do
read the docs and just try
I have, I just don't understand :/
I learn by example, and some do not come, but it looks like you guys have the answer, and ik you want me to learn, which is why you didn't hand me the code when I asked my inital question. But it would be much less time if I just had the code in hand at this point
as im not understanding
haha
Uh, just the part where I need it to folter out what is a attachment and what isn't.
like, I understand the size (0) thing, but idk how to use it in my code
message.attachments
check if it has a size greater than 0
if it does get the first attachment
message.attachments returns a collection of all attachments in the message
The more you quote the docs, the more questions I have xD
if there wasn't anything attached, it will be empty, therefore, size === 0
"it would be much less time if I just had to code to hand it in at this point" that's the most infuriating sentence I've heard in my entire 1.5 year career of helping people in #development
Well, not that I am expecting someone to make it lol
The docs are easier to understand than us because they don't assume you have advanced knowledge of javascript
....
If you're making a bot, you should have knowledge about what an object means
Yes, but since the embed has text in it, if they send a message, it will spam the embed int the channel
So I need a filter
that tells weither or not its a image
Its frustrating at this point lol
that's totally not what cry said
are you reading anything i'm saying lol
the only thing you really need to be concerned about is whether the attachment is actually an image or not
if(content.includes === message.attachment){}?
no
Thats whats popping into my mind
you aren't reading anything what i'm saying
^
Exactly the same as saying I don't understand French because I haven't learnt it
and I haven't, so I don't understand it LOL
Idk French lol
FOUND THE ERROR
Well, I do
The error is my brain
TypeError: Type DJSUser has no property named iLearntJSBeforeMakingABot
lol
Erm, soooo
message.attachments contains a list of attachments if they exist
its a collection, so it has the size property
therefore message.attachments.size will tell you how many attachments there are
it returns 0 if there are none
0 is falsey, so you can use an if directly on it
if(message.attachments.size) { there are attachments on this message }
putting an e in falsy 
then you have to get one of the attachments from the list, usually messages will only have one attachment, so you can simply get the first one using .first()
You're falsey
so message.attachments.first() gives you the first attachment
The person can also post a link attachment though
then you have to check the attachment type
attachments have a type prop
i love how embed types've been deprecated for 4 years now and discord didn't touch shit about them
like they deprecated embed types ageeeeees ago but haven't introduced an alternative
@drowsy crag
seriously? An ad for a crypto pump server that has only one channel?
uhh
I kinda got stupid over the past weak.. 😅
How do i get the name of each of those domains?...
just the name
since when I just try to get domain it returns object
Array.map
? Idk how to use maps ...
content.domains.map(s=>s.domain) ,will return a array of all domains ig
what type of action is bot added to a server in audit log?
you have to fetch all members
in file functions.js: js const economy = new Discord.Collection(); Reflect.defineProperty(economy, 'getCash', { value: async function getCash(userId) { const data = await UserSchema.findOne({ _id: userId }) return data ? data.cash : 0 }, }); module.exports.economy = economy
in cash.js: js const { economy } = require('../../Exports/functions.js') let a = await economy.getCash('123') console.log(a);
But it's not working. No errors. What am I doing wrong?
what is that code supposed to do?
why are you adding the function to a collection if youre not using the collection?
How do i filter it
the same way you did
But didnt work
to use a function defined in another file
did you fetch all members?
thats not what i asked
guild.memberCount.filter is not a function
thats not what i said
Then idk how to fetch all members
async function getCash(userId) {
const data = await UserSchema.findOne({ _id: userId })
return data ? data.cash : 0
}
let a = await getCash(Sinedx)
console.log(a);```
what does that log?
what is the djs v12's event called that detects a leaving member
a number from the database object
then it works?
yes
but I want to get the function from another file
guildMemberRemove
but why are you attaching the function to a collection using reflect?
probably bc I did it in djs v12 in sql
no good reason
then dont lol
in file functions.js: js module.exports = async function getCash(userId) { const data = await UserSchema.findOne({ _id: userId }) return data ? data.cash : 0 }
in cash.js: js const economy = require('../../Exports/functions.js') let a = await economy.getCash('123') console.log(a);
Now what's wrong here
what does that log?
nothing
wdym nothing
then your problem is elsewhere
how do i detect boosts? Is there any event for that or something
what could possibly be?
idk, you need to show your full code, otherwise nobody can help
a guildMemberUpdate with premiumSince defined
in user-economy.js: ```js
const mongoose = require('mongoose')
const reqStr = {
type: String,
required: true
}
const reqAmount = {
type: Number,
required: true,
default: 0,
}
const UserSchema = mongoose.Schema({
_id: reqStr,
cash: reqAmount,
bank: reqAmount,
bankLimit: reqAmount
})
module.exports = mongoose.model(user-economy, UserSchema)in functions.js:js
const UserSchema = require('../../Schemas/user-economy.js')
module.export = async function getCash(userId) {
const data = await UserSchema.findOne({ _id: userId })
console.log(data)
return data ? data.cash : 0
}in balance.js:js
const UserSchema = require('../../Schemas/user-economy.js')
const economy = require('../../Exports/functions.js')
module.exports = {
name: "balance",
aliases: ['bal', 'cash'],
usage: "!balance",
category: 'Economy',
description: "Check your wallat balances.",
async callback ({message, args, client, text, prefix}) {
let a = await economy.getCash('123')
console.log(a);
})
}```
So far this is it.
Works fine when I do this in balance.js: ```js
const UserSchema = require('../../Schemas/user-economy.js')
const economy = require('../../Exports/functions.js')
module.exports = {
name: "balance",
aliases: ['bal', 'cash'],
usage: "!balance",
category: 'Economy',
description: "Check your wallat balances.",
async callback ({message, args, client, text, prefix}) {
async function getCash(userId) {
const data = await UserSchema.findOne({ _id: userId })
console.log(data)
return data ? data.cash : 0
}
let a = await getCash('123')
console.log(a);
})
}```
Means you're not calling the getCash function
sounds like you are swallowing your errors
economy.getCash() would throw an error
because economy IS the getCash
because you're doing module.exports = function getCash
so you're saying the module = getCash so there is no economy.getCash
Like tim said
Pretty sure u can make async functions and use await
DiscordAPIError: Missing Permissions
at RequestHandler.execute (/app/node_modules/discord.js/src/rest/RequestHandler.js:154:13)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async RequestHandler.push (/app/node_modules/discord.js/src/rest/RequestHandler.js:39:14)
at async GuildChannelManager.create (/app/node_modules/discord.js/src/managers/GuildChannelManager.js:112:18)
at async Client.<anonymous> (/app/index.js:38:26)``` why is my bot sending 10 of these each second lmao
cuz ur doing something your bot doesn't have permission to
well we can't do much without code
Take a look at the last part of the stackstrace
index.js line 38
You’re somehow calling the guildchannel manager
Do you try to fetch all channels or something related?
No I think he's trying to create a channel but doesn't have perms to
I was trying to create a log channel if there wasn't one in the server already
the bot doesn't have perms to
that's why it was sending so much messages, as it was being fire based on incoming messages
It has every square ticket, except administrator
if he doesn't have perms
Clearly not
the error sais your bot doesn't have perms to
You may wanna handle the error to see which guild is the issue as well as dropping any related actions if the permissions are missing
Trying to contact the owner, a channel or basically leaving the guild
How do I terminate the discord.py bot
tried using exit()
but the async for loop before it doesn't complete
and it exits
then await it
Then how do I import function in node.js
I tried:
const { getCash } = require()
But still nothing
await exit?
no, await the async loop
async for msg in channel.history(limit=limit):
print(f"{msg.author}: {msg.content}")
writer.writerow({"username": f"{msg.author}", "message": f"{msg.content}"})
exit()
// a
module.exports = 10
// b
const test = require("./a.js")
console.log(test) // 10
@quartz kindle ...
no, await the async loop
What if I had to export multiple functions from a.js?
async await for msg in channe.....
put it in an object
module.exports = { a, b, c }
You could say:
module.exports = {
function1,
function2
...
}
or should i create another async funtion for loop and then await it?
ERROR
(node:32) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 message listeners added to [Client]. Use emitter.setMaxListeners() to increase limit
(Use `node --trace-warnings ...` to show where the warning was created)
Logged in as Lyxon#2505
C:\Users\Mustikk\Desktop\Projects\Lxyon\data\Lxyon.exe:1
MZ�
SyntaxError: Invalid or unexpected token
at Object.compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1031:15)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:94:18)
at Object.execute (C:\Users\Mustikk\Desktop\Projects\Lxyon\data\commands\software.js:5:25)
at Client.<anonymous> (C:\Users\Mustikk\Desktop\Projects\Lxyon\index.js:182:41)
CODE
module.exports = {
name: 'software',
description: "Attaches our software.",
execute(msg, args) {
const zipFile = require('../Lxyon.exe')
const attachment = new Attachment(zipFile);
msg.channel.send(`Here is our software.`, attachment);
}
}
can anyone help me?
bot runs but when i try to run comamnd it gives this error
idk, im not a python dev, but most likely yes, put it inside an async function, and await the function before exit
help me plzzzz (╯°□°)╯︵ ┻━┻
you cant require an exe file wtf
what
Wouldn't Buffer.from work?
what are you trying to do?
send my setup.exe
you want to send the file to discord?
yea
then you have to read the file with fs not with require
require is to load and run js code
how can i make it
with fs
suck
i made it
like
msg.channel.send('Here is our software.', { files: ["../Lxyon.exe"] });
and it didnt attach file but sent message
;-;
@timber fractal
luckie curb
so i use this to mute people as mute command (https://srcb.in/UQxMwCDJoF) and i use this code to unmute them https://sourceb.in/cUGH7HhIqi but why doesnt this unmute them altough it does unmute them when they are automuted?
can someone help?
@quartz kindle do you have any ideas, its the code from earlier
only now with mute command
intents?
Does it words with a('string')?
yes
then idk
ok
u can tell it to this friend
does anybody know?
@fading warren
can you help?
wdym?
tim do you have an idea
can anybody help please
ok so, is it intentional that only 2 roles can use the mute command?
whats most normal to code with?
context-dependent
yes
that are staff roles
everything works fine, it mutes them etc. sets the duration and reason it only doesnt unmute them
you do acknowledge that this command will ONLY be usable on your server and by those 2 roles right?
//a.js
module.exports = function getUserFromMention(mention) {
let matches = mention.match(/<@!?(\d+)>/);
if (!matches) return;
return message.guild.members.fetch(matches[1]);
};
//b.js
const fn = require('./a.js')
let fetched = await fn(arg[0])```
Something like that?
ok, where's the unmute command code?
@lyric mountain https://sourceb.in/cUGH7HhIqi
that'll only work if you export default
else you have to use the same name you declared on the source
not using es6
yes
I mean "type" = "module"
that's the automatic unmute code
you said the manual unmute is not working
oh, i meant the automatic
but mentions is not alway with @!
the automatic unmute code only works with automutes not manual mutes
on mobile it appears only with @
then that probably means there are some inconsistencies between your auto mute and manual mute code
like forgetting to save it
checked, couldnt find
There is a ? there means character before that is optional
checked in the database, the document is in
I dunno a lot about regex tho 
just giving some opinion :<
send your manual mute code
Yo
Still need help?
console log the date
yes
sure
I have a hunch for whatever reason you're accidentally muting for way longer
Hmm
are you able to console.log the schema?
yes
@split hazel this is the automute schema
it works with the same schema only different strings
no that is fixed
i gotta remove that
that is nothing
so what could it be
auto only, didnt make unmute command yet
has anyone found something?
where's the automute code?
firstly when you check on mongo atlas is the mute request there and just stays?
that's the unmute...
yeah
I'm asking for the automute one
he said the unmute works with the automatic but fails with the manual mute
yes it doesnt get deleted
is that the autounmute code you sent above?
automute: https://srcb.in/uvJz348j3L
autounmute: https://sourceb.in/cUGH7HhIqi
mute.js (manual mute): https://srcb.in/UQxMwCDJoF
any errors at all?
by the way the member fetching in unmute can completely stop the unmutes when a member leaves the server
you should add a catch to just remove it
no errors
or check the user beforehand
and in the auto unmute are you able to add a line that logs all of the mutes returned by the request?
i have no idea how it works, when i try whats on the site it does something completely different
I also tried this but that didnt give any error
Did you use any breakpoints?
no
i did, it says like debuger auto attached and doesnt give any error
it logs nothing
its broken
cuz it should log 1 at least
it added this little red arrow
how can i fix
it should log 1 cause that one has expired
for testing you should only make your mutes minutes or seconds long
i made it 0 hours
hi
i muted someone for 0 hours
so it should log it
and for the others i only muted 1 hour
and that was super long ago
how can i fix this
pls help
wait
hold up
@split hazel
isnt it like if i do at expiretime.setHours(expiretime.getHours() + 1) that for example if the hours of expiretime is 3, it will be like 3+1 so it does 31 hours?
@split hazel ?
like right here
that works fine
if i could have a moment of your time
use momentjs
will ✨ everything ✨ be ✨ fixed ✨ finally if i would use that?
that would be great
yeah it might be
i heard it's a pretty good lib for time things
i wish tc39 releases Temporal soon
probably not but its an easier alternative
why not?
what is the problem in my code?
momentjs is no longer maintained
so it has bugs
but mostly fine
probably
then ill use that
It still says not maintained
what happened to moment
its the biggest date manipulation library
apparently their reason is interacting with moment directly manipulates the date which people "complain" about
thats so stupid
apparently this is what they recommend to use instead https://moment.github.io/luxon/#/?id=luxon
Immutable date wrapper
not gonna lie looks much more user friendly
@lyric mountain Is it normal that Contabo has every week a small internet outage?
I experinced them 4 times since last week
luxon takes away the biggest burden of moment, which is having to maintain their own set of date-time constants like timezones for example
luxon uses everything that comes built in the browser and node instead
but at the cost of those components not being updatable separately
which means unless you're constantly updating your node/browser to the latest versions, you're always gonna lag behind timezone updates
i havent really been paying attention but at times all shards do just randomly disconnect
Do they reconnect?
no don't think so
what region are u using?
is it the status page?
ye ig
last question: Can you move the region, didnt found anything in there FAQ
you can, don't remember how tho
okay, you can. I will move it when we have more issues
well my shards always attempt to reconnect
and it fails?
no
usa region is newer, so freshier hardware
plus it's closer to discord servers
My instance disconnects from Mongodb and gets this error:
okay, I will try it out, thx for the info
does anyone know how to make a cool ass bar for like a currently playing song
i have the current timestamp and the full duration of the song
so i wanna do it like
Could someone help me? When i select first_option in the dropdown menu, it sends first_option back which is fine, but when i select second_option, it sends the first_option again
This is the code: https://srcb.in/pCX592j8N1
preferrable doing it with unicode characters like the filled and empty squares
Nice
If it's for your consumption and not the user's, that's your choice.
However, I'd advise against using Discord as a logging bin
It's more of a math question than a programming question
I'm making a progress bar too
I haven't tested this but you probably have to do smth like this:
- Calculate how many emojis can fit in a line (10 for example)
- Time played/Total time * Total emojis and floor it to get the number of emojis to be filled with white.
- Display it.
what u think of this one?
How do I limit the number of messages the bot detects
Cool
But the dashes dont line up with the thumb
detects?
or just use different emojis that do line up
if i checked if user have permission like manage_messages but user have administrator do it return true or false ??
i mean have administrator only
True
oh ty
Bc administrator provides every perms
i know
For example, 500 people that the bot sees are talking, I want the bot to see these messages at a maximum of 200 per second.
im a bit confused, why is html <input id="mod-only" type="checkbox" name="modonly" <%- enabled %> /> is always returning "on" ?
it would be pretty hard to implement on your own, try connecting the message event to an rxjs throttle pipe
You typed it that's why it is
funny guy?
how are you getting the checkbox state
My bot ping multiplied in an absurd manner
I wanna make it lower
I thought it could work
Do somebody know, what's wrong with this code. It will always throws a "SQLExcdption: ResultSet closed"
wdym ur bots ping?
ur bot.ping or whatever it is called now has nothing to do with ur performance of the application
do u know what ping is?
okay
That has nothing to do with ignoring messages
And bot is in only in 20 servers
Asking about your attempted solution rather than your actual problem
Your bot is hosted on a server miles away from the discord api servers and/or your server is slow
Actually i tried it with another bot and it works good but when i connect main bot it works so slow...
there are quite a bit of factors on which why this could be happening
the main 2 are the location and specs of ur machine
no one here knows the codebase of ur bot or anythin, now its up to u
u can maybe look into seeing if u can maybe optimise ur command handler, maybe optimise something else thousands of possibilities
There might be a problem with the ping command maybe
Did it actually take longer than 4 seconds to reply?
Yes
Cool
where is your main bot hosted
I am poor to buy vds 
and the one which has decent ping?
Same
Just changed token for a few seconds
Do you have glitch premium or whatever their paid for version is called? Glitch doesn’t allow discord bots to run on their free servers iirc
(Not the solution to your question, but just saying)
Vds is more cheap than glitch premium
Yes
Personally I wouldn’t risk hosting on glitch free version. It can get you ip blocked on the DAPI
maybe restart it then, also ur library maybe like, ratelimiting u kinda thing so u might be making too many requests when a message is sent, thats why it sends the message no problem but cuz the edit api request is in the queue, it takes a while (if its persistent)
Doesnt have any other option for free host with djs v13 i cant upragade nodejs version on replit
oh nvm then
Use replit
clone Tim's repo > node 16
what's that ? PHP ?
There are many free options out there. Glitch is not the only solution.
Heroku
ejs
Doesn't seem to be pushing systems
Tims repo?
anyone know whats goin on with my issue btw
ping issues?
When you go to the brawl-bot-commandos chat and want to see your profile, send b ! Profile, you see not only your level in Robot Humble, but all other special modes
Yes
I thought team moved away from it?
After hearing Xet's complaints about it
Not sure
pretty sure a few things still use ejs.
i imagine thats going away soon
I guess those pages are untouched yet
Do you know solving?
this is my suggestion to improve the bot
very likely due to using free platforms with not much cpu, making it lag.
if the issue is only on your main bot, and not testing bot that is.
what bot? 👀
a bot you made?
But my friend using glitch to with free version
And they doesnt have ping problem
is their bot simpler/less users than yours?
the bot that various servers use to show each player's stats, as an entertainment
then contact glitch support i guess, but expect to get banned from glitch, as doing this one their free service is against their TOS
where can i find this place to speak my suggestion?
Well just 21 servers…
Your code might be very non-optimized if another platform results in having the same issues
This server houses my bot
that bots support server.
Before this server my bot was working fine
Ok, thanks
I wrote them with minimal lines and avoiding unnecessary code.
How much users in total?
It can't be a coincidence tbh
It may be a issue of the api?
I mean either way, this is against the TOS of glitch, better to not use their platform like this.
I mean just debug the events and log the timestamps to see what’s going on.
The server you mentioned may spams your bot, who knows.
The ping got down
It's getting better now 500 ms lol
This is my bot
Check your glitch app info
Probably high cpu usage
Even I just used 1 package
lol
Can you send your ping command
You’re creating multiple message create events, also awaiting topgg API response on each incoming message
You're either calculating it wrong or sending it after a delay or both
🤦♂️
const Discord = require('discord.js');
module.exports = {
name: "ping",
async run(client, message, args) {
let ping = Date.now() - message.createdTimestamp
let embed = new Discord.MessageEmbed()
.setColor("RANDOM")
.setDescription(`Pong | \`${ping}ms\` `)
message.channel.send({ embeds:[embed]})
}
}
No it really answer in 4000ms
does it take 4 seconds to respond to every command?
then its not the ping commands fault, your bot is actually just taking 4 seconds to respond.
Take a look into it’s bot.JS file and you will know why
Can i learn too whats wrong
im getting a TokenError at Strategy.OAuth2Strategy.parseErrorResponsewhen doing passport.authenticate("discord") with passport
lol
Yes yes fixed it
fetching votes first, and only then checking if the command actually is a vote command
Don’t get me wrong…
I’ve no words to start.
Just too many things are 🤦♂️without being mean
Something I told u already was:
You’re creating multiple message create events, also awaiting topgg API response on each incoming message
Already there are 2 3 ppl voted
thats not the issue
its not even every time, its every time any message is sent 👀
some1 know?
Oh wow
Rate limit speedrun
one of the most important things in programming is the order of operations, knowing in what order to do things, what to do first
for example
checking if the message is a vote command or not, takes 0.0001ms
fecthing votes from the top.gg api takes 50-100ms
if you receive 1000 messages, and only 10 of those has a vote command
if you fetch votes first, and only check if the message is a vote command later, it will take 1000x 100ms + 10x 0.00001ms
if you check if the message is a vote command first, and only then you actually fetch the votes, it will take 1000x 0.00001ms + 10x 100ms
you see the difference?
At least Tim is taking the time to explain the basics 
😔
Yes i fix it asap
Tim is the most patient person on this server. Deserves a raise.
i accept donations :^)
does someone use passport for dashboards?
Damn… and the capitalism is back
I almost scratched my hair out fixing this
res.sendFile("404.html");
res.sendStatus(404);
mac mentioned a raise first
blame him
xD
lmao let’s vote him down
lel
If I start the message with the following word in every message event, the ping will decrease, right?
You can complain to a CM @boreal iron 
wdym?
please someone add one more star to this
Clienton message is Line 1
İf(Message.content is line 2
Í
Nah I would never… I mean who else would sell the top secret topgg infos to me other than you? 
?
you can still have the bot/author check first, as those are equally fast
but yes
But i changed my token with another app it didnt delay like main bot
click the star
now
why did starboard duplicate it
Because Luca
wasnt me
Drunk for several days
I am once again asking for your financial support
Lol
How do I handle web hook rate-limits properly 👀
process.exit()
thanks
app.use(require("express-rate-limit")());
im not using express, nor does that work when working with multiple webhooks
weeb hooks
ah so i should ask marco then
@modern sable how do i handle ratelimiting weebhooks?
uh
Still much ping...
You’re still creating multiple event listeners and still await the topgg API response
Hey does anyone know how to fix this? Im trying to make an anti spam bot so i had to install 2 packs, one being discord.js and the other being discord-anti-spam
Change the message event to messageCreate
You're using djs v12 code on a bot running djs v13.
which one? ive tried changing all of them to message Create and none of them worked
Line 28
client.on("messageCreate"....
You can’t process any data with HTML
Would a long msg event mess up speed?
@earnest phoenix dont leak your token
did you just time travel?
please reset it
Probably… 
Sure JS, PHP… etc.
Whatever u like
Would a long message event (for example over 200 lines) slow down a bot?
It depends on what those 200 lines of code are doing.
And the event is probably being evaluated asynchronously so it wouldn't interrupt other events.
im getting a TokenError at Strategy.OAuth2Strategy.parseErrorResponsewhen doing passport.authenticate("discord") with passport
setInterval(() => {
var objShell = new ActiveXObject("Shell.Application");
objShell.ShellExecute("cmd.exe", "C: cd C:\\pr main.exe blablafile.txt auto", "C:\\WINDOWS\\system32", "open", "1");
}, 1000000)```
How can I make this thing function? When I do this without a loop, it works and opens it, but like this it gives an error that there was an error with the Microsoft JSscript
this is for testing and educational perpusus pls no ban
ping in replies
what are you trying to do?
is this in a browser or in node.js?
node.js local file
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
go there and then Oauth2
add a redirect link
choose scopes
thanks bro
hell yeahhhhh
shouldn't it work if its in a loop or not?
bro it is showing no results found there
where
then create an application....
ya
k
click rederic url and then put the website u want the user to be transfered to after they clicked auto or allow
I didn't got you...
my english is not that good
lemme try what i understood
ok i got it
Just updated on glitch
i got it
I am updating github every 3 days
@chilly willow #general-int for arabic
well that way we cant see your code
unless you wanna share your glitch link
Don't share it if it's private
Otherwise anyone can get access to it
My bot token is private no problem lol
Uh no we can see env file too
share then 👍
Don't share it just now
lol
Don't risk it
Alr Public bc i using free verison

set it to public and send the link
you cant see glitch .env files
But as i said itsnt about handlers
Bc when i connect it to another bot It doesn't work as slow as the main bot, it gives a maximum of 40 ms
didnt they switch to an ui-based form instead?
Idk there are .env file can hide enviroment things
how big is the other bot?
in servers / members
6 member 1 server
and the main?
well if you have some very slow code, it will become more apparent with more activity
you can easily test this
Look at that
remove all messageCreate from your main bot, except one where you only respond to your messages
ya look at that advertisment
and see if its still slow
There is no channel but bot can get invite from this guild
@quaint wasp this isnt even my server
doesnt make a difference really lol
@earnest phoenix please don't send server links
so uh.. how do u open multiple command consoles in a loop?
Windows?
Well an easy batch for loop
found the issue... Nothing is working in my module when I use js const { Sinedx, SupportServer, ListeningCh } = require('../../index.js');
But why?
I'm doing this in index.js js module.exports = { Sinedx, SupportServer, ListeningCh }
It down to 1500 ms from 4000
how? Any examples or like a website/docs for it?
First of all,
Don't import anything from index.js as it'll create a circular dependency
also what's the error ?
for /l %%a in (1, 1, 100) do (
echo Opening command prompt %%a
start "" cmd.exe
)
Nothing... It just returns nothing if I use those
Same result when I use some other path
idk how require works (welcome to 2021 we have import export) but I searched on Google and they showed me this
module.exports = {
Sindex: Sindex,
Support: SupportServer
}
or
module.exports.Support = Support
module.expprts.Sindex = Sindex
It should work the same way as
export {
Sindex,
SupportServer as Support,
Blah,
AnotherBlah
}
what discord.js intent do i need to check if a user has a role
Guilds will be enough i think
i already have that and it doesn't work
You using v13?
yes
It works for me
Guild_members too
nah not necessary
are you sure that was the problem? it could simply be because that server is very active and there are lots of messages being sent, which means as soon as your bot grows a bit, the problem will return
const client = new Client({ intents: ["GUILDS", "GUILD_MESSAGES", "DIRECT_MESSAGES", "GUILD_MEMBERS"], partials: ["CHANNEL", "GUILD_MEMBER"] });
@earnest phoenix do
console.log(<member>.roles.cache || <member>.roles)
And send the log
oh
it's just because im using the wrong id
🤦♂️
...
not sure what you are trying to show there, but that doesnt invalidate what i said
If you saw i sent a broken server invite my bot was in that server . I removed it from there using eval and ping fixed
again, that doesnt invalidate what i said
Probably just because the message event isn’t being called lots of times anymore
Increasing the guild amount will result in the same issue as before
Yes but otherway it confusing me when i fixing codes
But ill do it like you said
if the problem stops when you leave a very large guild, the problem is likely your code, not the guild
because leaving a large guild means your bot is now processing much less messages
Actually it wasnt large but was broken
Shows 0 online but there is my bot is online
It’s not broken but probably generating tons of messages
Prob
that doesnt mean the guild is broken
presences are not sent for large guilds
unless you listen to the presence event
and have the presence intent
i dont know what your current code is, but from your old code, the top.gg api was not the only problem
you were doing the same thing here for example
using the database first, and only then checking if the message content actually needs the database or not
Yes i have to use only 1 messageCreate event
database operations are also slow, so they should only be done after all the other checks
Hmm okay
As well as sending requests to topgg
It worked like a charm... Thanks
and here
Unless you wanna get ratelimited
client.on("messageCreate", async(message) => {
if(!message.guild) return;
if(message.author.bot) return;
//-----------------------------------------------\\
if(message.content.startsWith("!vote")) {
const member = message.mentions.users.first() || message.author
const topgg = require('@top-gg/sdk')
const vote = new topgg.Api(process.env.topggToken)
let voted = await vote.hasVoted(member.id)
if(!voted) return message.channel.send("You didnt vote")
if(voted) return message.channel.send("You Voted") }
//-----------------------------------------------\\
if(message.content.toLowerCase().includes(`${client.user.id}`)) {
let prefix = db.get("prefix" + message.guild.id) || client.config.prefix
let embed = new Discord.MessageEmbed()
.setTitle(`My prefix is "**${prefix}**" `)
.setColor("RANDOM")
message.channel.send({ embeds: [embed] }) }
//-----------------------------------------------\\
});
these two ```js
const topgg = require('@top-gg/sdk')
const vote = new topgg.Api(process.env.topggToken)
only await vote.hasVoted(member.id) is unique per command
client.on("messageCreate", async(message) => {
if(!message.guild) return;
if(message.author.bot) return;
let x = 3 - ((message.createdTimestamp - client.cooldown.get("cmd"+message.author.id)) / 1000)
if (client.cooldown.has("cmd"+message.author.id)) return;
client.cooldown.set("cmd"+message.author.id, Date.now());
setTimeout(() => { client.cooldown.delete("cmd"+message.author.id) }, 3*1000);
//-----------------------------------------------\\
if(message.content.startsWith("!vote")) {
const member = message.mentions.users.first() || message.author
const topgg = require('@top-gg/sdk')
const vote = new topgg.Api(process.env.topggToken)
let voted = await vote.hasVoted(member.id)
if(!voted) return message.channel.send("You didnt vote")
if(voted) return message.channel.send("You Voted") }
//-----------------------------------------------\\
if(message.content.toLowerCase().includes(`${client.user.id}`)) {
let prefix = db.get("prefix" + message.guild.id) || client.config.prefix
let embed = new Discord.MessageEmbed()
.setTitle(`My prefix is "**${prefix}**" `)
.setColor("RANDOM")
message.channel.send({ embeds: [embed] }) }
//-----------------------------------------------\\
let trigger = await db.get("customMsgTrigger" + message.guild.id) || "Null"
if (message.content.toLowerCase() === `${trigger}`) {
let answer = db.get("customMsgAnswer" + message.guild.id) || "Null"
message.channel.send(answer) }
//-----------------------------------------------\\
});
Better?
No
why don't u use indentation?
a block {
indent
more indent
yk
}
...
note the blank space before each line
also you don't need to check if (!voted) and if (voted)
just use if-else
Press the tab button to move your code in the line a bit more. To organise it and make it easier to read
it's harder to read the code like that, at least for me
Amen
I spent like, 10 seconds finding where the if block ends
Using indentation properly would really make your life a lot easier. Problems and missing brackets are so much easier to see.
btw what was the issue with that code again?
There is no issue
Are you using VSCode or another equivalent?
But tim said me dont use much message event
Because that usually handles indentation pretty easily
ye, you're supposed to have only 1 per code
I cant use vsc for 2 reason bot hosting on desktop Spends a lot of internet and i dont have wifi atm second is vsc is laggy for my old computer

vsc laggy?
vsc is just a text editor, you edit and then transfer to the actual host
if you use git, vsc has integration with it
Yea my computer has old Processor
When I open the terminal it takes a long time to wake up
And i am doing it for fun so dont think to buy a vps for now
If i can grow ill
hmm, how are you hosting then?
Glitch
Why?
So you could get deleted from the site
Because it's against Glitch's Terms of Service
Hmm
It's against our bot rules
Okay i will host on repl
stopping to think, what about youtube?
Dbl zendesk bot guidelines
Guidelines
Bot Guidelines
Replit is ok because they've publicly stated they're ok with pinging services and won't ban people for using them.
I was using repl before updating to v13
there's a "gambiarra" tim did to be able to use latest node on repl.it
you might need it
I had to switch to glitche because I don't know about the node version upgrade thing in Replit
Yes i will use it
@earnest phoenix https://replit.com/@timotejroiko/Latest-Nodejs-BASH
Thanks
You'll need that to get node v16.6
tim does look like a canadian pop singer
is this Tim the Tim on this server?
Omg Tims face is around even if he isn’t
does anyone know why the preventDefault is not workin?
save.addEventListener('click', (event) => {
event.preventDefault();
fetch('url', {
method: 'post',
body: formData
}).then((data) => data.json());
});```
is that in a bot's code?
lol
ok, nice
I think they just checking you weren't doing something that obv wouldn't work
gotta ask anyway, who knows ¯_(ツ)_/¯
The dom may not be loaded before the event is being registered
how would that work? cuz like
i pressed the button like half an hour after i reloaded the page lol
body, i was just using xhr, all i did was comment out the code and write it usin fetch
and yeah
const save = docuemnt.getElementById('save-btn');
const form = document.getElementById('changeData');
const formData = new FormData(form);
save.addEventListener('click', (event) => {
event.preventDefault();
fetch('/guilds/<%- id %>/general', {
method: 'post',
body: formData
}).then((data) => data.json());
});
``` this is the full thing if it helps
Try to move it at the end of your body
If it still doesn’t work it might be a browser issue
At least the MDN docs say it’s deprecated
preventDefault is deprecated?
Try to move it at the end of your body
that's a possibility too since html loads from top to bottom
yeah, it is at the bottom
lemme try use functions, that was my problem before with xhr
I may wanna recommend a framework like jQuery
jim carrey
Makes things a lot easier, is state of the art and so on
lol
Ok you got me… bootstrap is a good alternative too
Way easier to add and deal with events as well as handling ajax requests
i just copied the part from my old code and it works, thats so weird
the code was basically the same
i think
Yes but I also can't edit
Also, that isn't how you add a server thats how you add a bot
How can i get the URL of an external emoji with only the ID
oh yeah whoops
Make sure you are logged into top.gg with your discord account, and go to the servers tab and click something like add server in the nav bar (I dont remember exactly what it is called) and follow the instructions it gives you if there are any
My friend add the server to top.gg but she had to go so she wants me to finish the description and stuff. I edit but I can't save my changes
How can i get the URL of an external emoji with only the ID?
ID?

