#development

1 messages Β· Page 735 of 1

valid frigate
#

an

#

d

#

before you dive into classes

#

make sure to capitalize class names

#

example iAmRetarded turns into class IAmRetarded

#

i am indeed retarded

languid dragon
#

yes because it was an example

quartz kindle
#

capitalization is not a requirment

#

its just what people usually do

#

you can just as well do your own thing and make all classes lowercase and all variables uppercase lol

amber fractal
#

there's only some rules to names in js

#

Cant start with a number

#

Lol

#

I think there are some more

quartz kindle
#

cant be any built in js namespaces, such as var let const for while new in of etc..

knotty steeple
#

whats the fastest http lib

heavy marsh
#
if (!message.member.roles.has(dj.id) || !message.member.hasPermission("MANAGE_MESSAGES"))

Is this wrong?

earnest phoenix
#

looks fine

#

as long as dj is a role object and your on stable

gentle bane
#

spanish?

#

Help?

heavy marsh
#

With out DJ?

earnest phoenix
#

?

heavy marsh
#

I am trying to make the command avaiable for users with dj role or for users with MANAGE_MESSAGES permissions

#

i removed the dj role from me an it didnt work

earnest phoenix
#

well that's how you have it coded

#

if they don't have the role or permission then...

heavy marsh
#

I mean i am the owner of the server

#

so i have MANAGE_MESSAGES permission

earnest phoenix
#

ok

heavy marsh
#

but the command send the errors

earnest phoenix
#

|| means or and you said you don't have the role so it's functioning as expected, right?

heavy marsh
#

ok wait

#
    if (!message.member.roles.has(dj.id) || !message.member.hasPermission("MANAGE_MESSAGES"))
    return [utils.timed_msg(utils.no_perm("You need the \`DJ Role\` or \`MANAGE_MESSAGES\` permission to use this command!"), 5000)];
earnest phoenix
#

what's the error

heavy marsh
#

it says "You need the `DJ Role` or `MANAGE_MESSAGES` permission to use this command!"

earnest phoenix
#

ik this isn't much of a solution but why not use &&

if they don't have the DJ role and they don't have the permission to send messages then...

heavy marsh
#

I dont want that ....

#

i need it with ||

#

or

finite atlas
#

how do i start using the bot

earnest phoenix
#

well the code is functioning as intended lmao

#

you don't have the role so it's returning that message

#

because your using ||

finite atlas
#

?

earnest phoenix
#

talking to Director

heavy marsh
#

or should i do something like

let havepermission = message.member.roles.has(dj.id) || message.member.hasPermission("MANAGE_MESSAGES")

 if (!havepermission )
    return [utils.timed_msg(utils.no_perm("You need the \`DJ Role\` or \`MANAGE_MESSAGES\` permission to use this command!"), 5000)];```
earnest phoenix
#

my brain hurts sorry

#

lmao just try

#

come back if there's a problem

heavy marsh
#

ok

atomic quarry
#

So I don't know where to put a part of the code can someone help me?

earnest phoenix
#
client.level.fetch(message.author.id + message.guild.id).then(i => {
      client.level.fetch(`userLevel_${message.author.id + message.guild.id}`).then(o => {
      message.channel.send(`Total messages sent: ${i.value + 1}\n Level: ${o.value}`)
    })
    })
sturdy wyvern
#

...

earnest phoenix
#

o is null

twin pendant
#

does anyone know the max file size a bot can upload?

loud salmon
#

at least im pretty sure thats what it means

slender thistle
#

Python question
open(some_file, 'wb') used to create a file if it didn't exist but apparently it doesn't work anymore? special_think

Issue solved

twin pendant
#

oh thanks spider

oak minnow
#

Can some 1 tell me how 2 send a image in a message (like the one im typing now) by a command by a embed 2 another channel.? EX:

#

-bugreport please send this immage in the embed 2 the super secret bug report channel >>>

#

ive tried multiple approaches but none seem 2 work.

loud salmon
#

@oak minnow

  1. Get the message content + any attatchments
  2. store them all in variables
  3. Get the channel you want to send the message to
  4. Either make a fancy embed or just send it raw. doing smth like channel.sendMessage(rawMessage + attatchments)
cerulean salmon
#

how to tag a role in imbedded message

#

discord.js

amber fractal
#

Well it wont actually tag the people, but <@&roleid>

#

I don't think it does anyways

slender thistle
#

For the looks k3llyShrug

cerulean salmon
#

GWmythiFeelsBannedMan \

junior dome
#

It’s possible to record audio with the discord api if I remember right. Would it be against the ToS to do that? I feel like if you have a terms of service thing you would be fine but just looking for some else’s opinion

earnest phoenix
#

its possible

slender thistle
lament meteor
#

it should be fine when u put it in ur bots ToS right

slender thistle
#

Technically yes

#

So the user can be held liable for not reading it later :^)

earnest phoenix
#

Hello

#

I have an add command for a music bot

#
let queue = {};

And the queue is in the file add.js

But if i want to use the queue in the play.js i can't....

tranquil drum
#

you can hold the queue object in play.js and pass it to add.js so it can add to it

#

or make it somewhere else and pass it to both scripts

earnest phoenix
#

you can hold the queue object in play.js and pass it to add.js so it can add to it

#

How?

tranquil drum
#

actually what i think what i would do is create it in some main script that requires the other two

#

then pass it to both

earnest phoenix
#

Oh okay

#

Ty

#

This is a nice idea

#

index.js => let queue = {};

play.js and add.js => let { queue } = require("../index.js")

But when i add i have =>

                if (!queue.hasOwnProperty(message.guild.id)) queue[message.guild.id] = {}, queue[message.guild.id].playing = false, queue[message.guild.id].songs = [];

TypeError: Cannot read property 'hasOwnProperty' of undefined```
tranquil drum
#

don't use require to get the queue object

#

you have to pass it by reference either with a method or a property

restive furnace
#

you should do it to <client>.queue to get it all files

#

like <client>.queue = {}; on index
and <client>.queue[message.guild.id] = {}; ln play.js and add.js

earnest phoenix
#

Oh okay ty

#

I'm bad pepowot

mossy vine
#

fyi that just makes the queue a property of your client object

earnest phoenix
#

Yup

#

TY

