#development

1 messages Β· Page 1595 of 1

cinder patio
#

So you should use async/await syntax or manually return a promise

honest perch
#

ah ok

blissful coral
#

I mean

#

I am testing my dashboard a lot

#

So

outer perch
#

I'll make one too someday

#

I actually have GCP ready @solemn latch, maybe I should swap πŸ€”

blissful coral
#

Looks so bad

glacial pagoda
#

    welcomechannel.send(`Hey <@${guildMember.user.id}> , Welcome To The **Dogey Army**. Please Read The Dm You've Gotten By @jolly zephyr For Steps To Unlock The Server!`);```
#

I got this error

#

how do i fix this

blissful coral
#

welcomechannel is undefined

glacial pagoda
#

But isnt it a variable?

blissful coral
#

Doesn't matter

#

They can be undefined

#

guildMember.guild.channels.cache.find(channel => channel.name === ':blush:welcome:blush:') returned undefined

#

Because it didn't find the channel

cinder patio
#

There isn't a channel with that name

glacial pagoda
#

oh

#

How do i make it find a channel id?

#

instead of name?

solemn latch
glacial pagoda
#

ok

blissful coral
#

Just use .get()

#

Instead of .find()

outer perch
#

which type is vips? const vips = new Set();

blissful coral
#

If your searching for id

blissful coral
outer perch
#

ty

glacial pagoda
#

ty

blissful coral
#

Mhm

glacial pagoda
#

@blissful coral so this guildMember.guild.channels.cache.get(channel => channel.id === '675173793483980808')

#

?

blissful coral
#

No

#

Get takes a string

cinder patio
glacial pagoda
#

oh

blissful coral
#

guildMember.guild.channels.cache.get('675173793483980808')

glacial pagoda
#

guildMember.guild.channels.cache.get('675173793483980808')

#

yeha

blissful coral
cinder patio
#

Set<TypeInside>

outer perch
glacial pagoda
#

ty

cinder patio
#

If you are using typeof t would be object, they're talking about typescript types

blissful coral
#

nvm

#

ohhhh

outer perch
#

yea

blissful coral
#

object for me

cinder patio
#

noted

outer perch
#

πŸ˜‰

#

omfg, I already asked around 50 questions here today

#

anyways, I need to ask at least once so I can learn

#

it looks like I'm already halfway through the process of rewriting to TS, even if there's a lot more left

#

but these little things will keep in my head so i can do the rewriting faster

outer perch
#

o_O

blissful coral
#

2 instances of the client

#

Same bot

#

let me try awaiting it

outer perch
blissful coral
#

and fetching instead

blissful coral
cinder patio
#

Wait 2 instances of the client? You should always have 1 client

blissful coral
#

Ik

#

It isn't a bot client

#

It just is logged into the API as a bot

#

But the bot doesn't have anything but a ready event

outer perch
#

hmmm

solemn latch
#

are you doing this in the ready event?

outer perch
#

when I want to test my code I use the Dev version's client token

blissful coral
solemn latch
#

guilds are not cached until the ready event

blissful coral
#

Wait

#

Yes

#

I start the dashboard in the ready event

solemn latch
outer perch
#

makes sense

blissful coral
#

yeah lol

solemn latch
#

so its logging after "bot is ready."?

blissful coral
#

Yes

solemn latch
#

πŸ‘€

blissful coral
solemn latch
#

bots not sharded?

blissful coral
#

Nope

solemn latch
#

welp

blissful coral
#

wait

#

client#guilds#fetch isnt a thing?

outer perch
#

any fast script to change every file extension in a folder from .js to .ts?

blissful coral
#

it is

#

lmao

mellow kelp
#

it's pretty easy

blissful coral
#

oh wait

#

hmmm

outer perch
blissful coral
#

guilds is undefined

mellow kelp
#

first make a function to recursively read a directory

#

get every path that ends with .js

#

and rename each of them to .ts

blissful coral
#

I am so confused

outer perch
blissful coral
#

it is client#guilds#fetch

outer perch
#

k

blissful coral
#

Your skipping the cache and going to the API instead

outer perch
#

k

blissful coral
mellow kelp
#
function readFullDirSync(dir) {
    const result = [];
    const files = fs.readdirSync(dir);

    for (const file of files) {
        const path = path.join(dir, file);

        if (fs.statSync(path).isDirectory()) {
            result.push(...readFullDirSync(path));
        } else {
            result.push(path);
        }
    }

    return result;
}
outer perch
mellow kelp
#

that's a function to recursively read an entire directory

#

it reads the base files of the directory first, and loops through them

#

if the file is a directory, the function calls itself to get the files inside that subdirectory

blissful coral
#

Ok this is so weird

#

I can't fetch the guild

mellow kelp
#

if the file is just a file it adds it to the results

blissful coral
#

But if I console.log() and use get() it finds it

outer perch
mellow kelp
#

readFullDirSync('some_directory/')

outer perch
#

but where

mellow kelp
#

idk

outer perch
#

insert it in the index?

mellow kelp
#

you wanted a script to rename .js files to .ts

blissful coral
outer perch
#

is there a command to execute functions?

blissful coral
#

I do it the line above

#

It works

#

The line below

#

It doesn't

#

The hell is going on

#

atTim

outer perch
quartz kindle
#
if(a) b; c;

is the same as

if(a) b;
c;

@blissful coral

mellow kelp
#

oh cool there's a command for that

#

no idea how it works but k

outer perch
#

cd to the folder u want

mellow kelp
#

yeah that's the command

outer perch
#

and execute this

warped torrent
#

is python or javascript preferred for bot development?

#

i coded my bot in python

mellow kelp
#

i meant that i don't know why those commands work

#

ofc i know how to run a command

warped torrent
#

are there any significant advantages/disadvantages

outer perch
#

whatever you want

outer perch
warped torrent
#

besides js being native discord

quartz kindle
quartz kindle
warped torrent
#

?

outer perch
warped torrent
#

wdym

glossy spoke
warped torrent
#

the web client uses js does it not?

glossy spoke
#

Ye

warped torrent
#

and the app is electron

mellow kelp
#

that doesn't matter at all

quartz kindle
# warped torrent ?

the desktop and browser clients are built with js
the android client is built with java
the ios client is probably built with swift
their servers are built with go, rust, python and probably more languages

glossy spoke
#

But js isn't native discord lmao

outer perch
mellow kelp
#

they use react tho

#

so js

#

but it still doesn't matter for bots

outer perch
#

hmm

warped torrent
#

they use electron + react

mellow kelp
#

it's not like making a bot in js will inherently make it faster

warped torrent
#

but wtvr wasn't really the main point

stark abyss
#
            pool.query(`UPDATE claninfo SET entryFee = ${entryFee}, due = ${due}, fee = ${fee}, role = ${role} WHERE clan = ${clanID}`, (err) => {
              if(err) return console.log(err + " | setup clan exist query")
            })  ```
