#development

1 messages · Page 130 of 1

lyric mountain
#

^

hushed robin
#

btw

#

is putting ; after my code bad?

#

also

lyric mountain
#

the opposite

hushed robin
lyric mountain
#

not putting ; is bad

hushed robin
#

oh

#

why did waffle get angry at my for putting it then

lyric mountain
#

even tho js doesn't enforce

hushed robin
#

he says i put it too much

#

also another question

lyric mountain
#

hard to say without looking at code

hushed robin
#

whats the best way to test my code in a production-like environment

#

bc i am making big changes and don't wanna do bad

lyric mountain
#

making a production-like environment

hushed robin
#

hm

#

but my bot has 230+ trackers

#

that will be a lot of work to make

#

😵‍💫

quartz kindle
#

lmao

proven lantern
#

can you believe we still use the Integer type for application programming

#

insane

#

this is the regex i wrote to parse the fancy new input that tim suggested

    const placementInputNoWhitespace = placementInput.replace(/\s/g, '');
    const teamOrPlayerStrings = placementInputNoWhitespace.match(/(\([^()]*\)|[^\b>]*)/g).filter(a => a);```
hushed robin
#

i don't get how people write regex

#

looks hard

proven lantern
#
'(@ebon shadow @median yoke)(@ebon shadow @median yoke)';
'@ebon shadow @median yoke(@ebon shadow @median yoke)';
'(@ebon shadow @median yoke)@ebon shadow @median yoke';
'(@ebon shadow @median yoke)@ebon shadow <@&456>';```
proven lantern
solemn latch
#

regex is pain, but it works

hushed robin
#

also guys

#

whats the best way to make number that goes up

#

right now i do this but it's kinda akward

lyric mountain
#

so...a generator

#

or autoincrement field

proven lantern
#

you probably want to use a nosql database instead of a legacy sql database

hushed robin
#

no

#

🗿

proven lantern
#

see, it doesn't work the same when you know i'm trolling

hushed robin
lyric mountain
#

yes?

hushed robin
lyric mountain
#

in the database

hushed robin
#

hm

#

i don't see that

#

avaliable for SQLite?

lyric mountain
#
hushed robin
#

hm

#

ok

#

also guys

#

what a good way to convert a string null to an actual null

sharp geyser
harsh nova
#

A string null being an empty string or a string that is "null"?

hushed robin
#

"null"

sharp geyser
#

I’m not even going to ask why you’re doing it like that

hushed robin
#

for some reason with my old code

#

null is being stored in my database as a string

sharp geyser
#

because you told it to?

hushed robin
#

yeah ik that's why i'm trying to fix

rustic nova
lyric mountain
#

again, without code it's impossible to know

sharp geyser
#

^

#

Also you don’t have to save anything in a db if you want it null, fields left empty are by default null

#

Unless you give it a default value

hushed robin
#

well i did this to automatically increment my ids

#

my updated bot code is looking good

lyric mountain
#

that's horribly inefficient

hushed robin
#

bruh

#

how

lyric mountain
#

2 db ops + wrapping resultset + preparing statement + incrementing variable

harsh nova
#

Bro does not use auto increment

proven lantern
#

aws has free hosted database that are nosql

hushed robin
#

???

#

also whats wrong with prepared statments

proven lantern
#

foreign key

#

i believe

#

but sql is no fun

#

or a join

#

idk

#

just use nosql

hushed robin
#

no

#

shush

lyric mountain
sharp geyser
#

his issue isn’t swapping to a new database

quartz kindle
#

sql has funcions to increment numbers without having to get them first

proven lantern
#

you dont need to know sql for nosql

lyric mountain
#

you need to know !sql tho

solemn latch
lyric mountain
#

autoinc is the very first thing u learn basically

quartz kindle
hushed robin
#

oh wait i see

quartz kindle
#

fucking discord using 1.2gb ram for no reason

lyric mountain
#

that wont work for ur case btw

hushed robin
#

so for auto increment do i need to put a value for id?

#

or will it do that itself

solemn latch
harsh nova
#

Discord using more ram than an operating system TrollFace

lyric mountain
solemn latch
#

I had it use 4-5gb once 👀

hushed robin
#

ok

#

let me test this now

#

um what is this

quartz kindle
#

literally closed discord plus chromium and ram went from 90% to 50%

hushed robin
#

when i set mine to auto incredient it created this and won't let me delete

quartz kindle
#

internal sqlite stuff

#

dont mess with it

hushed robin
#

oh wow

#

this is nice

#

it automatically increments

lyric mountain
#

that moment when you find out the gate you were trying to jump is open

hushed robin
#

wow

#

thats a ton

quartz kindle
#

forgot new database()?

ember fiber
#

anyone have an idea about how to make this on bot profile ?

#

Essaie mes commandes : Try my commands

deft wolf
#

Well, you can't

#

Discord add it after some time

#

Like, in my bot it has been added like 2 weeks maybe 1 week after verification

solemn latch
#

IIRC there are some requirements for it to show

deft wolf
#

I didn't count the time exactly

deft wolf
#

To show up like this

earnest phoenix
#

Only verified bots will have it show up

quartz kindle
#

pretty sure you need it to be listed in the discovery thingy for it to appear

deft wolf
#

Hmmm

earnest phoenix
#

