#development

1 messages ยท Page 802 of 1

true ravine
#

Is for things like checking what game users are playing?

#

Or just if they're online or not?

quartz kindle
#

both

#

also affects username updates

true ravine
#

Oh right

quartz kindle
#

and pfp changes

neat ingot
#

but they'r gonna limit that in future right?

true ravine
#

My bot uses whether users are online or not so I guess I have to keep it

quartz kindle
#

wdym limit? there are certain restrictions when using it already

neat ingot
#

i dont do anything presence related since i broke my bot by iterating over 40k users each second trying to check their online activity

#

#noobbot ๐Ÿ˜„

#

there was some post where they are gonna be limiting it to 100 guilds

#

if you use presence data

quartz kindle
#

yes, also for guildMember data

#

it requires turning on a setting in your bot application

#

in discordapp

neat ingot
#

ye

#

what does that mean though ~@ track server members

#

like, would using message.member count?

quartz kindle
#

the guildMember intent affects memberAdd memberRemove and memberUpdate

neat ingot
#

like, the events?

pine aspen
#

Hey.
So.
I've been trying to search for data in a column.

      let crow = await con.prepare('SELECT * FROM codes');
      const { code } = await con.prepare('SELECT code FROM codes');
      if(code == args[0]) {

i think this is the code that is messing up.

quartz kindle
#

if you use intents but dont enable guild members, you dont receive any guild member events

#

meaning your bot will not be able to track members, nor their count

#

nor when they join/leave

#

nor nickname updates

neat ingot
#

:/

#

i had to use guild.memberCount for getting accurate member count since bot.client.users fails hard af

#

tells me 10k, when its over 120k now

quartz kindle
#

you can still estimate member count via guild.memberCount

#

but the count will not be updated automatically

neat ingot
#

ahhh

quartz kindle
#

basically it will only be accurate at login

#

after that it will lose track of it

neat ingot
#

but those are gonna fail right?

quartz kindle
#

yup

neat ingot
#

ehh, idm, i was thinking of removing the welcome emssages and mod stuff from my bot anyway

#

there are tons of bots for that that do it better, mines is more rpg minigame focused

#

so no real need

quartz kindle
#

@pine aspen i believe i have answered your question before

#

.prepare() will create a prepared statement, but not run anything by itself

pine aspen
#

Ok.

quartz kindle
#

you need to actually execute the queries after preparing them

pine aspen
#

.query()

quartz kindle
#

refer to your library's documentation

pine aspen
#

Then?

#

Ok.

#

Thanks.

quartz kindle
#

which library are you using?

pine aspen
#

Discord.js

quartz kindle
#

database library

pine aspen
#

Oh.

#

MYSQL

quartz kindle
#

npm mysql?

pine aspen
#

Yes

quartz kindle
#

doesnt look like the library supports prepared statements at all

pine aspen
#
if(code == args[0]) {
            let row = await con.prepare('SELECT * FROM config WHERE guildid = ?').get(message.guild.id);
            const { premium } = await con.prepare('SELECT premium FROM config WHERE guildid = ?').get(message.guild.id);
            if (premium == 0) {
#

I have prepare for my premium.

#

It works fine.

quartz kindle
#

that looks like a different library

#

the example for mysql shows this

#
connection.query('UPDATE users SET foo = ?, bar = ?, baz = ? WHERE id = ?', ['a', 'b', 'c', userId], function (error, results, fields) {
  if (error) throw error;
  // ...
});```
true ravine
#

That's how my mysql stuff works

#

I've never seen it done the way syn has it

quartz kindle
#

better-sqlite3 does it that way

true ravine
#

Ah well I haven't used that

pine aspen
#

I'm not trying to update though.

#

I'm trying to fetch for a data in the column.

true ravine
#

You use the same structure

quartz kindle
#

its not about updating

#

its about how the library works

pine aspen
#

Ah.

#

Ok.

quartz kindle
#

the mysql library works like this connection.query("SQL",[parameters],(error,result,fields) => {})

#

your code shows this connection.prepare("SQL").get(parameters)

pine aspen
#

Ok.

quartz kindle
#

its a completely different library, its not mysql

#

which library are you using?

pine aspen
#

I have mysql installed in my Node_Modules.

quartz kindle
#

show your package.json

pine aspen
#
  "dependencies": {
    "ascii-table": "0.0.9",
    "bot-utils": "^1.4.2",
    "common-tags": "^1.8.0",
    "discord.js": "^11.5.1",
    "fs": "0.0.1-security",
    "moment": "^2.24.0",
    "mysql": "^2.18.1"
  },
true ravine
#

Yeah that's mysql so use the structure described by tim

quartz kindle
#

i cant find any mention of .prepare in the mysql page

#

you said your other code is working?

pine aspen
#

Yes.

slate oyster
#

Awesome. The developers of the library I use said they automatically process rate limits for me, across multiple library calls

pine aspen
#

All my codes are working.

#

Apart from my code fetch.

#

example this works.

#

fine.

quartz kindle
#

thats not using mysql

#

thats using a con object you passed to the run function

pine aspen
#

My Con

quartz kindle
#

show the code that calls the run function

pine aspen
#

Wdym?

true ravine
#

In index

pine aspen
#

Like login to databse?

quartz kindle
#

what is con

true ravine
#

Yeah but hide the credentials

pine aspen
#

Duh

#
const Database = require('./handlers/Database');
const con = new Database({
    connectionLimit: 20,
    host: '',
    user: '',
    password: '',
    database: ''
})```
#

This is con Tim

quartz kindle
#

well, what is /handlers/Database?

true ravine
#

My mysql con looks nothing like that

neat ingot
#

i wish my package dependencies were asa few as your syn ๐Ÿ˜„

true ravine
#

That's mysql

pine aspen
#

Yeah thats what's in ^^

quartz kindle
#

oh

#

who wrote that?

pine aspen
#

A friend.

#

I didn't

quartz kindle
#

thats like a custom wrapper for the mysql library

pine aspen
#

Probaby.

#

He just explained me how to use it.

#

Not how it works.

quartz kindle
#

alright, then you should follow what he says

#

there is no documentation for that as its custom made

pine aspen
#

I did.

#

But idk.

#

I'll ask him.

#

How it works.

quartz kindle
#

the code you showed before was lacking the .get() part

#

thats why its not working

true ravine
#

Might be more useful to use something documented if you're trying to learn

#

At least there's support

pine aspen
#

K

#

Thanks for the help.

blissful scaffold
#

@slate oyster D4J already has rate limiting for ages ^^

pine aspen
#

THANKS!

#

I got it to work.

#

Tim you gave me an idea when you said .get() and now it works!

#

There's a few errors which i should be able to fix.

nocturne grove
#

Does anyone have a good idea on how to measure a MySQL database latency in JS?
Would something like this be trustworthy?

// get time a here
con.query('SELECT 1', (err) => {
  if (err) throw err;
  // get time b here
  console.log('The latency is ' + time b - time a);
});```
modest maple
#

how fucking big is your DB for it to take a noticable amount of time

true ravine
#

Lol true

nocturne grove
#

really small rn ๐Ÿ˜‚

#

but I sometimes saw a database ping in a ping command

modest maple
#

why bother

#

it should be such a insignificant amount

true ravine
#

I guess store var before = new Date() before the request and then compare it to var after = new Date() once the request is done - but it will be a tiny number

modest maple
#

even a large DB is factions of second

true ravine
#

Yeah

nocturne grove
#

yeah I know it's a really small time, but I just want to know

true ravine
#

Fair enough I guess

nocturne grove
#

@true ravine with 'once the request is done' you mean in the con.query thing itself?

blissful scaffold
#

As long as the db is not physically far away the ping should always be near 0

true ravine
#

As long as the db is not physically far away the ping should always be near 0
Yeah

#

@true ravine with 'once the request is done' you mean in the con.query thing itself?
After you check for errors

nocturne grove
#

okay okay

true ravine
#

Basically where you console.log is

nocturne grove
#

thank you both for your help

true ravine
#

Np

pine aspen
#

How can i fix this error.

#
(node:468) UnhandledPromiseRejectionWarning: TypeError: Cannot destructure property `code` of 'undefined' or 'null'.
    at Object.run (/app/data/DiscordBot/commands/misc/redeem.js:36:5)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7)
(node:468) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, orby rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:468) [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.
#

It check's if code is valid.

#

If the code is not valid i want it to do something.

#

It does the correct thing if the code is valid btw

#

(in the table)

true ravine
#

You can always use a catch block

pine aspen
#

oh

#

ya

#

try

#

then } catch {
}

#

right?

true ravine
#

Or with normal mysql you get an err object that you can literally throw in an if statement

pine aspen
#

try {

} catch {

}

#

Ok.

true ravine
#
badcode()
.catch(() => {
  console.log("oopsie")
})
#

Like that

earnest phoenix
#

or

#

here's a crazy thought

#

fix the code that throws errors?

#

try catching everything is not the solution and a ton of memory gets wasted on handling exceptions/errors

pine aspen
#

@earnest phoenix Gosh. Why didn't i think of that.

true ravine
#

Pff who wants a stable platform in 2020?

pine aspen
#

Indeed.

#

Wait?

#

wdym by badcode()

true ravine
#

Thats the code that might go wrong

pine aspen
#

Ah k

true ravine
#

It doesn't literally have to be badcode

earnest phoenix
#

bomboclaat

blissful scaffold
#

Make sure you always log errors that you catch, you will regret it later if you don't

true ravine
#

Indeed

pine aspen
#

Alright.

earnest phoenix
#

where is peanut dread?

pine aspen
#

console.err(err)

#

๐Ÿ™‚

true ravine
#

๐Ÿ‘

quartz kindle
#

you cannot destructure a property if it doesnt exist

#

lets examine your query, you have { something } = await database.prepare().get()

#

this means that, if the database returns an object like this { something:10 } the value of your something variable will be 10

#

but what if the database doesnt find anything? what if the supplied parameters are not found in the database?

#

the code will try to extract a something property from nothing

#

the error says that your database is returning either a null value or an undefined value

#

so you have to account for those possibilities before trying to extract a property out of them

#

essentially, doing { something } = value is the same as doing something = value.something. and if for some reason value is null, then doing { something } = value will be the same as something = null.something, which will throw an error, because null cannot have values

#

also, you're running a lot of duplicated queries, which is terribly innefficient

#

thats basically the same as loading a website twice to get one word from it each time, instead of loading a website once and getting two words from it

digital ibex
#

hi

#

means? And why its not working on the vm but its working on my pc

quartz kindle
#

show code

true ravine
#

When I was having problems where my code worked on my pc but not my server, it was because on my server I was running using node index.js instead of node .. Might not fix your problem but it could be an easy fix?

digital ibex
#
        let embed = new Discord.MessageEmbed()
            .setAuthor(`Total: ${lost.commands.size}`, message.author.displayAvatarURL())
            .setColor('#fffffa')
            .addField('Administration', 'a!purge\na!dm\na!slowmode', true)
            .addField(
                'Moderation',
                'a!ban\na!unban\na!kick\na!mute\na!unmute\na!purge\na!dm\na!slowmdode\na!checknick',
                true
            )
            .addBlankField()
            .addField('Utility', 'a!say\na!erotes\na!roles\na!emotes', true)
            .addField(
                'Info',
                'a!commands\na!help [command]\na!info\na!invite\na!lost\na!membercount\na!ping\na!uptime',
                true
            );
        message.channel.send(embed);``` you need to see more?
true ravine
#

Isn't it meant to be new Discord.RichEmbed()?

digital ibex
#

not for master

true ravine
#

Ah I see

#

Looks fine to me tbh

quartz kindle
#

@digital ibex Discord.js v12 does not have addBlankField()

digital ibex
#

uh, it was woring before

#

what would i need to do?

quartz kindle
#

it was removed 6 days ago

#

use .addField("\u200B","\u200B")

#

its basically what blankField was doing internally

digital ibex
#

oh

earnest phoenix
#

how I can fix that

quartz kindle
#

have you tried clicking on "click here for help"?

earnest phoenix
#

am yes

#

I click on click here for help and he give me link for this server

quartz kindle
#

then you need to ask a moderator

pine aspen
#

@quartz kindle wouldn't it work if i tested for code as null?

#

if (code == null);

quartz kindle
#

if(!code) should suffice, but you have to do that without destructuring

#

ie:

let response = await con.prepare().get();
if(!response) { return message.channel.send("not found") }
let code = response.code```
or just use response.code directly
pine aspen
#

k

earnest phoenix
#

Can i get the reason for banning dexter bot โ€675991950762967040โ€? I am a bot mod

modest maple
#

Wasn't banned

modest maple
#

Read what it says

#

Its API abuse

earnest phoenix
#

Ok

grizzled raven
#

can you get the content of system on join messages?

quartz kindle
#

yes

earnest phoenix
#

does someone know how to make my bot icon moving

#

like moving to top and down

#

in dbl page

quartz kindle
#

css animation

earnest phoenix
#

yeah but

#

how

#
webkit-animation: mover 1.5s infinite alternate;
    animation: mover 1.5s infinite alternate;
    -webkit-animation-timing-function: ease-in-out;
    animation-timing-function: ease-in-out;
    -webkit-animation-iteration-count: infinite;
    animation-iteration-count: infinite;
    border-radius: 50%;```
#

@quartz kindle

slender thistle
#

Did Google help

quartz kindle
#

did you define the keyframes?

earnest phoenix
#

huh no

#

1 sec

earnest phoenix
#

@earnest phoenix is gay

#

self bot

copper cradle
#

are they even here

tight plinth
#

What a self bot

#

Is he here

copper cradle
#

@earnest phoenix yeah

#

this isn't the channel tho

tight plinth
#

That's him

earnest phoenix
#

as i explained to him, i dont selfbot

mossy vine
#

/coinflip

#

sick

tight plinth
#

So how u do embeds

copper cradle
#

the only way to send an embed on an user account is selfbotting

mossy vine
#

well not really

copper cradle
#

could be an imh

#

but ยฏ\_(ใƒ„)_/ยฏ

tight plinth
#

It's the only way

#

Lol

mossy vine
#

could be an oauth app with permission to send messages

copper cradle
#

still

#

selfbotting

mossy vine
#

that is not selfbotting

tight plinth
#

Selfbot

mossy vine
#

but it could be

earnest phoenix
#

oh mah god

knotty steeple
#

whats an oauth app

mossy vine
#

ok sam idk if thats the right term

#

i cant english today

knotty steeple
#

only thing that can send images is users bots and webhooks

#

and both webhooks and bots have a bot tag in their name

vague chasm
#

@earnest phoenix selfbot?

tight plinth
#

What's ur prefix proper

knotty steeple
#

and webhooks cant have roles

earnest phoenix
#

no ffs

mossy vine
#

@earnest phoenix how do you do it then lol

knotty steeple
#

so from images alone its a selfbot

#

logically

tight plinth
#

Yes

earnest phoenix
#

he made me gay aswell several times

knotty steeple
#

unless its just some dumb joke

tight plinth
#

He says "no selfbot" but no proofs

earnest phoenix
#

in every channel

knotty steeple
#

and he is posting images

red hollow
#

@earnest phoenix say /coinflip now without delay

earnest phoenix
#

@tight plinth how do you want me to prove

knotty steeple
#

HE MADE ME GAY

tight plinth
#

Well prove

knotty steeple
#

man this is the wrong channel

earnest phoenix
#

/coinflip

red hollow
#

yeah u shutted it down

knotty steeple
#

you can turn off the selfbot

#

ยฏ_(ใƒ„)_/ยฏ

earnest phoenix
#

oh mah god

red hollow
#

ye he did

earnest phoenix
#

i was reading testin 1

knotty steeple
#

also the images are from a different server

mossy vine
#

honestly alex was smart af, not only straight up threatening a report but also reporting it in a public and wrong channel

knotty steeple
#

2000iq

earnest phoenix
#

im done

knotty steeple
#

who cares

#

omegalul

earnest phoenix
mossy vine
#

unless you can prove how you sent those messages without selfbot its obvious

earnest phoenix
#

he made me gay

#

lmaoo

#

its just my bot guys

#

dw

#

lier

quartz kindle
#

but is your bot using your user token?

knotty steeple
#

and tbf he did actually call him gay

#

so thats not a lie

#

but why

quartz kindle
#

@earnest phoenix did you put your user token in your bot?

knotty steeple
#

how tf do u even get a user token now

#

like

red hollow
#

widget

earnest phoenix
#

insp element

hoary elm
#

^^

quartz kindle
#

so yes, its a selfbot

knotty steeple
#

well if u did put a user token its a selfbot ๐Ÿ˜‚ ๐Ÿ‘Œ

hoary elm
#

Literally just admitted it and doesn't even realize ๐Ÿคท๐Ÿปโ€โ™‚๏ธ๐Ÿคฆ๐Ÿปโ€โ™‚๏ธ๐Ÿ˜‚

knotty steeple
#

@coral trellis can u do something pls

coral trellis
#

Why is this even being discussed here

knotty steeple
#

idk

mossy vine
#

cuz some idiot decided to report here

#

i mean what

earnest phoenix
#

could be an oauth app with permission to send messages
this is impossible by the way

#

no app can send messages for you

mossy vine
#

yes i realized

earnest phoenix
#

otherwise that would be a huge both privacy and security breach

mossy vine
#

ive read so many other api docs i swore discord has something like that too

earnest phoenix
#

well

#

it used to

#

it had rpc which was whitelist only

slender thistle
#

I thought Discord oauth could do that

earnest phoenix
#

but that is long abandoned

slender thistle
#

lalala I'm a butterfly

#

I'm not smart but I fly around

quartz kindle
#

cant a client emulate discord's own oauth flow for users?

unique nimbus
#

@slender thistle you are smart smh

slender thistle
unique nimbus
#

true

earnest phoenix
#

is that a question or a statement

#

are you asking where to find it?

summer torrent
#

under the esc

earnest phoenix
#

google the type of your keyboard and append backtick

unique nimbus
#

left of 1

#

wait is this for a qwerty keyboard

mossy vine
#

omg yall just assume everyone has the same keyboard layout

#

its alt gr + 7 for me smhhh

earnest phoenix
#

lol

unique nimbus
#

oh god

earnest phoenix
#

is it that hard

#

facedesk

#

to do a damn google search

unique nimbus
#

under 1 what letter is there?

mossy vine
#

omg

#

are you stupid or something

true ravine
#

To be honest I use a nes keyboard with my computer smh

unique nimbus
#

Is there a Q?

#

next to it is there a W

earnest phoenix
#

lol

mossy vine
#

LMAOOOO

unique nimbus
#

Okay

earnest phoenix
#

ouch my brain cells

unique nimbus
#

Next to W is there a E?

#

it looks like this

#

well american keyboard layout

#

but somewhat same

#

what is that supposed to mean

#

Like this?

#

Where are you from

true ravine
#

On windows try pressing windows key and space to see keyboards

earnest phoenix
#

jesus christ just google your keyboard layout and backtick

true ravine
#

Not enough arrows smh

slender thistle
#

@earnest phoenix sorry what are we supposed to see on that screenshot?

unique nimbus
#

google

earnest phoenix
slender thistle
#

I think I need to click on the arrows

#

Oh thanks my issue is solved now

earnest phoenix
#

no probleM ๐Ÿ‘ !

slender thistle
#

cry is a helpful dev
now how do you call Python functions in ASM

grizzled raven
earnest phoenix
#

asm lol

grizzled raven
#

why is the link purple though

slender thistle
#

Because he visited it

#

ez

earnest phoenix
#

dark reader and i visited it

slender thistle
#

Where you got that sweet dark reader from?

unique nimbus
#

google

grizzled raven
#

yes

unique nimbus
#

I am guessing you use chrome

#

it is also on Firefox

earnest phoenix
#

lol no

grizzled raven
#

nah he uses safari

unique nimbus
#

ez

earnest phoenix
#

chrome more like here you go use my data without my consent

slender thistle
#

Chromium enough

unique nimbus
#

Firefox > *

earnest phoenix
#

this tbh

grizzled raven
true ravine
#

Isn't the discord windows client based on chrome? MegaThonk

earnest phoenix
#

yeah

#

chromium

#

aka electron

grizzled raven
#

what is the difference between chrome and ium

true ravine
#

One is cool one is edgy

pale vessel
#

chromium doesn't have feature like sign in

grizzled raven
#

ok

earnest phoenix
#

chromium is open src

pale vessel
#

no sync afaik

true ravine
#

Chromium has sign in and sync?

earnest phoenix
#

and it acts as a base for chrome

mossy vine
#

chromium is mostly just chrome but less bloat

earnest phoenix
#

okay my internet is fucking me

pale vessel
#

that's erotic

grizzled raven
#

did your internet ask for consent?

true ravine
#

dont give them tea

earnest phoenix
#

anyways chromium sucks and it consumes an ungodly amount of ram for no reason

mossy vine
pale vessel
#

ok

#

so

neat ingot
#

chromium is a stripped down version of chrome, that is also open source.

pale vessel
#

but still shit

mossy vine
#

not really

#

chrome is chromium + more

#

but yea

true ravine
#

thats why you can only install chromium os on windows not chrome os

#

because chrome os is for cool people

pale vessel
#

lag city

true ravine
#

Windows machines *

pale vessel
#

i can install it on my linux machine

true ravine
#

Because it's linux based I swear

pale vessel
#

you swear?

true ravine
#

Not on christian servers

pale vessel
#

good.

split hazel
#

I'm confused and never had this issue before, for some reason running console.log on ascii (surrounded by back ticks) returns "irregular expression"

pale vessel
#

can we have a snippet of the code?

slender thistle
#

@earnest phoenix so firefox > chromium in a way?

earnest phoenix
#

yes

#

by a mile

pale vessel
#

just a mile?

slender thistle
#

I'll let your internet send the replies in an hour GWahreeVampySmug

earnest phoenix
#

firefox actually cares about user privacy

pale vessel
#

free vpn also

quartz kindle
#

firefox's engine is weird af tho

#

always needs dedicated css rules to fix inconsistencies

pale vessel
#

i don't trust opera since it's a chinese company

slender thistle
#

But do you trust TikTok

pale vessel
#

no

slender thistle
#

Good

tight plinth
#

Opera is a independent Chinese company

pale vessel
#

never even signed up nor download

tight plinth
#

They don't sell data to government

pale vessel
#

tiktok is cancer

#

had to say it

earnest phoenix
#

because it is

pale vessel
#

but is the opera gx worth the try

mossy vine
#

but is this the right channel

true ravine
#

No because yall just ignored someone who asked for help xd

mossy vine
#

your question was answered

true ravine
#

Not me

#

I mean tbf they didn't reply to flazepe so idk

pale vessel
#

b-but

cerulean salmon
#

how to set time limit on bot message response ?
i mean user need to response between 1/2 min

crimson vapor
#

create a message collector with a 30000 ms timeout

earnest phoenix
#

ooooof

quartz kindle
#

nice

summer torrent
#

master is best

quartz kindle
#

true

pale vessel
#

is it stable? i'm worried the code will keep on changing

#

i might migrate

quartz kindle
#

holy

#

we can finally fetch member presences

#

without using presence packets

pale vessel
#

which type of presence?

quartz kindle
#

guildMember presences

pale vessel
#

i thought we already have that

quartz kindle
#

not when fetching

pine aspen
#

Hey.

#
number_codes = 0
new_code = "Code"
setInterval(async () => {
    let { number_codes } = await con.prepare("SELECT COUNT(*) FROM codes").run();
    console.log(await con.prepare("SELECT COUNT(*) FROM codes").run())
    while (number_codes <  100) {
        const new_code = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);return v.toString(16);});
        con.prepare("INSERT INTO codes (code) VALUES (?)").run(new_code);
    } 
}, 1 * 10000) // 1 * 10000 = 1 Minute
#
(node:822) UnhandledPromiseRejectionWarning: TypeError: Cannot destructure property `number_codes` of 'undefined' or 'null'.
    at Timeout.setInterval [as _onTimeout] (/app/data/DiscordBot/index.js:43:1)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7)