so apparently `due = ${due}` is causing me error: column "daily" does not exist. I just don't understand why is that, and how to prevent it.
outer perch
#

angular vs react, REEEEEEEEEEEEEEEEEEEEEEE

warped torrent
#

creation wise

mellow kelp
warped torrent
#

But I'm much more experienced with python anyways

#

so I'll stick with it

mellow kelp
#

aight cool

blissful coral
#

I FIXED IT

quartz kindle
#

yes go with what you're more experienced

blissful coral
#

I DONE DID IT

#

HOLYYYYY

#

Fucking hate ejs with a passion rn

mellow kelp
#

don't wanna start another civil war

stark abyss
#

is it because I called due text?

outer perch
quartz kindle
#

lul

stark abyss
#

Tim do you know?

blissful coral
#

It wasn't the problem tho

mellow kelp
#

@outer perch vscode tinder is lit tho

outer perch
#

wot

quartz kindle
#

it was the reason it was logging guild not found

blissful coral
#

Something when compiling the files

#

Yeah that too

#

lmao

quartz kindle
#

xD

blissful coral
#

I think I fixed it before you pinged me

#

and I never read it xD

quartz kindle
#

ah xd

stark abyss
quartz kindle
outer perch
#

Parameter 'undefined' implicitly has an 'any' type, but a better type may be inferred from usage. lmao

stark abyss
#

its "daily"

quartz kindle
#

then it needs to be in quotes

stark abyss
#

hm

quartz kindle
#

:^)

stark abyss
#

var due = "daily";
this is what its like tho

mossy jackal
#

die

quartz kindle
stark abyss
#

${"due"}?

quartz kindle
#

no

outer perch
#

should I do module.exports on commands?

#

with TS?

stark abyss
quartz kindle
#

quotes define a string literal, so "text" is a string, but if you put it inside another string, the quotes are removed, otherwise it would be stupid. for example ```js
a = "text"
b = abc ${a} xyz

b is equal to `abc text xyz` and not `abc "text" xyz`
#

however the sql query must be column = "text" and not column = text

outer perch
stark abyss
#

okay I think I understand

quartz kindle
outer perch
quartz kindle
#

if you do export function

#

then you get it with import function from

#

if you do export default

#

then you do import * as function from

#

or import default from

outer perch
#

but

#

I am talking about the command handler

#

I need to export the code for index.js to read

quartz kindle
#

what are you exporting tho?

#

isnt it a function?

outer perch
#

full code

quartz kindle
#

you dont export full code, not even in js

#

you export specific things

#

like module.exports = something

outer perch
#

yes

quartz kindle
#

so what are you exporting

outer perch
#
module.exports = {
    name: 'angry',

    execute(bot, message, command, db, lang) {
        const user = message.mentions.users.first();
        const rnd = Math.floor(Math.random() * 6);

        if (!user || user == message.author) {
            return message.channel.send(`${message.author}${lang.angry.gotAngry}`, { files: [`img/actions/${command.name} (${rnd}).gif`] }).catch(err => { console.error(err); });
        }
        else if (user == bot.user) {
            return message.channel.send(`${message.author}${lang.angry.gotAngryWithUs} 😧`, { files: [`img/actions/${command.name} (${rnd}).gif`] }).catch(err => { console.error(err); });
        }
        else {
            message.channel.send(`${message.author}${lang.angry.gotAngryWith}${user}!`, { files: [`img/actions/${command.name} (${rnd}).gif`] }).catch(err => { console.error(err); });
        }
    },
};
quartz kindle
#

you are exporting an object containing name and execute

#

so you can literally do

outer perch
#

oh, now I understand

#

silly me

quartz kindle
#
export const name = "angry"
export function execute(...) {}```
outer perch
#

aha

quartz kindle
#

and then you can import name from or import execute from

outer perch
#

what about aliases

#

this one doesn't have any

#

but the others have

#

and

#
interface Cmd {
    name: string;
    aliases: string[];
    execute(bot: Client, message: Message, command: Object, db: any, lang: Object, language: string, prefix: string, args: string[], serverSettings: Object): void;
}
quartz kindle
#

same thing

#

export const aliases

outer perch
#

as null?

quartz kindle
#

for example yes

outer perch
#

what If I don't export them

quartz kindle
#

or make aliases optional in your interface

outer perch
#

it'll still be undefined

#

oh yeah

#

aliases?

quartz kindle
#

yes

outer perch
#

~~(^o^)~~

vestal parrot
#

Hello everyone. Can someone help me about Python? I have a little question πŸ™‚

#

How can I obfuscate my python codes safely? Is pyarmor safe method for it?

solemn leaf
#

Why would you need to obfuscate

midnight blaze
#
module.exports.test = function test(test) {...}

