#development

1 messages ยท Page 1178 of 1

opal plank
#
You have not provided enough information!
Which programming language do you use?
Which Library are you using?
If its an error, send the error here
What exactly is the expected output?
Have you read the docs regarding that specific matter?
#

this should cover 90% of stuff

misty sigil
#

ty not erwin i shall use this

opal plank
#

shame bots cant reply here

#

lemme add a tag for that

#

there we go

exotic cradle
#

Anyone know a source where I can find code to set the bots "Playing" text?

#

I'm not asking for direct code, just a source.

zenith terrace
#

The status?

exotic cradle
#

yes

misty sigil
#

@exotic cradle what lib

exotic cradle
#

...

#

uh

opal plank
exotic cradle
#

discord.js...?

misty sigil
#

read this

exotic cradle
#

oh ok

opal plank
#

fucker had it on paste beforehand

exotic cradle
#

thanks

opal plank
#

wtf @misty sigil lol

misty sigil
#

nah

#

i had it on paste because i just assume everyone uses d.js

opal plank
#

true that, man of culture

exotic cradle
#

wow

zenith terrace
#

User: Asks how to set activity
Leuca: Sends that link

exotic cradle
#

btw can i use free heroku hosting forever or do i have to switch if my bot gets big enough?

misty sigil
#

you have to use a vps

#

if it gets too big

exotic cradle
#

ok

misty sigil
#

because heroku will literally die if you host a 100+ server bot on it LUL

exotic cradle
#

// Set the client user's activity
client.user.setActivity('discord.js', { type: 'WATCHING' })
.then(presence => console.log(Activity set to ${presence.activities[0].name}))
.catch(console.error);
that was the code I used

fluid basin
#

wrap it in code blocks oh gosh

paper cliff
#

^

#

Yes

#

The code has to be in "ready" event

misty sigil
#

client isnt defined then

paper cliff
#

client.user is not defined until the "ready" event

exotic cradle
#

oh

misty sigil
#

aH YES

dreamy thistle
#

How do I know how many guilds my bot is in?

paper cliff
#

<Client>.guilds.cache.size

misty sigil
#

@dreamy thistle <client>.guilds.cache.size

dreamy thistle
#

: o ty

paper cliff
#

CTRL+F for your everyday questions

dreamy thistle
#

ah

#

true

#

ty

exotic cradle
#

Would this work?
client.user.setStatus('dnd', 'Made by KwinkyWolf')

#

