#development

1 messages · Page 1853 of 1

earnest phoenix
#

I've only seen it used with dynamic imports and i don't wanna ssr the component

#

wait can react.lazy work with normal Promises? @vivid fulcrum

vivid fulcrum
#

iirc the promise needs to return a react component

#

also

earnest phoenix
#

works for me

vivid fulcrum
#

suspense works without ssr

earnest phoenix
pallid jungle
#
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.
earnest phoenix
#

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?

uneven garden
#
k
earnest phoenix
vivid fulcrum
#

v13, right?

earnest phoenix
#

Yeppers

vivid fulcrum
#

as for redirecting, you have two ways

#

sending the url and re-uploading

#

both have caveats

earnest phoenix
#

Its gonna be in a embed

#

channel.send(dmmessage.toString()); ?

earnest phoenix
#

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 facepalm 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

earnest phoenix
#
 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...

vivid fulcrum
#

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

earnest phoenix
#

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

vivid fulcrum
#

which part of it don't you understand

#

if you say everything i'll slap you

earnest phoenix
#

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

vivid fulcrum
#

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

earnest phoenix
#

The more you quote the docs, the more questions I have xD

vivid fulcrum
#

if there wasn't anything attached, it will be empty, therefore, size === 0

earnest phoenix
#

"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

earnest phoenix
#

....

#

If you're making a bot, you should have knowledge about what an object means

earnest phoenix
#

So I need a filter

#

that tells weither or not its a image

#

Its frustrating at this point lol

vivid fulcrum
#

no it won't

#

because in those messages, there isn't anything attached

earnest phoenix
vivid fulcrum
#

are you reading anything i'm saying lol

earnest phoenix
#

Yes I am

#

so in a embed

vivid fulcrum
#

the only thing you really need to be concerned about is whether the attachment is actually an image or not

earnest phoenix
#

if(content.includes === message.attachment){}?

vivid fulcrum
#

no

earnest phoenix
#

Thats whats popping into my mind

vivid fulcrum
#

you aren't reading anything what i'm saying

earnest phoenix
#

I AMMM

#

Thats the thing

#

Its confusing

earnest phoenix
#

Yes

#

so

#

.setImage(messageAttachment)

#

orrrrrr

#

am I just officially dum

earnest phoenix
earnest phoenix
#

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

quartz kindle
#

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 }

earnest phoenix
quartz kindle
#

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()

pale vessel
#

You're falsey

quartz kindle
#

so message.attachments.first() gives you the first attachment

earnest phoenix
#

The person can also post a link attachment though

quartz kindle
#

then you have to check the attachment type

earnest phoenix
#

doesn't matter though

#

the url will still be valid

quartz kindle
#

attachments have a type prop

pale vessel
#

attachment type poor

#

wait that's embed type nm

vivid fulcrum
#

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

earnest phoenix
#

seriously? An ad for a crypto pump server that has only one channel?

quaint wasp
#

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

cinder patio
#

Array.map

quaint wasp
#

? Idk how to use maps ...

earnest phoenix
# quaint wasp

content.domains.map(s=>s.domain) ,will return a array of all domains ig

near grotto
#

what type of action is bot added to a server in audit log?

earnest phoenix
#

How do i fetch bots

quartz kindle
#

you have to fetch all members

sterile thicket
#

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?

quartz kindle
#

what is that code supposed to do?

#

why are you adding the function to a collection if youre not using the collection?

earnest phoenix
quartz kindle
#

the same way you did

earnest phoenix
#

But didnt work

sterile thicket
quartz kindle
quartz kindle
earnest phoenix
#

guild.memberCount.filter is not a function

quartz kindle
earnest phoenix
#

Then idk how to fetch all members

quartz kindle
#

await guild.members.fetch()

#

you need the members intent

sterile thicket
#
async function getCash(userId) {
       const data = await UserSchema.findOne({ _id: userId })
       return data ? data.cash : 0
}