How do I enable it? You don't have to do anything! As long as your app is verified and has at least one global slash command, a max of 5 will be displayed in your bot profile automatically.

quartz kindle
#

ah cool

proven lantern
#

i moved my rust code and now intellij is yelling at me

#

i needed to update this manually.

lyric mountain
#

check module settings

hushed robin
hushed robin
#

after a few days it will show up

#

at least it took that long for mine

#

how can I convert true / false into numbers?

#

but also keep null as null

spark flint
#
const value = whatever === null ? null : whatever === 1 ? true : false```
#

idk

#

i have no clue what you mean by convert into numbers

quartz kindle
hushed robin
#

sqlite cannot store booleans

spark flint
#

oh yes

#
const value = whatever === null ? null : whatever === true ? 1 : 0```
quartz kindle
spark flint
#

i am proud to say i have never used sqlite KEKW

proven lantern
#

fact

hushed robin
#

sqlite is so good

#

why don't u like?

spark flint
#

because tim is sane

lyric mountain
hushed robin
proven lantern
#

columnar > relational

earnest phoenix
#

yo my acc got disabled nice

lyric mountain
earnest phoenix
#

and also anyone knows why this ain't working?

#
EmbedX.description += `**${data.replace('.txt','')}:** \`${lines.length}\`\n`
earnest phoenix
#

It should work according to older versions

hushed robin
#

🫠

lyric mountain
#

what is embedx

tulip ledge
#
Argument of type 'HTMLImageElement' is not assignable to parameter of type 'Canvas | Image'.
  Property 'dataMode' is missing in type 'HTMLImageElement' but required in type 'Image'.ts(2345)
index.d.ts(328, 2): 'dataMode' is declared here.

Code:

const img = new Image();
img.onload = async () => {
        ctx.drawImage(img, 0, 0);
        ...
}

anyone knows how I can resolve this typing issue?

lyric mountain
earnest phoenix
#

a user inventory

lyric mountain
#

that "cannot access id" is from the image I sent

#

ur literally assigning a variable to its own iterator during initialization of itself

hushed robin
#

cap

#

maybe

tulip ledge
#

could I just type cast it

#

imma try that

quartz kindle
proven lantern
hushed robin
#

JavaScript is so good

lyric mountain
#

no

#

TRACK_COMPAT_MODS is a string or contains strings?

#

that contains strings buddy

#

anyway, what's the issue?

#

consider that idk how forge works internally, nor how to check for mods

#

aight, what u want is TheClass.valueOf(mod.toUpperCase())

#

do note tho

#

it must be a perfect match

#

else it'll error

#

so biomesoplenty != BIOMES_O_PLENTY

quartz kindle
#

with a shit ton of ai-powered stuff

earnest phoenix
lyric mountain
#

u didn't show the error

earnest phoenix
#

there you go

#

(node:4868) ExperimentalWarning: stream/web is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
App is running, server is listening on port  5000
 06/14 19:51:37   info    I am logged in as GenBot#3237 to Discord!
/home/runner/Generator/node_modules/@sapphire/shapeshift/dist/index.js:47
    throw this.error;
    ^

