#development

1 messages ยท Page 724 of 1

loud salmon
#

yea you're right fucked

solar wraith
#

?

#

how so

#

xD

loud salmon
#

if you dont know how to code then you're going to really have a bad time

solar wraith
#

i know how to code

#

some what

loud salmon
#

then why did you buy a bot Thonk

solar wraith
#

but im a system administrator

loud salmon
#

ah gotcha

solar wraith
#

i thought

#

deploy that fucker

#

and bookm

#

but...

#

as usual

loud salmon
#

understandable

solar wraith
#

things are never easy

loud salmon
#

I would ask the dude you bought it from about the issue

solar wraith
#

he is a dick and wont give me advice

loud salmon
#

oofers

solar wraith
#

@ Blload#6680 <---- oh here he is!

#

xD

loud salmon
#

that should get you started

solar wraith
#

thanks

modest maple
#

@solar wraith dm me if u want

loud salmon
#

also

solar wraith
#

a simple hint is pleasant

modest maple
#

i think i might know whats wrong

solar wraith
#

Yush

modest maple
#

but i need to see the code

solar wraith
#

i mean

#

wait

loud salmon
#

apparently ctx is a commandnotfound object and I have no fucking clue why, ctx is usually something else

modest maple
#

have you actually told it to pass CTX?

solar wraith
#

can i just run this on every IP adress?

loud salmon
#

I'm not too familiar with python or discord.py but I know that ctx isnt that object

#

um

solar wraith
#

so im home now

loud salmon
#

yes

solar wraith
#

but if i run at school will it still communicate?

modest maple
#

if you dont tell it to run with CTX it will just pass the message payload

#

and yes it will

loud salmon
#

yea as long as there isnt any firewall on standard ws ports

modest maple
#

i occasionally stick the bot on the school server

#

i mean

#

what

#

xD

solar wraith
#

great

#

that means its only offline during thingys

#

@modest maple where do i tell ctx to kindly fuck off?

modest maple
#

if u dont need ctx

#

its just


aync def on_message(message):

solar wraith
#

what is ctx?

modest maple
#

context

#

i personally dont use it but i see why people do use it for bots

#

but i use the message payload instead

solar wraith
#
async def on_command_error(error, ctx):```
modest maple
#
@client.event

async def on_message(message):
    print(message.content, message.author, message.guild)
    Message_To_Split = message.content
    Split_Message = Message_To_Split.split(" ", 1)
    Split_Message[0] = Split_Message[0].upper()
    Person = message.author```
solar wraith
#

that?

loud salmon
#

oh

#

ctx, error

modest maple
#

thats my basic code for when ever anyone messages

loud salmon
#

that should be the order no?

solar wraith
#

i geuss?

#

xD

modest maple
#

ahhhhhhhhhhh

solar wraith
#

silently swears @ Blload#6680

#

xD

modest maple
#

i think i might know, have you made sure its not a client event instead of a bot event

#

as its the client doing somthing

#

could be completly wrong

solar wraith
#

well i swapped them

modest maple
#

xD

solar wraith
#

new error

#

Command "shop" is not found

#

:D

#

getting closer and closer

modest maple
#

xD

#

i think that is your error

solar wraith
#

commands are not found

modest maple
#

its trying to get commands that dont exist

#

find them

solar wraith
#

looks in root

#

commands.json

modest maple
solar wraith
#

well i found them alright

#

:3

modest maple
#

if you wanna have a look should give u some good examples of stuff

solar wraith
#

:3

terse pier
#

how to make url markdown for embed title in discordpy?

solar wraith
#

@modest maple Traceback (most recent call last):
File "D:\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\discord\ext\commands\bot.py", line 621, in load_extension
lib = importlib.import_module(name)
File "D:\Microsoft Visual Studio\Shared\Python37_64\lib\importlib_init_.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'tanki'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "D:\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\discord\client.py", line 270, in _run_event
await coro(*args, **kwargs)
File "D:\tanki online\Tanki Online Bot\run.py", line 43, in on_ready
bot.load_extension(cog)
File "D:\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\discord\ext\commands\bot.py", line 623, in load_extension
raise errors.ExtensionNotFound(name, e) from e
discord.ext.commands.errors.ExtensionNotFound: Extension 'tanki' could not be loaded.

#

:c

#

thats what i get every launch

west raptor
#

The error is at the bottom

solar wraith
#

yeah

#

but

#

why>

#

*?

west raptor
#

Well

#

What's your code

solar wraith
#

i got a bunch of code xD

#

what are you looking for?

west raptor
#

Line 43

terse pier
#

can I have a question regarding discordpy please?

solar wraith
#

aha yes

west raptor
#

Sure

terse pier
#

how to make url markdown for embed title in discordpy?

west raptor
#

In titles? I believe you can pass a parameter

#

url I believe

terse pier
#

oh, thank you I'll try it

west raptor
#

Np

solar wraith
#

hmmm

