#development

1 messages Β· Page 1485 of 1

rocky hearth
#

yes

cinder patio
#

square.piece as Piece tells TS that square.piece is strictly of type Piece. So (square.piece as Piece).alliance would fix the TS error.

rocky hearth
#

doing this, ts is not complaining any more. And therefore is now of type Piece

#

I'm already using this method, since last few weeks

cinder patio
#

But then your if statement becomes redundant

summer torrent
#

!. tells compiler that "don't worry about .piece"

rocky hearth
#

yes, U (Feud) might be confused with ! and ?

eternal osprey
#

anyone knows the answer?

summer torrent
rocky hearth
#

using ? checks for falsy values.

#

yes

cinder patio
#
const piece = square.piece as Piece;
piece.alliance; 

To me that's clearer when I have to access properties inside piece multiple times but to each their own

rocky hearth
#

I use that approach, when I forcefully want to change the type of the object.
otherwise, if piece is of type Piece | null
I do

const piece = square.piece!;
piece.alliance;
earnest phoenix
#

it's just used to tell tsc "at this time, it will definitely have a value"

rocky hearth
#

hmm, "or in this block..."

eternal osprey
#
//Google Map
  var lat = parseFloat(document.getElementById('52.379189').value);
  var lng = parseFloat(document.getElementById('4.899431').value);
 
  function initialize_google_map() {
    var myLatlng = new google.maps.LatLng(get_latitude, get_longitude);
    var mapOptions = {
      zoom: 14,
      scrollwheel: false,
      center: myLatlng
    };
    var map = new google.maps.Map(document.getElementById('google-map'), mapOptions);
    var marker = new google.maps.Marker({
      position: myLatlng,
      map: map
    });
  }
  google.maps.event.addDomListener(window, 'load', initialize_google_map);```
fierce ether
#

on local host it looks normal

#

but when punlished the css goes weird

earnest phoenix
#

make sure it isn't your cache

fierce ether
#

what isnt the cache?

#

client.guilds.cache?

earnest phoenix
#

huh

fierce ether
#

whats not cache?

earnest phoenix
#

browsers cache websites

knotty carbon
#

Refresh with Ctrl + F5

earnest phoenix
#

make sure it isn't the cache's fault

fierce ether
#

oh thanks

#

worked

knotty carbon
#

;)

eternal osprey
#

hey

eternal osprey
knotty carbon
#

I don't know

normal sage
#

does anyone wanna work on a bot together?

fierce ether
#

@normal sage nobody is going to want to make a bot with you unless you bring something to to the table for them

#

so what are you offering?

normal sage
#

a good bot idea

#

one thats never been done before

fierce ether
#

dm me

earnest phoenix
#

my labour is paid

normal sage
#

ok

knotty carbon
#

Never say never

earnest phoenix
rocky hearth
#

dm me too

eternal osprey
#

could someone help me?

#

still at the same issue.

rocky hearth
#

Sorry, bro, I hvn't worked with google maps

#

u can try, reading the docs, though

delicate shore
#

Controlling game with discord commands

#

Where to start

earnest phoenix
#

which game

#

what

#

what do you want to do

delicate shore
#

Mario for example

#

If a person says right

#

It goes to right

#

If person says left it goes to left

earnest phoenix
#

which language are you using

delicate shore
#

If jump then jump

#

JavaScript

earnest phoenix
#

i use robotjs in my app

#

super simple API for controlling the keyboard (and mouse)

delicate shore
#

Wait it's really easy

#

Wow

earnest phoenix
#

you have to have the game focused though

delicate shore
#

@earnest phoenix can I make my bot run N instances of the game on the VM

#

For each server

#

But wait

#

The bot can't share screen

#

;-;

#

I thought I had a really good idea

#

But I can share screen

#

And bot can control

earnest phoenix
delicate shore
#

Iffy?

earnest phoenix
#

it's just presumed they can't because the mobile client ignores all video data from bots

delicate shore
#

Oh

earnest phoenix
#

no library supports video streaming regardless

#

you would have to implement it yourself

#

you have to use voice v5

#

voice v5 uses a new encryption method so that's fun

delicate shore
#

Ohh

earnest phoenix
#

sodium seems to have support for it

#

AES256-GCM

#

i started reverse engineering video but took a pause

#

it doesn't seem to be all that different from voice though

delicate shore
#

Thanks

old cliff
#

I have an idea

#

Make a mario game using embeds and emojis

#

You will have to write the game logic tho

earnest phoenix
#

and have it run at 1 fps with occasional ratelimits lmfao

#

you also wouldn't really need to write game logic

#

you can still run the game

#

take a screenshot of it

#

and send it

#

it would still run at 1fps and you'd get occasional ratelimits

dull blade
#

Mario game with 1 week cooldown for each server

cinder patio
#

@delicate shore your idea is still doable but you would have to show the game in a website possibly, not discord

earnest phoenix
#

cloud gaming in a nutshell

delicate shore
#

ye

old cliff
#

1fps games are great

#

For discord

#

Like sokobot

earnest phoenix
#

you can do snake... and that's pretty much it

inner roost
#

a mario game i think is too complex to do it in discord

old cliff
cinder patio
#

pacman maybe

old cliff
#

But did not all to main bot

earnest phoenix
#

and asteroids

old cliff
#

Pacman can be harder

cinder patio
#

tetris

inner roost
#

||i luv discord pacman||

earnest phoenix
#

anything that runs on more than a few fps is pretty much impossible to do without skipping frames

old cliff
#

We can do pacman tho

#

Pac and ghosts will have 1 speed

#

But it will get ratelimted too much

earnest phoenix
#

it wouldn't be enjoyable either

old cliff
#

Yes

earnest phoenix
#

people can just google pacman and play it if they want to

cinder patio
#

tetris is also possible, there will a timer for when the piece will fall, you can move and rotate the piece

old cliff
#

Nah

#

Make snake

#

1fps snake

#

🐍

cinder patio
#

co-op tetris

earnest phoenix
#

you'd basically have 1hz polling rate lmfao

rocky hearth
#

I did, connect 4 game, for my bot

mellow kelp
#

how about minesweeper

old cliff
#

No

mellow kelp
#

o

#

fine

old cliff
#

You can't detect mine clicks

rocky hearth
#

and tictactoe, puzzle15 etc

mellow kelp
#

but like

old cliff
#

Unless user types coordinates

mellow kelp
#

the user can type

#

A5

#

B2

old cliff
#

That sucks

earnest phoenix
#

are you implying your average user is smart enough to understand how that works

mellow kelp
#

hm

old cliff
#

Reactions could also be used

mellow kelp
#

true tho

old cliff
#

Abcdefghi

mellow kelp
#

users are dumb

old cliff
#

123456789

#

Music bots are easier than game bots

mellow kelp
#

yeah

#

but you need more bandwidth to host them

rocky hearth
earnest phoenix
#

music bots are also oversaturated and aren't worth making

old cliff
#

Pong bot ?

#

Ping pong

#

Chess bot ?

quartz kindle
#

cheese bot

earnest phoenix
#

see that is something you could do

#

chess with custom emojis

#

play against the bot

#

etc

old cliff
#

Ludo and chess

#

And snake and ladder

quartz kindle
#

how about an auto-board game

old cliff
#

Monopoly ?

quartz kindle
#

something like that

#

but it plays by itself

#

you just watch

old cliff
#

Nah

quartz kindle
#

xD

grizzled raven
#

make a bot that dms tim whenever it senses a discord.js like question

quartz kindle
#

Lol

old cliff
#

Interestung

#

Ai powered code error solver

earnest phoenix
#

on message => send("use google")

old cliff
#

Lol

grizzled raven
#

opening some development channel to see use google after ever message bigbrain

#

in reality i don't really know any more bot ideas at this point

#

well i do have one last bot idea but it's just a twist to your basic moderation bot

old cliff
#

A bot which does nothing ?

#

AI mod bot ?

#

Which deleted toxic stuff ?

earnest phoenix
#

people waste their very creative game ideas on implementing it in a discord bot

#

why not just get into actual game deving

#

turn your idea into reality

quartz kindle
#

much good shit is wasted on discord bots

#

however discord bots are sometimes much easier to implement such ideas

#

because you dont need to deal with UI, you just abuse discord's lul

#

my bot for example could have had much more success as a web app, and i do plan to make a web app out of it

#

but fuck frontend

mellow kelp
#

css about to give you a stroke

misty sigil
#

css will

quartz kindle
#

btw whats the best reaction role bot out there?

misty sigil
#

I don’t know

#

definitely not mee6

heavy anchor
#

I use Carl-bot and it works fine for me

cinder patio
#

I would jump straight into game dev if I knew how to do art

rocky hearth
#

For ts, I have a type say type MyType = 'HELLO' | 'BELLO';
How do I change it to a enum like
enum EnumType {HELLO, BELLO};

cinder patio
#
enum EnumType {
  HELLO = "HELLO",
  BELLO = "BELLO"
}
#

but enums are better with numbers.. that's basically their whole point

rocky hearth
#

U hv not got my point. I want to change that type to a enum

#

And I do want the numbers

mellow kelp
#

well you can't do that stuff at runtime

#

ts is compiled to js

cinder patio
#

Then just

enum EnumType {
  HELLO,
  BELLO
}
#

oh you want to convert it during run-time

#

that's not possible

restive furnace
#

also when that's transpiled to js, then enums are weird

mellow kelp
#

well yea

#

but like, i guess they still work

rocky hearth
#

yeah, but I do want to get that weirdness, 'hello' -> 0 and 0 -> 'hello'

#

we can use const though with enum, to not reverse map the numbers

cinder patio
#

type declarations themselves don't transpile to anything - they are just helpers for the typescript compiler and your IDE.

rocky hearth
#

hmm ok thanks πŸ‘

mellow kelp
#

im pretty sure const enum was to make the enum not available at runtime i think?

rocky hearth
#

I didn't knew about that though! πŸ€”

cinder patio
#

yea

#

well, it does make them available to runtime but they just compile to a basic array

rocky hearth
#

hmm, yeah, I too just saw

mellow kelp
#

oh alr

#

that kinda makes sense

cinder patio
#

actually I don't think they even get compiled

mellow kelp
#

o

cinder patio
#

so for example

const enum Enum {
   one = 1,
   two, 
   three
}

console.log(Enum.one)
typescript will replace Enum.one with 1 in the compiled code

honest perch
#

so im fetching the latest ban case in discord.js, but its giving me the one before the latest one

heavy anchor
#

What does this mean? TypeError: fields.flat is not a function in a discord.js embed

honest perch
#

im using Guild#fetchAuditLogs
and then entries.first();

pale vessel
#

Array.prototype.flat() is only available in node 11 and upper

pale vessel
honest perch
#

@pale vessel yeah but when i fetch the whole array from the audit log, the ban that just occurred isnt there

pale vessel
#

It takes time for Discord to update audit logs

honest perch
#

so how to fix

pale vessel
#

wait

honest perch
#

yes

heavy anchor
#

thx

honest perch
#

@pale vessel still alive?

pale vessel
#

ye

honest perch
#

you told me to wait

pale vessel
#

yes, wait for discord

honest perch
#

how

eternal osprey
#

hey guys i have got a question

#

i just made my first website and want to deploy it to my vps.

#

how would i actually do that?

misty sigil
#

use a webserver

#

if its a static site you can use nginx/apache

eternal osprey
#

I already have the whole website done,.

misty sigil
#

does it have a backend or just files?

eternal osprey
#

index.html, js and css

upbeat prairie
#

Here

eternal osprey
upbeat prairie
#

Waiting for orange to explain why elif statements exist

#

Wait

#

Maybe I got it

inner roost
#
a = 5+5
if a > 9:
 print("a is bigger that 9")
elif a < 9:
 print("a is smaller that 9")
else:
 print("a equals to 9")
upbeat prairie
#

Elif is literally another if

rocky hearth
#

I hv an array of instances of a class.
So to check if two instances are equal (with ref)
Should I use === or ==. (ik the diff bw these two)
I mean do I also need to check for the type?

upbeat prairie
#

U can only put one if, as many elifs and only one else

inner roost
quartz kindle
#

elif is the weirdest thing ever

upbeat prairie
#

Fr

mellow kelp
#

@rocky hearth do you want to check if the objects hold the same reference?

upbeat prairie
#

I think I got it

quartz kindle
#

why couldnt they go the normal route and just use else if

upbeat prairie
#

Thx orange

inner roost
#

Like

if:
False
elif:
True
else:
dont Activates

mellow kelp
gilded olive
mellow kelp
#

apparently

#

a regular else if

#

is just

#

an else

#

but with an if statement directly after it

#

but since python uses this weird indent thing

gilded olive
mellow kelp
#

they had to make another keyword just for that

eternal osprey
#

is there anyone that actually could help me to get my website up and running?

quartz kindle
#

so basically its a patch to an issue py itself created

#

lmao

eternal osprey
#

I don't get any of the tutorials i watched.

inner roost
#

indent makes the code more easy to read at least for me Pinwino

mellow kelp
#

lmao accurate

inner roost
#

Lol

mellow kelp
gilded olive
#

{=>{}{><~♀○}{}3{|{β—‹}

inner roost
rocky hearth
mellow kelp
#

just good practice to use ===

#

i think both work anyways

quartz kindle
#

whats worse, jsfuck or pyfuck

mellow kelp
#

penis.js

inner roost
#

😱

mellow kelp
quartz kindle
#

This library also has ReactJS bindings wiht the CondomJS wrapper component.

queen needle
mellow kelp
#

this library is revolutionary

#

completely ahead of its time

#

Used by 4

rocky hearth
inner roost
mellow kelp
#

truly an amazing discovery

quartz kindle
#

this is why i love programming

inner roost
quartz kindle
queen needle
#

that is amazing

rocky hearth
#

issues are even better there

inner roost
#

😳 LOLLLL

quartz kindle
mellow kelp
#

i love this community

pale vessel
#

lmfao vagina.js

inner roost
quartz kindle
#

best comment

inner roost
gilded olive
#

😭

tribal siren
#

how to make a check if a role is higher in the list?

#

for example

#
let mod = message.guild.roles.cache.get('304313580025544704');
let botReviewer = message.guild.roles.cache.get('767389896133443625');
if(mod > botReviewer) return message.channel.send('Mod **is** higher on the list!');
message.channel.send("Lol Bot Reviewer is higher didn't expect that");```
rocky hearth
#