let a = await getCash(Sinedx)
      console.log(a);```
quartz kindle
#

what does that log?

eternal osprey
#

what is the djs v12's event called that detects a leaving member

sterile thicket
quartz kindle
#

then it works?

sterile thicket
#

but I want to get the function from another file

quartz kindle
quartz kindle
sterile thicket
#

no good reason

quartz kindle
#

then dont lol

sterile thicket
# quartz kindle 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

quartz kindle
#

what does that log?

sterile thicket
quartz kindle
#

wdym nothing

sterile thicket
#

it just ignores everything

#

nothing to log

quartz kindle
#

then your problem is elsewhere

eternal osprey
#

how do i detect boosts? Is there any event for that or something

sterile thicket
quartz kindle
quartz kindle
sterile thicket
# quartz kindle idk, you need to show your full code, otherwise nobody can help

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);
})

}```

tulip ledge
#

Means you're not calling the getCash function

quartz kindle
#

sounds like you are swallowing your errors

#

economy.getCash() would throw an error

#

because economy IS the getCash

tulip ledge
#

because you're doing module.exports = function getCash

#

so you're saying the module = getCash so there is no economy.getCash

#

Like tim said

worn sonnet
#

Hi

#

is there any way i can run d.py synchronusly?

tulip ledge
quartz kindle
#

wdym run it synchronously lol

#

for what purpose?

eternal osprey
#
 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
tulip ledge
#

cuz ur doing something your bot doesn't have permission to

eternal osprey
#

I just booted it up

#

that's all

tulip ledge
#

well we can't do much without code

boreal iron
#

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?

tulip ledge
#

No I think he's trying to create a channel but doesn't have perms to

eternal osprey
tulip ledge
#

the bot doesn't have perms to

eternal osprey
#

that's why it was sending so much messages, as it was being fire based on incoming messages

tulip ledge
#

You have to catch the error

#

And then return

eternal osprey
tulip ledge
#

if he doesn't have perms

#

Clearly not

#

the error sais your bot doesn't have perms to

boreal iron
#

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

worn sonnet
#

tried using exit()

#

but the async for loop before it doesn't complete

#

and it exits

quartz kindle
#

then await it

sterile thicket
worn sonnet
#

await exit?

quartz kindle
#

no, await the async loop

worn sonnet
#
            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()
quartz kindle
worn sonnet
boreal iron
#

no, await the async loop

sterile thicket
worn sonnet
#

async await for msg in channe.....

quartz kindle
#

module.exports = { a, b, c }

tulip ledge
worn sonnet
#

or should i create another async funtion for loop and then await it?

burnt anchor
#

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

quartz kindle
burnt anchor
#

help me plzzzz (╯°□°)╯︵ ┻━┻

quartz kindle
#

you cant require an exe file wtf

burnt anchor
#

how can i attach an exe file

#

i need help

quartz kindle
#

you cant

#

lol

burnt anchor
#

what

earnest phoenix
#

Wouldn't Buffer.from work?

quartz kindle
#

what are you trying to do?

burnt anchor
#

send my setup.exe

quartz kindle
#

you want to send the file to discord?

burnt anchor
#

yea

quartz kindle
#

then you have to read the file with fs not with require

burnt anchor
#

when i type
$software

#

it will attach

#

;-;

#

again fs

quartz kindle
#

require is to load and run js code

burnt anchor
#

how can i make it

quartz kindle
#

with fs

burnt anchor
#

but how

#

xd

quartz kindle
#

fs.readFile or fs.readFileSync

#

or fs.createReadStream

burnt anchor
#

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

timber fractal
#

can someone help?

#

@quartz kindle do you have any ideas, its the code from earlier

burnt anchor
#

@quartz kindle

#

made it

timber fractal
#

only now with mute command

burnt anchor
#

is ur bot have permissions?

#

and intents

timber fractal
#

yes

#

it has admin and is above all roles

burnt anchor
#

intents?

sterile thicket
timber fractal
burnt anchor
timber fractal
#

ok

burnt anchor
#

u can tell it to this friend

burnt anchor
#

JolteonYellow#7328

#

maybe he know

timber fractal
#

@fading warren

burnt anchor
#

