#development

1 messages Β· Page 1250 of 1

arctic cape
#

ah

#

so i have to giev or after bracket in if

#

got it thnkx

slender thistle
#

Doing 'one' || 'two' will always return one because it's not an empty string (or a falsey value)

arctic cape
#

Hmm got it

slender thistle
#

aye

arctic cape
#

no actually i didn't know permission didnt allow or

#

πŸ˜“

slender thistle
#

hasPermission('ADMINISTRATOR') || hasPermission('MANAGE_MESSAGES')

arctic cape
#

hm got that

#

can this work ? js if(2 < messagecount > 100 )return message.channel.send(`THE NO. OF MESSAGES TO BE CLEARED SHOULD BE BETWEEN 2 AND 100 !`);

slender thistle
#

messsagecount >=

#

but should work

arctic cape
#

oh sry me nub πŸ˜‚

silver lintel
#

shouldnt it be ```js
if(2 > messagecount || messagecount > 100 )

#

wait

arctic cape
#

i edited it to reverse sign idk why

silver lintel
#

can you compare two stuff like that?

arctic cape
#

thats what i wonder

slender thistle
#

Both work

#

should

arctic cape
#

nice

silver lintel
#

okk

slender thistle
#

let me open my browser

#

Oh, seems JS doesn't like that

arctic cape
#

ah

slender thistle
#

you'll have to use &&

silver lintel
#

isnt it || for that example?

slender thistle
#

2 < messagecount > 100 is supposed to say "more than 2 AND less than 100"

earnest phoenix
#

|| operator is for or but this seperates to 2 different functions to be parsed and coerced to a boolean

silver lintel
#

but if you look at the response return message.channel.send(THE NO. OF MESSAGES TO BE CLEARED SHOULD BE BETWEEN 2 AND 100 !);

arctic cape
#

it just doesnt work now i feel

slender thistle
#

between

arctic cape
#

its only taking 1st condition

#

in &&

slender thistle
#

so it must be less than 100 and more than 2

arctic cape
#
 if(2 > messagecount && messagecount > 100  )return message.channel.send(`THE NO. OF MESSAGES TO BE CLEARED SHOULD BE BETWEEN 2 AND 100 !`);```
earnest phoenix
#
if (messagecount > 100 || messagecount < 1) {
// Send the message
}```
silver lintel
#

make it or, because for that to trigger, message count has to be smaller than 2 and bigger than 100 at the same time which is impossible

slender thistle
#

Imagine not being able to apply common sense to a simple script

#

totally not me

arctic cape
#

i feel i am becoming dumb making my bot πŸ˜‚

earnest phoenix
#

Learn badics of JavaScript or the programming language before making a bot

arctic cape
#

@earnest phoenix i have been confused with operators now

earnest phoenix
#

This is the best way to learn and not run into many issues

arctic cape
#

as some things dont allow operators

#

😦

earnest phoenix
#

Everything allows operators

slender thistle
#

Volt's snippet allows the operator though

arctic cape
#

permissions dont

slender thistle
#

why permissions specifically

arctic cape
#

in the ''

earnest phoenix
#

Permissions resolvables can be an array

slender thistle
#

I gave you a snippet

arctic cape
#

hmm

slender thistle
#

hasPermission('ADMINISTRATOR') || hasPermission('MANAGE_MESSAGES')
Did this not work

arctic cape
#

no that worked

#

i was saying inside hasPermission

earnest phoenix
#

Or just array check with flags

["ADMINISTATOR", "MANAGE_MESSAGES"].some(p => <GuildMember>.hasPermission(p));```
arctic cape
#

well my issue is solved so thank you !

earnest phoenix
#

Some functions and methods do not allow arrays or multiple params, as if you tried "ADMINSTRATOR" || "MANAGE_MESSAGES"
The reason it would always apply the administrator permission check is because, || operator checks if the first given arguments exists as in it's coerced to a boolean, if not continue, but in strings, they are always true

arctic cape
#

ohk !

slender thistle
#

Are empty strings coerced to false boolean?

earnest phoenix
#

I assume they're also true

#

Lemme check

silver lintel
#
messagecollectorstuff {

}

reactioncoolectorstuff {

}
``` is there a way to make the reaction collector run only after the message collector is done?
earnest phoenix
#

Yep, empty strings with no chars is false

#

@silver lintel Collectors have an end event, after the message collector, execute the given function as a parameter

silver lintel
#

collect.on('end')?

#

that sorta thing

earnest phoenix
#
<someMessageCollector>.on("end", ...fn)```
silver lintel
#

im only diong this because i need to run an await thing

#

but it doesnt work in a collector

#
Message.channrl.awaitMessages()({

//Need await here 

}).catch (() => {});
earnest phoenix
#

hi

#

if i setup an express.js server on my computer without configuring the router port forwarding stuff it probably won't work outside of localhost right?

#
Message.channrl.awaitMessages()({

//Need await here 

}).catch (() => {});

@silver lintel channrl

#

@earnest phoenix You obviously can't read buffer of something null, or something that has no buffer

#

oh

#

Could you tell me what I need to do? So that I can start

#

This never happened to me

#
const express = require("express");
const app = express();
app.post("/dsl_webhook", (request, response) => {
    console.log(JSON.stringify(request.body));
});
const listener = app.listen(process.env.PORT, () => {
    console.log("Your app is listening on port " + listener.address().port);
});

This does literally nothing when i test the DSL webhook.... why?

#

There is no output except Your app is listening on port 347238192689234823534923748

slender thistle
#

Make sure your port is open and there's no firewall that's blocking your requests

earnest phoenix
#

The port is open

#

i'll retest with HTTPS

#

Could you tell me what I need to do? So that I can start
@earnest phoenix Try reading buffer of something with node-fetch

#

ok sir

#

I'll try

#

@slender thistle the express.js server works fine with both HTTP and HTTPS
I'll try using phin to send a POST request to https://codeco-discord-bot.code913.repl.co/dsl_webhook with some sample data

#

oh okok

#

I would have to put this on all assets?

#

.png

#

@slender thistle

const phin = require("phin");
// AFTER the express.js shit
phin({
    url: "https://codeco-discord-bot.code913.repl.co/dsl_webhook",
    method: "POST",
    data: {
        guild: 1234,
        user: 1234,
        type: "test"
    }
});
#

still no work

#

Load fonts with jimp but to get buffer from links or image file paths, use node-fetch @earnest phoenix

#

ok

slender thistle
#

which port is the express server running on

earnest phoenix
#

understood

#

process.env.PORT changes randomly every time my program is run on repl.it

slender thistle
#

Oh well, try 8080

earnest phoenix
#

ok

#

@slender thistle 8080 works

#

lemme test the webhook with :8080 in front of the domain name

slender thistle
#

No

#

You don't append any port to the domain when entering it anywhere

#

repl.it internally proxies requests sent to the repl.co URL to your webserver running on port 8080

earnest phoenix
#

ok

#

THAT BRUH MOMENT WHEN YOU REALIZE IT WORKS AND IT JUST DIDN'T LOG IT IN THE CONSOLE man i'm retarded