#
@bot.event
async def on_ready():
    print(f'{bot.user.name} has logged in!')
    print("Starting up...")
    cogs = ["tanki",
            "economy",
            "containers",
            "DiscordBotsOrgAPI",
            "help",
            "general",
            "admin",
            "clans",
            "shop"]
    for cog in cogs:
        bot.load_extension(cog)
        print(f"- {cog} has been loaded.")```
west raptor
#

@trim saddle can you help thanks

#

Haven't don't dpy in a while

modest maple
#

yeet right your calling on the function load_extension and passing it the thing you want to find (cog)

#

its crashing cuz its trying to do somthing with cog

#

and it cant as youre missing a library

solar wraith
#

?

modest maple
#

which
A) means something else is broken
B) you havent imported everything you need
C) youre using the function wrong

west raptor
#

Oh that's shitty error handling

solar wraith
#

folder cogs

west raptor
#

ExtensionNotFound

modest maple
#

have you imported tanki

west raptor
#

But it just can't be loaded

modest maple
#

and does it know where to look for tanki

solar wraith
#

i am getting a few import errors

#

folder cogs

#

:3

#

*cog

modest maple
#

make sure python knows where to actually look

solar wraith
modest maple
#

as it defaults to either the python folder on your drive where its installed or PATH

#

cuz ur using pycharm:

go to the interpreter settings

west raptor
#

That's not pycharm

modest maple
#

then see what modules its finding

west raptor
#

That's visual studio

modest maple
#

oh oops

#

xD

#

okay

#

i see now lmao

#

NEW PLAN

#

get pycharm

#

go from there

solar wraith
#

no

#

xD

#

visual studio is bear

#

*beast

modest maple
#

use a program that is built around the language

trim saddle
#

whats happening

solar wraith
#

well visual studio is

#

xD

modest maple
#

hes getting import errors

solar wraith
#

partially

modest maple
#

and not like pycharm xD

solar wraith
#

BAH

#

surte

#

fine

#

i get pycharm

#

:C

#

xD

trim saddle
#

how about this

west raptor
#

Visual Studio is bloated to the brim

#

Why use it for python

modest maple
#

^

trim saddle
#
try:
    bot.load_extension("whatevercog")
except Exception as e:
    print(e)
#

then check the errors

solar wraith
#

me?

#

and where do i add it?

west raptor
#

Where you are loading cogs

trim saddle
#

where bot.load_extension was

solar wraith
#

ah

modest maple
#

i think its python not finding the file

@bot.event
async def on_ready():
    print(f'{bot.user.name} has logged in!')
    print("Starting up...")
    cogs = ["tanki",
            "economy",
            "containers",
            "DiscordBotsOrgAPI",
            "help",
            "general",
            "admin",
            "clans",
            "shop"]
    for cog in cogs:
         try:
                bot.load_extension("whatevercog")
        except Exception as e:
                print(e)
        print(f"- {cog} has been loaded.")```
#

ahhhhhhh indentation

trim saddle
#

ok uhh

#

you kinda copied and pasted without changing

solar wraith
#
async def on_ready():
    print(f'{bot.user.name} has logged in!')
    print("Starting up...")
    cog = ["tanki",
            "economy",
            "containers",
            "DiscordBotsOrgAPI",
            "help",
            "general",
            "admin",
            "clans",
            "shop"]
    for cog in cog:
        bot.load_extension(cog)
        print(f"- {cog} has been loaded.")```
modest maple
#

ik i tired to indent it but it did not work xD

solar wraith
#

found it?

#

sys.path.insert(0, "cogs")

sudden geyser
#

Python IndentationError will come back to haunt you

solar wraith
#

while name of folder is cog

#

:3

trim saddle
#

i just use os.listdir("cogs")

modest maple
#

^

#

will give u everything labeled in cogs

west raptor
#

Damn I don't even remember half of this when I did d.py

trim saddle
#

@modest maple so uh are these files in a folder called cogs?

modest maple
#

yh i think they are

trim saddle
#

ohhh theres your problem

modest maple
#

yup

west raptor
#

Not @modest maple

#

@solar wraith

modest maple
#

yh

#

xD

#

but i think its cuz theyre in a folder python isnt finding it

trim saddle
#

if you need to import from a folder

modest maple
#

not looking in the right area for it

solar wraith
#

no

#

they are called...

#

uhm

#

hol up

trim saddle
#

bot.load_extension(f"cogs.{cog}")

solar wraith
#

there

#

thats what they are called

modest maple
#

no he means

#

in relation to your bot code

#

where is the cogs area

#

xD

solar wraith
#

folder up

#

like bot root\cog

modest maple
#

if its in a folder youre gonna need to do what he said

#

or import it directly from that folder

trim saddle
#

@solar wraith did it work

west raptor
#

Wait what

solar wraith
#

hold up

west raptor
#

Is that how you indicate a dir

#

Is by a dot

solar wraith
#

im getting help from some one

west raptor
#

Lmao

trim saddle
#

pretty much

west raptor
#

Sounds gay

modest maple
#

welcome to pytohn

#

Object oriented language xD

trim saddle
#
# utils/gay/owo.py
# meanwhile in main.py...
from utils.gay import owo
modest maple
#

it took u that long to do that xD

west raptor
#

But like why

trim saddle
#

we don't use require

west raptor
#

The import makes like

modest maple
#

complete sidenote: how can i get my activity feed to update every 120 secs?

west raptor
#

At least a bit of sense

modest maple
#

the import makes life easy

#

youre importing other code

#

EZ

west raptor
#

But in a string?? lol

#

Tbf

#

Imports in rust are like rs use std::thing::AnotherThing

valid frigate
#

oh wait

#

this isnt off topic

trim saddle
#

@valid frigate woah no

valid frigate
#

lol wrong channel my bad

trim saddle
#

thats still wrong

modest maple
#

xD

valid frigate
#

kek im out

modest maple
#

python just has getting other modules sorted

#

easily

trim saddle
#
# good
from this import that

# bad
import this.that
valid frigate
#

a lot of languages use import statements

#

i think the only one that doesnt is js prior to emcascript 5 or something

west raptor
#

Is there such thing as private and public in python

#

Or readonly

valid frigate
#

nah i dont think theres package access

#

dont quote me on this

trim saddle
#

@west raptor wait wha

#

packagewise?

west raptor
#

Like anything

#

Like in rust ```rs
// private - unaccessible from other sources, only available to/in struct/class or said file
let private = true;

