#development

1 messages ยท Page 858 of 1

golden condor
pale vessel
#

@edgy heron

#

refer the link

edgy heron
#

but in this server. i want cor! prefix to work

golden condor
#

Use๐Ÿ‘A๐Ÿ‘DB

#

quick-db will do

pale vessel
#

he's not ready for it yet

edgy heron
#

oh thanls

tired nimbus
#

i dont know why

spare goblet
#

Quick db has some issues

#

Low-key don't recommend

tired nimbus
#

quick.db seems to be faster than better-sqlite3 with no wrapper

edgy heron
#

@Icero this is nicer
let prefix = ".";
if (message.guild.id === "DBLID") prefix = "cor!";

modest maple
#

postgres is better overall if you can set it up

spare goblet
#

Use a non file based db beggygiggle

quartz kindle
#

quick.db is not faster than sqlite

modest maple
#

^^

#

@spare goblet wut

spare goblet
#

quick db uses better sqlite 3 no

#

So technically it should be the same

#

Or a bit slower

tired nimbus
#

it might be the settings

modest maple
#

anything that is built of another thing will not be faster than the thing its built off

spare goblet
#

Yeah

modest maple
#

unless u do some crazy mumbo jumbo and commit tax faud

quartz kindle
#

yup

tired nimbus
#

I think its because I didn't optimize bettersqlite3 for the fastest use

modest maple
#

fastest

edgy heron
spare goblet
#

Better sqlite 3 has different use optimisation?

modest maple
#

idek

spare goblet
#

Never seen it

modest maple
#

i would put my own code

tired nimbus
#

right now its making 3 files

modest maple
#

farrrrrrrrr slower before blaming the DB

#

like my sqlite db atm thats what 1.4 Million rows on one table rn ignoring the other, takes a fraction of a ms

pale vessel
quartz kindle
#

sqlite3 has extensive customization and options for various use cases, for example if you prioritize write-intensive usage or read-intensive usage, large data or small data, redundancy/atomicity or performance

golden condor
#

I have been trying to set my bot to dnd for ages and it won't work
on discord.js

edgy heron
#

how can i try though

spare goblet
#

Interesting

#

@golden condor Do you get an error or

golden condor
#

No

#

Just doesn't work

#

client.user.setPresence({ activity: { name: c!help | ${client.guilds.cache.size} servers | ${value.toLocaleString()} users }, status: 'dnd' })

quartz kindle
#

discord status is wonky, sometimes it simply doesnt work and then it randomly works again

#

idk

edgy heron
#

@pale vessel sad

golden condor
#

I have tried many times before

spare goblet
#

Odd

pale vessel
#

did you try it on a dm?

edgy heron
#

wdym

#

actually i cant try it

#

coz i cant try the commands in this server

#

the bot has common prefix role

#

๐Ÿ˜„

#

both prefix are working

#

but we need only cor! working here

golden condor
#

I'm so annoyed

#

why does discord not let me change my bot status