thin turret
earnest phoenix
#

ok so it works

#

but for some reason it logs undefined into the console

#

request.body is how you read POST request data in express.js right?

slender thistle
#

@earnest phoenix Let's not post links that have crypto miners in them btw, thanks

earnest phoenix
#

k

#

@earnest phoenix Let's not post links that have crypto miners in them btw, thanks
@slender thistle what do you think is better, getting bombarded with adverts or a cryptominer that is set to NOT take more than 5% of CPU

slender thistle
#

Adverts at least are less scummy than having your users mine shit without their consent πŸ™ƒ

earnest phoenix
#

that emoji existed and i didn't know wtf

#

@quartz kindle how would I read data from POST requests in express?

#

I have this rn:

app.post("/dsl_webhook", (request, response) => {
    console.log(request.body);
})

it logs undefined in the console when i test the DSL webhook

opal plank
#

this is what im using

earnest phoenix
#

tahpscreept

opal plank
#

GodlyScript

#

yes indeed

#

i didnt bother typing out the request types though

slender thistle
#

Yeah, I can see the anys

earnest phoenix
#

so

opal plank
#

its just a test

earnest phoenix
#

what exactly does it do

opal plank
#

mine?

earnest phoenix
#

yep

opal plank
#

evals my code remotely

earnest phoenix
#

lmfao

opal plank
#

via admin panel rather than in discord

#

Β―_(ツ)_/Β―

earnest phoenix
#

i meant what is express.js doing when it recieves a POST request to /panels

#

*receives
fuck my english

quartz kindle
#

you need to use the body-parser middleware

opal plank
earnest phoenix
opal plank
earnest phoenix
#

POGGERS i thought it is normal JS
wait you can't send JS objects directly
please ignore my dumbness

opal plank
#

cof cof stringify cof cof

#

or use a http lib that does it for u

#

laughs in axios

slender thistle
#

Can't JS objects be visualized as JSON objects though

earnest phoenix
#

@earnest phoenix

opal plank
#

im pretty sure you gotta stringify it

earnest phoenix
#

Bruv, use inspect method of util to turn your object to a string

opal plank
#

actually maybe im wrong

earnest phoenix
#

Literally

slender thistle
#

Nah, I think it should be stringified in any case

earnest phoenix
#

ok

slender thistle
#

which would make sense in any case

opal plank
#

im not sure actually now

#

cuz i know axios handles a lot of that stuff in the background

earnest phoenix
#

@earnest phoenix I literally said the images not the fonts

slender thistle
#

Giving people existential crisis since my birth

opal plank
#

no biggie

#

yo

#

shiv

earnest phoenix
slender thistle
#

No, it's stringified internally, as far as I'm aware

opal plank
#

have you seen what i did yesterday?

earnest phoenix
slender thistle
#

uhh

brisk rune
#

How to play poketwo

slender thistle
#

Let's assume I did but please explain

earnest phoenix
#

oh sorry i read wrong, my english is not so good @earnest phoenix

#

sorry

opal plank
#

read above it aswell for context

earnest phoenix
#

It's ok

opal plank
slender thistle
#

πŸ˜‚ what the fuck

opal plank
#

iim dead serious lol, i went to request them for verification status on my bot to increase its rate limits

#

just running a test to have even more reason to request it

brisk rune
#

Pls work

slender thistle
#

you doofus

opal plank
#

like

#

cmon

#

8h to join 4k streams

earnest phoenix
#

YES! IT WORKS! tada

{
  guild: '721707451375943740',
  user: '503948134439976972',
  type: 'test',
  query: '?test=data&notRandomNumber=8'
}
opal plank
#

i surely need some privileged privileges

earnest phoenix
#

wait did i just log normal JS instead of JSON into the console without it saying [object Object]
POGGERSPOGGERSPOGGERS

#

Of course, console can parse normal js objects without being stringified

#

smh

opal plank
#

console without object explorer is a sin

earnest phoenix
#

i once tried doing:

var smth = {};
console.log(smth);

and it outputted [object Object]

opal plank
#

i wonder if youtube also has verified bots

#

100% gonna pokemon the fuck out of this and get my bot verified on discord, twitch and youtube

slender thistle
#

I only have one word for you

#

baka

opal plank
#

How ironic is it for my discord bot to get verification on another platform before i get it here?

slender thistle
#

fairly ironic I'd say

opal plank
#

from the info they provided i should hear back within 2-3 days

#

meanwhile discord.....

#

well...

#

you get the idea

slender thistle
#

bloblul pretty much

opal plank
#

wtf

#

i borked grafana

earnest phoenix
#

not very experienced with web http shit
i am a down-to-earth node.js boi
so
what are headers and how do i check if the guy that sent the POST request sent the authorization header as my set password

opal plank
#

3.1050K

#

sounds good

#

@earnest phoenix theres basically 3 things in a request, headers, parameters and body

#

headers usually arent exposed, params are in the url, body is the content of the payload

earnest phoenix
#

req.headers does not exists thonkingintensifies

opal plank
#

how you even checking for req.headers?

eternal osprey
#

hey could anyone help me?
there is a !queue join (your message) command
where you can join a queue (your name will appear in the embed) with your tryped message behind your name
however, it actually deletes after someone else joins.
this is the code:

    // If queueMessageId is still 0, no queue has been created
    if (queueMessageId === 0) {
      message.channel.send('A queue does not currently exist sailor '+ "<@" + message.author.id + ">");
      // Otherwise, the queue already exists, so users can join
    } else {
      message.channel.messages.fetch(queueMessageId).then(queueMessage => {
        if (addUserToQueue(message.member.displayName, message.member.id, args)) {
          assembleQueueMessage();
          queueMessageText += ' ' + message.content.slice(Config.prefix.length).replace(/^queue *join/, '').trim()
          if (Config.useEmbeds) {
            queueMessage.edit(embedQueue.setDescription(queueMessageText));
          } else {
            queueMessage.edit(queueMessageText);
          }
        } else {
          message.channel.send(`${message.author} already entered the ship queue!`);
        }
      })
        .catch(console.error);
    }
  }```
kindred musk
#

i tried installing the server count thingy on my bot, it says this (replace 'my bot dbl client token thingy' with my actuall token thingy)

const dbl = new DBL('MY BOT DBL CLIENT TOKEN THINGY', client);
                                                                                                                                                                                   ^

ReferenceError: client is not defined
    at Object.<anonymous> (D:\Download\Memes\Batch 2\CooldownsUPDATED\index.js:5:180)
    at Module._compile (internal/modules/cjs/loader.js:1076:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
    at Module.load (internal/modules/cjs/loader.js:941:32)
    at Function.Module._load (internal/modules/cjs/loader.js:782:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
    at internal/main/run_main_module.js:17:47```
how do i fix this? thanks
umbral zealot
#

well you haven't defined any variable called client

opal plank
#

@kindred musk then you didnt define your client

umbral zealot
#

what is your bot client's variable?

opal plank
#

likely bot

#

show the top of your file @kindred musk

#

your index.js

kindred musk
#