(node:822) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, orby rejecting a promise which was not handled with .catch(). (rejection id: 3)
#

How could i make this work?

#

Do i use a catch box again?

true ravine
#

Did you see the explanation tim wrote earlier?

pine aspen
#

I may have forgot it.

#

I need to re find it.

pine aspen
#

AH.

#

Yeah. Thanks I got it.

marble juniper
#

can anyone suggest a node module or any api that can auto detect a language

#

its for my translate command

#

(node.js)

summer torrent
#

google-translate

hoary elm
#

@earnest phoenix so when you run the command it gets your info?

restive furnace
#

message.guild.members.find()

hoary elm
#

No

#

Why did you say message twice

#

First of all msg isn't a thing

restive furnace
#

edited alr

hoary elm
#

Unless you define it

restive furnace
#

^ same as message. if you dont define it, it arent a thing.

hoary elm
#

message is a thing when used in a message event ๐Ÿคฆ๐Ÿปโ€โ™‚๏ธ

#

It's automatically defined via the event

restive furnace
#

nope.

hoary elm
#

Lol ok

restive furnace
#

client.on("message", message/msg => {})

hoary elm
#

client.on("message", message => {

#

Defines the message

restive furnace
#

u can choose it can be bruh too

#

or what ever

hoary elm
#

Yeah that's a message event

#

Yes you can choose what you want it to be your not wrong

#

But it is defined with the function the variable is whatever you set it as

grizzled raven
#

wht

#

nvm

hoary elm
#

For a userinfo command if it's returning his info even if he tags someone I'm gonna take a shot in the dark and say he didn't define how to call the user he tags

grizzled raven
#

is there a way to stop multiple instances of a bot without restarting the whole process?

#

bruh i cant word anything

#

๐Ÿ˜”

hoary elm
#

Lol

#

Umm token reset?

grizzled raven
#

ok if you have a bot sending 3 messages, how do you stop that without restarting the bot

hoary elm
#

Don't quote me on that ^

restive furnace
#

Probably by stopping the other instances

hoary elm
#

@grizzled raven so say if you run the help command it returns the response multiple times?

#

Yeah I'd do a token Regen or find what other instances are running and stop them. (Again token Regen not guaranteed to work but usually helps me)

grizzled raven
#

@restive furnace but like how would i go about that

#

and also, it seems as if its works together, like say i set a cooldown, the other instances also have that cooldown cached

hoary elm
#

@grizzled raven do you use d.js?

grizzled raven
#

yes

hoary elm
#

Does your bot restart often on its own?

quartz kindle
#

describe what you want to achieve

#

i dont understand what you're on about

hoary elm
#

Me?

quartz kindle
#

noob

hoary elm
#

Oh

#

He's just having the multiple instances issue

#

Bot responds to one thing multiple times

quartz kindle
#

yeah but what for?

hoary elm
#

It does it for anything he said.. commands, cooldowns

#

if you mean lang it's d.js

quartz kindle
#

no i mean what he wants to achieve, if i dont understand what he wants, its hard to suggest how to approach the problem

hoary elm
#

Oh I see what you mean

quartz kindle
#

it could be load balancing, could be sharding issues

hoary elm
#

That is true

#

Honestly Sharding Issues didn't even cross my mind ๐Ÿคฆ๐Ÿปโ€โ™‚๏ธ

#

@earnest phoenix then your bot is missing perms

#

Make sure it has the send messages perm, read channels perm ect

grizzled raven
#

@quartz kindle i havent sharded, the bot responds to commands and message multiple times, how do i stop it from responding multiple times without actually restarting thr bot

#

not right now, but im just asking for an if so

hoary elm
#

@earnest phoenix could be an error from another server then

#

@earnest phoenix this is for a userinfo command right?

#

Can you show me the code or tell me how you define the user

quartz kindle
#

@grizzled raven why does it respond multiple times? did you add multiple message events?

hoary elm
#

Oof

crimson vapor
#

hey guys, how would one check if a string is a color hex code?

hoary elm
#

Try something like this

let user = message.mentions.users.first();

if(!user) user = message.author

@earnest phoenix

#

Replace what you sent me with what I sent you

charred jetty
#

How to add image in canvas-constructor on glitch?

#

Then?

#

It's asking for path

#

Not link

hoary elm
#

@earnest phoenix what permissions does your bot have

#

It shouldn't throw a perms error unless it's missing a perm

#

To get it to stop sending your info

#

And try this

let user = msg.mentions.users.first();

let muser = msg.guild.member(msg.mentions.users.first());

if (!muser) muser = msg.member;

if(!user) user = msg.author;
#

@earnest phoenix it works if you tag them because that's what your telling it to use

#

A tag/mention

quartz kindle
#

const user = message.mentions.users.first() || message.author || message.guild.members.find(args [1])

#

message.author always exists

#

so message.guild.members.find() is never checked

hoary elm
#

What I sent should work if he sets it up right that's similar to how my set up is currently

quartz kindle
#

just switch them around lol

#

also, .find() requires a function as an argument

#

not a value

hoary elm
#

Tim what if he wanted to get them VIA Nickname or ID that would be defining the user as args right?

#

Nickname is one idk how to do. I know how to make the bot use if they have a nickname in messages like <@!${user}> but mention them via their nickname I have never tried.

#

Don't even know if it's possible

#

But if I tag one it goes, only if I put the nickname it doesn't go
This is Also why I asked that question

warm marsh
#

Search the string with a users name?

hoary elm
#

No he wants to call them via a nickname like let user =

warm marsh
#

String = args.

hoary elm
#

I think

#

Anyways

warm marsh
#

<Guild>.members.find(x => x.whateverthenicknamepropisnowadays === args[index])

hoary elm
#

Oh it is a thing

#

I honestly didn't know that

warm marsh
#

Yeah stable it was displayName

#

Now it's nickname.

hoary elm
#

That's good actually could be useful

#

Thanks for telling me that exists ๐Ÿ˜

warm marsh
#

Np.

#

I think it returns null if a user doesn't have a nickname, Will need to check though.

hoary elm
#

Would only make sense if it does. But I'll look into it

grizzled raven
#

@quartz kindle i dont know

#

that could actually be the case when i think about it, as when the client.ready event is emitted, it loads all commands and events

#

so actual

#

yeah

hoary elm
#

Lol

#

Easy fix ๐Ÿ˜

quartz kindle
#

console.log(client._events)

grizzled raven
#

yeah nvm LUL

#

i restarted the bot already

#

i was just asking for the next time it were to happen

quartz kindle
#

you can disable events by removing them from client._events

#

if that was the problem

slender thistle
#

Is that safe though

quartz kindle
#

yes

earnest phoenix
#

hello

#

go to inspect element and check out what it is then remove it in your css

#

i cant see whats that.

royal ravine
#

How can i check if the mention is a user?

earnest phoenix
#

you very much can

#

ohhh

#

you'll have to regex check for it @royal ravine

#

is wrapper

grizzled raven
#

@royal ravine explain your problem a bit more

royal ravine
#

i have a command like SB give @ user

#

but when the author enters a role

#

so he tags a role

#

the script stops

#

cus it cant give a role a role

#

how can i check if the mention is a user in the channel

quartz kindle
#

what library?

royal ravine
#

i use disocrdjs

quartz kindle
#

how are you parsing the mention?

royal ravine
#

i am doing user = message.mentions.members.first()

#

and then i give the user a role

grizzled raven
#

show the error

royal ravine
#

1 sec

earnest phoenix
#

ok i cant

#

1 se

#

how to remove that line

#

i tried searching that in inspect element

#

but i cant find it

#

whats your bots id

#

going to try to find the element

#

658294671167979570

royal ravine
#

i fixed the error

#

:D

earnest phoenix
#

it's border-top property of the container @earnest phoenix

#

set it to none in your css

#

ok so

neat ingot
#

I've just spent way too long customizing my bots top gg page ๐Ÿ˜„

earnest phoenix
#

i put display: none

#

no

#

that's the display property

#

i said to set the border-top property to none

#

@neat ingot btw, sry for mention, but, how u put the bot icon moving

#

@earnest phoenix wym

#

what

slender thistle
#

kek

#

for the container, set border-top: none

earnest phoenix
#
.border-top
display: none;
}```
#

lol

#

oh

#

OHHH

#

OH

quartz kindle
#

learn css

earnest phoenix
#

okok

#

i understand

#

sry

slender thistle
#

Tbh CSS is hard imo

earnest phoenix
#

how the div class is named?

#

it's really... not

#

its called .container?

#

yes

#

okay ty

#

the class is called container

#

okay

#

. is a class selector

#

its just i did not understand it. @quartz kindle

slender thistle
#

Eh it's probably just me who sucks at this stuff /shrug

earnest phoenix
#

yeah i know

#

lmfao

#

but

#

i tought

#

the class was called like that

#

nvm

#

when you get stuck at those kind of things

#

play with the inspector

#

LMAO rip /

#

yeah

#

but i didnt see that

#
.container {
 border-top: none;
 }```
#

@earnest phoenix

#

does not work

neat ingot
#

@earnest phoenix css styles. you can view source on my page to see how, but i just pinched the css from medals page ๐Ÿ˜„

earnest phoenix
#

yeah yeah xdd i saw that xdd dw

neat ingot
#

border top?

#

your trying to remove the white line at the top of the page?

earnest phoenix
#

try selecting its id

#

#details

#

okay

neat ingot
#
#bot-details-page #details .container {
    border-bottom: 1px solid #18191c;
    border-top: 1px solid #18191c00;
    padding: 40px 0;
}
#