@fading warren

#

yo

quartz kindle
timber fractal
#

can anybody help please

lyric mountain
stiff folio
#

whats most normal to code with?

lyric mountain
#

context-dependent

timber fractal
#

that are staff roles

#

everything works fine, it mutes them etc. sets the duration and reason it only doesnt unmute them

lyric mountain
#

you do acknowledge that this command will ONLY be usable on your server and by those 2 roles right?

timber fractal
#

altough it does unmute them with automutes

#

yes

sterile thicket
# quartz kindle wdym?
//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?
lyric mountain
#

ok, where's the unmute command code?

timber fractal
lyric mountain
#

else you have to use the same name you declared on the source

sterile thicket
sterile thicket
#

I mean "type" = "module"

lyric mountain
#

you said the manual unmute is not working

timber fractal
willow mirage
timber fractal
#

the automatic unmute code only works with automutes not manual mutes

willow mirage
#

on mobile it appears only with @

split hazel
#

like forgetting to save it

timber fractal
#

checked, couldnt find

sterile thicket
timber fractal
willow mirage
#

just giving some opinion :<

split hazel
#

send your manual mute code

timber fractal
#

found something?

fading warren
split hazel
#

After expireTime.setHours could you console that that

#

@timber fractal

fading warren
split hazel
#

console log the date

timber fractal
split hazel
#

I have a hunch for whatever reason you're accidentally muting for way longer

timber fractal
#

the duration is right everytime i logged that too

fading warren
timber fractal
#

wait

#

does it mute untill 9:44 pm

#

uhhhh

#

@split hazel

split hazel
#

are you able to console.log the schema?

timber fractal
#

you mean that it outputs?

#

this is in the db

#

@rustic nova

split hazel
#

bit odd it isn't working

#

how about the auto mute?

timber fractal
#

automute unmuting works

#

do you want the code?

split hazel
#

yes

timber fractal
#

@split hazel this is the automute schema

#

it works with the same schema only different strings

split hazel
#

oh wait

#

is it not working because of that error in console

#

members of undefined

timber fractal
#

i gotta remove that

#

that is nothing

#

so what could it be

lyric mountain
#

could u show the manual unmute code?

#

or is it auto-only?

timber fractal
#

has anyone found something?

lyric mountain
#

where's the automute code?

split hazel
#

firstly when you check on mongo atlas is the mute request there and just stays?

split hazel
lyric mountain
#

that's the unmute...

split hazel
#

yeah

lyric mountain
#

I'm asking for the automute one

#

he said the unmute works with the automatic but fails with the manual mute

split hazel
#

now I'm getting confused

#

is that the autounmute

timber fractal
split hazel
#

is that the autounmute code you sent above?

lyric mountain
timber fractal
split hazel
#

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

timber fractal
#

no errors

lyric mountain
#

or check the user beforehand

timber fractal
#

ok

#

but any fix for my problem?

lyric mountain
#

debug the code to see where it's failling

split hazel
#

and in the auto unmute are you able to add a line that logs all of the mutes returned by the request?

timber fractal
#

I also tried this but that didnt give any error

solemn latch
timber fractal
#

no

solemn latch
timber fractal
timber fractal
#

its broken

#

cuz it should log 1 at least

split hazel
#

actually of course it won't

#

your mutes are hours long

timber fractal
#

it added this little red arrow

timber fractal
#

it should log 1 cause that one has expired

split hazel
#

for testing you should only make your mutes minutes or seconds long

timber fractal
earnest phoenix
#

hi

timber fractal
#

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

split hazel
#

that works fine

earnest phoenix
#

if i could have a moment of your time

use momentjs

timber fractal
#

that would be great

earnest phoenix
#

yeah it might be

#

i heard it's a pretty good lib for time things

#

i wish tc39 releases Temporal soon

split hazel
#

probably not but its an easier alternative

timber fractal
#

what is the problem in my code?

earnest phoenix
#

so it has bugs

#

but mostly fine

timber fractal
#

hm

#

are all bugs able to fix

earnest phoenix
#

probably

timber fractal
#