what, this is a commision bot i got i just added the lines of code from the documentation idk node.js

opal plank
kindred musk
#

oh i see

#

what do i put there lol

opal plank
#

again

#

show the top of ur file

kindred musk
#

const bot = new Discord.Client();

#

this?

opal plank
#

then use bot instead of client

#

though if you comissioned the bot you should likely ask the person who made it to do the changes

kindred musk
#

so to change that to const bot = new Bot.Client();

opal plank
#

no

#

only on the dbl

eternal osprey
#

why is no-one helping me?

#

ffs, i was the first to ask help.

opal plank
#

cuz i havent played with music/audio or opus

eternal osprey
#

what?

opal plank
#

so i likely dont know the answer for ur question Awsome

eternal osprey
#

i am not using mussic or audio

#

it is just a queue

opal plank
#

ohi see

#

dont ask to ask

#

just ask

eternal osprey
#

everyone comes after me

#

but they always receive help first

#

no offence

#

but it is really frustating

umbral zealot
#

@earnest phoenix you would need to fetch the audit logs for that

opal plank
#

like i previously said,i thought that was an audio question

eternal osprey
#

i was talking in general

#

otherwise i wouldd ping you

opal plank
#

first off

#
 if (command === 'queue' && subcommand === 'join') {
    // If queueMessageId is still 0, no queue has been created
    if (queueMessageId === 0) {
      message.channel.send('A queue does not currently exist sailor '+ "<@" + message.author.id + ">");
      // Otherwise, the queue already exists, so users can join
    } else {
      message.channel.messages.fetch(queueMessageId).then(queueMessage => {
        if (addUserToQueue(message.member.displayName, message.member.id, args)) {
          assembleQueueMessage();
          queueMessageText += ' ' + message.content.slice(Config.prefix.length).replace(/^queue *join/, '').trim()
          if (Config.useEmbeds) {
            queueMessage.edit(embedQueue.setDescription(queueMessageText));
          } else {
            queueMessage.edit(queueMessageText);
          }
        } else {
          message.channel.send(`${message.author} already entered the ship queue!`);
        }
      })
        .catch(console.error);
    }
  }```
#

now its redable

umbral zealot
opal plank
#

whats the issue awsome/

eternal osprey
#

look

opal plank
#

lookinh

umbral zealot
#

attempts to magically guess what the original question meant

eternal osprey
#

if someone uses !queue join test test

#

they will join the queue

opal plank
#

okay

eternal osprey
#

with test test after their name

#

so as you see i used !queue join hello

#

it worked

#

but as soon as someone else joins with another message

#

mine gets deleted

opal plank
#

the message or the queue?

eternal osprey
#

as you see my friend joined iwht the message !test test

#

the message

#

behind the names

umbral zealot
#

well nothing here is deleting messages so it must be part of some other code.

eternal osprey
#

should i pastebin?

opal plank
#

i guess that'd helpa bit

umbral zealot
opal plank
eternal osprey
umbral zealot
#

there's nothing about message deletion here either

#

also doing !queue test test shouldn't be triggering anything except line 350.

opal plank
#

indeed theres no deletion

eternal osprey
#

hmm what is the problem then?

opal plank
#

you sure there isnt something else on another file doing the deletions?

umbral zealot
#

or another process. or another bot.

opal plank
#

^^

#

though this looks like his index

eternal osprey
#

it is my index

opal plank
#

why not handler?

umbral zealot
#

well, something else than this particular bot's code is deleting messages.

#

because this isn't it.

eternal osprey
#

maybe because of this line:

#
if (userAdded) {
            assembleQueueMessage();
            if (Config.useEmbeds) {
              queueMessage.edit(embedQueue.setDescription(queueMessageText));
            } else {
              queueMessage.edit(queueMessageText);  ```
#

if someone gets added

umbral zealot
#

there's nothing about deleting messages here.

opal plank
#

you'd still get the bot name

eternal osprey
#

the embed gets edited

#

bot name?

opal plank
#

even if you edit the embed payload

#

you see basically this

#

@umbral zealot tpye something

umbral zealot
opal plank
#

​

eternal osprey
#

wut

opal plank
#

you'd see that

#

if you edit with blank

#

the message itself doesnt get deleted

#

if you send an empty edit im pretty sure api throws an error too

#

so its not empty

errant perch
#

i have a prefix command that changes the prefix for my bot and if you change it to \ it crashes the bot anyone know how to prevent this?

umbral zealot
#

I dunno at this point the best advice is to just start console.log(allthethings) and figure out what your values are, what gets triggered, what changes your variables, etc.

opal plank
#

bad

#

console logging bad

#

use debugger

umbral zealot
#

what? of course it's not bad.

opal plank
#

of course it is

umbral zealot
#

why is it bad

opal plank
#

use a debugger for debugging

#

you follow the script as it runs

#

you see real time variables and values

umbral zealot
#

yeah I get that debuggers are better but saying console logs are bad is a ridiculous statement.

opal plank
#

theres a reason its called a debugger

#

its for debugging(which is the case here)

umbral zealot
#

yeah I get that debuggers are better but saying console logs are bad is a ridiculous statement.

opal plank
#

unless you know whats wrong, console wont do any good other than a bunch fo try and errors

#

which they dont know whats wrong

#

so follow the code with a debugger instead

umbral zealot
#

@errant perch show us the code and the error

errant perch
umbral zealot
#

are you manually editing a json file???