<Role>.position

tribal siren
#

oh

#

so like

#

if(mod.position > botReviewer.position)

#

like this?

rocky hearth
tribal siren
#

oh

#

ok

#

thanks

quartz kindle
#

how about jesus.js

inner roost
#

Lmfaoo

quartz kindle
#

the code is amazing

mellow kelp
#

beautiful

quartz kindle
#
    Jesus.walkOnWater = function(){
        var elems = document.querySelectorAll('*');
        for(var i = 0, len = elems.length; i < len; i++) {
            elems[i].style.float = Math.random() < 0.5 ? 'left' : 'right';
        }
    };

    Jesus.die = function(){
        //check if Jesus died to prevent him to die again
        if(_jesusBody) return;
        _jesusBody = exports.Jesus;
        exports.Jesus = undef;

        // back to life in 3 days ---
        //=====================
        setTimeout(function(){
            exports.Jesus = _jesusBody;
        }, 3 * 24 * 60 * 60 *1000);
    };
    
    Jesus.waterToWine = function() {
        document.body.innerHTML = document.body.innerHTML.replace(new RegExp('water', 'gi'), 'wine')
    };

    Jesus.isDead = function(){ return !!_jesusBody;};
mellow kelp
#

whats the repo

quartz kindle
#

its from the same guy

