#development

1 messages · Page 1284 of 1

quartz kindle
#

this way the library sets it automatically for you every time it reconnects

sly dawn
#

Ohh!

#

shall i put this on top of my index.js?

#
bot = new Discord.Client({
  presence:{
    activity:{
      name:"my status",
      type: "WATCHING"
 bot.user.setActivity(`my status`, { type: 'WATCHING'}).catch(console.error);
    }
  }
})```
#

like this?

#

oh wait

fickle sapphire
#

Don’t think so

sly dawn
#
bot = new Discord.Client({
  presence:{
    activity:{
      name:"my status goes here?",
      type: "WATCHING"
    }
  }
})```
#

like that?

quartz kindle
#

yes

sly dawn
#

ok imma try

#

it worked yes

#

btw is heroku laggy?

#

cuz its giving my bot 40k ms

slender thistle
#

The logic behind it is to use member.remove_roles(...) to remove the role.
@sudden geyser remove_roles accepts either discord.Objects or discord.Roles (basically any object that has an .id property

sudden geyser
#

ah then that too

slender thistle
#

One workaround when you don't want to bother getting the roles is to create discord.Object yourself ¯_(ツ)_/¯

lucid wharf
#

How can I get the image (URL) of the bot?. I have tried with message.author.bot.displayAvatarURL...

cyan bear
#

@lucid wharf the link?

lucid wharf
#

Yess

cyan bear
#

ok

#

Do you use develepor portal?

#

ait

lucid wharf
#

I have succeeded but the user, what I need is the bot Q_Q

cyan bear
#

ok go to 0auth2

#

there is a checkbox

#

choose 1 that is bot

#

copy the link

#

enter it into hte searh

golden ingot
#

@lucid wharf client.user.displayAvatarURL i think

#

just read the documentation, it won't kill ya

lucid wharf
#

@golden ingot i love you

twilit hare
#
            const m = await msg.channel.send(mainembed);

            await m.react('🚫');
            await m.react('🧱');
            await m.react('⚛');     
            await m.react('📏');  
                    
            const filter = (reaction, user) => {
                return ['🚫', '🧱', '⚛', '📏'].includes(reaction.emoji.name) && user.id == msg.author.id;
            };
            
            const removeReaction = async (m, msg, emoji) => {
                try { m.reactions.find(r => r.emoji.name == emoji).users.remove(msg.author.id); } catch(err) {}
            }

            awaitReactions(msg, m, options, filter);
#
const awaitReactions = async (msg, m, options, filter) => {

                const { min, max, page, limit } = options;
                
                m.awaitReactions(filter, { max: 1, time: limit, errors: ['time'] })
                .then(async (collected) => {

                    
                    const reaction = collected.first();

                    var extembed = await getExtClutcherStats(args, msg);
           

                    var bridgeembed = await getBridgeClutcherStats(args, msg);
                    
        
                    var omniembed = await getOmniClutcherStats(args, msg);



                    if (reaction.emoji.name === '🚫') {
                        return await m.delete();       
                    }
                    else if (reaction.emoji.name === '🧱') {


                        await removeReaction(m, msg, '🧱');
                        await m.edit(bridgeembed);

                    }
                    else if (reaction.emoji.name === '⚛') {

                        await removeReaction(m, msg, '⚛');
                        await m.edit(omniembed);

                    }
                    else if (reaction.emoji.name === '📏') {

                        await removeReaction(m, msg, '📏');
                        await m.edit(extembed);

                    }
                    else {
                        awaitReactions(msg, m, options, filter);
                    }
                    





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

Im trying to create a reaction menu but every time it says it cannot send an empty message even before clicking on any of the reactions
i know the functions do return the embed

#

it seems like im not sending any kind of message before the if statements, but it dosen't even get to them before erroring out

sudden geyser
#

It's adding the first four emojis before the error occurs, correct?

#

Since it's erroring out, does the stacktrace point to anything useful in your source code.

twilit hare
#

yes i debugged that the emojis are being sent before the error

#

no the stacktrace just says discordapi error. no line is specified

#

in my source code

#
(node:18187) UnhandledPromiseRejectionWarning: DiscordAPIError: Cannot send an empty message
    at RequestHandler.execute (/home/bardia/3d4hbot/node_modules/discord.js/src/rest/RequestHandler.js:170:25)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:18187) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:18187) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
leaden rover
#

How do I make it so if my bot is the only user in a VC that its in, it would leave in discord.py?

viral iris
#

hello? is there a way to make images from api using any package (like canvas) and make them gif?

autumn aspen
#

what
@ripe wyvern lmao u copy

#

hello? is there a way to make images from api using any package (like canvas) and make them gif?
@viral iris no

#

u must have an gif

#

or I think if u put the newest link to it when u made it to a gif but I dont think so 😦

twilit hare
#

@sudden geyser no nothing useful and yes error happens after emojis

sudden geyser
#

What you could do is try adding debug statements before each m.edit (aka use a debugger or just plop console.log in there). That should give you an idea of where the error is occurring.

twilit hare
#

What you could do is try adding debug statements before each m.edit (aka use a debugger or just plop console.log in there). That should give you an idea of where the error is occurring.
@sudden geyser I put console.log before every m.edit put the program dosen't get to any of them

#

it errors before i can even choose a reaction

quartz kindle
#

do you have any code after awaitReactions?

#

in the first code block

twilit hare
#

after awaitReactions is const awaitReactions = async (msg, m, options, filter) => {

#

i just split them up bc 2000 char limit

quartz kindle
#

ah so its all the same block

#

what about after it then

#

after the function

twilit hare
#

i have the enitre thing in a try/catch

#

only the catch is after

quartz kindle
#

you need to await the awaitReactions

#

otherwise the try catch doesnt do anything

twilit hare
#

ok did that same issue

sudden geyser
#

But it couldn't throw an error as it's being ignored with .catch(() => {})

quartz kindle
#

put more console.logs and see until where it works

twilit hare
#

ok

sudden geyser
#

also is there more to the file you could share

twilit hare
#

yeah this is the entire function

quartz kindle
#

im pretty sure you cannot send an error object directly

misty sigil
#

you cant

#

error.message

twilit hare
#

i have promises in each of the *ClutcherStats which reject strings

#

i changed the try/catch in the pastebin

sudden geyser
#

Also over here: js const removeReaction = async (m, msg, emoji) => { try { m.reactions.find(r => r.emoji.name == emoji).users.remove(msg.author.id); } catch (err) {} }
You need to await the statement in the try block as it won't catch the promise.

twilit hare
#
await m.reactions.find(r => r.emoji.name == emoji).users.remove(msg.author.id); ```
#

so like this?

sudden geyser
#

Yes, but that's a minor bug. It's not the exact issue you're having.

twilit hare
#

ok

#

ok i moved awaitReactions(msg, m, options, filter) to after const awaitReactions = async (msg, m, options, filter) => {

#

it dosen't error anymore but now the reactions don't do anything

quartz kindle
#

if you need it to be recursive, declare it as a function

#
async function awaitReactions(...) {
  ...
}
twilit hare
#

ok did that

#

i followed this tutorial if that helps

#

ooh ok so i got it working, but the removeReaction function dosen't work the reactions don't get removed

restive furnace
#

thats probably v11

slender thistle
#

VBA
How do you get only the float part of a decimal number? As in, get 0.9 from 6.9.

pure lion
faint prism
#

modulus of 1?

#

wait that's not right

slender thistle
#

Hmm...

hazy sparrow
#

guys i wonder how the first coding language was written

faint prism
#

guys i wonder how the first coding language was written
@hazy sparrow Binary

slender thistle
#

Maybe I could convert to integer and subtract

hazy sparrow
#

Oh right

faint prism
#

And then abstracted into higher level languages

slender thistle
#

That's VB.NET but I hope it will help

restive furnace
#

asm was second one :)

#

(assembly in case you don't know)

faint prism
#

I think it was ENIAC

karmic compass
#

is there a way to get all attachments in a message (images, etc.) and then display them in an embed in d.js?

faint prism
#

asm was second one :)
@restive furnace ASM came a few years later

karmic compass
#

(ping me if you have close to a response)

faint prism
#

Then fortran maybe?

restive furnace
#

@restive furnace ASM came a few years later
@faint prism Jacquard machine seems to be first according to wikipedia, then ENIAC. But most compilers compile into ASM/Binary.

faint prism
#

I mean, if you consider a loom in 1804 to be a computer, sure lol

restive furnace
#

yes

earnest phoenix
#

is there a way to get all attachments in a message (images, etc.) and then display them in an embed in d.js?
@karmic compass Iterate through <message>.attachments

karmic compass
#

it becomes an array?

#

so i could use a forEach

#

right

earnest phoenix
#

Also you can't attach more than 1 image

karmic compass
#

yeah so just

#

message.attatchments[0]

earnest phoenix
#

Attachments returns a collection

autumn aspen
faint prism
#

But most compilers compile into ASM/Binary.
Yep, pretty much.
Some Higher level -> ASM (instructions, registers, and opcodes) -> Binary representation

slender thistle
#

LMFAO U DONT SEND ANYTHING OUTSIDE BRO!
what

faint prism
#

what
@slender thistle ||I just did what Cry did||

autumn aspen
#

bro what the hell is that on top.gg

#

can someone tell me why is that COVID-19 shit there do u like to have it like others?

#

@humble gyro llmao srry for ping but u needa explain for us

slender thistle
#

Did you read it

autumn aspen
#

yes

slender thistle
#

People kept complaining about long bot review times and that disclaimer is there to explain why

autumn aspen
#

People kept complaining about long bot review times and that disclaimer is there to explain why
@slender thistle bruuuh

slender thistle
#

And no it wasn't added there "just because it's nice"

autumn compass
#

there is always a reason

hearty wren
#

Does anyone have experience with pug?

#

I haven't touched web dev stuff for over a yr im lost

open rune
#

Does anyone have experience with pug?
@hearty wren no, but I have experience in pubg

hearty wren
#

That won't help

faint prism
#

why are you using pug?

hearty wren
#

Im using express.js for a portfolio website

#

And pug for templating

faint prism
#

why not a more popular framework like Angular, Vue, or React?

hearty wren
#

Its not as complicated and idk those frameworks

#

I think ill just do it in flask and save me this bs

open rune
#

try vue, it's ez to learn

#

otherwise, if you wanna try php thingy, try Laravel

faint prism
#

I dunno about php

hearty wren
#

Ill look into vue rq then

#

Idk a single thing in php tbh

drowsy kite
#

hello, can anyone help me to make a embed?

faint prism
#

Vue.JS i've heard is a good mix of the other JS frameworks

open rune
#

yes

#

they're

faint prism
#

I'd recommend that one because how easy it in to add on to a website

hearty wren
#

Im usually working in flask but i heard its "cool" to use a js framework so ik express alrdy but pug is not recognized by the script

open rune
#

hello, can anyone help me to make a embed?
@drowsy kite Yes, discord.js?

faint prism
drowsy kite
#

yes i guess so i don't understand ".addfield"

faint prism
#

yes i guess so i don't understand ".addfield"
@drowsy kite It's two strings, a title, and the content

open rune
#

.addField("Title", "Topic", "true/false")

drowsy kite
#

Just replace the things I want with what is there

thin turret
#

.addField(<Title>, <Content>, <InlineBoolean>);

faint prism
#

Just replace the things I want with what is there
@drowsy kite Well you put the strings you want there

sly dawn
#
haha = new Discord.Client({
  presence:{
    activity:{
      name:`${bot.guilds.cache.size} with ${bot.users.cache.size} users | c!help`,
      type: 'PLAYING',
    }
  }
})``` my bot's status not appearing
drowsy kite
#

haha?

#

😂

faint prism
#

Just like any other function in Javascript

drowsy kite
#

okay

thin turret
#

haha what

sly dawn
#

xD

#

haha is a variable

drowsy kite
#

okay

hearty wren
#

OMG ty to whoever told me to use vue im on their docs and it looks so simple

sly dawn
#

just tell me if something is wrong with that code

drowsy kite
#

@drowsy kite Well you put the strings you want there
@faint prism thanks for support me 😉

faint prism
#

It's a function that accepts 3 arguments iirc

open rune
#

@hearty wren thanks to Auger

sly dawn
#
haha = new Discord.Client({
  presence:{
    activity:{
      name:`${bot.guilds.cache.size} with ${bot.users.cache.size} users | c!help`,
      type: 'PLAYING',
    }
  }
})``` status not appearing
#

please help

faint prism
#

Be patient

sly dawn
#

ik but they ignored it lol

faint prism
sly dawn
#

stop pinging?

drowsy kite
#

k

faint prism
#

You waited 1 minute

sly dawn
#

Fine

drowsy kite
faint prism
#

I mean, you copy and pasted that, but yeah

drowsy kite
#

okay

sly dawn
#

lmao

faint prism
#

Straight out of the example

sly dawn
#

yeah

drowsy kite
#

@drowsy kite lemme guess it, you got it from discord.js.org
@sly dawn 🤯 REALLY? 😂

sly dawn
#

@drowsy kite yeah

drowsy kite
#

bruh

#

it's a joke

#

eeheh

sly dawn
#

mean like, u make ur own

drowsy kite
#

i guess

sly dawn
#

not to copy from websites

drowsy kite
#

i wil make my embed

sly dawn
#

some value here

#

l o l

drowsy kite
#

with bot commands

#

🤷‍♂️

faint prism
digital ibex
#

that wont work cuz ur not exporting it lol

drowsy kite
#

k

sly dawn
#

to watching or listening

drowsy kite
#

🇵🇹

sly dawn
#

i mean, my status is not appearing, first it worked then it didnt work

drowsy kite
#

i is appearing

sly dawn
#

..

#

my bots status..

drowsy kite
#

ah okay

#

sorry

#

😅

sly dawn
#

bruh have ur eyes open..

drowsy kite
#

😒

sly dawn
#

someone help ^^^^^^^^^^^^

#
haha = new Discord.Client({
  presence:{
    activity:{
      name:`${bot.guilds.cache.size} with ${bot.users.cache.size} users | c!help`,
      type: 'PLAYING',
    }
  }
})``` status not appearing

@sly dawn

drowsy kite
sly dawn
#

what language is that lol

drowsy kite
#

portuguese

sly dawn
#

hello from china

drowsy kite
#

i'm from portugal

#

hello

#

commercial partners @sly dawn

#

ahha

frosty girder
#

for music bots how do i get a non laggy api key any answers?

drowsy kite
#

translate?

opaque eagle
#

non-laggy API key?

open rune
#

I have some portuguese friend

sly dawn
#

espanol

frosty girder
#

cuz all the api keys i've used

drowsy kite
#

I have some portuguese friend
@open rune i have a irish friend

frosty girder
#

were hella laggyy

opaque eagle
#

...

open rune
#

me no Irish

drowsy kite
#

ahah

#

it's other people

frosty girder
#

im saying i got alot of latency in my api keys

#

i wanna know how i can get an api key with less latency

sudden geyser
#

API key for what though.

#

The key is just a key. It probably doesn't have any effect on latency.

faint prism
#

Unless the API doesn't like you

open rune
#

lol

sudden geyser
#

does Discord's API count

faint prism
#

It counts a lot of things

obtuse jolt
#

with this code where is split the values into an array js cmd --text yes lmfao --text jsnfnrn".split("--text");

#

is there a way to only get the value after --text and before any other tags

#

so like
ban 551854789990940699 --reason yeah cool reason --time 4d

#

reason would be yeah cool reason

faint prism
#

yeah

obtuse jolt
#

and time would be 4d

faint prism
#

just split it, and loop over each -- prefix and check if it's a known argument like, text or reason or time, and do the appropriate stuff with the index+1

main chasm
#

member.user / i want get badge user how?

sudden geyser
#

It doesn't contain every badge.

main chasm
#

thank u bro

autumn aspen
obtuse jolt
#

now for the 7 week wait yeah?

autumn aspen
#

now for the 7 week wait yeah?
@obtuse jolt ... yeah 😔 ✊

earnest phoenix
autumn aspen
#

TF

#

lol

obtuse jolt
#

i want the things individually

earnest phoenix
#

Individually?

obtuse jolt
#

yeah so like

#

ban 551854789990940699 --reason yeah cool reason --time 4d
const reason = the reason
const time = the time

autumn aspen
#

Individually?
@earnest phoenix bro tf u cooded that shit

earnest phoenix
#

Yes

proven lantern
#

use .trim instead of doing all those slices

earnest phoenix
#

tr yetkili varmı

proven lantern
#

e.startsWith(" ") dont do this

autumn aspen
obtuse jolt
#

its clearly stock

#

but otherwise i see nothing wrong

hazy sparrow
#

"Everyday and week" wut

autumn aspen
#

its clearly stock
@obtuse jolt wdym

faint prism
obtuse jolt
#

the lines

#

show

#

its downloaded

autumn aspen
#

"Everyday and week" wut
@hazy sparrow lmao Im gonna fix that

hazy sparrow
#

Yeah you should probably

autumn aspen
#

@obtuse jolt wdym is it weird to have the bot pfp like that

obtuse jolt
#

no

stiff orbit
#

hi

#

i wana make a bot

obtuse jolt
#

same

#

@stiff orbit start here https://discord.js.org/#/

stiff orbit
obtuse jolt
#

ew

stiff orbit
#

its easier

gilded plankBOT
slender thistle
#

really

plain mason
#

Hi

obtuse jolt
#

oof

stiff orbit
#

sorry

#

@slender thistle im really sorry

plain mason
#

How i can change my nickname in the server

stiff orbit
#

U CAN'T

obtuse jolt
#

you have to boost the server

stiff orbit
#

lul

faint prism
opaque seal
#

When I do

channels.create(name, {position: positionNumber});

I get different results, most of the time wrong results, in comparison to

channels.create(name)
  .then(async channel => await channel.setPosition(positionNumber));

Can someone explain me why? Is this a bug?

#

Discord.js

earnest phoenix
#

With that you can do

const reason = optionsObj.reason, time = optionsObj.time;```
twilit hare
#

how can I remove a user's reaction right after they click on the bot's reaction?

#
else if (reaction.emoji.name === '🧱') {

                        await m.edit(bridgeembed);  

                        await m.reactions.get('🧱').remove(msg.author.id);
                    
                        awaitReactions(msg, m, options, filter);

                    }
#

i have this

sly hatch
#

static void UpdatePresence() { DiscordRichPresence discordPresence; memset(&discordPresence, 0, sizeof(discordPresence)); discordPresence.state = "Playing Solo"; discordPresence.details = "Competitive"; discordPresence.startTimestamp = 1507665886; discordPresence.endTimestamp = 1507665886; discordPresence.largeImageText = "Numbani"; discordPresence.smallImageText = "Rogue - Level 100"; discordPresence.partyId = "ae488379-351d-4a4f-ad32-2b9b01c91657"; discordPresence.partySize = 1; discordPresence.partyMax = 5; discordPresence.joinSecret = "MTI4NzM0OjFpMmhuZToxMjMxMjM= "; Discord_UpdatePresence(&discordPresence); }

solemn latch
faint prism
#

oh look a secret

solemn latch
#

tell me your secrets

sly hatch
#

Ok

faint prism
#

no, don't lol

sly hatch
#

$argsCheck[>1;Please mention somebody to mute.]
$nomention $unmute[Muted]
$onlyPerms[manageroles;:error:You don't have enough permissions to run this command.]
$title[Mute]
$color[#FF0000]
$footer[Muted by $username.]
$description[

Unmuted: <@$mentioned[<]>
Unmuted by: <@$authorID>
]

thick gull
#

tell me your secrets
ok . . . , , don’t tell anyone . . .

#

one time in kindergarten. . , ,

#

i stole a stuffed bear . . . ,

#

i still have it though , , . .

solemn latch
#

the police have been notified

thick gull
faint prism
thick gull
#

i believ tokens are part of your token date it was made and some thing else

solemn latch
#

123123

thick gull
#

I can’t remember

leaden rover
#

How do I make a disable/enable command? As in discord.py

sly hatch
thick gull
#

rude

solemn latch
#

youll need to have a database

leaden rover
#

Ok

sly hatch
#

Haahha

slender thistle
#

what does the command need to enable/disable

sly hatch
#

How do I make a disable/enable command? As in discord.py
@leaden rover you can make one on mobile

#

I will send you the app

leaden rover
#

No

thick gull
#

???

slender thistle
faint prism
#

joinSecret char* unique hashed string for chat invitations and Ask to

slender thistle
#

you aren't helping with your app

leaden rover
#

S M H

sly hatch
#

No
@leaden rover yes

thick gull
#

no

#

he said discordpy

sly hatch
#

Yes

solemn latch
#

yikes

thick gull
#

not bot builder

slender thistle
#

They literally asked for discord.py
you aren't helping with your app

leaden rover
#

._.

slender thistle
#

what does the command need to enable/disable

sly hatch
#

It's not my app

thick gull
#

@leaden rover Idk much for py, but I can give you the logical aspect,
Check if database has true/false, if it’s true, run command, else, don’t

leaden rover
#

ok

thick gull
#

idk

opal plank
#

jesus

thick gull
#

tried to help in anyway I could

opal plank
#

please dont do that

thick gull
#

dunno py ¯_(ツ)_/¯

opal plank
#

dont pull from your database on every request

#

for the love of god

leaden rover
#

advertiser

serene idol
slender thistle
#

@scenic kelp bit.ly link redirecting to YT above

sly hatch
#

did everyone did say I'm live

serene idol
leaden rover
#

nitro flexing?

opal plank
#

py surely has a a memory way to order or map guilds like that

sly hatch
#

:v

opal plank
#

at the minimum, use redis

thick gull
#

^

sly hatch
#

🧃

leaden rover
#

lol redis

thick gull
#

was supposed to be a simple basic explanation erwin

opal plank
#

do NOT do database queries on EVERY command

sly hatch
opal plank
#

thats simply stupid and inneficient

leaden rover
sly hatch
#

give me cold

opal plank
sly hatch
#

And you token

leaden rover
sly hatch
#

And you Bot username

leaden rover
#

no

sly hatch
#

Yes

leaden rover
#

fight me

sly hatch
#

Touch me

#

You set on fire

leaden rover
sly hatch
#

You

slender thistle
#

You both can leave this shit for #general

sly hatch
#

you said fight me

leaden rover
#

ok

slender thistle
#

or even better, DMs

opal plank
#

^^^^

sly hatch
#

Language: Clojure
Library: JDA
Code:
project.clj
...
:dependencies [[cheshire "5.8.0"]
[clj-http "3.7.0"]
[net.dv8tion/JDA "3.4.0_320"]
[org.clojure/clojure "1.9.0"]]
:repositories [["jcenter" "https://jcenter.bintray.com"]]
;:jvm-opts ["--add-modules" "java.xml.bind"] ; if using Java 9 uncomment this

core.clj
(ns dbl-server-stats.core
(:require [cheshire.core :as cheshire]
[clj-http.client :as client])
(:gen-class)
(:import (net.dv8tion.jda.core AccountType JDABuilder JDA)
(net.dv8tion.jda.core.hooks ListenerAdapter)
(net.dv8tion.jda.core.events ReadyEvent Event)
(net.dv8tion.jda.core.events.guild GuildJoinEvent GuildLeaveEvent)))

(defn update-server-stats
"Sends a POST request with the new server count for the bot-id."
[bot-id token stats]
(let [api-url "https://discordbots.org/api/"
body (cheshire/generate-string stats)
headers {"Authorization" token}]

(-> (str api-url "bots/" bot-id "/stats")
    (client/post {:body body
                  :headers headers
                  :content-type :json
                  :accept :json}))))

(defn bot-stats
"Create stats map from the JDA api object"
[^Event event]
{:server_count (-> event
.getJDA
.getGuildCache
.size)})

(defn listener-adapter [bot-id token]
(proxy [ListenerAdapter] []
(onReady [event]
(let [stats (bot-stats event)]
(println "onReady:" stats)
(update-server-stats bot-id token stats)))))

(defn -main
[& args]
(let [bot-token "discord-api-bot-token"
bot-id "dbl-bot-id"
token "dbl-api-token"
jda (-> AccountType/BOT
JDABuilder.
(.setToken bot-token)
(.addEventListener (object-array [(listener-adapter bot-id token)]))
.buildBlocking)]))

slender thistle
#

why paste that here

earnest phoenix
#

Codeblocks exist

#

Bins exist

#

please bins

#

but seriously we need a rule implemented about walls of code

thick gull
#

I can’t tell what that is

#

is that his code, docs?

#

error?

#

idk

#

he did post a bot designer link when someone asked for py help

earnest phoenix
#

I think he trying to flex cuz we don't know the language

slender thistle
#

Language: Clojure
Library: JDA

earnest phoenix
#

clojure is elixir on crack

#

He told us the language, lib and code but not the issue

#

Very helpful indeed

#

How do I get json files of 5 people separately

const derece = [];
for (var i = 0; i < canli.participants.length; i++) {
  if (canli.participants[i].teamId === 100) {
  const mavitakimderece =   `https://tr1.api.riotgames.com/lol/league/v4/entries/by-summoner/${canli.participants[i].summonerId}?api_key=${apikey}`
  let res;
  res = fetch(mavitakimderece).then(url => url.json())
  derece.push(`${oh[res.tier]} ${res.rank} (${res.leaguePoints} LP)`)
  }
}
embed.addField('Derece', derece.length ? derece.join("\n") : "Yok.",true)
#

5 people "seperately"?

#

"json files"

no trace of json files

#

url.json()

#

yeah that's not a json file lol

misty sigil
#

thats a json response

#

not a file

earnest phoenix
#

that's parsing the response body as an object

#

Yea it's kinda of object

#

Hi I have a question

#
embed.add_field(name = "I choose " + random.choice(choices),value = "")
#

If I put the field like this

#

Will it display a blank space in second line

#

no

slender thistle
#

why not use title or description or author instead of blank field value

earnest phoenix
#

insert a zero width space, both the field name and value have to have a value

faint prism
#

not sure it allows that

earnest phoenix
#

it does

slender thistle
#

\u200b for life

earnest phoenix
#

\u200b right

#

discord allows zwsp or any char for that matter as long as there's just something

#

Oh I see thank you very much

#

I think discord allows almost every unicode char possible

#

The scariest one such as \u202B

#

luckily zalgo text gets normalised

faint prism
#

lol

cobalt spruce
#

Guys can u edit embed color ?

thick gull
#

yes

slender thistle
#

Please VBA tell me in which living God's name Sqr(b * WorksheetFunction.Power(x, 2)) is 0 where b is 2.07 and x is 2.3

cobalt spruce
#

how ?

thick gull
#

same way you'd edit any embed

earnest phoenix
#
<MessageEmbed>.setColor()```
cobalt spruce
#

@earnest phoenix but how to edit

thick gull
#

<message>.edit(<MessageEmbed>)

earnest phoenix
#

Get the message embed instance and edit

thick gull
#

^

earnest phoenix
#

you need to rebuild the whole embed

cobalt spruce
#

Ok

earnest phoenix
#

Not really

#
let sendEmbed = await message.channel.send(embed);

sendEmbed.embeds[0].color = "#0033ff";

sendEmbed.edit({
embed: sendEmbed.embeds[0]
});```
#

Something like this can be done also

fluid orbit
earnest phoenix
#

waitWhat uhh

fluid orbit
#

this is a map ^ but client.reactions.get(reaction.emoji.name) is not working idk why

earnest phoenix
#

How's it not working exactly

fluid orbit
#

it return undefined

earnest phoenix
#

Where is it used on?

#

Reaction collector?

fluid orbit
#

it's a reaction handler

earnest phoenix
#

Can i see it's structure?

fluid orbit
#

i think it doesn't matter it's a map right? it works like this client.reactions.get('⏹') but i don't know why it doesn't work with variables

earnest phoenix
#

Maybe you're using different unicode emojis?

fluid orbit
#
if (reaction.emoji.name === '⏹️') {
            console.log('test')
        }
#

i add this to check and it should be the same

earnest phoenix
#

¯\_(ツ)_/¯

fluid orbit
#

my brain stopped

faint prism
#

Hm, wondering if it's normal to see 500 errors during API performance testing

earnest phoenix
#

Nah some guy got 800 errors

#

How do I use node-fetch in a for loop?

faint prism
#

are you sure you want to do that?

#

without a sleep in there it's kinda spammy

earnest phoenix
#

yes.

#

Here is what I want to do.

const derece = [];
for (var i = 0; i < canli.participants.length; i++) {
if (canli.participants[i].teamId === 100) {
let mavitakimderece = `https://tr1.api.riotgames.com/lol/league/v4/entries/by-summoner/${canli.participants[i].summonerId}?api_key=${apikey}`
let mavitakimderecesi;
mavitakimderecesi = await fetch(mavitakimderece).then(url => url.json())
derece.push(`${oh[mavitakimderecesi.tier]} ${mavitakimderecesi.rank} (${mavitakimderecesi.leaguePoints} LP)`)
 }
}   
embed.addField('Derece', derece.length ? derece.join("\n") : "Yok.",true)
#

${canli.participants[i].summonerId} will return 5 users.

#

I want to pull users' information from json

opal plank
#

wtf is this

earnest phoenix
#

buddy i'm a beginner yet.

#

I made too many mistakes maybe

sonic lodge
#

besides that there's nothing stopping you from using fetch in a for loop, aside from the fact that you might get rate limited from many fetches in quick succession

opal plank
#

its not that

#

why declare a variable

#

and then assign it right after?

#
let mavitakimderecesi = await fetch(mavitakimderece).then(url => url.json())
earnest phoenix
#

How do I use node-fetch in a for loop?
@earnest phoenix push promise of the fetches to an array, then Promise.all(...arr)

sonic lodge
#

yeah that's just

earnest phoenix
#

have you tried reading the docs

sonic lodge
#

i am so utterly confused right now

#

here's my code

#
const message = await channel.send('test');
const deleteReaction = await message.react('🗑️');
console.log(message);
console.log(deleteReaction);```
#

and these are the beginnings of the two console.logs

#

how in the world is the reaction's channel a DMChannel?

earnest phoenix
#

that's

#

weird

#

try calling fetch() on the reaction

#

(it's a promise)

opal plank
#

huh

#

im fairly certain its void

#

holdup

earnest phoenix
#

it's a promise

#

anything that needs to make a REST request is a promise

opal plank
#

oh shit it actually returns the message

#

today we learned

earnest phoenix
#

uh

sonic lodge
#

now i get

(node:15044) UnhandledPromiseRejectionWarning: DiscordAPIError: Invalid Form Body
channel_id: Value "undefined" is not snowflake.```
opal plank
#

and this too

earnest phoenix
#

the issues seem to be internal

#

what's the version you're on

opal plank
#

actually wtf im on about? i knew about it

sonic lodge
#

12.2.0

opal plank
#

im dumb, sorry

sonic lodge
#

i'ma update d.js and see if that's the issue

earnest phoenix
#

try uninstalling then reinstalling djs

calm mesa
#

What is the best website for coding?

earnest phoenix
#

what do you mean by that

opal plank
#

for LEARNING to code?

#

the best website for coding is the one you download VSC from mmulu

earnest phoenix
#

"what's the best tool for fixing my car"

calm mesa
#

Should I use discord.js lol

opal plank
#

i'd say go for it

#

d.js is decent

#

its actually really good

calm mesa
#

Alr

opal plank
#

untill it isnt

clever marsh
#

Is there a chat channel?

opal plank
earnest phoenix
#

literally look a few channels single channel above this one

clever marsh
#

Thanks G

sonic lodge
#

i guess it was internal

#

the issue is gone, thanks

drowsy kite
#

how do i put a image

earnest phoenix
#

read the docs

drowsy kite
#

okay

opal plank
#

fairly certain thats Portuguese

earnest phoenix
#

fairly certain thats spanish

opal plank
#

Nope, thats definetly portguese

runic sapphire
#

Hello, can you explain to me how to publish my bot, I don't speak English very well

opal plank
runic sapphire
#

I know I already published it p...

misty sigil
#

@runic sapphire you don’t

#

you wait for approval

#

6+ weeks rn

runic sapphire
#

but another thing, because my name is white

hasty mulch
#

So, the bot is coded in Python @midnight blaze

midnight blaze
#

Can't help then

#

I am jsler

runic sapphire
#

because my name is white

midnight blaze
#

Fairly certain that's a 5head

runic sapphire
#

what?

#

I do not understand?

sudden geyser
#

@runic sapphire your bot is probably still in the queue

slate oyster
#

Hey guys
I'm hitting the quota on searching for youtube videos
Actually playing videos by URL works fine though
I was wondering if there was an alternate API for searching for youtube videos that does not have a quote?
What do people here do?

opal plank
#

i dont fuck with youtube, or music at all at that, but i'd say check spotify's api

sudden geyser
#

You can't stream with Spotify.

#

It's against their ToS to my knowledge.

slate oyster
#

Oh

opal plank
#

so is youtube

sudden geyser
#

~~if it is then one more reason to not make a music module ~~

slate oyster
#

This is where not having a credit card really hurts me
If I had a credit card, I could just pay to increase my quota
In fact, Google gives a free $200 to people with credit cards

#

Somebody has got to have made a knock-off web scraper API, so I'm going to search for that

runic sapphire
#

*help

hasty mulch
runic sapphire
#

sorry

#

:c

#

I am new and I do not understand some things

earnest phoenix
#

@slate oyster scraping youtube is your best bet

#

tools like youtube-dl can do that but there's probably an existing library for your language already

slate oyster
#

The scraper I found requires in my language running a webserver
But I wonder if it can be modified to work without

earnest phoenix
#

thonk

#

what language are you using

slate oyster
#

Java

unreal solar
#

anyone?

faint prism
#

Means a syntax error

unreal solar
#

idk how to fix it tho

faint prism
#

Get your syntax right

unreal solar
#

ok

#

thx

sudden geyser
#

Whatever you put is unexpected, so check the code around that statement.

unreal solar
#

i tried didnt work

faint prism
#

i tried didnt work
@unreal solar So you're saying your syntax is perfect and the error about syntax persists?

sudden geyser
#

can you show your code

faint prism
unreal solar
#

ok

#

hold up

hasty mulch
#

LUA?

earnest phoenix
#

close your play function

#

...which you just copypasted

#

lol

unreal solar
#

oof my friend did the music i guess he copy pasted xD

earnest phoenix
#

i didn't ask

unreal solar
#

whatever

#

thats all i had

#

to do

#

someone kill meee uggggggg

hasty mulch
#

Welcome to the club

#

One thing wrong and sometimes we can’t see it ourselves

slate oyster
#

Well, at least the ratelimits are not preventing people from using my bot (:

#

I'm going to go onto Google Console and look at what that quota was even set at

#

(I'm on my computer now)

earnest phoenix
#

can't you use lavaplayer?

hasty mulch
#

Google is hosting your bot?

slate oyster
#

@earnest phoenix It's searching songs that is the problem, not playing songs. LavaLink works great for playing songs
@hasty mulch No. I just use it for music, but I am getting ratelimitted

earnest phoenix
#

i'm aware

#

i also mentioned lavaplayer, not LL

#

lavaplayer has a youtube scraper built in

#

you can use that

slate oyster
#

Oh, gotcha
I'll check it out
Thanks!

sudden geyser
#

@faint prism he was already right when he said that. It's well known this server serves more as a place for beginners

slate oyster
#

@earnest phoenix Also, since I think LP is just a wrapper around LL IIRC, and the API looks similar, it should be easy to port

earnest phoenix
#

other way around

#

LL is wrapping around LP

#

LL is just a webserver, LP is the brains

slate oyster
#

@earnest phoenix Wait no I got it mixed up lol
I'm already using LP not LL, oof
Embarrassing

I can't even remember which libraries I am using

So I just gotta figure out the API used for scraping

#

(EveryOS is stupid)

earnest phoenix
#

if you're already using LP you can just let it search for you, no?

slate oyster
#

Yea
I'll have to look for the API to do that
I'll continue to use the official API as my main approach, and use the web scraper as a fallback
Thanks, did not realize LP had a web scraper

frigid spruce
#

That's not Lua, that's JS. There's some similarities though.

#

Man discord.js is really neat

#

I had no idea they had something called MessageCollector

solemn latch
#

explore the docs and the guide

#

lots of neat little useful things

zinc condor
#

im working on the project KM_Dorime

umbral zealot
#

TIME TO PLAY CODE GOLF, BOYS

#

Oh it's see pee pee, nevermind.

earnest phoenix
#

how would one go about checking if a user has a Specific role in a discord to be able to use a command in another ?

#

would that need a check for the user in the guild and has_role?

opal plank
#

wait what?

earnest phoenix
#

errrr

opal plank
#

roles ids are unique iirc

#

so doing that wont work in the first place

#

you cant compare two different guilds roles

#

unless you using name, which is tbh not a very good way of doing things

#

though if you just want the target role in a guild

#

and you are not comparing

solemn latch
#

do you mean a main guild?
like your bots home guild?

earnest phoenix
#

yes

opal plank
#

i have something similar for my private commands

#

keep stored the guild id

earnest phoenix
#

so, ID > Name

opal plank
#

thats it

#

get use from member list in that guild

solemn latch
#

then get the member object in that guild(if it exists)
then check the role in that guild

opal plank
#

and check role

#

thats it

#

command in guild 1 => get user id => get guild 2 => get member list => get member by user id => check role => //do stuff @earnest phoenix

earnest phoenix
#

Thank you ❤️

opal plank
lost forge
#

heloo

#

what is Bot Developer role mean?

opal plank
#

means at least one of the bot s we submiteed got approved @lost forge

keen hemlock
#

how long does it take usually for your bot to get approved?

opal plank
#

5+ weeks

keen hemlock
#

oooooof

hasty mulch
#

How do I open the webhook_port?

#

Using Python and a Raspberry Pi

solemn latch
#

like port forwarding?

fluid basin
#

@opal plank its 6+ weeks btw

hasty mulch
#

“Before using the webhook provided by this library, make sure you have the specified port open.
webhook_port must be between 1024 and 49151”

solemn latch
#

I think thats referring to port forwarding.
https://portforward.com/
it depends on your router this site lists a ton of methods for specific routers

hasty mulch
#

So, I can’t get a server count then?

solemn latch
#

who said that?

#

just port forward 🤔

hasty mulch
#

Not my internet plan

solemn latch
#

f?

opal plank
#

what?

#

port fowarding is on the router

solemn latch
#

🤷‍♂️

#

wait you want to post stats? you dont need a webhook for that right?

hasty mulch
#

I don’t have access to the credentials @opal plank

opal plank
#

oh, fat rip then

#

just factory reset it

solemn latch
#

^ its probably factory password or written on the router

hasty mulch
#

No, it was changed

#

And if I reset it, it’ll piss off a certain person

opal plank
#

nginx i guess?

#

or proxy

#

or politely ask the owner of the router

hasty mulch
#

If I can figure out how to proxy, maybe

quartz kindle
#

you dont need the webhook for server count

earnest phoenix
#

why

#

?

#

do u have node js installed

#

?

#

yes

#

do u have it added to ur %PATH%

#

wait

#

C:\Users\USERNAME\AppData\Roaming\npm

#

hm

#

did u use the installer

#

from the node website

#

cause im pretty sure node adds it self to the path var

#

yes

#

hmmmmmmmmmmmmmmmmmm

#

well

#

idk on this one

#

watch him downloading it from some sketchy website

#

why?

#

to help me

#

i mean really this is a pretty simple situation

#

either ur node install f'ed up

#

or

#

it just didnt get added to the path

#

C:\Program Files\nodejs\

#

u should also check there

#

and now how do you add

#

well u should add C:\Program Files\nodejs\

#

to ur system path enviroment variable

#

HERE?

#

yeah u have to add that folder to ur system path

#

find a video on how to do it online because i dont feel like explaining the full thing

#

PLS LINK?

#

i found this in 2 seconds

#

enjoy

#

TY

clever dust
#

also please turn off caps lock

karmic compass
#
            await message.guild.channels.create("info", { 
                type: "text",
                topic: "Information",
            })
``` how can i add permissions to this so that way the everyone role can't see it?
earnest phoenix
#

the folder I have to put it as you say because he does it for python while I want it for python?

#

just change what he puts to the node js path

#

that i sent

#

i mean if u want python put python if u have it downloaded

shy turret
earnest phoenix
#

yes but I write it in js it will not work fail?

shy turret
#

python <> nodejs

karmic compass
#

can anyone answer my question above?

fluid basin
#

check your docs

karmic compass
fluid basin
#

options.permissionsOverwrites

#

¯_(ツ)_/¯

shy turret
karmic compass
#
(node:23296) UnhandledPromiseRejectionWarning: TypeError: permissionOverwrites.map is not a function
    at GuildChannelManager.create (C:\Users\email\Desktop\coding\KrossBot\node_modules\discord.js\src\managers\GuildChannelManager.js:109:51)
    at C:\Users\email\Desktop\coding\KrossBot\index.js:271:46
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:23296) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an 
async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 3)
(node:23296) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
``` ```js
                await message.guild.channels.create("kross-logs", { 
                    type: "text",
                    topic: "KrossBot Logs and Information",
                    permissionOverwrites: {
                        READ_MESSAGES: false
                    }
                }) 
#

@fluid basin any ideas?

umbral zealot
#

permissionOverwites needs to be an array

#

specifically an array of objects.

karmic compass
#

how so?

shy turret
#

array: []

karmic compass
#

i know what an array is

shy turret
#

using []

earnest phoenix
#

so use it ?

karmic compass
#

i'm a bit confused on what i put there

midnight blaze
#

you know what a variable is?

karmic compass
#

yes

midnight blaze
#

(jk)

karmic compass
#

god

umbral zealot
#

Do you know what an array is?

karmic compass
#

yes i know, how do i define the permissions inside of it

shy turret
#
                    permissionOverwrites: [{
                        READ_MESSAGES: false
                    }]

might be wrong but

karmic compass
#

aah

umbral zealot
karmic compass
#

that makes more sense

shy turret
#

[{"json":"here"}]

umbral zealot
earnest phoenix
#

(waiting for the mofo to start talking about associative arrays and the guys head explodes)

shy turret
#

[{"json":"here"}, "etc", null, 123]

umbral zealot
#

@shy turret please never refer to an object as "JSON" 😛

shy turret
#

nu kk

midnight blaze
#

you ok two?

umbral zealot
#

JSON is a string, Objects are Objects. There is no such thing as a "JSON Object"

shy turret
#

no

#

i am not ok

earnest phoenix
#

man that was 3 mesages deleted as once

karmic compass
#
node:19552) UnhandledPromiseRejectionWarning: TypeError [INVALID_TYPE]: Supplied parameter is not a User nor a Role.
#
                    permissionOverwrites: [{
                        "READ_MESSAGES": false
                    }]
umbral zealot
#

ok what are you overwriting?

earnest phoenix
#

umm hate to say it

karmic compass
#

hcannel perms

umbral zealot
#

what role or user?

earnest phoenix
#

Json objects do exist

karmic compass
#
             await message.guild.channels.create("kross-logs", { 
                    type: "text",
                    topic: "KrossBot Logs and Information",
                    permissionOverwrites: [{
                        "READ_MESSAGES": false
                    }]
                }) 
#

everyone

umbral zealot
#

Ok so you need to tell it you're overwriting the everyone role

karmic compass
#

lemme guess

umbral zealot
#

its ID is the same as the guild's id

karmic compass
#

permissionOverwrites: [guild.roles.everyone, { etc..

umbral zealot
#

@earnest phoenix no, W3Schools is source of that shit and they're wrong. JSON objects are not a thing in javascript.

earnest phoenix
#

i never said json objects are a thing in java script

#

i just said that json in general has json objects

umbral zealot
#

No, JSON is a string which contains javascript data structures.

midnight blaze
#
guild.channels.create('new-voice', {
  type: 'voice',
  permissionOverwrites: [
     {
       id: message.author.id,
       deny: ['VIEW_CHANNEL'],
    },
  ],
})
earnest phoenix
#

u know what im not going to start this lmao

karmic compass
#

hmm

#

ah

umbral zealot
#

It confuses the noobs to talk about JSON Objects because those 2 words are different concepts in javascript.

midnight blaze
#

lvl 100 when enters a lvl 1 arrea

earnest phoenix
#

objects are different in most langs?

umbral zealot
#

We are specifically talking about JavaScript.

earnest phoenix
#

yeah ig

umbral zealot
#

lvl 100 when enters a lvl 1 arreaa
p0wn3d

karmic compass
#

how do i get the id of everyone?

quartz kindle
#

the everyone role has the same id as the guild

karmic compass
#

ah

#
(node:24524) UnhandledPromiseRejectionWarning: DiscordAPIError: Invalid Form Body
permission_overwrites[0]: List item values of ModelType are required
    at RequestHandler.execute (C:\Users\email\Desktop\coding\KrossBot\node_modules\discord.js\src\rest\RequestHandler.js:170:25)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:24524) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an 
async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:24524) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
``` ```js
                await message.guild.channels.create("kross-logs", { 
                    type: "text",
                    topic: "KrossBot Logs and Information",
                    permissionOverwrites: [, {
                        id: message.guild.id,
                        deny: ['VIEW_CHANNEL'],
                    }]
                }) 
#

wait a sec

umbral zealot
#

why is that extra , in there

midnight blaze
#

[,

karmic compass
#

welp

#

big dumb poggers!

umbral zealot
#

you just need to pay more attention to details ¯_(ツ)_/¯

solemn latch
#

also your ide will generally highlight close to the cause of the error

quartz kindle
#

technically thats a valid array

#

so the ide wont complain

earnest phoenix
#

its a valid array

#

not valid json

solemn latch
#

{"thingy": [],}
is valid?

earnest phoenix
#

json requires that a hanging comma be removed

quartz kindle
umbral zealot
#

@earnest phoenix this isn't JSON, it's a normal javascript array.

#

smh

earnest phoenix
#

then why call it json

#

bruh

umbral zealot
#

I didn't

solemn latch
#

oh hey, looks like tims right 🤔

umbral zealot
#

The error is because each array element needs to be an object which specific values, and [, {}] creates a null value

earnest phoenix
#

u are right u didnt call it json it was the other guy

#

why did that guy bring up json here lmao

umbral zealot
#

¯_(ツ)_/¯

lucid wharf
#

Q_Q help

#

plzz

umbral zealot
#

need to see code

lucid wharf
solemn latch
#

instead of building an embed in each loop in the for loop, do one embed and add the respective data in that loop.

earnest phoenix
#

u can edit embeds after they have been sent to the channel

#

so u can also do it that way

lucid wharf
#

@solemn latch Tried adding the 'embed' before the for and the message.channel.send(embed) also when terminating after the for

solemn latch
#

editing would add more api calls for no real reason though.

umbral zealot
#

just define const embed outside the loop

#

then set its fields inside of it

#

though, watch for the limits of embed fields.

#

And overall embed limits

lucid wharf
#

yes?

#

in this way?

umbral zealot
#

yes, but embed.setColor

#

since you need to call that variable

lucid wharf
#

OH

solemn latch
#

dont need to set the title color thumb thumbnail and author in each loop i dont think.
would be more efficent to do those outside the loop.
only do the things you need to loop over in the loop

lucid wharf
#

Ok now it does it right, the problem is that now it doesn't print every .setThumbnail and I only get 1.. what could I do?

solemn latch
#

only one thumbnail per embed afaik

lucid wharf
#

Q_Q #crying

#

many thanks ❣️

midnight blaze
#

make an embed with reactions that edit the embed 🤔

charred geyser
#

if i am searching for somehthing using a regex

#

and i get four results

#

one is an array and the others are null

#

how do i get just the array

earnest phoenix
#

Filter out the null

#

And filter out the non array

charred geyser
#

using .filter just says cannot read property of null

earnest phoenix
#

Check if the thing is null

#

If yes then ignore it

charred geyser
#

how can i check though

#

the result is one variable

earnest phoenix
#

if (object === null)

charred geyser
#

but what is object

#

the result is one variable

earnest phoenix
#

Alright so

#

What did you get from the regex?

charred geyser
#

it is searching a few files for a string

#

so some files return null

earnest phoenix
#

So it return an array?

charred geyser
#

and some give the srtring in an array

#

not really

earnest phoenix
#

Did it return

#

"[]"

#

or

#

[]

#

You lnow what

#

@charred geyser show me your code

charred geyser
#

k one sec

#
  fromDir(dir, /\.txt$/, function (filename) {
    fs.readFile(filename, function (err, data) {
      if (err) throw err;
      let regex = new RegExp(
        "example"
      );
      let str = data.toString();
      var res = str.match(regex);
      console.log(res);
    });
  });
#

this is the bit where it is searching each file in the directory

#

for a folder with the .txt extention

#

for an "example" regex

#

and the result is:

#

null

#

null

#

[
whatever string it finds
]

#

null

earnest phoenix
#

Show me what res is

charred geyser
#

its very long

#

for my example

forest iris
#

How can you make a Simon says bot

charred geyser
#

bruh

forest iris
#

How can you

charred geyser
#

this is not the place to ask

forest iris
#

...

charred geyser
#

this is for help with specific development issues or challenges

#

not just telling people how to make bots

earnest phoenix
#

Seasnail

#

I dont understand what youre trying to say

#

You mean if the file doesnt return anything, it will return []?

charred geyser
#

okay so for each file it is searching for a string that fits the regex and if it doesn't find anything it will return null for each file and if it fiinds something in one file it will return with an array for just that file but still null for the other files

#

so if i have

#

example1.txt
example2.txt
example3txt
example4.txt

#

it searches the four files

#

and it will console log what it finds

#

so

#

example1 2 and 3 will be null

earnest phoenix
#

So

charred geyser
#

and 4 will be [the string that it found]

earnest phoenix
#

If i understand correctly

#

File1 - null
File2 - null
File3 - null
File4 - []

charred geyser
#

yeah

earnest phoenix
#

Ok

#

You can just check if the respond is null

charred geyser
#

but iit is not always file 4 = []

#

how would i check?

earnest phoenix
#

if (res == null)

#

This is show you do it

charred geyser
#

if res = null then what though?

earnest phoenix
#

or you can do

#

if res != null

charred geyser
#

okay

#

so not i have

#
      if (res == null) {
        return;
      }
      console.log(res);
earnest phoenix
#

Remove {}

charred geyser
#

this will just log the array

earnest phoenix
#

as its one line

charred geyser
#

oh yeah okay

#

still

earnest phoenix
charred geyser
#

now it just logs the array which is good

#

lol

#

thank you @earnest phoenix

earnest phoenix
#

Np

charred geyser
#

you have been very helpful i appreciate it

solemn latch
#

another way you could do it is

if(res) console.log(res);
#

if your only goal is to log it

earnest phoenix
#

I want to make my embed show my bots total servers and total members in all servers...
The servers line works.. but users doesnt..

Whats an easy way of doing this or do i have to loop the guilds for member counts?

    embed.add_field(name="Server Count", value=f"{len(self.bot.guilds)}", inline=True)
    embed.add_field(name="Users Watched", value=f"{len(self.bot.guilds.member)}", inline=True)
earnest phoenix
#

@earnest phoenix bot.guilds.member?

#

yeah that didnt work

#

@earnest phoenix the embed just didnt send.. i got it to work by makeing a for loop but wanted a simpler way

#

not used to python but pretty sure members without the s means the member object for the bot

copper cradle
#

having good grammar always helps

obtuse niche
#

I want to make my embed show my bots total servers and total members in all servers...
The servers line works.. but users doesnt..

Whats an easy way of doing this or do i have to loop the guilds for member counts?

    embed.add_field(name="Server Count", value=f"{len(self.bot.guilds)}", inline=True)
    embed.add_field(name="Users Watched", value=f"{len(self.bot.guilds.member)}", inline=True)

@earnest phoenix i used a loop yes for the total member count

earnest phoenix
#

@earnest phoenix .guilds returns the bots List of guilds and members will return a List of members for a guild but the problem with running .guilds.members is thats its trying to sort a List of a List and it freaked out on me

#

you didn't put the s

#

i had tried it before

#

sorry didnt say that

#

ok

#

its fine

#

i just ran a loo

#

loop and all is good

#

no links ?

#

he deleted

#

the message sender deleted

slender thistle
#

@earnest phoenix sum([guild.member_count for member_count in self.bot.guilds])

earnest phoenix
#

so thats looping the count in .guilds and saving to variable guild.member_count?

#

@slender thistle

slender thistle
#

It creates a list with member_count of all guilds the bot is, and gets sum of it

earnest phoenix
#

@slender thistle guild isn't set.. sorry i am still learning and trying to wrap my head around how this is working.

#

it needs to loop the bot.guilds to get the guild.id

#

people will respond when they can

#

i wouldnt ping people unless they ping you first

clever wren
#

ok

slender thistle
#

@earnest phoenix for guild