errant perch
#
                userData.serverprefix = args[1]
                    fs.writeFile("./prefix.json", JSON.stringify(file), err => {
                        if (err) console.error(err);
                    });
             message.channel.send(`Server Prefix set to ${args[1]}`)
    break;```
#

no

umbral zealot
#

then something went wrong in your stringify because that shouldn't happen, it should have been escaped.

errant perch
#

i did manually create that bruh

#

\n

#

whenever i do \\n

#

it causes a error

umbral zealot
#

why \n ?

#

that's a line return.

opal plank
#

@errant perch \ is escaping that "

errant perch
#

yes

umbral zealot
#

just "\\"

errant perch
#

how do i prevent people from doing it though

umbral zealot
#

you really shouldn't be using a json file as a database anyway

#

that's your main problem

errant perch
#

but im lazy

opal plank
errant perch
umbral zealot
#

Why shouldn’t I use a JSON file as a database?

A JSON file is not suitable for use as a database for several reasons.

Firstly, you will incur a major performance hit as you need to read from and write to the file on each query and modification. This brings a major performance impact especially when the amount of data increases.

Second, you cannot concurrently write to a JSON file - only one write can be performed at a time. This is part of what causes the performance impact, but perhaps more importantly may introduce unexpected results and even file corruption.

JSON files are also human readable and easily accessible by end users. This means that your database and application will be vulnerable to attacks, especially as database reads are rarely checked for malicious code (Which usually happens on write).

What should I use instead?

An actual database, to put it bluntly. SQL, NoSQL, whatever takes your fancy. Some SQL databases are SQLite, PostgreSQL and MariaDB, while NoSQL databases include things like MongoDB, RethinkDB, ArangoDB and many more.

What can I use a JSON file for?

JSON files are best used to store static data, in other words data that doesn’t need to change often or programmatically. In practice, this means configuration and other application data that needs to be defined by a human - which is what JSON excels at.
Also see: #development message

opal plank
#

^^

umbral zealot
#

being lazy isn't the same as taking the wrong decisions and endangering your own settings.

opal plank
#

Be lazy. Corrupt JSON. Lose all data. Mass send messages saying 'sorry for incovenience'. Mob of angry users who lost their settings. Regret life decisions. Using database after being a stubborn cuck

umbral zealot
#

it'll be easier to use a proper database, so use that laziness to your advantage.

errant perch
#

or be lazy

#

and back it up with google docs

opal plank
umbral zealot
opal plank
#

you arent fit to be a dev

slender thistle
#

It'll bite your own bum in the end

opal plank
#

lazy devs at least find good solutions for problems

errant perch
#

mmulu i've just lost all motivation and hope

slender thistle
#

so your fault if the data is corrupt and irreversible

umbral zealot
#

Actually good devs are lazy devs, because they'll make sure to write good code that they'll never have to fix in the future

#

so right now you're having to fix a problem that would not happen in a database.

opal plank
#

thats the polar opposite of good dev though

#

he KNOWS it WILL error

errant perch
#

and THATS why i backed it up with google docs

#

😏

opal plank
#

which wont keep newest data

umbral zealot
#

right that's still stupid, not lazy, though.

opal plank
#

cuz guess what?

#

the newest dataset got corrupted

umbral zealot
#

just use a database, I literally gave you an example that's going to be super easy to implement even for a lazy bum like you

errant perch
#

ok if i must

umbral zealot
#

successfully helped someone point a shotgun away from their own foot

errant perch
#

sometimes you just wanna get shot

sonic lodge
#

you backed up a json file in google docs?

opal plank
#

then by all means,use JSON database

errant perch
#

yes

opal plank
#

make sure you got a webcam

#

i wanna see a reaction

umbral zealot
#

Those who do not learn history are doomed to repeat it.

errant perch
#

dont have im too lazy to get one

slender thistle
#

why not leave it guys

woven gale
#

can i add my bot here ?

opal plank
errant perch
#

cmon im enjoying the constant berating

sonic lodge
#

oh no, he's crazy

umbral zealot
#

It was constructive criticism πŸ˜›

opal plank
#

more like a fair warning tbh, its better to do stuff properly right away than regret later

woven gale
#

can i add my bot here ?
Answer pls

opal plank
woven gale
#

+help

opal plank
#

93%

#

pls dont get ratelimit on the last 5%

woven gale
#

How can i add ? Please tell me i cant find it @opal plank

opal plank
opal plank
#

click link

#

read

woven gale
#

I am from turkey can u tell me ? Can i add or not if i can add how?

opal plank
#

yes, yes you can

errant perch
#

turkey is good

woven gale
#

Yeah i added

errant perch
#

it prefer it over ham

opal plank
#

then wait

woven gale
#

Okey

opal plank
#

3 weeks

woven gale
#

What

errant perch
#

i have had my bot submitted for 5 weeks

opal plank
#

wait 3 weeks

woven gale
#

:/ ok

opal plank
#

4% left

#

im pretty sure you cant

#

you need to loop each entry

#

yes

#

fetch 50 and then filter them

misty sigil
opal plank
#

No, we dont give code here

peak osprey
#

how would i make it so someone does .ping and it shows the bots ping

#

im useing js

opal plank
#

so close

leaden rover
#
    @commands.has_permissions(administrator=True)
    async def changeprefix(self, ctx, prefix):
        """Change the servers prefix. Note: Only server admins can use this command."""
        with open('prefixes.json', 'r') as f:
            prefixes = json.load(f)

        prefixes[str(ctx.guild.id)] = prefix

        with open('prefixes.json', 'w') as f:
            json.dump(prefixes, f, indent=4)

        await ctx.send(f'Prefix changed to `{prefix}`')```
This code has given me the `FileNotFoundError: [Errno 2] No such file or directory: 'prefixes.json'` error. I have the file with the same name, but do I need it to be `cogs/prefixes.json`?
earnest phoenix
#

try it and see

umbral zealot
#

you really shouldn't be using a json file as a database anyway

misty sigil
umbral zealot
#

@misty sigil we've made an infinite loop of referencing! πŸ˜‚

misty sigil
#

ping pong

umbral zealot
#

It's silly I wish I could use @potent eagle in here it would be useful πŸ˜‚

eternal osprey
#

btw guys this wass my problem

#

this is when i join the queue

#

this is what happens when someone else joins.

#

look

#

could someone please have a look at my code

autumn aspen
#

I can

#

@eternal osprey

eternal osprey
#

okay

#

there you go

autumn aspen
#

ah u need a valid command there bud there is no one

#

Look ur pb is big

eternal osprey
#

what

autumn aspen
#

haha

#

I cant tell u bc Im tired

eternal osprey
#

what the fuck are you saying m8?

autumn aspen
#

srry

eternal osprey
#

okay it's all good.

earnest phoenix
#

@autumn aspen please don't say anything, if you can't do anything.

#

@eternal osprey i will take a look at the code, please be patient

stable eagle
#

Is there a way to reload my index.js file without having to restart my bot?

opal plank
#

index? no

#

commands?

#

yeah

earnest phoenix
#

@eternal osprey Hey! i have read your code! but i can't understand it! so i came up with tips

opal plank
#

i highly doubt you'd be able to re-require your index cache

autumn aspen
#

@autumn aspen please don't say anything, if you can't do anything.
@earnest phoenix yo can u like stop be rude

earnest phoenix
#

I am not rude

#

That's my normal attitude, if you can't stand it, just ignore me

autumn aspen
#

Ok I think u have to change ur "attitude"

thick gull
#

he's not being rude

#

if you can't help don't try to help

autumn aspen
#

I can

#

but u telling me I cant

earnest phoenix
#

I am sick right now, please drop the conversation, thanks.

thick gull
autumn aspen
#

Zobros

#

eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee ._.

thick gull
#

can you

#

not

opal plank
#

Take wines, complaints and childish behaviours to #general pls

earnest phoenix
#

@eternal osprey If possible please rewrite your code to

  1. Have Command Handler
  2. Have Event Handler
  3. Put function in JS file
    both command and event handler can be done by using fs module
#

it will greatly improve your code readiblity and performance

eternal osprey
#

okay, sorry buddy!

thick gull
#

how does a reload command work though Thonk

earnest phoenix
#

@thick gull by removing the require cache

#

and require the file again

thick gull
#

h o w ;tm;

#

wait no let me figure out im smart

opal plank
#

beauty

umbral zealot
#

🀒

opal plank
#

||If you give up,you delete and re-require cache|| @thick gull

earnest phoenix
#

Don't judge his code, he's a beginner, and he's willing to learn, and not expecting spoonfeeding code.