mellow kelp
#

this guy totally deserves a follow

inner roost
quartz kindle
#

the code is empty lmao

inner roost
#

😱

quartz kindle
mellow kelp
#

"Made with πŸ†"

misty sigil
#

what the fuck have i just walked into

#

i love it

vale garden
#

hi

quartz kindle
vale garden
#

lmao

mellow kelp
#

to use ${} you have to use template literals, which use these quotes ``

misty sigil
#

its inside that

#

can you not see

mellow kelp
#

but you only have one thing on them, you should just use the variables themselves

misty sigil
#

bro

mellow kelp
#

o

#

wait yes

#

um nvm

vale garden
#

ive had this question for a while

mellow kelp
#

well its a syntax error

vale garden
#

and asked this a few times before here

#

but

mellow kelp
vale garden
#

how do i make an oauth2 app and a discord bot on 1 file

#

does anyone know

mellow kelp
#

1 file?

vale garden
#

ye

#

that isnt working

#

wha

mellow kelp
#

um i dont get what you mean

vale garden
#

like i did it in 1 file

#

and

mellow kelp
#

but in which line is the syntax error

vale garden
#

if the bot code is above only the bot works and if the oauth2 bot is above only that works

mellow kelp
#

check line 1

#

oh that thing has happened to me a couple times

#

i don't remember exactly why tho

earnest phoenix
#

Need little assistance. How to check if channel has perms or not?

mellow kelp
#

you mean the bot's channel permissions?

inner roost
#

ΒΏJs?

quartz kindle
#

look at the quotes

mellow kelp
#

maybe you had some more double quotes

quartz kindle
#

well now its even more wrong

mellow kelp
#

chage every double quote inside js events to single quote

earnest phoenix
mellow kelp
#

you can use channel.permissionsFor(someMemberOrUser)

earnest phoenix
#

kk

inner roost
earnest phoenix
#

i really want this to look superb

gilded olive
#

looks clean

#

af

inner roost
#

Lorem ipsum dolor sit amet, consecteur adipiscing elit. Etiam non urna ut purus

gilded olive
#

tho that bed icon

#

....

#

idk about that one chief

earnest phoenix
#

it's on the opposite side lmfao

#

i downloaded it from google because i cba to extract mc textures

#

going to fix the icons later

gilded olive
mellow kelp
#

but now, the ultimate question

#

is it responsive?

earnest phoenix
#

yup!!

mellow kelp
earnest phoenix
#

the font scales too

spiral crag
#

guys i tried to access the user's voice channel with ctx.message.author.voice.voice_channel in discord.py but i got the error nonetype object has no attribute voice channel, can someone please help

gilded olive
#
x = #fetch something
x.your_mom
#

in our case x is none

#

so it'd be something like nonetype object has no attribute your_mom