^functional

#

used it on mine

earnest phoenix
#

okay

#

@neat ingot but i need the keyframes for the animation in bot icon

#

btw, thanks it works

amber fractal
#

keyframe animations in css arent that hard

neat ingot
#
@-webkit-keyframes pulse {
  0% {
    -webkit-box-shadow: 0 0 0 0 rgb(255, 181, 59);
  }
  70% {
      -webkit-box-shadow: 0 0 0 20px rgb(255, 181, 59);
  }
  100% {
      -webkit-box-shadow: 0 0 0 0 rgba(25, 118, 210, 0);
  }
}
@keyframes pulse {
  0% {
    -moz-box-shadow: 0 0 0 0 0 0 0 0 rgb(255, 181, 59);
    box-shadow: 0 0 0 0 rgb(255, 181, 59);
  }
  70% {
      -moz-box-shadow: 0 0 0 20px rgb(255, 181, 59);
      box-shadow: 0 0 0 20px rgba(25, 118, 210, 0);
  }
  100% {
      -moz-box-shadow: 0 0 0 0 rgba(255, 255, 255, 0);
      box-shadow: 0 0 0 0 rgba(255, 255, 255, 0);
  }
}

@keyframes float {
    0% {
        box-shadow: 0 5px 15px 0px rgba(0,0,0,0.6);
        transform: translatey(0px);
    }
    50% {
        box-shadow: 0 25px 15px 0px rgba(0,0,0,0.2);
        transform: translatey(-20px);
    }
    100% {
        box-shadow: 0 5px 15px 0px rgba(0,0,0,0.6);
        transform: translatey(0px);
    }
}```
amber fractal
#

or you can spoonfeed, that works

neat ingot
#

i copied from elsewhere so idm ๐Ÿ˜„

amber fractal
#

though they will never learn anything

neat ingot
#

this is true

#

but i already had the edit page opened, so was no real hasstle

#

and saves the dude at least 30 minutes if never done it before

amber fractal
#

But if you learn it you wont need to ask again

earnest phoenix
#
Animista CSS animations on demand

Animista is a place where you can play with a collection of ready to use CSS animations, tweak them and download only those you will actually use.

neat ingot
#

also true ๐Ÿ˜„

earnest phoenix
#

thank me later

#

then i use this:

#
.bot-img img {
    -webkit-animation: mover 1.5s infinite alternate;
    animation: mover 1.5s infinite alternate;
    -webkit-animation-timing-function: ease-in-out;
    animation-timing-function: ease-in-out;
    -webkit-animation-iteration-count: infinite;
    animation-iteration-count: infinite;
    border-radius: 50%;
}```
#