// public - accessible from other sources
pub let public = true;```

trim saddle
#

i actually don't know

slender thistle
#

Not that I heard of

spark mantle
#

how do I get a bot to check to see if there in a certain server

sudden geyser
#

What library

spark mantle
#

im sorry do you mean like my programing language

slender thistle
#

The API wrapper you use (if you use one)

spark mantle
#

like visual studio code

blissful scaffold
#

you use discord.js?

spark mantle
#

yes

sudden geyser
#

then that's the library you use

spark mantle
#

sorry

blissful scaffold
#

you can check the id of the guild is the same as the guild you want to be in

spark mantle
#

thanks

valid frigate
#

hey so i'm having a sort of specific issue with eris sharding on multiple processes, on some occasions (local & production) shards will go offline with code 1006 (connection reset by peer) and i'm assuming it has to do with my local device

#

most of the time the lib handles reconnections fine, but other times it's gonna be stuck in a "invalid session/already authenticated" loop

#

in these scenarios i have to manually reboot every cluster but obviously don't want this happening, i also debugged by listening to debug events emitted and everything seems normal so what could be the reason for this?

earnest phoenix
#

or will it yell at me

valid frigate
#

as long as it resolves to some value it's probably fine

#

iirc it needs to be a primitive type though like boolean, number, string, etc

#

also try it and s e e

earnest phoenix
#

yea .reduce resolves a number so we gucci

vital lark
#

@valid frigate I also get 1006 errors with Yamashiro

valid frigate
#

yeah it should work then

vital lark
#

I think it's the host and Discord's connection

valid frigate
#

it's not eris

#

yeah its our own devices

#

however it's eris' fault for not handling duplicate identify requests

vital lark
#

I usually get 1001 or 1006 errors mmuh

valid frigate
#

i only get 1006 lmao

#

signifying it's only my device

warm marsh
#

Is the use of ssh considered a security flaw?

earnest phoenix
#
``` how i get the dbl token and what is webhookAuth: 'passwaord'
summer torrent
earnest phoenix
#

and what is webhookAuth: passward

#

how i get that

summer torrent
#

idk

winter basalt
raven torrent
#

did you even created a webhook?

earnest phoenix
#

@raven torrent yaa

cedar brook
#

-mybot

#

!mybot

summer torrent
#

-bots

gilded plankBOT
west raptor
#

@warm marsh No, if you use it correctly you'll be fine

cedar brook
#

Sorry.

#

-bots

gilded plankBOT
cedar brook
#

๐Ÿ˜„

west raptor
#

I just said to not run it here..

solar wraith
#

ugh

#

keep running into the error : TypeError: cogs must derive from Cog

slender thistle
#

Well

#

If you know subclassing, you know how to fix it

solar wraith
#

I do not

#

sadly

slender thistle
solar wraith
#

Wall of texts

#

I hate that

#

;-;

west raptor
#

Welcome to programming

#

Might wanna get used to it now

solar wraith
#

im a system admin

#

XD

#

Not a programmer

#

XD

west raptor
#

You should be used to this then

slender thistle
#

Might wanna learn basics before getting into non-beginner-friendly libraries

solar wraith
#

XD

#

Perhaps ur right

#

But

#

;-;

#

ugh

#

ffs

#

discord.ext.commands.errors.NoEntryPointError: Extension 'tanki' has no 'setup' function.

#

:C

#

what the frick frack snack am i doing wrong

slender thistle
#

Don't put the function setup under the class

solar wraith
#

ah

#

now it complains it hasnt have a setup -_-

slender thistle
#

How are you defining the function

solar wraith
#

def

slender thistle
#

And where exactly

solar wraith
#

class Tanki:
def init(self, bot):
self.bot = bot

def tanki(bot):
    bot.add_cog(Tanki(bot))
#

that

slender thistle
#

It needs a setup function outside of the class

solar wraith
#

ah

#

above the class tanki

#

or under

slender thistle
#

Wherever you want, just don't indent it

solar wraith
#

cuz under class it gets a mental break down

#

and i run into that error

slender thistle
#

It won't matter where it is

#

It just needs to be outside of the class

solar wraith
#

okay

#

:c

slender thistle
#

Did you subclass

solar wraith
#

i dont know xD

#

let me read that now

#

cuz im done asking questions

