#development

1 messages · Page 914 of 1

quartz kindle
#

@high geode you cannot create a member out of nowhere, you need to get the member from somewhere

pale vessel
#

those gifs look bad on mobile btw

tulip ledge
#

Sorry :/ Am kind of on a rush

neat ingot
#

yea on mobile they strenthed af :/

high geode
#

so const member = with what

neat ingot
#

i tried to waifu2x them to like, 20x, but they look trash lol

#

stretched *

quartz kindle
#

@high geode where is this code used? show full code

lyric mountain
#

Hi so I'm getting the error that it can't read sell_summary of undefined any idea why? Am I doing something wrong?
data.products[miniontype].sell_summary[0].pricePerUnit (This is an API btw)+
@tulip ledge do console.log(data.products)

neat ingot
#

i think on guild member add event

marble juniper
#

how can I get urls from a string as an array (I did use a node module for that but it doesn't detect urls like discord attachment urls)

lyric mountain
#

see if that entry exists

neat ingot
#

link i answered that already lol

tulip ledge
#

It does

#

Cuz data.products.BONE.sell_summary... worked

high geode
neat ingot
quartz kindle
#

@high geode full code

neat ingot
#

"im a string https://dekbot.com".match(/(?:(?:https?|ftp|file):\/\/|www\.|ftp\.)(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[-A-Z0-9+&@#\/%=~_|$?!:,.])*(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[A-Z0-9+&@#\/%=~_|$])/igm)

lyric mountain
#

do String(miniontype) then @tulip ledge

tulip ledge
#

ok

#

TypeError: Cannot read property 'sell_summary' of undefined

lyric mountain
#

hm

high geode
#

@high geode full code
@quartz kindle i full?

#

okay then

lyric mountain
#

wait

tulip ledge
#

Oi

#

Nvm

lyric mountain
#

@tulip ledge console.log(miniontype)

high geode
#

:))))))))

tulip ledge
#

The api stores it as CLAY_BALL not CLAY srry xd

high geode
#

and 9 photos more

#

xd

lyric mountain
#

@high geode just use hastebin goddamm

quartz kindle
#

at least use hastebin or something

high geode
#

wait

#

i send you in dm

sudden geyser
#

also why is your dbl token in the picture

lyric mountain
#

omg

sudden geyser
lyric mountain
#

lol hardcoded token

quartz kindle
#

@high geode you're trying to use member in the top level, you cant do that, there is no member there

#

you dont even need member

high geode
#

i need user

quartz kindle
#

if you want a guild, just do client.guilds.cache.get()

high geode
#

right?

quartz kindle
#

what do you want?

high geode
#

so

#

i want

#

welcome messages

#

god damn

strange mango
#

does anyone know how to allow iframes with nginx? I'm having issues with that

neat ingot
#

lulz

quartz kindle
#

then you need to use the memberAdd event

high geode
#

yes

#

1 sec

quartz kindle
#

you're putting that code in top level, outside of any event

neat ingot
#

the way i showed earlier worked for me hector, idk why it wouldnt for you 😦

strange mango
#

yeah it's weird

neat ingot
#

you could just allow iframes for all sites

strange mango
#

how

neat ingot
#

cant recall off the top of my head the header to do that

#

but there is one!

strange mango
#

current one: add_header Content-Security-Policy "default-src 'self' http: https: data: blob: 'unsafe-inline' frame-ancestors 'self' https://top.gg/bot/534632914445664267;" always;

quartz kindle
#
bot.on("guildMemberAdd", member => { // here is your member
  member.guild.channels...
})
``` @high geode
#

now you have a proper context to get a member from

high geode
#

thanks

neat ingot
#

whats your domain that your trying to iframe hector?

high geode
#

whats the const for message?

lyric mountain
#

http cannot iframe https iirc

quartz kindle
#

what message?

high geode
#

cant I use bot.on("guildMemberAdd", member, => { // here is your member
message.channel.send('message')
})

#

?

quartz kindle
#

there is no message in guildMemberAdd

#

guildMemberAdd gives you a member

#

you get a guild from the member

#

you get a channel from the guild

high geode
#

i need when someone joines that guild id

quartz kindle
#

then you send to that channel

high geode
#

on that guild id, channel id

#

to send a message

neat ingot
amber fractal
#

why not just make a .html file and test it yourself?

neat ingot
#

shows that for my domain, which is correct as i only allow my site and top.gg bot page to iframe

high geode
#

@quartz kindle

#
bot.on('guildMemberAdd', async member => {
     bot.guilds.get("699189120945094757").channels.get("706161523155796058").send(`message`);
}```
quartz kindle
#

why are you mixing client with bot

strange mango
high geode
#

now

#

is it good?

quartz kindle
#

yes, its good if you want to send a welcome message always to the same guild

#

even if the member joins a different guild

strange mango
#

@neat ingot it could be because of the html tag? I just have <iframe src='https://deltabot.tech></iframe>

high geode
#

oh

neat ingot
strange mango
#

I think I'll just put a screenshot of the site if I can't put an iframe

high geode
#

then what must i edit like when a member joines my server, that guild to send a message in a channel?

quartz kindle
#

when a member joins

high geode
#

i can sue

#

member.guild.channels.find("name", "nume")

#

use*

quartz kindle
#

you get the guild from the member

high geode
#

is it good?

quartz kindle
#

yes

high geode
#

member.guild.channels.find("name", "welcome")

quartz kindle
#

but change find to a function

high geode
#

but where must i insert that

neat ingot
#

i sue SAMEORIGIN too though inn my setup, so idk why thats disallowing it

quartz kindle
high geode
#

ok

#

1 sec

copper cradle
#

omg

sweet spade
#

/app/events/message.js:8 let perms = client.elevation(message); ^ TypeError: client.elevation is not a function at Client.module.exports.message (/app/events/message.js:8:22) at emitOne (events.js:121:20) at Client.emit (events.js:211:7) at MessageCreateHandler.handle (/rbd/pnpm-volume/13b65e33-103e-4d0a-8ef1-675f018a70c7/node_modules/.registry.npmjs.org/discord.js/11.6.4/node_modules/discord.js/src/client/websocket/packets/handlers/MessageCreate.js:9:34) at WebSocketPacketManager.handle (/rbd/pnpm-volume/13b65e33-103e-4d0a-8ef1-675f018a70c7/node_modules/.registry.npmjs.org/discord.js/11.6.4/node_modules/discord.js/src/client/websocket/packets/WebSocketPacketManager.js:108:65) at WebSocketConnection.onPacket (/rbd/pnpm-volume/13b65e33-103e-4d0a-8ef1-675f018a70c7/node_modules/.registry.npmjs.org/discord.js/11.6.4/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:336:35) at WebSocketConnection.onMessage (/rbd/pnpm-volume/13b65e33-103e-4d0a-8ef1-675f018a70c7/node_modules/.registry.npmjs.org/discord.js/11.6.4/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:299:17) at WebSocket.onMessage (/rbd/pnpm-volume/13b65e33-103e-4d0a-8ef1-675f018a70c7/node_modules/.registry.npmjs.org/ws/6.2.1/node_modules/ws/lib/event-target.js:120:16) at emitOne (events.js:116:13) at WebSocket.emit (events.js:211:7)
.-. welp

copper cradle
#

verified bot dev

high geode
copper cradle
#

const member = "";

strange mango
#

i sue SAMEORIGIN too though inn my setup, so idk why thats disallowing it
@neat ingot uh I don't have that option

copper cradle
#

client doesn't have an elevation function then

#

did you define it?

elder garnet
#

?

high geode
#

@copper cradle shut up, i really dedicate my self to learn.

topaz fjord
#

you don't need much to become verified bot dev @copper cradle

high geode
#

so was you at start too

#

so shut up

topaz fjord
elder garnet
topaz fjord
#

afaik

elder garnet
#

doesn't work

quartz kindle
#

@high geode no

elder garnet
#

i removed quotes

neat ingot
#

i'd try adding the x-frame option for sameorigin then, just to see how it responds.

elder garnet
#

still not working

copper cradle
#

@topaz fjord I know lol

neat ingot
#

add_header X-Frame-Options "SAMEORIGIN" always;

copper cradle
#

@elder garnet ids are strings

#

what do you want to check

elder garnet
#

for the message author's id

#