@neat ingot right?

quartz kindle
#

you dont need to repeat properties if you use their short hand version

neat ingot
#

thats a pretty neat site cry ๐Ÿ™‚

#

wait, you dont?

#

so i dont need to use the -webkit prefix?

quartz kindle
#

not that

#

repeating infinite

earnest phoenix
#

@neat ingot ยฟ?

neat ingot
#

ooohh lol. yea noah

quartz kindle
#

and also, most times you dont need to use -webkit

neat ingot
#

im trash with css ๐Ÿ˜ฆ

quartz kindle
#

-webkit is to make it work in old versions of webkit browsers when those properties were still experimental

neat ingot
#

yea that'd make sense ๐Ÿ˜„

quartz kindle
#

so basically animation: name [duration] [timing-function] [delay] [iteration-count] [direction] [fill-mode] [play-state]

#

if you include those properties in the animation rule, you dont need to declare them separetely

#

animation: name 2s;
is the same as
animation-name: name;
animation-delay: 2s;

neat ingot
#

yea i figured what you meant. cause the animation has infinite declared its obsolete in the other declarations ๐Ÿ˜„

quartz kindle
#

yeah, and css is even smart enough to not require them in order

grizzled raven
#

if a message is partial, and you fetch it, will all the properties be fetched too, such as the author, reactions or channel properties