Idk, I use this

vestal parrot
solemn leaf
#

You dont really need to

mellow kelp
#

python is server-side, there's no need for obfuscation

solemn leaf
#

But ok

mellow kelp
#

i guess you could rename variables to random letters

#

but you can't really obfuscate the code, since python relies on indent and that sort of stuff

mossy jackal
#

DIE

outer perch
#

I just noticed that ESLint isn't working on TS o_O

solemn leaf
#

Argosa i have only seen obfuscated code in like lua

mellow kelp
#

you gotta use @typescript-eslint/parser

#

wait whos named type

solemn latch
#

f

mellow kelp
#

crap

solemn leaf
#

You can change the encoding

#

But that might be about it

vestal parrot
#

Thanks for helping πŸ™‚ Sorry, I'm just curious.
For example; I develop online trade bot and will sell it. Will this be safe when I don't obfuscate the codes?

solemn leaf
#

You can change the encoding

#

And maybe compress to a executable

#

Other then that I dont know

vestal parrot
#

You have been very helpful. Thanks a lot.

outer perch
#

I never understood how .exe works

#

I'll be serious, never had time for that too

solemn leaf
#

Its basicly a zip

#

I think

#

Just compressed alot

#

And runs c

#

Idk much either

vestal parrot
#

As far as I researched best way for obfuscation in python is cython and pyinstaller to make .exe files.

solemn leaf
#

Yep so I thought

mellow kelp
#

oh yeah exe files

solemn leaf
#

I think you can chnage the encoding of the py files

#

Say to like some random encoding

#

Then just decode it once you run it

outer perch
#

I'd like to decode Sonic.exe

mellow kelp
#

lmao

vestal parrot
#

Thats a good idea. Lastly which programming language is the best for obfuscation? I think c++

solemn leaf
#

@outer perch there id a windows terminal command for that

mellow kelp
vestal parrot
#

Why every programmers asks me; why would you need to obfuscate?

mellow kelp
#

obfuscation is mostly used on frontend

solemn latch
#

its not common to need to

mellow kelp
#

to prevent people from reverse-engineering javascript code

outer perch
#

obfuscating games

vestal parrot
#

Oh okay copy that πŸ™‚

outer perch
#

wait a minute

mellow kelp
#

wait obfuscating games?

#

well fair enough

quartz kindle
#

obfuscation is not needed unless your program has some kind of trade secret in it

#

or an anti-crack/anti-cheat

#

if you just want to hide your source-code for copyright reasons, look into compiling to native code, if your language supports it

outer perch
#

why didn't Scott Cawthon hide the variables from the FNaF games?

#

you can change those to get further in the game without actually playing the game

quartz kindle
#

when it comes to videogames, having them cracked can actually help you

midnight blaze
#

a question, anyone ever worked with terminalservers aka windows server distro?

quartz kindle
#

it gives you more exposure and popularity, and also more interest

vestal parrot
#

Tim there is something I don't understand. Aren't developers afraid of their program being stolen by others?

quartz kindle
#

there have been many game developers going on thepiratebay and thank users for liking their game so much they even cracked it

#

and the result was that more and more people started buying it

outer perch
#

same for Undertale

#

save files

mellow kelp
#

mods hashflushed

outer perch
vestal parrot
quartz kindle
#

if your code is compiled, you already have a decent protection

#

source code cannot be easily decompiled, not to the same code as it was

#

you can decompile it in many different ways but it will not be the same

outer perch
#

programs are evolving to WebApps

quartz kindle
#

decompiled code looks like a bunch of weird functions and variables with weird names

mellow kelp
#

unless you're using jar files πŸ˜”

outer perch
#

so u don't have to download anything

mellow kelp
#

pwa's are amazing

outer perch
#

and to avoid those things

mellow kelp
#

just obfuscate your js code

#

and poof

outer perch
#

u can't decompile if u can't access

mellow kelp
#

well uhh

#

inspect tool

#

view page source

quartz kindle
#

js is one of the languages that is very hard to protect

vestal parrot
#

I understood properly now. Thanks πŸ™‚

quartz kindle
#

but not impossible

outer perch
#

uhh, block IPs outside the developers'?

drowsy grail
#

then the browser can't load it

outer perch
#

talking about sensitive info

#

idfk

quartz kindle
#

this is how decompiled code looks like

drowsy grail
#

that is more readable than i expected

quartz kindle
#

yes, its readable

outer perch
quartz kindle
#

but there is no context

drowsy grail
#

yup

quartz kindle
#

you dont know what is what

#

there are no strings either

outer perch
#

no comment lines?

#

I saw them now

drowsy grail
#

thats just c in general tho

quartz kindle
#

this is another example

outer perch
#

weird

drowsy grail
#

oof lol

quartz kindle
#

it depends on the language as well

drowsy grail
#

for sure

quartz kindle
#

some languages produce more complex compiled code than others

#

and also depends on the compiler

drowsy grail
#

makes sense

outer perch
#

@mellow kelp I installed eslint for TS, but it's not saying shit about those extra tabs

mellow kelp
#

that's not a typescript thing tho

#

check your eslint config

quartz kindle
#

if you make a game in a compiled language like c++ or similar, and distribute the exe, people will be able to reverse engineer many things, but they wont be able to extract the exact source code nor clone the entire project

vestal parrot
#

@quartz kindle Which software languages do you know?

quartz kindle
#

mostly just js

#

and maybe a little bit of c++ and php

vestal parrot
#

Is c++ good for desktop apps?

honest perch
quartz kindle
#

if you want your code to be 100% reverse-enginnering-proof you can always use movfuscator :^)

grizzled raven
#

wonder what number the variable c is now, with everyone incrementing it with c++

quartz kindle
#

lmao

