#development

1 messages · Page 1658 of 1

solemn leaf
#

you dont

vivid fulcrum
#

there's also the scroll event but be careful how and what you do with it

craggy elk
solemn leaf
#

Because you pinged me 😭

vivid fulcrum
#

it fires a lot of times, you can potentially block rendering by blocking the scroll event handler

craggy elk
solemn leaf
#

@boreal iron I think I did this right, but 26069.0 != 500

boreal iron
#

Sorry I gtg, just message cry, he’s being payed to give support

craggy elk
#

I will ask in another place

#

bye

quartz kindle
#

cry is getting paid? lmao

solemn leaf
#

oh epico

vivid fulcrum
#

i wish

quartz kindle
#

i wish i was paid

solemn leaf
#

@vivid fulcrum let me help you get paid more lmfao

vivid fulcrum
#

multiplying things by zero still gives zero 😔

solemn leaf
#

I know?

heavy marsh
vivid fulcrum
#

it's a joke

solemn leaf
#

Cry

#

this is right to get mB correct

os.totalmem() / 1024 / 1024
vivid fulcrum
#

i have no idea, sorry lol

quartz kindle
#

yes its correct

vivid fulcrum
#

i don't work with node enough

solemn leaf
#

then why is it so big

#

nothing to what repl says it gives

quartz kindle
#

hmm?

solemn leaf
#

?

unreal estuary
#

what are some of the reasons why that people make their projects open source? just curious

quartz kindle
#

why is what so big

solemn leaf
#

to help others?

unreal estuary
#

lol christmasthink

quartz kindle
solemn leaf
#

Tim what would you do to get the hosts system stats

quartz kindle
solemn leaf
#

h what

#

give example what yours looks like

quartz kindle
#

i dont have any, i dont measure system stats

#

only my bot's stats

#

but os.totalmem is the right way

solemn leaf
#

what would you measure

quartz kindle
#

i only measure my bot's memory usage and cpu usage

solemn leaf
#

Which is

quartz kindle
#

wdym which is

blissful coral
#

Anyone know how I could get the ping in ms from mongoose?

quartz kindle
#

make a request and measure how much time it takes?

solemn leaf
#

Using date.now

blissful coral
#

Yeah thought there was a built in function but it apparently doesn't return what I thought it did

final lynx
#

so i tried to organize my commands but, it didnt work. The error was "fs.readdireSync" is not a function. what should i replace it with

blissful coral
#

what is fs defined as

final lynx
blissful coral
#

require("fs")

#

It is a node module, you have to use require()

final lynx
#

where should i put require('fs')

blissful coral
#

Where you have ("fs")?

#

call a function on the ()

#

that function being replace

final lynx
#

this is where i have fs

#

and where the error is

#

should i replace that with require("fs")?

blissful coral
#

I would suggest learning javascript and node.js before attempting to code a discord bot

solemn leaf
#

no no no

unreal estuary
#

fs.readdirsync

solemn leaf
#

learn how to use your brain cells first

final lynx
#

:/

blissful coral
#

readdirsync is not a function because fs does not have a function called readdirsync in it

#

all fs is = to is "fs"

unreal estuary
#

i dont think there is an e

blissful coral
#

?

unreal estuary
#

const fs = require("fs") ?

solemn leaf
#

raddirsync

#

radd

unreal estuary
#

did u do that

blissful coral
#

You need to define with requiring the node module

solemn leaf
#

pretty rad dir sync

blissful coral
#

@unreal estuary Please look up before attempting to help uwu

river fog
#

hi

final lynx
#

so this

blissful coral
#

Ues

#

Yes*

final lynx
#

ok

#

thanks

river fog
#

who can help me ?

blissful coral
#

Ask your question so we know if we can help KEKW

unreal estuary
blissful coral
#

No

#

I am saying you were repeating things that were already said

unreal estuary
#

ohh

#