neat ingot
#

oohhhh, now thats a trick!

#

a partial message?

grizzled raven
#

yes

quartz kindle
#

yes, most properties will

slender thistle
#

They should

quartz kindle
#

channel most likely not

grizzled raven
#

huh

neat ingot
#

what makes a message only partial? slow speed?

quartz kindle
#

no

grizzled raven
#

im not on djsv12, so i cannot test this

quartz kindle
#

partial means its incomplete

slender thistle
#

Only part of its properties are available

quartz kindle
#

i can test that for you

neat ingot
#

how would that occur?

grizzled raven
#

yeah thanks

quartz kindle
#

this is what a message packet contains

#

so fetching a message will parse and resolve whatever it can from that

#

if the channel is cached, it will have a full channel, if guild is cached, it will have a full guild

#

but the message itself only comes with author, embeds, mentions and attachments

#

also reactions if they exist

#

it doesnt come with reaction details, those need to be fetched separately

shrewd perch
earnest phoenix
#

@quartz kindle how can i lock a command if a json value is a id?

shrewd perch
#

What this ?

#

@quartz kindle

quartz kindle
#

this is not the support server for invite manager

earnest phoenix
#

LOL

quartz kindle
shrewd perch
#

@quartz kindle ok next

earnest phoenix
#

@quartz kindle can you answer my question now?