outer perch
vestal parrot
mellow kelp
quartz kindle
outer perch
#
{
    "extends": "eslint:recommended",
    "env": {
        "node": true,
        "es6": true
    },
    "parserOptions": {
        "ecmaVersion": 2021
    },
    "rules": {
        "brace-style": ["error", "stroustrup", { "allowSingleLine": true }],
        "comma-dangle": ["error", "always-multiline"],
        "comma-spacing": "error",
        "comma-style": "error",
        "curly": ["error", "multi-line", "consistent"],
        "dot-location": ["error", "property"],
        "handle-callback-err": "off",
        "indent": ["error", "tab"],
        "max-nested-callbacks": ["error", { "max": 5 }],
        "max-statements-per-line": ["error", { "max": 3 }],
        "no-console": "off",
        "no-empty-function": "error",
        "no-floating-decimal": "error",
        "no-lonely-if": "error",
        "no-multi-spaces": "error",
        "no-multiple-empty-lines": ["error", { "max": 2, "maxEOF": 1, "maxBOF": 0 }],
        "no-shadow": ["error", { "allow": ["err", "resolve", "reject"] }],
        "no-trailing-spaces": ["error"],
        "no-var": "error",
        "object-curly-spacing": ["error", "always"],
        "prefer-const": "error",
        "quotes": ["error", "single"],
        "semi": ["error", "always"],
        "space-before-blocks": "error",
        "space-before-function-paren": ["error", {
            "anonymous": "never",
            "named": "never",
            "asyncArrow": "always"
        }],
        "space-in-parens": "error",
        "space-infix-ops": "error",
        "space-unary-ops": "error",
        "spaced-comment": "error",
        "yoda": "error"
    }
}
vestal parrot
quartz kindle
#

movfuscator makes your code 9999x slower

#

xDD

#

its still brilliant

#

read about it

vestal parrot
#

I laughed.

honest perch
#

.NET is a pain to protect

outer perch
honest perch
#

i just use googles eslint config

quartz kindle
outer perch
outer perch
glossy spoke
quartz kindle
#

this is what i love about programming

outer perch
#

asduifghpaudifgh

quartz kindle
#

you can do whatever the fuck you want, no matter how stupid

honest perch
#

tim i have code for you tomorrow cause it aint working

quartz kindle
#

so... it works today but it wont work tomorrow?

outer perch
#

Why? Because I thought it would be funny

outer perch
#

what does the flag --save-dev do?

solemn latch
#

things that work today, but not tomorrow suck

honest perch
#

you can also use -D

glossy spoke
#

on messageUpdate event the parameters are oldMessage and newMessage, right?

outer perch
#

what if I don't flag anything on npm i

quartz kindle
#

you probably know this one already, the most famous source code comment

glossy spoke
#

oh right.

outer perch
#

roflmao

outer perch
sudden geyser
outer perch
#

kek

#

didn't have "parser": "\@typescript-eslint/parser",

#

wtf

#

now it's this

quartz kindle
#

welcome to eslint

outer perch
#

it's an interface!!!

quartz kindle
#
"extends": [
        "eslint:recommended",
        "plugin:@typescript-eslint/eslint-recommended",
        "plugin:@typescript-eslint/recommended"
    ],
outer perch
#

should I remove no-shadow and no-unused-vars?

#

those didn't override the rules

#

maybe I should delete the rules

quartz kindle
#

another answer from SO

#
{
  "parser": "@typescript-eslint/parser",
  "extends": [
    "plugin:@typescript-eslint/recommended"
  ],
  "rules": {
    "@typescript-eslint/no-unused-vars": "error",
    "no-unused-vars": "off"
  }
}
outer perch
#

what's SO, @quartz kindle?

solemn leaf
#

I tried

const newMessage = await translate(message.content, { to: "en", engine: "libre" });
glossy spoke
#

read the docs

solemn leaf
#

I am

#

this is what it says to do

#

no?

quartz kindle
solemn latch
solemn leaf
#

okay

solemn latch
#

you need to specify what from, and what to if the from isnt english

solemn leaf
#

form

#

where

#

oh from

white drum
#

could someone help me out with what im trying to do here
cause it keep crashing everytime a user doesnt have a nickname set

solemn leaf
#

can I make it translate from all languages to en

solemn latch
#

it needs a from if its not en

#

it says it right in the page

#

from: the string of the language to translate to. It can be in any of the two ISO 639 (1 or 2) or the full name in English like Spanish. Also defaults to en.

solemn leaf
#

😐

#

Error: nl is not supported

solemn latch
#

dutch isnt supported by libre

outer perch
solemn latch
#

best translator

glossy spoke
#

you can change the default lang

solemn latch
#

chinese is easy

#

lmao

outer perch
#

how do you make a gif like that?

solemn latch
#

i use sharex

#

then i have my own image host, but imgur works just aswell

outer perch
#

how do I reload VSC without closing it?

quartz kindle
#

why?

crimson vapor
#

you don't need to reload VSC, if you mean the terminal you can do Ctrl + C

outer perch
#

for eslint to reset

crimson vapor
#

open command prompt and type eslint there should be a restart eslint one

outer perch
#

sometimes only after closing the properties take effect

crimson vapor
quartz kindle
#

but what cant you close and reopen?

#

you have a process running in the terminal?

#

you can try reload window from the command palette

outer perch
quartz kindle
#

lol

outer perch
#

and a low-spec pc

quartz kindle
#

but all your open tabs will still be open

outer perch
#

VSC takes around 20 secs to open

grizzled raven
#

it's taking you way longer than 20 seconds to find a better option mmLol

solemn latch
#

vsc takes 20 seconds to open?

#

it seriously opens in under 3 seconds on my pc

opal plank
#

40, take it or leave it

crimson vapor
#

you guys close vsc?

grizzled raven
#

wish i didn't need to so i could just ctrl-z my way back to an empty workspace whenever i need to