and check if its a specific id

copper cradle
#

well

neat ingot
#

also: remember to reload nginx conf. ive forgott hat a few times and wondered why changes werent working lol

elder garnet
#

doesn't work

copper cradle
topaz fjord
#

don't use !message.author.if

copper cradle
#

easy

elder garnet
#

was working last time

#

but now doesn't

#

idk why

#

doesn't work

copper cradle
#

don't use ! if you don't know what it means

strange mango
topaz fjord
#

it shouldn't have worked with !message.author.id

copper cradle
#

! is a negation operator

neat ingot
#

aha fml

elder garnet
#

ye

copper cradle
#

then why are you using it?

topaz fjord
#

if(!msg.author.id == "492506057814310923") {return;}
@elder garnet take out the ! in front and replace the == with !==

elder garnet
#

ima try again

strange mango
#

@neat ingot do I have to replace SAMEORIGIN by my bot's page?

elder garnet
#

ok

neat ingot
#
    proxy_hide_header X-Powered-By;
    #proxy_hide_header X-Frame-Options;
    
    add_header X-Powered-By "DekitaRPG" always;
    #add_header X-Frame-Options "" always;
    #add_header X-Frame-Options "ALLOW-FROM (https://top.gg/bot/652216670370398231)" always;
    add_header X-Frame-Options "SAMEORIGIN" always;
    add_header X-XSS-Protection "1; mode=block" always;
    add_header X-Content-Type-Options "nosniff" always;
    # enable strict transport security only if you understand the implications
    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;

        
    add_header Content-Security-Policy "default-src * data: 'unsafe-eval' 'unsafe-inline'; frame-ancestors 'self' https://top.gg/bot/652216670370398231" always;
    #add_header Content-Security-Policy "script-src 'self' 'nonce-ZGVrYm90UkQ'" always;
    add_header Referrer-Policy "strict-origin-when-cross-origin" always;
    add_header Feature-Policy "accelerometer 'none'; camera 'none'; geolocation 'none'; gyroscope 'none'; magnetometer 'none'; microphone 'none'; payment 'none'; usb 'none'" always;```
#

is all the headers i use in my nginx

#

rip formatting lol

elder garnet
#

going to try

sweet spade
elder garnet
#

elevation?

#

never heared of that before

sweet spade
#

me 2

#

hmm

neat ingot
#

hector, can you try adding https://www.w3schools.com/ to the csp for frame-ancestors

copper cradle
#

@sweet spade client doesn't have an elevation method

#

where did you copy that code from

sweet spade
#

I find it somewhere I cant remember :/

#

how I can fix that ?

copper cradle
#

remove that

#

it doesn't exist

elder garnet
#

still doesn't work

copper cradle
#

duhh

#

show your code

elder garnet
#
if(msg.author.id !== "492506057814310923") {return;}
copper cradle
#

what should happen

#

and what does actually happen

elder garnet
#

eval

#

eval(args[2])

copper cradle
#

where did you put that if statement at

elder garnet
#

ima console log

copper cradle
#

wait

#

show the rest of the code

elder garnet
#
    var args = msg.content.split(/[ ]+/)
    if(msg.content.startsWith(config.prefix + "eval")) {
        if(msg.author.id !== "492506057814310923") {return;}
            
        eval(args[2])
    }
#

in the

client.on('message', async msg => {
copper cradle
#

what does happen

elder garnet
#

i change the coins

#

with something like

copper cradle
#

you what

neat ingot
#

@elder garnet not an answer to your question, but if your doing a single line if statement, you can drop the {}. for example:

if(msg.author.id !== "492506057814310923") return;```
elder garnet
#

or something

copper cradle
#

no

#

in the command

elder garnet
#

ima try with a console

copper cradle
#

if say

#

for example

#

If I run the eval command it doesn't work

sweet spade
#

now I take error from event loader

copper cradle
#

show

elder garnet
#

ok

earnest phoenix
#

@weak parrot is @707618473966043227 approved?

elder garnet
#

when i try to do "goose eval console.log("blah blah")"

#

it doesn't work

sweet spade
elder garnet
#

ima come back later, lol

white gyro
#

{return;} is really ugly coding, no offense

copper cradle
#

@sweet spade the error isn't coming from that file

#

duh

#

read the error

#

the fact that it says eventLoader.js doesn't mean the file has an error, if you try to read the rest of the error it says 'cannot find module eventLoader.js'

#

which means that in your main file

#

where you're requiring eventLoader js you're getting an error

weak parrot
#

No

#

Seems it's still in queue @earnest phoenix

sweet spade
#

index requiring eventloader so... I need to delete it or change it ?

copper cradle
#

oml

#

show the code in your index file

#

did you make your bot asking should I delete or change

strange mango
#

hector, can you try adding https://www.w3schools.com/ to the csp for frame-ancestors
@neat ingot still getting the same error

neat ingot
#

this dude says:

sweet spade
copper cradle
#

show your file tree

#

you're just importing it wrong

neat ingot
#

a possible alternative would be to have your iframe use a unique 'nonce'

strange mango
#

what will that do?

#

oh

sweet spade
topaz fjord
#

you require quick.db twice 👀

copper cradle
#

weird

neat ingot
#

tbh csp is a dick. i had a bunch of trouble getting all mine working as well. havent touched it since incase it breaks again lol

copper cradle
#

the file is where it should be

#

and you're requiring it correctly

#

do you require it anywhere else?

earnest phoenix
#

Seems it's still in queue @earnest phoenix
@weak parrot Ok Thx

sweet spade
#

hmm Im going to take code in my another bot It can be solve problem I think

#

I will try that

neat ingot
strange mango
#