surreal sage
#
 if (command === "ping") {
        const msg = await message.channel.send("Pinging...");
        await msg.edit(`Pong! (Took: ${msg.createdTimestamp - message.createdTimestamp}ms.)`);
        console.log(`${message.author.tag}` + " Used PING " + `${msg.createdTimestamp - message.createdTimestamp}ms`);
    }``` I want to add the time at the console log, What do i need to use?
solar wraith
#

@slender thistle i properly did the subclass it still complains about the cog error

slender thistle
#

How did you subclass

solar wraith
#

class tanki:
def init(self, bot):
self.bot = bot
self.cog = tanki

#

that\

#

is all i have

surreal sage
#

CreatedAt just found at docs

slender thistle
#

ig it's time for me to find a solution for you

solar wraith
#

oh?

#

is it not my fault?

slender thistle
solar wraith
#

(probably is)

slender thistle
#

I mean

solar wraith
#

fun fact

#

i had that already

slender thistle
#

That's the first website I found when Googling "subclass python"

solar wraith
#

:c

#

same

slender thistle
#

Yet you're still not doing the right thing

solar wraith
#

F

slender thistle
#

class some_class(some_other_class_we_want_to_inherit):

solar wraith
#

i want to inherit the bot right?

slender thistle
#

Cog class

#

commands.Cog

solar wraith
#

ah

#

frick

#

so

#

self.add_cog(tanki.cog(bot)?

slender thistle
#

How did you even come to that conclusion

solar wraith
#

brain

#

dont question

solar wraith
#

i mean

#

im dum

#

:3

slender thistle
#

I literally gave you a solution where you just need to replace 2 things

solar wraith
#

ooohhh

#

class tanki(commands.cog)

#

?

slender thistle
#

Cog, not cog

#

Capitalization matters

solar wraith
#

i geuss?

#

long live batch and qbasic i geuss

#

xD

slender thistle
#

We're talking Python here

solar wraith
#

yush

#

i know

#

leave my brain out of this xD

#

YES

#

thanks

#

damn

#

im dum

#

<discord.ext.commands.context.Context object at 0x000002107F053988>
<discord.ext.commands.context.Context object at 0x000002107F053988>
Ignoring exception in on_command_error
Traceback (most recent call last):
File "D:\tanki online\Tanki Online Bot\discord\client.py", line 270, in _run_event
await coro(*args, **kwargs)
File "D:\tanki online\Tanki Online Bot\run.py", line 212, in on_command_error
channel = ctx.message.channel
AttributeError: 'CommandNotFound' object has no attribute 'messag

#

@slender thistle well what the frick did i feck up this time

slender thistle
#

Uhhh

#

eghhh

solar wraith
#

im stupid

#

:c

slender thistle
#

How do I say it

solar wraith
#

;-;

#

just say yes to me being dum

slender thistle
#

Did you help me help you by giving some part of your code

#

Specifically the one that applies here

solar wraith
#

well tanki now loads properly

modest maple
#

Oh we're still here

#

XD

solar wraith
#

but commands are recieved and then it gets a mental break down

#

no we are one cog further

#

xD

slender thistle
#

Give me your on_command_error

modest maple
#

Eric I gotta ask how much experience have you had programming discord bots in python and python in general?

solar wraith
#

hehehehe

#

1%

#

possibly?

slender thistle
#

A lot of people either use bot makers or straight up get to Discord libraries without learning the language

solar wraith
#

i dont even know

#

yush

slender thistle
#

and that would be your issue

solar wraith
#

i just bought this bot

#

i thought

#

run it and boom done

#

but

#

NOOOO

modest maple
#

That's kinda the issue... You've started with a library that is using alot of external classes and modules

#

Which you need to know how classes and functions works and python in general

solar wraith
#

yush

#

its also complaing about data even though data is a folder

#

and not a class

#

from data import config
from data.checks import owner_only, blacklist_check

#

data is a folder

#

containing owner_only.py and blacklist_check.py

#

but it cant import 'data'

modest maple
#

Have you shown python where to look...

solar wraith
#

pretty sure i did

#

using sys.path.insert

#

:3

modest maple
#

:/

solar wraith
#

i made dum mistake

#

did i?

modest maple
#

Idk

#

It's rlly hard to know cuz I can't see the full code

solar wraith
#

which file you need?

modest maple
#

Most likely the bot code itself, the modules shouldn't need touching and shouldn't be touched

solar wraith
#

i will send you the main file

modest maple
#

Where is data located?

#

Directory wise

solar wraith
#

data folder

#

root(where run.py is located)\data\ *.py

modest maple
#

As far as I can see you haven't told it to look for data directory locally

solar wraith
#

ah

#

well

#

link to how to do that?

#

but tanki.py uses assets located in data too

#

do i need to do this not only for run

#

but for all cogs?

modest maple
#

No if the files are in the same directory they should be fine

#

But I'm not entirely sure about sepecifying location to import from

solar wraith
#

F

#

@slender thistle perhaps do you know?

#

@modest maple use pathlib?

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

solar wraith
#

how about i dont read a 14.19 megabyte file and just look for what i need :D

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

loud salmon
#

dv please

sage bobcat
#

One message removed from a suspended account.

loud salmon
#

you aren't really helping

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

solar wraith
#

i am not going to waste a year of my time programming shit that i will never use again

loud salmon
#

the furry python coder is at school

#

but they may get out soon and you can ask them then

sage bobcat
#

One message removed from a suspended account.

loud salmon
#

they said they have a half day

solar wraith
#
    channel = ctx.message.channel
line 212 reads as following:     channel = ctx.message.channel```
#