spiral crag
#

@gilded olive i get what the error means but why is the user none when i send the message

#

i mean the command

gilded olive
#

is the user in the voice channel?

inner roost
#

like a !join cmd?

gilded olive
#

that's one of the reasons it would return None

spiral crag
#

@gilded olive the user is none not the voice channel

gilded olive
#

that's pretty obvious why it would return None then

#

The user must be in the voice channel

spiral crag
#

@gilded olive i am in the voice channel but the user is none so the error says that a noneobject does not have a voice channel

gilded olive
#

what

earnest phoenix
#

if the user was none you wouldn't be able to access voice, no? but you accessed it and from there tried to access voice_channel

gilded olive
#

you know

#

ctx.message.author (which can just be ctx.author)

spiral crag
#

so what should i do to fix it

gilded olive
#

refers to the author invoking that command, not you (if you did not invoke it)

eternal osprey
#

hey could anyone please help me with setting up my website on the ubuntu vps?

eternal osprey
#

i've tried watching every tutorial out there but couldn't get it workingg.

gilded olive
#

and you were in the voice channel?

spiral crag
#

but apparently my voice is nonetype

#

yes

inner roost
#

ctx.author.voice.channel?

earnest phoenix
gilded olive
spiral crag
#

k

#
  if user_voice_channel != None:
    vc = covid_bot.join_voice_channel(user_voice_channel)
  else:
    ctx.send('Please join a voice channel first!')```
inner roost
#

i think

eternal osprey
inner roost
#
user_voice_channel = ctx.author.voice.channel
await user_voice_channel.connect()
spiral crag
#

@gilded olive do you think you could suggest a fi

#

*fix

earnest phoenix
gilded olive
#

what orainge said was correct

inner roost
#

:>

gilded olive
#

ctx.send is a coroutine

#

so await it

eternal osprey
#

so nginx should be installed on the vps riht

opal plank
#

POSTGRESQL

Does anyone know how one would do a sequence with a function/ multiplier rather than an integer increment?

earnest phoenix
inner roost
#

idk

eternal osprey
#

but wghat should i do after the installation?

#

Can't find any suitable tutorials on the web

gilded olive
#

sounds like a read the docs moment

earnest phoenix
#

guys still getting err for bot's channel permissions. how to check if channel which bot is creating has perm or not? any help is appreciated

#

your code makes absolutely zero sense

#

try refactoring that

pale vessel
#

async in map() thinkowo

#

use a for loop

mellow kelp
#

if you're gonna use async in map() use Promise.all

earnest phoenix
#

i mean sure you can map to a bunch of promises

#

and

#

yeah

#

that

#

well... are you running the function

#

post your entire snippet

#

so the for loop isn't executing

#

or, it is

#

it doesn't have any items to loop for probably

#

check for any errors

#

try putting a console.log above the for loop and see if it executes

atomic vault
#

i am hosting my bot on replit.io but now it s showing an error
`_http_client.js:152
throw new ERR_INVALID_PROTOCOL(protocol, expectedProtocol);
^