rugged minnow
#
.setImage("https://top.gg/api/widget/527625435128004628.svg")```
for some reason it's not putting any image?
#

should i put the link in a const?

modest maple
#

It should be .png

rugged minnow
#

uh ok

earnest phoenix
#

@rugged minnow

rugged minnow
#

thanks

earnest phoenix
#

Np

green kestrel
#

those of you with bigger bots, mind discussing your backup routine with me? what do you back up, how often, and how do you do it?

#

currently, i have all my source code in two git repositories, one on github and one on my lan, and i backup my sql database to a remote machine every night at midnight using a simple script that does mysqldump to a bzip2'd file with a datestamp in, deleting files over 30 days old.
should this be enough? to me it seems enough, as its more than most are doing i guess.

modest maple
#

I have any files on a GitHub

#

And then back up everything to onedrive

#

Every 24hr

green kestrel
#

the critical thing to me is my database. without it, my bot is basically a blank slate

modest maple
#

Same

green kestrel
#

i can restore the bot's source code as simple as git clone --recursive, but if i lost the database...

late hill
#

The code is on github and on my local machine

#

I backup db once a day keeping that backup on vps

#

Once a week I put a backpack on my local machine

#

In case the VPS would entirely die

green kestrel
#

good plan πŸ™‚

late hill
#

I've only ever needed backups because I messed something up

#

lol

mossy vine
#

should i even bother with stuff like string[] instead of using List<string> in C#

green kestrel
#

lol yeah thats been my experience, but things like bots tend to attaract skiddiots with a desire to prove themselves, dont want anyone to wipe my box or anything and have no backup to roll back to

#

@mossy vine isnt List<String> a linked list?

mossy vine
#

i have no idea lmao

green kestrel
#

if it is, its much slower to access an arbitary element by index, but faster to iterate the list... in that case, if youre accessing aribtary elements youre best using an array

mossy vine
#

but also arrays are garbage from what ive tried

green kestrel
#

yes, List<> is a doubly linked list

#

so if you want fast access to arbitrary indicies, use array

mossy vine
#

they dont have nearly as many useful methods and stuff as List

#

but if i dont care about speed can i just settle for List

green kestrel
#

or dictionary if you want best of both worlds

#

you should care about speed πŸ˜„

mossy vine
#

dictionary is key value which is not what i need lol

green kestrel
#

unles youre only storing like 10 elements

mossy vine
#

25 lmao

green kestrel
#

may be ok, depends on how often you access that list

mossy vine
#

i dont care much about speed, its just experimentation stuff

green kestrel
#

its also faster to insert into a list than an array

#

an array must be re-allocated to insert into it

#

an insert into a list is just the adjustment of two pointers

earnest phoenix
#
client.level.fetch(message.author.id + message.guild.id).then(i => {
      client.level.fetch(`userLevel_${message.author.id + message.guild.id}`).then(o => {
      message.channel.send(`Total messages sent: ${i.value + 1}\n Level: ${o.value}`)
    })
    })

o is null

#

@earnest phoenix console.log(o)

#

Please

warm marsh
#

Maybe you don't have userLevel inside whatever you're trying to access.

brave wedge
#

Can the ID of a user-to-user's DM channel change, e.g if the user 'deletes' it somehow?

slender thistle
#

I doubt there's a way to delete a DM channel

modest maple
#

Even if you close DMs the messages still stay there

compact oriole
#

How much does it take to get accepted for the auction system?

safe warren
#

idk

#

probs a week

#

or 3-4 days

compact oriole
#

Not a bot

modest maple
#

Well

#

I mean

#

I applied like 3 weeks ago

#

XD

slender mountain
slender thistle
#

Whenever the big man gets to it really

modest maple
#

Yh

wooden lance
#

Oops wrong channel

quartz kindle
#

they're probably so sick and tired of reviewing all sorts of applications that they are probably working on an AI for that at this point, hence why the queues are long

amber fractal
#

Which, to be fair, should've been done a long time ago

opaque eagle
#

Hmm...

#

TypeError: Reduce of empty array with no initial value

#
static highestRolePosition({ guild, roles = [guild.id] }: Member): number {
    const reducer = (a: string, c: string) => guild.roles.get(c).position > guild.roles.get(a).position ? c : a;
    return guild.roles.get(roles.reduce(reducer)).position;
}```
#

I set a default value

earnest phoenix
#

my 2 bots down after this error they are longing and disconnecting again and again.
both bot on different cloud

low wasp
#

you have hit your quota

#

quota is your limit

#

either daily, weekly, monthly

earnest phoenix
#

one on gllitch

#

and glitch is free

quaint grotto
#

to dm an embed is it message.author.send({embed});

low wasp
#

yes Gerb

quaint grotto
#

oh thank you

earnest phoenix
#

you could just do message.author.send(embed);

if you were to use it that way there is an embed option in the message

#

And how its possible both clouds quota exceeded on same time

#

@low wasp

low wasp
#

you using google cloud?

quartz kindle
#

quota for what tho? what kind of passwords are you verifying?

earnest phoenix
#

One glitch and second heroku

#

@quartz kindle idk

low wasp
#

there isnt much we can do without more information

earnest phoenix
#

Lol i have no more info about that

quartz kindle
#

are you using a database?

earnest phoenix
#

Yes

quartz kindle
#

which database?

earnest phoenix
#

Ah that should be problem

#

Im using firebase

amber fractal
#

@opaque eagle you didn't set an initial value...

#

All I see is ...(reducer)... which doesnt have an initial value

earnest phoenix
#

@quartz kindle @low wasp problem solved after regenerate my both bots token.

