#development

1 messages · Page 785 of 1

earnest phoenix
#

first i create a channel called logs then i used that code i mentioned earlier in order to get its ID

sudden geyser
#

What version of Discord.js and Node.js are you on?

earnest phoenix
#

the latest version of Node and 11.5.1 of discord.js

#

node version is 12.13.1

#

oh my bad, that is not the latest

quartz kindle
#

do you create the channel in your code as well? do you await the channel creation?

earnest phoenix
#

yes.... i mean the code to get the ID is after the channel creation code

quartz kindle
#

but do you await it?

#

channel creation involves sending a rest request, which takes time to return a response

earnest phoenix
#

no.....

quartz kindle
#

then thats your problem, its basically trying to find it before its finished creating

#

show your channel creation code

earnest phoenix
#
message.guild.createChannel('logs', {
            type: 'text',
            permissionOverwrites: [{
              id: message.guild.id,
              deny: ['VIEW_CHANNEL'],
            }]
        })
        .catch(console.error);
quartz kindle
#
// option 1
let created = await message.guild.createChannel(...)
let logsChannel = created;

// option 2
message.guild.createChannel(...).then(created => {
  let logsChannel = created;
}).catch()
earnest phoenix
#

cant i just let logsChannel = await message.guild........?

quartz kindle
#

yes you can

prime cliff
#

Fun fact this also means that the bot won't be able to see the newly created channel 😔 unless it has admin

quartz kindle
#

bots can see all channels

#

afaik

#

they just wont receive messages from them

earnest phoenix
#

acutally this is my first time ever coding outside of an IDE, so i didnt really know the concept of waiting for the request to be completed

prime cliff
#

Yea that's the thing

earnest phoenix
#

my bot has admin, so it should be able to see

prime cliff
#

You should never give bots admin anyway

quartz kindle
#

look into Promises in javascript, thats basically how async code works

blissful scaffold
#

Dont ask for admin rights if it is a public bot

earnest phoenix
#

its not public yet, i gave it admin just for testing

#

it worked!

#

thank you Tim

high wind
#

hey im really new at bot api

#

and im trying to make a bot that adds m to every sentence

#

const client = new Discord.Client();

client.on('message', msg => {

msg.content = msg.conted += "m";

});

#

I tried that code but it doesnt seem to work

twin pendant
#

well msg.content = msg.conted += "m"; should be msg.content = msg.content + "m";

#

and what are you gonna do with the new message? log it? send it?

high wind
#

im trying to edit the new message

#

and thanks for catching my slip up

twin pendant
#

all good

high wind
#

and when i change to i have to go back into my cmd and load the code again?

twin pendant
#

yup

high wind
#

ok

twin pendant
#

but that code wont actually do anything, you cant edit other peoples messages either im pretty sure

high wind
#

oh

twin pendant
#

you could delete their message then send the new one with your bot

high wind
#

ok

#

do you know how its done?

twin pendant
#

well below the line that i changed you would do msg.channel.send(msg.content)

#

but that will trigger for every message

#

even the ones that the bot it self sends

#

and to delete a message you do msg.delete()

high wind
#

ok thanks

#

is there a way to mark the messages the bots send to make it so the bot doesnt resend its own messages

#

when do i put msg.delete()

twin pendant
#

you can check if the author of the message is equal to the author id of the message

#

anywhere really

high wind
#

and how do i check for author id?

twin pendant
#

(for you)

high wind
#

do i use the 3 stars?

twin pendant
#

nah i corrected myself

#

msg.author.id

#

that gives the id of the message author

high wind
#

where do I put that?

twin pendant
#

also thats gonna run on every single message

#

uh make an if statement at the start

#

you should probably go watch a discord bot tutorial

#

thatll help you alot

high wind
twin pendant
#

yea pretty much

high wind
twin pendant
#

yea i meant that my bad

high wind
#

ok thanks

#

what do i replace with my bots

twin pendant
#

right click your bot and copy id

#

then paste it into your code

#

if(msg.author.id !== 'your-bots-id')

high wind
#

ok thanks

#

and i use {} brackets around it?

#

i made the bot

#

and re ran the cmd this

#

and tried to do

#

node bot.js

#

but it didnt work and m bot is still offline

twin pendant
#

what is the file called that all your code is in

#

index.js?

#

and yes use the {}

high wind
#

Oh that must be it

#

The ks

#

Thanks

high wind
#

My code looks like this

#

and my terminal keeps saying invalid or unexpected token

#

i dont know what im doing wrong

#

please help

#

my code looks like this now

#

const client=new Discord.client();

if(msg.author.id !== 675506964876230657){
client.on(message,msg =>{

msg.content = msg.content += m;
msg.channel.send(msg.content);
msg.delete();
}
);}

#

this is the only thing i wrote in my code

earnest phoenix
#

Ay every1 how do I ban every word in the world in a discord bot except for 1. Then give roles to people who say that word a certain number of times

#

I have a reference bot on another server

#

It's not mine

sudden geyser
#

Check if the message does not contain that one word you want to exclude, then save a collection or object counting how many times the user has said whatever.

slender thistle
#

if word in lowered message content

earnest phoenix
#

But I want it so they can ONLY say that word

#

Do u mind if I dm u what I'm talking about so u get a better understanding

high wind
#

you could replace the message with that word

#

have your bot delete the message and just send that word

earnest phoenix
#

No @high wind lemme dm u a sec

high wind
#

ok

digital ibex
#

how would i get the platform of a user?

amber fractal
#

I dont think you can for sure

copper cradle
#

@high wind that code

high wind
#

yes?

#

what about it

#

@copper cradle

#

my error log looks like this

#

SyntaxError: Invalid or unexpected token
at Module._compile (internal/modules/cjs/loader.js:891:18)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
at Module.load (internal/modules/cjs/loader.js:811:32)
at Function.Module._load (internal/modules/cjs/loader.js:723:14)
at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10)
at internal/main/run_main_module.js:17:11

earnest phoenix
#

Can i invite my bot here ?

#

Im newbie developer bot

#

I need to change name of my bot first

#

Because another bot has same nick

#

xD

stray wasp
#

You can submit it through the top.gg website

earnest phoenix
#

Ok

iron scaffold
#

Hello

#

i need help

#

in index.js

#

it says } is an error can not be specified

#

'}' expected.ts(1005)

#

Please ping me

#

nvm found it

fiery stream
kindred wadi
#

XQ Bot logo

fiery stream
#

My logo sucks 😢😢

primal helm
#

when I try to start my bot it says ReferenceError: guildMemberAdd is not defined
at Object.<anonymous>
I dont know what's the problem
:/

marble juniper
#

can you show some code where you are doing the guildMemberAdd thing