i hope so for you...

#

jk\

split hazel
#

that package is years old

timber fractal
#

then ill use that

earnest phoenix
split hazel
#

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

#

not gonna lie looks much more user friendly

tired panther
#

@lyric mountain Is it normal that Contabo has every week a small internet outage?

I experinced them 4 times since last week

quartz kindle
#

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

split hazel
lyric mountain
#

what region are u using?

tired panther
#

Which do you use? USA?

lyric mountain
#

ye

#

check whether they've announced known issues on the news page

tired panther
#

is it the status page?

lyric mountain
#

ye ig

tired panther
#

last question: Can you move the region, didnt found anything in there FAQ

lyric mountain
#

you can, don't remember how tho

tired panther
#

okay, you can. I will move it when we have more issues

split hazel
tired panther
split hazel
#

no

lyric mountain
#

plus it's closer to discord servers

tired panther
#

My instance disconnects from Mongodb and gets this error:

tired panther
worthy ivy
#

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

novel jetty
worthy ivy
#

smthing like that idk

worthy ivy
wheat mesa
#

Nice

sudden geyser
#

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

earnest phoenix
#

I'm making a progress bar too

#

I haven't tested this but you probably have to do smth like this:

  1. Calculate how many emojis can fit in a line (10 for example)
  2. Time played/Total time * Total emojis and floor it to get the number of emojis to be filled with white.
  3. Display it.
earnest phoenix
#

How do I limit the number of messages the bot detects

earnest phoenix
#

But the dashes dont line up with the thumb

low bone
#

you can make dash emoji

#

it will line up i think

earnest phoenix
earnest phoenix
hot sleet
#

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

earnest phoenix
hot sleet
#

oh ty

earnest phoenix
#

Bc administrator provides every perms

hot sleet
#

i know

earnest phoenix
# earnest phoenix detects?

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.

digital ibex
#

im a bit confused, why is html <input id="mod-only" type="checkbox" name="modonly" <%- enabled %> /> is always returning "on" ?

earnest phoenix
earnest phoenix
digital ibex
#

funny guy?

earnest phoenix
#

how are you getting the checkbox state

digital ibex
#

but its always sending checked to my backend even when unchecked

#

wdym?

earnest phoenix
#

I thought it could work

brave herald
#

Do somebody know, what's wrong with this code. It will always throws a "SQLExcdption: ResultSet closed"

earnest phoenix
#

@digital ibex

digital ibex
#

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?

earnest phoenix
#

Yes message answer delay

#

Date.now() - messageCreatedTimestamp

digital ibex
#

okay

earnest phoenix
#

And bot is in only in 20 servers

#

Your bot is hosted on a server miles away from the discord api servers and/or your server is slow

earnest phoenix
earnest phoenix
digital ibex
#

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

earnest phoenix
#

There might be a problem with the ping command maybe

digital ibex
#

if its just Date.now() - messageCreatedTimestamp i doubt it

#

but who knows

earnest phoenix
#

Did it actually take longer than 4 seconds to reply?

#

Yes

#

Cool

#

where is your main bot hosted

#

I am poor to buy vds z_smoke

digital ibex
#

and the one which has decent ping?

earnest phoenix
#

Just changed token for a few seconds

wheat mesa
#

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)

earnest phoenix
#

Vds is more cheap than glitch premium

wheat mesa
#

What’s vds

#

You mean VPS?

earnest phoenix
#

Yes

wheat mesa
#

Personally I wouldn’t risk hosting on glitch free version. It can get you ip blocked on the DAPI

digital ibex
#

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)

earnest phoenix
digital ibex
#

lol glitch premium is like £30 i think

#

or some stupid price like that

earnest phoenix
#

8$

#

But 80₺ for me

digital ibex
#

oh nvm then

near stratus
digital ibex
#

any ideas anyone?

near stratus
wheat mesa
near stratus
#

Heroku

earnest phoenix
digital ibex
earnest phoenix
#

Doesn't seem to be pushing systems

earnest phoenix
boreal iron
digital ibex
#