modest maple
#
def download(FileID):

    creds = None
    # The file token.pickle stores the user's access and refresh tokens, and is
    # created automatically when the authorization flow completes for the first
    # time.
    if os.path.exists('token.pickle'):
        with open('token.pickle', 'rb') as token:
            creds = pickle.load(token)
    # If there are no (valid) credentials available, let the user log in.
    if not creds or not creds.valid:
        if creds and creds.expired and creds.refresh_token:
            creds.refresh(Request())
        else:
            flow = InstalledAppFlow.from_client_secrets_file(
                'credentials.json', SCOPES)
            creds = flow.run_local_server(port=0)
        # Save the credentials for the next run
        with open('token.pickle', 'wb') as token:
            pickle.dump(creds, token)

    service = build('drive', 'v3', credentials=creds)

    Request = service.files().get_media(fileId=FileID)
    FileHandler = io.BytesIO()
    Downloader = MediaIoBaseDownload(FileHandler, Request)
    Done = False
    while not Done:
        Status, Done = Downloader.next_chunk()
        print(f"Download {int(Status.progress() * 100)}")```
#

i have achived fuck all with this ^^

#

^-^

#

just if anyone wants to know the worlds most annoying api

quartz kindle
#

wanna switch places?

sudden geyser
#

how dare you not add spaces between function arguments 😠

quartz kindle
#

to make my lines appear shorter and prevent horizontal scrolling

#

huehuehue

modest maple
#

Lol

#

If I knew Java I'd do it

#

Sadly

#

I'm a python dude

#

XD

quartz kindle
#

its javascript lul

loud salmon
#

lol imagine dealing with dates

#

and time

slender thistle
#

Java === JavaScript

quartz kindle
#

blasphemy

modest maple
#

Lol imagine not being python

strange trout
#

How do I send avatar as a png

#

displayAvatarURL() how do I pass it in Thinking

modest maple
#

usual .set_thumbnail(url="")

#

or in python

#

embedVar.set_thuimbnail(url="discord url link or what ever")

strange trout
amber fractal
#

@strange trout on master, format is a parameter not sure otherwise

west raptor
#

@strange trout are you on master?

strange trout
#

Yes but I figured it out

charred loom
earnest phoenix
#

this is the third time i'm telling you to read the error

vital lark
#

@charred loom Map#find requires a string or a function

#

ur missing a string or function in line 10 with find()

charred loom
#

ok

#

thanks

#

but on youtube it is

quartz kindle
#

youtube is bad

vital lark
#

YouTube bad

#

tutorials bad

charred loom
#

ok

#

help you with example?

vital lark
#

wha

quartz kindle
charred loom
#

help me or nu?

#

no*

quartz kindle
#

i did

charred loom
#

well you have to line 10

quartz kindle
#

i gave you the example on how to use .find()

charred loom
#

:facepalm: well what do i do

restive furnace
#

he gaved u link

charred loom
#

no

#

ok

#

thanks

#

I still did not understand, if you want to give me the direct example, if not, no

hasty sigil
#

Hello

charred loom
#

hi

#

please, help me bro

hasty sigil
#

Yes

#

@charred loom

charred loom
#

yes

hasty sigil
#

I m turkish

charred loom
#

use google translate?

hasty sigil
#

Use google translate

#

Phone

charred loom
#

ok

mossy vine
#

plot twist he doesnt read any answers that dont include the code he needs

restive furnace
#

@charred loom no spoonfeed

#

you need to understand yourself like i always do when i ask for help. they just give me links and i need to figure it out myself how to use by using the links what the guy gaved

modest maple
#

#nospoonfeed

charred loom
#

At least this time, I need to

#

I want to do something else

marsh cypress
#

can someone help me understand this error

#

please

vital lark
#

Directory/file doesn't exist

#

/ = root directory
../ = previous directory
./ = current directory

marsh cypress
#

it was working earlier

#

so how does the file not exist now

#

it has same file as another bot i own so i copied and pasted that to it and now the bot is working

#

but it was the same as it was before when it didnt work

#

im confused

compact oriole
#

~/ project root

marsh cypress
#

but why did it work after i copied and pasted the exact same thing

fathom cave
#

Hey I have some questions about the point bot

slender thistle
#

Is it a public bot or some self-hosted one

fathom cave
#

I want to use this bot (hopefully) so members of my discord can earn points by being active and sending messages.

Once they reach 500 points they can use the points to buy they're own discord channel. Is this possible?

#

And it's the "points" bot

summer torrent
#

yes

fathom cave
#

And I can set what the shop offers correct?

#

Or what they can buy with the points

south swallow
#

yeah

#

its on you to figure it out, not us

fathom cave
#

Perfect. Thank you guys. If I have anymore questions I'll be sure to ask.

south swallow
#

we can help you with bugs or errors, #nospoons

fathom cave
#

That's fine I'm capable of setting it up I only came to ask if it was possible.

#

Ty

south swallow
#

goodluck

fathom cave
#

Is it that bad?

#

If so I won't use it

south swallow
#

whats bad?

#

oh to set up paid roles?

fathom cave
#

You said good luck like it'll be a Hassel or hard to configure

south swallow
#

well its not going to be a 1-2-3, most peeps in discord expect stuff for free, you bot usecase applies more if patreons/donators get special roles

#

idk about their own channel

fathom cave
#

Then it doesn't seem possible as others said.

south swallow
#

its feasable

fathom cave
#

Unless if they get the role they can request they're own channel

south swallow
#

but i dont know how discord user will react to paid channels, i mean will they be able to talk with anyone since they are on their own in the channel?

#

how would you go about this?

fathom cave
#

It's used for personal advertising and posting update content for they're game. In this case an rsps.

#

RuneScape Private Servers.

#

So they earn points, with those points they buy the role, then request they're own channel

quartz kindle
#

their*

fathom cave
#

Lmao ^^^^

quartz kindle
#

if its a public bot listed on the website, you have to go to their support server

#

if its an open source bot, you have to host it and configure it yourself

#

we can help with coding and setting up hosting and shit, but we dont really help setting up public bots, they have their own support severs for that

plain comet
#

I need some help, when i press authorise it does nothing and it won't let me invite the bot to anything. i have 2 factor auth so idk

earnest phoenix
#

because you didnt select a server

plain comet
#

i have no option to

earnest phoenix
#

zoom out because your resolution is too low

plain comet
#

wow

#

i'm an idiot

#

thanks ahah

#

wow

earnest phoenix
#

dw

#

np lol

cunning tinsel
#

can someone help me with this?

amber fractal
#

With.... What?

mossy vine
#

2 6️⃣ reactions

sudden geyser
#

it's probably a custom emoji

cunning tinsel
#

yes, and that 6 is a reaction for roles

#

nope

sudden geyser
#

can you confirm?

cunning tinsel
#

: six : , not : six tilde:

#

:six~1: not this, so they're the same (?)

sudden geyser
#

ChillFish πŸ‘€

modest maple
#

dw about it

#

i needed to copy a FileID for Gdrive

#

its mostly development

sudden geyser
#

:six: and :six~1: are not the same. :name-number: is added when an emoji has the same name to my knowledge in the picker

#

unless you mean something else

cunning tinsel
#

yes, i know they're not the same

amber fractal
#

Mobile is having a stupid issue, when I click on one with the same name as another, but dont have nitro, it still appends the number :Thonk-1:

#

Like that

cunning tinsel
#

i'm telling you that in that message they're : six : and : six :

amber fractal
#

Doubt

cunning tinsel
#

not : six : and : six ~ 1 : so in theory they're the same

vital lark
#

6⃣

cunning tinsel
#

?

hollow granite
#

does the bot's detailed description on the website not allow script?

sudden geyser
#

if it's js, that's only for certified devs

hollow granite
#

oh, that makes sense

late hill
#

@cunning tinsel it does that for your emotes that have the same name, so you could tell which one it is

#

It doesn't do that for emotes from different users

#

As there's no reason for that

cunning tinsel
#

solved, i'm removing all 2k reactions and using just : six :

late hill
#

What even was the issue

cunning tinsel
#

the 2k one use the unicode one, the one that i was trying to use was : 6 :

knotty steeple
#

hi help

#

TypeError: cmds.map is not a function

mossy vine
#

what is cmds

knotty steeple
#
const cmds = boatboye.commands.filter(f => f.config.owner !== true)
cmds.map(c => `\`${c.help.usage}\` - ${c.help.desc}`).join("\n")```
#

and i have ```js
/**

  • A very cool extended Map class!!

  • @extends Map
    */
    class FancyMap extends Map {
    constructor() {
    super()
    }

    filter(fn, thisArg) {
    if (thisArg) fn = fn.bind(thisArg);
    const results = new Map();
    for (const [key, val] of this) {
    if (fn(val, key, this)) results.set(key, val);
    }
    return results;

    }

    map(fn, thisArg) {
    if (thisArg) fn = fn.bind(thisArg);
    const arr = new Array(this.size);
    let i = 0;
    for (const [key, val] of this) arr[i++] = fn(val, key, this);
    return arr;
    }
    }

module.exports = FancyMap;

mossy vine
#

Map doesnt have a map function

knotty steeple
#

thats why

#

i extended it

#

cyber pls

mossy vine
#

filter returns a map

#

not your extended map

knotty steeple
#

this is what happens when i copy paste

#

ok how do i make it do that in the

#

class