@neat ingot I changed the header to yours (mine wasn't exactly similar), now its not giving any log at all

#

also do you think it could be blocked by cloudflare?

neat ingot
copper cradle
#

it's working tho

strange mango
#

oh

#

omg

neat ingot
#

seems to be working though?

#

lol

strange mango
#

uh but its not showing for me

copper cradle
#

lmao

earnest phoenix
#

I made a custom prefix command with quick.db and now i want to ask, if i want to pun in another command ${prefix} i should define prefix like that?
let prefix = db.fetch(`prefix_${message.guild.id}`)

neat ingot
#

lmao

#

f

copper cradle
#

but remove that white shit from dbl

neat ingot
#

^

#

can use css styles in your bot description to customize the page 🙂

earnest phoenix
#

@earnest phoenix yes.

copper cradle
#

hey

#

that pic

strange mango
#

but its still not showing for me

earnest phoenix
#

lol

maiden mauve
#

did discordmessage.delete get changed?

earnest phoenix
#

@earnest phoenix i did this but when i use a command with ${prefix} in it it doesn't work

neat ingot
#

oh, you have your support page directly on your site, thats neat, ill have to pinch that idea 😄

maiden mauve
#

all of the sudden I'm getting errors on code that I didn't touch

strange mango
neat ingot
#

also: gotta love those font awesome icons 😄

strange mango
#

thanks lol

earnest phoenix
#

@earnest phoenix do you defined prefix in (message.js)?

onyx hare
#

I need help I’m trying to make a basic private bot for shits n giggles type but I want it so where if a command is entered it’s deleted and replaced by the outcome I can’t see anything on google that answers my question

neat ingot
#

wow, dbl blocks a ton of things on your page

earnest phoenix
#

@earnest phoenix i have defined once when i made the custom prefix in index.js, and then if i want in a command.js it doesn't work

#

my bot

maiden mauve
#

yikes

earnest phoenix
#

what the

maiden mauve
strange mango
#

wow, dbl blocks a ton of things on your page
@neat ingot maybe because its a sandbox iframe

maiden mauve
#

anyone have any idea why my msg isn't a valid object?

earnest phoenix
#

@earnest phoenix interesting..

earnest phoenix
#

@earnest phoenix oh nevermind, i solved it

maiden mauve
#

that code has been working fine for months

#

and suddenly its the devil

amber fractal
#

@maiden mauve message.delete()'s options are an object now

earnest phoenix
#

@maiden mauve do {timeout: 5000}

onyx hare
#

@maiden mauve I’m having that exact same issue 😂 with deleting message

neat ingot
#

oooohhh

#

thats my ad blocker stopping those i think

maiden mauve
#

ahhh

neat ingot
#

lulz, f

maiden mauve
#

very recent change?

amber fractal
#

no

maiden mauve
#

hmm

amber fractal
#

it's been on master forever

#

now stable

maiden mauve
#

weird, I just started getting the error today

amber fractal
#

did you just update d.js?

copper cradle
#

ofc

maiden mauve
#

updated a week ago

#

its possible I just didn't wait for the event to occur for some time

#

thanks for heads up

strange mango
#

chrome is blocking it lol

earnest phoenix
#

@earnest phoenix any idea why after i changed the prefix from a server the commands don't work with the changed prefix but with the old one ?

neat ingot
#

oh yea wth

#

firefox it loads fine, but chrome poops out

copper cradle
#

another reason to switch

neat ingot
#

omfg

#

and my bot too wth

earnest phoenix
#

[ERR_INVALID_ARG_TYPE]: The "id" argument must be of type string. Received undefined trying to switch from command.execute to module.exports.run

strange mango
#

lol usually its firefox blocking things that chrome doesn't

copper cradle
#

that has nothing to do with renaming an exported function

#

lmfao

earnest phoenix
#

Someone who know quick.db can help me ?

neat ingot
#

fml, now i too need to deal with this crap lol

earnest phoenix
#

how i use fetchMessage to dele a message?

#

like
!delete <messageID>

neat ingot
#

step 1, fetch message,
step 2, call delete on message.

copper cradle
#

lmao

earnest phoenix
#

ok :v

neat ingot
#

:/

strange mango
#

there's no way to bypass that?

amber fractal
#

dont use chrome?

earnest phoenix
#

LOLLLLLLLLLLLLLLLLLLLL

strange mango
#

thats not a solution

earnest phoenix
#

but true

amber fractal
#

it's built into google

earnest phoenix
#

thats not a solution
@strange mango agreed

amber fractal
#

that's your solution

#

or fix the content

quartz kindle
#

mixed content has been deprecated for ages no? it always showed the warning that it would be blocked in the future

neat ingot
#

this suggests its from loading resources via http, im certain my site doesnt do that though :/

amber fractal
#

do resources you load also load resources?

neat ingot
#

the only external resource is google analytics :/

#

everything else is hosted on site

#

and i guess paypal too, but thats on a different route that isnt the one being framed.

earnest phoenix
#
(node:4384) UnhandledPromiseRejectionWarning: DiscordAPIError: Unknown Message
    at C:\Users\Usuario Estandar\node_modules\discord.js\src\client\rest\RequestHandlers\Sequential.js:85:15
    at C:\Users\Usuario Estandar\node_modules\snekfetch\src\index.js:215:21
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
(node:4384) 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(). (rejection id: 2)
(node:4384) [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.
(node:4384) UnhandledPromiseRejectionWarning: #<Collection>
(node:4384) 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(). (rejection id: 3)
#

oooooookk

#
 if (command === 'deletemessage') {
    // Await !vote messages
    const filter = m => m.content.startsWith(`yes`);
    // Errors: ['time'] treats ending because of the time limit as an error
    message.channel.awaitMessages(filter, { max: 2, time: 60000, errors: ['time'] })
    message.channel.fetchMessage(args[0])
      .then(message => message.delete())
      .catch(message.channel.send('Error al no poder eliminar el mensaje'));
  }
neat ingot
#

i wish google would just die already 😐

strange mango
#

@neat ingot actually I think it was just missing a colon, but now its saying Refused to display 'https://deltabot.tech/' in a frame because it set 'X-Frame-Options' to 'sameorigin'. again. Can you tell me if it works on firefox?

neat ingot
#

nah blocked again

earnest phoenix
#

need help with a let commands argmunet

#

let commands = {}

#

does something go in the parenthesis

mossy vine
#

@strange mango i think thats because of your site

strange mango
#

why

mossy vine
#

because it has an x-frame-options header set to SAMEORIGIN

strange mango
#

k lemme remove that header

analog walrus
#

Is anyone familiar with Heroku and might be able to help me figure out how why my branch won't deploy?

strange mango
#

I removed the header but its still giving the error

simple stump
#

Hey. I'm a bit confused as to why I keep getting a null error in my code. All I do is talk (although that does trigger the client.on('message', message =>) and don't know how to fix it. Can anyone help me out here?
Code: https://srcb.in/31c26308f8
Error: https://srcb.in/4289777473

sudden geyser
#

member is null. Was the command used in a guild? Is the guild member cached?

simple stump
#

No it wasn't cached

#

That was the issue

#

I fixed it 😮

nimble escarp
#

Hey there! I'm having a problem.
Guess I don't full understand discord.js but I can't figure out how to listen for new reactions on a message after the bot restarts.
Currently I'm listening for the messageReactionAdd even on the client.

#

I want to make the bot give out a role to users who react in #rules (when they accept rules)

sonic lodge
#

the event doesn't emit on messages that aren't cached

#

you should try using partials

nimble escarp
#

I tried fetching messages in the channel but I guess that doesn't cache them?

const channel = this.guild.channels.cache.get(
            "chan_id",
        ) as Discord.TextChannel;
        channel.messages.fetch({ limit: 100 });
cinder patio
#

If the message is old then that won't work, using partials is the only way to do it

#

or you can save the message ID in a database and fetch it when the bot starts up

sudden geyser
#

don't you need to resolve the promise first

nimble escarp
#

it resolves itself

cinder patio
#

He's not using the returned messages from the fetch so no

nimble escarp
#

Since I don't need the value(s) then I don't need to use await or .then

#

My idea was to fetch the messages so that it puts them in the cache so they'd work with messageReactionsAdd.

sudden geyser
#

oh yeah nvm thought it took an api action.

white anvil
#

its still better practice to await promises

#

so u can properly handle rejections

nimble escarp
#

Not necessarily everywhere though. In this case I should await the promise but I wouldn't necessarily agree that it's better practice in general.

#

Also, thanks @cinder patio. Forgot to respond!
I'll take a look at partials MonjiroPray

white anvil
#

yeah but if it fails for whatever reason u cant handle it and you'll just get an unhandled promise rejection error

#

better to await and wrap in try catch

merry portal
#

Hey can someone help

lyric mountain
#

if you ask...

honest perch
#

dont ask to ask

#

smh

merry portal
#

Im trying to make a bot but when I do some commands it send 2 repones

nimble escarp
#

-ask2ask
EDIT: forgot it's for mods only

honest perch
#

show us the code too lmao

lyric mountain
#

Im trying to make a bot but when I do some commands it send 2 repons
@merry portal see if you're not creating two clients

merry portal
#

?

honest perch
#

also naming your self mee6 isnt the best idea. Showing the code will make it easier for us to find the error

merry portal
#

const Discord = require('Discord.js');
const bot = new Discord.Client();

const token = ';

const PREFIX = '?';

bot.on('ready', () =>{
console.log('this bot it online')
})

bot.on('message', message=>{

let args = message.content.substring(PREFIX.length).split(" ");

switch(args[0]){
    case 'ping':
        message.reply('your mom')
        break;
    case 'website':
        message.channel.send('')
        break;
    case 'info':
        if(args[1] === 'Version'){
            message.channel.send('Version 1.0.1');
        }else{
            message.channel.send('Invalid Args')
        }
    break;
    case 'clear':
        if(!args[1]) return message.reply('Error please Define secound arg')
        message.channel.bulkDelete(args[1]);
        break; 
    case 'embed':
        const embed = new Discord.MessageEmbed()
        .setTitle('User Info')
        .addField('Player Name', message.author.username)
        .addField('Version', '1.0.1')
        .addField('Current Sever', message.guild.name)
        .setColor(0x89FFA6)
        message.channel.send(embed);
    break;

}
lyric mountain
#

oh my

#

smh my head my head

honest perch
#
const Discord = require('Discord.js');
const bot = new Discord.Client();

const token = '';

const PREFIX = '?';

bot.on('ready', () =>{
   console.log('this bot it online')
})

bot.on('message', message=>{

    let args = message.content.substring(PREFIX.length).split(" ");

    switch(args[0]){
        case 'ping':
            message.reply('your mom')
            break;
        case 'website':
            message.channel.send('')
            break;
        case 'info':
            if(args[1] === 'Version'){
                message.channel.send('Version 1.0.1');
            }else{
                message.channel.send('Invalid Args')
            }
        break;
        case 'clear':
            if(!args[1]) return message.reply('Error please Define secound arg')
            message.channel.bulkDelete(args[1]);
            break; 
        case 'embed':
            const embed = new Discord.MessageEmbed()
            .setTitle('User Info')
            .addField('Player Name', message.author.username)
            .addField('Version', '1.0.1')
            .addField('Current Sever', message.guild.name)
            .setColor(0x89FFA6)
            message.channel.send(embed);
        break;

    }
#

fixed

#

now we can see it lmao

lyric mountain
#

why is everything blue?

sudden geyser
#

do you have two instances running

nimble escarp
#

cuz he forgot to terminate a string

lyric mountain
#

const token = ';

merry portal
#

?

nimble escarp
#
- const token = ';
+ const token = '';
sudden geyser
#

tried hiding their token but messed it up

#

I assume that's not the issue here

lyric mountain
#

thank u mr. git

honest perch
#

why is everything blue?
discord birthday soon

merry portal
#

oh yea I hid my token

#

Thats why thats missing

lyric mountain
#

misly terminate that string plz

honest perch
#

?

#

not my code

lyric mountain
#

ik

#

but put a ' there

#

it'll be better to read

sudden geyser
#

show where you login

merry portal
#

bot.login(token);

honest perch
merry portal
#

oh

#

there

#

So can someone please tell what I should fix

sudden geyser
#

it's either you have more than one instance running or you login some where weird in your code. can you upload your entire file to a site like https://hastebin.com as what you previously showed us is not the entire thing.

merry portal
#

Ok

honest perch
#

also would recommend making a command handler

nimble escarp
#

It could listen to the event twice as well.

#

That was my first thought, don't know if this is the full code or not.

#

And could you provide screenshot of the problem?
What command you're sending and what you're receiving.

honest perch
#

also @merry portal how old are you?

merry portal
#

I can not classfiy that

#

Oh

mossy vine
#

you know instead of calling out publicly you can report to a mod right

amber fractal
honest perch
#

good point

merry portal
#

But can someone help

earnest phoenix
#

smh, underage

nimble escarp
#

Well hey, at least he's interested in development pepeshrug

honest perch
#

shouldn't be on discord anyway.

earnest phoenix
#

how i upload a pip of python?

nimble escarp
undone carbon
#

And the image would pop up?

summer torrent
#

image uploader & sharex

nimble escarp
#

Well there are many approaches but the one that comes to mind instantly is that you can use .htaccess rewrite and php on a webhost.

undone carbon
#

So can I host the images on a same website host?

nimble escarp
#

Sure but it really depends on the project.
If the images are going to be accessed a lot and if you need performance then you should think about a cdn.

#

You can still use the webhost to display the images under that custom path.

undone carbon
#

I'm just thinking of uploading screenshots.

earnest phoenix
#

Cannot read property 'get' of undefined

at

     let commandfile = bot.commands.get(cmd.slice(prefix.length));```

code :

```js
let prefix = botconfig.prefix
     let messageArray = message.content.split(" ");
     let cmd = messageArray[0];
     let args = messageArray.slice(1);
     let commandfile = bot.commands.get(cmd.slice(prefix.length));
     if(commandfile) commandfile.run(bot, message, args);
     if(commandfile) db.add(`commandran_${message.guild.id}`, 1);```
#

Add if (!commandfile) return to your code @earnest phoenix

#

Oky

#

wdym?

#

then no queue :d?

#

yea

strange mango
hollow prawn
#

from the mozilla mdn docs on Date() I get error Date.prototype is not a constructor

#

what i'm trying to do is, have my date created differently when my bot comes online

#

so instead of using Date().toString() I build my own showcase of current day, month, year --- current time

#

on the docs it's showing that Date.prototype.getDate() is the usage, and I do this code:

bot.on('ready', async function() {
  const tn = new Date.prototype;
  console.log(`${bot.user.username} is online.\n${tn.getDate()}/${tn.getMonth()+1}/${tn.getFullYear()} --- ${tn.getHours()}:${tn.getMinutes()}:${tn.getSeconds()}`);
  const status = await bot.db.query(`SELECT * FROM botStats`).catch(console.error);
  if (status[0].motd.length > 1) {
    await bot.user.setActivity(`${bot.guilds.size} servers // fl.help / MOTD: ${status[0].motd}`, { type: "WATCHING" }).catch(console.error);
  }
  let gIDs = bot.guilds.map(g => g.id);
  for (const g of gIDs) {
    let gInDB = await bot.db.query(`SELECT * FROM serverInfo WHERE serverID = ${g}`).catch(console.error);
    if (gInDB[0].serverID.length < 1) {
       await bot.db.query(`INSERT INTO serverInfo (serverID) VALUES ('${g}')`);
       console.log(`Added ${g} to database as it was not in it`);
    }
  }
  const mainBotChannel = bot.channels.get('618929645173342210');
  const botRunning = new Discord.RichEmbed()
  .setColor('#63ff48')
  .setDescription('Started and running')
  .setFooter(`${tn.getDate()}/${tn.getMonth()+1}/${tn.getFullYear()} --- ${tn.getHours()}:${tn.getMinutes()}:${tn.getSeconds()}`)
  mainBotChannel.send(botRunning);
});```
#

mby I shouldn't use new before Date.prototype thinkW

neat ingot
#

hector you got your iframeworking?

#

or is that just an image of what the iframe should show?

lyric mountain
#

@hollow prawn there's no Date.prototype

#

just do new Date()

hollow prawn
#

ye i figured it out, but i got lied by this

#

lol

neat ingot
#

for chrome too?

#

yea, when you visit your top gg bot page using google chrome, does your iframe show? mine only shows in firefox cause of changes chrome made late last year/this year that i cannot fix for some reason :/

#

whats your site ip/domain that the iframe points to if u dun mind sharing? i want to see what security headers its using

#

ty 🙂

#

lol, no security headers at all. f rating. 😄

#

even why i try do that for the one route im trying to frame it doesnt allow it :/

knotty steeple
#

@strange mango thats not how u css

neat ingot
#

fk it, imma just show an image. this is now worth all the hasstle, nor worth reducing my site security. ill figure a fix in future if needed lol

#

dekbot.com but its going on and offline like mad atm cause im changing and trying things 😛

earnest phoenix
#

hello that i can check for sql, a
THIS? (PHP) URL: phpactiovation.php?email=****&vkey=*** ```php
if (!isset($_GET['email']) || !isset($_GET['vkey'])) {
header('Location: reg.php');
exit();
} else {

$email = $_GET['email'];
$vkey = $_GET['vkey'];

$sql = mysqli_query($con, "SELECT * FROM users WHERE email=$email AND vkey=$vkey AND verify=0");

if ($sql->num_rows > 0) {
    $sql2 = mysqli_query("UPDATE users SET verify=1 WHERE email=$email");
    refirect();
} else 
echo "asd";

}```

slim sparrow
#

ughhhhh

strange mango
#

hector you got your iframeworking?
@neat ingot unfortunately I didn't, so I'll just put a screenshot of the site

neat ingot
#

yea i checked source and seen that, i was gonna do the same, but its itching my brain now

#

so, i'd like to thank you for raising it to my attention and ruining my day ❤️

#

im determined to figure out how to allow the iframe on chrome but only for that specific route im showing in the iframe (/mini)

simple stump
#

How would I add a role when I'm using client.on('message', message=> and not client.on('guildMemberAdd', member =>?
Ex. I want to add the 'Shield' role to an user here:

    // Shield
    if (message.content.startsWith(`${prefix}shield`)) {
        con.query(`SELECT * FROM energy WHERE id = '${message.author.id}'`, (err, rows) => {
            if (err) throw err;
            let xp = rows[0].xp;
            if (xp < 10000) {
                message.reply("You don't have enough energy!");
            } else {
                // Add shield role
            }
            console.log(xp);
        })
    }

How would I do that?

sudden geyser
#

You get the guild member with message.member and then add the roles like you would

#

there's no guaranteed the member will be cached or exist.

marble juniper
#

if you wanna make sure the member is cached you can fetch it

glacial thicket
#

I want to make my bot status change like every 30 seconds, and I'll need loop on a timer. how do I make a loop so the code keeps repeating?

copper cradle
#

yeah

#

but like

#

what language

#

always specify that

glacial thicket
#

Oh yeah sorry python

copper cradle
#

ah well you can use the task.loop() decorator

#

lemme get the docs of it

glacial thicket
#

Okay, thanks!

simple stump
#

Sorry for the ping @sudden geyser I'm still a bit confused. I tried using this method:

var role = message.member.guild.roles.find(role => role.name === "Shielded");
message.member.roles.add(role);

But I got the error message.member.guild.roles.find is not a function. I assume I'm doing the role variable wrong?

sudden geyser
#

Yeah in v12 it's a manager, so you should be using the .find function on the cache collection.

earnest phoenix
#

cache.find

simple stump
#

Alright. Cool. So it would be:

message.member.cache.find
```?
sudden geyser
#

noop

earnest phoenix
#

roles.cache.find

sudden geyser
#

should be .roles.cache.find

simple stump
#

ohhh i see

#

okay thx! ill try that out

#

Oh no I got a deprecation warning:

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.

And than the fact that the role supplied is not a role/snowflake/array/collection. I already have the role created (which the bot creates if it doesn't exist).

    // Shield
    if (message.content.startsWith(`${prefix}shield`)) {
        con.query(`SELECT * FROM energy WHERE id = '${message.author.id}'`, (err, rows) => {
            if (err) throw err;
            let xp = rows[0].xp;
            if (xp < 1000) {
                message.reply("You don't have enough energy!");
            } else {
                // Add shield role
                var role = message.member.roles.cache.find(role => role.name === "Shielded");
                message.member.roles.add(role);
            }
            console.log(xp);
        })
    }
amber fractal
#

make sure it's properly getting the role

#

use like console.log(role) after var role = ...

simple stump
#

Hmm it says undefined thinker

#

*after logging it

#
var role = message.member.roles.cache.find(role => role.name === "Shielded");
message.member.roles.add(role);
console.log(role);
quartz kindle
#

you're searching for the role in the member roles

simple stump
#

Wdym?

quartz kindle
#

if you have roles A B C D, and member has roles A and B added to them, and you search for role C, member will not have it

simple stump
#

Oh I see.

quartz kindle
#

you have to search it from the guild

simple stump
#

hmm wont it send an error tho?

#

since im using:

client.on('message', message =>
quartz kindle
#

role is undefined, which means it wasnt found

marble juniper
#

no

#

message.guild.roles works

simple stump
#

okay. ill try that than

#

thx

earnest phoenix
#

Where can i use bot command

#

s

simple stump
#

Yay it works. Thanks 🙂 This might've caused another issue however. I keep getting this null error:

if (!message.member.hasPermission("ADMINISTRATOR")) {
                            ^

TypeError: Cannot read property 'hasPermission' of null

Which is always this similar line:

if (!message.member.hasPermission("ADMINISTRATOR")) {
earnest phoenix
#

Anyone mind giving me their opinion on something?

quartz kindle
#

did the message come from a DM?

simple stump
#

no (if ur talking to me)

quartz kindle
#

@earnest phoenix just ask lol, dont ask to ask

simple stump
#

^

quartz kindle
#

@simple stump the only way message.member would be null is if the message came from a dm, or if for some reason the member isnt cached

earnest phoenix
#

oh sorry lol, well i'm working on a dashboard for my bot, and im making a page to manage punishments, and I need someone to critique my punishment card, cause it looks weird and idk what to do with it

simple stump
#

That's weird. Well I'll have to look into it than. Thanks

quartz kindle
#

@earnest phoenix work on the font spacing, make it smaller and make each area more distinct and separated

earnest phoenix
#

I'll do that, thanks :)

#

.

neat ingot
#

@strange mango I fixed it ^_^

earnest phoenix
#

my terminal is spamming TypeError [ERR_INVALID_ARG_TYPE]: The "id" argument must be of type string. Received undefined at validateString (internal/validators.js:117:11) at Module.require (internal/modules/cjs/loader.js:1035:3) at require (internal/modules/cjs/helpers.js:77:18) at Client.<anonymous> (C:\Users\jjpla\OneDrive\Documents\GitHub\disc-bot-rep\bot.js:48:27) at Client.emit (events.js:310:20) at MessageCreateAction.handle (C:\Users\jjpla\OneDrive\Documents\GitHub\disc-bot-rep\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14) at Object.module.exports [as MESSAGE_CREATE] (C:\Users\jjpla\OneDrive\Documents\GitHub\disc-bot-rep\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32) at WebSocketManager.handlePacket (C:\Users\jjpla\OneDrive\Documents\GitHub\disc-bot-rep\node_modules\discord.js\src\client\websocket\WebSocketManager.js:386:31) at WebSocketShard.onPacket (C:\Users\jjpla\OneDrive\Documents\GitHub\disc-bot-rep\node_modules\discord.js\src\client\websocket\WebSocketShard.js:436:22) at WebSocketShard.onMessage (C:\Users\jjpla\OneDrive\Documents\GitHub\disc-bot-rep\node_modules\discord.js\src\client\websocket\WebSocketShard.js:293:10) (node:47720) 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: 150)

simple stump
#

How would I check whether an user's ID has been inputted? For example I have this snippet of code:

    if (message.content.startsWith(`${prefix}shield`)) {
        let ts = Date.now();
        con.query(`SELECT * FROM energy WHERE id = '${message.author.id}'`, (err, rows) => {
            if (err) throw err;
            let xp = rows[0].xp;
            if (xp < 1000) {
                message.reply("You don't have enough energy!");
            } else {
                // Add shield role
                var role = message.guild.roles.cache.find(role => role.name === "Shielded");
                message.member.roles.add(role);
                message.channel.send("Inserting data for " + message.author.id + "... Please wait.");
                con.query(`INSERT INTO shielded (id, time) VALUES ('${message.author.id}', '${ts}')`, (err, rows) => {
                    if (err) throw err;
                    message.reply("You have been shielded for 12 hours.");
                })
            }
        })
    }

Which inserts the user's ID into the database. I'm slightly familiar with MySQL (I've used in PHP a LOT) but always been stumped on how to check if something exists. Can someone give me an example? Thanks for the help!

white anvil
#

check that the id matches a user in the cache

#

or use rest

simple stump
#

No I mean in MySQL... In PHP I would use:

if (mysqli_num_rows($check) > 0) {
#

But in Node it's different

#

so i'm just wondering what the way to do this is in node

quartz kindle
#

it depends on the library/driver you're using, not node

#

each library has their own way of interacting with sql

#

you have to check the docs for the one you're using

hollow prawn
#
if (!(channel.permissionOverwrites.get(rows[0].muteRoleID).deny & new Discord.Permissions('SEND_MESSAGES', 'SEND_TTS_MESSAGES', 'ADD_REACTIONS', 'EMBED_LINKS', 'ATTACH_FILES', 'SPEAK', 'USE_VAD').bitfield)) {
                  channel.overwritePermissions(channel.guild.roles.find(r => r.id === rows[0].muteRoleID), { SEND_MESSAGES: false, SEND_TTS_MESSAGES: false, ADD_REACTIONS: false, EMBED_LINKS: false, ATTACH_FILES: false, SPEAK: false, USE_VAD: false }, 'Updating perms for the mute role').catch(console.error);
                  console.log(`Denying perms for ${rows[0].muteRoleID} in channel ${channel.id} of server ${channel.guild.id}`);
                }```
am I able to do this compare in the `IF` statement?
I've tried to do such before, but I've had troubles, for example ones that are promises and require awaiting to actually do it
so I want to know, if something doesn't need an awaiting/callback function and etc, can I work with it in a `IF`?
simple stump
#

tim im just using MySQL; node.js and using phpMyAdmin. i dont think it rlly depends...

#

i mean

open flicker
simple stump
#

i just need to check whether a row exists

quartz kindle
#

mysql is not built in into node

#

you use mysql in node through a driver/library/package

#

just like you use mysqli in php

simple stump
#

oh i see.

quartz kindle
#

the way you posted is mysqli's specific way of doing it, you need to see whats the way for the package you're using

simple stump
#

would saying that i use the MysQL library than?

hollow prawn
#

seems like you're using d.js library
after you get the row and if nothing is found on user ID/serverID etc you can do if (row.length < 1) { code to run here }

simple stump
#

i honestly have no clue how to find an existing row

quartz kindle
#

if you did npm install mysql, yes

simple stump
#

^ thats what i did

quartz kindle
#

check the npm page of the mysql library

#

you'll find the docs there

simple stump
#

okay. thx for the help

true ravine
#

Anyone got any tips on how to decide if updates are major, minor or patches (using semantic versioning)?

#

I mean are there weirdos that are gonna get mad if I don't do it right?

copper cradle
#

if you fixed a bug or renamed something

#

patch

#

if you added new stuff removed stuff but it doesn't break any existing code

#

minor

earnest phoenix
copper cradle
#

and if you literally changed a big part of the project and it breaks existing code or you literally removed lots or features

#

major

#

or you can read that too

true ravine
#

Thank you very much, that kinda explains it better than the site imo

open flicker
viral torrent
#

Pls ready webhook thanks vote code ❤️

copper cradle
#

??

#

what the fuck are you even asking for

#

I don't understand

true ravine
#

I think they want the code for a webhook to fire when someone votes?

#

Idk

viral torrent
#

Yeah @true ravine

pale vessel
#

no we don't give out codes

#

read the docs

earnest phoenix
pale vessel
#

interesting

copper cradle
#

well saying pls ready webhook thanks vote code ❤️ doesn't say anything

#

I've seen some engrish here

pale vessel
#

lmao ye

#

vote code thanks code give?

copper cradle
#

but that's just plain unreadable

#

lol

earnest phoenix
#
    await channel.send(f'Antes: {before.content}, Despues:
{after.content}')
AttributeError: 'NoneType' object has no attribute 'send'
slender thistle
#

channel is None

earnest phoenix
#
@client.event
async def on_message_edit(before, after):
    channel = client.get_channel(f'{int(get_channelID(after))}')
    await channel.send(f'Antes: {before.content}, Despues: {after.content}')

#

what?

slender thistle
#

Uhh

earnest phoenix
#

the value of the json is none?

#

i have lag ;vvvvvvvvvvv

slender thistle
#

get_channel takes an int

earnest phoenix
#

what?

#

the value of the json is none?

slender thistle
#

get_channel takes an int

#

not a string

earnest phoenix
#

i have lag ;vvvvvvvvvvv

copper cradle
#

oh shit a papulince

#

yuck

slender thistle
#

get_channel returns a Channel object if your bot could find a channel under given ID

copper cradle
#

@earnest phoenix in d.py ids are ints not strings

earnest phoenix
#

oh

slender thistle
#

What is get_channelID anyway

earnest phoenix
#
def get_channelID(ctx):
    with open("logs.json", 'r') as f:
        logs = json.load(f)
    return logs[str(ctx.guild.id)]
copper cradle
#

in that case a str

#

if logs is a dict

slender thistle
#

And what type will be returned from that function

copper cradle
#

which must be the case

amber fractal
#

I legit just got $50 for inviting a bot to someone's server

copper cradle
#

dude

amber fractal
#

what the hell

copper cradle
#

omg

delicate zephyr
copper cradle
#

@amber fractal on freelancer?

amber fractal
#

fiverr

copper cradle
#

omg

amber fractal
#

I even told him he didnt need to pay

#

I thought he wanted a custom bot

copper cradle
#

I'm gonna do that too

#

lmao

amber fractal
#

he insisted on paying

#

wait wrong channel

open flicker
#

@delicate zephyr, I want to get it in userinfo

earnest phoenix
#

so? @copper cradle

copper cradle
#

?

#

we don't use ¿ in english

slender thistle
#

You need to give get_channel an integer

earnest phoenix
#

oh

copper cradle
#

that's only in spanish thoñ

earnest phoenix
#

im spanish xd

copper cradle
#

I know

slender thistle
#

You are giving it a string

#

An unnecessary f-string, to be precise

earnest phoenix
#

oh

copper cradle
#

yeah

#

btw

#

don't use ¡ either

earnest phoenix
#

i dont understand(my english is bad xd)

copper cradle
#

we only use ? and ! in english

#

and we don't use ¿ nor ¡

royal portal
#

does anyone know what 'AbortError' means

#

the user aborted a request

woeful sphinx
#

the request took too long to receive a respond so it just dipped

royal portal
#

that wouldnt be my fault lol

#

its discord

woeful sphinx
simple stump
#

I am legit so confused. If I do console.log(rows[0].time), I get no errors and get printed a nice string of numbers. But if I do if (ts = rows[0].time + 1000), I get this error:

throw err; // Rethrow non-MySQL errors
      ^

TypeError: Cannot read property 'time' of undefined

This legit makes NO SENSE.
Code:

        con.query(`SELECT * FROM shielded WHERE id = '${message.author.id}'`, (err, rows) => {
            if (err) throw err;
            if (ts = rows[0].time + 1000) {
                var role = message.guild.roles.cache.find(role => role.name === "Shielded");
                message.member.roles.remove(role);
                message.reply("Shielded role removed.");
            }
            //console.log(rows[0].time);
        })

I have my ts variable defined which is Date.now. What the heck???? How do I fix this?

woeful sphinx
#

I'm assuming that rows can be an empty array. If true, then rows[0] will be undefined. This will probably occur when shielded does not include a row with the user's ID

earnest phoenix
#

that's not how js works

#

eltik

simple stump
#

?

#

what did i do wrong than? and @woeful sphinx it is defined. i have a row in my db where id is equal to my id

#

if it isnt i could see why that could be an issue

#

and yes cry i prob am not comparing ts and rows[0].time

#

but im still a bit stumped on how to fix the error itself

#

cause when console.loging its fine

#

but when comparing the two variables it isnt

woeful sphinx
#

print out rows[0] right after if (err) throw err;. at some point itll be undefined

simple stump
#

alright

#

i get the same thing

#

1588884916929

#

which is what i want

#

sry its prob not clear what my goal is

woeful sphinx
#

so rows[0] is 1588884916929?

simple stump
#

i basically want to check if rows[0].time plus <some_number> is equal to ts, or the current date

#

yes

#

because rows[0] is the time stamp

woeful sphinx
#

it should look something like

{
  time: 1588884916929
}```
simple stump
#

yes

#

but its not stored in a json file its stored in a mysql db 😛 but yes same premise

woeful sphinx
#

right. but the mysql library will return the data in an object

simple stump
#

oh? i dont believe ive seen that...

woeful sphinx
#

when you select, it'll return an array of objects where each object has a key of the column along with its value

royal portal
#

does anyone know if this is possible

client.on('ready', () => {
console.log("Successfully logged in.")
setInterval(() => {
process.exit()
}, 1800000)
});
woeful sphinx
#

setInterval?

royal portal
#

yes

#

to restart every 30 mins

woeful sphinx
#

it'll close off so no point in making that an interval

simple stump
#

GoogleSites hmm true. so do u think my MySQL query is incorrect?
@woeful sphinx

woeful sphinx
#

use setTimeout and a package like pm2 to restart it

royal portal
#

im using pm2

#

if process.exit then it will restart

woeful sphinx
#

then yeah go for it

#

@simple stump your query is good. you're just handling it incorrectly. here's an example in node14

con.query(`SELECT * FROM shielded WHERE id = '${message.author.id}'`, (err, rows) => {
  if (err) throw err;

  const [ row ] = rows;

  if (row?.time + 1000 === ts) {
    const role = message.guild.roles.cache.find(role => role.name === "Shielded");
    message.member.roles.remove(role);
    message.reply("Shielded role removed.");
  }
});```

or <14

```js
con.query(`SELECT * FROM shielded WHERE id = '${message.author.id}'`, (err, rows) => {
  if (err) throw err;

  const [ row ] = rows;

  if (row && row.time + 1000 === ts) {
    const role = message.guild.roles.cache.find(role => role.name === "Shielded");
    message.member.roles.remove(role);
    message.reply("Shielded role removed.");
  }
});```
simple stump
#

alright. cool thansk for the help 🙂 ill try it out

woeful sphinx
#

I'm not sure what you're trying to achieve though. I'm assuming row.time + 1000 will return a timestamp and you're making sure it's been at least a second (cooldown maybe). but this will not work

rocky lintel
#
at Function.normalizeFields (/home/container/node_modules/discord.js/src/structures/MessageEmbed.js:443:8)
at MessageEmbed.setup (/home/container/node_modules/discord.js/src/structures/MessageEmbed.js:77:91)
at new MessageEmbed (/home/container/node_modules/discord.js/src/structures/MessageEmbed.js:18:10)
at embedLikes.map.e (/home/container/node_modules/discord.js/src/structures/APIMessage.js:164:40)
at Array.map (<anonymous>)
at APIMessage.resolveData (/home/container/node_modules/discord.js/src/structures/APIMessage.js:164:31)
at TextChannel.send (/home/container/node_modules/discord.js/src/structures/interfaces/TextBasedChannel.js:166:62)
at Object.exports.run (/home/container/commands/verify.js:24:14)
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:16) 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(). (rejection id: 1)
(node:16) [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.

anyone know how to fix this?

royal portal
#

fields.flat is not a function

#

in your code

woeful sphinx
#

update node

#

you need node12+ for discord.js 12 @rocky lintel

simple stump
#

GoogleSites thats correct.

knotty steeple
#

dont spoonfeed wew

woeful sphinx
#

not spoonfeeding - he's already got it I'm just showing him how the structure looks

#

@simple stump currently you're checking if row.time + 1000 is equal to ts (is that the current time in UNIX?). anyway, if you want it to make sure it has been at least a second you need to make sure that row.time + 1000 is less than ts

royal portal
#

lol

simple stump
#

okay. thx googlesites

neat ingot
#

top gg is down?

simple stump
#

uh there seems to be an error

#

i tried logging row and row.time

#

but it says that its undefined?

#
            console.log(row.time);
            console.log(row);
#
throw err; // Rethrow non-MySQL errors
      ^

TypeError: Cannot read property 'time' of undefined

@woeful sphinx
Edit: Fixed

neat ingot
knotty steeple
knotty steeple
#

bot isnt a constructor

#

omegalul

#

ok wtf is this

pale vessel
#

classes

quartz kindle
#

you cant extend an initialized class, you need to extend it before initializing it

knotty steeple
#

so u have to do it in the other file

snow urchin
#

welp

knotty steeple
#

yea u dont extend it when u initialize

#

i didnt understand for a sec

#

so just export client

neat ingot
#

yea, or extend it before creating instance

simple stump
#

For some reason my custom status isn't working. I don't get ANY errors, yet my bot has no status whatsoever.

client.once('ready', () => {
    console.log('Ready!');
    client.user.setPresence({
        status: "online",  // Change 'online' to online, idle, etc.
        game: {
            name: "the Endran Empires.",  // The message shown in status
            type: "WATCHING" // PLAYING: WATCHING: LISTENING: STREAMING:
        }
    });
});
quartz kindle
#

pretty sure its activity, not game

honest perch
#

^

simple stump
#

alright. thanks

woeful sphinx
#

also if you're keeping status to online then you can set the activity with client.user.setActivity('the Endran Empires.', { type: 'WATCHING' })

clear wraith
#

What can I do to fix this...

#

and why does it do that?

#

Feel free to @ me.

sudden geyser
#

It's a common issue with the website.

topaz fjord
#

basically

#

site is ded

#

and you have to wait for it to fix itself

sudden geyser
#

I'd simply ignore it.

pale vessel
#

what are these profile pictures pls explain

amber fractal
#

that's all you can do right now

#

it's a known issue

topaz fjord
#

@pale vessel ?

sudden geyser
#

flazepe it's an evolution.

pale vessel
#

how

topaz fjord
#

isn't it discords birthday or smth

pale vessel
#

can I join

sudden geyser
pale vessel
#

thank you

simple stump
#

How do I get an user's nickname/name by their ID? I don't want to do it in my client.on('ready' but rather in client.on('message'.
Ex.

if (message.content.startsWith(`${prefix}energy`)) {
        let target = message.mentions.users.first() || message.author;

        if (!target) {
            message.reply("Please either mention an user!")
        }

        con.query(`SELECT * FROM energy WHERE id = '${target.id}'`, (err, rows) => {
            if (err) throw err;

            if (!rows[0]) return message.channel.send("This user has no XP on record.");

            let xp = rows[0].xp;
            if (target != " ") {
                const user = <something>.fetchUser(target.id);
                message.channel.send(user + " has " + xp + " xp.");
            } else {
                message.channel.send("You have " + xp + " xp.")
            }
        });

    }
#

I know it's client.fetchUser but that becomes a problem if I want to get it in a client.on('message'

quartz kindle
#

client.fetchUser() in v11
client.users.fetch() in v12

simple stump
#

How would I get "client" though?

#

i dont believe u can if its not inside a client.on('ready'

viral spade
#

How do servers with a few hundred shards manage their database connection? i guess not every shard will have its own connection? (nodejs, mysql)

quartz kindle
#

client is a global variable, since you define it in top level

simple stump
#

hmm okay thx

#

ohhh i see

#

nvm

quartz kindle
#

you just need to await it

simple stump
#

lol im using v12 not v11

quartz kindle
#

because fetching returns a promise

simple stump
#

okay. thx tim!

quartz kindle
#

@viral spade remote database probably

#

each client will have its own connection yes

viral spade
#

but that multiple hundrets of connections to the remote database then?

small prairie
#

F

quartz kindle
#

yes, databases are capable of handling that many connections

simple stump
#

Sorry for coming back so soon but how would I use an await if I don't put my client.ons inside an async?

viral spade
#

okay i read that mysql default is 150

simple stump
#

^ you could amp that up

knotty steeple
#

for the callback put async

simple stump
#

if ur using XAMPP you can configure

#

sammy-ette wdym by that?

quartz kindle
#

you just need to make the parent function async, or use .fetch().then() if you prefer callbacks

knotty steeple
#
client.on("event", async (variable) => {})
simple stump
#

whats the documentation page for the .fetch().then()? i dont want to change my code up too much

knotty steeple
#

example

simple stump
#

oh i see

#

okay. thx

quartz kindle
#

promises are native javascript

simple stump
#

thanks. its been too long since ive done js. need to relearn it

#

again

knotty steeple
#

or make some kind of empty async function

viral spade
#

Okey tim please check my plan of implementation. my goal is that the setup could theoratically handle 1.000.000 servers.

So lets say i have multiple nodes with shards and multiple nodes with databases and 1 manager node that has info of which guild data is in which database (this info gets cached in the client's guild object).

Lets say the bot is in 1.000.000 servers and there is 10 database nodes they are separated on. Each shard/client will be connected to each database, and use the right connection for the right guild. This means every of the 10 databases will have 1000 connections, altough data will be spread pretty thin accross the connections.

Would this be a good or bad way to do it?

quartz kindle
#

it wont work

#

because if/when you change your total shard count, all guilds will be re-shuffled across shards, so a single shard can contain guilds from databases A B C and more all mixed in

#

unless you plan to have each shard connect to all databases

viral spade
#

Each shard/client will be connected to each database

neat ingot
#

its also possible to shard databases, for example mongodb

viral spade
#

That should work i guess, but only its so many connections

quartz kindle
#

so if you have 1000 shards, with 1000 guilds each, each database will have 1000 connections

#

which is doable, but not ideal

viral spade
#

yes

woeful sphinx
#

you can pool connections and use them when they're needed -- you dont need to stay connected all of the time

quartz kindle
#

also, you dont need to have one process per shard, you should mix internal sharding in

viral spade
#

i was thinking of letting the db query go though the shardingmanager, so its sent from one place per node

quartz kindle
#

lets say you have 100 processes, each process has 10 shards

#

also possible yes

woeful sphinx
#

each shard is already a new process, no?

quartz kindle
#

since anyway you need the sharding manager to keep an index of what guild is in what database

#

with the sharding manager yes

viral spade
#

no i cache it from the manager node into the shard

#

first time i see a not cached guild

quartz kindle
#

discord.js in general is not recommended for large scale bots

woeful sphinx
#

yeah. until they limit the user cache size it takes up way too much memory

viral spade
#

lets say you have 100 processes, each process has 10 shards
i thought the sharding manager spawns 1 client within 1 process? Can i explicitly tell it to spawn multiple shards per process?

quartz kindle
#

not sure, but i believe so

#

let me check

viral spade
#

thanks!

quartz kindle
#

you can give the manager a a totalShard and which shards to spawn

#

so for example give it 50 total shards, and spawn 10 shards

viral spade
#

i do that

quartz kindle
#

and inside each shard, you have to tell it to spawn a specific set of shard ids

#

i dont think the manager will do that for you

woeful sphinx
#

a shard is the process - I don't think you can spawn more shards in a shard

viral spade
#

thats what i was thinking

quartz kindle
#

technically a "shard" is a websocket connection

#

which discord limits to 2500 guilds per connection

sullen night
woeful sphinx
quartz kindle
sullen night
quartz kindle
#

because the mods closed it, so people stop spamming the same question

sullen night
#

about the crash?

quartz kindle
#

yes

sullen night
#

How can i get a bot developer role?

quartz kindle
#

by adding a bot to the website

sullen night
#

I built my first bot and cannot add it here

#

cz the site crashed

quartz kindle
#

wait until they fix it

sullen night
#

btw im grateful to this server

#

i forgot who

small prairie
#

https://discord.js.org/#/docs/main/11.5.1/class/TextChannel?scrollTo=permissionsFor doesnt return null when i serialize it
Thought its as the guild's role perms are taken into account to
is there any to to ignore role perms just the channel perms
Get it?

sullen night
#

but someone in the voice channel told me i was coding in a wrong way

#

Can I get another help?

#

how can i tackle latency issues?

viral spade
#

but in principle do you agree with my plan tim?
So for handling a huge amount of servers, let each shard connect to each database, possibly having 1000 connections on a single db?

quartz kindle
#

@small prairie you need to use permissionOverwrites

#

and its related functions/methods

small prairie
#

Ah
i can get the required role from there
Thanks tim

quartz kindle
#

@viral spade at such large scale, database connections are usually not kept open, the shards should connect, do a thing, and disconnect

#

which makes using transactions and eventual consistency more important

viral spade
#

i see, that sounds legit.

Yes i want to reassamble my bot to reflect your tips you gave me! That means (for now, but i am planing ahead as you see) use only a remote, no local database and in turn add perfect caching of the most important parts so like you said, only a) user actions or b) periodic batch updates cause database actions.

quartz kindle
#

yup

#

also look into using internal sharding in combination with the sharding manager

amber fractal
#

Tim at what point would you say you need to switch from djs or start horizontal scaling?

quartz kindle
#

having one process per shard is not a good idea at scale

vivid crescent
#

So opening new connections > Keeping one connection open 😅

quartz kindle
#

as soon as you want to stop wasting resources lmao

amber fractal
neat ingot
#

f

viral spade
#

oh but then the databse connection problem also resolves. i guess each shard from the same process would use the same static module and connection?

amber fractal
#

when is your lib gonna come out

#

I need some code to stealbots to write

quartz kindle
#

yes, all shards in the same process share everything from the process

#

they even share the same discord client and events

neat ingot
#

interested in this tim.lib mentioned 👀

quartz kindle
#

lmao

amber fractal
#

uh top secret project

quartz kindle
#

idk, i havent worked on it much the past few days

#

but i'll push something to github soon

neat ingot
#

😮 your actually writing a library? lol

amber fractal
#

is the repo private?

rustic veldt
#

hi

neat ingot
#

for which language might it be for?

quartz kindle
#

there is no repo yet lul

amber fractal
#

o

#

lmao

quartz kindle
#

for js

rustic veldt
#

already installed

neat ingot
#

oohhh nice

rustic veldt
#

but i get such error

amber fractal
#

are you requiring the right path?

neat ingot
#

what prompted you to write your own? not happywith the current offerings?

rustic veldt
#

Will anyone help if I throw my project

quartz kindle
#

@neat ingot yeah there is a market gap that remains unfilled

amber fractal
#

d.js is unoptimized and eris is hell

neat ingot
#

'market gap' 😄

quartz kindle
#

lmao

rustic veldt
#

@quartz kindle help me pls

neat ingot
#

sounds like this lib gonna cost me many bucks 😛

quartz kindle
#

@rustic veldt make sure you install the latest version. if it still doesnt work, run enable pnpm in your glitch console

amber fractal
#

I want to learn how to write something like a lib, I just dont know websocket stuff heartbeating etc

#

I've worked with tcp sockets before though mmLol

rustic veldt
#

what is the latest version @quartz kindle

neat ingot
#

learn by doing! 🙂

#

get better over time etc etc

quartz kindle
amber fractal
#

I mean I've been developing for many years now, just never had a real reason to look into it

quartz kindle
neat ingot
#

oof

rustic veldt
#

@quartz kindle :/

#

How do I install the latest version

quartz kindle
#

did you copy and paste someone's package.json?

pale vessel
#

looks like it lmao

amber fractal
#

Tim do you use ws or is there another package/built in node thing you use

rustic veldt
#

no

amber fractal
quartz kindle
#

then how did you install ytdl?

#

@amber fractal im using ws

#

i looked into uws, but i remember discord.js had issues with it

rustic veldt
#

my own project

amber fractal
#

Yeah I heard uws was stink

rustic veldt
#

how to install the latest version

quartz kindle
#

uws is supposed to be much faster tho

#

@rustic veldt how did you install it?

simple stump
#

How do I use message.channel.type? I'm trying to check if the message an user sent was in a channel or a DM.

quartz kindle
#

did you write it in package.json? did you install it from the console, using npm install? did you use the add package button in glitch?

amber fractal
#

It was deprecated tho wasnt it?

rustic veldt
#

I put this in the main file
const m3u8stream = require ('m3u8stream');
const parseTime = require ('m3u8stream / dist / parse-time');

quartz kindle
#

the one in npm was, but they are still in development

pale vessel
rustic veldt
#

If I throw my project, do you have a chance to see what the problem is?

simple stump
#

ive tried taking a look at taht @pale vessel. tbh it doesnt rlly make sense to me i just need an example

quartz kindle
#

actually im gonna give uws a try

simple stump
#

like whether its message.channel.type()

#

or message.channel.type =

rustic veldt
#

@quartz kindle ?

pale vessel
#

the latter

amber fractal
#

they boast being 2x more efficient than ws

pale vessel
#

and it's == or === btw

simple stump
#

okay. thx

pale vessel
#

for comparison

quartz kindle
#

@rustic veldt i still dont understand what you're doing, why did you require them separately?

amber fractal
#

and 5x more efficient than Socket.IO (what even is this lmao)

quartz kindle
rustic veldt
#

main on the internet wrote that this file should be discarded

quartz kindle
#

they kinda pioneered websockets on browsers

#

ws is the new and good stuff

#

uws is a port from c++

rustic veldt
#

I have difficulty understanding you because I am Turkish

white anvil
#

uws is so hot

#

it’s so fast

neat ingot
#

not heard of this uws thing, still using socket.io where needed. its worth learning more on uws to repalce the sockets?

rustic veldt
#

@quartz kindle

pale vessel
#

stop pinging random users

amber fractal
#

if it's 5x more efficient, probably

neat ingot
#

👀

quartz kindle
#

its native code, so yes its more efficient than js

white anvil
#

uws is theoretically the fastest open source websocket atm

rustic veldt
#

If I throw my project, would you look at the problem @quartz kindle

white anvil
#

and by a lot

quartz kindle
#

@rustic veldt i can try

neat ingot
#

its similar to use to socket io, or a hugely different structure?

amber fractal
#

He's about to yeet his project

#

this is the example they give

white anvil
rustic veldt
#

@quartz kindle thanks

neat ingot
#

intersting, gotta look into that more i think 🙂

amber fractal
#

Cant seem to find docs on uws tho, besides docs directory in the repo, but I don't know if they host that somewhere

#

wait

viral spade
#

Tim do you know you're an angel in this otherwise mostly stupid and unhelpful world

amber fractal
#

I'm just dumb

quartz kindle
#

i know

quartz kindle
#

lmao

amber fractal
#

I don't really understand these docs though tbh

#

oh I see now

neat ingot
#

oh neat, so this would entirely replace express as well

quartz kindle
amber fractal
#

Just feels different

neat ingot
#

wonder if templating engines are supported. like ejs etc.

rustic veldt
#

thanks

queen needle
#

"Add Package 22"

rustic veldt
#

can you load the module @quartz kindle

neat ingot
#

i guess i could always use ejs and just render the content before sending it

small prairie
quartz kindle
#

uws's benchmarks are stupid