#

but if i don't close vscode for a while it just starts to die because my pc bad

crimson vapor
#

lol

#

yikes

quartz kindle
#

if vsc takes 20 seconds, switch to sublime text

#

sublime is fast af

opal plank
#

use notepad

#

not the ++ one, just notepad

modest maple
#

20 secs is longer than it takes me to start pycharm mmLol

mellow kelp
#

nah

#

use nano πŸ‘

earnest phoenix
#

vim

#

good luck finding out how to exit

quartz kindle
#

is it just me or are most windows programs named very literally by what they do?

lyric mountain
#

firewall is not a flaming wall

quartz kindle
#

linux and mac for example have very creative names for many apps

opal plank
#

steam does not provide steam

earnest phoenix
#

cortana mmLol

opal plank
#

chrome is red blue yellow

lyric mountain
#

internet explorer is not named chrome downloader

quartz kindle
#

xD

opal plank
#

Twitch does not twitch

solemn latch
#

i couldnt imagine developing on a pc that takes 20 seconds to open VSC though eyes_shaking

opal plank
#

Discord does create discord, so i guess they named that one right, shit goes down every 2 days

earnest phoenix
#

2 days is an understatement

opal plank
solemn latch
#

anyone going to watch the rover landing on thursday

opal plank
#

i'll probably be drunk on thrusday.

and tomorrow

and later today

and prob the rest of the week tbh, hail jaggermeister! Buzz coding ftw

earnest phoenix
#

bot

lyric mountain
solemn latch
#

yeah

lyric mountain
#

spacex?

solemn latch
#

nasa

lyric mountain
#

meh

#

I wanna see a tesla wandering on mars

#

where will they land the rover this time?

#

iirc they were interested in the ice deposits near the poles

solemn latch
#

its in an old lake

#

looking for life

mellow kelp
#

i wanna see the cybertruck land on mars

#

gotta confuse aliens

earnest phoenix
#

gonna scare those water molecules off

solemn latch
#

very development

#

totally not paying attention

#

dont warn me hope 😦

warm oracle
#

So I'm trying to get my bot to respond to both @mentions and custom prefixes (discord.py)
Here's the code for the assignment of the bot object:

bot = commands.Bot(command_prefix= getPrefix, owner_id = int(ownerID), case_insensitive = True)

And here's the code for that function it calls:

async def getPrefix(bot, message):
    guild = message.guild
    if guild and ("database" not in disabled):
        server = await fetchServerEntry(message.guild.id)
        serverPrefix = server[1]
        return commands.when_mentioned_or(serverPrefix)
    else:
        return commands.when_mentioned_or("!")

Whenever this is ran, this error occurs:
TypeError: command_prefix must be plain string, iterable of strings, or callable returning either of these, not function

fetchServerEntry always returns a list, and server[1] is the column which contains the prefix for the specified server, which is always a string. I don't see why it's complaining about the type, can anyone spot it?

#

I should note that @mentions work, but custom prefixes don't

#

Also custom prefixes were working before I made this change

ember lodge
#

Code:


app.use(passport.initialize());
app.use(passport.session());
app.get("/auth/login", passport.authenticate("discord", { scope: scopes, prompt: prompt }), (req, res) => {});
app.get("/auth/callback",
    passport.authenticate("discord", {
        failureRedirect: "/"
    }), (req, res) => {
        res.redirect("/")
    }
);

app.get("/auth/logout", (req, res) => {
    req.logout();
    res.redirect("/");
});


app.get("/", (req, res, profile) => {
  
  if(req.user){
    let datoServidores = req.user.guilds.filter(p => (p.permissions & 2146958591) === 2146958591);
res.redirect("/server")
  } else {
res.redirect("/auth/login")
  }
});

After clicking authorize i get this error:
https://media.discordapp.net/attachments/579346890357866507/811365536666877962/unknown.png

#

Someone knows what error i have?

unreal kiln
#

someone hacked my music bot and have no clue on who did it

earnest phoenix
#

there's no such thing as hacking bots

#

you leaked some important information

mellow kelp
#

someone could have your token

warm oracle
unreal kiln
outer perch
#

what type is err, in .catch?

#

string?

earnest phoenix
#

an Error

toxic jolt
#

tim

#

is online?

outer perch
#

oh, so Error's a type

toxic jolt
#

@quartz kindle UwU

#

hi

ember lodge
outer perch
#

what options do i have to import json correctly into TS?

#

or the only way is through require?

mellow kelp
#

you can import it too

#

or you can use fs to dynamically load it

outer perch
#

says it cannot find module

#

but with require it can

mellow kelp
#

do you have resolveJsonModule enabled?

outer perch
#

where

#

config?

mellow kelp
#

yeah

#

tsconfig

outer perch
#

yes

mellow kelp
#

hmm

outer perch
#

what's the command to execute Ts with node?

mellow kelp
#

what's your code

#

ts-node

outer perch
#

I use npx ts-node index.ts

mellow kelp
#

yeah that works

outer perch
#

should it be just ts-node index.ts?

mellow kelp
#

nah

#

it works with npx

outer perch
#

before that

mellow kelp
#

yeah it's because the channel might be a DMChannel

#

DMChannel doesn't have a guild

outer perch
#

but I'm sure it's not

mellow kelp
#

but typescript isn't sure

#

use instanceof to check that the channel isn't a dmchannel

outer perch
#

where?

#

a line to check?

mellow kelp
#

yeah

#

as simple as

if (channel instanceof DMChannel) return;
outer perch
#

woah

mellow kelp
#

typescript will know that channel isn't a DMChannel from now on

outer perch
#

but...

zenith terrace
#

you sure its just not message.guild?

solemn latch
#

no reason to do message.channel

#

yeah

#

great minds think alike