i think chill fish can help me better he has the code

#

:3

loud salmon
#

lul

modest maple
#

Bruh no offense but you're trying to stuff in python that you've never done before, you've dived straight into fairly high level code calling upon other homebuilt modules... So I do have to agree with DV that you should learn the language before trying Todo advanced things with it, the bot you've been sold isn't exactly simple in code and if you don't know how python works or how to program in it then how are you going to program the commands?

loud salmon
#

oofers

solar wraith
#

yush

#

but i just need to get the bot working

#

that was and is my primary concern

loud salmon
#

if you were sold a non-working bot then thats something you need to bring up with that dude MegaThonk

solar wraith
#

when it is running stable i will look into things

modest maple
#

If you don't know how to work python you are going to get error after error after error

solar wraith
#

i will redo

#

i will just take the original thing

#

and delete the old

#

;-;

modest maple
#

There's no point in me helping you to correct the code that if it wasn't working in the first place should be taken up with the creator. Cuz even when it is working it won't respond or do anything you want it Todo cuz you can't program the commands which you need to know how to process data you get parsed etc...

#

Jumping into bot building in any language is a jump especially if you don't program the bot but by bit learning how the module works

grim aspen
#

are there any errors? @solar wraith

solar wraith
#

no

grim aspen
#

aw man deleted message

solar wraith
#

token stuff

#

i am using his token

#

which is invalid

#

xD

modest maple
#

Bruh

sage bobcat
#

One message removed from a suspended account.

modest maple
#

Ofc it's invalid

grim aspen
sage bobcat
#

One message removed from a suspended account.

modest maple
#

Do you have a developer portal?

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

grim aspen
#

@solar wraith like said above, using another man's token is not suggested generally, head to the discord developer portal and generate a token for your bot

solar wraith
#

@sage bobcat perhaps its me being to fast;.....

#

and skipping steps

sage bobcat
#

One message removed from a suspended account.

solar wraith
#

i had

#

my

#

own

#

key

sage bobcat
#

One message removed from a suspended account.

solar wraith
#

me

#

now leave me alone

sage bobcat
#

One message removed from a suspended account.

grim aspen
modest maple
#

Smh

solar wraith
#

ffs

#

AttributeError: module 'discord.ext.commands' has no attribute 'Cogs'

#

oh nvm

#

im stupid

earnest phoenix
#

this thing work, but it wont show me the imageee, anyone can help me out with this issue. :v

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

earnest phoenix
#

it still didnt show hmm

#

and my other members dont see any image in the embed too

#

there must be some line im missing to make it attach the file or something

mossy vine
#

JSON.parse will return an object that doesnt have an attachFile method

earnest phoenix
#

oof hm

#

ill try JSON.stringify()

mossy vine
#

no thats not the problem

earnest phoenix
#

ill google lmao im gonna be stuck with this for hours

mossy vine
sage bobcat
#

One message removed from a suspended account.

mossy vine
#

client.ws.shards.map => a a.status waitWhat

sage bobcat
#

One message removed from a suspended account.

mossy vine
#

thats not valid javascript

#

neither is whats following it

sage bobcat
#

One message removed from a suspended account.

mossy vine
#

if you are having trouble with arrow functions, you should try using a regular anonymus function instead

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

mossy vine
#

the following 2 are the same

functionWithSickCallback(result => { /* do stuff with result */ })```
```js
functionWithSickCallback(function(result) { /* do stuff with result */ })```
#

wait did you just say you dont know functions??,

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

mossy vine
sage bobcat
#

One message removed from a suspended account.

mossy vine
#

did you even read all of that

#

or any

sage bobcat
#

One message removed from a suspended account.

mossy vine
#

thats the problem

#

this one seems to be a good tutorial too

west raptor
#
function name(...params) {}

// or

let function = (...params) => {}``` in a nutshell
mossy vine
#

first is a regular function expression, second is an arrow function

#

the ... is the spread operator, if you dont know what that is, just dont use it

west raptor
#

A function as a parameter is known as a higher level function or callback

mossy vine
#

here are some very simple functions

west raptor
#

Higher order*

#

Sorry

mossy vine
#
function add(num1, num2) {
    return num1 + num2;
}

add(2,2) // 4
add(1, 999) // 1000
function greet(name) {
    return `Hello, ${name}`;
}
greet('world') // 'Hello, world'```
sage bobcat
#

One message removed from a suspended account.

mossy vine
#

it doesnt. you said you dont understand functions, so we gave you guides and examples

twilit rapids
#

You should learn and read the guides first before you continue with the broadcasteval

sage bobcat
#

One message removed from a suspended account.

twilit rapids
#

You really work yourself into broken code if you don't learn before you code

#

Then read the docs about broadcasteval

#

What version of d.js are you on?

west raptor
#

I believe she is on master

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

twilit rapids
#