CombinedError: Received one or more errors
    at UnionValidator.handle (/home/runner/Generator/node_modules/@sapphire/shapeshift/dist/index.js:1104:23)
    at UnionValidator.parse (/home/runner/Generator/node_modules/@sapphire/shapeshift/dist/index.js:212:88)
    at EmbedBuilder.setDescription (/home/runner/Generator/node_modules/@discordjs/builders/dist/index.js:316:26)
    at /home/runner/Generator/commands/pstock.js:33:12 {
  errors: [
    ExpectedValidationError: Expected values to be equals
        at LiteralValidator.handle (/home/runner/Generator/node_modules/@sapphire/shapeshift/dist/index.js:745:76)
        at LiteralValidator.run (/home/runner/Generator/node_modules/@sapphire/shapeshift/dist/index.js:198:23)
        at UnionValidator.handle (/home/runner/Generator/node_modules/@sapphire/shapeshift/dist/index.js:1099:32)
        at UnionValidator.parse (/home/runner/Generator/node_modules/@sapphire/shapeshift/dist/index.js:212:88)
        at EmbedBuilder.setDescription (/home/runner/Generator/node_modules/@discordjs/builders/dist/index.js:316:26)
        at /home/runner/Generator/commands/pstock.js:33:12 {
      validator: 's.literal(V)',
      given: '',
      expected: null
    },
    ExpectedConstraintError: Invalid string length
        at Object.run (/home/runner/Generator/node_modules/@sapphire/shapeshift/dist/index.js:1546:79)
lyric mountain
#

you likely can't .description +=

earnest phoenix
#

not anymore?

lyric mountain
#

well, if it's erroring then I think so

#

since which version u had that line?

quartz kindle
#

idk why people use sapphire, it produces such garbage errors that make no sense

rustic nova
#

lemme just share this cool glowy thing im proud of

earnest phoenix
rustic nova
#

pogu glow yes

quartz kindle
#

dynamic is da wae

#

stuff like jsfuck is what makes js great

#

and being able to hack prototypes at runtime

earnest phoenix
hushed robin
#

how do i set an option to autocomplete

proven lantern
earnest phoenix
#

it was off till now

#

i started to work on it again now and its erroring

#

managed to change most of the stuff to v14

earnest phoenix
quartz kindle
#

yo

thorny cargo
#

Yo

hushed robin
lyric mountain
hushed robin
lyric mountain
#

Ur editor was supposed to tell you

lyric mountain
hushed robin
#

w0t

lyric mountain
#
switch (blabla) {
    case 1: 
        something();
        break;
    default:
        otherthing();
} 
hushed robin
earnest phoenix
#

Would creating a node.js bot to force approval process of image uploads be feasable?

#

I have no idea what's doable through dev API

proven lantern
thorny cargo
earnest phoenix
#

I mean whenever someone, with image perms, posts an image > Ping admin and wait for approval (Approve/Deny) before it's either posted publicly or deleted

#

@hushed robin

hushed robin
#

I mean

#

it's possible

#

but why

earnest phoenix
#

Did someone do it previously?

hushed robin
#

oh wait

earnest phoenix
#

For a specific usage, my boss wants it

#

because even though some users have image perms

hushed robin
#

i mean it's possible but you can't really like

earnest phoenix
#

go on?

hushed robin
#

reviewn a message

#

like the bot would have to send the image

#

idk if that makes sense idk how to explain it

earnest phoenix
#

and then replace with a placeholde

thorny cargo
earnest phoenix
#

That's what I suggested

hushed robin
#

like u can't stop a user from sending a message, so you would have to delete their message, send it for approval, then send it through the bot

earnest phoenix
#

but you know bosses

thorny cargo
#

Thats a cool module I will add it in my bot ngl

earnest phoenix
hushed robin
#

yes it's possible

earnest phoenix
#
  1. replace with local-only message about "your image is being reviewed)
hushed robin
#

not really difficult either

earnest phoenix
#

I really could use it. Boss'd be happy.

#

I was thinking man, not a bad idea, so I'm thinking about making it myself

solemn latch
earnest phoenix
#

but I've no idea how2

thorny cargo
#

Its just an messageCreate event , check if the command is on . If yes then check for images (maybe also filter role or perm check, so it doesn't delete admins/staff images) . Then it continues with the process

hushed robin
#

yeah u could set the username and picture to the users

solemn latch
#

With a webhook you can set the name and avatar just for that message to the users username.

hushed robin
#

who orginally sent it

solemn latch
#

looks a lot noicer

hushed robin
#

ye

thorny cargo
solemn latch
#

nicer*

earnest phoenix
#

lemme ask chatgpt if he can pop out a node.js discord bot

#

doing that

hushed robin
#

💀

earnest phoenix
#

👼

hushed robin
#

goodluck

solemn latch
#

chatgpt only knows older versions of djs right?

hushed robin
#

yeah

#

doesn't even know v13 i'm pretty sure

earnest phoenix
#

can't I point him to external ressources?

hushed robin
#

actually it may

earnest phoenix
#

e.g. latest docs

solemn latch
#

if you have premium

hushed robin
#

but it doesn't know v14 for sure

solemn latch
#

the $20 a month plan ye

#

otherwise it cant use the web no

thorny cargo
solemn latch
#

It can do psudocode that could be helpful too

#

then its just a matter of reading the docs and understanding the psudocode

hushed robin
#

chat gpt is ok for small code snippets

earnest phoenix
#

I just cant wrap my head around the fact this doesnt exist

hushed robin
#

not really an entire bot

earnest phoenix
#

and isn't in MEE6 or wtv

#

no I know

#

but like

#

MEE6

#

Upload Approval

#

module

#

or something

hushed robin
#

make it yourself and become a billionaire

#

😁

earnest phoenix
#

but diablo4

thorny cargo
hushed robin
#

wait

#

since when could u scroll through emojis while typing

#

is that new

earnest phoenix
#

Jokes aside, if you guys think it would be easy to do, DM me and we can work a paid deal out.

solemn latch
#

Most of it is only a few lines tbh

earnest phoenix
#

dm

solemn latch
#

the most complex part is the database

hushed robin
#

why would u need a database for

thorny cargo
solemn latch
#

Which is pretty basic

solemn latch
solemn latch
#

Unless you plan to store the image within discord; but thats against the dev policy

earnest phoenix
#

or gcp

#

for the swap

thorny cargo
earnest phoenix
solemn latch
#

👀 you delete the image from discord

#

so it needs to go somewhere

hushed robin
#

hm

solemn latch
#

since the files are temporary you may be able to get away with storing it on the filesystem; but meh

thorny cargo
earnest phoenix
#

no?

solemn latch
hushed robin
#

yeah

solemn latch
#

Yeah; thats probably smarter

earnest phoenix
earnest phoenix
#

but would work

#

i think

thorny cargo
earnest phoenix
#

the bot?

#

not the user

thorny cargo
solemn latch
lyric mountain
earnest phoenix
thorny cargo
earnest phoenix
#

ig

#

which again isnt perfect

#

but would work

thorny cargo
#

There's no perfect out there

#

If it works it works

earnest phoenix
#

You tell me

hushed robin
#

webhook with the username and profile picture set as the original users

thorny cargo
earnest phoenix
#

If so I'd like to buy the code

thorny cargo
earnest phoenix
thorny cargo
quiet trench
#

hi

#

How can I make a voting system? when they vote for my bot they can use exclusive commands

eternal osprey
#

is it possible to get the date a certain user got a specific role?

hushed robin
#

maybe through audit logs

clever ore
#

Somebody know where I can found a guy for test my bot ? Like finding bugs

spark flint
hushed robin
#

is this a cleaner way to do all this

#

it works but

#

er

#

@pale vessel

#

why

#

:hmm:

lyric mountain
hushed robin
#

hey kuuhaku

#

do you know?

hushed robin
#

guyssss 🙏

wheat mesa
#

#1 stop using semicolons after non-statements (blocks)
#2 you can simplify your switch statement to be ```js
if (tracker.type === 'favorites') {
path = 'favoritedCount';
} else {
path = tracker.type;
}

#3 don’t use `new Array()`, just initialize it with empty brackets
hushed robin
#

er

#

i need to do this 3 times

#

will kinda look cluttered

wheat mesa
#

there's probably more but that's what I got from first glance

hushed robin
#

KuuHaKu said using them is good

wheat mesa
#

he meant that for statements like console.log("Hello world!"); not {};

hushed robin
#

do u have suggestions on how i can condense the bot more

wheat mesa
#

condense != better codebase btw

lyric mountain
#

Using brackets is good, when they have a meaning

wheat mesa
#

make it efficient and readable

hushed robin
wheat mesa
#

I don’t like how you’re getting guilds and channels from the cache instead of fetching them

#

They’re not guaranteed to be cached

hushed robin
#

they are

#

I have the Guilds intent

wheat mesa
#

That doesn’t guarantee caching of channels

hushed robin
#

yes it does

wheat mesa
#

It does not

hushed robin
#

it does

#

i've been running my bot for a long time with getting the channel from the cache and there's never been a single time a channel hasn't been in the cache

wheat mesa
#

Pretty sure that guilds aren’t guaranteed to be cached either even with the intent

hushed robin
#

bruh

#

yesthey are

wheat mesa
#

Just because something works now doesn’t mean it will work in the future

hushed robin
#

maybe i'll just fetch anyways

#

because it'll check cache first

wheat mesa
#

@lyric mountain are they cached?

#

I haven’t done bots in like a billion years

lyric mountain
#

I think they are always available

#

Guilds

hushed robin
#

with the Guilds intent all guilds and channels are cached

#

yes they are

#

🤦

lyric mountain
#

Talking from JDA experience, it's the only type of entity that has no retrieve method

#

Not really, what's 100k entries in a collection

#

As long as u keep the member count low it shouldn't impact much

hushed robin
#

because you guys don't believe me for some reason

#

and i'm telling u but no listen

#

well

#

waffle wasn't

wheat mesa
#

Battle I don’t take anything you say at face value lmao

hushed robin
#

he thinks i'm wrong

lyric mountain
hushed robin
#

i am a serious person

lyric mountain
#

Iirc, guilds are kept at shard-level

#

So shard 1 will not have the same guilds available as shard 2

wheat mesa
# hushed robin i am a serious person

I believe that which is why it concerns me so much when you ask certain questions that most would believe to be common sense; I do not trust your judgement

#

Hence why I called upon a secondary source here to help me

lyric mountain
#

I'm not a good source tbh, only had top-level experience with jda

#

Tim would be able to say for sure

lyric mountain
#

Exactly that one

hushed robin
#

so

#

about my code again

lyric mountain
#

Our version is slightly different with a tiger instead

hushed robin
#

how can i make it better

#

shorter

lyric mountain
#

But that's what happens when a tiger is more common than wolfs where u live KEKW

hushed robin
#

if i do my current code 3 times there will be 200 lines

#

kinda a lot

#

good idea

lyric mountain
#

Code size is not synonym to code quality

hushed robin
#

but

#

do u think my code is good

lyric mountain
#

No

hushed robin
#

💀

#

how can I improve it

#

bruh

#

this ain’t about typescript

#

it would be the same length or long with typescript

#

i will just become good at JavaScript like Tim

#

so there’s no need for typescript

#

my code above

lyric mountain
#

I'd go with an OOP approach, moving as much processing as possible to inside the class

#

And sieve as much as possible inside the query

hushed robin
#

are you talking to me

lyric mountain
#

Queries are extremely powerful, lots of filtering and transforming can be done before it returns the resultset

#

Yes I was

hushed robin
#

i don't really know what any of that means

lyric mountain
#

Oop means object-oriented programming

#

Basically using classes to handle processing as you would in real life

#

Queries, well, you skipped the entire fundamentals about sql, u didn't even scratch how to build queries

#

Is the code I use for calculating the meta for my game

#

The data is returned ready for use, I don't need to do anything else on java's side

thorny cargo
#

PyThOn fAstEr

wheat mesa
#

I explained it earlier didn't I

#

well I guess I didn't explain it in detail

hushed robin
#

how would classes be used in my code? 🤔

lyric mountain
#

Hardly, if you didn't start with oop in mind it's unfeasible to convert to

frigid epoch
#

I deleted the old version of my bot about a year ago and am working on a new but similar version. My top.gg page shows "Deleted User" as the name. Do I need to delete the bot listing and apply again?

gusty linden
#

As if it's a new application app then it will be classed as a separate id and a whole different bot

frigid epoch
#

got it, thanks

gusty linden
#

K

#

Is it allowed to use a currency for your bot that you pay for to get specific things from your bot that are premium and if you don't want the currency you can exchange it for something like a £5 gift card voucher or discord nitro or something

#

Like you pay irl money for bot currency

#

Like if someone was to go buy 500 coins for £5 they could buy a £5 voucher if they decide nah I won't use this anymore its been a while so I will transfer it for this

thick path
#

Guys how can I fix my websocket error....

rustic nova
#

Damn

#

If only we'd know what error

rustic nova
clever ore
surreal sage
#

When I want to host something on my local server and access it on my ip but my Cloudflare/Nginx/Router configs are set to exactly say fuck that and have to make a subdomain 🔥 9

north cairn
#

hey can someone help me with buttons?
so basically i run the command,the bot responds with the message that has buttons.

now i want like that so that when i click one of the buttons,it sends the same message again and keeps going like this until a no. rolls to 5
For eg-
command- c!bat
message- Full Toss Delivery Is Coming.
Buttons - loft,drive,cut
i click loft,i want it to send same message again(full toss..) with buttons and keeps going like this until a random no.(say 5) rolls

#

i hope i was able to explain well

#

can someone help

lyric mountain
#

You need to write the backing logic entirely, buttons are nothing more than clickable commands

#

Do it as if you were making commands

north cairn
#

thats what i need help with

#

i tried using while

#

doesnt work

lyric mountain
#

You can't use loops

#

You need a handler like you would for commands

#

Then have a persistent "context" to store states

north cairn
#

cant there be a simpler way

lyric mountain
#

This is the simpler way

#

Don't be lazy, fancy features require effort

north cairn
#

u sure u got what i an trynna do?

lyric mountain
#

Yes

north cairn
#

say to confirm u got it

lyric mountain
#

U want an interactive game basically

#

But through buttons

north cairn
#

yea

#

well why i can use loops

#

like while(x!=5) {
return message.reply('stuff")}

lyric mountain
#

First of all, you're using js, so using blocking loops will hang your app

north cairn
#

then what do i do

lyric mountain
#

Second, you can't have an interactive game without states

#

This is not something easily done at first try, you'll need to experiment a bit

north cairn
#

see i got this template of python
it is a handcricket game(not buttons)

lyric mountain
#

Especially if ur used to functional programming

north cairn
#
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
char name[20];
int choice, player, comp, score2 = 0, toss, ts, d, score1 = 0, comp1, player1,
                          num;
void bat() {
  do {
    comp = rand() % 10 + 1;
    printf("%s Enter number from 1 to 10 to score\n", name);
    scanf("%d", &num);
    printf("the no. given by computer is: %d \n", comp);

    if (num > 10 || num <= 0) {
      printf("wrong entry!!! \n");
      continue;
    }

    else if (num != comp) {
      score1 = score1 + num;
      if (d == 2) {
        if (score1 > score2)
          break;
      }
    }

    else if (num == comp) {
      printf("You are out !!\n");
      printf("The score of player 1 is : %d\n\n\n", score1);
      break;
    }
  } while (comp != num)```
#

like he did while

#

cant i do

#

i tried tho,but not working

lyric mountain
#

That's a console app, not a discord bot

#

Apples are not oranges

#

Console apps don't care if they get halted by a blocking loop

#

Bots must handle thousands of users at once

north cairn
#

hm then what do i do nw

lyric mountain
#

Hard to explain if u never did something similar

#

I could show u my game, but it'd make even worse to understand

north cairn
#

explain in short,will try my best to undertsand

lyric mountain
#

Already did

lyric mountain
#

You create a context class to hold states, and act on button press based on it

lyric mountain
north cairn
#

ik this bot will take me ages..

#

but i'll make

lyric mountain
#

Not really, all u need is to grasp the logic

lyric mountain
#

It's a huge logic, don't expect u to understand

#

Just scroll down to getButtons()

#

That's where I make the buttons act based on the current game state

north cairn
#

blown my mind 💀

lyric mountain
#

Yeah, it's a very complex logic

north cairn
#

is ur game complete

lyric mountain
#

Did u ever work with classes?

north cairn
lyric mountain
lyric mountain
#

Not available in english yet, and it's only available on my dev bot for now

#

The production bot isn't in English either

lyric mountain
#

Try learning how to work with classes

#

It's VERY different to functional (the way people write bots in d.js) programming

north cairn
#

hmm

#

have u ever heard about the bot cricket guru

lyric mountain
#

No

north cairn
#

hm i kind of wanna make ike that

#

he made in py

#

tho i only know js

lyric mountain
#

U can make in any lang, u just need to practice

north cairn
#

hm so i first go learn classes u say?

lyric mountain
#

Yeah

#

To sum it up, you need a game instance to track player actions, whenever they press a button u update the state and edit the message from inside it

#

To start the game, all u need to do is create a new game instance and let it act by itself

north cairn
#

yo just searched up a bit
i need create like a storage jar with all the functions inside it
And to start game, i need make object @lyric mountain

#

is that it?

lyric mountain
#

Nono, jar?

#

Jar is for java

#

U need to research how to use classes in js

#

Ah, u mean "storage jar" as in the container

#

Yeah, kinda that

north cairn
lyric mountain
#

For example, imagine I have a car

north cairn
#

start is class
leave a class

u are object
kuu.start

#

so whatever function associated with start will perform

lyric mountain
#

Yes, start would be the initial setup

#

Such as adding button listeners, adding players, initializing variables, etc

#

After that, it should act on its own

north cairn
#

or i define it before

lyric mountain
#

Yes, and you shouldn't need to control it directly

#

Buttons must be intercepted and acted upon by the instance

north cairn
#

pre defined kinda??

#

or i say pre programmmed

lyric mountain
#

Programmed into the instance

#

The easiest project u can attempt to learn how to work this way is by making a pagination feature

#

Like this

lyric mountain
#

Huh, the gif is stopped

north cairn
#

that*

lyric mountain
#

Is it playing for u?

north cairn
#

no

lyric mountain
#

Weird

north cairn
#

check ur code once ig

#

mayb some lil error

lyric mountain
#

There, had to download it

#

This is pagination

lyric mountain
north cairn
#

really*

#

its just like dank marketing page left right

jaunty basalt
#

Hey, anybody know how I can also make this command work with a userID also:

const { EmbedBuilder } = require('discord.js');

module.exports = {
    name: 'avatar',
    aliases: ['av'],

    async execute(message, bot, args) {

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

        if (!user) {

            if (args.length > 0) {
                return await message.reply({
                    content: "![Smike_x_mark](https://cdn.discordapp.com/emojis/1058994007449014293.webp?size=128 "Smike_x_mark") Please mention a valid user!",
                    allowedMentions: {
                        replied_user: false
                    }
                });
            }

            user = message.author;
        }

        let member = await message.guild.members.cache.get(user.id);

        if (!member) return await message.reply({
            content: "![Smike_x_mark](https://cdn.discordapp.com/emojis/1058994007449014293.webp?size=128 "Smike_x_mark") The user mentioned is no longer within the server!",
            allowedMentions: {
                replied_user: false
            }
        });

        let avatar = user.displayAvatarURL({ size: 2048, dynamic: true });

        let embed = new EmbedBuilder()
            .setTitle(`${user.username}'s avatar`)
            .setURL(avatar)
            .setImage(avatar)
            .setColor('#00008b');

        await message.reply({
            embeds: [embed],
            allowedMentions: {
                replied_user: false
            }
        })

    },

};```
#

If yes, then please tell

lyric mountain
#

that's pagination - using buttons for navigating a very big list

#

that uses the same concept as your desired game

jaunty basalt
#

Can you please tell bro?

#

If you know?

lyric mountain
#

simply get the first argument and see if it's a number

north cairn
jaunty basalt
north cairn
lyric mountain
north cairn
jaunty basalt
hushed robin
#

hi

lyric mountain
north cairn
#
if (isNaN(warnno))
      return message.reply("Argument Isn't A Number.")```
hushed robin
#

why can't i loop through games

north cairn
jaunty basalt
hushed robin
#

it's an array

north cairn
north cairn
#

what if the message is diff

#

u click the button,new message apppears,click button and so on

lyric mountain
#

u just need to update the message id which ur tracking

north cairn
lyric mountain
#

yeah, although I'd recommend against

#

that can easily lead to spam

north cairn
#

hmm but currrently i am just tsting

lyric mountain
#

2 people using that command in a single channel would clog it

north cairn
#

so u know startup to udertsand

hushed robin
#

!!

north cairn
lyric mountain
north cairn
hushed robin
#

fetch?

#

what

north cairn
#

what lang is that

#

js?

hushed robin
#

what am i fetching

hushed robin
#

and it returns nothing

lyric mountain
#

no, not like that

north cairn
lyric mountain
#

show the actual code and what error ur facing, and write at least the minimal context for undestanding ur question

lyric mountain
north cairn
lyric mountain
hushed robin
#

tracking is the thing on the right

lyric mountain
#

ok, now the context

hushed robin
#

see console.log(data)?

#

it's logging nothing

lyric mountain
#

what is tracking?

north cairn
#

as well as i understoood till now is
classes are like a fucntion of game and object is to run the game

hushed robin
lyric mountain
#

yes, but where did u print that?

#

put a console.log before the first loop

hushed robin
#

wym

hushed robin
north cairn
lyric mountain
#

its just a regular batch api response

north cairn
hushed robin
#

log this

lyric mountain
#

ops

#

wrong ping

north cairn
#

..

lyric mountain
hushed robin
#

but

lyric mountain
#

tracking is an object, not an array

hushed robin
#

oh

#

i think i understand

lyric mountain
north cairn
#

yo kuu whats ur age

lyric mountain
#

24

north cairn
north cairn
lyric mountain
#
class Cow {
  void moo() {
    println "moo"
  }

  void move(int x, int y) {
    ... // move the cow to x,y
  }
}
hushed robin
#

MOOO

#

🐮

lyric mountain
#
def cow = new Cow();
cow.moo();
cow.move(1, 0);
#

this is self-contained logic

#

the cow has all the logic for doing cow things

#

you don't need to handle anything outside of cow

hushed robin
#

ok kuuhaku

#

still doesn't work

lyric mountain
#

updated code?

hushed robin
#

no work still

lyric mountain
#

code, not the object

hushed robin
#

code is same

#

why would i change

lyric mountain
#

because the issue is there, not in the obj

hushed robin
#

o

#

y didn't u say that 🙁

lyric mountain
#

u dont need to change the object, u need to change the code to properly access that object

#

games is inside that object, you need to access before iterating over it

hushed robin
#

i think i solved

hushed robin
#

no

#

js

#

i think

#

but it's not python

#

python looks worse than that

north cairn
hushed robin
#

read what he said

#

he explained it good

#

actually it's java i'm pretty sure

lyric mountain
#

it's groovy actually

north cairn
#

its not js

#

thats what i know

hushed robin
#

groovy?

lyric mountain
#

yes, groovy

hushed robin
#

oh well

#

same thing

#

java groovy

lyric mountain
#

it's to java what typescript is to js

hushed robin
#

oh

#

nice

lyric mountain
#

except groovy makes java more minimal, contrary to ts

hushed robin
north cairn
#

ig i still gotta learn class more

#

dont really understand whats void and all that

north cairn
lyric mountain
#

println prints a line

north cairn
#

nvm i only need know channel.send,.reply and .log

lyric mountain
#

printf prints formatted

lyric mountain
#

I don't need a return of moo()

north cairn
lyric mountain
#

it's only supposed to say moo to the console

hushed robin
#

MOOOOOOOOOOOOOOOOOOO

#

🐮

north cairn
lyric mountain
#

def cow = new Cow() creates a new cow, imagine u have a grass field and a cow simply pops there

#

then it proceeds to cow.moo()

#

and walk to cow.move(1, 0)

hushed robin
#

ok i've made progress

north cairn
#

moo is nothing rifht??

#

cow.moo does what

hushed robin
#

print moo

#

cow go moo

north cairn
#

and that move?

#

ig moves along x and y axis on website

#

?

hushed robin
#

slight progress, it's only logging games tho

lyric mountain
hushed robin
north cairn
#

hm thank you so much for explaining so well bro
@lyric mountain

lyric mountain
#

in any lang actually

north cairn
#

imma go get dinner

lyric mountain
north cairn
#

have a nice day ahead

lyric mountain
#

u dont care about the keys

north cairn
#

imma make some progress and return

lyric mountain
#

actually, just do tracking.games

hushed robin
#

no

#

i need to loop through it entirely

#

theres tracking.groups too

north cairn
#

bye cya and thanks once again

lyric mountain
hushed robin
#

object.values works

#

still only prints games tho

lyric mountain
#

as ur looping over entries, not values

hushed robin
#

what

#

why is it only logging games

lyric mountain
#

it's not, see the object right below it

#

they'll appear without keys

hushed robin
#

but now

#

my function is making it not continue loop

lyric mountain
#

likely getting stuck in updateTypes

hushed robin
#

yah

#

trying to find out whats doing it now

#

ok it's getting stuck on this

#

hm

#

kinda confused tbh

#

why's it not logging?

lyric mountain
#

maybe that select is erroring

hushed robin
lyric mountain
#

not showing anything when it should is technically an error

#

put a try-catch around it

#

if it's async use .catch() too

hushed robin
#

it's not async but

#

i put it in a try catch and it sent the error
SqliteError: no such column: playing

#

er i know why

lyric mountain
#

as it's a database operation

hushed robin
#

no

#

better sqlite3 isn't async

#

🫠

lyric mountain
#

I said "it should be"

#

not that it is

hushed robin
#

why should it be

lyric mountain
#

all database ops should be async

#

because a query might run for a long time

#

being sync means it'll stop the execution until it finishes

hushed robin
#

well why do lots of people use better sqlite3 if it should be async

#

and isn't

proven lantern
#

human behavior is strange

hushed robin
#

@quartz kindle

#

opinion on this

#

should i stop using better sqlite3

lyric mountain
#

maybe it's because sqlite itself doesn't support multiple writes, so they chose sync

#

but it's weird anyway

hushed robin
#

hm

harsh nova
#

Better sqlite3 is fast enough that it really isn't an issue

hushed robin
#

true

#

sqlite is fast 🚀

#

where am i saying playing is a column 😵‍💫

lyric mountain
hushed robin
#

yes type = playing

#

not a column

lyric mountain
#

'did u forget something?'

hushed robin
#

oh

#

shit

#

🤣

#

im such a silly goof

quartz kindle
hushed robin
#

makes sense

#

now i think i fixed all my code

earnest phoenix
#
         EmbedX.description += `**${data.replace('.txt','')}:** \`${lines.length}\`\n`
          });

#

any help with this i'm struggling on from yesterday?

lyric mountain
#

didn't we talk abt this already?

earnest phoenix
earnest phoenix
lyric mountain
#

stop using description += altogether

earnest phoenix
lyric mountain
#

setDescription

proven lantern
#

i'm planning to make a DynamoDB table like this to store guilds and users. it'll be shared by two bots and eventually more. In the DbGuild table i use application_id and guild_id for the key schema. Now i'm wondering if there is a better way to create the key schema for the DbUser. I currently concatenate application_id and guild_id in my code and use that for the HASH key. is there a better way to do this? like tell DynamoDB to do this for me through configs?

  DbGuild:
    Type: AWS::DynamoDB::Table
    Properties:
      KeySchema:
        - AttributeName: "application_id"
          KeyType: "HASH"
        - AttributeName: "guild_id"
          KeyType: "RANGE"
      AttributeDefinitions:
        - AttributeName: "application_id"
          AttributeType: "S"
        - AttributeName: "guild_id"
          AttributeType: "S"
      BillingMode: "PAY_PER_REQUEST"
  DbUser:
    Type: AWS::DynamoDB::Table
    DependsOn: DbGuild
    Properties:
      KeySchema:
        - AttributeName: "application_id+guild_id"
          KeyType: "HASH"
        - AttributeName: "user_id"
          KeyType: "RANGE"
      AttributeDefinitions:
        - AttributeName: "application_id+guild_id"
          AttributeType: "S"
        - AttributeName: "user_id"
          AttributeType: "S"
      BillingMode: "PAY_PER_REQUEST"
earnest phoenix
#

it doesn't work

#

i tried it

lyric mountain
#

or see if there's an appendDescription or smth

lyric mountain
earnest phoenix
#

i removed the .setDescription at first

#

and then changed the .desc with .setDescription

earnest phoenix
rose warren
#

TIL you can't use ternary operators inside a string, only in a template literal

lyric mountain
#

cuz it wont work obv

earnest phoenix
lyric mountain
#

it's a function ffs

proven lantern
earnest phoenix
#

xd

lyric mountain
#

setDescription(the text)?

earnest phoenix
#

ye

lyric mountain
#

then your EmbedX is broken

earnest phoenix
#

and it only put 1 item not each items

lyric mountain
#

yes, it overwrites

#

that's what set means

rose warren
lyric mountain
#

if u want to concatenate u need to setDescription(getDescription() + text)

#

or build the string outside of it

earnest phoenix
lyric mountain
#

which will be cleaner

#

setDescription is a function

deft wolf
#

XD

#

You can use += only with the string right?

proven lantern
lyric mountain
#

else it'll try to concat the falsy branch

rose warren
#

yeah true

#

template literals are cleaner anyway

proven lantern
#

the ternary operator has the wrong level of precedence in all programming languages so it's confusing

lyric mountain
proven lantern
#

it should be at the same level as the logical or operator

lyric mountain
#

but yeah, try to use it only with strings and numbers

hushed robin
#

why when i fetch a user in a guild for the second time their data isn't updated

lyric mountain
#

context

hushed robin
#

i fetch user in my guild to check their roles

#

if they have Supporter role

#

when I do first time

#

role = correct

#

if I change role without restarting bot role = incorrect

#

it has old roles

lyric mountain
#

do u have guild members intent?

hushed robin
#

no

#

i don't want unnecessary intents

#

also my bot is verified, i don't think Discord would give me the intent for this

solemn latch
#

You can fetch the user again to get their roles

solemn latch
#

are you no caching the fetch?

hushed robin
#

i use fetch

hushed robin
deft wolf
#

Yea but fetch gonna check cache first

hushed robin
#

how can i make it

#

not do that

#

bc i need updated values

solemn latch
#

docs has that info 👀

#

I dont remember off the top of my head

hushed robin
#

hmm

#

ok

deft wolf
#

You need to add something like force: true but it's gonna hit ratelimit so fast

pale vessel
#

the values should stay updated though, assuming you're receiving the corresponding events?

deft wolf
#

If you are gonna use loop or something

solemn latch
#

5/s?

lyric mountain
hushed robin
#

i need to check the roles in my guild

lyric mountain
#

without the intent it wont receve role updates

#

so it'll never update the cache

#

fetching a member will add them to the cache, the second time u use it it'll grab from the cache as it's still there

hushed robin
#

i don't wanna do that

#

i need updated values

#

adding force: true doesn't do anything

empty sapphire
#

hello

hushed robin
#

still returning the same things

lyric mountain
#

why do u need to check the role anyway?

hushed robin
lyric mountain
#

store the supporter status in the database

hushed robin
#

er

lyric mountain
#

together with their user account

hushed robin
#

how

solemn latch
#

If you already have a table with a list of users just adding a column

#

if not, you can make a dedicated table

hushed robin
#

i mean like

#

how would i do that

#

fetch all members of my guild and filter them out?

lyric mountain
#

if ur giving them the role, u can add to the database

hushed robin
#

wym

lyric mountain
#

unless ur manually giving the role

hushed robin
#

i'm not

#

a bot will give them it

#

ok i figured out how to force fetch

#

i think it'll be fine

pale vessel
#

violence is not an option

#

please do not use force

hushed robin
#

i need updated values bro

#

if i don't force it'll be outdated

lyric mountain
#

and apis for checking

hushed robin
#

it does but

#

they don't provide you with person who donateds discord ID

#

this is what they give ya

#

tho they have a feature to give people who subscribe to u a role

#

which is what i'm planning on using

rustic nova
#

just use the email within that and oauth, compare the emails, boom

#

might only cover the ones with the same emails

hushed robin
#

no

#

i'm not doing allat

rustic nova
#

skill issue then

hushed robin
#

i will just always fetch

#

unless someone has a better idea

slender wagon
#

can i send gifs using canvas

earnest phoenix
#
  File "main.py", line 169
    @venady.slash_command()
                           ^
IndentationError: unindent does not match any outer indentation level
 

#

this worked few hours ago

#

it doesn't now

#

wow

rustic nova
#

more code please

earnest phoenix
#

venady is the client (like client = discord.Client)

#

i'm lil new to python and found disnake

#

and also i'm not using local because i'm running out of space

rustic nova
#

the annotation needs to be on the same line as the function