quartz kindle
#

explain better pls

earnest phoenix
#

the command works only if a json value is an id

mossy vine
#

hes saying that you are not good enough and wants the next person to help

quartz kindle
#

Lol

#

@earnest phoenix explain better pls

shrewd perch
#

@quartz kindle please help me

quartz kindle
#

show code example

earnest phoenix
#

:\

#

i dont have code

quartz kindle
#

@shrewd perch i already told you, you are in the wrong server

#

we have nothing to do with invite manager

earnest phoenix
#

-wrongserver @shrewd perch

#

lol

#

wrong cmd

#

@quartz kindle so, i mean, lock command only for ids

quartz kindle
#

check if ids exist?

earnest phoenix
#

noo

summer torrent
earnest phoenix
#

the command to work only for specified ids

quartz kindle
#

yeah

#

make a list of ids

earnest phoenix
#

Yes

#

i made

quartz kindle
#

and check if the id exists in the list

#

before continuing the command

earnest phoenix
#

how can i check the if id exists?

quartz kindle
#

show code

earnest phoenix
#

i dont have code

quartz kindle
#

then make a code lol

earnest phoenix
#

:\

quartz kindle
#

load the json file or whatever

#

into a variable

earnest phoenix
#

how

quartz kindle
#

then check if the id exists in the variable