umbral zealot
#
  const evtFiles = await readdir("./events/");
  client.log("log", `Loading a ${evtFiles.length} events.`);
  evtFiles.forEach(file => {
    const eventName = file.split(".")[0];
    const event = require(`./events/${file}`);
    client.on(eventName, event.bind(null, client));
  });

this is beauty πŸ˜‰

pale vessel
#

make it one line smh

earnest phoenix
#

alright

#

hindsight

eternal osprey
#

i remember my code to be like that

pale vessel
#

await readdir? why not readdirSync

earnest phoenix
#

why the fuck did you spoonfeed code?

opal plank
#

dynamic handling commands, i got something similar

#

though the problem is that events require different params

pale vessel
#

using fs and JSON.parse /s

opal plank
#

unifying it is a pain

earnest phoenix
#

There's a lot of command handler out there

opal plank
#

thats an event handler

#

not a command one

earnest phoenix
#

one use fs
one manually register command

opal plank
#

nor am i interested in copying that

umbral zealot
#

I mean that's just part of a bot's code I could copy/paste.

earnest phoenix
#

but did you learn anything?

#

no

umbral zealot
#

it's not exactly going to work without more work to integrate it.

earnest phoenix
#

that's why you don't spoonfeed beginner

opal plank
#

Starwoman

umbral zealot
#

yeah I'm aware of how spoonfeeding works and why it's bad, kthx

opal plank
#

he isnt spoonfeeding here

earnest phoenix
#

what

#

oh

#

fuck

opal plank
#

i wasnt asking for code either way

umbral zealot
#

I was comparing my beautiful code with Erwin's.

opal plank
#

i just showed my events

earnest phoenix
#

I am dumb

#

i am so fucking dumb

opal plank
#

and hind is dynamically handling them

earnest phoenix
#

hind i am so fucking sorry

umbral zealot
#

Hey, admitting your faults is the first step to being a better person! thumbs

opal plank
#

though in my case cuz typescript i'd need to massively work on that

earnest phoenix
#

i thought you give code to awsome guy

umbral zealot
#

Nah. I have guides for that though.

earnest phoenix
#

i am so fucking sorry

umbral zealot
#

They may or may not have small mistakes in them preventing them from being copy/pasted directly.

#

It's fine, Star. ^_^

opal plank
#

fuck i still am not able to find the sweet spot

wintry niche
#

hi

opal plank
#

1h vs 8h from before

wintry niche
#

i need help

#

for my bot need vote

opal plank
#

massive improvement but i still think i can tune it down to 40 if i try hard enough

wintry niche
#

code

opal plank
earnest phoenix
#

@wintry niche you could either

#

1

umbral zealot
#

write it yourself

#

or 2

earnest phoenix
#

no

#

1 Either use a webhook

#

2 or check if user voted every x second and if they voted, put it in a list (not recommended)

opal plank
#

AAAAAAAAH

#

why?!

#

im waiting 4x more than the API docs say the ratelimit is

#

WHAT THE FUCK

#

someone please do explain

#

19 joins, thats 19 seconds,+ 11 seconds when the bucket limit is down to 1 remaining, thats 30 seconds

#

and i still get ratelimit

#

NANI THE FUCK

drifting wedge
#

collection.update_one({"_id": author_id}, {"$set":{"purse":str(purse + coinstogive)}}, upsert=True)

#

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: can only concatenate str (not "int") to str

#

any1 know why?

earnest phoenix
#

you cant add an integer to a string

#

try converting the integer in str(purse + coinstogive) (idk what one the int is) to a string before continuing

#

means

#

oh wait no

#

im dumb

#

are you tryna add 2 values together?

#

@drifting wedge

drifting wedge
#

yes

earnest phoenix
#

maybe one is a string

drifting wedge
#

and then sending it to mongo

earnest phoenix
#

and cant be added to a int

drifting wedge
#

well its a number

earnest phoenix
#

try converting the one you believe is a string to a number

drifting wedge
#

so i can turn it into a int?

earnest phoenix
#

if you are trying to add 2 integers together and one is a string, it'll fail so

#

if you think one of these 2 values is a string, convert them before adding

#

can only concatenate str (not "int") to str
indicates that its trying to add a integer to a string

#

basically like "this will have a " + 0 + "% success rate"

eternal osprey
#

how do i fix this?

earnest phoenix
#

basically json features in vs code dont load the document fully when its above 5000 chars

#

@eternal osprey are you using JS as DB?

#

to prevent your pc from, well, oofing

#

If yes, please switch

#

i would recommend changing your strategy if these files are a normal thing in your workspace

#

and for god damn sake, dont use a json db

#

please

eternal osprey
#

i know but this is just for now

#

i don't want to start all over

#

and i am only known with json databases.

earnest phoenix
#

you can just change your json db to quick.db

#

quick.db is like the most easy db to use for a small project

eternal osprey
#

that can't be all

earnest phoenix
#

i can help you migrate from json to quick.db

eternal osprey
#

sure

earnest phoenix
#

basiclly

#

the easiest way is to

#

read data from json and transfer it to quick.db

#

so you have to loop throught the data

#

not that difficult, but can be a bit challenging when you have many nested properties

#

^

#

Object.keys(yourDbObject) returns all keys from that object, which you can then loop through

eternal osprey
#

okay woooh

#

a bit overwhelming

earnest phoenix
#

It's not hard

#
Object.keys(yourDbObject).forEach(key => {
let valueToKey = yourDbObject[key]
// set value to quick.db's database here, using "key" as key and "valueToKey" as value
// example: db.set(key,keyToValue)
})
#

that can be done in the node.js live shell, no need to make a script for it

#

just open cmd, type in node and you are set

eternal osprey
#

hmm

#
    // If queueMessageId is still 0, no queue has been created
    if (queueMessageId === 0) {
      message.channel.send('A queue does not currently exist sailor '+ "<@" + message.author.id + ">");
      // Otherwise, the queue already exists, so users can join
    } else {
      message.channel.messages.fetch(queueMessageId).then(queueMessage => {
        if (addUserToQueue(message.member.displayName, message.member.id, args)) {
          assembleQueueMessage();
          queueMessageText += ' ' + message.content.slice(Config.prefix.length).replace(/^queue *join/, '').trim()
          if (Config.useEmbeds) {
            queueMessage.edit(embedQueue.setDescription(queueMessageText));
          } else {
            queueMessage.edit(queueMessageText);
          }
        } else {
          message.channel.send(`${message.author} already entered the ship queue!`);
        }
      })
        .catch(console.error);
    }```
#

cuz

#

if someone else joins with a message

#

it gets delete (the previous mesage)

#

i have been trying to fix this for over 2 freakin days.

#

anyone that can help

wheat mesa
#

How do I use catch to catch an error?

rancid bramble
#

What was setNickname changed to?

wheat mesa
#

Nevermind, just figured it out

#
if(command == 'clown'){                        //clown
if(message.mentions.roles.size || message.mentions.everyone) {return message.reply('Improper mention.')}
if(!message.member.hasPermission('ADMINISTRATOR')) return message.channel.send('You must be an admin to use this!')
  let newClown = message.mentions.users.first()
if(Clowns.has(newClown.id)) {
  Clowns.delete(newClown.id)
  message.channel.send('removed clown')
}
else {
Clowns.add(newClown.id)
message.channel.send('new clown!')
}}
client.on('message', function(message){
if(Clowns.has(message.author.id)) {
message.react('🀑')
}
})
``` I finally got this to work properly, but after I use the command once and do it two more times, it gets really slow at reacting. Is my code just slow or is there something wrong?
zenith knoll
#