outer perch
zenith terrace
#
if(!message.guild.me.hasPermission('permission'))```
quartz kindle
#

otherwise you have to use npx

outer perch
#

I guess

#

maybe not, since .gitignore has node_modules

quartz kindle
#

also

#

if you know the channel type

#

typecast it

#

channel = message.channel as TextChannel

#

or (message.channel as TextChannel).guild

mellow kelp
#

yeah you can also do that

#

you might want to check if the channel is a DMChannel if there are no previous checks before tho

solemn latch
#

does message?.guild or whatever not exist in ts?

quartz kindle
#

pretty sure it does

#

since it supports esnext features

#

but in order to use message.guild?.name you would have to declare guild as an optional property on message

#

and i dont know if union types with missing fields count as optional there

mellow kelp
#

i think guild is optional

outer perch
zenith terrace
#

any time I look up about typescript all it shows it discord.js

outer perch
#

if (message.channel.type === 'dm' || message.author.bot) return;

#

I have this in index

zenith terrace
#

should work

outer perch
#

always worked

#

as .js

quartz kindle
#

works for js, but doesnt tell ts what type is it

#

as far as ts is concerned, message.channel is still DM | Text | News

outer perch
#

but TS doesn't complain about that in index

#

not even once

quartz kindle
#

because djs has wack typings

#

because channel.type exists in all 3 of them

#

but channel.guild doesnt

outer perch
#

yea

#

which language and lib do you use @quartz kindle?

quartz kindle
#

js and djs-light, which is basically djs

outer perch
#

aight

#

why don't you like TS?

quartz kindle
#

because its a pain to setup

outer perch
#

xD

opal plank
#

for example, i have all my commands be guild only

#

they cant be executed in dm's

opal plank
#

if you're case is the same, theres no need to add extra logic on runtime

outer perch
#

it has been working forever

opal plank
outer perch
#

xD

quartz kindle
#

how would you cast it to avoid runtime logic?

#

like cast it only once

#

assign it to a variable?

opal plank
#

instance of is the same as if() something

#

you adding extra logic knowing the variable type

#

theres no need

#

its the same as this tim

quartz kindle
#

how do you stop the code from continuing with casting only then?

opal plank
#

client.on('message', message => {
  if(!message.channel.guild) return;
  command.run(message);
})
// and then adding this to your command
if(!message.channel.guild) return;
mellow kelp
#

well that works if you previously checked that the message has a guild

opal plank
#

types are only used in ts

#

its redudant to check it twice if you already know its type

quartz kindle
#

yes but how does type casting prevent the code from executing in this case

#

what is the logic behind it

opal plank
#

wdym?

#

how it transpiles instanceof to js?

quartz kindle
#

yes, how it transpiles to an if

#

with type casting

opal plank
#

thats a question i've had an answer too, but never got the answer for it

#

nor did i check

earnest phoenix
#

hey just curious is it possible to add other bots using discord.js? this wont be a public bot dw

opal plank
#

should be fairly simple though

quartz kindle
#

show a ts snippet

opal plank
#

let me get a test config rq

quartz kindle
#

like how would you replace the if in ts

#

if you do x as y, does the code not execute if x cannot be y?

mellow kelp
#

instanceof is a js thing

outer perch
tiny dune
#

hey

#

everyone

#

hola todos

opal plank
#

@outer perch both works

outer perch
#

with !message.channel.guild, TS will point at that

#

cuz it can be 3 types where .guild doesn't exist in 2

slim stag
opal plank
#

@quartz kindle oh, its js

quartz kindle
#

you said there is no need for extra logic at runtime

#

thats what im confused about, how can do execute an IF with ts casting only?

opal plank
mellow kelp
#

it uses instanceof which is a javascript thing

opal plank
quartz kindle
#

thats not what i mean

opal plank
#

you're checking types twice

quartz kindle
#

show me a ts snippet that works without an IF

opal plank
#

wdym?

quartz kindle
#

you said that an if was not necessary

slim stag
quartz kindle
#

and to typecast it instead

opal plank
#

well yeah, you dont need to check if its DmChannel

#

cuz they already are removing it

quartz kindle
#

and if they didnt?

opal plank
#

then you would need it, yes

quartz kindle
#

ah

slim stag
#

who

#

me

quartz kindle
#

i thought you said they didnt need that if

opal plank
#

well it cna be one of the 3

#

so you need to do some logic to remove the ones you dont want

quartz kindle
#

yes

opal plank
#

though i could cheat and use a switch

#

that wouldnt be an IF, technically

quartz kindle
#

i got confused because it sounded like you could to ```js
X as Y

#

like the casting would replace an IF check

opal plank
#

oh, nono

#

thats simply saying : i know x is y in this case, dont worry

quartz kindle
#

yes thats what i thought

opal plank
#

checking with instanceof is smart, but in this case is redudant since they already know all messages are coming from guilds

#

and iirc you can remove dm message intents too

#

so technically speaking you wouldnt even need that in the index

quartz kindle
#

is there a way to cast something without assigning it to a variable and without having to repeatedly cast inline again?

opal plank
#

hmmm

quartz kindle
#

well you could replace the variable itself no?

opal plank
#

if its a function you could cast it in the function parameter

#

otherwise, i dont think so

quartz kindle
#

message.channel = message.channel as TextChannel?

opal plank
#

let me check something, i think i might be able to merge it

#
import {Message, TextBasedChannel } from 'discord.js';
interface _Message extends Message {
channel!: TextBasedChannel 
}
module.exports = {
  run: (message: _Message) {
  //logic
  }
}

you might be able to fly with this

outer perch
#

! means must?

opal plank
#

it means its always present

outer perch
#

ah, k

quartz kindle
#

well thats a way i guess

#

but at that point just reassign it lol

#

you could also destructure it

#
run: ({ channel: TextChannel }) {
  channel.guild
}
opal plank
#