mossy vine
#
- const results = new Map()
+ const results = new FancyMap()```
#

i think

knotty steeple
#

so that would work

mossy vine
#

i think

knotty steeple
#

it comes up

#

yea it works

#

thank cyber

mossy vine
#

wait it does

#

lmao

#

i was 99% sure that wouldnt work

late hill
#

Works but doesn't make sense?

knotty steeple
mossy vine
#

it does when your brain is js

late hill
#

Just return this?

mossy vine
#

no

#

results is different

late hill
#

oh

knotty steeple
#

it doesnt make sense because ur using the class in what makes up the class

late hill
#

I mean if you never use the key value

#

Just returning an array would be enough

#

That's what the filter method in a regular Map does I think anyway

quartz kindle
#

well, if you're gonna extend it like that, its always better to return itself so you can chain it

#

and yeah, you can call classes from within themselves, the same way you can do recursive functions

distant plank
#

I don't know why this code doesn't work for me, it orders users in a messy way, I want to order them by xp, can you help me? :c

xp.query('SELECT id, xp, level FROM xplevel ORDER BY xp DESC', (err, rows) => {
         if (err) {
             throw err;
         }

         const embed = new Discord.RichEmbed()
             .setColor('#800080')
             .setTitle('Tabla de primeras posiciones')
             .setFooter('Ordenado por xp');

         let order = 0;
         for(let i = 0; i < 10; i++) {
             if(i > rows.length - 1) {
                 break;
             }
             
             if (message.guild.members.get(rows[i].id)) {
                 const user = message.guild.members.get(rows[i].id).user;
                 if(!user.bot) {
                     embed.addField(`${numbers[order]} ${user.username}`, `${rows[i].xp}xp - lvl ${rows[i].level}`)
                     order++;
                 }
             }
         }
         
         message.channel.send(embed);
     });
quartz kindle
#

what is xp defined as? INT or VARCHAR?

#

or something else?

distant plank
#

@quartz kindle varchar

#

all

quartz kindle
#

then it orders alphabetically not numerically

distant plank
#

oh

#

i'm stupid xD

quartz kindle
#

if your database supports it, you can use ORDER BY cast() or ORDER BY convert()

#

try googling those functions

distant plank
#

@quartz kindle I already changed it to type int, thanks!

quartz kindle
#

πŸ‘

earnest phoenix
#

client.channels.map(c => {if(c.type =="voice" && c.voiceConnections == true){return console.log(c.name)}})

I was asked to make a bot music for a "radio" system and the person wants it to indicate the name of the channels that were with the bot when it restarted
How can i make this?

#

uh

#

what

#

client.channels.map(c => {if(c.type =="voice"){return console.log(c.name)}})

This return all of voice channels but it should only give the names of the channels in which it is connected

#

keep track of the channels you're connected to manually

#

or even better, keep track of the VoiceConnection objects manually

quartz kindle
earnest phoenix
#

oh that's a thing in d.js

#

So I'm trying to evaluate this script but it just outputs false I can't figure out what's wrong with it.

client.guilds.map(g=>g.name + ` with ` + g.members.size + ` members, owned by ` + g.owner.user.tag).join('\n \n')
quartz kindle
#

are you sure the problem is there?

earnest phoenix
#

OH yes ty

quartz kindle
#

@earnest phoenix could be guild owner not cached, but that should throw an error

#

try without the guild owner to see if it works

earnest phoenix
#

Okay

quartz kindle
#

also, to get a more accurate number of members, use g.memberCount

earnest phoenix
#

Okay

quartz kindle
#

members.size will return only cached members

earnest phoenix
#

Okay, hold on

#

Try to send this in your channel

#
client.channels.map(c => {if(c.type =="voice" && client.VoiceConnection.connection == true){return console.log(c.name)}})```

TypeError: Cannot read property 'connection' of undefined
#

"TypeError: Cannot read property 'connection' of undefined"

vital lark
#

Client#VoiceConnection doesn't exist

quartz kindle
#

what are you trying to do lol

earnest phoenix
#

Wait i open a translator x)

quartz kindle
#

also @earnest phoenix it works for me, so there might be something wrong with you eval command

earnest phoenix
#

@vital lark yup this is voiceConnection i think

#

Maybe, but you just saw it working. I'm gonna try some more evals

vital lark
#

voiceConnection doesn't exist in the Client class

#

maybe check the docs

earnest phoenix
#

Oh this is

#

client.guild.voiceConnection

#

In the doc

#

I try it x)

quartz kindle
#

it works here (0 members and null guild owner because i dont cache them)

earnest phoenix
#

Weird

#

Thanks anyways

quartz kindle
#

check if the result is not too big

#

maybe you're hitting the character limit

vital lark
#

it would result in a error instead of false tho? MegaThonk

#

if it hit the character limit

quartz kindle
#

yeah but he could be handling it and turning it into false

#

and forgetting about it

#

lul

earnest phoenix
#
client.channels.map(c => {if(c.type =="voice" && c.guild.voiceConnection.connection == true){return console.log(c.name)}})```
`TypeError: Cannot read property 'connection' of null` :/
quartz kindle
#

what are you trying to do wtf

vital lark
#

^

distant plank
#

because sometimes it detects that "type" is greater than "bank" being that it is not so?

let type = args[0];
let bank = rows[0].bank; //bd mysql

if(Number(type) > Number(bank)){
            const embed = new Discord.RichEmbed()
            .setAuthor(`Retiro`, message.author.avatarURL)
            .setDescription(`Al parecer quieres retirar dinero que no tienes :|`)
            .setColor("RED");
          message.channel.send(embed);
        }

quartz kindle
#

console.log them both

earnest phoenix
#

I was asked to list the channels to which the bot was connected when broadcasting a radio

quartz kindle
earnest phoenix
#

c.connection?

distant plank
#

@quartz kindle in another command the same thing happens, in the same embed it comes out "you only have $56 and you need $30", :c

#

And it detects it as 56 is less than 30

#

The sign is not included in "bag"

quartz kindle
#

console.log them both

earnest phoenix
#

Is it just me or when I try fetching a message by Id and edit it to a new embed message, the embed will be gone after some time?

#

someone is probably suppressing the embed (clicking on the little x next to it)

slender thistle
#

I thought suppressing bot embeds went to shit recently

glacial mango
#

Can someone help me with a webhook which sends a message to a channel when someone voted for my bot?

modest maple
#

They break alot

glacial mango
#

wdym

modest maple
#

Huh

#

Oh

#

Ignore me

#

My message didn't send

#

Dw

rugged minnow
#

[Discord.js]
i tried to use message.client.guilds.size to get the amount of servers where my bot is in, it gives 1 when it should give 3/4

sudden geyser
#

maybe your bot is in one server

rugged minnow
#

nope, the bot is in 4/5 servers

green kestrel
#

shouldnt it be guilds.length?

rugged minnow
#

let me try

green kestrel
#

btw that was an uneducated guess, ive not used d.js but i have done a fair bit of js

#

and most arrays and lists seem to have a length property

rugged minnow
#

nope, undefined

green kestrel
#

ok, worth a try lol

rugged minnow
#

it's size

green kestrel
#

are you sharding your bot across 4 or 5 shards for some reason?

rugged minnow
#

well, i'm unsure by myself

#

nope

green kestrel
#

hmm, well, im out πŸ˜„

rugged minnow
#

i'm not using shards

#

let me try something

green kestrel
#

are you using the wrong token?

rugged minnow
#

no, i should be using the right one

#

one sec

green kestrel
#

(i have two tokens and if i use my dev token my bot has 2 guilds, if i use live it has 280)

sudden geyser
#

client.guilds is a map, so it's size and not length.
Try logging message.client.guilds to the console and see what you get

rugged minnow
#

i'm using 2 bots, one for development and the other one for the stable, soon deprecated, but i implemented the DBL api in the dev one

#

hm, looks like i'll have to implement the dbl api in the old one

green kestrel
#

hmm. i just had a crazy idea.

#

its probably completely wrong.

#

but what if, .size was a writeable property, and somewhere you did a guilds.size = 2 rather than == 2...

rugged minnow
#

nope, first time using the guilds.size

green kestrel
#

i doubt its writeable by you anyway

rugged minnow
#

yep

#

alright i'll spend my next 50 minutes of my life trying to figure out how to fix this, brb

sudden geyser
#

You can't write to it.

rugged minnow
#

alright so, little update

#

the bot counts the servers

#

buuut, DBL's card stays on 1

earnest phoenix
#

it takes a while to update on dbl

#

that is, if you made an api request to update it lol

rugged minnow
#

if you made an api request to update it lol

nope, i just added

const client = new Discord.Client();
const dbl = new DBL(process.env.BOTGG, { webhookPort: 5000, webhookAuth: 'password' });
dbl.webhook.on('ready', hook => {
  console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on('vote', vote => {
  console.log(`User with ID ${vote.user} just voted!`);
});```