earnest phoenix
#

how can i load the json file into a variable

#

you confusing me

quartz kindle
#

require or fs.readFile or fs.readFileSync

earnest phoenix
#

Ok

quartz kindle
#

this is like super basic stuff

#

you should google before asking here

earnest phoenix
#

ok

zenith orchid
hollow prawn
#

is it against the ToS of DBL/top.gg to have direct communication to server owners from me thru messaging my bot?

#

so basically i'd be able to message a server owner and vice versa thru my bot

crimson vapor
#

I think that as long as you don't message a server owner first it is okay but a mod would know

hollow prawn
#

ye the question is generally towards a mod but dont wanna ping them bcs p sure there's rule against that xd

slender thistle
#

Not exactly the right channel for such question
It's finmost likely alright if the bot mentions who sent which message

hollow prawn
#

it would do it thru quotation with rich embeds

#

so it'd be like jsut message relay

slender thistle
#

eh sounds alright

#

Just state the message author and you're good

finite bough
#

make an @earnest phoenix array

#

and check

#

coz

#

it's easier on the basic level

#

u can use advanced stuff when u get the hang of it

grizzled raven
#

huh

#

ok tim

#

so i'll fetch channel, reactions and author properties i guess thonking

quartz kindle
#

author is included in the message

grizzled raven
#

oh wait

#

you cant g

#

yeah nvm

quartz kindle
#

if you have nothing cached, the correct order would be to cache guild -> channel -> message -> reactions

grizzled raven
#

but

#

ok so isnt message.guild a get property, getting message.channel.guild?

zenith orchid
#

Why is the CSS file not included on the page? This my code head tag between:

@zenith orchid

quartz kindle
#

what does your console say?

#

(browser console) (f12 -> console)

#

actually, go to network and reload your page

#

@grizzled raven yeah it is

#

what are you trying to do?

zenith orchid
quartz kindle
#

@zenith orchid show your style.css

zenith orchid
quartz kindle
zenith orchid
#

Cannot GET /style.css

quartz kindle
#

are you using express?

zenith orchid
#

Yes, i solved

earnest phoenix
#

@zenith orchid you Turk