How do you DM a user?

#

a cirtain one

thick gull
#

<user>.send

zenith knoll
#

Yes but by ID

thick gull
#

get them from the cache

strong geode
#

get the id from the cache

zenith knoll
#

because when I use the cache one it says cannot read property of undefined

#

so do i needa store the member list fiorst?

thick gull
#

well then it can’t find the user in cache

#

no

#

discordjs does that automatically

zenith knoll
#

hmm well keeps saying

#

Cannot use send of undefined

#

my code is

thick gull
#

are you sure it’s a valid ID?

zenith knoll
#
user.send(`${message.author.id}`);```
#

724066932701134979 is me

#

says user isnt defined or not usable

thick gull
#

are you in the cache?

zenith knoll
#

Yes

#

bc i used the cace

#

cmd'

#

i mean

thick gull
#

try .fetch() CH_PepeHmm

zenith knoll
#

so no .get but.fetch

#

gotchu

thick gull
#

i don’t know the exact format for fetch lol

#

@earnest phoenix qt come here

zenith knoll
#

fetch returns a promise iirc

#

so lemme do my .then

#

TypeError: client.users.cache.fetch is not a function
at D:\dbots\Emit\commands\purchase.js:22:49
at processTicksAndRejections (internal/process/task_queues.js:97:5)

#

oop

strong geode
#

don't use cache

zenith knoll
#

okie

strong geode
#

fetching doesn't require cache

zenith knoll
#

yea forgot

#

thats y i said oop

drifting wedge
#
            collection.update_one({"_id": author_id}, {"$set":{"purse":str(purse - int(arg))}}, upsert=True)
            collection.update_one({"_id": member_id}, {"$set":{"purse":str(purse + int(arg))}}, upsert=True)```
zenith knoll
#

fetching doesn't require cache
@strong geode I need to login too, right?

#

because it uses the client token

drifting wedge
#

how can i make sure that the arg is an int

strong geode
#

!isNaN if you want to make a return part for your code like if(!isNaN(args[3]))return; wrong language

slender thistle
#

arg.isdigit() returns True if the arg is a number

zenith knoll
#

i use isNan

#

NaN

#

wait so

drifting wedge
#

arg.isdigit() returns True if the arg is a number
@slender thistle alr

#

ty

zenith knoll
#

it sends the message to me, but for sum reason it says user.send isnt a function

slender thistle
#

Imagine seeing Python and suggesting JS functions

zenith knoll
#

agreed

#

lmao

#

jk

#

Imagine seeing Python and suggesting JS functions
@slender thistle I didnt read his code, just saw he wanted to check if its a int

strong geode
#

@slender thistle I didnt read his code, just saw he wanted to check if its a int
so did i πŸ˜„

slender thistle
#

What do I want to say about this

zenith knoll
#

You want to say that somehow python is better?

slender thistle
#

Nothing other than "why try to blindly help"

zenith knoll
#

what if hes using some npm package to implement python in js code?

faint prism
#

Imagine seeing Python and suggesting JS functions
@slender thistle I prefer to give answers in a different language, since it would explain how to go about something, but not spoonfeed

slender thistle
#

Last time I checked pymongo wasn't an npm package

zenith knoll
#

idk bro

slender thistle
#

But Auger, there's no "is_NaN" in Python

#

or a NaN object

zenith knoll
#

dude you dont needa flex ur superior coding skills

faint prism
#

Well it'd be a failed parse/cast then

slender thistle
#

My main point is, you suggesting an "isNaN" function when there's no such thing in Python is only confusing for a beginning Python dev

faint prism
#

IsNaN wouldn't be hard to implement in another lang regardless

slender thistle
#

And oh boy, that "beginning" part should be emphasized with bold caps

#

Well, there's no NaN anyway

zenith knoll
#

theres also google

#

"isNaN python version"

slender thistle
#

More like if arg.isdigit(): arg = int(arg)

faint prism
#
public static bool IsNaN (object obj)
{
  return double.TryParse(obj, out double unusedDouble);
}
#

Something like that for C# I'd imagine

#

Or try/catch an explicit cast

slender thistle
#

mmm exceptions

faint prism
#

I'd imagine that's how tryParse is implemented

#

Exception handling to return a Boolean

earnest phoenix
#

wtf why does my bot answer to any prefix that has p

#

letter

eternal osprey
#

hey how do i save my messages?

earnest phoenix
#

it started happening recently

eternal osprey
#
if (command === 'queue' && subcommand === 'join') {
    // If queueMessageId is still 0, no queue has been created
    if (queueMessageId === 0) {
      message.channel.send('A queue does not currently exist sailor '+ "<@" + message.author.id + ">");
      // Otherwise, the queue already exists, so users can join
    } else {
      message.channel.messages.fetch(queueMessageId).then(queueMessage => {
        if (addUserToQueue(message.member.displayName, message.member.id, args)) {
          assembleQueueMessage();
          queueMessageText += ' ' + message.content.slice(Config.prefix.length).replace(/^queue *join/, '').trim()
          if (Config.useEmbeds) {
            queueMessage.edit(embedQueue.setDescription(queueMessageText));
          } else {
            queueMessage.edit(queueMessageText);
          }
        } else {
          message.channel.send(`${message.author} already entered the ship queue!`);
        }
      })
        .catch(console.error);
    }
  }``` i want to save the args put in by the users
#

so it doesn't get deleted

#

and stays in the embed

#

how can i do that?

#

cuz i have a problem

faint prism
#

letter
@earnest phoenix are you doing something like startsWith or contains?

eternal osprey
#

but no-one knows the answer

earnest phoenix
#

nvm i found out why it does that

eternal osprey
#

any help?

faint prism
#

cuz i have a problem
@eternal osprey double check your { and } count

earnest phoenix
#

@thick gull yes?

thick gull
#

n v m

drifting wedge
#

            if arg2 == True:
                collection.update_one({"_id": author_id}, {"$set":{"purse":purse - arg}}, upsert=True)
                collection.update_one({"_id": member_id}, {"$set":{"purse":purse + arg}}, upsert=True)
            if arg2 == False:
                await ctx.send('Please use a valid amount of money!')```
#

does this work?

#

the purse - arg or purse + arg is giveng some error

wheat mesa
#

Is there a way to look for a certain word within a sentence? I tried to make a "bad word" filter but whenever someone said class, it triggered as ass. I used the message.content.includes command for it.

sonic lodge
#

try using regex

solemn leaf
#

do I need to end breaks for switches?
break;
or only on the last break?

pale vessel
#

you need breaks but it's optional on last because it's going to break out anyway

#

if you don't add break, it'll continue looking in the switch until the end

#