TypeError [ERR_INVALID_PROTOCOL]: Protocol "https:" not supported. Expected "http:"
at new ClientRequest (_http_client.js:152:11)
at request (http.js:46:10)
at Object.get (http.js:50:15)
at Timeout._onTimeout (/home/runner/wall-bot/index.js:13:8)
at listOnTimeout (internal/timers.js:549:17)
at processTimers (internal/timers.js:492:7) {
code: 'ERR_INVALID_PROTOCOL'
}`

earnest phoenix
#

you should try catch inside the for loop, and log the error from the catch, maybe there is an error happening

#

nvm im blind

#

didnt see the second snippet

#

you might not have the right instance of whatever events is

ionic dawn
#

I can make a connection to my MySQL db and then export that connection from the main js to another module right?

ionic dawn
#

can I export it as I export the client/args/message etc?

atomic vault
#

hosted?

ionic dawn
#

local

#

VPS

atomic vault
#

localhost?

ionic dawn
#

yh

upbeat prairie
#

can someone help?

atomic vault
#

which language

upbeat prairie
#

python

ionic dawn
#

I mean... I already made a connection at the main but I want to use that connection on another module to add it in a command

#

js

upbeat prairie
#

i just need the dpy equivalen of raw_input

ionic dawn
#

well... yes

#

xD

earnest phoenix
#

That's not the official domain

atomic vault
earnest phoenix
#

In the url that you passed

#

To the function

#

Also can you send your code

vale garden
#

im super late, but ye i am returning some stuff

atomic vault
earnest phoenix
#

you probably passed a url to http.get() that used https protocol change that

#

also can ye send thy code

atomic vault
#

const http = require('http'); const express = require('express'); const app = express(); var server = require('http').createServer(app); app.get("/", (request, response) => { console.log(Date.now() + " Ping Received"); response.sendStatus(200); }); const listener = server.listen(process.env.PORT, function() { console.log('Your app is listening on port ' + listener.address().port); }); setInterval(() => { http.get('https://appname.user.repl.co'); }, 280000);

ionic dawn
earnest phoenix
atomic vault
#

ya

earnest phoenix
#

I got a tutorial

#

Wait

#
repl.it

Hosting discord.js bots on repl.it ! This tutorial shows how you can host your discord bots on repl.it if they are built in node.js irrespective of whatever library you used. This tutorial is applicable for all discord.js and Eris bots. Just to ease things we'll be using the end product of this tutorial . What we'll be doing? Creat...

#

Use uptimerobot

#

It's way better

#

In that tutorial they use uptimerobot

#

They just tell u how to make a server with express

#

Or buy hacker plan if you really need good hosting

#

And link it to index.js

atomic vault
earnest phoenix
#

where is the error

atomic vault
earnest phoenix
#

and also can you send your code

atomic vault
#

i sent

earnest phoenix
#

Change the protocol to HTTP

earnest phoenix
atomic vault
#

i will try

sudden geyser
#

Is there really any point in using Eris

earnest phoenix
#

Idk

pale vessel
#

What do you mean

rocky hearth
#

for ts, what is the difference bw private member and using js' #member??

earnest phoenix
#

And put it in uptimerobot

#

Make it ping every 10-15 mins

sudden geyser
#

I know a lot of bots in the past used it for memory/performance reasons, but now with intents, the performance burden is less for both libs.

earnest phoenix
#

oh

#

nice

sudden geyser
pale vessel
#

Some people prefer using Eris just because it makes them "independent"

earnest phoenix
earnest phoenix
misty sigil
#

llmao

earnest phoenix
#

i replied to the wrong message

#

oops

#

It's a library you use to interact with discord api

That's the point

inner roost
#

lol

misty sigil
#

i don't know if i am the average user of djs

earnest phoenix
#

You only asked for the point

rocky hearth
earnest phoenix
#

You didnt ask for the comparison

pale vessel
#

and Eris has less utils and helper methods, so you have to find ways to do stuff yourself

#

unlike Discord.js which has a method for every fucking thing

earnest phoenix
#

eris is for tryhards

#

and so is djs

misty sigil
#

no

#

none of that is for tryhards

#

wanna know what is

pale vessel
#

ourcord

misty sigil
#

raw ws

earnest phoenix
#

botghost

#

not using node in the first place? mmLol

sudden geyser
#

Eris feels more like a do-it-yourself job but with less advantages unless you don't want Discord.js doing most things for you. Like sorting a collection of members in Eris doesn't provide a sort method, so you have to map it to an array then do your sorting, yet you can on Discord.js with its Collection object.

sudden geyser
misty sigil
earnest phoenix
#

botghost is for people who wanna spend ten hours making a shit bot than spending two minutes making something that you actually like even if it sucks

pale vessel
#

ten hours more like ten dollars

earnest phoenix
#

botghost is for people who want to brag about knowing programming but aren't able to write a for loop

sudden geyser
#

so a skid

earnest phoenix
#

ding

sudden geyser
#

mmlol

pale vessel
#

Eris collection.filter() returns an array instead of a collection

#

that's one weird thing I noticed when using it

earnest phoenix
#

uhh lite why are you whitename

sudden geyser
#

White names are superior to green names

pale vessel
#

you can ask the same to cry sure

earnest phoenix
#

public bots lmao

#

ew

pale vessel
#

imagine

#

pussy grabber is better bro

earnest phoenix
#

LMFAO

toxic jolt
#

hi

sudden geyser
#

inb4 taken out of context

atomic vault
ionic dawn
#

bruh...

inner roost
#

Why there is a invite there

#

Nah

#

lol

atomic vault
toxic jolt
#
if(db.fetch(`mesajsayi_${message.author.id}`) > 5) {
    db.delete(`mesajsayi_${message.author.id}`)
  const botdm124 = new Discord.RichEmbed()
 .setTitle(`![zipzip](https://cdn.discordapp.com/emojis/785883576734449745.webp?size=128 "zipzip") **Tek seferlik, Robot olmadığını doğrulaman gerekiyor** ![zipzip](https://cdn.discordapp.com/emojis/785883576734449745.webp?size=128 "zipzip")`)
 .setColor('#0008FF')
 .setThumbnail(client.user.avatarURL)
 .setDescription(`\`\`\`Cortexciği kâtü robotcuklardan koruman gerekiyor UwU\`\`\`\n > **Destek Sunucusuna Katılarak:**\n\n![Yetkili](https://cdn.discordapp.com/emojis/709332943922921482.webp?size=128 "Yetkili") !!rozetlerim - 2 Adet rozet hediye.\n![cortex](https://cdn.discordapp.com/emojis/759432975216803840.webp?size=128 "cortex") Cortex artık daha insansı konuşacak! (konuştuğunca gelişir)\n![premium](https://cdn.discordapp.com/emojis/709334994815811624.webp?size=128 "premium") !!sunucutanıt - Komutuna erişim sağla!\n![renkli_konfeti](https://cdn.discordapp.com/emojis/786236677462425610.webp?size=128 "renkli_konfeti") Ücretsiz, Spotify, Deezer, Youtube, Cortex Premium'unu al!\n\n > **Cortex Destek Sunucusuna katıl :** https://discord.gg/xxxxxxxxxx`)
 .setFooter("Neden bâyle bir mesaj geldi?\nCortex dakikada 150 farklı kişi ile konuşuyor. Cortex'in bir sabrı var :3", client.user.avatarURL)
 
     message.channel.send(botdm124)
//.then(c => c.delete(30 * 1000))

 }``` 
"db.delete" works but the embed does not come (discord.js v11)
earnest phoenix
#

why are you using v11

toxic jolt
#

so many code

#

I am lazy

earnest phoenix
#

ok...? port it...?

sand condor
#

v11 will break early 2021

toxic jolt
#

break?

old cliff
#

yo

sand condor
#

yes since discord changed their domain

earnest phoenix
#

it's running on gateway v5 which is deprecated

old cliff
#

how do I send a file in atttachment using json ?

pale vessel
#

...using JSON?

earnest phoenix
#

Discord has different gateway versions?

old cliff
#

yes

toxic jolt
old cliff
#
                embed : {
                    title: "Blah Blaht",
                    description: `\`\`\`${data}\`\`\``,
                    color: 'RANDOM'
                },
                files: []
            });```
earnest phoenix
old cliff
#

add file with a name of the file

earnest phoenix
toxic jolt
#

how can i see the error

old cliff
#

nah just how to send an attahment without using new Discord.Attachment

ionic dawn
toxic jolt
#

there is no error because

mellow kelp
#

ig

toxic jolt
#

thanks for helping

#

guys

old cliff
#

All I am asking is to how to name an attahcment

pale vessel
#
channel.send({
    files: [{ name: "image.png", attachment: buffer }]
});```
old cliff
#

thank you

inner roost
#

i want to do that activity changes every 30 sec and instead of putring things in on_ready put it in
async def activity(bot):
commands.Bot(activity=activity)?

#

it is possible?

earnest phoenix
#

@inner roost use an interval

#

idk how to do in python tho

inner roost
#

Lol

earnest phoenix
#

ask shivaco the python guy

ionic dawn
inner roost
#