and the vote thing doesn't even work
earnest phoenix
#

uh

#

what

#

weren't you just talking about the server count?

rugged minnow
#

yep

#

i just said that i just added this, nothing else, someone said that i have to manually update the counter

earnest phoenix
#

uh

#

do you know that webhooks are completely irrelevant to the server count

rugged minnow
#

never worked with anything else other than discord.js

#

i barely know what i'm doing πŸ˜‚

earnest phoenix
#

read the docs πŸ‘

modest maple
#

Might help if you actually read the docs then

#

Damn it cry beat me to it

rugged minnow
#

already reading the docs

#
client.on('ready', () => {
    setInterval(() => {
        dbl.postStats(client.guilds.size);
    }, 1800000);
    console.log("Stats Updated on top.gg")
});```
this should be ok, right?
#

but now i'm thinking about something...
since i'm using glitch.org, every change i make restarts completely the bot

earnest phoenix
#

rent a proper vps then

rugged minnow
#

i already set up a throttle, but i'm afraid that i might accidentally request too many times to upload the stats in a small amount of time

#

@earnest phoenix can't afford a vps at the moment

#

i don't have any kind of credit card/debt card

#

yet

blissful scaffold
#

Get a raspberry pi or something similar and self host it on that

rugged minnow
#

i give up, i'll see what i can do

quartz kindle
#

renting a vps wont magically fix his issue tho lul

blissful scaffold
#

if you don't have the money to rent/buy hosting then you will have to accept the crappy service that you get on free hosts

rugged minnow
#

@quartz kindle i was thinking about the same thing

#

wait, can i request an update every 5 minutes?

quartz kindle
#

well, yeah

#

your setInterval wont fire immediately, the first call is always after the timeout

#

but the dbl module has an internal interval that also sends updates

#

so you'd need to disable that

#

or drop the package and do your own request

#

its not hard

rugged minnow
#

i'm trying to do this because the image won't update, it says that my bot is only in one server

#

and the image doesn't properly update

#

the bot-displayed image shows 3 upvotes, but when i open the original image it shows 4 upvotes

quartz kindle
#

upvotes are inconsistent

#

dont worry about them

rugged minnow
#

what about the server count?

quartz kindle
#

server count should update right away, but your code doesnt do that

#

setInterval will only fire after one full interval

rugged minnow
#

(i removed the setInterval)

quartz kindle
#

dm me your bot page

rugged minnow
#

alright

earnest phoenix
#

c# process effectively communicating with minecraft

#

this project is a mess of languages lol

#

c# typescript and java

quartz kindle
#

now make discord plays minecraft

earnest phoenix
#

good idea

quartz kindle
#

stream a minecraft game controlled by bot commands

loud salmon
#

ono

vital lark
#

oh yes

mossy vine
#

or with twitch

grizzled raven
#

hey uh

#

how fast does editing a message have to be to be considered api abuse?

slender thistle
#

The ratelimit is 5/5s by default

grizzled raven
#

oh ok

fallen arch
#

i need help

slender thistle
#

Get straight to the question instead of saying "I need help"

fallen arch
#

oh okay

#

i keep getting this error
UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'pollchannel' of undefined
i know why its giving this error, because the guild did not set any channels
thats why i want to return message saying please set the channel

#

Code:

#

i did run check but its not working

slender thistle
fallen arch
#

i did

slender thistle
#

Or literally a simple try-catch

fallen arch
#

not returning message for some reason

#

okay wait

slender thistle
#

Yup, I see the if statement now

fallen arch
#

so?

#

i dont know why its not returning the message

slender thistle
#

Huh

fallen arch
#

?

vital lark
#

maybe pollchannel doesn't exist in the object

#

console log the object

fallen arch
#

okay

#

nothing

#

my bot can set the poll channel but if the poll channel is not set then how do i return a message saying its not set

#

like when you use the poll command if its not set then return message

#

i check if the channel was set with if statement and its not working

grizzled raven
#

if (!pollchannel)

glacial mango
#

When I run this script:

const DBL = require('dblapi.js');
const dbl = new DBL(myDBLToken, { webhookPort: 5000, webhookAuth: 'password' });
dbl.webhook.on('ready', hook => {
  console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on('vote', vote => {
  console.log(`User with ID ${vote.user} just voted!`);
});

I get this error:
ReferenceError: hook is not defined

#

Could someone help?

sudden geyser
#

did you make sure the file was saved

#

or are you sure the error was thrown in that codeblock

tight mountain
#

Sometimes my bot randomly shuts down with the error message.guild.joinedAt can't read the property of 'null'

sudden geyser
#

are you sure the command was used in a guild

tight mountain
#

Yes. It in in my info command and usually works. It just randomly shuts down with that error.

earnest phoenix
#

pls

#

help

#

pls

#

provide a valid token hmmEz

#

thx

#

How to make the bot write to ctx.message.author ?

sudden geyser
#

.send

earnest phoenix
#

thx

vague kite
#

I'm kinda confused I'm trying to reward people for voting but I'm not sure how to create the webhook that DBL connects to

loud salmon
#

you need to make your own webserver in your own language and either host it alongside your bot or in the same application @vague kite

#

for example in java my code looks something like this

bot.start() // do shit here
webserver.start() // port, url to listen to, endpoint, etc
vague kite
#

Okay Thanks will give that a go

distant plank
#

I have an economy leaderboard in my bot, in my MySQL database I have the "bag" and "bank" rows, in the command you can see the first 10 with money in the bank or the first 10 with money in the bag, but how can I see those who have more money in total adding bag + bank?

xp.query('SELECT id, xp, level FROM xplevel ORDER BY xp DESC', (err, rows) => {
         if (err) {
             throw err;
         }

         const embed = new Discord.RichEmbed()
             .setColor('#800080')
             .setTitle('Tabla de primeras posiciones')
             .setFooter('Ordenado por xp');

         let order = 0;
         for(let i = 0; i < 10; i++) {
             if(i > rows.length - 1) {
                 break;
             }
             
             if (message.guild.members.get(rows[i].id)) {
                 const user = message.guild.members.get(rows[i].id).user;
                 if(!user.bot) {
                     embed.addField(`${numbers[order]} ${user.username}`, `${rows[i].xp}xp - lvl ${rows[i].level}`)
                     order++;
                 }
             }
         }
         
         message.channel.send(embed);
     });
earnest phoenix
#

short PSA: webhooks are basically reverse api requests, instead of you making requests to a website, the website makes requests to you instead, which is why you need to expose a port

late hill
#

Haven't used sql in a while but I believe you can ORDER BY x + y @distant plank

#

You could also add the sum as a new collumn in your query and then order by whatever you named that

distant plank
#

@late hill I will try :)

lavish shuttle
#

Hey, I'm trying to make a regex that converts every ES6 import to CommonJS require()

#

But it messes up the code

earnest phoenix
#

by the time you spend writing the regex to do it for you, you could've ported it all manually

knotty steeple
#

are you that lazy

lavish shuttle
#

Oh yeah, I would love copy pasting a bunch of const for over 300 files

#

That is sure a fun thing

earnest phoenix
#

by the time you spend writing the regex to do it for you, you could've ported it all manually

lavish shuttle
#

Eh, not necessarily

knotty steeple
#

why are you trying to port it anyway :)

lavish shuttle
#

Because I made a dumb mistake and hit convert to ES6 module in VSCode

#

which now means my bot doesn't work

knotty steeple
#

then hit convert to commonjs

#

big brain

lavish shuttle
#

make that button then

#

big brain

knotty steeple
#

have you ever heard of a

#

you know

#

a nice little keyboard shortcut

#

its called ctrl + z

#

it makes you undo most actions

lavish shuttle
#

Yes, I know that exists

#

Problem is I did that a while ago

#

for all my files

#

and I expected it to work on node.js

knotty steeple
#

cant help u

#

convert it

#

urself

#

Β―_(ツ)_/Β―

#

ur problem lmao

lavish shuttle
#

...bro, if I'm asking for help, you don't need to say convert it yourself

knotty steeple
#

what else do i say thats all you have to fucking do

#

???

#

search for a website then

#

????

#

what do u want

lavish shuttle
#

I need help with the regex I'd like to build

knotty steeple
#

yea no

#

i dont even know regex

lavish shuttle
#

Then clearly, I wasn't talking to you specifically

knotty steeple
#

and the time it takes you to wait for someone who does u can just do it urself

#

Β―_(ツ)_/Β―

modest maple
#

calm it down xD

lavish shuttle
#

Now, I'm just going to respond to cry

#

by the time you spend writing the regex to do it for you, you could've ported it all manually
Not necessarily, its a lot of work and time I'd rather be spending doing something else

#

Besides, it might come handy in the future

knotty steeple
#

bro how hard is it to write const package = require("package")

distant plank
#

@late hill is working, thanks

knotty steeple
#

babel might be able to help

lavish shuttle
#

I've been trying to use babel

#

but my bot didn't work at all

knotty steeple
#

so you have literally only 2 options

#

try to waste time on some regex or fucking

#

do the thing urself

lavish shuttle
#

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

#

I already picked the option #1

#

and that's what I'm asking here: for help with it

knotty steeple
#

ok

#

gonna take you time to get that help is all im trying to say

lavish shuttle
#

Thanks for wasting my time then

knotty steeple
#

atleast i wasted it with you

earnest phoenix
#

@lavish shuttle

#

Regex?

lavish shuttle
#

Yeah

knotty steeple
#

there is ur help

#

my guy's name is literally regex + r

lavish shuttle
#

I messed up and converted my bot to ES6 without realizing that node.js didn't support it and that Babel wouldn't be able to compile it with the code working

#

and I can't undo it all, so I wanted to build a regex to undo it for me

modest maple
#

calm down dudes

earnest phoenix
#

Add a .babelrc to your repo

modest maple
#

no point aruging

lavish shuttle
#

It'd be much quicker to make the regex to convert import to require

#

I already done so. Let me send it to you

earnest phoenix
#

Paste snippet please

lavish shuttle
#

Alright

earnest phoenix
#

Or link to github

#

I'm on my phone

lavish shuttle
#
    "presets": [
          [
            "env",
            {
                  "targets": {
                    "node": "current"
                  }
            }
          ]
    ],
    "plugins": ["@babel/plugin-syntax-dynamic-import", "add-module-exports", "transform-remove-strict-mode"]
}```
knotty steeple
#