which defeats the purpose

sonic lodge
#

there seems to be a trend of people who ask questions and don't stay for the answer
but idk

slender thistle
#

@drifting wedge if arg2 == True:
arg = int(arg)

earnest phoenix
#

im trying to run a bot 24/7 and im trying to do this technique but my command prompt says invalid path ThisPC\Desktop\DiscordBot and it says the system cannot find the path specified

honest perch
#

just run the program from the ide console

wheat mesa
#
if(PersonWritingCommand == 173489654144696320) {
const str = message.content.toLowerCase()
const badWord = ['word1', 'word2', 'word3', 'word4', 'word5', 'word6', 'word7']
const LookForCuss = str.search(badWord)

if(LookForCuss) {return message.reply('cuss detected')}


}
``` Any idea why this doesn't work? I've never used regex before, sorry if this seems simple.
cinder patio
#

The ID should be a string

pale vessel
#

it's python

cinder patio
#

the number is too big to be a JS number

#

oh

wheat mesa
#

it's js

pale vessel
#

WAIT

slender thistle
#

I uh

#

don't think that's py

pale vessel
#

i'm retarded

sonic lodge
#

.search takes in a string or regex pattern to search for, not an array

wheat mesa
#

Is there a way to seach for words in an array?

pale vessel
#

something about it made me think it's py thinkingreverse

cinder patio
#

The code shouldn't even execute

sonic lodge
#

an example regex that matches "ass" by itself: \bass\b

wheat mesa
#

Can something like that work in an array?

sonic lodge
#

you could create a single regex that matches every bad word in your bad-words-array

pale vessel
#

array.some()?

sonic lodge
#

that too

solemn leaf
#

How can I check if a string is just numbers

pale vessel
#

you can use !isNaN(number)

faint prism
#

@drifting wedge if arg2 == True:
arg = int(arg)
@slender thistle why would you ever do == True or == False...?

solemn leaf
#

@pale vessel so number would be the string

pale vessel
#

yes

solemn leaf
#

!isNaN(args[1])

pale vessel
#

it'll try to convert it to a number and check

#

yeah

#

that checks whether a number is Not a Number or not. adding ! makes it do the opposite

slender thistle
#

@Auger#8261 precision

#

But usually just doing if x works

solemn leaf
#

k thanks

pale vessel
slender thistle
#

I usually do if x == False if it's something public and the thing is supposed to be stricly False

#

strictly

drifting wedge
#

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: unsupported operand type(s) for -: 'str' and 'int'

#
arg2 = arg.isdigit()

            if arg2 == True:
                arg = int(arg)
                collection.update_one({"_id": author_id}, {"$set":{"purse":purse - arg}}, upsert=True)
                collection.update_one({"_id": member_id}, {"$set":{"purse":purse + arg}}, upsert=True)
            if arg2 == False:
                await ctx.send('Please use a valid amount of money!')


            await ctx.send(f'You have given {member.mention} {arg} coins!')```
slender thistle
#

What's purse

drifting wedge
#
        for purs in prs:
            purse = purs["purse"]

        bnk = collection.find(memberid)
        for bk in bnk:
            bank = bk["bank"]

        inventory = collection.find(memberid)
        for invt in inventory:
            inv = invt["inventory"]```
#

its a currency system

#

purse is the money you have on you

slender thistle
#

Remind me

#

why use .find and not find_one

faint prism
#

I usually do if x == False if it's something public and the thing is supposed to be stricly False
@slender thistle if !x is the same. It just looks amateur to compare booleans within a conditional

slender thistle
#

p.s. strictly False and not anything generically falsey

faint prism
#

Oh wait, are you saying x could be something other than a Boolean?

slender thistle
#

In some cases it can. Not here though.

#

But it's more verbose so I don't blame anyone for doing it

faint prism
#

I'm used to strict type languages. But ig you could do that if it implicitly parses like "True" == True

slender thistle
#

I sometimes don't get a single fucking idea of what my variables return in if aaa: πŸ˜‚

faint prism
#

Ehhh

slender thistle
#

"E" is true, "" is not

faint prism
#

I'd be very careful returning dynamic datatypes

#

Leads to a lot of avoidable runtime errors

slender thistle
#

We're talking Python here

faint prism
#

Sigh, right

slender thistle
#

πŸ˜‚

#

I do use type annotations a lot though

#

Though eh...

#

Nested Dicts and Unions for Lists is a bleh

sudden geyser
#

if not not "E": ...

slender thistle
#

if not not not not not not not not not not not False

earnest phoenix
low shard
#

It say

#

You need to drop your pc from the window

#

And try again

#

Just try this way

slender thistle
#

Let's be actually helpful

earnest phoenix
#

βœ“ yes βœ“ xd

slender thistle
#

@earnest phoenix what's your code looking like

low shard
#

I’m joking

earnest phoenix
pale vessel
#

this fucking channel man istg

drifting wedge
#

@slender thistle

#

the blinking thing

#

ok ty

slender thistle
#

YEET

earnest phoenix
#

Co ja?

#

is someone gonna answer angrybirdbruh

sonic lodge
#

that's not your code

#

they asked for your code

earnest phoenix
#

Hmmmm?

#

Eee idk

slender thistle
#

Please stay away from this channel if you're not going to help

earnest phoenix
#

they asked for your code
@sonic lodge which one

sonic lodge
#

the javascript file?

earnest phoenix
sonic lodge
#

that's your bot.js file?

earnest phoenix
#

yeah

misty sigil
sonic lodge
#

why does that look exactly like the code i copied pasted when i started making a discord bot

misty sigil
#

it is copypaste code

#

it literally is

earnest phoenix
#

Β―_(ツ)_/Β―

sonic lodge
#

...

misty sigil
#

...

#

(β•―Β°β–‘Β°οΌ‰β•―οΈ΅ ┻━┻

earnest phoenix
#

ok

pale vessel
#

that is some old old old code

misty sigil
pale vessel
#

like three years ago

low shard
#

Skid

sonic lodge
#

so i'm 91.75% sure that isn't your bot.js file

low shard
#

@earnest phoenix if you wanna be insane don’t be skid

misty sigil
#
var logger = require('winston');
var auth = require('./auth.json');
// Configure logger settings
logger.remove(logger.transports.Console);
logger.add(new logger.transports.Console, {
    colorize: true
});
logger.level = 'debug';
// Initialize Discord Bot
var bot = new Discord.Client({
   token: auth.token,
   autorun: true
});
bot.on('ready', function (evt) {
    logger.info('Connected');
    logger.info('Logged in as: ');
    logger.info(bot.username + ' - (' + bot.id + ')');
});
bot.on('message', function (user, userID, channelID, message, evt) {
    // Our bot needs to know if it will execute a command
    // It will listen for messages that will start with `-`
    if (message.substring(0, 1) == '!') {
        var args = message.substring(1).split(' ');
        var cmd = args[0];

        args = args.splice(1);
        switch(cmd) {
            // !ping
            case 'ping':
                bot.sendMessage({
                    to: channelID,
                    message: 'Pong!'
                });
            break;
            // Just add any case commands if you want to..
         }
     }
});``` yup
#