sorry (;

blissful coral
#

;0

river fog
blissful coral
#

What about it?

river fog
#

how to make like this decription

blissful coral
#

css

#

and htrml

#

html*

solemn leaf
#

and brain cells

river fog
#

ı dont know

#

hot to make

#

do you have code

#

?

blissful coral
#

No

earnest phoenix
blissful coral
#

Not a good idea

#

Won't learn by doing that

heavy marsh
#

I updated my command for #development message but I dont get all of the required badges

      const flags = await member.user.fetchFlags();
      const userFlags = flags.toArray();
        
      let IncludeBadges = {
        "DISCORD_EMPLOYEE": "emoji 1",
        "PARTNERED_SERVER_OWNER": "emoji 2",
        "HYPESQUAD_EVENTS": "emoji 3",
        "BUGHUNTER_LEVEL_1": "emoji 4",
        "HOUSE_BRAVERY": "emoji 5",
        "HOUSE_BRILLIANCE": "emoji 6",
        "HOUSE_BALANCE": "emoji 7",
        "EARLY_SUPPORTER": "emoji 8",
        "BUGHUNTER_LEVEL_2": "emoji 9",
        "VERIFIED_BOT": "emoji 10",
        "EARLY_VERIFIED_BOT_DEVELOPER": "emoji 11"
      };

    let DisplayBadges = [];    
    for (var key in IncludeBadges) {
        if (userFlags.includes(key)) {
            DisplayBadges.push(IncludeBadges[key])
        }
    }     
    console.log(DisplayBadges);   
blissful coral
#

Because not all of them are public

heavy marsh
#

EARLY_VERIFIED_BOT_DEVELOPER is not public?

blissful coral
#

iirc no

heavy marsh
quartz kindle
blissful coral
#

^

quartz kindle
#

EARLY_VERIFIED_DEVELOPER

#

not EARLY_VERIFIED_BOT_DEVELOPER

blissful coral
#

^

heavy marsh
#

ahh ok

blissful coral
#

yea

#

lmao

quartz kindle
#

djs might wanna fix that

blissful coral
#

d.js just wants to be stinky and not update docs

quartz kindle
#

is that in stable docs or master docs?

blissful coral
#

I just submitted a quick pr

heavy marsh
blissful coral
#

stable

#

hm

quartz kindle
#

same in master

#

time for PR

blissful coral
#

I sent in the stable PR

heavy marsh
#

is it correct

quartz kindle
#

should be

heavy marsh
#

oks

quartz kindle
#

btw the verified developer seems to be wrong in the discord api too lol

heavy marsh
#

d.js messed up?

#

or did Discord API

quartz kindle
#

no discord did

heavy marsh
#

rip

final lynx
#

does anyone know why this doesnt work, the error is, "Cannot read property 'set' of undefined"

heavy marsh
#

works now

hidden lynx
unreal estuary
hidden lynx
#

?

solemn leaf
#

@quartz kindle For cpu usage it returns system and user

unreal estuary
#

they put

final lynx
#

lol

unreal estuary
#

```const commands = require(./commands/${file});````

#

in the for const file of command files

unreal estuary
#

so commands doesnt even exist out of it

hidden lynx
#

???

unreal estuary
#

so how can nothing equal to "ban"or "kick"

#

just read the code im bad at explaining stuff

#

lol

quartz kindle
#

@heavy marsh @blissful coral actually the docs are correct

#

this change was made in december 2020

#

your library is probably outdated

heavy marsh
#

ooh

quartz kindle
#

actually they didnt release it to stable

#

its on master only

#

not sure why the stable docs were changed tho

final lynx
#

ok, i got everything to work... finally

twilit hawk
# river fog

search up markdown on google that's how u make it like that

blissful coral
#

Yeah @quartz kindle was boutta say that was stable that said that imo

#

And I ran it on my stable bot to check

earnest phoenix
#

Can someone explain me how i can export a variable from an asynchronous function

quartz kindle
#

await it

earnest phoenix
#
function checkUser() { 
var returnValue; 

axios.get(`api/users/CheckUsername/${this.username}`).then(response => { 
returnValue = response.data.error === 0; 
}, errorCallBack => { 
returnValue = false; 
}); 

return returnValue; 
}
#

It always return undefined

quartz kindle
#

because .then() is the same as a callback

#

it doesnt pause the outer code while it waits

#

when the .then() is executed, the outer code doesnt exist anymore

#

you have to use async / await syntax

earnest phoenix
#

Ohh okay ty for helping

unreal estuary
#

why is tim so helpful bearcop

livid lichen
#
const NewPages= new require("DiscordEasyPages")
.set("test")

``` Just wondering, how would I use the new constructor for developing a package?
opal plank
#

just what you did, but with parenthesis

livid lichen
#

Oh?

opal plank
#
const test = (new require('MODULE_NAME')).set('test')
livid lichen
#

Okay. Thanks!

opal plank
#

no problomo

blissful coral
#

Anyone use kurasuta?

#

Having this problem when I run this.client.shard.restart(0) or this.client.shard.restartAll()

quartz kindle
#

do you have an error event listener?

thick nexus
#

idk

quartz kindle
#

manager.on("error")

thick nexus
#

so someones trying to intentionally rate-limit my bot but idk how 2 counter it lmao

#

i do but they just cycle through my commands

#

nop

boreal iron
#

Set a cooldown for the whole guild

thick nexus
boreal iron
#

Can’t be easier
Just add a property to the guild obj
message.guild.commandTimeout

#

Check in your message event if that property exists and calculate now - timestamp

#

Oops I meant .commandTimestamp

#

Damn mobile auto correction

#

At the end of your message event just add the property = current timestamp

#

3 lines of code but a huge change

thick nexus
#

hmm

boreal iron
#

1 more line to send a message with some spam protection content (only send it once of course)

#

Very simple

#

With the check if time - timestamp > cooldown you can even go further and double the protection time each abuse for example etc.

grizzled raven
#

so the best thing you can do is an error listener or a sort of rolling restart

blissful coral
#

Yeah I figured it out lulw

#

Forgot to add my error event

#

how the frickity frack can I silence this

#

@quartz kindleothy any idea?

misty sigil
#

thats a mongoose error

#

iirc

crimson vapor
#

install an older mongoose

blissful coral
#

how older

crimson vapor
#

ill send the version I use and don't get the error

misty sigil
#

older older

#

so like older

crimson vapor
#

"mongoose": "^5.11.15",

misty sigil
#

be sure to remove that ^

blissful coral
#

There we go

misty sigil
#

or it'll install later ver

#

or something

blissful coral
#

Yep it worked

#

No more errors

#

poggers

drifting wedge
#

using System;
using System.Threading;

namespace full_calculator
{
    class Program
    {
        static void wait(int time) {
            Thread.Sleep(time);
        }
        static void Main(string[] args)
        {
            Boolean loop = true;
            if (loop) {
                Console.WriteLine("Please enter your expression below! Each term should be separated by a space.");

                String expression = Console.ReadLine();

                expression.Split(" ");

                if (expression[1] == "+") {
                    Console.WriteLine(Int16.Parse(expression[0] + Int16.Parse(expression[2])));
                }
            }
        }
    }
}

#

what is wrong

#

cs

blissful coral
#

And thats my queue to leave

drifting wedge
#

SOMEONEEEE

#

ahh

#

@sage bobcat sorry for ping but ur like the only person i know that knows c#

crimson vapor
#

@scenic kelp

drifting wedge
#

Argument 1: cannot convert from 'char' to 'System.ReadOnlySpan<char>'

#

oh yeah parm too

#

sorry faith

scenic kelp
#

wheres the error

#

why are you calling tostring on "+"

drifting wedge
#

i removed that

#

the error is on the if line

#

if expression[1]...

scenic kelp
#

you're comparing a string to a char as well

drifting wedge
#

well yeah but how can i turn it into a str?

#

i tried ToString() the index but it didnt work too

scenic kelp
#

compare to '+'

#

string[i] returns a char

drifting wedge
#

yes

#

i tostringed it

#

and it still gave same error

scenic kelp
#

you tostringed the +

drifting wedge
#

i did it with the index too

#

i judt didnt send it here

#

i tried both

#

cannot convert from 'char' to 'System.ReadOnlySpan<char>'

#

if (expression[1].ToString() == "+") {

scenic kelp
#

also another nitpick, string should be lowercase when you're referring to the type

drifting wedge
#

where?

#

oh okay

#

cool

scenic kelp
#

String expression

drifting wedge
#

i did

#

yep i saw

#

alr but its still erroring out

scenic kelp
#

why are you splitting the string and not storing its value

drifting wedge
#

oh lol

#

hahahaha

#

i didnt realize

scenic kelp
#

you call expression.Split(" ") but do nothing with the output

drifting wedge
#

yep

#

oops

#

i think its that

#

i just assumed it would auto save it

#

but idk why i did

#

now

#
using System.Threading;

namespace full_calculator
{
    class Program
    {
        static void wait(int time) {
            Thread.Sleep(time);
        }
        static void Main(string[] args)
        {
            boolean loop = true;
            if (loop) {
                Console.WriteLine("Please enter your expression below! Each term should be separated by a space.");

                string expression = Console.ReadLine();

                expression = expression.Split(" ");

                if (expression[1] == "+") {
                    Console.WriteLine(Int16.Parse(expression[0] + Int16.Parse(expression[2])));
                }
            }
        }
    }
}
#

and Argument 1: cannot convert from 'char' to 'System.ReadOnlySpan<char>' still

#

oh

#

i know what i did

#

whoops

scenic kelp
#

you're still comparing to a string as well as overwriting expression somehow which is not doable

drifting wedge
#

i fixed it

#

string[] expressionArray = expression.Split(" ");

#

tho it adds the strings

#

not the ints

#

even though i int parse it?

scenic kelp
#

you're adding a string to an int in the intparse

#

should be intparse(1) + intparse(2)

#

not intparse(1 + intparse(2))

drifting wedge
#

oh lol

#

it was a mistek

#

typo

#
                if (expressionArray[1] == "+") {
                    int output = Int16.Parse(expressionArray[0]) + Int16.Parse(expressionArray[2]);
                }

                Console.WriteLine(output);``` and it says output doesnt exist in current context?
#

do i need to set output as "" above?

scenic kelp
#

you define output in the if

drifting wedge
#

i got it working lol but int16 is too small

#

yepo

#

fixed it

scenic kelp
#

use int32 or 64 yeah

drifting wedge
#

like does int64 work better?

#

yeah alr

scenic kelp
#

no reason to use 16

drifting wedge
#

is 64 weird?

#

for you?

scenic kelp
#

why would it be weird

drifting wedge
#

cuz 64 gives some errors 32 doesnt

scenic kelp
#

what errors

drifting wedge
#

1 sec

#

Cannot implicitly convert type 'long' to 'int'

#

when 65

#

64*

#

when 32 it works fine

scenic kelp
#

because you store it in an int

drifting wedge
#

wdym?

scenic kelp
#

you can't convert a long to an int implicitly because you're losing precision

drifting wedge
#

whats a long?

scenic kelp
#

64 bit int

drifting wedge
#

oh okay

#

a 32 is medium?

#

and 16 smoll?

scenic kelp
#

int is 32 bit

boreal iron
#

You would call it bigint in js

drifting wedge
#

when i specify an int by default its 32?

scenic kelp
#

no

#

bigint is arbitrary precsion

#

@drifting wedge yes int is always 32

drifting wedge
#

oh okay cool

scenic kelp
#

in js all numbers are doubles

drifting wedge
#

so how can i make it work?

scenic kelp
#

bigints can store literally any intege

drifting wedge
#

if 64 is a long?

scenic kelp
#

store it in a long

drifting wedge
#

oh

#

isntead of int?

#

its a long?

scenic kelp
#

ye

drifting wedge
#

cool

#

c# is weird man

scenic kelp
#

the reason why you can implicitly convert a 16 bit int to a 32 bit int i because you cannot lose precision

drifting wedge
#

do longs have any limits?

scenic kelp
#

64 bit integer

drifting wedge
#

64 chars?

quartz kindle
#

no

drifting wedge
#

digits*

scenic kelp
#

64 bits

#

a bit is a 0 or a 1

drifting wedge
#

isnt a digit a bit?

scenic kelp
#

no

quartz kindle
#

8 bits is up to 255

drifting wedge
#

oh

quartz kindle
#

16 bits is up to 64k

scenic kelp
#

2^64-1

quartz kindle
#

32 bits is up to ~4 billion

#

etc..

drifting wedge
#

geez okay

scenic kelp
#

plus it's signed so

drifting wedge
#

so i cant do like 10 billion + 5 billion?

scenic kelp
#

on a long ye

quartz kindle
#

no

scenic kelp
#

on ints no

drifting wedge
#

longs are 64 bits?

scenic kelp
#

ye

drifting wedge
#

oh

quartz kindle
#

in some languages, long is 32 bit for some reason

drifting wedge
#

i misread tims thing

scenic kelp
#

cpp moment

quartz kindle
#

yes

#

cpp long is 32 bit

#

for 64bit you have to do long long

#

lmao

scenic kelp
#

cpp has long long

#

lmfao

drifting wedge
#

1.8446744e+19 this isnt long enough

#

it cant even measure my pp size

#

you think itll work for my codebase

#

?!?!?

scenic kelp
#

i think c# has arbitrary precision ints as well

quartz kindle
#

each bit doubles the capacity size

drifting wedge
#

oh

#

thats cool

#

coding is cool

quartz kindle
#

so if 32 bit is 4 billion, 33 bit is 8 billion

#

and so on

drifting wedge
solemn latch
#

looking into binary math is fun 👀

scenic kelp
#

c# has BigIntegers

drifting wedge
#

is it possible to get more than a64 bit?

#

or like do i need complicated stuff?

scenic kelp
#

yeah but BigInteger arithmetic is slow

#

your processor is good at normal ints

solemn latch
#

most computers are 64 bit, going above 64 bit and its slow 👀

quartz kindle
#

some systems support native 128 bit numbers, buts its rare

scenic kelp
#

unless you got a damn supercomputer

drifting wedge
#

no syntax errros

#

lets gooo

shy turret
#
            body {
                margin: 0px;
            };

            #screen {
                max-width: 100%;
                max-height: 100vh;
                margin: auto;
                height: 100%;
                display: grid;
            };

why does body's margin: 0 break the grid

quartz kindle
#

LOl

drifting wedge
#

margin auto wont work

#

i think

#

and body try setting it to none?

scenic kelp
#

any more c# qs while i'm here?

drifting wedge
#

also maybe this is just for me but use classes and not ids

quartz kindle
#

yes

#

why is c# weird

drifting wedge
#

i usually reserve ids for the js

#

and use classes for css

shy turret
#

if i remove the body, it works, but there's a scroll bar and a black space on the top

#

let me get my whole html code

quartz kindle
#

and does c# still need glasses

scenic kelp
#

how is c# weird

drifting wedge
#

alr

shy turret
#
<html>
    <head>
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <style>
            #screen {
                max-width: 100%;
                max-height: 100vh;
                margin: auto;
                height: 100%;
                display: grid;
            };
        </style>
    </head>

    <body style="background-color: black;">
        <video autoplay id="screen">
            <source src="yay.mp4" type="video/mp4">
        </video>
    </body>
</html>
scenic kelp
#

no c# sees sharp

shy turret
#

removing the body style will

scenic kelp
#

i personally love c#, it's super flexible

shy turret
#

wait what

#

the scrollbars are gone now...

#

.-.

#

ill take it

final lynx
#

?

#

this is a ban cmd, does anyone know how i could use this to make a un-ban command

#

would i just make this unban?

scenic kelp
#

well no because member wouldn't exist

final lynx
#

thats the problem

#

so i would need to change "member" values

#

to a discord user

#

and then make it unban?

lyric mountain
#

It's slight harder to make an unban than it is to ban

final lynx
#

ya, i knew that

lyric mountain
#

Can't u just start with simple stuff like ping, 8ball, choose, uptime, etc?

final lynx
#

i guess

lyric mountain
#

Why jump right into non-starter stuff?

final lynx
#

well i cant really tell my self if its started or non-started

#

i just have to try then find out

lyric mountain
#

You're definitely a newbie

#

Starter-level

final lynx
#

ik lol

lyric mountain
#

So start with easy stuff

final lynx
#

what should i start with

lyric mountain
#

Generic stuff like ping, uptime, 8ball, choose, say, repeat, etc

final lynx
#

ok

boreal iron
#

Learning an experimenting with JS basics and some easier commands after

final lynx
#

ill just go to the discord.js website

lyric mountain
#

No

final lynx
#

i meant

#

the lessons

lyric mountain
#

Don't look for examples about that

#

Use the documentation for method reference

final lynx
#

you dont think i should do lessons

lyric mountain
#

And think

final lynx
#

ya

#

and learn functions

#

and what-not

boreal iron
#

You need to learn the JS basics before you’re able to understand the docs

final lynx
#

ya

#

ill do that

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

quartz kindle
#

do you have to c# to know c#?

#

are people who need glasses banned from using it?

boreal iron
#

Guess he was in a desperate situation okeh

boreal iron
#

That’s our sad world...

lyric mountain
boreal iron
#

Aye probably the best example

dawn needle
#

Is there anywhere I could get more people using my bot?

lyric mountain
#

Friends

dawn needle
#

Yea

lyric mountain
#

Then friends of friends

dawn needle
#

91 servers are using it so far

lyric mountain
dawn needle
#

Not yet

lyric mountain
#

Submit then

dawn needle
#

Ima do it tomorrow

lyric mountain
#

Do today

#

The earlier you do the earlier you get reviewed

#

Remember that it takes 2+ weeks

scenic kelp
dawn needle
#

I can’t get guild info

lyric mountain
#

What guild info?

dawn needle
#

For servers

lyric mountain
#

I know, but what info?

sage bobcat
#

One message removed from a suspended account.

dawn needle
#

I’d

lyric mountain
#

Enable developer mode for discord

scenic kelp
#

also @drifting wedge since i'm here i'll complain about your code again

lyric mountain
#

It's under appearance menu

dawn needle
#

Ok

scenic kelp
#

You should use Int32/Int64.TryParse instead of Parse. TryParse takes in the value as well as an output value and returns a boolean if the value was successfully parsed to the value, in which case you can access it in the out variable you passed to it

#

if you try to parse a non-int value it'll probably throw some sort of error

grizzled raven
#

does the guild emojis intent being disabled still allow you to receive guild emojis with the guild packet?

shy turret
#
  win.on('focus', (event) => {
    electronLocalshortcut.register(win, ['CommandOrControl+R','CommandOrControl+Shift+R', 'F5'], () => {
      console.log(1)
    });
  });

... still googling how would you prevent reloads on electron

final lynx
#

(my prefix is () )this is a remove message script. I didnt make the OG version but, it didnt work. This one doesnt work either but, when I type ()Clear then put a number, it just says "Not a valid amount" and if i just put ()Clear then it says the same thing. There are no errors in the terminal or debug console. can anyone help me find out why

quartz kindle
#

console.log(args) and you'll see why

final lynx
final lynx
quartz kindle
#

do you know what console.log is?

final lynx
#

i do

#

there are no errors or logs tho

#

it just says

#

complete

quartz kindle
#

thats why i said to use it

shy turret
#

in the next line

#

add

#

console.log(args)

final lynx
#

ok

shy turret
#

and see what it says on the console

dawn needle
#

Hey @lyric mountain I added it

#

And found the info

#

Thanks

lyric mountain
#

Now u gotta wait

dawn needle
#

LOL

#

Yea

lyric mountain
#

And make sure it's 99% functional

#

But most importantly

#

Keep it online

dawn needle
#

There are no bugs

#

It’s 24/7

agile lance
#

How can I make my bot be like: "Type i just play stupid games as your job today!" and have the person respond after?

#

Lib: Discord.js

#

v12.5.1

lost mirage
#

use awaitMessages like msg.channel.awaitMessages()

earnest phoenix
#

In client.on('voiceStateUpdate', (oldMember, newMember) => { } how do I get the oldMember voice channel's name?

feral skiff
#

Before isNaN put a !

agile lance
lost mirage
#

nah it would look smth like

const filter = res => {
  if (res.author.id !== msg.author.id) return false;
  if (res.content.toLowerCase() !== "i just play stupid games") return false;
  return true;
}
const filtered_msg = await msg.channel.awaitMessages(filter, { max : 1, time: 60000} );
if (!filtered_msg) return console.log("I didn't receive anything the suits my filter!");
msg.channel.send("You successfully earned $13500!");
// add money to db
agile lance
#

And how would I make sure the message it waits for is the author of the work command?

#

o jesus

lost mirage
#

so the filter basically makes sure its the author of the work command

#

and it also checks if the content of the message is equal to whatever u want

agile lance
#

so, after it finds that message being sent, how do i make it respond with something and then make it add money to the db?

#

oh ok, thanks :D

boreal iron
lost mirage
boreal iron
#

anything is wrong with his code... if(amount < 1 || amount < 100) ...
but he's refusing to learn the js basics or in general coding basics at all

agile lance
#

@lost mirage that code works but even if they dont respond it works

#

it pays still no matter what

#

code:


module.exports = {
  name: 'work',
  run: async(client,message, args) => {
    let msg = message
    let discord = require('discord.js')
    let db = require('quick.db')
    let b = 'bal'+message.author.id
      let w = ['i play stupid video games', 'i work for the idiot department']
  let WR = w[Math.floor(Math.random() * w.length)]
 msg.reply('You are currently working for $13500. Please type: `'+WR+'`\n\n\n*You have 25 seconds to type this phrase.*')
  const filter = res => {
  if (res.author.id !== msg.author.id) return false;
  if (res.content.toLowerCase() !== WR) return false;
  return true;
}
const filtered_msg = await msg.channel.awaitMessages(filter, { max : 1, time: 20000 } );
if (!filtered_msg) return message.reply('You did not respond in time with the required phase. Enjoy $0 loser.')
msg.channel.send("You successfully earned $13500!");
return db.add(b, 13500)
  }
}

lost mirage
#

bro

#

u cant just copy and paste code without understanding it

pale vessel
#

It's if (!filtered.first())

lost mirage
#

i used the variable msg instead of message

pale vessel
#

It returns a collection of messages

boreal iron
lost mirage
#

-_-

pale vessel
#

An empty collection is always truthy

#

you following me bro?

lost mirage
#

i mean its works the first way so

agile lance
lost mirage
#

the shorter the better :)

#

bro ur variables

agile lance
#

never used a filter-

lost mirage
#

change msg to message

#

actually nvm i didnt read

pale vessel
#

or if (!filtered_msg.size)

lost mirage
#

let msg = message -_-

pale vessel
#

that's as short as it can get

lost mirage
#

nah

agile lance
#

lol

lost mirage
agile lance
#

im just lazy tbf

lost mirage
#

types are important

#

u said if (res.content.toLowerCase() !== WR) return false;

#

ofc it wnt work bc u need a string

#

if (res.content.toLowerCase() !== "WR") return false;

agile lance
#

uhm

pale vessel
#

I also suggest using WR.split("").join("\u200b") like Dank Memer so that people can't copy paste

agile lance
#

WR is a areay

#

array

#

Wait no

pale vessel
#

No, w is array

agile lance
#

w is a array WR is a random index from the array

#

so doing "WR" will make them be required to type WR

lost mirage
#

its prob that

pale vessel
#

it IS

lost mirage
#

smh im dumb

pale vessel
#

you can't boolean a collection like that, it'll always return true making it pass

lost mirage
#

plz no booli

agile lance
#

just a simple mistake

dense surge
#

Can someone give me the code for where I put my bot token in?

river panther
#

@lone rune

#

who this?

lone rune
river panther
#

umm, oh, you are not a bot, nothing, nvm

lone rune
#

i'm not, but you need help with something?

dense surge
#

I do.

river panther
#

no no

#

oh

#

what?

dense surge
#

I do.

river panther
#

what?

#

with what?

#

-data

#

-datoa

dense surge
#

I need help with the start of the coding like where the bot token and stuff.

river panther
#

show the code
show the error
and i will explain

dense surge
#

I start of with my client.login("bot token")

#

But I don't know what comes before or next

river panther
#

-.-

dense surge
#

I'm a beginner

river panther
lone rune
river panther
dense surge
#

And your satus

river panther
#

not the status

#

i can also put a status like that

agile lance
#

rich presence isnt hard to do

river panther
#

see

solemn leaf
#

everyone just copying erwin isnt that lovely

#

poor erwin

river panther
#

no no

solemn leaf
#

gets their ideas stolen

lone rune
solemn leaf
#

poor poor erwin

river panther
#

i saw it in the developer server

solemn leaf
#

f in chat for erwins ideas

dense surge
#

The status

lone rune
agile lance
#

Rich Presence ._.

river panther
solemn leaf
#

is that a self bot bot

lone rune
lone rune
agile lance
#

i clicked 'users' and it didnt work

lone rune
#

oh

lone rune
crystal wigeon
#

discord fkin shards are weird af wtf

#

idk why but it kept spam DM-ing the same user when other people voted

#

like tf

#

i restarted and everything went back to normal

#

i checked for shard crash logs and nothing

earnest phoenix
#

Possible memory leak detected
What's this? It's my first time encountering this issue.

feral aspen
#

Wtf is this.

#
"fs": "0.0.1-security",
#

An npm having that version

earnest phoenix
#

Well, fs is a native package so that might be the reason, no idea about that really

scenic shale
#

is it possible to know how many servers my bot is on?

earnest phoenix
scenic shale
#

none in particular to accomplish this ... I thought it was possible to do it on the site

earnest phoenix
#

Wut, you want to display the amount of guilds your bot is in, in the site?

scenic shale
#

I don't need it to show on the site, I thought the site itself had this function ... I was just curious to know how many servers my bot has, do you recommend any library for that?

opal plank
#

as i mentioned ebfore, you can use oauth

earnest phoenix
#

monkaHmm You get the amount of guilds your bot is in by whatever library your bot was made with, not anything else, the site can't get the info of how many guilds the bot is in unless you post them, and a library is basically discord.js, discord.py, eris, discord-rose, detritus, discordgo, discord-net, serenity, etc etc

opal plank
earnest phoenix
#

You can also use the raw API to get that information, without the need of libraries

opal plank
#

oauth gives you the estimate of guilds

#

not precise, mind you

#

for a precise count you'd need your bot's token or a proxy

#

then you'd need to use the gateway to fetch your guildCount

#

@scenic shale

scenic shale
earnest phoenix
gritty lintel
#

hi where can i do that coding stuff

#

can i get the link

dusky sundial
#

What kind of coding?

gritty lintel
#

discord bot

dusky sundial
#

In what language are you making your bot?

gritty lintel
dusky sundial
#

No, what programming language?

gritty lintel
dusky sundial
#

Well, I wouldn't recommend a bot to be your first project. But either JavaScript or Python is usually good for beginners.

earnest phoenix
#

You can use whatever programming language you want, but I recommend learning the basics of that specific programming language before attempting to make a bot

gritty lintel
#

now is there any specific link for that

earnest phoenix
#

If you're gonna use Python, do you know it's basics/fundamentals?

dusky sundial
earnest phoenix
#

Then go ahead and have a look at discord.py's documentation which is a discord bot library you can use

earnest phoenix
#

Spaxter already sent the link

gritty lintel
#

okay

spiral tinsel
#

Is anyone able to provide me the API that allows you to update "<value> Servers"

cyan hollow
#

what is the support server of discord.js

spiral tinsel
#

Yes but where within the API?

#

I can't find it.

#

Sorry.

dusky sundial
spiral tinsel
#

Discord.js

#

Well javascript

dusky sundial
spiral tinsel
#

Ah I see

#

Thanks for the help.

dusky sundial
#

No worries, you can use #topgg-api for any further questions about it

spiral tinsel
#

When should I post stats?

#

Oh

#

oops

#

Ill go there now

sudden linden
#

please when will my bot be sent :(

old cliff
#

you should change your bot's pfp

#

or it might get denied

old cliff
earnest phoenix
earnest phoenix
#

Eris.js or d.js

cinder patio
#

whichever one you like more

pale vessel
#

deeeetriiiitussssss

#

sends the memory usage difference image

#

also sends their support server invite

cinder patio
#

😩 detritus is kinda good though]

sudden linden
#

it's taking too long bro

paper pilot
#

how to make a slash command on djs tho

old cliff
paper pilot
willow mirage
#

Anyone know how to make google form post an HTTPS request to my express server?

earnest phoenix
earnest phoenix
old cliff
#

even djs 11 allows that

cinder patio
#

yeah djs also allows you to selfbot

#

but all selfbot methods are removed in v12

willow mirage
#

not i make request to google form

#

they make request to my server

old cliff
#

use html

#

for form

#

google doesn't send data to some third party servers

willow mirage
#

smh

scarlet stratus
#

It's interesting ngl

earnest phoenix
#

does anybody know how to make a join/leave vc command in discord.py

crystal wigeon
#

imgur images dont load on djs embeds?

old cliff
crystal wigeon
#

its not working tho

lusty quest
earnest phoenix
#

hm

lusty quest
restive wagon
#

does anyone know how to add ssl for db connections for node js postgres sequelize

#

due to the heroku recent update my insecure database connection without ssl is now rejected and my bot cant connect to my database

earnest phoenix
#

in java, for my mc server to db connection i had the same problem but in that case all i had to do was append autoSSL=false to my connection string

#

Correction

#

verifyServerCertificate=false and useSSL=true

restive wagon
#

ok so the thing is i found online guides telling me to add ssl: true somewhere but i cant find it, let me post some screenshots

earnest phoenix
#

Add that to your connection string

restive wagon
#

so in my main.js i have this line

#

so i go to models > index.js and open the file

#

am i on the wrong file?

#

@earnest phoenix could you please take a look thanks

earnest phoenix
#

Show me your config file

#

blur out parts if you need

gentle drum
#

yeah do that but remove the token lmao

#

obvio

restive wagon
feral aspen
#
module.exports = async (bot, guild) => {

    if(!guild.me.hasPermission(["SEND_MESSAGES", "EMBED_LINKS"])) return;
    
    if(guild.name === undefined) return;

    const embed = new MessageEmbed()
    .setColor(red)
    .setTitle("Attitude was Removed from a Server")
    .setThumbnail(guild.iconURL({ size: 2048 }))
    .addField("Server Name", `${guild}`)
    .addField("Member Count", guild.memberCount)
    .addField("Attitude is now in", `${bot.guilds.cache.size} servers!`)

    return bot.channels.cache.get("780712801961902100").send(embed);
};

cannot read property hasPermission of null

earnest phoenix
restive wagon
#

no its been like that since the start, it actually worked since last year when i launched it, but few weeks ago heroku changed their stuff and blocked non-ssl database connections which caused my connection to not work

earnest phoenix
restive wagon
#

my heroku app looks like that, an app with a postgres add-on

earnest phoenix
#

let me see

#

You should use this format postgres://user:pass@example.com:5432/dbname and then postgres://user:pass@example.com:5432/dbname?verifyServerCertificate=false&useSSL=true

feral aspen
earnest phoenix
#

Precisely new Sequelize('postgres://user:pass@example.com:5432/dbname?verifyServerCertificate=false&useSSL=true')

earnest phoenix
feral aspen
#

Oh alright.

earnest phoenix
#

Intents have nothing to do with that

feral aspen
earnest phoenix
#

You have to show more code but supposedly what youre replacing is null

#

The owner of the guild is not always cached, you have to fetch it @feral aspen

earnest phoenix
#

the url is what you need

#

and to that append what i said above

restive wagon
#

sorry im quite bad at databases and its concepts, might need some spoonfeeding help

#

alright lemme do it and screenshot again

earnest phoenix
#

You should just try new Sequelize('url?verifyServerCertificate=false&useSSL=true')

restive wagon
#

is this right

#

wait actually do i not need the password and stuff

earnest phoenix
#

password and stuff is already inside the url

restive wagon
#

oh ok

#

i'll try running it now

earnest phoenix
#

CPU goes brrrrrrr sometimes LUL

#

They're grooving

restive wagon
#

@earnest phoenix seems like the problem is not fixed yet

modern swallow
#

Hey does anyone know of a bot that can post a message when someone receives a specific role? Not a welcoming bot because it can do it at anytime this role is given not just joining

carmine summit
#

does forEach do things one at a time? (1212121212)

#

or multiple at a time? (1111122222)

restive wagon
#

ok so the error message produced in the log when using the url?verifyServerCertificate=false&useSSL=true is the same as the original error which is:
(node:4) UnhandledPromiseRejectionWarning: SequelizeConnectionError: no pg_hba.conf entry for host "54.224.223.52", user "iqezzwhocrduzj", database "d1geqa245p50dm", SSL off

but i looked up a solution on stack overflow which told me to do url?ssl=true now i get this error:
(node:4) UnhandledPromiseRejectionWarning: SequelizeConnectionError: self signed certificate

i guess im on the right path?

carmine summit
#

my forEach is running multiple at a time. Start Start End End.

#

I want to make it run only one at a time, and only start another one if the current one is finished

#

Start End Start End

pale vessel
#

use a for loop then

carmine summit
#

ok thanks, worked perfectly

restive wagon
#

oh i found the solution @earnest phoenix thanks for your help on navigating the chunk of code to modify else i wouldnt know where to add it

sudden linden
slender wagon
#

what's the best discord library i should use if my bot suddenly goes brr

#

like to make it lighter

old cliff
#

depends

robust moth
#

u have bot ideas?

quartz kindle
#

for which language? @slender wagon

narrow oracle
#

hi guys, im searching someone that wants to make a economy system for me. dm me for info ( i can pay in paypal and cashapp )

sick fable
#

bobs

slender wagon
#

sorry for late reply didn't saw the ping

quartz kindle
#

if you want to make your bot lighter, look into libraries that allow you to disable what your bot doesnt need, more specifically caching

#

detritus, discord-rose and discord.js-light allow you to do that, there might be more

slender wagon
#

okay ty! 🙂

marble juniper
#

discord.js-light is the best one out of that list

#

<3

river panther
#

detritus

#

is the best

#

even tim agrees

marble juniper
#

discord.js-light

#

is the best

river panther
#

no

tulip ledge
#

Hello, I've been struggling with this issue for a couple hours now and finally gave in down here I have a function (previously made by Tim)

function test(data = [{ itemid: "2", amount: 1 }, { itemid: "1", amount: 2 }], string = "1:4,2:3") {
    let array = string.split(",");
    for(let d = 0; d < data.length; d++) {
        for(let i = 0; i < array.length; i++) {
            if(!array[i].startsWith(data[d].itemid+":")) { continue; }
            let [key,value] = array[i].split(":");
            array[i] = `${key}:${parseInt(value)+data[d].amount}`;
            break;
        }
    }
    return array.join(",");
}

What this essentially does is it adds the amount to the id in the string eg this function will return: "1:6,2:4" as it's adding the amount of each index in the data array to it's itemid in the string, now when I add something with an index like this: {itemid: 3, amount: 1} in the data for example it doesn't return "1:6,2:4,3:1" like it's supposed to but just returns "1:6,2:4 anyone knows why?

river panther
#

what is this?

#

what does it do?

tulip ledge
#

read what I said

river panther
#

i am layz

#

someone else shall help you 👍

#

don't loose hope

quartz kindle
grizzled raven
#

it seems you need to add it to the string as well

quartz kindle
#

it doesnt look for new values in the data

tulip ledge
#

how would I make it so it adds new values?

quartz kindle
#

it has to be rewritten to work the other way around

#

go over the values in the data, and look for existing values in the string

tulip ledge
#

well fuck

#

I have no clue how tho lol

quartz kindle
#
for(let item of data) {
  let [key, value] = Object.entries(item);
  if(!string.indexOf(key)) {
    string += `${key}:${value}`;
  } else {
    let startIndex = string.indexOf(key);
    let endIndex = string.indexOf(",", startIndex);
    if(endIndex === -1) { endIndex = string.length; }
    let piece = string.slice(startIndex, endIndex);
    let existingValue = Number(piece.split(":")[1]);
    string = string.replace(piece, `${key}:${existingValue + value}`);
  }
}
#

something like that should do

tulip ledge
#

This returns itemid,3:NaNamount,24:1

rocky hearth
#

Where can I see the source code of djs

quartz kindle
#

change let [key, value] = Object.entries(item); to let key = item.itemid; let value = item.amount

quartz kindle
tulip ledge
#

itemid,4:NaNamount,1itemid,3:NaNamount,24:1

rocky hearth
#

yeah but on github, it is written in js.
Isnt this lib written in ts?

quartz kindle
#

no?

#

djs is not ts

grizzled raven
#

hint: discord.js

quartz kindle
#

djs-next will be written in ts

#

detritus is written in ts

#

djs, eris, etc.. are all in js

quartz kindle
sage bobcat
#

One message removed from a suspended account.

quartz kindle
#

/hug

tulip ledge
#
function test(data = [ { itemid: '3', amount: 2 }, { itemid: '4', amount: 1 } ], string = "4:1") {
    for(let item of data) {
        let key = item.itemid; 
        let value = item.amount;
        if(!string.indexOf(key)) {
          string += `${key}:${value}`;
        } else {
          let startIndex = string.indexOf(key);
          let endIndex = string.indexOf(",", startIndex);
          let piece = string.slice(startIndex, endIndex);
          let existingValue = Number(piece.split(":")[1]);
          string = string.replace(piece, `${key}:${existingValue + value}`);
        }
      }
      return string;
}
quartz kindle
#

if(!string.indexOf(key + ":"))

#

let startIndex = string.indexOf(key + ":");

#

if(endIndex === -1) { endIndex = string.length; } right after endIndex

tulip ledge
#

4:3:NaN I don't think this is right

exotic galleon
#

How should I prepare an article for the opening of your existence and throw it on the disc?

quartz kindle
#

????

pale vessel
quartz kindle
tulip ledge
#
function test(data = [{ itemid: "2", amount: 1 }, { itemid: "1", amount: 2 }], string = "1:4,2:3") {
    for(let item of data) {
        let key = item.itemid; 
        let value = item.amount;
        if(!string.indexOf(key + ":")) {
          string += `${key}:${value}`;
        } else {
          let startIndex = string.indexOf(key + ":");
          let endIndex = string.indexOf(",", startIndex);
          if(endIndex === -1) { endIndex = string.length; }
          let piece = string.slice(startIndex, endIndex);
          let existingValue = Number(piece.split(":")[1]);
          string = string.replace(piece, `${key}:${existingValue + value}`);
        }
      }
      return string;
}

console.log(test([ { itemid: '3', amount: 2 }, { itemid: '4', amount: 1 } ], "4:1"))
quartz kindle
#

if(!string.includes(key + ":")) {

tulip ledge
#

Now it returned 4:14

cinder patio
#

lemme make my own version

rocky hearth
#

what is the meaning of this in a static method? Does it points to the static members of the class? (in js)

cinder patio
#

yes

quartz kindle
cinder patio
#

it's the class itself

tulip ledge
#

string = string.replace(piece, ${key}:${existingValue + value}); here?

cinder patio
quartz kindle
#

no, in the string.includes

tulip ledge
#
string.split(",").map(i => items.find(item => item.itemid === i.split(":")[0]) ? i.split(":")[0] + ":" + (parseInt(i.split(":")[1]) + items.find(item => item.itemid === i.split(":")[0]).amount) : i).join(",");

This is what I had at first, but Tim made a faster version and this version uph ere has the same issue so I looked in a file where I saved that function and used that one instead but it appears it has the exact same issue

quartz kindle
#

thats not what he means

tulip ledge
#

Oh

quartz kindle
#

he means using new Map() and setting the data there

#

instead of array of objects

#

or one big object instead of array of objects

tulip ledge
#

idk

quartz kindle
#

anyway did you add the comma? it should work now

tulip ledge
#

but it works now although 1 small thing if I put the string to "" it returns: ,3:2,4:1 how would I remove the first comma?

#

can I just do string.length <= 0 ? string += ${key}:${value}: string +=,${key}:${value};?

#

Yeah that works

#

alright tyvm Tim! 😄

quartz kindle
#

string += `${string ? "," : ""}${key}:${value}`
tulip ledge
#

ty 😄

cinder patio
#

Instead of doing... that you can simply change the data structure you're storing the items in and make your code cleaner and probably faster

final lynx
#

so this is the working remove messages command, but if i type anything that starts with the prefix, it clears messages. Does anyone know why?

quartz kindle
#

because you're not checking for the command

#

this line is not doing anything

final lynx
quartz kindle
final lynx
#

where should i put it to make it read the command instead of the prefix

quartz kindle
#

that line says "if the message starts with prefix plus RemoveMessages, do nothing"

#

aka, continue the code like nothing happened

final lynx
#

should i connect it with a ;

quartz kindle
#

no

final lynx
#

or put the rest of the code into a {}

quartz kindle
#

yes

final lynx
#

ok

#

thanks

umbral zealot
quartz kindle
umbral zealot
#

High praise coming from Tim hugguspoon

quartz kindle
#

<3

final lynx
#

awit

#

rly quickly

#

now there is a error at the end

umbral zealot
#

Then you didn't wrap it correctly

final lynx
#

there are 5 open {

#

and 0 open (

blissful coral
#

Syntax error

#

Count your ( and {s

#

Make sure you have equivalent closing ones

final lynx
#

thats 5

#

5 {

#

2 }

sage bobcat
#

One message removed from a suspended account.

umbral zealot
blissful coral
#

You need to have 5 } in the correct spots facepalm

sage bobcat
#

One message removed from a suspended account.

final lynx
#

ok i got it

sage bobcat
#

One message removed from a suspended account.

blissful coral
#

I suggest learning js

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

blissful coral
#

And formatting

#

And syntax

umbral zealot
#

Don't just count the things, actually look at how they work and what they do.

sage bobcat
#

One message removed from a suspended account.

blissful coral
#

^

umbral zealot
boreal iron
#

We tried to tell him for 2 days now to learn the JS basics or at least any coding basics. notlikenoot

final lynx
#

i literally

#

am reading

#

the lessons

#

you guys

#

are sending me

#

also

shrewd creek
#

bro whats this

final lynx
#

im mainly using discord bots

#

to learn js

boreal iron
#

You’re still copying code without understanding it.

tulip ledge
blissful coral
#

Don’t make a discord bot to learn js

#

Your skipping every step when you do that

final lynx
pale vessel
shrewd creek
#

any idea what this is i tried to add my bot

tulip ledge
pale vessel
#

TS too

final lynx
pale vessel
#

not just JS

blissful coral
tulip ledge
#

same

shrewd creek
blissful coral
#

Not what it says

pale vessel
#

I don't regret it

final lynx
#

then try again

tulip ledge
#

When you actually start working on other projects then just bots you start to learn alot more of js imo

blissful coral
#

@shrewd creek you have a button on your discord dev portal that is requiring a code grant which you don’t have

#

Disable it there and generate a new link

blissful coral
final lynx
blissful coral
#

No

#

Please stop

shrewd creek
#

ohkay thx bud

final lynx
#

isnt that the invite link

boreal iron
#

No

shrewd creek
#

seems like i was messing with the oauth2 settings

boreal iron
#

Aye

final lynx
#

that link took me to this page

#

b o i

tulip ledge
# final lynx isnt that the invite link

We really appreciate it that you're trying to help, but please if you don't know what you're talking about don't try to you'll put other people on the wrong path

blissful coral
#

This

crystal wigeon
#

is something wrong with dbl??

blissful coral
#

Under the bots tab in the dev portal