You could pass both tho

#

And use channel instead of message.channel

outer perch
quartz kindle
#

you dont usually call message anyway, usually just content and channel, so you can just desctructure both

ancient vault
#

@slim stag

#

here

opal plank
outer perch
#

just tell me something

ancient vault
#

why are we doing this?

#

we can just work on something else you know

#

we can ride our bikes

#

or maybe

#

run

pale vessel
#

No

ancient vault
#

or something

opal plank
#

@ancient vault go somewhere else

ancient vault
outer perch
#

cast means what? maybe I know what it means in my language, but explain anyways

opal plank
#

cats means you're saying, okay, this variable is of this type

ancient vault
#

I'm trying to help my STuPid friend @slim stag

opal plank
#

say, this

ancient vault
#

:,

quartz kindle
#

transforming one type to another type, as long as they are compatible

slim stag
#

can sombody help me

ancient vault
#

;-;

slim stag
#

ho to run the bot

ancient vault
opal plank
#
let a:string = 'bla';

let b:number = a as number
ancient vault
#

Several people are typing...

lyric mountain
#

You can't "run" a bot

slim stag
#

bruh why on dms you cant but on here can

lyric mountain
#

Bots are programs that run somewhere

slim stag
opal plank
#

even though a is a string, you're casting it and saying: okay, a is now a number

ancient vault
slim stag
#

yeah the program

#

i dont know

lyric mountain
#

You need to code it

quartz kindle
#

for example in a language like c++, where you have multiple types of integers, you can cast a signed int to an unsigned int, or cast an int32 to int16, or even cast a char to an int and vice versa

slim stag
opal plank
#

this example is stupid, but you can see your cases with d.js

#

using channel types

lyric mountain
#

But what what?

opal plank
#

since there are 3 of them

ancient vault
lyric mountain
#

Like, you need to write the code from scratch