quick ass google search found it

low shard
#

Lol

#

@earnest phoenix take it as tip

misty sigil
#

found it here too

low shard
#

Lolll

earnest phoenix
#

yeah im new to this type of shit

misty sigil
#

its quite obviously copypasted

low shard
#

So don’t copy codes

misty sigil
#

so go and learn some js i say it'll make it so much easier

low shard
#

Learn the basic

misty sigil
#

genuinely

fluid widget
misty sigil
#

use info.videoDetails.lengthSeconds?

#

its

#

its obvious

#

this channel man

wheat mesa
#
if(PersonWritingCommand == 173489654144696320) {
const badWord = ['word1', 'word2', 'word3', 'word4', 'word5', 'word6', 'word7']
const badWordCheck = badWord.some(e => message.content.toLowerCase().includes(e))
if(badWordCheck) {
{return message.reply('cuss detected')}

}
}
``` this still detects if I type a bunch of gibberish like this dasjndsjfdnkjsfnword1jkasdnfjsd as long as one of the words is in it. How can I make it so it only triggers if the word is by itself like "blah blah blah word1 blah blah blah"
misty sigil
sonic lodge
#

combine regex and .some

#

turn each word into a regex that detects the word by itself and use that in .some instead

wheat mesa
#

so I can't just do it through an array?

sonic lodge
#

you can

#

change your array of words to an array of regexes and in .some, see if the current regex matches the given string

fluid widget
#

@misty sigil I did not understand you

misty sigil
#

read the error maybe?

#

like uh

#

uhh

fluid widget
#

I had this problem a while ago and I didn't know the reason @misty sigil

misty sigil
#

BRUH

#

just change

#

info.length_seconds

#

to

#

info.videoDetails.lengthSeconds

fluid widget
#

@misty sigil here

#

It has changed and nothing has happened, but the main problem is there @misty sigil

misty sigil
#

i mean

#

dont do the best format stuff

zenith knoll
#

gyo

#

so

fickle arch
zenith knoll
#

um so

#

i made a user object

#

and i send a msg to the user

#

and it sends

#

bc i got the msg

solemn leaf
#

and?

zenith knoll
#

but it sends user.send isnt a function

umbral zealot
#

then it's not a proper user object.

fickle arch
#

you mean send dms to user ?

#

or

zenith knoll
#

yes

#

DMs

#

const user = client.users.fetch('724066932701134979').then((user) => {
user.send(${message.author.id});
})

fickle arch
#

message.author.send

zenith knoll
#

fetch returns a promise iirc

solemn leaf
#

const member = message.guild.member(user);

fluid widget
#

Ok what do I do to make it work @misty sigil

zenith knoll
#

k

misty sigil
#

i dont know

solemn leaf
#

member.send

fickle arch
#

member.send
@solemn leaf is that stuff like sending dms to people and not people who asked it ?

solemn leaf
#

message.author.send

earnest phoenix
#

How can I show 2FA Requirement for Moderation?

#

how do i know if it is true

fickle arch
#

Wdym of that ?

#

I really need help for music function lol, I failed on every tutorial lol.

tidal marlin
#

Can embed accept no url images?

vernal rivet
#

@fickle arch what are you struggling on with it?

eternal osprey
#

hey

#
from requests_html import HTML, HTMLSession

# Nike SNKRS Lauch Calendar
NIKE_SNKRS_URL = 'https://www.nike.com/fr/launch'
# Create requests-html session Object
s = HTMLSession() 
# Create response for Nike SNKRS Launch
r = s.get(NIKE_SNKRS_URL) 
# Contains the HTML 
html_of_site = r.html 

# Functions 
def get_nike_shoes(html_of_site=html_of_site): 
    '''Return the first five shoes in the launch calendar.''' 
    select = "div[class='d-sm-tc va-sm-m']"  
    shoes_and_releases = html_of_site.find(select)  
    list_of_shoes = []  

    for shoe_and_release in shoes_and_releases: 
        list_of_shoes.append(shoe_and_release.text)

    return list_of_shoes[0:5]

def get_links(html_of_site=html_of_site): 
    '''Return the first five links for the shoes in the launch calendar.'''
    select = "a[class^='ncss-col-sm-8']"  
    links_for_shoes = html_of_site.find(select)  
    list_of_links = []  

    for link in links_for_shoes: 
        list_of_links.append(list(link.absolute_links)[0])
    
    return list_of_links[0:5] ```
#

i want to scrape this part too:

#

the p

#

how can i do that in my code?

earnest phoenix
#

get the xpath to it

#

i know mozilla firefox has a bult in copy as xpath

eternal osprey
#

i am using opera gx

earnest phoenix
#

don't know about opera

eternal osprey
#

can't i just access p div?

#

where all the info is stored

earnest phoenix
#

don't know

eternal osprey
earnest phoenix
#

which would get me this

#

/html/body/div[1]/div/div/div[1]/div[1]/div[2]/div/div[3]/h2/span/div

eternal osprey
#

downloading firefox right now

#

hold on

#

this is how i am accessing the other info

#

select = "div[class='d-sm-tc va-sm-m']"

#

can't i just do

earnest phoenix
eternal osprey
#

select = "div[p]

earnest phoenix
#

well you'd be selecting any div with a p child

#

that's why you'd use xpath instead

eternal osprey
#

yeah

earnest phoenix
#

specific path to an element

eternal osprey
#

okay let me get firefox

earnest phoenix
#

from what i can see your lib supports xpath

eternal osprey
#

okay

#

i have firefox installed

#

how do i select the xcode thingy?

#

nvm got it

#

/html/body/div[2]/div/div/div[1]/div/div[3]/div[2]/div/section/div/div/div/div/p

#

the xpath

#

so now i should just put it in?

earnest phoenix
#

don't know

#

see your libs docs

faint prism
#

Oh I love xpaths

eternal osprey
#

hmm

faint prism
#

It's best to be as vague as possible so it's now resilient to changes in the page. Kinda like regex

#

/html/*/selection/ul/li[1] for example

#

I forgot xpaths queries though

#

But you can select where text property= "something" too

#

Or n-child of x

#

And it has conditional ANDs

#

A lot like regex really

main chasm
#

TypeError: Cannot read property 'aliases' of undefined

#

what is this error?

eternal osprey
#

hey

vernal rivet
#

your object is undefined. undefined objects do not have any properties.

drifting wedge
#

using aframe

#

how can i <a-entity kinema-body="radius: 0.8" movement-controls="fly: false" position="0 0 4" look-controls>

#

look controlls but replace with like moving mouse

hasty mulch
#

TypeError: Cannot read property 'aliases' of undefined
what is this error?
@main chasm Basically, you’re missing a period somewhere. Show your code

vernal rivet
#

lipd thats not always the case. that error simple means your grabbing a property from an undefined object. a missing . can be a cause, but its not the only cause. if you were to grab a property that doesn't exist on another property that doesn't exist on a Object with a Type, it will throw that error.

main chasm
#

@vernal rivet fixed thank u su much for help