or in my case
client.user.setStatus('online', 'Made by De'Toxanoche')

fluid basin
#

escape that quote

#

make sure you only modify the status after the ready event is called

exotic cradle
misty sigil
#

is it in client.on(ready, () => {})

exotic cradle
#

no

misty sigil
#

well it needs to be

fluid basin
exotic cradle
#

oh

opal plank
#

omg

#

kill it

#

use a command handler, or a switch at least

exotic cradle
opal plank
#

if()
if()
if()
if()

#

bad

#

also thats message event

#

unrelated to what was suggested

#

you want ready event

#

highly recommend doing a command handler already

exotic cradle
#

breh

opal plank
exotic cradle
#

ok my bot lived

#

nic

#

๐Ÿ‘Œ wearyblurry ๐Ÿ‘Œ

paper cliff
#

highly recommend reading the guide already

exotic cradle
#

It says bot is not defined tho

opal plank
#

then define it

exotic cradle
#

when i try bot.on

opal plank
exotic cradle
#

HOw

#

AAAAAAA

opal plank
#

learn JS

paper cliff
#

What even is JS

#

imagine starring that

delicate shore
fluid basin
#

@delicate shore lol

delicate shore
#

if i want to

paper cliff
#

no

#

don't

exotic cradle
#

star

opal plank
#

imagine coding a bot without knowing your own programming language

delicate shore
#

I did it

paper cliff
#

...

fluid basin
#

imagine coding erwin

delicate shore
#

Imagine Imagining

opal plank
#

imagine imagining

#

fuck

paper cliff
#

image.png

fluid basin
#

lol got starred anyways

paper cliff
#

what a useless star

opal plank
#

anyway @paper cliff JS is javascript, the language you coding with

delicate shore
#

bru

exotic cradle
#

learn JS
@opal plank thats like saying: learn to fly a plane

opal plank
#

you trying to write a russian essay without knowing russian

delicate shore
#

ok

paper cliff
#

omg

#

imagine taking it seriously

delicate shore
#

imagine imagining

drowsy sentinel
#

Stay on channel topic please.

exotic cradle
#

HEYHEYHEYHEY

#

somewhere in siberia russia a long long time ago

#

he was big and strog and his eyes were flamey glow

paper cliff
#

@exotic cradle And by the way, may be you named it client instead of bot

opal plank
#

you can name your variables whatever you want tbh, as long as you use them accordingly its fine

#

it can be TheBestBotInTheWorld = new Client()

exotic cradle
#

most people loook at him, with terror and the fear

#

but to moscow chicks he was a such a lovely dear

drowsy sentinel
#

@delicate shore @exotic cradle Star any random messages or abuse starring and you will be muted.

delicate shore
#

oh sorry

exotic cradle
#

(stars)

earnest phoenix
#
module.exports = async function format(content, guildName, botId) {
    let newContent = await content.split("{user}").join(`<@!${botId}>`).split("{user_name}").join("Bot Cool").split("{server}").join(guildName);
    return newContent;
}

why it return nothing

(node:7188) UnhandledPromiseRejectionWarning: DiscordAPIError: Cannot send an empty message
fluid basin
#

what

#

I can't even understand what you're trying to do

sudden geyser
#

Show us where you try to sending a message with the result of that function

earnest phoenix
#

in a Channel

sudden geyser
#

also you don't need to await content.split because it doesn't return a promise

earnest phoenix
#

:0

fluid basin
#

instead of split/join did you mean to use replace lmao

opal plank
#

why u awaiting it?

sudden geyser
#

To some? Probably. To everyone? Probably not.

opal plank
earnest phoenix
#

wait imma try replace

#

still emty msg

#

:((

delicate shore
#

:(

earnest phoenix
#

help meeeee

opal plank
#

dafuck you even doing dude

sonic lodge
#

why do you need to await string manipulation

paper cliff
#

You don't

sonic lodge
#

geniuses think alike

paper cliff
#

using .split().join() is not the way to go

#

use .replace?

opal plank
#

indeed

#

this snippet is wrong in so many levels

earnest phoenix
#

@opal plank i removed

#

bro

#

relax

#

i am not dumb

#

use .replace?
@paper cliff USED

opal plank
#

export rather than module.exports
dont await manipulation
replace
async function

paper cliff
#

module.exports is fine. And yes obviously it doesn't need to be an async function anymore

opal plank
#

you exporting a named function, should be using an export statement, otherwise if you only going to have 1 function, use an unnamed function statement

#

if its only one, no need to name it. if its named, it implies you'll have multiple functions

#

which is best to use export es6

sonic lodge
#

and if the resulting message is empty, that probably means the input is empty

spare gale
#

guys

#

stupid question

#

but

earnest phoenix
#

k

opal plank
#
module.exports = (test) => {console.log(test)}


function a() {
return 'a';
}

function b() {
return 'b';
}

export a , b

import a , b from 'something'

spare gale
#

how to get channel object by id in node?

paper cliff
#

client.channels.cache.get?

earnest phoenix
#

:0

#

nc it works

#

:))

paper cliff
#

No @opal plank wtf? Using exports is perfectly fine

opal plank
#

dealing with exporting named stuff is better with export rather than modules

paper cliff
#

You can export named stuff the same way

#

exports.namedStuff

#

that's it.

opal plank
sudden geyser
#
const a = () => "a"
const b = () => "b"

modul.exports = { a, b }```
paper cliff
#

^

#

???

#

Using exports is fine

#

I know the differences

opal plank
#

what you're doing is simply objectifying those functions

#

not exporting them

#

works too? yeah

#

also aliases

#

forgot to mention that

sudden geyser
#

Using both module.exports and export are fine imo. You aren't losing much from using the standard module.exports

opal plank
#

indeed both work, never said it wouldnt, its just better to use exports when dealing with named stuff

sterile thicket
#

So, I used the on collect event for reaction collector, and run the command in two different server, and it messing up the result.

#

hastebin is not working in opera gx, so sent you the .txt

jade drum
#

.

slender wagon
#

-dotpost

sterile thicket
#
                            (reaction, user) => Object.values(reactionControls).includes(reaction.emoji.name),
                            { time: time, dispose: true }
                        );
                        collector.on('collect', (reaction) => {
                            switch (reaction.emoji.name) {
                                case reactionControls.UP:
                                    thumbsUp = reaction.count-1;
                                case reactionControls.DN:
                                    thumbsDwn = reaction.count-1;
                                break;
                            }
                        })```
what's wrong here?
sudden geyser
#

What's not working about it?

earnest phoenix
#

help meh

sterile thicket
#

it doesn't count the correct reaction

cinder sandal
#

i have an error installing lubuntu:
Command 'mount' return ed non-zero exit status 32.

i don't know if this is about developement but i think this is a bug in the os
@cinder sandal e still unanswered

potent grove
sterile thicket
#

@earnest phoenix did you use eval(code)?
on the output?

earnest phoenix
#

/eval message.guild.roles.cache.get("545490362568015873")

sterile thicket
#

on the output

earnest phoenix
#

wdym ?

zenith terrace
#

Did you copy an actual role id

earnest phoenix
#

yes

#

OH

#

i copied my id

#

not the role

#

xD

sterile thicket
#

what am I doing wrong? It doesn't count the results

const collector = msg.createReactionCollector(
                            (reaction, user) => Object.values(reactionControls).includes(reaction.emoji.name),
                            { time: time, dispose: true }
                        );
                        collector.on('collect', (reaction) => {
                            switch (reaction.emoji.name) {
                                case reactionControls.UP:
                                    thumbsUp = reaction.count-1;
                                case reactionControls.DN:
                                    thumbsDwn = reaction.count-1;
                                break;
                            }
                        })```
cinder patio
#

what happens? Do thumbsUp and thumbsDwn stay at 0?

sterile thicket
#

1

#

0 when I don't vote, 1 when I vote only one of them

cinder patio
#

1 for both of them?

#

I am pretty sure you need to put break in all of your cases

sterile thicket
#

Oh yes... lol that was on problem

#

now another

#

if I request the same commands twice at the same time, I get same result on both messages

steel pelican
#

Can bots check ip adress

solemn latch
#

no

sterile thicket
#

no

steel pelican
#

Theres a bot bans me from server when i use vpn

#

._.

sterile thicket
#

@steel pelican that must be a game server?

steel pelican
#

Na a chat server

cinder patio
#

Sinedx, can you elaborate?

sterile thicket
#

did you use any of their websites?

solemn latch
#

or, is the vpn's ip banned from that discord?

#

๐Ÿค”

#

iirc, discord does ip bans(users cant see it)

steel pelican
#

@sterile thicket no only

#

A invite link and vpn

sterile thicket
#

Sinedx, can you elaborate?
@cinder patio I used the code for a poll command.
If I use one /poll, it's working fine.
but if I do /poll a and /poll b at the same time, then the results are getting messed up

fervent goblet
#

is there a way to prevent this from rounding to the nearest month?

moment(member.joinedAt, "YYYYMMDD").fromNow()
cinder patio
#

Sinedx, this shouldn't happen if all the code regarding the poll command is inside the function. If for example, you have some variables outside of the function that are used and changed in the poll function, things are gonna get messed up, yeah

sterile thicket
#

@cinder patio please take a look and help me

#

hastebin is not working

cinder patio
#

I'm assuming everything is inside the command function?

sterile thicket
#

ofc

#

of my knowledge

#

full code

#

There

#

@cinder patio

cinder patio
#

where do you define thumbsUp and thumbsDwn? They might get turned into global variables after the first use

sterile thicket
#

I didn't

#

wait

cinder patio
#

do let thumbsUp, thumbsDwn; at the beginning of the function that should solve the problem

#

Not sure if that's the issue, though

#

But it's best to define them before you use them

delicate zephyr
#

@glad charm kid trying to spam ads

sterile thicket
#

Not sure if that's the issue, though
@cinder patio Yep, that was the issue

#

Thanks

#

I thought if I don't define them, it will say "thumbsUp is undefined"

#

but then it worked

#

and I was like ok

#

let's go

cinder patio
#

Sometimes javascript can be weird

sterile thicket
#

true

#

I used awaitMessageReaction() earlier
but it didn't give me accurate reaction count

#

like if they spam the reaction button, it doesn't count them at all

cinder patio
#

I really don't know why that happens. I believe when you assign a variable name a value without any keywords it makes it global. It errors only when you access a variable that's not defined. It doesn't error when you assign it a value

sterile thicket
#

ig u'r right

teal fiber
#

I did a big dumb today

#

I accidently deleted all my bots files

#

and the recovery software can't get it

earnest phoenix
#

Oof

#

I did a big dumb today
@teal fiber you did a what

faint prism
#

I accidently deleted all my bots files
@teal fiber rip, next time use a source control manager like git-scm and upload the repo somewhere

earnest phoenix
#

version control you mean

faint prism
#

It means the same thing really. Git calls itself git-scm. TFS refers to itself as Team Foundation Version Control (TFVC)

#

Semantics, I suppose @earnest phoenix

teal fiber
#

it was a dumb mistake because i needed to reinstall the OS on the laptop i was hosting it on

faint prism
#

Yeah, bit rip. Upload repo to GitHub or azure devops or something next time

onyx summit
#

I want to run my bot in kubernetes (preferably easy to scale), can anyone link me resources that could help me (e.g. configuration files for the pods etc)

faint prism
#

Are you familiar with kubernetes or docker?

onyx summit
#

docker yes, but kubernetes not really. I'm just interested if there is public information for this or if I have to start from zero

earnest phoenix
#

What does that mean?

Error: Cannot find module 'discord.js'
Require stack:

  • C:\Users\User\Desktop\Giveaway Bot\server.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
    at Function.Module._load (internal/modules/cjs/loader.js:841:27)
    at Module.require (internal/modules/cjs/loader.js:1025:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (C:\Users\User\Desktop\Giveaway Bot\server.js:1:17)
    at Module._compile (internal/modules/cjs/loader.js:1137:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
    at Module.load (internal/modules/cjs/loader.js:985:32)
    at Function.Module._load (internal/modules/cjs/loader.js:878:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) {
    code: 'MODULE_NOT_FOUND',

My code: https://srcb.in/9e53b41fd3

cinder patio
#

you haven't installed discord.js

#

Do npm i discord.js

regal saddle
#

Seems like you didnt installed d.js before

earnest phoenix
#

I did! I typed npm install save --discord.js

regal saddle
#

oop, im late

cinder patio
#

Check if there is a discord.js folder inside the node-modules folder, or check your package.json file to confirm it's installed.

earnest phoenix
#

And then this is shown:

Error: Cannot find module 'moment-duration-format'
Require stack:

  • C:\Users\User\Desktop\Giveaway Bot\server.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
    at Function.Module._load (internal/modules/cjs/loader.js:841:27)
    at Module.require (internal/modules/cjs/loader.js:1025:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (C:\Users\User\Desktop\Giveaway Bot\server.js:8:9)
    at Module._compile (internal/modules/cjs/loader.js:1137:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
    at Module.load (internal/modules/cjs/loader.js:985:32)
    at Function.Module._load (internal/modules/cjs/loader.js:878:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) {
    code: 'MODULE_NOT_FOUND',
    requireStack: [ 'C:\Users\User\Desktop\Giveaway Bot\server.js' ]
    }
cinder patio
#

You haven't installed that either

regal saddle
#

^

#

If youโ€™re not trusted with the Code, try to learn it before using it.

earnest phoenix
#

How can I install this?

cinder patio
#

just like you installed discord.js,
npm i moduleName
Replace moduleName with the package you are missing

onyx summit
#

No one noticed how npm install save --discord.js (the command they claimed to run) is completely wrong?

cinder patio
#

lol

gray zealot
#

Hi :D I think this is a pretty common error, but I can't install quick.db I tried running vs code as admin but still an error

earnest phoenix
#

Why I cannot download quick.db?

#

Man, I have the exact same problem

cinder patio
#

any errors?

earnest phoenix
#

Error: Cannot find module 'quick.db'
Require stack:

  • C:\Users\User\Desktop\Giveaway Bot\server.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
    at Function.Module._load (internal/modules/cjs/loader.js:841:27)
    at Module.require (internal/modules/cjs/loader.js:1025:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (C:\Users\User\Desktop\Giveaway Bot\server.js:14:10)
    at Module._compile (internal/modules/cjs/loader.js:1137:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
    at Module.load (internal/modules/cjs/loader.js:985:32)
    at Function.Module._load (internal/modules/cjs/loader.js:878:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) {
    code: 'MODULE_NOT_FOUND',
    requireStack: [ 'C:\Users\User\Desktop\Giveaway Bot\server.js' ]
#

@cinder patio

gray zealot
#

^^^

#

Sameish :D

cinder patio
#

you should get that error when you require it, not when you install it

earnest phoenix
#

Hi :D I think this is a pretty common error, but I can't install quick.db I tried running vs code as admin but still an error
@gray zealot run powershell as admin and paste this: npm install --global windows-build-tools --vs2015

#

then install quick.db

gray zealot
#

Ok, I will try

#

as admin?

earnest phoenix
#

yea

gray zealot
#

k

#

@earnest phoenix SHould I still be as admin while npm i quick.db?

earnest phoenix
#

no

gray zealot
#

ok

#

:)

#

^^ This is what happens..

earnest phoenix
#

what did you put in your terminal

gray zealot
#

npm i quick.db

earnest phoenix
#

did you install the build tools first?

gray zealot
#

yes

earnest phoenix
#

in an admin powershell

gray zealot
#

yes

earnest phoenix
#

do you still have the terminal open

gray zealot
#

yes

earnest phoenix
#

show me whats in the terminal

gray zealot
#

sorry, powershell or vs code

earnest phoenix
#

off

#

sorry, powershell or vs code
@gray zealot pretty sure you should use powershell

#

or command prompt

#

you cant run vscode terminal as admin i dont think

gray zealot
#

ok

#

*?

earnest phoenix
#

yea

#

now try installing quick.db

gray zealot
#

in there?

#

:D

earnest phoenix
#

no

#

your normal terminal

gray zealot
#

๐Ÿ˜‚ ok

earnest phoenix
#

Now I have 23,5 GB but still @earnest phoenix

gray zealot
earnest phoenix
#

dude your error is literally just 300 lines of this:
npm WARN tar ENOSPC: no space left on device, write @earnest phoenix

gray zealot
#

I have installed node-gyp

earnest phoenix
#

@gray zealot try going to the bots files, right click and open powershell there

#

then try installing from powershell

gray zealot
#

ok

#

same thing

earnest phoenix
#

hmm

#

try going to the quick.db server, they have a guide thing on how to install it

gray zealot
#

ok :)

#

plexidev :D

earnest phoenix
#

ye

#

@earnest phoenix now I have 57,2 I restarted visual but still

#

check the #quick.db pinned messages

#

then try reinstalling it

#

Wdym pinned messages?

#

what

#

Wdym?

#

i was talking to him

#

oh

#

ok

#

but what can I do?

open flicker
#

Hello, why can a bot use 300 MB of memory?
when it has 32 servers

crystal socket
#

is it in this server?

ripe fulcrum
#

Guys what is this server for

crystal socket
#

if so this server has 100k users, which is HUGE, if you want it to go down, you can ask a mod to kick it

#

Guys what is this server for
@ripe fulcrum, its for https://top.gg

ripe fulcrum
#

Thanks

open flicker
#

if so this server has 100k users, which is HUGE, if you want it to go down, you can ask a mod to kick it
and because of this he consumes so much?

misty sigil
#

yes

crystal socket
#

id say maybe it'll go down 100 megs, if you want your ram to go down, you can also use d.js light, which doesn't cache as much.

misty sigil
#

^ my method

open flicker
#

ok

eternal osprey
#

hey guys

#

i am running into a problem

#

i recently started my bot on my vps

#

and i am sure i have the good bot key in the config file

#

but for some reason it starts the bot from the former config file.

misty sigil
#

is the config file pushed to the VPs

karmic compass
#

does anyone know how to host a html website 24/7

#

for free

#

because cheap go crabrave crabrave crabrave crabrave crabrave crabrave crabrave crabrave crabrave crabrave crabrave crabrave crabrave

misty sigil
#

you can host on a VPS

karmic compass
#

crabrave darnit crabrave

earnest phoenix
#
const { registerFont ,createCanvas, loadImage } = require('canvas')
registerFont(`${process.cwd()}/assets/fonts/neuville-bold.otf`, { family: 'Neuville' })
eternal osprey
#

is the config file pushed to the VPs
@misty sigil yup

dreamy cedar
#

how can i get mongodb ping ?

misty sigil
#

let time1 = Date.now()
await db.findOne
let time2 = Date.now()
time2 - time1

dreamy cedar
#

ty

eternal osprey
#

could someone tell me why my vps is running the file on a different bot

#

eventhough the bot token is right?

torn ravine
#

is there a guide on how to get discord voice channel ids?

#

I don't need it. I want to put it in one of my commands

sudden geyser
#

What library are you using?

torn ravine
#

discord.js

sudden geyser
#

And do you want to get a specific voice channel's ID, or some range.

torn ravine
#

no

#

I just want to teach users how to get their voice channel IDS

slender thistle
#

-ids

#

Fuck

#

-id

gilded plankBOT
#

An ID is a unique number which is used to identify a user, bot, channel, or message. To obtain an ID, right click on it and click "Copy ID"; this can be done from mobile by holding down.

Should you not see the option to acquire an ID, you need to enable "Developer Mode" which can be done from your user settings, under "appearance".

sudden geyser
#

big brain

slender thistle
#

Could use this as a template or just link them to the Discord article

torn ravine
#

alright thanks

dense vessel
#

is there a way to check if a specified timer is too short? im using discordjs with the ms library and my current code for it isnt working, the bot just ignores it

sudden geyser
#

What is time defined as?

dense vessel
#

args[0]

misty sigil
#

if time is ms(time) then it'll be in ms

sudden geyser
#

You simply need to check the milliseconds to see if it's less than whatever required

misty sigil
#

so no need for ms(60000)

#

just 60000

dense vessel
#

okay ill try doing that

#

thanks

drowsy skiff
#

package express { "error": "Missing required X-Access-Token header." } How do I fix this

violet haven
open flicker
#

how can you reduce your bot's RAM usage?

violet haven
#

?

open flicker
#

bot eats up a lot of memory)

violet haven
#

l$botinfo

#

ah shit

#

memory

#

Mรฉmoire
77.12 MB

open flicker
#

๐Ÿค”

violet haven
#

no it's just about the error i got

open flicker
torn ravine
#

what language do you use?

open flicker
#

?

violet haven
#

discord.js

torn ravine
#

try discord.js light

open flicker
#

๐Ÿค”

violet haven
#

what

open flicker
#

there like v11 or I'm wrong?

violet haven
#

just help me to resolve the error bruh

torn ravine
#

thats for you @open flicker

open flicker
#

there like v11 or I'm wrong?

violet haven
#

then can u help me?

torn ravine
#

not 100% sure thereโ€™s v11 light

misty sigil
#

no its not

#

there is still caching

#

just it can be managed more easily

torn ravine
#

yea thats what I mean

violet haven
pale vessel
#

change const track to let track

violet haven
#

just that?

open flicker
#

is DJS light used by DJS v12?

sudden geyser
#

yes

open flicker
#

๐Ÿค”

sudden geyser
#

Light is a third-party library.

torn ravine
#

Light is v12 I believe so

open flicker
#

ok

misty sigil
#

light is v12 yes

sinful belfry
open flicker
#

ok

violet haven
#

ow...it works

#

insane

sick cloud
#

does anyone use the mongodb driver for node

#

need help to update all fields with their own val but diff

#

each field (ie. price is a string, "9") but i need to update them all to number ie. 9

topaz fjord
#

so like if price is "8" in one and "9" in another you want to change the type for each to be a number?

sick cloud
#

@topaz fjord yeah as they all got inserted as strings

hushed axle
opal halo
#

case 'quota-add':
if (!msg.content.startsWith(Prefix))return
let db = new sqlite.Database('./Patrols.db', sqlite.OPEN_READWRITE);
var PatrolTime = args.slice(1).join(" ")
if (!PatrolTime){
return msg.channel.send("How many minutes did you patrol for?")
}

let Time = args[1];
let user = msg.author.tag

let query = `SELECT * FROM data WHERE user = ?`;
db.get(query, [user], (err, row) => {
    if (err) {
        console.log(err);
        return;
    }
    if (row === undefined) {
        let insertdata = db.prepare(`INSERT INTO data VALUES(?,?)`);
        insertdata.run(Time, user);
        insertdata.finalize();
        console.log("done");
        db.close();
        msg.channel.send(`Successfully logged your patrol of ${args[1]} minutes!`) 
        return;
    } else {
        let Time = row.PatrolTime + Math.floor(args[1]);;
         db.run(`UPDATE data SET PatrolTime = ?`, [Time]);
         msg.channel.send(`Successfully logged your patrol of ${args[1]} minutes! \n \n You now have a total of ${Time} minutes, epic`) 
         console.log(Time)
         console.log(db)
    }

Ok so im making a bot that saves a number someone said into sqlite, how would I make it so it doesn't overwrite everyone else's numbers?

sonic lodge
#

WHERE clause
UPDATE example_table SET example_column = 'example_value' WHERE another_column = 'must match this string'

topaz fjord
#

best to do it via the mongodb command line

sick cloud
#

okay

#

ty

topaz fjord
#

np

timid terrace
#

Thaty

#

@sick cloud

#

Bro i need 1 commands

#

ฤฐ need help

#

You help me?

opal halo
#

@sonic lodge Thanks

#

Wait

#

Is example table my variable that holds the number?

sonic lodge
#

no, that's just a placeholder table name

#

your table name is called data

faint prism
#

the table is not a variable

opal halo
#

Ohhh

faint prism
#

It's like a spreadsheet (kinda)

sterile minnow
#

Stoopid question but its 3AM for me so fuck it:

How do i get all args but not args[0] in JS

opal halo
#

So would this work?
db.run(UPDATE data SET example_column = ? WHERE another_column = ?, [Time, user]);

faint prism
#

get args instead of args[0]? lol

sterile minnow
#

i get ars[0] too

faint prism
#

the [index] is the item in the array you want

sterile minnow
#

I need all args but not args[0]

faint prism
#

then get args

#

and drop the index

sonic lodge
#

try it and see

opal halo
#

Ok

#

I forgot to fill in the things

sterile minnow
sudden geyser
#

is args an array

sterile minnow
#

yes

sonic lodge
#

must be a string

sudden geyser
#

Arrays don't have a .trim() function

summer torrent
#

you can't trim array

sudden geyser
#

You're probably looking to call it on a string

sterile minnow
#

AAAAAAAAAAAAAAAAAAAAA pain

sudden geyser
#

javascript

sterile minnow
#

is pain

faint prism
#

Arrays are pretty common in every language

pale vessel
#

list mmLol

sonic lodge
#

i think js makes array manipulation pretty easy

faint prism
#

A pretty essential datastructure

#

list mmLol
@pale vessel which is an array wrapper

sudden geyser
#

python

faint prism
#

AAAAAAAAAAAAAAAAAAAAA pain
@sterile minnow you probably want a for loop so you can handle each item in the array seperately

sterile minnow
#

nvm got it myself

faint prism
#

a for loop would let you go over each item like args[i] where each "loop" makes i + 1

sick cloud
hushed axle
#

meobuon hey someone know where to rent cheap vps to make the bot online 24/7 ?

sick cloud
#

digital ocean have decent vps' for $5/month

#

there's cheaper

hushed axle
#

How about the configuration

sick cloud
#

wdym configuration

summer torrent
#

check pins ๐Ÿ‘€

hushed axle
#

The computer configuration

sick cloud
#

do you mean the vps

hushed axle
#

Yeah

#

And can I control windown full root?catwhathappend

sick cloud
#

windown

#

what is that

hushed axle
#

SOo_o uhhh

sick cloud
#

do you mean windows

hushed axle
#

YesSOo_o

#

My english not good sorrySOo_o

sick cloud
#

vpses usually come with ubuntu or a distro of linux

#

not windows

#

iirc for $5/month DO gives you 1gb of ram, 1 vCore and 5 or 10gb storage, but you'd need to go to their site or pins maybe for details

hushed axle
#

bigsad alright thank

#

Does it have website or something?bigsad

sick cloud
earnest phoenix
#

yo where THE FUCK are the novelcovid docs

sick cloud
#

is the profanity really useful in that sentence

#

google is your friend though

earnest phoenix
#

google is my enemy

#

nothing comes up but the npm page which doesnt have any docs on it

sick cloud
#

literally first result

earnest phoenix
#

not the same thing

#

check the repos on them and they are different

sick cloud
#

send the repo then

earnest phoenix
#

wait

sick cloud
#

both belong to the same api

earnest phoenix
#

Can someone please help me with my code

#

my >bal command isn't working

pale vessel
#

what's the problem?

#

"not working" doesn't tell anything

earnest phoenix
#

Well first here's my index

pale vessel
#

if it doesn't work, there must be at least an error?

#

there's no errors?

earnest phoenix
#

here's my command

#

no errors

#

but my other commands work

sonic lodge
#

the point of a command handler is to prevent the need for a million if statements

earnest phoenix
#

I just added the command handler

#

I was gonna move them after I finished the eco system

sonic lodge
#

well i guess that's your problem

#

i don't see an if statement for bal

earnest phoenix
#

do I need one?

sonic lodge
#

well yeah, since you're still using if statements

earnest phoenix
#

I thought that eliminated the need

sonic lodge
#

it does, once you remove all the if statements

earnest phoenix
#

So unless the if statements are gone, it won't work?

sonic lodge
#

that's what you should do

#

what i'm saying is that you have a command handler; however, you still have if statements for each command as if you don't have one
a solution would be to add another if statement for the bal command, which is ridiculous, so
"true" solution is to remove every if statement to use the command handler properly

earnest phoenix
#

I'll do that rn

grizzled raven
#

client.commands.get(command).execute

earnest phoenix
#

i open and close a db in every command which makes the response real slow..

#

can i make a global connection and use it in the entire program?

faint prism
#

You can have a class where there is a connection object

#

And then you could pass around that instance as a service

#

Sounds like what you want is a inversion of control container or register a service dependency @earnest phoenix

earnest phoenix
#

ye

#

i can use that class thing

#

but isnt that same as opening and closing a db

faint prism
#

Depends on the lib and db you use really.

#

A db server where you make the call over a network is pretty fast

earnest phoenix
#

ohh

faint prism
#

Not really sure what you mean by open and close. Typically a DB server/service is in memory and calling it's API is meant to be as fast as possible

paper phoenix
#

Connection pool.

delicate shore
#

wow

ionic shard
#

even tho the same thing works when i do

    console.log(`${client.user.username} is now up and running...`);```
torn ravine
#

client is null until the ready event is emitted

#

if that makes sense

#

@ionic shard

ionic shard
#

but i cant really use client.on in that

torn ravine
#

what exactly are you trying to do?

ionic shard
#

trying to make help page with author = bot name

torn ravine
#

how are you doing your embed?

ionic shard
#

last option is to just put the bot name as static

torn ravine
#

Can I see your embed code?

ionic shard
#
                color: '#3de956',
                title: '[+] help',
                author: {
                    name: `${client.user.username}`,
                    icon_url: 'https://i.imgur.com/S1qiKEA.jpg',
                },
                description: '',
                timestamp: new Date(),
            };

            message.channel.send({ embed: helpEmbed });```
#

im yet to put stuff just stuck here

torn ravine
#

what language?

ionic shard
#

js

torn ravine
#

I mean

spare gale
#

what is this
@sonic lodge ohhh shhiiiiittttt

ionic shard
#

thats what im doing

#

i prefer this object one over the native

#

looks cleaner to me

torn ravine
#

oh alright

opal halo
#

Ok so Im trying to send a Embed but when it trys to send it gives me this
error: (node:41200) UnhandledPromiseRejectionWarning: TypeError: fields.flat is not a function

torn ravine
#

what language

opal halo
#

js

spare gale
#

Ok so Im trying to send a Embed but when it trys to send it gives me this
error: (node:41200) UnhandledPromiseRejectionWarning: TypeError: fields.flat is not a function
code?

opal halo
sonic lodge
#

@spare gale what did you ping me for

spare gale
cinder sandal
#

@spare gale this font breaks my eyes

torn ravine
#

oh my jesus christ

ionic shard
#

@opal halo u'r missing a ";" in 2nd last line

sonic lodge
#

you didn't have to ping me for it

spare gale
#

@spare gale this font breaks my eyes
this code breaks me

opal halo
#

Oh

cinder sandal
#

@opal halo at least your code font is normal

opal halo
#

Yes

#

@ionic shard Didn't change anything

spare gale
#

@opal halo hmm

#

i think problem not in Embed :/

ionic shard
#

ur missing it on the last line to

spare gale
#

in js ';' not probably

opal halo
#

that doesn't do anything though

ionic shard
#

well its the syntax idk if it fixes the problem ur getting or not

#

but syntax is still important

#

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

torn ravine
#

@opal halo can I see the full error

opal halo
#

Uh

#

Its just a bunch of spam

torn ravine
#

show

spare gale
#

hmm

opal halo
#

(node:31096) UnhandledPromiseRejectionWarning: TypeError: fields.flat is not a function
at Function.normalizeFields (C:\Users\Lane\Desktop\DiscordBot3\node_modules\discord.js\src\structures\MessageEmbed.js:450:8)
at MessageEmbed.setup (C:\Users\Lane\Desktop\DiscordBot3\node_modules\discord.js\src\structures\MessageEmbed.js:78:91)
at new MessageEmbed (C:\Users\Lane\Desktop\DiscordBot3\node_modules\discord.js\src\structures\MessageEmbed.js:18:10)
at embedLikes.map.e (C:\Users\Lane\Desktop\DiscordBot3\node_modules\discord.js\src\structures\APIMessage.js:166:40)
at Array.map (<anonymous>)
at APIMessage.resolveData (C:\Users\Lane\Desktop\DiscordBot3\node_modules\discord.js\src\structures\APIMessage.js:166:31)
at TextChannel.send (C:\Users\Lane\Desktop\DiscordBot3\node_modules\discord.js\src\structures\interfaces\TextBasedChannel.js:166:62)
at Client.Bot.on.msg (C:\Users\Lane\Desktop\DiscordBot3\index3.js:78:25)
at Client.emit (events.js:198:13)
at MessageCreateAction.handle (C:\Users\Lane\Desktop\DiscordBot3\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
(node:31096) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:31096) [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.

#

Lol

torn ravine
#

index3.js line 78 collum 25

spare gale
#

yep

torn ravine
#

let me see whats there

spare gale
#

74->80 lines, pls

#

@opal halo

earnest phoenix
#

my bot is sometimes go offline, hosted in vps with node.js with pm2, no errors, just going offline (650k users and 226 servers) how can i fix that?

opal halo
spare gale
#

@earnest phoenix
internet problems?

opal halo
#

74 80

spare gale
#

full screen pls

opal halo
#

w

#

ok

spare gale
#

78 line not full

torn ravine
#

put your cursor on colum 25

earnest phoenix
#

@spare gale idk

#

i dont think so

spare gale
#

windows/linux?

earnest phoenix
#

there are like 7 more bots

#

Windows

spare gale
#

try to start ping xD

#

ping -t 8.8.8.8.

opal halo
#

Ok

torn ravine
#

hosting on windows is just awful

opal halo
#

Im on column 25

earnest phoenix
#

there are like 7 more bots
and they are online

spare gale
#

hm

torn ravine
#

take a screenshot of the stuff around it

spare gale
#

7 bots in 7 scripts?

earnest phoenix
#

yes

#

7 different

opal halo
earnest phoenix
#

i know its dumb to host 8 bots in 1 vps but idk why my bot that have 226 servers go offline

#

when im doing pm2 logs i dont see any errors

#

when restarting it is going back online

wary flame
#

Pm2 seperates error logs from info logs

#

Are you sure there is no error

opal halo
#

@torn ravine Any ideas?

spare gale
#

hmmm, try to attach logger with logging discord connection

earnest phoenix
#

ok

#

Are you sure there is no error
@wary flame what do you mean

#

i see all logs and errors in one (pm2 logs helpful)

#

i just dont see one that making him going offline

wary flame
#

Nvm then

spare gale
#

@opal halo

opal halo
#

@spare gale

spare gale
#

add this to msg.send:

.catch(e => console.log(`Error: ${e}`)

i see only warnings :/

opal halo
#

Which one?

#

Where it sends the embed?

torn ravine
#

try switching the " to '

opal halo
#

Oh

#

ok

spare gale
#
msg.channel.send(QuotaEmbed).catch(e=>console.log(`Error: ${e}`))
earnest phoenix
#

doing

client.on("disconnent", () => {
require("child_process").exec("pm2 restart helpful") 
})

will work?

spare gale
#

:'D

torn ravine
earnest phoenix
#

lol

spare gale
#

XD

opal halo
#

Said the same thing

#

Error: TypeError: fields.flat is not a function

earnest phoenix
#

node.js version?

#

make sure to use 12+ when using d.js v12+

spare gale
#

search fields.flat in code

#

:/

earnest phoenix
#

i believe its why this error..

opal halo
#

its not in my code though

earnest phoenix
#

i saw this error many times

pale vessel
#

it's in discord.js code, upgrade node

earnest phoenix
#

its because your node version

#

upgrade to 12+

spare gale
#

:D

opal halo
#

Oh

#

Is v12 the latest?

earnest phoenix
#

you will get more errors...

#

no

opal halo
#

Oh

earnest phoenix
pale vessel
#

v14 is

spare gale
torn ravine
#

Latest NODEJS version

#

not asking you to go to discord.js v12 even though I highly recommend it

earnest phoenix
#

14.8

pale vessel
#

he's already on v12, hence the error

opal halo
#

^

#

So I delete the old node files?

earnest phoenix
#

just upgrade your node version and you wont get errors from the library

#

no

spare gale
#

node.js 8.0.1 is LATEST, PRETTY GOOD and, amm... and end. :'D

opal halo
#

I got

earnest phoenix
#

just download the current one and it will ask you to upgrade

opal halo
#

v14

spare gale
#

:)

opal halo
#

you almost made me download it again lol

spare gale
#

xD

#

im controool uuu

#

xD

#

ow, need more coffee

#

guys, how to create dynamic-loading plugins to bot? :/

torn ravine
#

wym?

spare gale
#

if *.js add to './plugins' it will loaded

#

im fcked for restarting bot :(

torn ravine
#

a command handler

opal halo
#

bruh

#

McAfee blocked the update

spare gale
#

add plugin and send command? no :((((

opal halo
#

aaaerrvrervew

spare gale
#

McAfee?

#

ill secure your PC better, lol

#

xD

opal halo
#

its an anti virus thing

#

lol

spare gale
#

come on, viruses, ill ready for fight

#

*died *

#

use firewall, antiviruses is shit

#

only in live cd it works good

earnest phoenix
spare gale
#

i can add NOT, NOT and NOT stable bot to this server? xD

#

in pre pre pre pre closed beta xD

earnest phoenix
#

see when file is added to directory and add that file to cmd handler

opal halo
#

@earnest phoenix So I updated the files, what do I do now?

spare gale
#

thx, i cant find it :////

#

thx, really

graceful dock
#

Eris or discord.js?

spare gale
#

am, english?

earnest phoenix
#

discord.js

opal halo
#

@earnest phoenix So I updated the files, what do I do now?
@opal halo

graceful dock
#

Any advantages of using Eris?

earnest phoenix
#

@opal halo just restart your bot ?

opal halo
#

Oh ok

spare gale
#

what is 'Eris' :/

earnest phoenix
#

npm package

spare gale
#

o.0

umbral pollen
#
    throw err;
    ^
Error: Cannot find module 'discord.js'
    at Function.Module._resolveFilename (module.js:548:15)
    at Function.Module._load (module.js:475:25)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
at Object.<anonymous> (/app/shard.js:1:91)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)```
How to fix this error , i have even install discord.js in it , still it is showing me the same error
spare gale
#

node js, node packet manager, ph

vale garden
#

hii

#
const api = require('novelcovid');
const Discord = require('discord.js')
const client = new Discord.Client()
const db = require('quick.db')
const Canvas = require('canvas')

module.exports = {
    name: "test",
    description: "Checks a weather forecast",
    async execute(message, args) {

    const canvas = Canvas.createCanvas(700, 250);
    const ctx = canvas.getContext('2d');

    // Since the image takes time to load, you should await it
    const background = await Canvas.loadImage('https://www.w3schools.com/w3css/img_lights.jpg');
    // This uses the canvas dimensions to stretch the image onto the entire canvas
    ctx.drawImage(background, 0, 0, canvas.width, canvas.height);
    // Use helpful Attachment class structure to process the file for you
  // Select the color of the stroke
    ctx.strokeStyle = '#74037b';
    // Draw a rectangle with the dimensions of the entire canvas
    ctx.strokeRect(0, 0, canvas.width, canvas.height);

  // Select the font size and type from one of the natively available fonts
    ctx.font = '60px sans-serif';
    // Select the style that will be used to fill the text in
    ctx.fillStyle = '#ffffff';
    // Actually fill the text with a solid color
    ctx.fillText(message.author.username, canvas.width / 2.5, canvas.height / 1.8);

  // Pick up the pen
    ctx.beginPath();
    // Start the arc to form a circle
    ctx.arc(125, 125, 100, 0, Math.PI * 2, true);
    // Put the pen down
    ctx.closePath();
    // Clip off the region you drew on
    ctx.clip();

  const avatar = await Canvas.loadImage(message.author.displayAvatarURL({ format: 'jpg' }));
    // Draw a shape onto the main canvas
    ctx.drawImage(avatar, 25, 25, 200, 200);

    const attachment = new Discord.MessageAttachment(canvas.toBuffer(), 'welcome-image.png');

    message.channel.send(`yo!`, attachment);

    }
}

#

this is my code

#

but

spare gale
#
    throw err;
    ^
Error: Cannot find module 'discord.js'
    at Function.Module._resolveFilename (module.js:548:15)
    at Function.Module._load (module.js:475:25)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
at Object.<anonymous> (/app/shard.js:1:91)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)```
How to fix this error , i have even install discord.js in it , still it is showing me the same error

show me your require discord.js, pls

vale garden
#

im getting this

#

why is my text not showing up

opal halo
#

Ayeee

#

It finally worked

vale garden
#

lol

torn ravine
#

are you trying to use a different font?

vale garden
#

wat

#

wdym different

#
ctx.font = '60px sans-serif';
#

this is the font

#

i dont understand what you mean by different

spare gale
#

username in eng or styled text?

torn ravine
#

are you trying to use a font besides the default ones

spare gale
#

aff

#

i dont see it

#

try with default font @vale garden

vale garden
#

kk

#

but do i specify a font or leave it

#

cuz i have no idea what the default font is

#

btw i removed it and tried

#

it gave the same result

pale vessel
#

it's system default

spare gale
#

ctx.font = '60px';

vale garden
#

o

#

kk

#

ooof

#

its still not working

vale garden
#

yeah the same thing

spare gale
#

console.log(message.author.username) normal text?

vale garden
#

ok let me see

opal halo
#

Ok im back

#

How would I make it so my bot posts in a certain channel?

pale vessel
#

fetch or get the channel

earnest phoenix
#

why sometimes when restarting a process in pm2 the process starting twice ? (restarted a bot and the bot is responding twice)

opal halo
#

Hm

pale vessel
#

is it inside the same guild?

opal halo
#

Yes

spare gale
#

why sometimes when restarting a process in pm2 the process starting twice ? (restarted a bot and the bot is responding twice)
bot self-coping ?

#

or what?

earnest phoenix
#

no

pale vessel
#

use guild#channels#[#cache]#find

#

use #get() instead of #find() if you already have the channel id

earnest phoenix
#

i will send a picture

spare gale
#

kk

earnest phoenix
#

its just doing everything twice after restarting

#

if i will do pm2 kill && pm2 resurrect it will work just fine

#

it just i dont want to do this ..

spare gale
#

in your disconnect action add self-kill

summer torrent
earnest phoenix
#

yea i did

spare gale
#

yep

earnest phoenix
#

but why after doing "pm2 restart helpful" its started twice

spare gale
#

your bot dont died, script still working, but u start new, if bot disconnected from discord. bot will reconnect, and on 1 bot worked many scripts

opal halo
#

How would I make it so my bot posts in a certain channel?
@opal halo But in discord.js

spare gale
#

script disconnected => started new, old reconnected :/

#

get event, handle new&old

vale garden
#

hi i am back

#
Promise { <pending> }
YOO boi im active lol LMAOOO
Bot is ready with username: TradeBot alpha 0.5
Fontconfig error: Cannot load default config file
Multi
spare gale
#

hi

vale garden
#

this is my exact

#

stuff

#

in the console

#

it says fontconfig error

#

but i just installed fontconfig

spare gale
#

ow...

vale garden
#

and it still says the same thing

#

lol wat

spare gale
#

dont use custom fonts

#

if its not stable

vale garden
#

wat

#

i left it at

#

the default font

spare gale
#

:/

#

:///

vale garden
#

whatt

#

lol what do i do

pale vessel
#

i meant channels my bad

spare gale
#

delete ctx.font setting :/

vale garden
#

lol ok

pale vessel
#

e.g. js guild.channels.cache.get("ID"); guild.channels.cache.find(channel => channel.name === "general");

spare gale
#

problem in font, but what :///////

vale garden
#

im still getting the same errorrrrrrr

opal halo
#

Oh alright

spare gale
#

im still getting the same errorrrrrrr
your system have fonts?

vale garden
#

ofc lol

#

ok i havent activated windows so that might have something to do with it

pale vessel
#

i don't think repl.it has system fonts

#

register one

#

using Canvas.registerFont(path, { family: "Font Name" });

vale garden
#

ok

#

kk

spare gale
#

srry if i bad help, i dont seen this problem later :'D

vale garden
#

ok see

#

@pale vessel

#

i did the thing

#

which you told me to do

#

but since repl isnt like on my pc

#

i dont think it can access anything on it

#

cuz

#

im getting this error

#
UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, lstat '/home/runner/Trade-Bot/C:UserssfudallyDownloadsabel.zipabel-regular.ttf'
opal halo
#

Ok so I did this:
let channel = Bot.channels.fetch("746975182169571338");
channel.send(${user} just completed their quota :beautiful:);

#

Says send is not a function

#

@pale vessel

pale vessel
#

channels.cache

#

also, if you're going to fetch, use await

opal halo
#

What do I do for cache?

spare gale
pale vessel
#

don't put cache, you're fetching it

vale garden
#

@pale vessel btw can you see my problem

#

lol

opal halo
#

would cache not work?

spare gale
#

tell him (@umbral pollen) - he dude xD

vale garden
#

wat

opal halo
#

I think faze died

#

aa

pale vessel
#

no i'm playing osu

vale garden
#

lol

pale vessel
#

you can't fetch something from cache

vale garden
#

btw thx my thing works now

pale vessel
#

it's either await client.channels.fetch() or client.channels.cache.get()/find()

opal halo
#

But its saying send is not a function

#

would await fix that?

pale vessel
#

yes

opal halo
#

Oh ok

#

uh

pale vessel
#

show code

opal halo
#

if (Time < 300){
let channel = await Bot.channels.fetch("746975182169571338");
channel.send(${user} just completed their quota :beautiful:);
}

pale vessel
#

more

opal halo
#

if (row === undefined) {
let insertdata = db.prepare(INSERT INTO data VALUES(?,?));
insertdata.run(Time, user);
insertdata.finalize();
console.log("done");
db.close();
msg.channel.send(Successfully logged your patrol of ${args[1]} minutes!)
return;
} else {
let Time = row.PatrolTime + Math.floor(args[1]);;
db.run(UPDATE data SET PatrolTime = ? WHERE user = ?, [Time, user]);
msg.channel.send(Successfully logged your patrol of ${args[1]} minutes! \n \nYou now have a total of ${Time} minutes, epic)
if (Time < 300){
let channel = await Bot.channels.fetch("746975182169571338");
channel.send(${user} just completed their quota :beautiful:);
}
console.log(Time, user)
}

pale vessel
#

more

#

actually, just the top portion

opal halo
#

You want all the code?

pale vessel
#

not all

opal halo
#

oh

#

ok heres the whole command

#

case 'quota-add':
if (!msg.content.startsWith(Prefix))return
let db = new sqlite.Database('./Patrols.db', sqlite.OPEN_READWRITE);
var PatrolTime = args.slice(1).join(" ")
if (!PatrolTime){
return msg.channel.send("How many minutes did you patrol for?")
}

let Time = args[1];
let user = msg.author.tag

if (Time > 999){
    return msg.channel.send("lmao, you expect me to believe that you patrolled for that long? smh.")
}

let query = `SELECT * FROM data WHERE user = ?`;
db.get(query, [user], (err, row) => {
    if (err) {
        console.log(err);
        return;
    }
    if (row === undefined) {
        let insertdata = db.prepare(`INSERT INTO data VALUES(?,?)`);
        insertdata.run(Time, user);
        insertdata.finalize();
        console.log("done");
        db.close();
        msg.channel.send(`Successfully logged your patrol of ${args[1]} minutes!`) 
        return;
    } else {
        let Time = row.PatrolTime + Math.floor(args[1]);;
         db.run(`UPDATE data SET PatrolTime = ? WHERE user = ?`, [Time, user]);
         msg.channel.send(`Successfully logged your patrol of ${args[1]} minutes! \n \nYou now have a total of ${Time} minutes, epic`)
         if (Time < 300){
            let channel = await Bot.channels.fetch("746975182169571338");
            channel.send(`${user} just completed their quota :beautiful:`); 
         }
         console.log(Time, user)
pale vessel
#

make the function async, async (err, row) => {}

opal halo
#

row is doing stuff with the data base though

pale vessel
#

that's a callback, it runs that function after it's done. you have to make the function async in order to use await

opal halo
#

Oh ok

#

Ok so

#

Like this?

#

let channel = async (err, row) => {await Bot.channels.fetch("746975182169571338")} ;

pale vessel
#

yes

opal halo
#

ight

#

Still says:
TypeError: channel.send is not a function

pale vessel
#

try console.log(channel);

#

right after defining it

opal halo
pale vessel
#

show code again, sorry

opal halo
#

case 'quota-add':
if (!msg.content.startsWith(Prefix))return
let db = new sqlite.Database('./Patrols.db', sqlite.OPEN_READWRITE);
var PatrolTime = args.slice(1).join(" ")
if (!PatrolTime){
return msg.channel.send("How many minutes did you patrol for?")
}

let Time = args[1];
let user = msg.author.tag

if (Time > 999){
    return msg.channel.send("lmao, you expect me to believe that you patrolled for that long? smh.")
}

let query = SELECT * FROM data WHERE user = ?;
db.get(query, [user], (err, row) => {
    if (err) {
        console.log(err);
        return;
    }
    if (row === undefined) {
        let insertdata = db.prepare(INSERT INTO data VALUES(?,?));
        insertdata.run(Time, user);
        insertdata.finalize();
        console.log("done");
        db.close();
        msg.channel.send(Successfully logged your patrol of ${args[1]} minutes!) 
        return;
    } else {
        let Time = row.PatrolTime + Math.floor(args[1]);;
         db.run(UPDATE data SET PatrolTime = ? WHERE user = ?, [Time, user]);
         msg.channel.send(Successfully logged your patrol of ${args[1]} minutes! \n \nYou now have a total of ${Time} minutes, epic)
         if (Time < 300){
            let channel = await Bot.channels.fetch("746975182169571338");
            channel.send(${user} just completed their quota :beautiful:); 
         }
         console.log(Time, user)
#

whole command ^

pale vessel
#

thonk

opal halo
#

lol

pale vessel
#

Bot is your client right?

opal halo
#

Mhm

trim saddle
#

this would be easier to look at in a box

#

@opal halo you copied this straight from your code right?

opal halo
#

Mhm

trim saddle
#

channel.send(${user} just completed their quota :beautiful:)

#

this isn't a string

pale vessel
#

it's `

opal halo
#

^

trim saddle
#

i don't see the markdown

pale vessel
#
`hi`
trim saddle
#

ik

pale vessel
#

nani

opal halo
trim saddle
#

hm.

pale vessel
spare gale
#

guys, which editor u use?

pale vessel
#

notepad++

spare gale
#

:'D

#

really?

pale vessel
#

@opal halo that's the correct channel id right?

opal halo
#

yes

pale vessel
spare gale
#

lol :DD

pale vessel
#

what's so funny about it smh

#

it just works

#

i don't need some advanced ide and debuggers

spare gale
#

Editor? editor

#

no problem :D

#

i use notepad++ for fast edit

pale vessel
#

did you literally put console.log(channel);?

opal halo
#

Yes

pale vessel
#

hm

#

where did you put it?

spare gale
opal halo
pale vessel
#

woah not there

small prairie
#

wait what

opal halo
#

what