edgy heron
#
var prefix ="cor!";
}else{
var prefix ="c!"```
spare goblet
#

Ew

#

var

#

Why the heck

finite bough
#

dont use var

#

let is more safe

edgy heron
#

what should i do xD

finite bough
#

let

spare goblet
#

You could make it way simpler with let
let prefix = ".";
if(guild.id === "26435355"){
prefix= "cor!"
}

#

Shorter code

slender thistle
#

"it works" != "It's good"

spare goblet
crimson vapor
#

let is better Imo

spare goblet
#

var is bad practive

finite bough
#

tho using var looks more bossy ngl

#

xD

edgy heron
#

guild isnt defined

finite bough
#

let and var have their differences

edgy heron
#

i am new

spare goblet
#

@edgy heron It's cuz you're getting DMs.

crimson vapor
#

no

spare goblet
#

I-
Ig they didn't put a guild object in

pale vessel
#

try ```js
let prefix = ".";
if (message.guild && message.guild.id == "264445053596991498") prefix = "cor!";

spare goblet
#

Okay

#

big brain

languid dragon
quartz kindle
#

also, you probably want to store your prefixes in a variable outside the message event lol

languid dragon
finite bough
#

defining it in every command

edgy heron
#

i think i am adding the code in wrong place

finite bough
#

is a very bad practice

edgy heron
#

bot.on("message", async message => {
  const prefixes = JSON.parse(process.env.PREFIXES);
  let chosenPrefix;

let prefix = ".";
if (message.guild && message.guild.id == "697473598033756241") prefix = "cor!";

  for (const prefix of prefixes) {
    if (message.content.startsWith(prefix)) {
      chosenPrefix = prefix;
      break;
    }```
spare goblet
#

@languid dragon No minimodding :)

languid dragon
#

smh im not minimodding nerd

quartz kindle
#

@edgy heron youre overcomplicating something very simple

edgy heron
#

๐Ÿ˜„

spare goblet
#

Ugh

snow urchin
#
           message.channel.send({embed: {description: "Fetching statistics...", color: "#36393F"}}).then(msg => {
invalid form body
spare goblet
#

Uhh idk whatyoire doing

edgy heron
#

not a start though

#

๐Ÿ˜ฆ

#

leave it

languid dragon
#

@woven sundial don't take rules/guidelines out of context

quartz kindle
#

@edgy heron how many prefixes do you have?

edgy heron
#

2

languid dragon
#

that has nothing to do with starting actual bot development, the rule is defined so people dont think adding a bot to DBL is how you create a bot

quartz kindle
#

and you use both prefixes for all servers?

edgy heron
#

i have .env file

#

tim yes

spare goblet
#

@woven sundial. Some people create a bot on top.gg and input their code in the description

edgy heron
#

xD

pale vessel
#

and markdown examples

spare goblet
#

And think it'll host

Spoiler: it won't host. :')

edgy heron
#

lol

#

And think it'll host

SO Funny

languid dragon
#

also note that line you screenshotted relates to the note right above it, which essentially provides the original context for the statement as a whole

crimson vapor
#

is this true?

pale vessel
#

btw is luca using d.js or custom?

languid dragon
#

well it's not, don't discourage new people asking for development help by spreading misinformation on the guidelines in #502193464054644737

spare goblet
#

iirc djs :') but ion remember

edgy heron
#

stimky, me?

languid dragon
#

not you

edgy heron
#

oh

quartz kindle
#
const prefixes = JSON.parse(...) // parse your prefixes once and save them, instead of parsing them on every single message

bot.on("message", async message => {
  let px = message.guild && message.guild.id === "id" ? ["cor!"] : prefixes;
  let currentPrefix = px.find(t => message.content.startsWith(t));
  if(currentPrefix) {
    // do your code
  }
})```
earnest phoenix
#

or module.exports

earnest phoenix
#

So i have a purge command but how can i make it delete my message first then delete the amount of messages that was mentioned in front of it?
Like: _purge 1
Output: My message gets deleted and a message above that

valid frigate
#

i'm trying to work with json web tokens to authenticate requests on my api, and i'm thinking about how to handle passwords. so basically i have a jwt with a payload with the user's username, and i'm thinking about adding a the user's password hash to the payload so if their password changes, the server can also check the hash and compare to see if they are the same or not and determine the validity of the token

#

basically is it a good idea to do this? storing a password hash in plaintext theoretically

#

but on the client side

quartz kindle
#

@earnest phoenix delete the message first, then use purge

earnest phoenix
#

Lmao

quartz kindle
#

or do purge +1 lol

earnest phoenix
#

Like seriously how is it possible?
When i even try to like do
{args[0] + 1} it doesn't return as a number...
It's just isNaN

quartz kindle
#

because args is a string

#

"1" + 1 = "11"

#

and args[0] is possibly not the correct arg

earnest phoenix
#

Hmm what's the correct one then?

quartz kindle
#

idk whats your code?

crimson vapor
#

ok

#

so why not message.delete() then message.channel.bulkDelete(args[0])?

quartz kindle
#

@valid frigate not familiar with jwts but passwords, hashed or not, shouldnt be stored on the client side, instead you should probably exchange the password for a token, and store that on client side. if im understanding the question correctly

earnest phoenix
#

Also that's the code for args

valid frigate
#

yes thats what i mean

earnest phoenix
#

Idk

valid frigate
#

im storing a hash within the jwt payload

#

or i was planning to

marble juniper
#
function cooldown(message, client) {
    const time = 5000
    function delay() {
        setTimeout(() => {
            commandCooldown.delete(message.author.id);
            message.author.send(`You can now use daily again! `+client.emoji.ring)
        }, time);
    }

    if(commandCooldown.has(message.author.id)) {
        const minute = 60000
        const hour = minute * 24

        message.channel.send(`you need to wait **${Math.round((commandCooldown.get(message.author.id) - Date.now)/minute)} minutes** and **${Math.round((commandCooldown.get(message.author.id) - Date.now)/hour)} hours** untill you can use daily again`)
    }
    else {
        // other stuff happening which I did not show and is not relevant
        commandCooldown.set(message.author.id, new Date())
        delay()
    }
}

My problem is that when I am trying to get the minutes and hours which are left for the cooldown to expire I get NaN

finite bough
#

or u can do message.deleate() then or await prune

valid frigate
#

its just the concern over invalidating tokens because when a user changes their password, the token is still valid since it only carries a username

earnest phoenix
#

Hmm lemme try deleting the message with that then doing it...

valid frigate
#

i was thinking like maybe adding the token to a redis db and blacklisting it until the token expires

quartz kindle
#

yes, a password change doesnt necessarily mean the token is reset, i've seen a few services that dont bother invalidating the token when you change your password

#

but if you want to, you can always manually invalidate the token on password change

valid frigate
#

i was reading about how others went about invalidating tokens

#

anyway thanks for the clarification mate, i think i know where to go from here

quartz kindle
#

@marble juniper new Date() creates a date object, which when stringified, returns a date string

#

you want Date.now() instead, which creates a timestamp

marble juniper
#

oh ok

earnest phoenix
crimson vapor
#

you need to make it a function

#

message.delete()

#

wait no you cant do that

earnest phoenix
#

Hmm

crimson vapor
#

thats not gonna work and you are abusing api

#

message.delete()

#

then

#

message.channel.bulkDelete()

earnest phoenix
#

Wait... Do i have to put a .then after the message.delete()? @crimson vapor

crimson vapor
#

no

quartz kindle
#

yes

#

or await it

#

you dont need to fetch the messages before bulkDeleting

#

bulkDelete also takes a number

earnest phoenix
#

Wait when i try to put a .then() function after message.delete() it says message.delete().then()
Is not a function..

quartz kindle
#

then you're doing something wrong

#

whats your full code?

earnest phoenix
#

Full code of purge command? @quartz kindle

quartz kindle
#

yes

earnest phoenix
#

It's literally up there... Scroll up

crimson vapor
#
if(isNaN(args[0])) return; //check if its a number
if(args > 100 || args < 2) return; //make sure its correct value, no point going lower than 2 and higher than 100 will not work
await message.delete(); //delete the message
await message.channel.bulkDelete(args[0]); //clear the amount you want
return; //end the command```
earnest phoenix
#

Hmm lemme try that real quick...

quartz kindle
#

await message.delete()
await message.channel.bulkDelete()

finite bough
#

inside an async function

crimson vapor
#

yes

earnest phoenix
#

Thx it worked as

await message.channel.bulkDelete(args[0]);```
#

@finite bough also ik that lmao

finite bough
#

just saying

#

people in this channel tend to suprise me sometimes

crimson vapor
#

^

lean linden
#

ow to edit a picture via node js script?

lyric mountain
#

verified where?

#

on dbl or on discord?

#

having a genuine bot I guess

#

there're lots of data they request u in the certification form

#

like what data you collect, why you collect, where you store, is your server safe, etc

#

they'll PM you when the time comes

#

read the above comment

#

yep

#

not the, but an

#

you can use any card that can be used to identify yourself

lean linden
#

ow to edit a picture via node js script?

#

ok thank you

uneven egret
#

hi

true ravine
#

I know it varies based on your bot, but does anyone else rely very heavily on databases to make their bots work?

lyric mountain
#

define "very heavily"

true ravine
#

Say you want to add a new feature, you immediately need to create a new table because you don't really have any other suitable way to make the feature work

lyric mountain
#

ah, that's not heavily at all

#

just normal db usage

#

yep

true ravine
#

Oh right fair enough

#

Just wondered

lyric mountain
#

if you need to persist something you gotta make a new table

#

best practice is to have one table for each subject

#

avoiding to make a misc table

earnest phoenix
#

disgostang

true ravine
#

Yeah I do have a misc table but I don't think it's used anymore

earnest phoenix
#

disSgOSTANG

true ravine
#

No u

#

With this discord verification thing, if a user wanted me to clear their data but they were in my blacklist table does that that mean I'd have to subsequently unblacklist them or would I be allowed to leave their id in that table

digital ibex
#

hi, how would i create a prefix command with mongoose?

earnest phoenix
#

you probably have the incorrect infrastructue for your database - the most reliable way is to have a table of guilds and then adding columns to that table based on what you need

grizzled raven
#

if one shard goes down (can a shard go down?) in discord.js v12's internal sharding, what happens?

lyric mountain
#

it goes down

grizzled raven
#

no

digital ibex
#

only one shard goes down

valid frigate
#

uh well

#

it uh tries to respawn no?

tired nimbus
#

/opt/watcher/app-types/node/start.sh: line 9: wait_for: No record of process 24395

#

now it wont reload

quartz kindle
#

shards always try to reconnect automatically

valid frigate
#

oh right reconnect

#

is there ever a scenario where it can't reconnect and just permanently dies while the process is running

digital ibex
#

yeah, but you'll have to find out why

earnest phoenix
digital ibex
#

read it

#

cannot read property of 'url' of undefined

earnest phoenix
#

oh

#

so it just needs to be .first()?

digital ibex
#

i believe so

quartz kindle
#

its not a contradiction

grizzled raven
#

no its because there are no attachments

quartz kindle
#

because trying to get a property of undefined will error out before it ever attempts to do the comparison

earnest phoenix
#

how else do i check if a message contains an attachment in discord.js?

grizzled raven
#

because my host said i have 2gb of ram lol

#

which would explain why my bot was logging due to heap used

quartz kindle
#

@earnest phoenix first check if an attachment exists, then get its url

#

you can use a little trick for that

grizzled raven
#

i dont understand but i know its an image that says i am wrong imcool

quartz kindle
#

(message.attachments.first() || {}).url

#

@grizzled raven heap is a section of ram dedicated to storing objects

#

it will be dynamically resized based on its needs

grizzled raven
#

huh

quartz kindle
#

resident set (rss) is the total ram used by the process

grizzled raven
#

how do you get the total ram available

quartz kindle
#

process.memoryUsage().rss

grizzled raven
#

star eval silent message.author.send(process.memoryUsage().rss / (1024**3))

#

that was ~1.3

quartz kindle
#

so 1.3 gb?

grizzled raven
#

huh

#

someone stole 0.7gb of my ram

earnest phoenix
#

seems a bit hacky but none of the methods i found intuitive has worked so far

quartz kindle
#

thats the total ram used by your process

#

not the available ram in the system

grizzled raven
#

oh

quartz kindle
#

to see system ram, use os

#

@earnest phoenix what methods?

grizzled raven
#

oh okay its 2gb

#

but

#

uh

#

if rss passes

#

nah im confused i cant phrase this question

earnest phoenix
#

just tried message.attachments.size !== 0 that seems to work, not sure if your way checks for more @quartz kindle

grizzled raven
#

maybe i was calculating my ram wrong

#

zerp thats fine

#

tims way just makes it return undefined if there are no attachements, or the url if there are

quartz kindle
#

if rss gets to 2gb it will crash the process due to out of memory

grizzled raven
#

hm

#

well i've been measuring heapused, which isnt rss obv bigbrain, and it hasnt ever really gotten above 1.3gb

charred jetty
#

"6123459" here how can i make it 6,123,459 ?

amber fractal
#

in what lang

charred jetty
#

Js

quartz kindle
#

depending on your system's region and language settings, you can do this

amber fractal
#

new Intl.NumberFormat('en').format(num) should work

quartz kindle
#

or this ^ if your region is different

charred jetty
#

Ok..lemme try in testing

amber fractal
#

or if you need to format multiple times const formatter = new Intl.NumberFormat('en') then using formatter.format(num) should do the trick

charred jetty
#
if(num >= 1000) {
//I don't understand
}```
#

Like i wanna do 10000 to 10k

quartz kindle
#

10000 / 1000 = 10

#

10 + "k" = "10k"

charred jetty
#

Ohk

grizzled raven
#

if you really wanted to be uncool like me, you could do ```js
let num = 2038 // whatever number
let s = num.toString().substring(0, 2) + "k"

amber fractal
#

so yeah

#

nice 20k

copper cradle
#

lmao

quartz kindle
#

lmao

copper cradle
#

2,0k

#

tim

#

I already said lmao

turbid bough
#

lmao

grizzled raven
#

or if you wanted to be extra uncool this might not work for some regions lol you could do this

let num = 728290
num.toLocaleString().split(/\.|,/)[0] + "k"
``` ![imcool](https://cdn.discordapp.com/emojis/697156764491317248.webp?size=128 "imcool")
earnest phoenix
#
collection('users').find({ skillsQueue: { $exists: true, $ne: [] } })
``` for anyone good with mongodb my logic is this would pull all mongo entries with non empty skillsQueue arrays right?
turbid bough
grizzled raven
#

what

turbid bough
#

nvm thats probably how it works

grizzled raven
#

Eval
Executed in 12.910363ms.
Input
let num = 728290
num.toLocaleString().split(/.|,/)[0] + "k"
Output
'728k'

turbid bough
#

whats your just "toLocaleString()" output?

slim flame
grizzled raven
#

toLocaleString for me outputs 000,000,000,000...

turbid bough
#

uuh

grizzled raven
#

nnn,nnn

turbid bough
#

num.toLocateString does that??

grizzled raven
#

well i see yours is spaces

turbid bough
#

oh yeah its in spaces

red hollow
#

is this possible to convert 2000 to 2K trough toLocaleString tho?

grizzled raven
#

forgot some countries output spaces

turbid bough
#

why do you need to substring that message flavex?

#

Math.floor(2038/1000) + "k"

#

uuh and btw, toLocaleString seems so stupid to use

#

seems like some counties could be using , instead of .

#

and exchange between them so it looks like . is ,

#

so like if you dont floor your number, you would get like 10.412,12 and it would be 10k or something

#

or im dumb

#

nvm, if you were using [0] then it would work

#

and if it only used . and ,

grizzled raven
#

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

#

what happens if your heap usage reaches 100%

turbid bough
#

memory exception?

quartz kindle
#

the heap size will be increased

turbid bough
#

oh right this isnt java

grizzled raven
#

huh

#

wait this deosnt make sense

#

my process is using 1.2gb of ram but thw bot is offline lol

#

and why is the bot offline

lime jewel
#

Did anyone here used Discord.js ans sharding yet?

quartz kindle
#

many people

pine bear
#

So I created a simple event handler but for some reason the command is unresponsive,

index.js

client.commands = new Discord.Collection();
client.aliases = new Discord.Collection();

const commandFiles = fs.readdirSync('./commands/').filter(file => file.endsWith('.js'));
for(const file of commandFiles){
    const command = require(`./commands/${file}`);

    client.commands.set(command.name, command)
}

    

client.on("message", message => {
    let args = message.content.substring(prefix.length).split(" ")

    switch (args[0]) {
        case 'adora':
            client.commands.get('adora')
        break;

    };
});

adora.js

module.exports = {
    name: 'adora',
    description: 'says Catra!',
    execute(message, args){
        message.channel.send("Catra!");
    }
}
``` is there something wrong, because i don't know because nothing shows on the console logs.
turbid bough
#

yeah i dont see any console.log either

pine bear
#

no I mean like no errors show

lime jewel
#

Hab someone help me?

I get this Error:

Launched shard 0
(node:32187) UnhandledPromiseRejectionWarning: TypeError: process.send is not a function
    at Client.<anonymous> (/root/Wumpy/node_modules/discord.js/src/sharding/ShardClientUtil.js:37:17)
    at Client.emit (events.js:323:22)
    at WebSocketManager.triggerClientReady (/root/Wumpy/node_modules/discord.js/src/client/websocket/WebSocketManager.js:433:17)
    at WebSocketManager.checkShardsReady (/root/Wumpy/node_modules/discord.js/src/client/websocket/WebSocketManager.js:417:10)
    at WebSocketShard.<anonymous> (/root/Wumpy/node_modules/discord.js/src/client/websocket/WebSocketManager.js:199:14)
    at WebSocketShard.emit (events.js:311:20)
    at /root/Wumpy/node_modules/discord.js/src/client/websocket/WebSocketShard.js:478:12
    at Timeout._onTimeout (/root/Wumpy/node_modules/discord.js/src/client/BaseClient.js:83:7)
    at listOnTimeout (internal/timers.js:549:17)
    at processTimers (internal/timers.js:492:7)
(node:32187) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:32187) [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:32187) UnhandledPromiseRejectionWarning: Error [SHARDING_READY_TIMEOUT]: Shard 0's Client took too long to become ready.
    at Timeout.onTimeout (/root/Wumpy/node_modules/discord.js/src/sharding/Shard.js:160:16)
    at listOnTimeout (internal/timers.js:549:17)
    at processTimers (internal/timers.js:492:7)
(node:32187)
#
    at Timeout.onTimeout (/root/Wumpy/node_modules/discord.js/src/sharding/Shard.js:160:16)
    at listOnTimeout (internal/timers.js:549:17)
    at processTimers (internal/timers.js:492:7)
(node:32187) 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: 2)
turbid bough
#

process.send is not a function

lime jewel
#

Yes but I dont use process.send ...

turbid bough
#

dunno then

#

ive never used it, is your Main.js file really named Main.js?

#

just making sure

lime jewel
#

Yes

#

It is

quartz kindle
#

@pine bear two things

#
  1. putting a function in an object should be done like this: execute: (args) => {} or execute: function(args) {} and not execute(args) {} as this one is for class methods
#
  1. you get the command but never execute it. should be commands.get(name).execute(args)
pine bear
#

oh ok.

quartz kindle
#

and 3. you dont need a switch case

#

because you dont need to check for the name of every single command

#

you can simply check if the command exists in client.commands: if(client.commands.has(args[0])) { client.commands.get(args[0]).execute() }

#

@lime jewel which discord.js version?

lime jewel
#

v12

#

Installed yesterday

twilit rapids
#

Outdated NodeJS version maybe 02think

quartz kindle
#

your Main.js might have a problem thats preventing it to load

#

and yeah, whats your node.js version?

lime jewel
quartz kindle
#

show your main.js code

lime jewel
#

Its much

#

And some german Things in

sudden geyser
#
  1. putting a function in an object should be done like this: execute: (args) => {} or execute: function(args) {} and not execute(args) {} as this one is for class methods
    execute(args) {} is actually fine according to JS.
lime jewel
#

Too long For Discord

sudden geyser
#

Upload it somewhere

twilit rapids
#

It should provide an option to send it as a file

#

If you all past it in

pine bear
lime jewel
turbid bough
#

remove case and break

#

and just use args[0] as your first parameter

#

in get()

pine bear
#

Oh ok.

lime jewel
#

found something in Main? @quartz kindle

quartz kindle
#

you are not using express.js anywhere, so you should remove it

#

you have an interval without a timer

#

you have duplicated double loops

pine bear
#

ok now it's just showing errors.

lime jewel
#

I used Express before I startet Coding in sharding

#

Ok but anything Throwing the Error?

pine bear
#

uhh, like 2 things,

quartz kindle
#

@lime jewel a lot of bad ideas but nothing causing the error specifically, might be another file. try disabling some stuff like chatbot api and see if it works

lime jewel
#

Ok i'll try it

pine bear
quartz kindle
#

what the fuck

west raptor
#

i cant even

quartz kindle
pine bear
quartz kindle
#

(and dont you dare remove client)

pine bear
#

I ain't that dumb!

quartz kindle
#

good

pine bear
#

ok maybe, sometimes.

quartz kindle
#

lmao

earnest phoenix
#

This is just hilarious...

#

Eats popcorn

lime jewel
#

I disabled ChatBot API but there is the Error against

quartz kindle
#

try disabling your command handlers

#

and event handlers

lime jewel
#

Ok

pine bear
west raptor
#

ok anyways, I want to use embeds for information that's obtained from the message but the issue is like.. it can be like 100 in one messages if someone wanted to abuse it, ie: omg im cringe weeb bro fuckin watch {sowrd atr oline} it amazing!! and make sure to read <deomn slyer> it so good bro

and of course memes aside it would gather info on the shit inbetween {} and <> and that can be up to how much discord messages can handle. So the issue is I would use multiple embeds in one message but that's not possible for bots, sending them individually would be troubelsome. Not really sure what to do in this case

#

plain message is hard as fuck to format

quartz kindle
#

@pine bear are you even trying?

pine bear
#

yes.

quartz kindle
#

get doesnt exist

west raptor
#

please learn javascript

#

and nodejs

quartz kindle
#

i told you to remove switch, not replace it

#

remove the block completely

#

and get the command directly from client.commands by using args[0]

#

client.commands.get(args[0])

#

then just call execute on it

#

and give the execute whatever arguments your execute needs

#

your execute needs message and args, so your command should call .execute(message,args)

#

but first you need to check if the commands exist

#

so you can put the command in a variable

#

let command = client.commands.get(args[0])

#

then check if(command)

#

and if there is a command, do command.execute(message.args)

earnest phoenix
#

@quartz kindle calm down a little...
Don't get angry...
You're literally Overloading your brain...
Lmao

quartz kindle
#

when i go into teacher mode i cant stop lmao

pine bear
#

lmao

hot moat
#

oof

pine bear
#

I still don't, bruh.

quartz kindle
#

what now...

pine bear
finite bough
#

if we are talking about changing channel names how often can they be changes without abusing discord api

quartz kindle
pine bear
#

*why this?*

quartz kindle
#

message.args = get args from inside message
message, args = get message and then get args

pine bear
#

faceplalms, why am I like this, I literally feel that much os a dummy.

finite bough
#

tim can u answer that^

quartz kindle
#

you feel dumb because you dont know the language, you should learn the language first

#

for example, dots . are always used to get stuff from inside other stuff

#

and commas , are always used to separate things

pine bear
#

I kinda know that, it's just that I never got back into JavaScript in over 2 weeks.

quartz kindle
#

well now you should know harder

#

lmao

pine bear
#

yes and that, and I've been at this for over 2 says, no cap.

quartz kindle
#

but repeating mistakes is the path to learning, the more mistakes you repeat, the less often you will repeat them again because the harder they will get stuck in your brain

pine bear
#

yes,

quartz kindle
#

just a lot of those mistakes can be easily fixed by going through the basics of the language again

pine bear
#

that and continuously misspelling length as lenth

quartz kindle
#

i misspell it as lenght

pine bear
#

that to

#

and that is coming from a slow typer.

turbid bough
#

has anyone here dealt with appveyor and visual studio building?

pine bear
#

@quartz kindle, ok so this is not that much, but I think there is some problems with it.

heavy marsh
#

@quartz kindle Tim sorry if i annoyed you about the broadcastEval()

    let embed = new discord.MessageEmbed();
    if (color) embed.setColor(color.hexColor);
        embed.addField("Premium Added", `${UserID.tag} \`${UserID.id}\``);
    
    let premiumadd = new discord.MessageEmbed();
      premiumadd.setTitle('Premium Added');
      premiumadd.setDescription(
        `**User ID:** ${UserID.id}\n**User Name:** ${UserID.tag}\n**User Created:** \`${bot.users.cache.get(UserID.id).createdAt.toUTCString().substr(0, 16)}\``
      );
      premiumadd.setThumbnail(UserID.displayAvatarURL({dynamic:true}));
      premiumadd.setTimestamp();
      premiumadd.setColor('#2ACC76');
      premiumadd.setFooter(`Command Run By: ${message.author.tag}`);

bot.shard.broadcastEval(`
const channel = this.channels.cache.get('679079839466127390');

if (channel) {
channel.send('${JSON.stringify(premiumadd)}');
true;

} else {
false;

} `) .then(sentArray => {
if (!sentArray.includes(true)) {
return message.reply('I could not find such a channel!');
}

return message.channel.send(embed);
});
#

This worked successfully

#

It it possible to get it as an embed?

quartz kindle
#

.send({embed:${JSON.stringify(...)}})

royal portal
#

is there a way

#

to return if member is banned

pine bear
#

No

quartz kindle
#

@pine bear i told you to remove that extra client.commands.get(args[0]) since you already have it. no need for duplicate code

#

other than that it should work

#

@royal portal return from where?

royal portal
#

so if user is banned

#

then

#

return

quartz kindle
#

from where?

#

message? memberAdd?

royal portal
#

message

quartz kindle
#

if the user is banned from the same guild where the message is coming from, the user cant be banned, else he wouldnt be able to send the message there

queen needle
#

Is it possible to store data in discord.js without a database

royal portal
#

well

quartz kindle
#

is your code still the same as yesterday?

queen needle
#

i know you can use json files but is that better then trying to set up the database

royal portal
#

i have an unban command and if you unban someone then it sends a thing to a logs channel saying who unbanned the user and the reason but you can unban the user multiple times and it sends the embed even though the user is already unbanned

hot moat
#

e I was editing my main script and it refused to save the file (i host it on a vps), i checked the file on the vps and it was blank

royal portal
#

not sure how to make it so if the user is already unbanned then dont send embed and dont try to unban user

quartz kindle
#

is your code still the same as yesterday?

pine bear
#

How does it still not work? that is so strange.

royal portal
#

yes

quartz kindle
#

does your console log any error when you unban someone who is not banned?

pine bear
#

oh, that was about the command handler.

royal portal
#

yes

#

unknown ban

quartz kindle
#

@queen needle without any external saving form, any data saved inside the process, in variables objects arrays etc.. will be lost when the process restarts/crashes

#

@royal portal then you need to handle the error correctly

#

i believe i told you yesterday that you cant use try/catch like that

queen needle
#

so if i do json files i lose the data when i restart my bot

quartz kindle
#
try {
  await ....members.unban()
  ....send("done")
} catch(e) {
  ....send("not banned")
}

or

....members.unban().then(() => {
  ....send("done")
}).catch(() => {
  ....send("not banned")
})```
#

@royal portal

#

@queen needle no, json files are stored in files, not in the process, so they are not lost

finite bough
#

if we are talking about changing channel names how often can they be changes without abusing discord api

quartz kindle
#

idk the exact limit, but i wouldnt change them more than once a minute

red hollow
#

ok so im so bad in math so im asking
how can i get % in js?
like what % is 1 of 10 to get output 10%

quartz kindle
#

n * 100 / %

red hollow
#

ty

quartz kindle
#

actually better to do % = % * N / 100

#

actually thats for getting the % value, not the % %

#

now im confused lmao

#

i need sleep

pine bear
#

this would be right?

client.on("message", message => {
    let args = message.content.substring(prefix.length).split(" ");
    let command = client.commands.get(args[0])

    if(command)command.execute(message, args)
    

    /* get(args[0]) => {
        client.commands.get(adora).execute(args);
    }; */
}); 
quartz kindle
#

should work

pine bear
#

with this?

client.commands = new Discord.Collection();
client.aliases = new Discord.Collection();

const commandFiles = fs.readdirSync('./commands/').filter(file => file.endsWith('.js'));
for(const file of commandFiles){
    const command = require(`./commands/${file}`);

    client.commands.set(command.name, command)
}
quartz kindle
#

yes

#

you can delete aliases since you're not using them

pine bear
#

I'll just ignore it for now.

#

ok lets see if this works

quartz kindle
#

put console.log(client.commands) somewhere in your code (after the command loader)

#

and show what comes up in your console

pine bear
quartz kindle
#

now add console.log(args)

#

what is your prefix?

finite bough
#

@quartz kindle and if I put it inside a member add thingy and suppose 5 people joined in 1 min surprisingly so its api abuse?

quartz kindle
#

also, that code allows all prefixes if they have the same length

pine bear
#

c!, but it's a "ping" command

quartz kindle
#

so your command should work if you do c!adora

pine bear
quartz kindle
#

but it will also work if you do 12adora or abadora or $%adora

#

your code is checking for any 2-letter prefix

pine bear
#

Hm,

#

oh now it works

quartz kindle
#

add this if(!message.content.startsWith(prefix)) return

#

before the let args = line

#

that will make it only work with !c prefix instead of any 2-letter prefix

#

@finite bough i suppose thats fine

finite bough
#

oki

pine bear
#

how to make it work without the prefix?

quartz kindle
#

remove the line i told you to add, and remove the .substring() part from args

pine bear
#

ok now it works.

wide ridge
#

My bot just went offline randomly and I have no output on my console that indicates why it went down. I just recently started using shardingManager, could it be that my shards somehow went down and didn't re-spawn? I have 2 shards atm.

I got my bot back online by simply restarting, but I would like to know if there's any ways to prevent this from happening?

earnest phoenix
#

toMute.addRole(role); says its not an function

#

@earnest phoenix what's toMute as defined as?

#

let toMute = msg.mentions.members.cache.first() || msg.guild.members.cache.get(args[0]);

quartz kindle
#

try logging shard events ie manager.on("shardCreate", shard => { shard.on("disconnect",console.log) }) (v12)

earnest phoenix
#

@earnest phoenix
toMute.roles.add(role)

#

ohhhh

#

oof

#

i forgot about that

#

thx

#

Lol np

quartz kindle
#

there is no cache in mentions

earnest phoenix
#

@earnest phoenix also if it doesn't work...
Try changing the:
let toMute = message.mentions.users.first() || message.guild.members.cache.get(args[0]);
To
let toMute = message.guild.member(message.mentions.users.first()) || message.guild.member(message.guild.members.cache.get(args[0]);

#

i am running 12

#

Hmm did it work? @earnest phoenix

#

yeh

#

Nice

quartz kindle
#

@earnest phoenix half of that is redundant lol

earnest phoenix
#

tim is your entire existance

#

in this one channel

#

Lol

quartz kindle
#

yes i am a sad creature

earnest phoenix
#

you are simultaniously like the most active person on this discord but the least ha

#

someone here have the bot developer badge?

quartz kindle
#

what badge?

earnest phoenix
#

@quartz kindle the badge you get after you get Verified on the discord developer verification program...

copper cradle
#

you can apply tim

#

actually

#

you HAVE TO apply

quartz kindle
#

i have until october to do it

#

no rush

copper cradle
#

lol

earnest phoenix
#

Yea if your bot is in 75 or more guilds then it's necessary...

muted ridge
#

is there a way to fetch messages in v12?

earnest phoenix
#

How do I check for the API ping of Discord? I am on djs v12

lyric mountain
#

Docs?

earnest phoenix
#

I canโ€™t find it

crimson vapor
#

its

#

client.ws.ping

earnest phoenix
#

thanks

muted ridge
#

found it, channel.messages.fetch

lyric mountain
#

๐Ÿ‘

pine bear
#

I want my bot to send multiple responses to a "ping" command, how do I do that?

crimson vapor
#

why many responses?

#

also, you just dont return

pine bear
#

yes.

#

well more than one

#

maybe at least 2

tired nimbus
#

I forgot about sqlite

#

sql.run(DELETE FROM giveawaymess WHERE points > 0;).run()

#

would this be right

#

for the comparison

slate pilot
#

can i ask here for ejs ?

crimson vapor
#

if ejs is eris then yes

slate pilot
#

EJS -- Embedded JavaScript templates

pine bear
#

how would I be able to test this?

client.on('guildMemberAdd', member => {
    const guild = config.guild;
    const welcomeChannel = member.guild.channels.get('660593478807322634');
    welcomeChannel.send(`<@${member.user.id}>`);
    const embed = new Discord.RichEmbed()

    .setColor(0x00A2E8)
    .setTitle("Welcome, " + `${member.user.tag}`)
    .setDescription("Feel free the stay for awhile! We are honored to have you here. We offer many things here")
    .addField("**NOTE:** you have to verify yourself in [#657412989011492915](/guild/264445053596991498/channel/657412989011492915/)")
    .addField("come here [#660717524639547413](/guild/264445053596991498/channel/660717524639547413/) to tell us your love about She-ra!")
    
    welcomeChannel.send({embed});
});
sudden geyser
#

Use client.emit

#

By the way, you can combine those two .send methods into one.

pine bear
#

oh I noticed that XD

#

would it be client.emit(guildMemberAdd)?

sudden geyser
copper cradle
#

client.emit('guildMemberAdd', ... args);

pine bear
#

it's saying guild is not defined.

mortal lynx
#

Hell mera member count bot offline hai

#

To Kya kru

pine bear
#

this ain't a bot support server.

earnest phoenix
#

@mortal lynx this server is not meant for a specific bot support...

mortal lynx
#

@earnest phoenix then this server which for support

pine bear
#
const welcomeChannel = member.guild.channels.get('660593478807322634');
                              ^
``` it's saying that the guild is not defined.
#

bot dev

earnest phoenix
#

@mortal lynx for bot building... Testing and getting approved and declined...

copper cradle
#

@pine bear how did you emit the event

#

ofc you gotta pass in everything that djs passes by default duhh

#

if you only passed a string or an object with random props then that's what you'll get

mortal lynx
#

To hamara bot kyu nahi Kam kr raha hai kab online aayega

pine bear
#
client.on("message", message => {
    if (message.author.bot) return;
    if (message.content.indexOf(config.prefix) !== 0) return;
   
    const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
    const command = args.shift().toLowerCase();
   
    if(command === 'add') {
        client.emit('guildMemberAdd', ... args);
    }
  });
copper cradle
#

@mortal lynx wrong server, and wrong channel

#

@pine bear ...

#

learn the basics of js

#

what I said was an example

mortal lynx
#

Please help me

copper cradle
#

if you pass in args it'll pass an array

mortal lynx
#

Guys

copper cradle
#

and that array doesn't have any property that you need duh

#

@mortal lynx this is the wrong server

#

this isn't a support server

mortal lynx
#

@copper cradle Hello ham Apne server pr member count bot add kiye the pr Kam hi Nahi kr raha

copper cradle
#

are you blind? I don't speak that language, and this ISN'T (IS NOT) [NOT === NEGATION === NO] a support server

earnest phoenix
#

@copper cradle do you know what he is saying?
Kinda looks like enchantment table...

copper cradle
#

no

#

idk what that lang is

earnest phoenix
#

Me either

copper cradle
#

looks like an english creole of some sort

mortal lynx
#

Aur m!setup bhi likhe pr hamre server ka member count hi Nahi kr raha hai Kya kru

earnest phoenix
#

@copper cradle it's hindi lmao

mortal lynx
#

@copper cradle this is Hindi language

copper cradle
#

I don't speak hindi language

#

and I'm NOT going to translate

mortal lynx
#

@copper cradle please help me

copper cradle
#

this server isn't a support server, we don't provide help for any bot

#

I can't help you

mortal lynx
#

Please

bitter sundial
copper cradle
#

this is the WRONG server @mortal lynx

mortal lynx
#

I know but help me guys

copper cradle
#

we can't help you holy cow

bitter sundial
#

-wrongserver

gilded plankBOT
#

Hey! We think you have our server mistaken. We do not provide support, help, or advice for any bot. You need to click on the "Support Server" button on the bot's page, not the "Join Discord" button at the top of our website. If there isn't a button that says Join Support Server, then we can't help you. Sorry :(

hexed moat
earnest phoenix
#

my bot didnt respond on everything -.-

#

@hexed moat with bitwise operations

#

check out permissions on the docs

#

they work on the same principle

hexed moat
#

ok thanks

raven urchin
earnest phoenix
#

titles can't lead to links

#

authors can

pale vessel
#

they can

#

using setURL()

raven urchin
#

Ohhh

#

For .setAuthor do I do .setAuthor(Memes)?

tight plinth
#

with ''

raven urchin
#

Alright

tight plinth
raven urchin
#

I kinda wanted like where it'll show the hyperlink as the title

#

allowed[randomnumber].data.title

high bough
slender thistle
#

It's in a string

#

And in an embed, either description or field value

tight plinth
#

^

#

u r dumb

high bough
#

Yeah T.T

#

Cuz IT DIDN'T WORK

tight plinth
#

``

#

u forgot

high bough
#

OWH, right...

cinder patio
#

Also

#

${clientname} is unnecessary if your variable is already a string, just use clientname

earnest phoenix
tight plinth
#

where

slender thistle
#

typeof Infinity returns number

twilit rapids
#

What

finite bough
#

infinity is in js yes

twilit rapids
#

typeof <x> returns whatever <x> is

finite bough
#

yea

#

wait

#

hmm

#

string

earnest phoenix
#

is it bc of discord js 12

#

idk

#

i have been breaking my head on that for days now

finite bough
#

use 11v like me

#

^

earnest phoenix
#

ok but i have no idea no how to use it

finite bough
#

I capital or wont work

#

what u trying to do

#

ah ok

earnest phoenix
#

cache

finite bough
#

cache

#

channels.cache.get

earnest phoenix
#

its discord 12

finite bough
#

class shift

#

some functions moved to a different class

earnest phoenix
#

ye

lime jewel
earnest phoenix
#

yep

#

anything that is related to storing and getting stuff is cache

finite bough
#

@lime jewel wdym

lime jewel
#

What?

finite bough
#

what?

earnest phoenix
#

why not use n database

#

or if its temporary use json

finite bough
lime jewel
#

Its temporary

#

Play Command

finite bough
#

use json then

#

or make a new collection

#

ur wish

lime jewel
#

Ok I'll try

twin iron
#

-bots

gilded plankBOT
tight plinth
#

read docs smh

twin iron
#

it's been 2 weeks i wait notlikenoot

tight plinth
twin iron
#

ah sorry xd

tight plinth
#

3/29/2020

#

๐Ÿ‘€

#

@woven sundial MessageEmbed

queen needle
#
const Discord = require('discord.js');
const bot = new Discord.Client();


client.on("message", message => {
    if(message.content.startsWith("*hi")){
        message.channel.send("hey");
    }
})```
#

when i run it it says client isn't defined

twin iron
#

cause isnt

finite bough
#

use not

#

bot

tight plinth
#

u never defined it

twin iron
#

do bot.on

#

bot is your client

tight plinth
#

^

finite bough
#

^

tight plinth
#

but I suggest you using client instead of bot

twin iron
#

yeah its more instinctive

tight plinth
#

coz every docs uses client

finite bough
#

I use doge.on

#

XD

queen needle
#

thanks

#

i've been having a lot of dumb mistakes like that

twin iron
#

it's normal for beginner

queen needle
#

the video im following got the same eror

#

error

#

thankfully

finite bough
#

._.

queen needle
#

what

tight plinth
#

video tutorial = never

queen needle
#

what'

slender thistle
#

thankfully
thankfully????????

hollow token
#

I have some error with heroku

#

my bot keep crashing

#

the error is this one

#

heroku[web.1]: State changed from starting to crashed

queen needle
#

so far so good i can log stuff into my json files

balmy knoll
#

Hi, can someone help me with discord.py, I don't know this language very well, I'm at the beginning

#

How can I change a user's nickname by adding something else (eg "Test") to his current nickname?

#

For example in my case: Simo >> Simo Test

slender thistle
#

member.nick + ' stuff'

#

Please keep in mind that .member.nick can be None

golden condor
#

@slender thistle is there no .displayName ?

slender thistle
#

member.display_name

golden condor
#

That would work no?

slender thistle
#

Would but it might not be what they need

golden condor
#

So it's their nick / their name

#

Seems like it could work but idk

#

His status says js dev

balmy knoll
#

In this case?

slender thistle
#

member.edit :p

balmy knoll
#

What is the string to insert that allows me to change his nickname

slender thistle
#

member being ctx.author I would assume

tight plinth
balmy knoll
#

In this case, I want to add after his nick content

slender thistle
#

User:
!powerlevel 5

Bot:
changes nickname from User to User 5

#

Is that what you want?

balmy knoll
#

Yes

#

It is the one in summary with a bit of formatting or

User:
!powerlevel 5

Bot:
changes nickname from User to User [โšก 5]

#

Thanks shivaco for your help

slender thistle
#

I'd suggest creating a dict somewhere where key is the level and value is the string you want to add to their nick

balmy knoll
#

I repeat is my first code that I make in discord.py, I don't know how

slender thistle
#

dictionaries are basic Python redShrug

#
levels = {'1': '[:hammer: 1]',
          '2': '[:hammer: 2]'}

async def powerlevel:

    await ctx.author.edit(nick=ctx.author.display_name + levels[content])``` a bit of pseudocode for you
balmy knoll
#

I try

nocturne grove
#

Our bot doesn't want to make an embed. It says TypeError: Discord.RichEmbed is not a constructor. We already changed the discord.js version in package.json. What to do?

small plume
#

@nocturne grove Replace RichEmbed with MessageEmbed

golden condor
#

@nocturne grove npm i

nocturne grove
#

@small plume oh thank you!
@golden condor what do you mean?

golden condor
#

If you want to change the package version

nocturne grove
#

Is .RichEmbed old code?

golden condor
#

You have to reinstall

#

Yes

nocturne grove
#

ohh okay thx

summer torrent
#

RichEmbed renamed to MessageEmbed on v12

golden condor
#

In v12 it's MessageEmbed

#

Same stuff

#

But also extra

nocturne grove
#

and changing in package doesn't do anything?

golden condor
#

Unless you use glitch no

summer torrent
nocturne grove
#

okay thanks!

golden condor
#

You have to reinstall

#

Np

nocturne grove
#

We just installed discord.js so I guess that was the newest. But we're used to use RichEmbed

earnest phoenix
#

Do you know in HTML for help me ?

quartz kindle
#

if you prefer discord.js v11, you can install it like this npm install discord.js@11.6.4

elder vine
#

What do you need help with @earnest phoenix ?

earnest phoenix
#

My board don't show

#

See this ```<!DOCTYPE html>
<html lang="en">
<head>
<link rel="icon"
type="image/png"
href="https://cdn.glitch.com/98ebb41d-db5d-4d3a-ab38-83a53f1e0b58%2FCapture.PNG?v=1586428175937https://cdn.glitch.com/98ebb41d-db5d-4d3a-ab38-83a53f1e0b58%2FCapture.PNG?v=1586428443956">
<title>SoundBoard - TapsHTS</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

<!-- import the webpage's stylesheet -->
<link rel="stylesheet" href="/style.css">

<!-- import the webpage's javascript file -->
<script src="/script.js" defer></script>

</head>
<body>
<font size="5"><font face="Poppins">Si toi aussi tu veux utiliser mon soundboard avec les mรชmes bruit voici les sons au dessus</font></font>

<div class="divTable steelBlueCols"></div>
    <div class="divTableBody">
<div class="divTableRow">

<div class="divTableCell"><iframe width="110" height="200" src="https://www.myinstants.com/instant/popopoooooo-7896/embed/" frameborder="0" scrolling="no"></iframe></div>
<div class="divTableCell"><iframe width="110" height="200" src="https://www.myinstants.com/instant/cheh-23601/embed/" frameborder="0" scrolling="no"></iframe></div>
<div class="divTableCell">cell3_1</div>
<div class="divTableCell">cell4_1</div>
<div class="divTableCell">cell5_1</div>
<div class="divTableCell">cell6_1</div>
<div class="divTableCell">cell7_1</div>
<div class="divTableCell">cell8_1</div>
<div class="divTableCell">cell9_1</div>
<div class="divTableCell">cell10_1</div>
<div class="divTableCell">cell11_1</div>
<div class="divTableCell">cell12_1</div>
</div>
</div>

<!-- include the Glitch button to show what the webpage is about and
      to make it easier for folks to view source and remix -->

</body>
</html>


Web: https://soundboard-hts.glitch.me/
#

@elder vine

slender thistle
#

Why use div for tables

elder vine
#

ye

#

and not li

earnest phoenix
#

But i don't understand tables

elder vine
#

Anyways, what fo you mean?

#

What should it be like?

earnest phoenix
elder vine
#

Borders?

earnest phoenix
#

But i don't see the borders

#

yes

elder vine
#

Border would be css

earnest phoenix
#

yes i have

#

body {
  font-family: helvetica, arial, sans-serif;
  margin: 2em;
}

h1 {
  font-style: italic;
  color: #373fff;
}

div.steelBlueCols {
  border: 4px solid #555555;
  width: 400px;
  text-align: center;
  border-collapse: collapse;
}
.divTable.steelBlueCols .divTableCell, .divTable.steelBlueCols .divTableHead {
  border: 5px solid #000000;
  padding: 5px 10px;
}
.divTable.steelBlueCols .divTableBody .divTableCell {
  font-size: 12px;
  font-weight: bold;
  color: #000000;
}
.steelBlueCols .tableFootStyle {
  font-size: 13px;
}
/* DivTable.com */
.divTable{ display: table; }
.divTableRow { display: table-row; }
.divTableHeading { display: table-header-group;}
.divTableCell, .divTableHead { display: table-cell;}
.divTableHeading { display: table-header-group;}
.divTableFoot { display: table-footer-group;}
.divTableBody { display: table-row-group;}
#

@elder vine

#
const msg = await member.send(solvecaptchaembed, {
            files: [{```
#

tried to send an embed but it sent [object object]

quartz kindle
#

the send function actually looks like this: .send(message) or .send(options) or .send(message,options)

#

embed is part of options

#

so if you put .send(a,b) embed should go in b, and a will become ONLY for text messages

#

if you do .send(options) embed should go inside options, together with all other options

#

so your send should look like this .send({embed:captchaembed,files:[...]})

earnest phoenix
#

i used it but the embed is being sent after the file

quartz kindle
#

theres nothing you can do about that, discord decides the order

#

if you want the embed first, you needs to send 2 messages

earnest phoenix
#

can i use .then or somthing

quartz kindle
#

yes, or await

#

await send(embed)
await send({files:[...]})

earnest phoenix
#

I tried and it worked

const msg = await member.send(solvecaptchaembed).then (await member.send({
            files: [{
                attachment: `${__dirname}/captchas/${captcha}.png`,
                name: `${captcha}.png`
            }]
        }));```
#

First the captchaembed, then the captcha itself
Thanks Tim!

quartz kindle
#

you dont need to use .then

#

await does the same thing

earnest phoenix
#

how can i change it then ?

#

just await?

quartz kindle
#

like i said

#

await send(embed)
await send(files)

#

the await does the same thing as the .then() at the end

earnest phoenix
#

Does it really matter ?

#

It's working

quartz kindle
#

its redundant

#

its like doing Number(1) when 1 is already a number

#

or "abc".toString()

earnest phoenix
#

I'm really bad at doing this

#

Or i just don't understand

quartz kindle
#

i mean

#

you literally just do

earnest phoenix
#

Oh got it

#

I removed the .then

#

That's it

quartz kindle
#
await member.send(solvecaptchaembed)
await member.send({
            files: [{
                attachment: `${__dirname}/captchas/${captcha}.png`,
                name: `${captcha}.png`
            }]
        }));
``` lol
earnest phoenix
#

oh ok

#

thanks

#
const msg = await member.send(solvecaptchaembed)
        await member.send({
            files: [{
                attachment: `${__dirname}/captchas/${captcha}.png`,
                name: `${captcha}.png`
            }]
        });```
#

msg.mentions.members.cache.first() it says cant not read first

quartz kindle
#

there is no cache in mentions

summer torrent
#

^

earnest phoenix
#

k

true ravine
#

My bot has a training programme for recruiting staff so I have to send text one paragraph after another (await reactions inbetween) although for some users it doesn't send them all the text and for some it does

#

Any ideas what could be causing that?

marble juniper
#

I assume those are dm messages? @true ravine

true ravine
#

Yeah they are

marble juniper
#

maybe the users have dms disabled

true ravine
#

But it will send maybe the first three and then not the rest

#

Only for some users

#

Other users get everything fine

marble juniper
#

then idk

quartz kindle
#

show code?

true ravine
#

I've even put it in a try catch and even when it doesn't show all the text the catch is never fired

#

(and I know the code is weird)

queen needle
#

is it possible to put serprate the data in my json file by lines

#

{"id":{"coins":"10"}

#

thats how the data works it writes next to each other is there a way i can make them on a new line

#

and thats what enters it

quartz kindle
#

@true ravine what is steps? i assume i is 0 and the rest are empty arrays?

true ravine
#

Steps is an array of the things to be sent

#

Just an array of strings

quartz kindle
#

you should check for the existance of a step before attempting to send them

slender thistle
queen needle
#

will that work with ks?

#

js?

true ravine
#

The steps are defined right above that so they should always exist Tim ^

quartz kindle
#

@queen needle you can pretty print an object in js using JSON.stringify

slender thistle
#

Why did I assume you were using Python...

queen needle
#
client.on("message", (message) => {
  if (!coins[message.author.id]) {
    coins[message.author.id] = {
      coins: 0,
    };
  }

  let coinAmt = Math.floor(Math.random() * 15) + 1;
  let baseAmt = Math.floor(Math.random() * 15) + 1;

  if (coinAmt === baseAmt) {
    coins[message.author.id] = {
      coins: coins[message.author.id].coins + coinAmt 
    };

    fs.appendFile("./coins.json", JSON.stringify(coins), (err) => {
      if (err) console.error(err);
    });
  }
});```
#

thats my code i tried like + \n but it didnt work

quartz kindle
#

you cannot append json

#

it will break the json structure

queen needle
#

so i can't separate into line

#

lines

quartz kindle
#

not with append

#

because look

#
{
  "a":10,
  "b":20
}``` this is how json looks like
queen needle
#

my data doesnt enter in between the {}

quartz kindle
#

if you want to add c it will look like this js { "a":10, "b":20, "c":30 }

#

however, if you use append file

#

it ends like this js { "a":10, "b":20 } { "c":30 }

#

which is invalid json

#

and will destroy your data

earnest phoenix
#

i can check this error code to see if it is true then what would happen? UnhandledPromiseRejectionWarning: Error: Not found

queen needle
#

{

#
{
}```
#

if i do that my data enters after the bracket

#
{

}(then my data shows uo here)```
quartz kindle
#

exactly

#

and that destroys the data

queen needle
#

but my data shows up like that normally

quartz kindle
#

because the file becomes invalid and will give you an error whenever you try to read it

#

you cannot use appendfile and json files, it simply doesnt work

queen needle
#

yeah

quartz kindle
#

they are not compatible

earnest phoenix
#

How do i get client.guilds.size on discord.js v12?

quartz kindle
#

client.guilds.cache.size

queen needle
#

but is it possible to get my data to show up in the right place and be on different lines

#
{
}{"id1":{"coins":"10"},{"id2":{"coins":"18"}```
#

thars what it looks like in my json file rn

quartz kindle
#

not with appendfile

queen needle
#

im not using appedfile

#

oh wait nvm

#

i understand what your saying

quartz kindle
queen needle
#

yeah would i use write

quartz kindle
#

the json structure is very strict, the only way to update a json file is like this

#
  1. read the ENTIRE file
  2. make the changes in memory
  3. save the ENTIRE file
#

which is why json is very bad for saving dynamic data, or things that get updated often

earnest phoenix
#

I can check this error code? if tag error code which I want to check UnhandledPromiseRejectionWarning: Error: Not found

quartz kindle
#

what code?

earnest phoenix
#
osuApi.getUser({ u: args[0] }).then(user => {

    let play_time = `${Math.round(Number(user.secondsPlayed) / 3600)}h`;
     play_time += ` ${Math.round(Number(user.secondsPlayed) % 3600 / 60)}m`;

     let grades = "";

            grades += `XH ${Number(user.counts.SSH).toLocaleString()}โ€`;
            grades += `X ${Number(user.counts.SS).toLocaleString()}โ€`;
            grades += `SH ${Number(user.counts.SH).toLocaleString()}โ€`;
            grades += `S ${Number(user.counts.S).toLocaleString()}โ€`;
            grades += `A ${Number(user.counts.A).toLocaleString()}`;


    let osu = new Discord.MessageEmbed()
    .setColor('#30acff')
    .setAuthor(`${user.name} - ${+Number(user.pp.raw).toFixed(2)}pp (#${Number(user.pp.rank).toLocaleString()}) (${user.country}#${Number(user.pp.countryRank).toLocaleString()})`, `http://s.ppy.sh/a/${user.id}`)
    .setThumbnail(`http://s.ppy.sh/a/${user.id}`)
    .setDescription(`**[Profile](http://osu.ppy.sh/u/${user.id})**`)
    .addField(`Ranked Score`, `${Number(user.scores.ranked).toLocaleString()}`, true)
    .addField(`Total Score`, `${Number(user.scores.total).toLocaleString()}`, true)
    .addField(`Play Count`, `${Number(user.counts.plays).toLocaleString()}`, true)
    .addField(`Play Time`, `${play_time}`, true)
    .addField(`Level`, `${+Number(user.level).toFixed(2).toString()}`, true)
    .addField(`Hit Accuracy`, `${Number(user.accuracy).toFixed(2)}%`, true)
    .addField(`Grades`, `${grades}`, true)
    .setFooter(`Playing for ${moment(user.raw_joinDate).fromNow(true)} | Joined on ${moment(user.raw_joinDate).format('D MMMM YYYY')}`)

    message.channel.send({embed: osu})
});```
quartz kindle
#

osuApi.getUser().then().catch()

#

add a catch at the end

queen needle
#

so how would i be able to save it so it works

earnest phoenix
#

how?

quartz kindle
#

@queen needle fs.writeFile or fs.writeFileSync

queen needle
#

is there a difference?

earnest phoenix
#

THANKS

#

tim

#

๐Ÿ˜‰

#

๐Ÿ˜—

marble juniper
#

I have a daily command and a working cooldown but I want to be able to tell the user the remaining time in minutes seconds and hours

#

and idk how to do that

#
const time = 60000
    function delay() {
        setTimeout(() => {
            commandCooldown.delete(message.author.id);
            message.author.send(`You can now use daily again! `+client.emoji.ring)
        }, time);
    }

    if(commandCooldown.has(message.author.id)) {
        const minute = 60000 * 8
        const hour = minute * 24

        message.channel.send(`you need to wait **${Math.round((commandCooldown.get(message.author.id) - Date.now())/minute)} minutes** and **${Math.round((commandCooldown.get(message.author.id) - Date.now())/hour)} hours** untill you can use daily again`)
    }
#

this is what I have rn

#

but it doesn't work

queen needle
#

i would suggest looking into ms

#

so for my mute command i have this javascript `@${person.user.tag} has now been muted for ${ms(ms(time))}

#

and it tells them how long they are muted for using ms

quartz kindle
#

@marble juniper any reason for 60000 * 8?

marble juniper
#

I was just testing

#

and maybe at the wrong place

#

lol

#

I didn't even notice

quartz kindle
#

does commandCooldown.get() return the time remaining in milliseconds?

marble juniper
#

when I set the cooldown for the user I do this

#
commandCooldown.set(message.author.id, Date.now())
quartz kindle
#

ah ok

marble juniper
#

but rn I just get 0

#

0 minutes

#

even though the cooldown is at 2 minutes

#

so technically it should show me 1

quartz kindle
#

how big is the cooldown?

marble juniper
#

thats the cooldown time

quartz kindle
#

ok

#

so commandCooldown.get(id) + time - Date.now() would be the time remaining

marble juniper
#

hmm ok

#

yeah it works

#

it shows me 2 minutes

quartz kindle
#
let remaining = commandCooldown.get(id) + time - Date.now();
let seconds = remaining / 1000;
let minutes = seconds / 60;
marble juniper
#

yeah oke