copper cradle
#

@high wind ofc

#

There are 2 things wrong in your code

#

First

#

There'a a semicolon that looks like this

#

);}

#

Remove that semicolon

#

Also

#

You can't do this

#
const client=new Discord.client();
if(msg.author.id !== 675506964876230657){
client.on(message,msg =>{

You're using the msg variable before even defining it, and the variable is inside the arrow function you're using to get the message object which means you can only use it inside of that scope

#

Ph and

#

IDs are strings

#

So wrap that id inside a string

earnest phoenix
#
4|xxx      |     at Object.<anonymous> (/root/xxx/Modules/GAwesomeClient.js:8:15)
4|xxx      |     at Module._compile (internal/modules/cjs/loader.js:1144:30)
4|xxx      |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1164:10)
4|xxx      |     at Module.load (internal/modules/cjs/loader.js:993:32)
4|xxx      |     at Function.Module._load (internal/modules/cjs/loader.js:892:14)
4|xxx      |     at Module.require (internal/modules/cjs/loader.js:1033:19)
4|xxx      |     at Module.Hook._require.Module.require (/usr/local/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:70:39) {
4|xxx      |   code: 'MODULE_NOT_FOUND',
4|xxx      |   requireStack: [
4|xxx      |     '/root/xxx/Modules/GAwesomeClient.js',
4|xxx      |     '/root/xxx/Modules/index.js',
4|xxx      |     '/root/xxx/master.js'
4|xxx      |   ]
4|xxx      | }```
#

How to fix it

marble juniper
#

show code first

lusty quest
#

missing module

#

looks like GAwesomeClient is missing or a dependency

inner bane
#

can someone here can help me with the python cmds of a bot
i am newcommer plz
can anyone

earnest phoenix
#

Accept pls

inner bane
#

wht

earnest phoenix
inner bane
#

ohh noice

#

waht i go and vote for u if i like it

#

can someone here can help me with the python cmds of a bot
i am newcommer plz
can anyone

#

can u help me then

earnest phoenix
#

@earnest phoenix. Umm?

#

Voting of my bot ?

inner bane
#

wait i confused

earnest phoenix
#

Ok

inner bane
#

u havent add the bot yet

#

i am right

earnest phoenix
#

I add bot

inner bane
#

like it is in testing???

#

dm??

earnest phoenix
#

Ok

copper cradle
#

@earnest phoenix there's a queue, it can take up to 2 weeks for your bot to get approved

earnest phoenix
#

2week

#

Ahh

#

Ok i will be patient

marble juniper
#

what a braindead chat

copper cradle
#

Ikr

earnest phoenix
#

2week so a long time

uneven wyvern
#

@marble juniper ikr, guess they are 11 y/o or something

marble juniper
#

maybe not in age but in brain age yes

uneven wyvern
#

@earnest phoenix I would suggest you take change the Prefix from . to something like si!

marble juniper
#

maybe the first two letters of your bot and then !

uneven wyvern
#

year or make it spaced

#

mention is still the best prefix

earnest phoenix
#

Hmm

#

Why ?

#

Why i must change prefix ?

marble juniper
#

because every other bot uses . and it will cause problems

earnest phoenix
#

Wht problem ?

marble juniper
#

because then if 2 bots have the same prefix for example both will react to commands

#

and maybe the person wants to use only 1 bot

earnest phoenix
#

Ow

marble juniper
#

and not both at the same time

#

you get what I mean

earnest phoenix
#

Yep

#

But i think bot with .prefix is less

marble juniper
#

this is why you need a prefix which is not common

uneven wyvern
#

Else your bot gets muted

marble juniper
#

and no there are thousands of bots who use .

earnest phoenix
#

Ow :v

#

Hmm

marble juniper
#

the best option would be using the bot mention as your prefix

earnest phoenix
#

Already used

marble juniper
#

or the first 2 letters of your bot followed by an + or . or whatever character

#

like sa! or sa+

earnest phoenix
#

Hm ok

uneven wyvern
#

or just sa with a space

#

so sa help

earnest phoenix
#

So hard coding

#

xD

uneven wyvern
#

No

#

It's easy

#

Are u Js?

marble juniper
#

My bots prefix is customizable for each server so I have no problem with the prefix thing

earnest phoenix
#

Nope

#

I use phone to coding my bot

marble juniper
#

phone

uneven wyvern
#

What language do u use?

earnest phoenix
#

I not really can speak english xD

#

Im from asia/indonesia

uneven wyvern
#

What coding language do you use?

marble juniper
#

no not your speaking language

#

the coding language

earnest phoenix
#

So im sorry if false word

#

Ow lol english

marble juniper
#

the language your bot is written in (programming language)

#

kms

earnest phoenix
#

Oww

uneven wyvern
#

lmao just trought about it myself

earnest phoenix
#

Just command suit from indonesia

#

Like rps

#

xD

uneven wyvern
#

kms

marble juniper
#

Aaaaaaaaaaaa

earnest phoenix
#

All coding with pc ?

uneven wyvern
#

reeee

marble juniper
#

No its not that

#

I mean coding language

earnest phoenix
#

Oww

marble juniper
#

like javascript

#

or python

#

not english

earnest phoenix
#

BDscript

marble juniper
#

Finnally a valid answer

earnest phoenix
#

Im sorry xD

marble juniper
uneven wyvern
#

Wait is BDscript not DBM?

earnest phoenix
#

Im not really can speak english

marble juniper
#

Well

#

its on phone

earnest phoenix
#

Yep

marble juniper
#

how do you code on phone

#

you don't

uneven wyvern
#

well i do

earnest phoenix
#

Secret

#

xD

marble juniper
#

well I don't

uneven wyvern
#

of cause u don't have strg z or something but idc about that

earnest phoenix
#

Lol

marble juniper
#

I guess tho that the "jeff" person uses a dbm

uneven wyvern
#

i think so

earnest phoenix
#

Wht is dbm ?

uneven wyvern
#

@earnest phoenix do u use discord bot maker as app?

earnest phoenix
#

Yep lols

uneven wyvern
#

@spare goblet you can decline @earnest phoenix Bot, it's made in BDscript so in Discord Bot maker

marble juniper
earnest phoenix
#

:v

#

Rip my bot

uneven wyvern
#

sorry but DBM is not allowed Here

bitter sundial
#

discord bot maker is allowed

marble juniper
#

Shimano

earnest phoenix
#

Ow see

uneven wyvern
#

yes

marble juniper
#

what r u talking about

earnest phoenix
#

Uhh yess

#

My hearth

marble juniper
#

before I knew I code my bot was accepted and It was made in dbm

#

lol

earnest phoenix
#

Dbm is coding too :v

marble juniper
#

no its not

earnest phoenix
#

But it has displayed code

marble juniper
#

but you are not the one writing it

bitter sundial
#

it is coding just like scratch is coding

earnest phoenix
#

Hmm im so nuub coding

#

Ye see developer opinion

marble juniper
#

im a developer too but ok

#

well as mentioned earlier

earnest phoenix
#

:v

marble juniper
#

use a prefix which is not .

#

or !

earnest phoenix
#

✓ prefix

#

So hard

#

xD

#

Because hard to find word

bitter sundial
#

nobody's stopping you from using a common prefix if you want, we just have to block its read access in this server because there's too many bots with those prefixes

earnest phoenix
#

Oww

#

I will change prefix

bitter sundial
#

if you went and wrote !help in a testing channel like thousand bots would respond

earnest phoenix
#

Yep lol

marble juniper
#

and this server would crash

earnest phoenix
#

Im sorry

bitter sundial
#

yeah it started causing outages too

#

you dont have to be sorry

marble juniper
#

now you know

earnest phoenix
#

Hmm did you have idea for new prefix @link.

bitter sundial
#

its just a thing in this server

#

if you dont care about #commands here the prefix doesnt matter

marble juniper
#

unless you want to test your bot in this server

earnest phoenix
#

Ok ill change prefix

#

xD

#

If $ prefix ?

#

Like $help

twin pendant
#

thats very common as well

#

try something with 2 characters

marble juniper
#

3 would be even better

twin pendant
#

you could also make a customizable prefix per server

#

but that needs a database

bitter sundial
#

mention prefixes are the best bet

twin pendant
#

^true

copper cradle
#

@earnest phoenix just a small question, I've seen you use ":v" a lot, do you speak spanish?

marble juniper
#

Im from asia/indonesia
jeffsay#6430

copper cradle
#

Mm

earnest phoenix
#

can anyone tell me why my guild ids last 3-4 digit change
its showing correct id at out of script aria and
its changing ids last 3-4 digit inside <script>

#

You from asia ?

#

Yes

#

Why you talking here

#

Plz remove your all message

#

ill ask $. Prefix is good or not ?

uneven wyvern
#

no

earnest phoenix
#

$. ?

#

Just delete your all messaage

uneven wyvern
#

@twin pendant I don't think dbm has a db

earnest phoenix
#

@earnest phoenix use strings to store snowflakes in js, js supports numbers up to 53 bits but snowflakes are 64 bits

#

Let me check @earnest phoenix

twin pendant
#

@uneven wyvern oh yeah true

earnest phoenix
#

$. Prefix is good :v

uneven wyvern
#

well

#

If u think so

earnest phoenix
#

Ok ill change

#

...

#

you're still not storing them as strings

#

Like how?

#

...

#

you know your code, go wherever you store ids in tbe the database and use strings instead

#

oh wait

#

is this a db

#

in the first place

uneven wyvern
#

also why are there "" in toString()

earnest phoenix
#

@earnest phoenix got it thanks anyway.

#

I still use prefix . And idc if bot will invite here

#

just pls in website

#

hi

glacial anchor
#

is eris faster than djs?

delicate zephyr
#

Both are different libs written in different ways

#

ones caching is better than the other but it generally comes down to preference at the end of the day

#

use whatever lib you see fit

glacial anchor
#

i thunk eris is faster

#

im going for the speed

#

my bot is a newgrounds crawler

#

i almost disabled all caching in djs

quartz kindle
#

if you want pure speed (speed is the wrong term here, because performance will be limited by network more than anything, so im assuming you mean resource usage and efficiency), you will need to modify the library (either of them)

#

because both of them are primarily centered around avoiding hitting the API as much as possible

#

which means tons of caching and processing all packets in one way or another

marble juniper
#

how can I detect in node.js if a file has been renamed and then get the old and new name of the file

lusty quest
#

so ive updated yesterday node on my pc and fryed my entire enviroment. ```internal/modules/cjs/loader.js:1021
return process.dlopen(module, path.toNamespacedPath(filename));
^

Error: Access is denied.
\?\W:\Discord Bots\Captain-Vor-Production\node_modules\better-sqlite3\build\better_sqlite3.node
at Object.Module._extensions..node (internal/modules/cjs/loader.js:1021:18)
at Module.load (internal/modules/cjs/loader.js:811:32)
at Function.Module._load (internal/modules/cjs/loader.js:723:14)
at Module.require (internal/modules/cjs/loader.js:848:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (W:\Discord Bots\Captain-Vor-Production\node_modules\better-sqlite3\lib\database.js:5:21)
at Module._compile (internal/modules/cjs/loader.js:955:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
at Module.load (internal/modules/cjs/loader.js:811:32)
at Function.Module._load (internal/modules/cjs/loader.js:723:14)```any suggestions?

earnest phoenix
#

@lusty quest uninstall node and re install your version :)

lusty quest
#

was step 1

#

didnt work

earnest phoenix
#

Lol

glacial anchor
#

gzip or deflate?

quartz kindle
#

@lusty quest did you run npm rebuild?

#

or delete node_modules and run npm install

#

@glacial anchor brotli > gzip > deflate

glacial anchor
#

ok im gonna rephase it - which method compresses best? gzip or deflate?

#

@quartz kindle brotli is br, right?

quartz kindle
#

yes

glacial anchor
#

can i include it as a node-fetch header?

#

i currently have deflate

quartz kindle
#

you can include it yes, if the server supports it

#

the server should send an accept-encoding header

glacial anchor
#

i tried but the fetch speed was worse than gzip or deflate, so methinks its not supported

#

might ask newage to add brotli support

quartz kindle
#

make a request and log their response headers

glacial anchor
#
(async () => { const i = require ("node-fetch"); await i ("https://api.newgrounds.app/").headers})```?
quartz kindle
#

i dont use node-fetch so idk the correct syntax for it, but should be soething like that yes

lusty quest
#

@quartz kindle done both with the same result

glacial anchor
#

how do i modify discordjs and use in my project? do i clone the git repo into one folder in my bot project and just recall it locally? if i delete some files and pieces of code, will it break?

inner slate
#

I has issues. So I'm using the following code where userID is being passed message.author.id

    let registered = false;
    var contents = fs.readFileSync('users/' + userID + '.json').catch(err);
    if (!contents) { registered = false; }else{ registered = true; }
    return registered;
}```
When the file exists it works no problem.
When it doesn't, I get an error that it can't throw an error.
glacial anchor
#

tf, why are you using json for database

#

especially when each file is an element of it

inner slate
#

because I have issues using database

quartz kindle
#

@glacial anchor what i do is build on top of it, by extending some classes and intercepting packets with the raw event

glacial anchor
#

im afraid that im gonna break something without the ability to recover

#

@inner slate your directory seems to be wrong

quartz kindle
#

most likely, i did break many things during my experiments

inner slate
#

How is my directory wrong?

quartz kindle
#

i can share what i learned so you dont break it

glacial anchor
#
let contents = fs.readFileSync(`./users/${userID}.json`);```
marble juniper
#

try ./users

inner slate
#

k

glacial anchor
#

@quartz kindle nah i dont think im gonna do such huge step

quartz kindle
#

@inner slate you cant catch fs.readFileSync like that, since its not a promise

#

you need to use a try catch block

glacial anchor
#

yeah

#
try {
  let contents = fs.readFileSync(`./users/${userID}.json`);
} catch {
  // code
}```
quartz kindle
#
let user;
try {
  user = fs.readFileSync(...)
} catch(e) {
  // failed to load user
}```
inner slate
#

ok

glacial anchor
#

also use es6 syntax

#

its just easier on the eyes

inner slate
#

thanks guys

glacial anchor
#
const checkRegistered = (userID) => {
  let user = "";
  try {
    user = fs.readFileSync(`./users/${userID}.json`);
  } catch (err) {
    console.log(err);
  }
  return user ? true : false;
}```
idk if its gonna work
inner slate
#

goddamned lifesavers

glacial anchor
#

np, have fun coding

quartz kindle
#

contents is undefined xD

inner slate
#

took whatcha said and actually simplified it, seeing as I don't need to know the contents in that context

function checkRegistered(userID){
    try {
        fs.readFileSync('./users/' + userID + '.json');
    } catch(e){
        return false;
    }
    return true;
}```
produced expected results both times
glacial anchor
#

and try to use streams whenever possible

quartz kindle
#

no need to bother with streams if the files are like 1kb

glacial anchor
#

@inner slate return is 0 as default

#

so instead of return false you can do return ig

inner slate
#

yeah, they're small, biggest ones are the user files

quartz kindle
#

return is undefined

inner slate
#

and they're max 2kb

quartz kindle
#

but its better to explicitly use true/false for the sake of consistency

glacial anchor
#

make a database ffs

#

simple enmap db is a good way to start

#

not too hard

inner slate
#

I hate databases, not to mention none of the free options are up to snuff

glacial anchor
#

enmap is a package

inner slate
#

hmm?

glacial anchor
#

it makes an object once you initialize it

#

it can be accessed globally, and you can push data to it

#

its kinda fast if your db is small

inner slate
#

and it's permanent?

dusky marsh
#

sqlite ftw

glacial anchor
#

yeah

#

@dusky marsh we all have to start somewhere /shrug

inner slate
#

I'll look into it, but I already have a crap ton of functions and such

earnest phoenix
#

hi, i have a db with 100 values, i tried to use a while and make a list, but the bot "lag"

dusky marsh
#

I had a friend who started out with enmap and now he is like, dependent on it

quartz kindle
#

well, my bot is on 2200 servers and still running on json

inner slate
#

much the way I'm already dependent on file databases ;P

glacial anchor
#

bruh what

quartz kindle
#

but im rewriting it to sqlite as we speak

glacial anchor
#

fr?

#

json is slow and the worst solution for database

inner slate
#

I mean, I run my bot locally on my laptop

quartz kindle
#

just that my bot so so complex i've been rewriting it for over a month and still nowhere near ready

glacial anchor
#

btw quick side question how do you make something like enums in c++?

late hill
#

show us what you did @earnest phoenix

quartz kindle
#

and json is not slow, nor a problem, if you use it efficiently

inner slate
#

efficiently... >.>

glacial anchor
#
const enum = Object.freeze({ key: "value"});
enum.key; // value```
#

?

quartz kindle
#

are enums like a kind of validation-enforced array/object? which only accepts predefined values?

meager mulch
#

Hello

glacial anchor
#

yeah

meager mulch
#

Why we cant use !thelp

glacial anchor
#

i think so

meager mulch
#

On BetterAntiSpam

quartz kindle
#

then you need to use a Proxy

meager mulch
#

It’s bug

grizzled raven
#

using a ternary operator for x ? true : false could just be replaced with !!x

glacial anchor
#

its like

#

if you have a string repeating a lot in code

#

you put it in an enum

quartz kindle
#

@meager mulch this is not the suport server for any bot, this is the official server for the top.gg website

grizzled raven
#

but then again i

glacial anchor
#

saves space, sort of

late hill
#

enums are a list of constants basically

quartz kindle
#

this is what i got from google Enums are used only when we expect the variable to have one of the possible set of values, for example, we have a dir variable that holds the direction. Since we have four directions, this variable can take any one of the four values, if we try to assign a another random value to this variable, it will throw a compilation error. This increases compile-time checking and avoid errors that occurs by passing in invalid constants.

#

this behavior is only achievable in js by using the Proxy class

glacial anchor
#

proxy class?

#

tell me more

quartz kindle
#

a Proxy is essentially a middleware for ANYTHING in js

#

you can use it for validation for example

glacial anchor
#

is identity compression fast and should i use it?

#

i mean over gzip or deflate

quartz kindle
#

identity is no compression

glacial anchor
#

ok then

#

should i use compress over these two i mentioned

quartz kindle
#

it only exists if for some reason someone wants to forbid uncompressed access

glacial anchor
#

@quartz kindle

quartz kindle
#

you should use br when possible, then gzip, then deflate

#

in most cases

glacial anchor
#

wait can i put these three as a header

#

and will it make it any faster

#

or it will take more time to compress than get data itself

quartz kindle
#

im not sure about compress, you can google it

glacial anchor
#

yeah ive seen it on mdn

quartz kindle
#

put the three in the header, and the server will send you what they prefer

#

if you send br,gzip,deflate the server will send br if they suport it and prefer it, else they will send whatever best match they have set up

#

br should be the best option at the moment, but if you feel like its slower, it could be their server is not good at encoding br, or node is not good at decoding it

#

if you feel gzip is faster, then use gzip

glacial anchor
#

ive seen its headers and it sends chunked data

#

in tunnel encoding

quartz kindle
#

gzip will be about 10% bigger in size, other than that its no biggie

glacial anchor
#

well gzip is at least something

#

no compression is slow af

#

god praise whoever invented gzip

quartz kindle
#

is the data you're receiving very large?

glacial anchor
#

maybe a few hundred bytes

#

but somehow it takes at least 5 seconds to get data

quartz kindle
#

5 seconds? wtf

glacial anchor
#

my bot's ping averages on 200ms, which is far less than 5 seconds

quartz kindle
#

my API can send several MB in less than 1 second

inner slate
#

okay, so question, would these two work the same:
Old: javascript if (command == "register" || command == "reg"){ fs.readFile('users/' + message.author.id + '.json', (err, data) => { if (err){ let userdata = newUser(message); let newdata = JSON.stringify(userdata, null, 4); fs.writeFileSync('users/' + message.author.id + '.json', newdata); botlog.send(message.author + " has just registered!"); }else{ message.reply("you're already registered!"); } }); }
New:javascript if (command == "register" || command == "reg"){ try { fs.readFileSync('./users/' + message.author.id + '.json'); } catch(e){ message.reply("you're already registered!"); return; } let userdata = newUser(message); let newdata = JSON.stringify(userdata, null, 4); fs.writeFileSync('users/' + message.author.id + '.json', newdata); botlog.send(message.author + " has just registered!"); }

tight heath
#

probably, but sync ops are blocking

#

so i doubt you wanna do that at any point but initialization

#

not when running a command

inner slate
#

1-2kb files don't take long to run through

#

yes B1tt

glacial anchor
#

@inner slate make a command handler bruh

inner slate
#

I know

#

oh

glacial anchor
#

dont tell me that you have all bots code in just one file

inner slate
#

thought you were gonna try the db thing again

#

it's only 1681 lines of code, I usually don't compartmentalize till after 2000 lines

glacial anchor
#

WHAT THE FUCK

#

how many commands do you have

inner slate
#

14

glacial anchor
#

make a command handler

inner slate
#

plus 15 functions

glacial anchor
#

and split all those ugly if's into files

#

move all these functions into their own folder like i did

#

ive made an util folder with useful functions

#

and i just call those in each command file

earnest phoenix
#

that code follows every bad practice you can possibly do lol

#

using json as a database, shoving all of your code into one file

glacial anchor
#

^^^

inner slate
#

I've had bad results using databases, specially when running my bots locally

glacial anchor
#

you even tried to run your bot locally?

#

thats the worst thing

inner slate
#

it's the only option I have atm

earnest phoenix
#

and other people didn't, so it's rather a you problem

glacial anchor
#

not shutting your pc down for 24/7

#

you can try using heroku

#

free vps

earnest phoenix
#

that's even worse

inner slate
#

it's a spare laptop I don't use for anything

quartz kindle
#

let them experiment, no need to criticize that much

glacial anchor
#

@earnest phoenix at least better than paying for electricity

earnest phoenix
#

and be extremely limited with uptime and resources?

quartz kindle
#

they will learn from experience

inner slate
#

Thank you Tim

earnest phoenix
#

heroku doesn't even allow discord bot hosting

quartz kindle
#

like we all did

glacial anchor
#

1 hour of downtime in 1 month

#

if thats too much for you then dont make a bot

#

and heroku does allow hosting for everything

inner slate
#

I moved from glitch, because glitch I had loads of downtime

earnest phoenix
#

selfhosting is fine

glacial anchor
earnest phoenix
#

using free hosts however, isn't because again, very limited resources and uptime

glacial anchor
#

all those are libs/packages which you can install and use from the console

quartz kindle
#

i did self hosting for several months in a slow af third world country internet

#

all my commands took randomly 1-10s+ to respond

inner slate
#

my commands respond almost immediately

quartz kindle
#

good internet is a blessing

glacial anchor
#

@quartz kindle and a curse

inner slate
#

just did a ping of the bot and it came back in 0.873 seconds

glacial anchor
#

873ms is huge

quartz kindle
#

that is a tad slow

tight heath
#

heroku and glitch are both

#

eh

quartz kindle
#

but better than what i had to work with at the time

tight heath
#

also i have 1ms to discord if we're already flexing ping

glacial anchor
#

wtf

earnest phoenix
#

back when i started my bot i selfhosted and my internet was ass slow cause it was always under stress, i borrowed a 4G module from a friend for an rpi and just used mobile data instead

tight heath
#

23ms roundtrip including latency & discords worker delay

glacial anchor
#

nasa pc

tight heath
#

no lol

#

just direct peering with cloudflare

glacial anchor
#

spacex internet

#

oh ok

earnest phoenix
#

the api servers are hosted in NY i think

#

so if you're close, you're going to have god latency

inner slate
#

b1tt, I'll humor you on the command handler bit, how exactly would I start that?

#

I'm near Baltimore, MD so... I'm close

quartz kindle
#

there are many different ways of setting up a command handler

#

you can be very creative with them

glacial anchor
#

the simplest one is using commando

#

but if you dont want to clutter your code

#

you can write your own

inner slate
#

yeah... already cluttered enough, lol

glacial anchor
#

mine fits in like 6-7 lines of code

inner slate
#

I'd rather code my own

tight heath
#

if you want

#

a very minimalistic one

glacial anchor
#

right now you have to move all your commands into some folder

tight heath
glacial anchor
#

each command is gonna have its own file

#

ok so theres spoonfeeding

tight heath
#

bruh

#

better than being a toxic bitch about it

inner slate
#

am I going to have to pass the message variable to them?

tight heath
quartz kindle
#

a dead simple example of a command handler would be to ```js
const commands = {
command: require(commandfile),
command2: require(commandFile2)
}

client.on("message", msg => {
if(msg.content.startsWith(prefix)) {
let command = commands[msg.content.slice(prefix.length)]
if(command) {
// call command
}
}
})```

tight heath
#

@inner slate yeah how would you otherwise interact with the message

inner slate
#

just making sure

glacial anchor
#
["commands", "aliases"].forEach(x => <Client>[x] = new Collection());
const load = async (dir = "DIRECTORY") => {
		const commands = await readdirSync(dir).filter(files => files.endsWith(".js"));
    for (const file of commands) {
		  let pull = await require (`${dir}${file}`);
			if (pull.help) {
				await bot.commands.set(pull.help.name, pull);
        pull.help.aliases.forEach(async alias => {
					await bot.aliases.set(alias, pull.help.name);
				});
        console.log(`Loaded "${pull.help.name}"!`);
			}
		}
};```
inner slate
#

so I'd run commands like I'd run functions

glacial anchor
#

no

inner slate
#

just making sure I'm understanding

quartz kindle
#

yes

inner slate
#

ok

#

o.o

quartz kindle
#

lmao

#

the difference in coding styles is so amusing

tight heath
#

lmao

glacial anchor
#

so you just check what the command inputted by user is, then check for that command in <Client>.aliases and then run that command

#

do module.exports for that

inner slate
#

okay, hold up so you guys can get my start bit here:

client.on("message", message => {
  const chnManage = message.guild.me.hasPermission("MANAGE_CHANNELS");
  const msgManage = message.guild.me.hasPermission("MANAGE_MESSAGES");
  if (message.author.bot) return;

  if (!message.content.startsWith(config.prefix)) return;

  const withoutPrefix = message.content.slice(config.prefix.length);
  const split = withoutPrefix.split(/ +/);
  const temp = split[0];
  const command = temp.toLowerCase();
  const args = split.slice(1);```
#

ignore the toLowerCase bit, I was having issues doing it directly

glacial anchor
#

yes

#

good enough but needs optimization

#
client.on("message", message => {
  const chnManage = message.guild.me.hasPermission("MANAGE_CHANNELS");
  const msgManage = message.guild.me.hasPermission("MANAGE_MESSAGES");
  
  if (!message.content.startsWith(config.prefix)) return;
  if (message.author.bot) return;

  const withoutPrefix = message.content.slice(config.prefix.length).split(/ +/g);
  const command = withoutPrefix[0].toLowerCase();
  const args = withoutPrefix.slice(1);```
#

stop that variable fetish

quartz kindle
#

an even easier way would be js client.on("message", msg => { if(msg.content.startsWith(prefix)) { let cmd = msg.content.slice(prefix.length).split(" ")[0]; try { let command = require("directory/"+cmd); command(msg); } catch(e) {} } })

#

xD

glacial anchor
#

@quartz kindle gross

quartz kindle
#

hahaha

glacial anchor
#

why not if (!msg.content.startsWith...)

#

so you can get rid of these brackets

quartz kindle
#

sure why not

inner slate
#

b1tt... where are you getting split? you removed it from the code example everywhere but the args bit

#

const args = split.slice(1);

quartz kindle
#

its there (well now it is)

glacial anchor
#

fixed

late hill
#

put the checks that lead to a return all the way on top

#

no point in declaring those variables if you'll return anyway

earnest phoenix
#

i have an entire service dedicated to registering command and parsing parameters

glacial anchor
#

@earnest phoenix that doesnt look like js at all

#

tf is that core

#

code

earnest phoenix
#

cause it isn't

#

c#

inner slate
#

and somewhere with your code ping was reacted to by a different command

glacial anchor
#

@inner slate wdym

inner slate
#

I replaced just the command portion with yours and when I did SD!ping, it ran a completely different command

#

one that started with p

#

but wasn't ping

quartz kindle
#

lmao

glacial anchor
#

do you have the whole discord.js required?

inner slate
#

replaced

  const temp = split[0];
  const command = temp.toLowerCase();```
with
`const command = withoutPrefix[0].toLowerCase();`
#

yes

glacial anchor
#

BRUH

#

thats inefficient af

#

instead of importing it all you can import needed functions or classes

inner slate
#

at least I get the right command

#

ohhhh

#

that seems well above my paygrade, I don't understand discord.js, I'm not gonna rip out pieces at a time

glacial anchor
#

for example, if you only need collection, you can change js const Discord = require ("discord.js"); const Collection = Discord.Collection;
with js const { Collection } = require ("discord.js");

quartz kindle
#

that doesnt really matter much lol

glacial anchor
#

it does

quartz kindle
#

it will improve startup time by a few nano seconds and reduce memory usage by a few kb

glacial anchor
#

imagine that - you require some 10mb lib while you only need one function from it

quartz kindle
#

djs is not 10mb lol

glacial anchor
#

i said that as an example

#

it can be 100mb, 200mb

earnest phoenix
#

lol

quartz kindle
#

yeah but it doesnt matter much in djs's case, nor with most libs

#

99% of libs are smart enough not to preload all files anyway

glacial anchor
#

imo it does

#

and it just results in less code

earnest phoenix
#

microoptimization doesn't matter in a poor performance language anyways

quartz kindle
#

grabs pitchfork

glacial anchor
#

js is not poor performance

#

people write bad code that works like bullcrap

#

nodejs uses v8 engine, which speed is something similar to c++

quartz kindle
#

anyways, microoptimization is not a dealbreaker for a small discord bot

glacial anchor
#

as i said it just results in less and cleaner code

quartz kindle
#

if you need that kind of microoptimization, you should not even be using discord.js in the first place

#

speaking of microoptimization, move your author.bot return to the top, and the prefix checking to right after

#

lul

glacial anchor
#

thats what i did

#

see my code snippet

tight heath
#

imagine speedwhoring and using d.js

quartz kindle
glacial anchor
#

oh and dont forget

#
const client = new Discord.Client({
  disabledEvents: ["TYPING_START"]
});```
quartz kindle
#

that doesnt do anything

glacial anchor
#

disabling typing_start

#

if you geniunely think it wont do anything

#

try with and without it

tight heath
#

that doesn't do anything

quartz kindle
#

it doesnt disable typing packets from being received, which is 99% of the problem

tight heath
#

the event still gets parsed

#

which takes the most cpu

#

emitting it is minimal work in js

glacial anchor
#

how? you have to enable partials to still get it parsed??

#

no?

tight heath
#

to get the type of the event

#

you have to

#

json.parse it

quartz kindle
#

no, they are always sent, unless you disable guild subscriptions in the discord identify

tight heath
#

inflate it

#

etc.

#

intents solve this

#

btw

quartz kindle
#

yeah im waiting for them

glacial anchor
#

dk it gave me like 30ms speed boost

#

maybe more

tight heath
#

@quartz kindle they're already working

#

i use em

quartz kindle
#

processing events is not about speed, its about cpu usage

earnest phoenix
#

intents will require most libs to switch to stateless design

glacial anchor
#

it was around 60-70mb cpu usage

#

now its just 40mb

tight heath
#

in djs you can just pass them to clientops#ws

quartz kindle
#

ah, i'll look into it

tight heath
#

sec

quartz kindle
#

im already using guild_subscriptions = false, didnt know intents were already accessible through djs

glacial anchor
#

what are intents

quartz kindle
#

when you connect to discord and open the websocket connection, you can specify an intents field

#

which tells discord what type of events do you want to receive

glacial anchor
#

oo

#

i didnt saw those in client options of v12

jade briar
glacial anchor
#

jfif

#

wut

jade briar
#

(nip)

quartz kindle
#

they are part of WS options, and not officially supported by djs

tight heath
quartz kindle
#

because disabling events from being received breaks any things in djs

glacial anchor
#

are they working on it tho

high wind
#

do you need to run this every single time you update your code?

glacial anchor
#

why

high wind
#

im new to this and im just getting it off the internet

quartz kindle
#

@high wind you are following a bad and outdated tutorial

high wind
#

oh

quartz kindle
#

discord.io is an old discord library that nobody uses

high wind
#

do you suggest any new ones?

quartz kindle
#

discord.js

glacial anchor
#

eew dude

quartz kindle
#

look for anidiotsguide

glacial anchor
#

use djs or eris

high wind
#

thanks

glacial anchor
#

also jotaro best jojo

high wind
#

at least hamon isnt the same type of stand as the protagonist of part 2

glacial anchor
#

@high wind get to part 7 and you'll see balls

high wind
#

I just got to part sever

#

seven*

#

Im following "anidiotsguide" on mac and its telling me to use the code apm install linter-eslint and terminal just outputs -bash -apm not found

quartz kindle
#

where did ou see this?

inner slate
#

Yeah, moved those two things under bot and prefix checks. Don't remember why I did that in the first place.

#

Why I placed them there instead of after I mean

high wind
#

@quartz kindle wdym

quartz kindle
#

which website and page did you see that instruction?

#

you dont need a linter for now

earnest phoenix
#

/eval message.guild.createChannel("OP",{ "text"}) does it correct cuz i am getting error

quartz kindle
tight heath
#

for intents

#

:)

earnest phoenix
#

help nenplzz

quartz kindle
#

@earnest phoenix i sent you the link that explains how to use createChannel

#

@tight heath thanks, im checking the discord api github as well

tight heath
#

yw 😊

sick apex
#

Please someone know how to install node.js to computer with Lubuntu 32 bit . ?

#

I updating OS but I can't install nodejs

restive furnace
#

i think node.js just supports ubuntu, not lubuntu ( i know its lightweight ubuntu)

steel heath
#

no it's still ubuntu but it's using the LXQt DE, yes it's a very lightweight de but lubuntu is lxqt ubuntu

#

anyway you can just do these

curl -sL https://deb.nodesource.com/setup_13.x | sudo -E bash -
sudo apt-get install -y nodejs```
#

that's for nodejs 13, if you want to install the 12 (lts) version do these:

sudo apt-get install -y nodejs```
quartz kindle
#

you could also use nvm

copper cradle
#

Why would you use 32Bit

minor kelp
#

Traceback

Feb 08 08:47:42 chipthewolf python[7004]: Traceback (most recent call last):
Feb 08 08:47:42 chipthewolf python[7004]:   File "/usr/local/lib/python3.6/dist-packages/discord/ext/commands/bot.py", line 863, in invoke
Feb 08 08:47:42 chipthewolf python[7004]:     await ctx.command.invoke(ctx)
Feb 08 08:47:42 chipthewolf python[7004]:   File "/usr/local/lib/python3.6/dist-packages/discord/ext/commands/core.py", line 728, in invoke
Feb 08 08:47:42 chipthewolf python[7004]:     await injected(*ctx.args, **ctx.kwargs)
Feb 08 08:47:42 chipthewolf python[7004]:   File "/usr/local/lib/python3.6/dist-packages/discord/ext/commands/core.py", line 88, in wrapped
Feb 08 08:47:42 chipthewolf python[7004]:     raise CommandInvokeError(exc) from exc
Feb 08 08:47:42 chipthewolf python[7004]: discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: code() missing 2 required keyword-only arguments: 'start' and 'end'

Code

    @commands.command()
    async def code(self, ctx, start: int, end: int, file):
        os.chdir('~/usr/botv2/cogs/')
        read = open(f"{file}.py", "r").readlines()[int(start)-1:int(end)]
        read = ' '.join(read)
        read = read
        await ctx.send(f"py\n {read}\n ")
#

What's causing that exactly?

modest maple
#

You are not passing start and end

#

/ it's not getting start and end passed to it

minor kelp
#

It isn't?

#

What do I exactly change then?

modest maple
#

Have it pass start and end

#

Lmao

minor kelp
#

So, I'd use *,?

modest maple
#

Just because you write in the params that the function wants this and that parsing doesn't mean the command handlers gonna do that for u

slender thistle
#

How are you using the command

minor kelp
#

py code 39 45 owner

zenith orchid
#
        b.updateOverwrite(role, {
          SEND_MESSAGES: false,
          VIEW_CHANNEL: false
          
        });

Why i can'y update channel permissions?
Note: b is channel

#

Discord.js v12

summer torrent
#

any error?

zenith orchid
#

Nope

summer torrent
#

v12 has no method named "defaultRole"

glacial anchor
#

imagine if someone makes a brainfuck discord library

zenith orchid
#

I try it for role ex: guild.roles.find(a => a.name == "@everyone")

#

i can't write permission

uneven wyvern
#

@earnest phoenix U forgot type tho

quartz kindle
#

the default role is the same id as guild id

zenith orchid
#

I will try.

#

@quartz kindle thx bro

uneven wyvern
#

@glacial anchor BRUH LMAO

glacial anchor
#

this is not gonna be funny

uneven wyvern
#

his brain would get fucked after that

sonic skiff
#

can anyone help me with setting a variable to a specific channel

#

like if I have a number guessing game, you cant play the same game in two different channels

zenith orchid
#

Why sending rate limit warn? on use this code:

await as.react("675604486659637259")
 await as.react("675604314718208001")
modest maple
#

erm

#

what language is that

zenith orchid
#

Js

tight plinth
#

Every time someone ask a question here the answer should be "Read the docs"

zenith orchid
#

Oky

#

1/0.25s

#

But 3 adds the emoji from to 1 second.

zenith orchid
#

I try it to, done.

minor kelp
#

How would i make my bot detect when someone joins a different server?
So when someone joins it sends a message to my server saying
User: abc123
Joined: Python
Current user count: 12345

copper cradle
#

@zenith orchid use === not ==

zenith orchid
#

?

copper cradle
#

When you're doing an expression

#

Don't use ==

#

Use ===

#

I'm not gonna explain why

minor kelp
#

should say, Im using py

mossy vine
#

lmaoo

minor kelp
#

what?

mossy vine
#

does python even have ===

minor kelp
#

bruh

mossy vine
#

@copper cradle use b instead of a i wont explain why is horrible advice

minor kelp
#

i dont even know what they talking about

#

my thing is different

#

lmfao

mossy vine
#

my last message still stands mmLol

#

anyways

#

there should be a guild member add event

#

or something like that

#

listen to that, and deal with the member object you get

copper cradle
#

Ok fine

minor kelp
#

ya, on_member_join but that only counts to my server

mossy vine
#

it shouldnt

#

or maybe it should

#

i dont do python

#

read the docs

earnest phoenix
#

can someone help me with python?

copper cradle
#

The difference between == and === is that:== converts the variable values to the same type before performing comparison. This is called type coercion. === does not do any type conversion (coercion) and returns true only if both values and types are identical for the two variables being compared.

earnest phoenix
#

SyntaxError: invalid syntax

Python bot.py
File "<stdin>", line 1
Python bot.py
^

minor kelp
#

ahem

#

code?

earnest phoenix
#

what dose that means?

copper cradle
#

And I was talking to the guy using js

minor kelp
#

Alex,

mossy vine
#

@copper cradle ok im blind

earnest phoenix
#

yes

minor kelp
#

It means invalid syntax

#

Show your code.

earnest phoenix
#

how can i run a python file?

copper cradle
#

It's python

#

Not Python

earnest phoenix
#

ok

mossy vine
#

learn python properly before attempting to make a bot with it

copper cradle
#

python bot.py

mossy vine
#

it will save you a lot of headaches and might even get you somewhere in bot development

copper cradle
#

FILE <stdin>

earnest phoenix
#

what is stdin?

mossy vine
#

standard input

copper cradle
#

Standard input

mossy vine
#

In computer programming, standard streams are preconnected input and output communication channels between a computer program and its environment when it begins execution. The three input/output (I/O) connections are called standard input (stdin), standard output (stdout) and...

earnest phoenix
minor kelp
#

n o

#

just

earnest phoenix
#

where can i get my standard input?

minor kelp
#

python bot.py

mossy vine
#

you dont have to do anything with standard input

earnest phoenix
#

ok

#
import logging
import sys
from discord.ext import commands
from cogs import music, error, meta, tips
import config

cfg = config.load_config()

bot = commands.Bot(command_prefix=cfg["prefix"])


@bot.event
async def on_ready():
    logging.info(f"Logged in as {bot.user.name}")


COGS = [music.Music, error.CommandErrorHandler, meta.Meta, tips.Tips]


def add_cogs(bot):
    for cog in COGS:
        bot.add_cog(cog(bot, cfg))  # Initialize the cog and add it to the bot


def run():
    add_cogs(bot)
    if cfg["token"] == "":
        raise ValueError(
            "No token has been provided. Please ensure that config.toml contains the bot token."
        )
        sys.exit(1)
    bot.run(cfg["token"])```
minor kelp
#

use hastebin.

#

of that

#

or*

earnest phoenix
#

i got it from github

modest maple
#

smh

minor kelp
#

oh lord

modest maple
#

DONT COPY PASTE

minor kelp
#

please dont

#

its a really bad idea

modest maple
#

as its very clear u have fuck all idea what ur doing

earnest phoenix
#

but what is wrong in my code?

unique nimbus
#

I just looked at it

#

It is not up to date

earnest phoenix
#

😦

unique nimbus
earnest phoenix
#

i tried to make a music bot

minor kelp
#

Alex.

earnest phoenix
#

wha

minor kelp
#

Making music bots are difficult.

earnest phoenix
#

even in python?

unique nimbus
#

any language

minor kelp
#

Definitely not something you want to do for your first project/bot.

unique nimbus
#

^

earnest phoenix
#

ok

unique nimbus
#

My first project was to make a calculator

minor kelp
#

My first was just a password generator,

earnest phoenix
#

i made a moderation bot as my first project, in js

modest maple
#

welp

#

you shouldnt start with a bot

earnest phoenix
#

then with what

unique nimbus
#

Make a calculator in python

earnest phoenix
#

ok

unique nimbus
#

don't take code

#

read the documents

#

look at how things are done

#

what the errors mean

earnest phoenix
#

Ok

mossy vine
minor kelp
#

Nice.

#

You use tkinter?

earnest phoenix
#

is there a way to have unlimeted time in setTimeout

mossy vine
#

uhm

#

whats the point of a setTimeout then

minor kelp
#

^

earnest phoenix
#

hmmm

unique nimbus
#

Wait why do you want to set a timeout in the first place if you don't want it?

minor kelp
#

Yeah.

blissful scaffold
#

Unlimited timeout, runs right after the universe ends

minor kelp
#

lol ye

copper cradle
#

My first proyect was a brainfuck interpreter

grizzled raven
#

my first project was a discord bot 😳

#

i made it because i was in some discord server with a community made bit and the owner made the bot bad so i learnt js so i could try and replace it

#

didnt work, but now im good at js

earnest phoenix
fiery stream
#

anyone wanna make discord bot usig discord.js web build

mossy vine
#

why would you

fiery stream
#

cuz

#

easier approch

#

dashboard would be easier

mossy vine
#

yes and publish your bot token and entire source code

fiery stream
#

oof

#

well ill find a way to secure that

mossy vine
#

you wont

fiery stream
#

well i can

potent ivy
#

lmao, anyways why cant you just use node express to render the website?

#

i made dashboard with custom commands like this

#

pretty seamless and painless exchange of data between bot and website

fiery stream
#

yo

#

do u have dashboard in same proj?

potent ivy
#

they run on the same process

#

yes

fiery stream
#

how would u shard then?

potent ivy
#

well i dont

#

small private bot

#

that would be an issue in here i guess?

fiery stream
#

i dont want a private bot

#

yea big issue with ports

potent ivy
#

well i never imagined sharding would break this in anyway

fiery stream
#

u ill get error saying

#

port 3000 is already in use

potent ivy
#

the bot file could be imported as module tho? no?

fiery stream
#

wdym

wicked badger
#

Is there a way to find/fetch a webhook by name in a guild for Discord.js?

potent ivy
#

well never did it but, just in the index.js (express app) make a require('./bot.js') which would be the bot

#

bot.js does whatever the fk it wants, shards or not

#

but can access parent module anytime, which would be the express app

fiery stream
#

ah so you would parent the express app>

#

?

potent ivy
#

like i said i never did it before, never even had a bot that required sharding

#

but just like my commands are modules i require in main bot file, i would make the bot file be required in the express file

#
let expressApp = module.parent.exports```
in the bot.js file
fiery stream
#

i get what u are trying to say

#

i never tried that

#

i tried importing web app to my bot and that used to crash it

summer torrent
potent ivy
#

ignore that last message, its confusing mess lol what i wrote

fiery stream
#

i get what u tring to say

wicked badger
#

Thank you

fiery stream
#

but is there any way i can hide token

#

in web build

potent ivy
#

...host your token on the web and make it so only the whitelisted IP can see it (the IP of your webbuild), and request token from webbuild to the place where you have your token lmao

#

idk if it even works like that

fiery stream
#

ohh just hasing it

potent ivy
#

im imagining you can make an API call from webbuild to anywhere

#

right

#

maybe?

#

dunno

#

but anyways

#

make a place in your web somewhere with token.txt

#

and just make the permissions so its visible only to localhost

#

127.0.0.1

#

IDK if it works, ive barely touched html

mossy vine
#

you will not be able to hide your token in web build

fiery stream
#

no awy?

#

way*

potent ivy
#

or trust that guy since he probably knows what hes doing

fiery stream
#

i can do something

potent ivy
#

how does web build work again? can you run it like on your local machine?