outer perch
#
let msg = message.channel as TextChannel;
msg.bulkDelete(number, true).then(deleted => {
//logic
});
``` like this innit?
lyric mountain
#

Or use some sketchy bloated maker like bdfd or dbd

outer perch
#

pun intended

quartz kindle
#

thats one option yes

opal plank
#

that would work, yeah

dusky sundial
quartz kindle
#

another option is (message.channel as TextChannel).bulkDelete

opal plank
#

^^

outer perch
opal plank
#

i prefer that one for single cases

outer perch
#

the least lines

#

the better

opal plank
#

if you use more than once, use a variable

crimson vapor
#

wtf

quartz kindle
#

another is (<TextChannel>message.channel).bulkDelete

opal plank
#

otherwise you're gonna be having more and more code unecessarily

#

though theres no harm

crimson vapor
#

why is msg message.channel?

opal plank
#

type are only used in ts

outer perch
quartz kindle
#

possibly

#

as was created to fix a compatibility issue with jsx/react

outer perch
#

o_O

quartz kindle
#

which already used <> for something else

outer perch
#

I hate when TS says this maybe converted to that

#

I never know if I have to put it like that already

#

or keep as is

opal plank
#

well, you DID copy my settings, which is a lot strict

safe path
opal plank
#

which is good, you're learning the hard way just once

opaque seal
#

Does anyone know how to do that?

outer perch
opal plank
#

did you make it more lax?

outer perch
#

wait no

zenith terrace
outer perch
#

I meant eslintrc, oof

opaque seal
opal plank
#

well i am using eslint too

opaque seal
#

yeah

#

they are emojis from my support server

quartz kindle
#

then you can react using the id

opaque seal
#

no it doesn't work

outer perch
#

let me know one thing

quartz kindle
#

it works across shards

opaque seal
#

it says Unknown emoji

quartz kindle
#

show code

outer perch
opal plank
#

not .ts

#

just tsconfig

#

without the dot

opaque seal
#

But here it is an example

opal plank
#

wtf

#

did my status break?

opaque seal
#

Command

const emojis = require('../../../core/aesthetics/emojis')
const vcManager = require('../../../core/utils/vcManager')

module.exports = {
  name: 'lock',
  aliases: ['l', 'close'],
  description: 'Locks your VC so that no one has access to it (besides moderators)',
  reqArgs: false,
  usage: null,
  exampleUsage: null,
  category: 'VC',
  reqVoting: false,
  reqChoice: null,
  reqRole: false,
  reqServerPerms: true,
  reqOwner: true,
  cooldown: 3,
  async execute (ctx) {
    const vc = ctx.member.voice.channel
    vc.permissionOverwrites.each(async perm => {
      if (perm.id !== ctx.guildSchema.role && perm.id !== ctx.member.guild.me.id) await perm.update({ CONNECT: false })
    })
    await vc.updateOverwrite(ctx.guildID(), { CONNECT: false })

    const lockedName = ctx.genInfo.defaultLockedName
    if (lockedName) await vcManager.changeName(vc, ctx.vcInfo, null, lockedName, ctx.member, ctx.guildSchema)

    await ctx.react(emojis.accept)
  }
}
outer perch
opal plank
#

hmmm

opaque seal
#
module.exports = {
  accept: '717523612936175616',
  reject: '717523612906684428',
  acceptExtended: '![check_yes](https://cdn.discordapp.com/emojis/717523612936175616.webp?size=128 "check_yes")',
  rejectExtended: '![check_no](https://cdn.discordapp.com/emojis/717523612906684428.webp?size=128 "check_no")',
  arrowRight: '738133448593768560',
  arrowLeft: '738133449021456406',
  error: '![error](https://cdn.discordapp.com/emojis/767034400495763467.webp?size=128 "error")',
  ultimate: '![AstroUltimateCirclemin](https://cdn.discordapp.com/emojis/741346705710252112.webp?size=128 "AstroUltimateCirclemin")',
  lock: '752143594827284580',
  unlock: '752143594361716777',
  hide: '752140305574264912',
  unhide: '752134135098769458',
  chat: '752134135216078898'
}

emojis

opal plank
#

let me restart my client

opaque seal
#

@quartz kindle

opal plank
#

its showing Visual Studio instead

#

i wonder which is faster tho

#

requiring a json file or a .js one

#

cuz i have a similar thing on mine, but i use json

#

and around 100 emotes hardcoded lul

opaque seal
#

The issue here is not the speed unfortunately xD

quartz kindle
opaque seal
#

okay

opal plank
#

i know, just thinking out loud

opaque seal
#

Ffs discord.js

#

why do you have to do this to me

opaque seal
#

maybe it's faster at caching json files

opal plank
#

tim, more testing for ya and yer fancy performance tools

opaque seal
#

What if the emoji is animated @quartz kindle

#

Do I keep the a: ?

opal plank
#

add a:, yes

misty sigil
#

ye

opaque seal
#

k

misty sigil
#

auch

#

erwin't too fast

opaque seal
#

and without angular parenthesis right

quartz kindle
#

without yes

#

with for messages, without for reactions

opal plank
quartz kindle
#

dafuq are you downloading

#

a car?

opal plank
solemn leaf
#

no

mellow kelp
#

ah yes

#

downloading cock

solemn leaf
#

prob every message ever sent in a guild

opal plank
#

this is too high iq for somepeople

#

tim knows

boreal iron
#

@quartz kindle Is there a lib similar to djs without all the caching bullshit - just the basic functionality?

solemn leaf
#

iq isnt actually for smarts

quartz kindle
mellow kelp
#

(not sponsored)

opal plank
#

a car

#

indeed

mellow kelp
#

cool

#

what brand

quartz kindle
#

the other ones are not similar

opal plank
#

tim explain to them the joke bliz

mellow kelp
#

does djs-light cache guilds?

#

or can i at least enable it

boreal iron
#

Other ones?

quartz kindle
#

by default yes

mellow kelp
#

yay

solemn latch
#

it caches what you want afaik

quartz kindle
mellow kelp
#

does it read my mind

opal plank
solemn leaf
#

yes

boreal iron
#

Hmm gonna take a look as soon as I’m back home ty

opal plank
#

detritus amazing

mellow kelp
#

am i supposed to use the command client

opal plank
#

yeah

#

thats your main client

mellow kelp
#

they show it a lot in the examples but i feel like i need something else

#

i wanna use the shardclient

opal plank
#

then you can use clusterClient option to amke it cluster

#

or shardClient for a single one

mellow kelp
#

o

#

aight then

#

time to port to detritus

opal plank
#

just do this

#
const commandClient = new CommandClient(config.token, {
  useClusterClient: true,
}
#

detritus i can spoonfeed a bit more, their docs are a bit lacking

mellow kelp
#

yeah

opal plank
#

thats for when you want to use multiple shards

mellow kelp
#

but seems simple enough

grizzled raven
#

who wants to benchmark requiring json files vs requiring js files

opal plank
#

if you dont, set that to false

#

Tim

grizzled raven
#

tim

mellow kelp
#

nah im gonna use either the shardclient or clusterclient

#

tim

#

time for your daily benchmark

opal plank
#

i'd recommend clustering, but setting a single shard

#

that'd save you from the hassle of porting it later down the line

mellow kelp
#

is there a difference?

opal plank
#

source: dude, trust me

mellow kelp
#

i don't fully get what the clusterclient does

mellow kelp
opal plank
#

basically its a client with a lot of shards in it

#

thats about it

lyric mountain
#

Glued glass cup

opal plank
#

clusterClient is a client with lots of ShardClients inside

mellow kelp
#

i mean my bot doesn't use sharding yet

opal plank
#

keyword: yet

#

if you dont think it will EVER need to be sharded, dont bother

#

otherwise, better start soon

#

and use a single shard

mellow kelp
#

oh well k

#

fair enough

#

man these typescript libs are amazing

grizzled raven
#

better than taking your bot down for 2 months to rewrite it mmLol

mellow kelp
#

you get declarations for each file

grizzled raven
#

like uh, a certain someone

opal plank
#

i already spawned 5 shards to split the workload

mellow kelp
#

poggers ascii text

outer perch
#

I hate it πŸ‘‡πŸ»

opal plank
#

its not required btw

outer perch
opal plank
#

that shouldnt prevent your code from compiling

opaque seal
#

Thanks Tim it works

opal plank
#

thats cuz u didnt enable the json option deadly

outer perch
mellow kelp
#

what's your tsconfig.json

outer perch
#

but my OCD's killing me

quartz kindle
#

there will probably be 0 difference

outer perch
mellow kelp
#

quick benchmarksℒ️

mellow kelp
outer perch
#

but without "strict" and "strictNullChecks"

grizzled raven
quartz kindle
#

xd

mellow kelp
#

send the actual json

grizzled raven
#

didn't even say anything and i got y'all laughing

mellow kelp
#

lol

opal plank
#

--resolveJsonModule use this @outer perch

outer perch
#
{
  "compilerOptions": {
    "target": "ESNext",
    "module": "CommonJS",
    "moduleResolution": "node",
    "outDir": "out",
    "sourceMap": true,
    "allowJs": true,
    "esModuleInterop": true,
    "importHelpers": true,
    "resolveJsonModule": true,
    "experimentalDecorators": true,
    "noImplicitReturns": true,
    "noImplicitAny": true,
    "lib": ["ES2020"],
    "declaration": true,
    "watch": true,
    "baseUrl": "."
  },
  "include": ["src/**/*.ts", "commands", "globals"],
  "exclude": ["node_modules", ".vscode", ".env", ".eslintrc.json"]
}
quartz kindle
#

unless requiring a json file does some optimizations under the hood, json and js should be loaded exacly the same