zenith orchid
#
  res.sendFile(__dirname + "/web/style.css")
});```
earnest phoenix
#

?

quartz kindle
#

you could just use static files lol

finite bough
#

ctrlc ctrlv

zenith orchid
#

@earnest phoenix You have a worse english than me.

#

@quartz kindle thx

earnest phoenix
#

@zenith orchid thx

finite bough
#

@finite bough thx

zenith orchid
#

If you mention me, i'm will report u.

earnest phoenix
#

Normally good, now it's broken

finite bough
earnest phoenix
#

@earnest phoenix translate?

kind flicker
#

I'm looking for base Bootstrap template to edit? Do you recommend something?

maiden crown
#

Hey everyone, Iam pretty new (aka I donโ€™t know anything tbh) to this and I just want to get a general idea how I can fix my problem:

What options would you recommend me for setting up a deadman switch bot? I need it to dm friends of mine when I donโ€™t send it a message in a set period of time. Mentioned people will be in the same server as the bot and allow it to dm them

true ravine
#

Have you check to see if a solution exists already?

maiden crown
#

I tried to find something on the net but Iam afraid I do not know where to look and how to have good results

true ravine
#

If you're looking to make a solution yourself then, I would personally recommend finding a Discord.JS bot tutorial on youtube, opening up the Discord.JS docs and joining their help server. The function you want to achieve shouldn't be too difficult to achieve and the Discord.JS server are very helpful if you get stuck

maiden crown
#

Thanks a lot, thatโ€™s a way I can follow

halcyon ember
#

Im writing a bot in Discord.js and its giving a role when I run a command that mentions the user. Is there a way to delete all messages sent by the user i mentioned in the command?

earnest phoenix
#

kinda like the purge command?
There is but i forgot how let me look it up

true ravine
#

You would probably be using a fetchMessages function, although for specific help I would recommend joining the discord.js server

halcyon ember
#

Ok

#

@earnest phoenix yea basically purge but for one specific user

earnest phoenix
#
// Parse Amount
const amount = !!parseInt(message.content.split(' ')[1]) ? parseInt(message.content.split(' ')[1]) : parseInt(message.content.split(' ')[2])
if (!amount) return message.reply('Must specify an amount to delete!');
if (!amount && !user) return message.reply('Must specify a user and amount, or just an amount, of messages to purge!');
// Fetch 100 messages (will be filtered and lowered up to max amount requested)
message.channel.fetchMessages({
 limit: 100,
}).then((messages) => {
 if (user) {
 const filterBy = user ? user.id : Client.user.id;
 messages = messages.filter(m => m.author.id === filterBy).array().slice(0, amount);
 }
 message.channel.bulkDelete(messages).catch(error => console.log(error.stack));
});```
halcyon ember
#

o thx

earnest phoenix
#

Np

#

my advice would be

#

even if your current bots code would allow you to copy and paste that dont

#

id look at it and try to dissect it then make your own so itll help you in the future :)
if you copy and paste everything (like i did for one of my first apps ๐Ÿ‘€ ) when its time to fix it youll be lost

tight plinth
#

Hi. With djs v11, I'm trying to get the bot send an error embed each time "soemthing went wrong" whle executing a command. but this code https://prnt.sc/r9nt7r (here on my command handler) just doesnt work, the error is just sent in the console, o error message. Why? Is there something wrong in this code?

Lightshot

Captured with Lightshot

true ravine
#

Your then block should look like .then(() => { and you should put a }) on the line below the console.log

#

It's meant to enclose the code to do 'then'

#

Can't easily give an example as I'm on mobile

quartz kindle
#

if the console.log is working then thats not the problem

tight plinth
#

u mean like that?

grizzled raven
#

@quartz kindle when you fetch a channel, would the guild also be fetched, since the api endpoint is guilds/id/channels/id, isnt it?

tight plinth
#

unexcepted token .

grizzled raven
#

actually that might not matter but im just asking anyway

tight plinth
#

wait what the fuck

quartz kindle
#

@grizzled raven i dont think so

grizzled raven
#

oh okay

quartz kindle
#

the channel will have a guild id, but not the full guild

tight plinth
true ravine
#

Is error like a reserved word

tight plinth
#

error is never defined in my code

#

except here

true ravine
#

No but in general

quartz kindle
#

but you said this console.log was working right?

tight plinth
#

else it will show an error like 'error is aleready defined'

#

yes

quartz kindle
#

the error was logged to your console

#

then the problem has nothing to do with that

#

add a .catch to the message

tight plinth
#

just broke a command (ping)

quartz kindle
#

well thats an unhandled promise rejection

tight plinth
#

oh

quartz kindle
#

are you awaiting your promises?

summer torrent
#

@flat pelican ads

quartz kindle
#

@earnest phoenix ads are not allowed

tight plinth
quartz kindle
#

lmao

grizzled raven
#

tim you got killed

summer torrent
#

stop sending ads

grizzled raven
#

banned now

tight plinth
#

banned

quartz kindle
#

is command.execute an async function?

tight plinth
#

Tonkku

#

yes

quartz kindle
#

then you have to await it

#

otherwise the error will not be caught

#

try/catch can only catch sync errors, not async errors

tight plinth
quartz kindle
#

unless they are awaited

tight plinth
#

like that?

quartz kindle
#

no, the execute

tight plinth
#

oh

#

yep, now it works

#

well thx u tim

quartz kindle
#

im not a boomer btw

earnest phoenix
#

hello

tight plinth
#

ur not

earnest phoenix
#

can i have help

sudden geyser
#

ask question pls

tight plinth
#

for what

earnest phoenix
#

in folder

quartz kindle
#

lol

#

what folder?

tight plinth
#

lol

earnest phoenix
#

my folder

tight plinth
#

i think he means right click menu on windows

earnest phoenix
#

no

tight plinth
#

oh

quartz kindle
#

command prompt is a program. you can find it in the start menu

earnest phoenix
#

it says hold shift key and right click anywhere inside the folder

quartz kindle
#

yes

tight plinth
quartz kindle
#

did you try it?

earnest phoenix
#

what start menu

#

window start menu????

quartz kindle
#

what happens if you right click anywhere inside the folder?

earnest phoenix
#

hold on

quartz kindle
earnest phoenix
#

i dont have open command prompt

#

where do i find it

quartz kindle
#

you have to hold SHIFT while right clicking

earnest phoenix
#

i see open powershell

#

what is that

quartz kindle
#

ah

#

you can use that

#

power shell is like a super mega version of command prompt

summer torrent
quartz kindle
#

there is an option in windows that says "replace command prompt with power shell"