anyone know whats goin on with my issue btw

near stratus
#

noone uses ejs

#

it's PHP but with js

sudden geyser
#

sadly people use ejs

#

templating is a scam

solemn latch
#

👀

sudden geyser
#

yuck

#

down with topgg

#

no don't hurt me

earnest phoenix
#

Moved bot to replit but same sh.t

solemn latch
#

ping issues?

dire cloak
#

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

earnest phoenix
#

Yes

slender thistle
#

After hearing Xet's complaints about it

#

Not sure

solemn latch
#

i imagine thats going away soon

slender thistle
#

I guess those pages are untouched yet

earnest phoenix
dire cloak
solemn latch
solemn latch
#

a bot you made?

earnest phoenix
#

But my friend using glitch to with free version

#

And they doesnt have ping problem

solemn latch
#

is their bot simpler/less users than yours?

earnest phoenix
#

No bigger than mine

#

At least as server and user

dire cloak
#

the bot that various servers use to show each player's stats, as an entertainment

solemn latch
#

then contact glitch support i guess, but expect to get banned from glitch, as doing this one their free service is against their TOS

earnest phoenix
dire cloak
#

where can i find this place to speak my suggestion?

boreal iron
#

Well just 21 servers…
Your code might be very non-optimized if another platform results in having the same issues

earnest phoenix
#

This server houses my bot

solemn latch
earnest phoenix
#

Before this server my bot was working fine

dire cloak
#

Ok, thanks

earnest phoenix
indigo cobalt
#

How much users in total?

boreal iron
#

It can't be a coincidence tbh

indigo cobalt
#

It may be a issue of the api?

solemn latch
#

I mean either way, this is against the TOS of glitch, better to not use their platform like this.

earnest phoenix
boreal iron
#

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.

indigo cobalt
#

The ping got down

earnest phoenix
#

It's getting better now 500 ms lol

indigo cobalt
#

Probably api problems or smth

#

Sometimes happens idk

earnest phoenix
#

This is my bot

#

Check your glitch app info

#

Probably high cpu usage

#

Even I just used 1 package

boreal iron
#

lol

earnest phoenix
#

Can you send your ping command

boreal iron
#

You’re creating multiple message create events, also awaiting topgg API response on each incoming message

earnest phoenix
#

You're either calculating it wrong or sending it after a delay or both

boreal iron
#

🤦‍♂️

earnest phoenix
#
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]})
  }
}
earnest phoenix
solemn latch
#

does it take 4 seconds to respond to every command?

earnest phoenix
#

Yes

#

Lemme record

solemn latch
#

then its not the ping commands fault, your bot is actually just taking 4 seconds to respond.

boreal iron
earnest phoenix
earnest phoenix
solemn latch
#

op, btw you just leaked your top.gg token, best to reset that

earnest phoenix
#

Lol

#

I am dumb

tawdry oracle
#

im getting a TokenError at Strategy.OAuth2Strategy.parseErrorResponsewhen doing passport.authenticate("discord") with passport

quartz kindle
earnest phoenix
#

Yes yes fixed it

quartz kindle
#

fetching votes first, and only then checking if the command actually is a vote command

boreal iron
rose warren
#

Do you really want to hit the top.gg api every time someone runs the command tho? dog_Think

boreal iron
#

Something I told u already was:

You’re creating multiple message create events, also awaiting topgg API response on each incoming message

earnest phoenix
quartz kindle
solemn latch
rose warren
#

Rate limit speedrun

quartz kindle
#

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?

boreal iron
#

At least Tim is taking the time to explain the basics topggWink

tawdry oracle
#

😔

earnest phoenix
rose warren
#

Tim is the most patient person on this server. Deserves a raise.

quartz kindle
#

i accept donations :^)

tawdry oracle
#

does someone use passport for dashboards?

boreal iron
#

Damn… and the capitalism is back

earnest phoenix
quartz kindle
#

blame him

#

xD

boreal iron
#

lmao let’s vote him down

earnest phoenix
#

If I start the message with the following word in every message event, the ping will decrease, right?

rose warren
#