But like
async def activity(bot):
return activity(#smthng)
await asyncio.sleep(60)
....

earnest phoenix
inner roost
#

ik but just want to see if it is possible lol

earnest phoenix
#

go to the doc link and read it

inner roost
#

ik ab tasks ;-;

earnest phoenix
#

oh

#

why would you not use them then

inner roost
#

idk, just question :> sorry

crimson vapor
old cliff
#

yo is there any way to not show attachment appear as an attachment and just add it as a link ?

#

or show attachment inside an embed ?

pale vessel
#

<url>

old cliff
#

like this ? fields: [{ name: "Download", value: "[Click Here](attachment://message.txt)" }]

pale vessel
#

you have to send the message somewhere and get the attachment URL

#

and then send another message to the correct channel with the attachment URL

old cliff
#

oof

polar kiln
pale vessel
old cliff
#

is there any way to send embed before attachment ?

pale vessel
#

I don't think so, embeds always show up later

old cliff
#

oof

#

ok thanks

pale vessel
#

You need to send the attachment after sending an embed

old cliff
#

hmm k

pale vessel
#

which takes 2 calls

old cliff
#

yeah double quota usage

quartz kindle
#

xxx: OK, so, our build engineer has left for another company. The dude was literally living inside the terminal. You know, that type of a guy who loves Vim, creates diagrams in Dot and writes wiki-posts in Markdown... If something - anything - requires more than 90 seconds of his time, he writes a script to automate that.

xxx: So we're sitting here, looking through his, uhm, "legacy"

xxx: You're gonna love this

xxx: smack-my-bitch-up.sh - sends a text message "late at work" to his wife (apparently). Automatically picks reasons from an array of strings, randomly. Runs inside a cron-job. The job fires if there are active SSH-sessions on the server after 9pm with his login.

xxx: kumar-asshole.sh - scans the inbox for emails from "Kumar" (a DBA at our clients). Looks for keywords like "help", "trouble", "sorry" etc. If keywords are found - the script SSHes into the clients server and rolls back the staging database to the latest backup. Then sends a reply "no worries mate, be careful next time".

xxx: hangover.sh - another cron-job that is set to specific dates. Sends automated emails like "not feeling well/gonna work from home" etc. Adds a random "reason" from another predefined array of strings. Fires if there are no interactive sessions on the server at 8:45am.

xxx: (and the oscar goes to) fucking-coffee.sh - this one waits exactly 17 seconds (!), then opens a telnet session to our coffee-machine (we had no frikin idea the coffee machine is on the network, runs linux and has a TCP socket up and running) and sends something like sys brew. Turns out this thing starts brewing a mid-sized half-caf latte and waits another 24 (!) seconds before pouring it into a cup. The timing is exactly how long it takes to walk to the machine from the dudes desk.

xxx: holy sh*t I'm keeping those

crimson vapor
#

I saw that once

#

its funny

trim saddle
#

@quartz kindle stop with the hypotheticals

cerulean ingot
#

hey guys

#

ive really been wanting to make a new bot recently, any ideas?

trim saddle
#

@tight heath hey come here

tight heath
#

i am here

#

hi

trim saddle
#

hello

#

about that http lib you suggested

#

it appears i'm sending busted data with it

tight heath
#

im just gonna mind read your code really quick

#

give me a sec

trim saddle
#

shut up

tight heath
#

aight

#

πŸ™Š

trim saddle
#
async initDM(id: string) {
    const res = await this.client.path(USERS+"/@me/channels")
    .body({ recepent_id: id }, "json")
    .send()
    if (res.statusCode === 200) return await res.json() 
    else console.log(await res.text())
}
tight heath
#

wtf is this.client.path

#

what

trim saddle
#

this.client is a centra instance

tight heath
#

i am confused

#

okay

#

what's a recepent_id

#

do you mean recipient

#

also you're using centra right?

trim saddle
#

and yes i am

tight heath
#

use @aero/centra

#

also

#

then like

#

write recipient

#

not recepent

trim saddle
#

waht

#

W A HT

tight heath
#

also @aero/centra changes behavior so you can just do

#

res.json

#

instead of

#

await res.json()

trim saddle
#

i swear spelling is gonna be my downfall

#

i'll migrate at some point

tight heath
#

also .path() etc mutate in-place

#

i dunno how good a client instance is

#

i think there was a bug in centra that i fixed in my fork with that

trim saddle
#

hm.

#

oh shit

#

i figured out my issue

#

it was POST and i didn't set it KEKW

#

kinda odd how it redirected to google for a 400

tight heath
#

in centra-aero you can do .method("POST")

trim saddle
#

the advertising 😩

tight heath
#

i can also just not help you if you prefer that

trim saddle
#

i said i would switch

cinder patio
#

ew centra

earnest phoenix
#

How to set a global database value for all servers and users? I want to make a botstatus command to change to maintenance status if it's in maintenance
I tried : let botstatus = db.get(`botstatus`) if(!args[0] === "set") { db.set(`botstatus`, args[0]) } if (botstatus === "1") message.channel.send('Maintenance') if(botstatus === "2") message.channel.send('Running')
And it didn't work

#

Halp

cinder patio
#

!args[0] === "set" That's not correct - !args[0] turns args[0] into a boolean value, so you are comparing true or false to the string "set" (false === "set"), which will always equal false and the code inside the if statement will never execute

earnest phoenix
#

Oh

#

I meant args[0] without exclamation

#

Point

#

And even if I remove the thing

#

It doesn't work

cinder patio
#

did you try?

#

If args[0] is "set", and you do db.set(`botstatus`, args[0]), then "botstatus" will be always set to the string "set"

earnest phoenix
#

Oh

#

True

#

args[1] then?

#

In the db.set

cinder patio
#

sure

earnest phoenix
cinder patio
#

?

opal plank
#

thats a bad way of doing it, but i guess it works?

earnest phoenix
opal plank
#

i assume he legit counted how many characters are in the message (including his prefix + commandname + sub-arguments)

#

oh

#

no

#

dude

earnest phoenix
cinder patio
#

oh jesus

opal plank
#

pls tell me you dont have multiple client.on(''message')

#

please tell me you dont

cinder patio
#

yup he does

earnest phoenix
#

i do

trim saddle
#

tbh i wouldn't try to mediate a minimum number of characters

opal plank
#

dont

earnest phoenix
#

do i need all in one listner?

opal plank
#

yes

cinder patio
#

otherwise it'll be very slow

earnest phoenix
#

But for that i need do to else if

opal plank
#

use a command handler

#

rather than that

earnest phoenix
#

Anything but not cmd handler

opal plank
#

wdym antyhing BUT command handler?

cinder patio
#

if you have 20 commands and 20 message listeners then everytime a new message is sent 20 functions will be called, each to check if the message matches a command

opal plank
#

your options are either a massive else if chain or a switch

#

command handlers are the best option by FAR

earnest phoenix
#

i need else if chain not handlers

trim saddle
#

why

opal plank
#

you need a command handler not stubbornness

earnest phoenix
#

handlers are complex to undersant

trim saddle
#

a command handler is easier to use and recommended

opal plank
trim saddle
earnest phoenix
#

i have a 600 line code if i change it now it'll take megazega billion years

opal plank
#

your 600 line code will turn into 4k in a few days

cinder patio
#

no they are not. You are basically putting all your commands in a hash map and in the message event you get the command and execute it

earnest phoenix
#

oh nvm its 792 lines

opal plank
#

dont be stubborn, use a command handler

#

its for yuor own good

earnest phoenix
#

ok so do i jsut paaste the current code in different files?

#

or what

opal plank
#

well, if you followed the guide you should have at LEAST a bit of JS common knownledge to start with

#

thats what the guide is there for, to teach you on how to do it

cinder patio
#

different files aren't required, but are recommended for readability

opal plank
#

just dont blindly copy stuff

#

understand what it does

trim saddle
#

this is so bad tim came

quartz kindle
#

792 lines? im splitting a 3500 line file into 90 files lmao

earnest phoenix
#

keep in mind that a giant if else is the reason why yandere simulator runs like cyberpunk but has the graphics of tetris

#

can someone solve this problem

cinder patio
#

you didn't even tell us the problem

earnest phoenix
#

Its my first time scripting a discord bot so....

quartz kindle
#

you are bypassing the report command

#

the bot will respond to ANY message with less than 11 characters

opal plank
#

Command handling:

+ Readability
+ Able to reload the commands without restarting the bot
+ looks a lot better
+ structure and dynamic importing commands

Else/if

+ you get probably 3 or 4ms more since requiring other files are "less performant"
earnest phoenix
#

then suggest a solution...

trim saddle
#

πŸ€¦β€β™‚οΈ

opal plank
#

Rigby

#

legit

#

read this

earnest phoenix
#

i wish Js was like lua :(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((

opal plank
#

Before you make a Discord Bot, you should have a good understanding of JavaScript. This means you should have a basic understanding of the following topics:

  • proper syntax
  • debuging code
  • basic features (vars, arrays, objects, functions)
  • read and understand docs
  • nodejs module system

As much as we d like to assist everyone with making their bots, we rarely have the time and/or patience to handhold beginners through learning javascript. We highly recommend understanding the basics before trying to make bots, which use advanced programming concepts.

Here are good resources to learn both Javascript and NodeJS:

Javascriptinfo: https://javascript.info/
Codecademy: https://www.codecademy.com/learn/javascript
FreeCodeCamp: https://www.freecodecamp.org/
Udemy: https://www.udemy.com/javascript-essentials/
Eloquent JavaScript, free book: http://eloquentjavascript.net/
You-Dont-Know-JS: https://github.com/getify/You-Dont-Know-JS
NodeSchool: https://nodeschool.io/
CodeSchool: https://www.codeschool.com/courses/real-time-web-with-node-js
Evie s Accelerated JS: https://js.evie.dev/

Please take a couple of weeks/months to get acquainted with the language before trying to make bots!

earnest phoenix
#

@opal plank requiring at boot time and storing the result of that will negate the con of losing a few ms

#

so you would actually gain speed

quartz kindle
opal plank
#

monolithic code is probably the most performant of all, the issue is, well, its monolithic mmulu

quartz kindle
#

i prefer my code Palaeolithic

earnest phoenix
#

make everything a microservice tm

#

an aws lambda tm

quartz kindle
#

cloudflare workers

earnest phoenix
opal plank
#

just put your code in a database and reload it it by fetching the commands from the database WeSmart

inner roost
#

😱

quartz kindle
#

code your bot in C then compile it with movfuscator :^)

opal plank
#

| command name | code | lul |

#

store your commands in json and then require them

earnest phoenix
#

tell users to run it on their machine instead

quartz kindle
opal plank
#

i legit cannot think of anything stupid'er than what i recommended

toxic glade
#

how can i make a bot ?

opal plank
#

dynamic json command handler

inner roost
#

Code you own language in binary 😱

opal plank
misty sigil
#

its better than else if tho

inner roost
earnest phoenix
toxic glade
#

how to make but ?

cinder patio
#

store your commands in a discord channel

misty sigil
#

learn js

opal plank
#

@toxic glade
Before you make a Discord Bot, you should have a good understanding of JavaScript. This means you should have a basic understanding of the following topics:

  • proper syntax
  • debuging code
  • basic features (vars, arrays, objects, functions)
  • read and understand docs
  • nodejs module system

As much as we d like to assist everyone with making their bots, we rarely have the time and/or patience to handhold beginners through learning javascript. We highly recommend understanding the basics before trying to make bots, which use advanced programming concepts.

Here are good resources to learn both Javascript and NodeJS:

Javascriptinfo: https://javascript.info/
Codecademy: https://www.codecademy.com/learn/javascript
FreeCodeCamp: https://www.freecodecamp.org/
Udemy: https://www.udemy.com/javascript-essentials/
Eloquent JavaScript, free book: http://eloquentjavascript.net/
You-Dont-Know-JS: https://github.com/getify/You-Dont-Know-JS
NodeSchool: https://nodeschool.io/
CodeSchool: https://www.codeschool.com/courses/real-time-web-with-node-js
Evie s Accelerated JS: https://js.evie.dev/

Please take a couple of weeks/months to get acquainted with the language before trying to make bots!

inner roost
misty sigil
#

or just any lang

inner roost
#

:scream:

solemn latch
#

ah

earnest phoenix
#

a butt? a lot of injections

pale vessel
#

why are you spamming

opal plank
quartz kindle
inner roost
#

😳

earnest phoenix
#

still not working

solemn latch
#

watch finding nemo, it helps with that stuff.

#

making buts

opal plank
quartz kindle
pale vessel
#

else if else if else if else if else if else if else if else if

toxic glade
#

thx

opal plank
#

else if else if else if else if else if else if else if else ifelse if else if else if else if else if else if else if else ifelse if else if else if else if else if else if else if else ifelse if else if else if else if else if else if else if else if

#

use a command handler

toxic glade
misty sigil
#

use πŸ‘ a πŸ‘ command πŸ‘ handler

#

there are open source ones

#

too

opal plank
#

open sources? just legit copy the shit from the djs guide

#

its the simpliest one

inner roost
#

Lol

misty sigil
#

thats open source technically

quartz kindle
#

just make your own damn handlers

#

its like less than 10 lines

opal plank
#

i'd recommend else if's over COmmand to be completely honest

misty sigil
#

i started off with a base handler

pale vessel
#
JSON.parse(require("fs").readFileSync(`./commands/${args[0]}`)).run(message)```/s
quartz kindle
#

Lol

misty sigil
#

then i built on it

solemn latch
#

run message pogey

quartz kindle
#

json commands with functions?

#

wtf

toxic glade
#

hmm

pale vessel
#

oh RIGHT lol

toxic glade
#

hmm

misty sigil
#

u gotta eval it

toxic glade
#

you have verified bot badge

misty sigil
#

i know and dont care

toxic glade
#

i also want

pale vessel
#
try {
    require(`./commands/${args[0]}`).run(message);
}
catch (e) { return; }```
toxic glade
misty sigil
#

honestly

#

thats better than else ifs imo

pale vessel
#

idk probably

toxic glade
opal plank
#
commands = new Map();
postgres.query('SELECT * FROM commands').then(e => e.rows.forEach(e => commands.set(e.name, eval(e.code))));```

Beat that scrubs. I got all of it. global variables, obfuscation, evaluation, gg ez no re
quartz kindle
#

a solid 5/7

misty sigil
#

i can make a better one

toxic glade
#

gimme all code

opal plank
#

i wonder if this disgrace of code would even run

misty sigil
#
commands = new Map()
r = require('./commands/index')
Object.keys(r).forEach(e => {
  commands.set(e, r[e])
})```
opal plank
#

can you even require an eval?

quartz kindle
#

if you have an index file, you can require the directory directly

opal plank
#

im really not sure if you can even declare something like that

misty sigil
#

commands/index is js module.exports = { help: require('./help'), ping: require('./ping'), } etc

toxic glade
earnest phoenix
#

.find() but always return false, just so you can walk through the array mmLol

misty sigil
#

i like when development's like this

opal plank
#

retarded?

#

me too

toxic glade
#

all have rare badge

misty sigil
#

purposefully retarded

toxic glade
quartz kindle
#
commands = new Map(Object.entries(require("./commands")));
misty sigil
#

compaction

solemn latch
toxic glade
#

Pokemon Code

solemn latch
#

we dont give code

misty sigil
#

we help

solemn latch
#

spoonfeeding code is against rules here

misty sigil
#

not give

toxic glade
#

ohk

quartz kindle
#

how old are you @toxic glade ?

toxic glade
#

15

misty sigil
#

what a terrible name

opal plank
#
commands = new Map([...await postgres.query('SELECT * FROM commands').rows])```
toxic glade
misty sigil
#
process.commands = new Map([...await postgres.query('SELECT * FROM commands').rows])
pale vessel
#

process gang

jade juniper
#

hello

toxic glade
#

hmm

misty sigil
#

process is really fucking convenient

opal plank
#
process.ENV.commands = new Map([...await postgres.query('SELECT * FROM commands').rows])```
Beat that
earnest phoenix
#

\u006e\u006f
here's your pokemon code

toxic glade
solemn latch
misty sigil
#

yea ikr

opal plank
misty sigil
#

no

#

i haven't said anything about it because of pure fear

opal plank
#

xD

jade juniper
#

hello, i use BDFD and y can change the programation to Javascript how can make a play music command?? never i used Javascript

pale vessel
opal plank
#

i'll claim the crown of the stupidestesdes here then

misty sigil
#

oh no

jade juniper
#

sorry i speak only spanish

earnest phoenix
#

you have to rewrite the whole thing

toxic glade
#

me also

misty sigil
#

in javascript

earnest phoenix
misty sigil
#

ok back to stupid command handlers

toxic glade
#

πŸ˜‚

quartz kindle
#
global.commands = new Map(Object.entries(require(require("zlib").inflateSync(require("zlib").deflateSync(Buffer.from("./commands"))).toString())))
#

:D

misty sigil
#

OK

#

NOW THAT IS STUPID

jade juniper
#

you discovered me

toxic glade
#

:)

earnest phoenix
#

zlib triggers my vietnam war flashbacks
i was never in a vietnam war

opal plank
misty sigil
#

erwin can't beat that

quartz kindle
#

i have a better one

misty sigil
#

oh no

opal plank
#

bruh, mine uses fucking ENV to store it

jade juniper
#

it's possible make a music player on Javascript?

opal plank
#

how can u beat that?

solemn latch
#

only the best devs can make the worst code

misty sigil
#

if you use nodejs and not bdfd

opal plank
inner roost
misty sigil
#

im scared, what is tim going to come up with

toxic glade
#

const { CommandoClient } = require('discord.js-commando');
const path = require('path');

inner roost
#

Dbd.js Pinwino

misty sigil
#

commando

#

...

jade juniper
#

I mainly use BDFD only now I want to use a little more Javascript

toxic glade
#
const path = require('path');```
inner roost
#

no one uses dbd.js HC_SeriousSadCat

opal plank
toxic glade
#
    .registerDefaultTypes()
    .registerGroups([
        ['first', 'Your First Command Group'],
        ['second', 'Your Second Command Group'],
    ])
    .registerDefaultGroups()
    .registerDefaultCommands()
    .registerCommandsIn(path.join(__dirname, 'commands'));```
misty sigil
#

ajodWaerwhjuoaeEEEE

#

i dont like that

toxic glade
#

BDFD

opal plank
#

my point proven

toxic glade
#

hmm

jade juniper
#

i use BDFD

misty sigil
#

bdfd? more like badfd

opal plank
#

i dont even know what bdfd is