And are you sharding internally or are you using a shardingmanager

#

Like

#

Internal sharding or shardingmanager

sage bobcat
#

One message removed from a suspended account.

west raptor
#

I haven't even done sharding

#

Why are you doing it now

sage bobcat
#

One message removed from a suspended account.

twilit rapids
sage bobcat
#

One message removed from a suspended account.

twilit rapids
#

How much server is your bot in

west raptor
#

script should be a string iirc

#

Just like eval

twilit rapids
#

broadcastEval needs to be a string yes

#

.broadcastEval("Some code here")

west raptor
#

Broadcast eval should return Promise<Array>

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

west raptor
#

Codeblock pls

twilit rapids
#

You just copied the code from the guide

sage bobcat
#

One message removed from a suspended account.

twilit rapids
#

Then read the guide...

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
#

previous...

west raptor
#

^

#

It's just a name

#

It can be anything

slender thistle
#

Isn't reduce a built-in func

twilit rapids
#

reduce is basic js yes

slender thistle
sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

west raptor
#

Client#shard doesn't exist

spare goblet
#

He's not trying to add all of shards' member counts together

sage bobcat
#

One message removed from a suspended account.

analog jolt
#

Oh, apologies

spare goblet
#

-supportserver @analog jolt

gilded plankBOT
#

@analog jolt

This server is NOT the support server for ANY bot. You need to click on the "Support Server" button on the bot's page, NOT the "Join Discord" button at the top of DBL.

spare goblet
sage bobcat
#

One message removed from a suspended account.

spare goblet
#

sorry typo

#

y keyboard keeps cutting off the first letter of

#

very

#

my *

#

every sentence

#

idk why (i didn't swear, shut)

#

@sage bobcat im only gonna explain this one last time.

client.shard.broadcastEval('this.shard.id').then(a=>{
// a is an array of the ids of the shardsums
})```

broadcastEval is something that runs a chunk of code on all shards. It's literally an eval that runs on all your shards
sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

spare goblet
#
client.shard.broadcastEval('this.shard.id').then(a=>{
/** a is an array of the ids of the shardsums.
 so for example, if you have like 3 shards, it'll be [ 0, 1, 2]
**/
})
sage bobcat
#

One message removed from a suspended account.

spare goblet
#

so basically

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

spare goblet
#

because it's running an eval on every single shard

sage bobcat
#

One message removed from a suspended account.

spare goblet
#

a shard = a separate process

sage bobcat
#

One message removed from a suspended account.

spare goblet
#

what

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

spare goblet
#

broadcast eval has a defined variable, THIS.
this is the client

#

so imagine if you're running an eval on one of the shards

#

basically

#

it just runs on all of them

sage bobcat
#

One message removed from a suspended account.

spare goblet
#

YES FINALLY

earnest phoenix
#

maybe 50/50

spare goblet
#

okay so

client.shard.broadcastEval("this.shard.id + '-' + this.ws.ping").then(a=>{
/** a is an array of the ids with the "-" and the ping of each shard
 so for example, if you have like 3 shards, it'll be [ "0-somepingvalue", "1-somepingvalue", "2-somepingvalue"]
**/
})
#

it's literally that easy

grim aspen
#

i keep thinking it says shardums

spare goblet
#

it does

sage bobcat
#

One message removed from a suspended account.

spare goblet
#

i speak in turkum

sage bobcat
#

One message removed from a suspended account.

spare goblet
#

what are you doing

mossy vine
#

that just declares an array with those values

spare goblet
#

thats an arrow function

#

a just defines what is returned from the promise

#

because broadcast eval returns a promise

#

the promise is in an array

grim aspen
#

it's just like the command handler in discord.js

#

^^

spare goblet
#

the array contains the value you evaluated but for each shard

sage bobcat
#

One message removed from a suspended account.

spare goblet
#

yes i know NyaScree

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

spare goblet
#

what

#

wait you're using internal sharding or traditional sharding

#

cuz you dont need to do this if you're internal sharding

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

languid dragon
#

have you considered learning how promises work and how to read documentation before trying to dive into the deep end?

spare goblet
#

do you know what a callback is?

sage bobcat
#

One message removed from a suspended account.

spare goblet
#

a is the callbackum

#

aafter the promise is resolved, a returns

#

just like how client.fetchUser() works; you have to .then(user => { /** run some func **/ } )

languid dragon
#

by "traditional" do you mean, you're trying to make your own sharder?

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

spare goblet
languid dragon
#

you're using the d.js manager, how are you creating shards?

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

languid dragon
#

okay and you're trying to fetch values from each shard?

sage bobcat
#

One message removed from a suspended account.

languid dragon
#

this is what you need

#

go have a read

mossy vine
#

thats what iara has been saying for 2-3 days

spare goblet
#

i am a triggered rolypoly rn

languid dragon
sage bobcat
#

One message removed from a suspended account.

spare goblet
#

finally

languid dragon
spare goblet
sage bobcat
#

One message removed from a suspended account.

solar wraith
#

F

languid dragon
#

by using an if statement POGGY

spare goblet
#

sobmylifeisover why u do this

#

use a ternary conditional operator if you wanna cut code

twilit rapids
#

${the-status-thing === 0 ? "green heart" : "red heart"}

spare goblet
#

you used that in your prior code

sage bobcat
#

One message removed from a suspended account.

languid dragon
#

did you even consider googling or thinking of the answer before blindly asking in #development first?

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

surreal sage
#

is asking peeps to do something for money allowed? Ping me if you have answer

amber fractal
slender thistle
#

Stalking someone for money? Definitely not.
Do some code for money? Well, yes

glacial mango
#

How do I convert 3:41 into seconds?

slender thistle
#

3*60+41

#

Basic math

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

slender thistle
#

TIAS

sage bobcat
#

One message removed from a suspended account.

grim aspen
#

lel webmd

glacial mango
#

@slender thistle I know, but it's not always 3:41, depends on the song duration

slender thistle
#

Use urban dictionary

#

If that's a string, handling it isn't that hard

glacial mango
#

?

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

slender thistle
#

Good fucking lord

lavish shuttle
#

@glacial mango here, I'll send you something in DM

slender thistle
lavish shuttle
#

It should help you out

glacial mango
#

Thanks

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

slender thistle
#

You can calculate that very easily

#

if you know how to convert an hour into minute, a minute into seconds, etc.

earnest phoenix
#

I would take a wild guess on it but ik itโ€™s wrong

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

amber fractal
#

this.shard is undefined.

#

Could just fetchClientValues instead.

loud salmon
sage bobcat
#

One message removed from a suspended account.

sudden geyser
#

are those even in quotes

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
#

broadcastEval takes a string

amber fractal
#

^ it's a string with a script in respect to client

#

I would still use fetchClientValues

#

Something like let statuses = await <ShardClientUtil>.fetchClientValues("status")

surreal sage
#

how to do or? js if (command === prefix + "help") { like help but can i add like a or to like help / commands

#
..```?
grim aspen
#

||?

amber fractal
#

Have you done basic js?

surreal sage
#

idk

#

im just asking

#

I have the command help but i want that commands work to

grim aspen
#

waitWhat you don't know if you've done basic js?

slender thistle
#

have you done basic js?

idk

#

That's when you know you don't know basic JS

surreal sage
#

://

#

dumb

#

you

slender thistle
#

I don't see any point in calling anyone dumb here

grim aspen
#

yes it's ||

amber fractal
#

If you use lua its or mmulu

grim aspen
#

same with python

earnest phoenix
#

How to get the ping of a shard?

amber fractal
#

Now that I think about iy lua is literally english

#

@Dany-LF#3539 what lib

earnest phoenix
#

discord.js

amber fractal
#

Master or stable

earnest phoenix
#

stable :)