You can complain to a CM @boreal iron dog_Joy

earnest phoenix
#

Clienton message is Line 1
İf(Message.content is line 2

#

Í

boreal iron
tawdry oracle
quartz kindle
#

but yes

misty sigil
#

its true

earnest phoenix
#

But i changed my token with another app it didnt delay like main bot

#

click the star

#

now

quartz kindle
#

why did starboard duplicate it

rose warren
#

Because Luca

quartz kindle
#

is luca drunk

#

go home @gilded plank you're drunk

rose warren
#

Oh shoot

#

Woo

solemn latch
#

wasnt me

stable eagle
earnest phoenix
quartz kindle
#

Lol

solemn latch
#

How do I handle web hook rate-limits properly 👀

rose warren
solemn latch
#

thanks

earnest phoenix
solemn latch
#

im not using express, nor does that work when working with multiple webhooks

quartz kindle
#

weeb hooks

solemn latch
#

ah so i should ask marco then

#

@modern sable how do i handle ratelimiting weebhooks?

modern sable
#

uh

earnest phoenix
#

Still much ping...

boreal iron
#

You’re still creating multiple event listeners and still await the topgg API response

quartz kindle
#

whats your current code?

#

your github is not updated

boreal iron
#

last edit 2 minutes ago

#

At least for me?!

earnest phoenix
#

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

rose warren
#

Change the message event to messageCreate

#

You're using djs v12 code on a bot running djs v13.

earnest phoenix
#

which one? ive tried changing all of them to message Create and none of them worked

rose warren
#

client.on("messageCreate"....

boreal iron
#

You can’t process any data with HTML

stable eagle
#

Would a long msg event mess up speed?

earnest phoenix
#

thanks

quartz kindle
#

lol

boreal iron
#

WTF not it’s 36 mins for me too

#

It was 2 mins a few mins ago

solemn latch
#

@earnest phoenix dont leak your token

quartz kindle
#

did you just time travel?

solemn latch
#

please reset it

earnest phoenix
#

oof

#

i forgot sorry

#

thanks for deleting it

boreal iron
#

Sure JS, PHP… etc.

#

Whatever u like

stable eagle
#

Would a long message event (for example over 200 lines) slow down a bot?

sudden geyser
#

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.

tawdry oracle
#

im getting a TokenError at Strategy.OAuth2Strategy.parseErrorResponsewhen doing passport.authenticate("discord") with passport

quaint wasp
#
 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

quartz kindle
#

is this in a browser or in node.js?

high crown
#

hey developers

#

listen

#

how do you guys make a different oauth2 link

quaint wasp
quaint wasp
#

go there and then Oauth2

#

add a redirect link

#

choose scopes

high crown
#

thanks bro

quaint wasp
#

and there

#

ur welcome 👍

high crown
#

hell yeahhhhh

quaint wasp
high crown
#

bro it is showing no results found there

quaint wasp
#

where

high crown
#

can I send ss

#

?

quaint wasp
#

then create an application....

quaint wasp
high crown
quaint wasp
#

ss in NSFW version of plain Screen Shot?

#

NSFW no

high crown
#

in place of redirect url....it shows no results found

quaint wasp
#

click rederic url and then put the website u want the user to be transfered to after they clicked auto or allow

high crown
#

I didn't got you...

#

my english is not that good

#

lemme try what i understood

#

ok i got it

earnest phoenix
high crown
#

i got it

earnest phoenix
#

I am updating github every 3 days

chilly willow
#

السلام عليم

#

عليكم

earnest phoenix
quartz kindle
#

unless you wanna share your glitch link

earnest phoenix
#

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

quaint wasp
#

share then 👍

earnest phoenix
#

Don't share it just now

earnest phoenix
#

Make it public then

quaint wasp
#

lol

earnest phoenix
#

Alr Public bc i using free verison

#

set it to public and send the link

quartz kindle
#

you cant see glitch .env files

earnest phoenix
#

But as i said itsnt about handlers

quartz kindle
#

they automatically lock it afaik

#

also, do they even use env files anymore?

earnest phoenix
#

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

quartz kindle
#

didnt they switch to an ui-based form instead?

earnest phoenix
#

Idk there are .env file can hide enviroment things

quartz kindle
#

in servers / members

earnest phoenix
#

6 member 1 server

quartz kindle
#

and the main?

earnest phoenix
#

9k users 21 servers

#

But one of the server is Broken

quartz kindle
#

well if you have some very slow code, it will become more apparent with more activity

#

you can easily test this

earnest phoenix
#

Look at that

quartz kindle
#

remove all messageCreate from your main bot, except one where you only respond to your messages

quaint wasp
#

ya look at that advertisment

quartz kindle
#

and see if its still slow

earnest phoenix
#

There is no channel but bot can get invite from this guild

#

@quaint wasp this isnt even my server

quaint wasp
#

doesnt make a difference really lol

rose warren
#

@earnest phoenix please don't send server links

quaint wasp
#

so uh.. how do u open multiple command consoles in a loop?

earnest phoenix
#

Okay

#

Lemme remove my bot from this guild

boreal iron
sterile thicket
#

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 }

earnest phoenix
#

It down to 1500 ms from 4000

quaint wasp
earnest phoenix
#

the whole problem was that broken server

near stratus
#

also what's the error ?

boreal iron
sterile thicket
sterile thicket
boreal iron
#

(1,1,100) start, step, max

near stratus
#

It should work the same way as

export {
  Sindex,
  SupportServer as Support,
  Blah,
  AnotherBlah
}
earnest phoenix
#

what discord.js intent do i need to check if a user has a role

#

Guilds will be enough i think

earnest phoenix
#

You using v13?

#

yes

#

It works for me

#

Guild_members too

near stratus
earnest phoenix
#

Okay

#

i have guild_members and guild_member as a partial

quartz kindle
# earnest phoenix

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

earnest phoenix
#

const client = new Client({ intents: ["GUILDS", "GUILD_MESSAGES", "DIRECT_MESSAGES", "GUILD_MEMBERS"], partials: ["CHANNEL", "GUILD_MEMBER"] });

near stratus
#

@earnest phoenix do

console.log(<member>.roles.cache || <member>.roles)
#

And send the log

earnest phoenix
#

it's just because im using the wrong id

#

🤦‍♂️

near stratus
#

...

quartz kindle
# earnest phoenix

not sure what you are trying to show there, but that doesnt invalidate what i said

earnest phoenix
quartz kindle
boreal iron
#

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

earnest phoenix
#

Yes but otherway it confusing me when i fixing codes

#

But ill do it like you said

quartz kindle
#

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

earnest phoenix
#

Actually it wasnt large but was broken

#

Shows 0 online but there is my bot is online

boreal iron
#

It’s not broken but probably generating tons of messages

earnest phoenix
#

Prob

quartz kindle
#

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

earnest phoenix
#

Yes i have to use only 1 messageCreate event

quartz kindle
#

database operations are also slow, so they should only be done after all the other checks

earnest phoenix
#

Hmm okay

boreal iron
#

As well as sending requests to topgg

sterile thicket
quartz kindle
#

and here

boreal iron
#

Unless you wanna get ratelimited

earnest phoenix
#
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] }) }
//-----------------------------------------------\\  
}); 
quartz kindle
#

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