github is too much

sudden geyser
#

You could manually type it (which is probably more efficient), but I think the problem with your script is you don't really handle anything that's a keyword. You only handle anything within braces and * as. You could add a third "OR" divider and make it catch all until it's hit a space.

knotty steeple
#

just paste or hastebin mmLol

earnest phoenix
#

That babelrc doesn't look correct

#

At initial glance

#

Okay hold on I'm going to my computer

#

You made me get out of bed

lavish shuttle
#

Sorry Regexr

earnest phoenix
#

if you don't have anything helpful to say don't say it at all

#

Who are you talking to

lavish shuttle
#

@sudden geyser Hm, I'll try that. Thanks for the tip

earnest phoenix
#

someone who deleted their message

sudden geyser
#

np, also can you send the regex

earnest phoenix
#

If you want to send me the regex that you're using, I'll help you correct it. But I don't think that correcting the regex is actually the correct solution here. What you should do is configure your babyl RC properly

lavish shuttle
#

import\s*(?:\{?\s*(.*)\s*\}|\*\s*as\s*(.*))\s*from\s*([^;]*);*

#

Here's the regex

#

But lets try to configure babel correctly

knotty steeple
#

@earnest phoenix yea thats why i deleted it not supposed to be a message you think about :)

#

pls stop saying babyl its babel xd

earnest phoenix
#

I dictated it

#

i wasn't just talking about the message, i was talking about your messages, but i'm not going to argue

knotty steeple
#

so u just said it out and spelled it so

#

lul ok

#

yea ill leave now i have no reason being here currently

earnest phoenix
#

allllll right

#

lets gets the babelrc figured out

lavish shuttle
#

Here, I'll send you my bot code too

sudden geyser
#

I added another "OR" and matched everything: import\s*(?:\{?\s*(.*)\s*\}|\w+|\*\s*as\s*(.*))\s*from\s*([^;]*);*

The groups you'll be matching and such are really up to you, assuming this is all you were looking for.

earnest phoenix
#

I don't want it

knotty steeple
#

actually do any of you have boilerplates

lavish shuttle
#

ok

knotty steeple
#

also you should make backups

#

not just for this but like incase ur pc dies or something

earnest phoenix
#

this is my babelrc