amber fractal
#

client.ping

earnest phoenix
#

For a shard?

#

๐Ÿ‘€

amber fractal
earnest phoenix
#

Okay ty

amber fractal
#

:+1:

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

amber fractal
#

Fetch client values takes a string and evaluates it in respect to client

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

amber fractal
#

I can tell you ws doesnt have a shard property it does have a shards property even with that Im not sure what you're trying to do would work.

#

Assuming you're on master because you use .ws though

#

I need to go anyways. Good luck though

languid dragon
#

@sage bobcat do you know what a promise is?

sage bobcat
#

One message removed from a suspended account.

languid dragon
#

i'll take that as a no

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

languid dragon
sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

languid dragon
#

if you "know" what a promise is, why aren't you resolving the promise returned from fetchClientValues?

sage bobcat
#

One message removed from a suspended account.

languid dragon
#

is that why you're not resolving the promise returned from fetchClientValues?

sage bobcat
#

One message removed from a suspended account.

languid dragon
#

either that or i think it would be wise to google your questions that likely already have answers rather than asking in #development every time you hit a small brick wall
eg. "how to resolve a promise in javascript/node.js"

valid frigate
#

Also another tip

#

If you're using async/await promise chaining becomes redundant

#

Basically .then and .catch don't really do anything since you can just put async before the promise

#

So if you see any examples in npm packages and such using .then don't copy and paste their examples

earnest phoenix
#

how can i show Custom Status text in command?

quartz kindle
#

custom status is not available for bots yet

mossy vine
#

i think he is asking how to retrieve a users custom status

quartz kindle
#

same answer afaik

mossy vine
#

fair

quartz kindle
#

last time i checked, library maintainers were waiting for discord to officially release docs about it

mossy vine
#

so its technically in the api, right?

#

just no documentation?

quartz kindle
#

custom statuses are not yet documented

#

yup

mossy vine
#

ah

quartz kindle
#

pretty sure you can get them if you use raw presence packets

valid frigate
#

i think a lot of people prefer not to use raw presence packets

#

also discord will probably release the docs in a little bit so lib maintainers will implement it soon

steel stream
#

Hi

quartz kindle
#

actually some libs already support it, have supported it for like 3 months before discord released it

#

in d.js master you can see it in user.presence.activity

slender thistle
#

Lib devs document and support it but bots still can't use custom statuses, right?

quartz kindle
#

not sure if bots ever will

slender thistle
#

I mean I don't think we got a statement on that one, or did we?

smoky spire
#

I think the statement was "we're looking into it"

quartz kindle
#