earnest phoenix
#
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

lyric mountain
#

why don't u use indentation?

earnest phoenix
#

Bc used cooldown on wrong place

#

Whats that

lyric mountain
#
a block {
  indent
    more indent
      yk
}
earnest phoenix
#

I cant say i understand what did you showing me

lyric mountain
#

...

#

note the blank space before each line

#

also you don't need to check if (!voted) and if (voted)

#

just use if-else

rose warren
#

Press the tab button to move your code in the line a bit more. To organise it and make it easier to read

earnest phoenix
#

I'm used to using it like this

#

Using //-----\ come more easy

lyric mountain
#

it's harder to read the code like that, at least for me

boreal iron
#

Amen

lyric mountain
#

I spent like, 10 seconds finding where the if block ends

rose warren
#

Using indentation properly would really make your life a lot easier. Problems and missing brackets are so much easier to see.

earnest phoenix
#

Hmm okay ill try to write as you suggested

#

Thanks

lyric mountain
#

btw what was the issue with that code again?

earnest phoenix
#

There is no issue

rose warren
#

Are you using VSCode or another equivalent?

earnest phoenix
#

But tim said me dont use much message event

rose warren
#

Because that usually handles indentation pretty easily

lyric mountain
earnest phoenix
#

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

lyric mountain
#