#
{
  "presets": [
    ["@babel/preset-env", { "targets": { "node": "10" } }],
    "@babel/preset-react"
  ],
  "plugins": [
    "@babel/plugin-syntax-dynamic-import",
    "@babel/plugin-transform-modules-commonjs",
    "@babel/plugin-proposal-export-default-from",
    "@babel/plugin-proposal-export-namespace-from",
    ["@babel/plugin-proposal-decorators", { "legacy": true }],
    ["@babel/plugin-proposal-class-properties", { "loose": true }]
  ],
  "parserOpts": {
    "ecmaFeatures": {
      "legacyDecorators": true
    }
  }
}
#

I recommend using "@babel/preset-env"

#

as well as most of those plugins

#

the decorator syntax is super optional

knotty steeple
#

whats that

lavish shuttle
earnest phoenix
#

specifically

lavish shuttle
#

I'll check out your babel config

earnest phoenix
#
    "@babel/plugin-syntax-dynamic-import",
    "@babel/plugin-transform-modules-commonjs",
    "@babel/plugin-proposal-export-default-from",
    "@babel/plugin-proposal-export-namespace-from",
    ["@babel/plugin-proposal-class-properties", { "loose": true }]
#

those plugins are helpful

knotty steeple
#

ew akairo

#

atleast its not commando

sudden geyser
#

klasa is bae

earnest phoenix
#

whats wrong with commando?

knotty steeple
#

i agree

lavish shuttle
#

What's wrong with akairo?

knotty steeple
#

p e r s o n a l o p i n i o n

#

i dont use frameworks in general tho i make my own stuff

sudden geyser
#

There's nothing wrong with them package wise; they get the job done. It's just a preference

knotty steeple
#

^

earnest phoenix
#

making your own frameworks is a great way to innovate new and interesting wheels

knotty steeple
#

my layout i guess

#

is based on klasa

#

"framework"

#

command

#

file

#

nah its based on komada

sudden geyser
#

Klasa just has everything I need & advanced even though it's large.

vital lark
#

I have my own framework uwu

knotty steeple
#
exports.run = (boatboye, msg, args, prefix) => {
    if bruh is bruh then bruh
}

exports.config = {
    aliases: [],
    ownerOnly: yas
}

exports.help = {
    name: "e",
    desc: "eeks description",
    usage: "how to use!!!"
}```
#

ℒ️

vital lark
#

I use es6 classes

knotty steeple
#

i dont

lavish shuttle
knotty steeple
#

why

mossy vine
#

my framework is if return

sudden geyser
#

Classes are great

earnest phoenix
#

ugh

#

this is a vim vs emacs conversation

knotty steeple
#

i dont use classes much

#

i use neither also

#

vscode >>

#

but i did used to use neovim

mossy vine
#

vim >

earnest phoenix
#

you seem to misunderstand the statement

#

talking about vim vs emacs vs vscode vs sublime vs whatever is pointless, meaningless garbage

knotty steeple
#

no i get it

earnest phoenix
#

it has the smackings of substance without any substance

mossy vine
#

not very pointless

knotty steeple
#

can i show some bad code

mossy vine
#

knowing the advantages and disadvantages of something lets you decide more easily

sudden geyser
#

Regexr it's more just preferences than calling the other bad

knotty steeple
#

no

#

just go on my github profile

earnest phoenix
#

people who ask you to look at their github should be called github rappers

knotty steeple
#

thonk

sudden geyser
#

actually it's just unsafe but not complete sql injection

knotty steeple
#

year ago me

#

what would be better

earnest phoenix
#

lol

#

yeah

#

that's a straight sqli right there

sudden geyser
#

You can use variables or just placements like SELECT * FROM store WHERE storeID = ? and have the 2nd arg be an array or object by replacing ? for $variableName

lavish shuttle
#

@earnest phoenix hey, do any of these modules remove the .default stuff from the end or atleast make it work without .default?

knotty steeple
#

you shouldve seen the code for my first bot then

earnest phoenix
#

@lavish shuttle when using es6, you import default by stating import Thing from 'file'

knotty steeple
#

trust me it was bad

#

slots was a complete mess

earnest phoenix
#

I hate doing security research, because inevitably you just end up being a QA analyst for someone elses shitty code

quartz kindle
#

idk why node has everything from ES6 except imports

#

its under an experimental flag lul

earnest phoenix
#

@lavish shuttle if you want to require() a file, and that file does export default, then yes, you need to reference it by require('thing').default

sudden geyser
#

import() returns a promise kannaSpook

#

how will that work

earnest phoenix
#

but it makes more sense to use import Thing from 'file'

#

@sudden geyser what are you talking about?

#

i

#

need

#

weed

#

bee

#

are

#

bee

knotty steeple
earnest phoenix
#

haha

#

I have one of those

#

a slot bot

sudden geyser
earnest phoenix
#

@sudden geyser yes, import can be used in that way, but it can also be used in es6 basically as a require statement

#

a little sample code from my actual job:

#
import { readDashboardActivityLogs } from '../../actions'
import { dashboardActivityLogsSelector } from '../../selectors'
import { ActivityPropType } from './shared/proptypes'

import { t } from '../../lib/i18n'

import './ActivityHistory.scss'

export const ROOT_CLASS = 'client-activity-history'
export const LOADER_CLASS = `${ROOT_CLASS}-loader`
export const NO_DATA_CLASS = `${ROOT_CLASS}-no-data`
export const ACTIVITY_HISTORY_UL_CLASS = `${ROOT_CLASS}-activity-node-ul`
sudden geyser
#

I'll try it out

quartz kindle
#

once you go node, you hate going back to web

knotty steeple
#

i never go to web

quartz kindle
#

i do, but i hate every minute of it

knotty steeple
#

i also remember trying to make a profile command

lavish shuttle
#

@earnest phoenix So the bot still doesn't want to do anything. I don't know how to debug it either

#

Oh, nvm, I got an error this time

#

Killed
npm ERR! code ELIFECYCLE
npm ERR! errno 137
npm ERR! yamamura-discord-bot@0.0.1 server:prod: `node ./dist/yamamura.js`
npm ERR! Exit status 137
npm ERR!
npm ERR! Failed at the yamamura-discord-bot@0.0.1 server:prod script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/pi/.npm/_logs/2019-11-26T20_34_45_191Z-debug.log
ERROR: "server:prod" exited with 137.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! yamamura-discord-bot@0.0.1 prod: `NODE_ENV=production npm-run-all clean build server:prod`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the yamamura-discord-bot@0.0.1 prod script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/pi/.npm/_logs/2019-11-26T20_34_45_590Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! yamamura-discord-bot@0.0.1 start: `npm run prod`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the yamamura-discord-bot@0.0.1 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/pi/.npm/_logs/2019-11-26T20_34_46_378Z-debug.log```
#

just a simple "Killed"

#

I also get this:

< Debugger listening on (Insert Debugging link here)
< For help, see: https://nodejs.org/en/docs/inspector
< Debugger attached.
Break on start in file:///home/pi/yamamura-discord-bot/dist/yamamura.js:1
> 1 (function (exports, require, module, __filename, __dirname) { require("cache-require-paths");
  2
  3 require("./utils/extraFunctions.js");```
#

Oh whoops, I forgot to git pull

#

yep, nothing is happening

#

The bot doesn't even go online

knotty steeple
#

pfft

#

just write code in es6

lavish shuttle
#

........

#

I wrote my code in ES6

#

and I'm trying to use Babel

#

to allow NodeJS to run in it

knotty steeple
#

everything

#

?

lavish shuttle
#

Yes everything

vital lark
#

Babel big succ

knotty steeple
#

ok then

lavish shuttle
#

Babel big succ

#

What would you recommend then

vital lark
#

TS but that's just me

knotty steeple
#

sarcasmℒ️

#

or true

vital lark
#

what

knotty steeple
#

is babel bad

vital lark
#

to me yes

#

since ts does it better imo

paper flame
#

anyone know how to set up a connections authorization for a bot?

#

I'm like 2/3 of the way there but can't figure out the purpose of the redirect URL and how my bot is supposed to get the code out of it

earnest phoenix
#

uh you mean oauth?

#

yeah

#

ok

#

the redirect uri is where your user gets redirected after they authorize your app

#

the authorization process adds a ?code= url parameter to your redirect uri

#

so when your user gets redirected to your website

#

you can extract that code

#

exchange it for an access token and boom

paper flame
#

yes that's what I was referring to

#

I don't have a website for my bot, so would I have to create one in order to get the oauth code?

earnest phoenix
#

yes

paper flame
#

why is having a website a necessity to extracting the code?

earnest phoenix
#

because that's how oauth2 works

paper flame
#

sorry, I'm not entirely familiar with how oauth works

#

thanks for the help

#

just trying to find the easiest way

earnest phoenix
#

you can't utilise oauth2 features if you don't have a website

#

(inviting a bot into a server is the only exception)

paper flame
#

my bot is in a bunch of servers so could you elaborate on that exception?

earnest phoenix
#

the link where users invite your bot to a server

#

is a part of oauth2

#

it's the only case where you don't need a website to complete an action (because it doesn't need a redirect uri)

paper flame
#

ah okay so that's just the oauth2 authorization for server invites

#

so I can't use that for getting an individual users connections

earnest phoenix
#

nope

paper flame
#

alright thanks for your help

#

I'm not very familiar with hosting a website, but the only need I have for it is to fetch the access codes

#

So I need to figure out something very simple

#

but when someone visits I can somehow check the URL they are using and extract the code from that?

earnest phoenix
#

uh what

#

can you elaborate your question

paper flame
#

I don't have a website for my bot, so I'd need to set something up in order to get the auth codes when users authorize the bot to see their "connections"

modest maple
#

seems a little more complicated than it needs tobe

earnest phoenix
#

you need a website

modest maple
#

^

earnest phoenix
#

there's no other way to go around it

modest maple
#

also oath2 has alot of stuff you need to set up with it

paper flame
#

yeah I understand that, now I'm trying to think of the easiest way to get a website set up since my only purpose for it is to get the code

modest maple
#

why do you need the codes anyway

earnest phoenix
#

a simple api server would be enough

modest maple
#

^

#

like from what i can tell you dont need to get permission from the user to access there profile and personal info etc...

#

or grant yourself access to other files

earnest phoenix
#

they want to get user connections

modest maple
#

if your hosting it yourself

earnest phoenix
#

user connections are accessible through a user token and through oauth only

paper flame
#

yeah

modest maple
#

but why do you need connections?

paper flame
#

to get the users steam account so I can have my bot integrated with their steam

modest maple
#

wouldnt it be easier just to have a opt-in feature

#

e.g GameStats takes your steam profile ID

#

and then you just need to make your account profile public

#

but it works just as well

earnest phoenix
#

someone can fake being someone else by doing that

paper flame
#

yeah that would be easier but it also allows someone to put another person's ID in

modest maple
#

seems a bit overkill if you ask me

paper flame
#

yeah that's making me consider if it's worth it

#

gona look into setting up a simple API server first like cry suggested

modest maple
#

cuz another thing to also make note of if you do it via connections if people use a diffrent engine, program to play the game / account then it wont work

#

so in some cases allowing the user to add their own accounts makes more sense

earnest phoenix
#

@lavish shuttle don't know what to tell you

paper flame
#

what if I used oauth2 and made the users DM the bot with the code so I don't have to fetch it from a website

earnest phoenix
#

kinda seems like you don't know what you're doing with es6 tbh

#

or maybe you have too many variables changing too quickly in your env

modest maple
#

problem still stands that it will only work for steam games

#

which rules out OW, fortnite etc...

paper flame
#

this bot is specific to CSGO

#

and if they have those accounts connected to their profile then I'd be able to see those too

lavish shuttle
#

Could you check the bot code for me? Its on GitLab

earnest phoenix
#

what if I used oauth2 and made the users DM the bot with the code so I don't have to fetch it from a website
big security issue

paper flame
#

yeah that's what i was thinking

#

not sure why it would be though

earnest phoenix
#

you'd still need a website so it redirects the user to that website with the code

paper flame
#

is that so I can exchange the code immediately and invalidate it

earnest phoenix
#

pretty much, the code is there acting as a protection layer

#

you need to exchange it for an access token

#

and exchanging requires you to match the client secret

paper flame
#

but couldn't I just have the bot take the code and use it with the client secret to do the exchange

#

Not saying that's a good idea though

earnest phoenix
#

not really

#

someone else can use their code

paper flame
#

yeah

earnest phoenix
#

that process is so quick and automatic on most websites using oauth that the user doesn't even get to see the code

paper flame
#

they do that by making the link redirect?

earnest phoenix
#

yeah

#

i'm doing that on a website i'm working on

#

basically as soon as the user hits the redirect uri the webserver attempts to grab the code from the url and just redirects the user back to the homepage

paper flame
#

cool

#

yeah I'm thinking I'll just set up a simple rest api server with flask

#

and the bot can interface with that easily

#

would that be good to do what I want?

earnest phoenix
#

don't work with python so i don't know what you would use, but yeah a simple rest server is good

paper flame
#

yeah my bot is currently in python but I guess the server wouldn't have to be since it's a separate entity

#

thanks for your help @earnest phoenix and @modest maple much appreciated

lavish shuttle
#

@earnest phoenix here's my bot's GitLab page in case you want to see what's going on

knotty steeple
#

what are some things i can add to an extended client

#

xd

modest maple
#

@paper flame you can use Django for python websites just btw

#

Altho defo better using js etc...

paper flame
#

yeah, I'm a CE major so my exposure is C/C++ Python, so I'd have to learn JS

#

Or get someone else to do it

modest maple
#

Coding a simple website isn't a massive issue

#

But you'll still need a domain

#

All I can say is oath2 can be a massive pain in some ways

earnest phoenix
#

js for apis πŸ™…

#

ridiculously slow and most people implement poor security

modest maple
#

^

#

Altho Django isn't much better

quartz kindle
#

whats wrong with js for apis?

grim aspen
#

nice to know that embeds said no

#

or are just slow af

quartz kindle
#

i already told that guy how to fix it

#

@_@

grim aspen
#

imma just do the github update later and send it to my stackoverflow answer later

earnest phoenix
quartz kindle
#

well thats benchmarking serialization, which can be offloaded to native code

#

pretty much depends on what exactly you're benchmarking