Custom statuses are activities with a type of 4, a name of Custom Status, the actual custom status in the state field, and a new emoji field for the main emoji. Bots aren't blocked from doing this, but... well, read the docs: https://discordapp.com/developers/docs/topics/gateway#activity-object.

Bots are only able to send name, type, and optionally url.

As bots cannot send states or emojis, they can't make effective use of custom statuses. The header for a "Custom Status" shows up on their profile, but there is no actual custom status, because those fields are ignored.

Discord Developer Portal

Integrate your service with Discord โ€” whether it's a bot or a game or whatever your wildest imagination can come up with.

#

that was posted 13 days ago

#

idk the current state of affairs

slender thistle
#

Oh yeah that Reddit comment

steel stream
#

In how many days they will see my bot

quartz kindle
#

you know what discord should implement?

#

opening links like those in a popup or something

#

or preview them

slender thistle
#

imo actual quotes linking the original message and showing the quoted message content would be decent

loud salmon
#

you already have your quotes shiv >

slender thistle
#

200iq Spood

#

I meant actual quote when you link a message

quartz kindle
#

actually, imma make a bot that replaces those urls with a quoted message

#

lmao

loud salmon
#

do it

slender thistle
#

iirc there was a bot which is @carmine adder but idr if it does that

frozen cedar
#

weirdsip how can I make my bot scan videos and download them/sort them by the 'actor'. I got the downloading and sorting stuff, I just need the AI to figure out similar faces. weirdsip weirdsip

#

Basically just nodejs ai

quartz kindle
#

done

slender thistle
#

You're an angel

loud salmon
#

using > instead of a rich embed

#

disgusting

quartz kindle
#

using > makes it not require embed permissions

#

one less headache

#

xD

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

quartz kindle
#

a is the response

#

promises are basically doing something that takes time, and then receiving an answer, same as requesting a website or url

#
doSomething.then(whateverHere => {
    // whateverHere is the response. console.log it to see what the response is, do something with it, etc...
})```
sage bobcat
#

One message removed from a suspended account.

lament meteor
#

ye

sage bobcat
#

One message removed from a suspended account.

quartz kindle
#

is the response

sage bobcat
#

One message removed from a suspended account.

lament meteor
#

a is a response

sage bobcat
#

One message removed from a suspended account.

lament meteor
#

basicly its a variable

quartz kindle
#

you name it whatever you want

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

quartz kindle
#

is the same as js doSomething.then(function(whateverHere) { // whateverHere is the response. console.log it to see what the response is, do something with it, etc... })

sage bobcat
#

One message removed from a suspended account.

lament meteor
#

and u can async it by doin ```js
doSomething.then(async(whateverHere) => {

})```

#

its cleaner

sage bobcat
#

One message removed from a suspended account.

lament meteor
#

not really sure about speed but yea

quartz kindle
#

arrow functions have a slightly different behavior, especially when using classes and the keyword this

#

other than that, they are the same

lament meteor
#

lemme test which is the fastest

sage bobcat
#

One message removed from a suspended account.

quartz kindle
#

console.log it to see what it is

sage bobcat
#

One message removed from a suspended account.

quartz kindle
#

then wait until you can properly test it

#

dont code blindly

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

quartz kindle
#

if you cant test it, you wont be able to finish it lol

sage bobcat
#

One message removed from a suspended account.

lament meteor
#

lemme check the docs to help u

#

u using stable or master dv

sage bobcat
#

One message removed from a suspended account.

lament meteor
#

basicly... a in this case is an array

#

and the items in the array are the output of the eval for each shard

sage bobcat
#

One message removed from a suspended account.

lament meteor
#

also whats with the " in front of the this.shard.id

#

yea should be

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

mossy vine
#

what no

sage bobcat
#

One message removed from a suspended account.

mossy vine
#

<> means type

sage bobcat
#

One message removed from a suspended account.

mossy vine
#

it doesnt exist in js, only used for documentation

lament meteor
#

cyber f.then(async (x) => console.log(x)) should work right

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

lament meteor
#

probs just do (this.shard.id + '-' + this.ws.ping + '-') + (this.ws.shards.status === 0 ? 'green_heart' : 'broken_heart')

sage bobcat
#

One message removed from a suspended account.

lament meteor
#

use the brackets

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

lament meteor
#

wait...

quartz kindle
#

dude...

#

the promise returns an array

#

that means your a is itself an array

#

do .send(JSON.stringify(a)) and you'll see

lament meteor
#

the thing i sent dv is saying that this.shard doesnt exist... but yea

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

quartz kindle
#

broadcastEval takes a string

#

your entire code to be sent to other shards, must be sent as a string

#

.broadcastEval("your code here")

lament meteor
#

o yea me stupid

quartz kindle
#

else you're sending stringified versions of that shards own information

#

basically, this shard will send text, and the other shards will eval() it

#

and send back the result

valid frigate
#

bruh moment

#

theoretically couldnt you spawn shards using some upper level management then use ipc to request shard data on demand

#

writing a gigantic script in a string seems kinda wack

quartz kindle
#

sure you can

#

you can define functions and then call broadcastEval("myfunction()")

valid frigate
#

and im pretty sure djs uses ipc internally anyway

#

oh yeah

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

valid frigate
#

right now i just request cluster data by sending out a request to other shards asking for their data

#

i mean shard data