vsc laggy?

rose warren
#

You don't need to host on your computer

#

You can use VSCode and host on a VPS

lyric mountain
#

vsc is just a text editor, you edit and then transfer to the actual host

#

if you use git, vsc has integration with it

earnest phoenix
#

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

lyric mountain
#

hmm, how are you hosting then?

earnest phoenix
#

Glitch

rose warren
#

That's against Glitch's Terms of Service

#

You can get banned

earnest phoenix
#

Where there is no police there is no ban

rose warren
earnest phoenix
#

Why?

rose warren
#

So you could get deleted from the site

rose warren
earnest phoenix
#

Hmm

rose warren
#

It's against our bot rules

lyric mountain
#

basically it's against top.gg tos to break other services tos

earnest phoenix
#

Okay i will host on repl

lyric mountain
#

stopping to think, what about youtube?

rose warren
#

Dbl zendesk bot guidelines

livid jackalBOT
rose warren
#

Replit is ok because they've publicly stated they're ok with pinging services and won't ban people for using them.

earnest phoenix
#

I was using repl before updating to v13

lyric mountain
#

there's a "gambiarra" tim did to be able to use latest node on repl.it

#

you might need it

earnest phoenix
#

I had to switch to glitche because I don't know about the node version upgrade thing in Replit

#

Yes i will use it

rose warren
earnest phoenix
#

Thanks

rose warren
#

You'll need that to get node v16.6

lyric mountain
#

tim does look like a canadian pop singer

earnest phoenix
#

is this Tim the Tim on this server?

boreal iron
quartz kindle
#

lmao

#

that pic is like 5 years old

earnest phoenix
#

Fixed Glitch problem

#

Thanks Tim

digital ibex
#

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());
               });```
lyric mountain
#

is that in a bot's code?

boreal iron
#

lol

digital ibex
#

?

#

thats in the script tag

#

html

lyric mountain
#

ok, nice

earnest phoenix
#

I think they just checking you weren't doing something that obv wouldn't work

lyric mountain
#

gotta ask anyway, who knows ¯_(ツ)_/¯

boreal iron
#

The dom may not be loaded before the event is being registered

digital ibex
#

how would that work? cuz like

#

i pressed the button like half an hour after i reloaded the page lol

lyric mountain
#

where is your script block?

#

head or body?

digital ibex
#

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
boreal iron
#

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

digital ibex
#

preventDefault is deprecated?

lyric mountain
#

Try to move it at the end of your body
that's a possibility too since html loads from top to bottom

digital ibex
#

yeah, it is at the bottom

#

lemme try use functions, that was my problem before with xhr

boreal iron
#

I may wanna recommend a framework like jQuery

lyric mountain
#

jim carrey

boreal iron
#

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

digital ibex
#

i just copied the part from my old code and it works, thats so weird

#

the code was basically the same

timid trench
#

Gow do I add my server to top.gg?

digital ibex
#

i think

timid trench
digital ibex
earnest phoenix
#

Also, that isn't how you add a server thats how you add a bot

jovial nexus
#

How can i get the URL of an external emoji with only the ID

digital ibex
#

oh yeah whoops

earnest phoenix
# timid trench Yes but I also can't edit

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

timid trench
earnest phoenix
#

Mmm, do you have the proper perms to do so? I don't remember how top.gg servers work but I think they need to add you as an owner of the server as well on top.gg. Maybe someone more suited to help can do this and I think #support is a better channel for this

jovial nexus
#

How can i get the URL of an external emoji with only the ID?