#development

1 messages · Page 693 of 1

stray garnet
#

so <table></table>?

earnest phoenix
#

essentially yes

modern elm
#

How would I handle specific permissions errors in my command handler?

quartz kindle
#

check for permissions before attempting to do it

modern elm
#

I know

#

but like

#

how would I catch a permissions error and then send a message to the channel saying something like

I need ${permissionserror} permissions to be able to do that!

wooden lance
#

All of the modules I just installed onto my debian (node.js) VPS but no modules's commands are working. Anyone know how to fix this? -bash: screen: command not found

earnest phoenix
#

install screen

#

or even better tmux

wooden lance
#

it is installed.

copper cradle
#

reboot

wooden lance
#

okay

#

restart the hardware or software?

#

i really have no clue what the difference is lol

copper cradle
#

._.

#

the vps

#

just run the reboot command

wooden lance
#

i just have the VPS's panel open all the time lol

#

i can just hit reboot

copper cradle
#

do it

wooden lance
#

didnt work

#

you there?

inner jewel
#

you shouldn't need to reboot after installing stuff

abstract crow
unique nimbus
#

qt

#

I wanna know how to do that

#

😩

abstract crow
#

thx

#

React 🙂

#

React and Express

unique nimbus
#

Give code

#

all of it

#

zip it up

#

fax it to me

abstract crow
#

I would work on a project with you and do that if you want

#

I would love to collab in general with someone

unique nimbus
#

I dont even know React and Express oof

abstract crow
#

Do you know JS?

unique nimbus
#

No lmao

abstract crow
#

oof

unique nimbus
#

I need to learn

#

:c

abstract crow
#

lol

#

Messy af

#

But I like colors so I have plugins for that

unique nimbus
#

that looks kinda easy but I cba to learn

abstract crow
#

lol

#

I mean it isn't hard. For me it is just tricky as I am still learning React, but you just gotta think outside of the box 🙂

unique nimbus
#

I got confused learning js

abstract crow
#

wut

unique nimbus
#

so 😩

abstract crow
#

I learned that a year ago when I was 12

unique nimbus
#

python doesnt have the {

abstract crow
#

Yeah

unique nimbus
#

Well I didnt

#

at 12 I was playing Minecraft

abstract crow
#

lol

#

sorry I came off rude lol

unique nimbus
#

its fine

#

I am retardation in general

abstract crow
unique nimbus
#

yeet

abstract crow
unique nimbus
#

make it glow on hover

abstract crow
#

I made all of the icons move up on hover

#

But the VIP glow

#

bad gif but it is the same on both

#

the first hover just got cut off lol

unique nimbus
#

epic

indigo geyser
#

#6666

#

(Epic#6666)

rugged bramble
#

python is a good language to program a discord bot?

#

i already learn a bit of Java and a lot of JS

winged thorn
#

python is good if you already know it

#

otherwise not beginner friendly

warm marsh
#

Python is probably one of the easier languages to learn as a beginner.

unique nimbus
#

Python is by far the easiest to learn

zealous veldt
#

It's syntax is yuxky

modern elm
#

^

#

Its*

#

lol

broken shale
#

js > py

zealous veldt
#

Let's not start a language war

#

Keep things civil and back up your claims with real, valid arguments lmao

modern elm
opaque eagle
#

Don’t use JSON as a database

modern elm
#

Yeah

#

thanks for that

#

🙄

unique nimbus
#

json is a bad database

#

it can break

slender thistle
#

It can break from constant writing data into it

#

But really, as long as you know how to prevent that, it's ok

modern elm
#

does anyone want to address the actual problem or no

unique nimbus
#

you didnt define it :^)

modern elm
#

define what?

#

@unique nimbus

unique nimbus
#

the id

modern elm
#

um

#

yeah i did FatThonk

#

@unique nimbus isnt it already defined because I defined the user?

amber fractal
#

I swear no one understands the errors for some reason

#

You're trying to set a property of an object which is not defined

modern elm
#

yes

#

but im defining the object ;-;

amber fractal
#

idek where it's erroring at because we dont have a full trace back

#

it should say the line

modern elm
#
(node:3603) UnhandledPromiseRejectionWarning: TypeError: Cannot set property '460935884666044427' of undefined

at Object.exports.run (/app/commands/mute.js:46:26)

at Client.bot.on (/app/index.js:235:37)

    at emitOne (events.js:116:13)

    at Client.emit (events.js:211:7)

    at MessageCreateHandler.handle (/rbd/pnpm-volume/6db9c604-aacf-48f2-8d74-f4b97a1b4a80/node_modules/.registry.npmjs.org/discord.js/11.4.2/node_modules/discord.js/src/client/websocket/packets/handlers/MessageCreate.js:9:34)

    at WebSocketPacketManager.handle (/rbd/pnpm-volume/6db9c604-aacf-48f2-8d74-f4b97a1b4a80/node_modules/.registry.npmjs.org/discord.js/11.4.2/node_modules/discord.js/src/client/websocket/packets/WebSocketPacketManager.js:103:65)

    at WebSocketConnection.onPacket (/rbd/pnpm-volume/6db9c604-aacf-48f2-8d74-f4b97a1b4a80/node_modules/.registry.npmjs.org/discord.js/11.4.2/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:333:35)

    at WebSocketConnection.onMessage (/rbd/pnpm-volume/6db9c604-aacf-48f2-8d74-f4b97a1b4a80/node_modules/.registry.npmjs.org/discord.js/11.4.2/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:296:17)

    at WebSocket.onMessage (/rbd/pnpm-volume/6db9c604-aacf-48f2-8d74-f4b97a1b4a80/node_modules/.registry.npmjs.org/ws/4.1.0/node_modules/ws/lib/event-target.js:120:16)

    at emitOne (events.js:116:13)

(node:3603) 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(). (rejection id: 1)

(node:3603) [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.
amber fractal
#

bot.mutes[toMute.id] = {

#

do this

#

console.log(bot.mutes)

modern elm
#

ok

inner jewel
#

bot.mutes is undefined

amber fractal
#

basically what natan said, but i was just gonna have you figure it out yourself mmLol

broken shale
#

also I feel like that's css markdown

modern elm
#

yeah it was

broken shale
#
  • he needs spoonfeeding
modern elm
#

wrong paste

broken shale
#

don't use css for js errors

modern elm
#

ok

amber fractal
#

why not?

#

in js it looks dumb

modern elm
#

exactly

amber fractal
#

it's just more colored

modern elm
#

but ya know

earnest phoenix
#

it literally doesn't matter

modern elm
#

im not gonan argue

amber fractal
#

^

broken shale
#

¯_(ツ)_/¯

amber fractal
#

Also, make a check in your code so if bot.mutes isnt defined, make it

earnest phoenix
#

instead of getting triggered over the color, it would've been better to suggest to use a paste service to not clutter the chat with long error messages

amber fractal
#

or in your index file (or whatever you call it) define it where it wont be ran more than once

#

like right after you define bot

modern elm
#

i figured it out

#

thx for the help

lusty dew
#

@meager goblet I know it’s not returning it I haven’t gotten that far yet kek 😂

#

Oof wrong person my bad

#

@late hill ^

#

Is there a way I can change the background and buttons, etc on the bot page?

earnest phoenix
#

find the css class that's being used on the website and overwrite it

lusty dew
#

Mk but like how? I’m not used to internal css don’t even know how to do it for one

earnest phoenix
#

inspect element

lusty dew
#

I don’t have that on a tablet kek

#

Also wouldn’t I use the style tags?

earnest phoenix
#

yes, in your bot's description

lusty dew
#

<style></style>

#

Mk

#

Now I gotta find out how to find out what css class I want to change

earnest phoenix
#

iirc someone made a repo of all classes dbl uses so you can overwrite them

#

i'll go hunt for it

lusty dew
#

Oh thanks I’ll look for it as well

earnest phoenix
lusty dew
#

Oh thanks!

tight forum
#

hellow

earnest phoenix
#

byew

lusty dew
#

Lmfao

quiet rapids
#

While trying to set up a eval command, all responses comes out as undefined What did I do wrong?

EDIT - I fixed it with a bit of fiddling with the code.

lusty dew
#

What you’re trying to eval is probably undefined

quiet rapids
#

oh.

valid frigate
#

some statements return nothing so pretty much

quiet rapids
#

hmm ok

inner jewel
#

or clean() returns undefined

topaz fjord
#

Anyone use coc and the kotlin language server

lusty dew
#

Also true

#

Lol

tight forum
#

hellohellohello

lusty dew
#

If you’re not here to ask for help or talk about development #memes-and-media @tight forum

#

Please and thank you

tight forum
#

no im asking w8 pls

lusty dew
#

Then just get straight to the point....

tight forum
#

I did a custom command for my server, I just added this code so I want it to run on my own server. but it is also working on other servers. how do I prevent it in another way?

if(!message.guild.id === '495725015418011658') return;
lusty dew
#

Not how you do that

#

if(message.guild.id !== 'guildID') return;

tight forum
#

oh god damn really ?

lusty dew
#

Yea.

tight forum
#

it makes sense, i never thought of it

#

ty mmLol

lusty dew
#

How could I do something like that?

knotty steeple
#

like?

lusty dew
#

Huh

#

What’s confusing

knotty steeple
#

like what

lusty dew
#

Look at the image lol

knotty steeple
#

ok

#

and

#

what do you want to do

lusty dew
#

Is it that hard to understand

knotty steeple
#

yea it really is

lusty dew
#

Okay

#

That’s on dbl

knotty steeple
lusty dew
#

It’s like a web socket or smth idk and it allows you to test the bot in the server

#

From the botpage

indigo geyser
#

Oh

#

I saw a video

#

Let me find it

#

@lusty dew

#

But idk how to import it on the DBL page

knotty steeple
#

embed it into a website

#

but the website is dbl

topaz fjord
#

you could make that easily with some webhooks

indigo geyser
lusty dew
#

OkY thanks

indigo geyser
#

Np

lusty dew
#

Seems pretty easy to use

unique wagon
#

So I need it to state wich permission it needs, It done that:

#

@cmd.has_permission(administrator=true)
@cmd.bot_has_permissions(Manage_messages=true)

#

(python)

#

I need it to have multiple permissions tho

#

not just manage_messages

#

how can I define multiple?

#

I need "Mange webhook" and "Manage channels" and "Manage messages and "Manage reactions" for it to fully function

#

ok I think i worked a solution.... just keep stacking it 😂, I mean its not the cleanest way but, whatever lol

earnest phoenix
#

okay i need some help

#

I've been trying for 30 minutes to get my font to change to a sans-serif but I can't for the life of me get it to work

#

here's my html

#
<!DOCTYPE html>
<html>  

<head>
<title>iab command reference</title>
</head>

<body bgcolor="#93A5FF" style="font-family: 'Arial';">
<h1>iab Command Reference</h1>
<p>(as written by an html noob)</p>
</body>

</html>
#

that doesn't work, neither does importing stylesheets, or using <style> tags. The <head> tag isn't even populated in browser.

#

like please just let it be that I have a microscopic brain

#

I was looking at and editing different files

lusty dew
#

Lol

#

Do you need help? @earnest phoenix

#

👀

#

I may not be the best at html but ya know

#

I’m not the worst either

#
const { Guild } = require('../library/seq_db.js')
const Discord = require('discord.js')
module.exports.load = (client) => {
    client.on('messageUpdate', messageUpdate)
}

module.exports.unload = (client) => {
    client.removeListener('messageUpdate', messageUpdate)
}

async function messageUpdate(oldMsg, newMsg){
    if(oldMsg.author.bot) return;
        const res = await Guild.findOne({where: {id: oldMsg.guild.id}})
        let log_channel = res.get('messageUpdate')

        const msgUpEmbed = new Discord.MessageEmbed()
        .setAuthor(newMsg.author.tag, newMsg.author.displayAvatarURL())
        .setDescription(`Message updated in: <#${oldMsg.channel.id}>`)
        .addField('Old message: ', oldMsg.cleanContent)
        .addField('New message: ', newMsg.cleanContent)
        .addField('ID: ', `\`\`\`User ${oldMsg.author.id}\nMessage ${oldMsg.id}\`\`\``)
        .addField('Date: ', new Date().toDateString())
        .setColor('BLURPLE')
        .setTimestamp()
        .setFooter(client.user.tag, client.user.displayAvatarURL())
        if(log_channel === null){
            return;
        }else {
            client.channels.get(log_channel).send(msgUpEmbed)
        }
}
#

I’m having trouble with my messageUpdate event

#

It’s not firing

#

But the other events do

earnest phoenix
#

I was going to say no but I actually do have a pretty annoying problem

#

How can I lower the amount of space between these lines without using the line-height css tag

#

I don't want to use line-height because it makes it unreadable on mobile

lusty dew
#

Iirc that’s a margin thing @earnest phoenix

earnest phoenix
#

Yeah you were right

lusty dew
#

Yea

#

Forgot lol

#

I get margin and padding mixed up

#

Also that example is kinda confusing to me @earnest phoenix

earnest phoenix
#

basically it gets the last 100 messages

#

and in those 100 messages

#

deletes all of iab's messages

#

but it doesn't just keep going until it deletes 100 of iab's messages

lusty dew
#

But it says it does not delete iabs messages

earnest phoenix
#

no

#

it says it doesn't delete 100 of iab's messages

#

important distinction lmao

lusty dew
#

Am I missing something

earnest phoenix
#

perhaps

lusty dew
#

Oh well

#

Time to go code my website on glitch mmLol

#

Jk

#

I gotta go to the store cya guys

earnest phoenix
#

cya

#

thanks for the help

lusty dew
#

Np and if ya ever need help just ping me or dm I’ll try my best

earnest phoenix
#

Does anyone know the command to repeat a command

zealous veldt
#

]]moreinfo @earnest phoenix

covert turtleBOT
#

If you want people to be able to assist you, please provide more information, such as what library and language you're using, the code in question and what you are trying to do and/or what is causing the error.

lusty dew
#

I mean make a say command and allow your bot to respond to itself

#

Then do prefixsay prefixsay

#

;)

zealous veldt
#

Do not ever let your bot respond to itself

lusty dew
#

Hehe shhhh

#

I’m kidding though don’t do that

#

It’d be in a continuous non stop loop until you turn your bot off

smoky finch
#

Its a great idea @lusty dew

lusty dew
#

Don’t ping me....

smoky finch
#

ok...

lusty dew
#

Is there an easy way to translate all text outputted by my bot to a language chosen by the server owner/admin

#

I was originally trying to make my own class extended onto TextChannel and make my own send function that’d translate the text for me but pretty sure that’d only translate text inside the send function and not text in the embed it’s sending

lime bough
#

I finally did it

#

I made a bot

#

With a sinple app

sudden geyser
#

You could do something like make a function which checks what language the server is set to, then pick from a collection of responses based on the lang.

#

good job

lime bough
#

Ty

lusty dew
#

Hm

#

But I only wanna support certain languages like Russian, English, Spanish, French, German, etc

copper cradle
#

@lime bough "simple app" that's not a good job

tough wave
#

Will my bot get declined if for online it shows !?!? Because my bots online

lusty dew
#

If your bots online it won’t be declined unless there is another reason.

#

@copper cradle Don’t be rude.

#

He/she accomplished something

copper cradle
#

I am rude

tough wave
#

Yes but it doesent show my bot as online it shows it as not knowing

copper cradle
#

I'm always rude

lusty dew
#

Because the website doesn’t register your bot yet

#

It’s not in this server

tough wave
#

Oh ok

#

How long does it normally take to get accepted or declined

lusty dew
#

Depends really

#

How busy the mods are

tough wave
#

Ok

lusty dew
#

Mine took 3-4 days to get accepted but it could take longer or it could take less time

tough wave
#

Ok

#

What roled people review my bot

lusty dew
#
const { Guild } = require('../library/seq_db.js')
const Discord = require('discord.js')
module.exports.load = (client) => {
    client.on('messageUpdate', messageUpdate)
}

module.exports.unload = (client) => {
    client.removeListener('messageUpdate', messageUpdate)
}

async function messageUpdate(oldMsg, newMsg){
    if(oldMsg.author.bot) return;
        const res = await Guild.findOne({where: {id: oldMsg.guild.id}})
        let log_channel = res.get('messageUpdate')

        const msgUpEmbed = new Discord.MessageEmbed()
        .setAuthor(newMsg.author.tag, newMsg.author.displayAvatarURL())
        .setDescription(`Message updated in: <#${oldMsg.channel.id}>`)
        .addField('Old message: ', oldMsg.cleanContent)
        .addField('New message: ', newMsg.cleanContent)
        .addField('ID: ', `\`\`\`User ${oldMsg.author.id}\nMessage ${oldMsg.id}\`\`\``)
        .addField('Date: ', new Date().toDateString())
        .setColor('BLURPLE')
        .setTimestamp()
        .setFooter(client.user.tag, client.user.displayAvatarURL())
        if(log_channel === null){
            return;
        }else {
            client.channels.get(log_channel).send(msgUpEmbed)
        }
}
#

My messageUpdate event isn’t firing.

#

I get no errors at all but all the other events fire with no problems

floral bloom
#

Discord.js
How would I remove all reactions from a message? I've tried multiple things, but can't seem to get it right.

#

Ping with response, please.

smoky spire
#

@floral bloom message.clearReactions on stable

floral bloom
#

Thanks.

earnest phoenix
#

Hello.

#

ask your question

#

i need know how to use a channel name instead of the channel id

#

await user.Guild.GetTextChannel(561572026486095902).SendMessageAsync($"User: {user.Mention} joined the official **{user.Guild.Name}** discord server!");

#

thats what i have right now.

#

Guild.TextChannels and use System.Linq's FirstOrDefault method

#

FirstOrDefault takes a lambda expression so you can pass in your condition there

earnest phoenix
#

What does this error mean (knowing that I do not know where and from which command it comes)

at RequestHandler.execute (/home/container/node_modules/discord.js/src/rest/RequestHandler.js:106:9)
at process._tickCallback (internal / process / next_tick.js: 68: 7)
(node: 14) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated from the inside of the outside world, but it was not handled by .catch (). (rejection id: 6)```
amber fractal
#

@earnest phoenix it means a http request to the discord api server failed

earnest phoenix
#

help

    const role = member.guilds.find("618406843303067649").roles.find(ro => ro.name === 'Members');
#

can't get it to work

amber fractal
#

.find("618406843303067649")

#

Use .get

#

Also

#

If you already have the member

#

Why get the guild

copper cradle
#

maybe it's an upvote reward

#

@amber fractal

amber fractal
#

Did you need to mention me for that tho? And also

#

.guilds isnt a property on user or member

earnest phoenix
#

i chave question to canvas: how can i load a image from url there?

#

i kinda need it and I d K how to

amber fractal
#

In the canvas module for node, you can use loadImage, then use drawImage

peak quail
#
                .addField("Roles:", message.guild.member(user).roles.map(s => s).filter(r => r.id !== message.guild.id).join(" • ")  )

how can i say "None" if he has no role 🤔
|| "none"
but where i need to put it

copper cradle
#

after .join()

#

@peak quail

peak quail
#

i was faster ^^ but thanks

earnest phoenix
#

Thing is @amber fractal

#

the drawImage thing

#

isnt existant on my script for some reason

sage bobcat
#

One message removed from a suspended account.

unique nimbus
#

try to learn python?

dusky marsh
#

Rust uwu

sage bobcat
#

One message removed from a suspended account.

unique nimbus
#

Some jobs wants experience with python

#

¯_(ツ)_/¯

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

west spoke
#

@sage bobcat backend dev for discord uses python

grave pilot
sage bobcat
#

One message removed from a suspended account.

spark star
#

Could someone point me towards a tutorial that teaches me how to make a Welcome and goodbye command? For more then one server?

#

Please ping me when you can help me please

harsh nova
#

What language?

dusky marsh
#

@sage bobcat it's not too hard once you get used to it, and it should be easier if you have any experience with other low level langs

spark star
#

Any language

#

I don't mind

#

As long as my rpi can run it

quartz kindle
#

you must chose a language and a library first, before you can find a tutorial, as tutorials are specifically made for a given language and library

spark star
#

Would python be a viable option?

#

For multiple servers as well?

quartz kindle
#

yes, python is one of the most popular ones around

spark star
#

In Britain it's most popular so I think I'd be good with sticking to that

earnest phoenix
#

hello

#

i was looking on discord docs at clientStatus

#

i have no clue what to do

#

xD

quartz kindle
#

neither do i (what you wanna do that is)

earnest phoenix
#
Properties
.clientStatus
The devices this presence is on

PARAMETER    TYPE    DESCRIPTION
web    PresenceStatus    
Documentation missing.

mobile    PresenceStatus    
Documentation missing.

desktop    PresenceStatus    
Documentation missing.
#

is there a way to set a bot to mobile status?

#

i seen a bot have this

grim aspen
#

i was just thinking of that

earnest phoenix
#

it looks cool

#

i wanna implement

#

but no idea

#

@grim aspen you know how?

quartz kindle
#

i dont see it listed in the discord gateway api, so i dont think its possible

#

where did you see that?

copper cradle
#

that's outdated

#

iirc

grim aspen
knotty steeple
#

you can do that in servers you own

#

used to

#

idk how

unkempt prism
#

im using quick.db
idk how to get users from 11-20 on leaderboard

#

my code :

#

for (var i in resp) {
    resp.length > 11 && resp.length < 20
topaz fjord
#

just get all of them and slice the array

#

<Array>.slice(11, 21)

unkempt prism
#
 resp.length = 20
        resp.slice(resp.length).slice(11,21)
#

??

#

@topaz fjord

topaz fjord
#

no

#

resp.slice(11,21)

unkempt prism
#

i tried that didnt wok

#

resp.length = 20 resp.slice(11,21)

#

that didnt work

#

@topaz fjord

#

hello?

#

it shows 20

#

top 20

#

not 10 , 20

short ocean
slow crypt
#

Yikus

short ocean
#

Well. Theres no more error. But my bots (premium. Not normal bot) on, no status, and no commsnds are responding

#

@slow crypt it started when i added ur 8ball command

slow crypt
#

WDYM

short ocean
#

Yea

slow crypt
#

But that in other section tho

short ocean
#

But it started

slow crypt
#

It has nothing to do with that

short ocean
#

When i added 8ball command

slow crypt
#

No

#

The error is on your help list command

short ocean
#

Uhhhhhhh

#

Nvm. Ignore everything i said about it not working. Only status wont work

#

I just reset bots data

slow crypt
#

F

unkempt prism
#

say if i was NUMBER 1 on leaderboard how do i make myself not appear on leaderboard?

mossy vine
#

are you asking about a certain bot or your own bot

unkempt prism
#

my own bot

#

im number 1 atm

#

i dont want myself to show on leaderboard

mossy vine
#

filter yourself out by id

earnest phoenix
dusky mist
#

??

#

Whats the problem?

#

@earnest phoenix

earnest phoenix
#

i want text to be

#

Members (1241241)

#

not Members
12314

dusky mist
#

So

#

Members (${client.users.size})

#

Client or bot

earnest phoenix
broken shale
#

since when did descriptions support inline

#

it doesn't afaik

amber fractal
#

they didnt, but it doesnt matter because when you pass extra arguments in js they are just ignored unless you use the arguments object. However there is no point in passing it so may as well remove it

earnest phoenix
#

me?

broken shale
tacit slate
#

Does anybody have any tips about deving a bot.

knotty steeple
#

dont use d.js

tacit slate
#

what?

mossy vine
#

dont reivent the wheel, and if you do, dont try to make it better than the wheel

#

@knotty steeple honestly thats shit advice for a beginner

knotty steeple
#

no

mossy vine
#

d.js is perfect for newbies, at the cost of performance

tacit slate
#

is JDA a good thing to use?

knotty steeple
#

eris isnt different from d.js smh

mossy vine
#

yes

knotty steeple
#

also yes

#

jda is better than any other java library

tacit slate
#

@mossy vine were u talking to me when u said 'Yes'

mossy vine
#

yes

knotty steeple
#

yes

tacit slate
#

k

knotty steeple
#

also try to be a bit original with ur bot

tacit slate
#

wdym by 'Original' ?

knotty steeple
#

original

#

come up with a unique idea of what your bot is going to be

#

so basically dont make another multipurpose bot

tacit slate
#

mine is to watch my RP server

knotty steeple
#

rp server

#

mmm

tacit slate
#

i was thinking about doin !b or !k for banning and kicking

#

and more

knotty steeple
#

so u want like a custom mod bot

tacit slate
#

ye

knotty steeple
#

for ur server

#

why did that take so long to send

tacit slate
#

ye

topaz fjord
#

jda is cool

#

there's also catnip

tacit slate
#

wdym? @knotty steeple

summer torrent
#

how to I get emoji ID in discord js?

knotty steeple
#

\:emoji:

#

oh in discord.js

#

uhhh

summer torrent
#

in code

knotty steeple
#

cant really do that can u Thonk

quartz kindle
#

get emoji id from what?

summer torrent
#

for emoji info command

knotty steeple
#

oh

#

do you know how to get the

#

emoji

#

if you do you can just use <Emoji>.id

#

i dont do d.js so i dont even know how you would get the emoji

summer torrent
#

but appears undefined in a embed

#

I finally did

knotty steeple
#

ok so how would i go by making command line arguments

#

i know how i can take arguments but how do i basically parse it

summer torrent
#

${argumentname}

#

for example

#

const argumentname = ...........

amber fractal
#

@knotty steeple do you just have the command as a string?

#

because the easiest way would be to make flags

#

-r -f etc

#

but

#

that's like

#

shit

#

cuz then you wanna -rf

#

yeeeeeee

knotty steeple
#

well i wanted to do like

#

--welcome hello there

#

because it wouldnt be hard to do what you are referring to like --r

amber fractal
#

If I wasnt in a game I'd help more :(

knotty steeple
#

smh

quartz kindle
#

make a prefix for the arguments and split on it

#
"!command -argument -argument2 -argument3".split("-").slice(1).map(t => t.trim()) // ["argument","argument2","argument3"]```
topaz fjord
#

@west raptor i switched to suckless since vim was being gay in urxvt

#

specifically xst

#

oh fuck

#

wrong channel

knotty steeple
#

--thing argument

#

how can i make that

#

args.thing

quartz kindle
#

"prefixSomecommand --option value --option2 value 2"

#

.split("--").slice(1) will give you ["option value","option2 value 2"]

#

then you can .map(t => {t.split(" ")[0]:t.split(" ")[1]})

#

and you get [{option:value},{option2:value}]

#

or instead of split(" ")[1] you can .split(" ").slice(1).join(" ") to keep spaces as well if you need several arguments with spaces

#

im tired and icba to use code blocks and explain better rn

knotty steeple
#

lul

#

i love how the context is a bot command but im using it for a node app

#

i get how it works

faint acorn
#

Oof.

#

My bot uses a program...

#

Does This Work?

#

Ok.

knotty steeple
#

i run part of the code and i get [ '' ], [ 'rating', 'saef', '' ], [ 'wow' ] ]

#

the first part really shouldnt be there

#
const args = process.argv.slice(2).join(" ").split("--").map(t => t.split(" "))
console.log(args)```
#

y this

#

is happening

lusty dew
#
const { Guild } = require('../library/seq_db.js')
const Discord = require('discord.js')
module.exports.load = (client) => {
    client.on('messageUpdate', messageUpdate)
}

module.exports.unload = (client) => {
    client.removeListener('messageUpdate', messageUpdate)
}

async function messageUpdate(oldMsg, newMsg){
    if(oldMsg.author.bot) return;
        const res = await Guild.findOne({where: {id: oldMsg.guild.id}})
        let log_channel = res.get('messageUpdate')

        const msgUpEmbed = new Discord.MessageEmbed()
        .setAuthor(newMsg.author.tag, newMsg.author.displayAvatarURL())
        .setDescription(`Message updated in: <#${oldMsg.channel.id}>`)
        .addField('Old message: ', oldMsg.cleanContent)
        .addField('New message: ', newMsg.cleanContent)
        .addField('ID: ', `\`\`\`User ${oldMsg.author.id}\nMessage ${oldMsg.id}\`\`\``)
        .addField('Date: ', new Date().toDateString())
        .setColor('BLURPLE')
        .setTimestamp()
        .setFooter(client.user.tag, client.user.displayAvatarURL())
        if(log_channel === null){
            return;
        }else {
            client.channels.get(log_channel).send(msgUpEmbed)
        }
}
#

The only event not firing is this one

#

I get 0 errors and I don’t know why

earnest phoenix
#

Please enter at least 300 characters excluding special characters in your detailed description. Add your commands. Spaces or empty spaces are not counted.

lusty dew
#

?

knotty steeple
#
  1. not really a development question
#
  1. do what it says
earnest phoenix
#

someone help me?

knotty steeple
#

make a description that

#

describes

#

ur bot

lusty dew
#

What’s there to be explained

#

It says it all

knotty steeple
#

just make a decent description saying the types of commands your bot has

#

there isnt really much to explain

earnest phoenix
knotty steeple
#

it literally says what to do

lusty dew
#

Okay and?

#

Make a long description using html or just plain words

earnest phoenix
#

OK

knotty steeple
#

discordia

#

dead lib

lusty dew
#

Yea...

#

Surprised that’s an option still

#

Isn’t discordia lua?

#

Actually discordia still offers support @knotty steeple

earnest phoenix
#

I will tell the truth I don't even know what my library is

knotty steeple
#

oh its the lua lib

lusty dew
knotty steeple
#

there is a js lib that has a similar name

lusty dew
#

Then how did you even make a bot

earnest phoenix
lusty dew
#

Either Eris or d.js

knotty steeple
#

how do you not know ur library

#

huh

lusty dew
#

He’s using either Eris or d.js

knotty steeple
#

thats d.js

earnest phoenix
#

doing more I'm kind of dumb in information

lusty dew
#

How do you know

knotty steeple
#

events/message.js

lusty dew
#

It could be Eris

knotty steeple
#

eris' message event is messageCreate

lusty dew
#

Eris is js

#

Bruh

#

Doesn’t mean he named the file exactly that

#

🤦

knotty steeple
#

if you want modular events u kinda have to

lusty dew
#

What

#

How does that make sense?

earnest phoenix
#

I renamed my index.js to NarutoNoTopo

lusty dew
#

Also please don’t tell me you are using Json as a database

knotty steeple
#

json.sqlite

lusty dew
#

Ik

#

But I see blacklists and such.

#

As a Json file

knotty steeple
#

if a blacklist is small it can be json

#

¯_(ツ)_/¯

earnest phoenix
#

I am Brazilian I always forget things just understand that works much more very well indeed

lusty dew
#

Yea but it’s still a bad practice imo

#

I remember when I lost 50k people’s info in a Json db

#

Kek

#

This is when I made my first bot GWlulurdMegaLul

earnest phoenix
#

As much as my source is all poorly made I know how to use it very well

lusty dew
earnest phoenix
#

wtf

lusty dew
#

?

trim saddle
#

@lusty dew this is why i gave up on storing user data

amber geyser
#

How did my bot invite this server?

shy rose
sudden geyser
#

rename development to read-faq then fixed

floral bloom
#

Discord.js
How would I add every message in a channel to a string? I know it probably needs fetchMessages but I can't seem to get the message content, author, or any other info.

#

~~Would this work?

let string = "";
message.channel.messages.forEach(function (msg) {
    string += `${msg.author.id} - ${msg.content}`;
})

Ping with response, please.~~

#

Never mind, I got it.

twilit pasture
#

anyone know if you can give somone a group in your discord based off a invite link?

solemn lotus
#

@floral bloom Its ez xd

slim heart
#

You mean depending on which invite they use?

rugged patrol
#

I created a bot but it got declined cuz i was using botghost do i really need to code?

unique nimbus
#

Coding is preferable

#

I just looked at the website

#

You just flip a button and then you get the code without doing nothing?

quartz kindle
#

woah

unique nimbus
#

@quartz kindle bro I am like you Number 1 fan can I have you signature?

quartz kindle
#

lol wut

unique nimbus
#

omg

rugged patrol
#

Well i got bored doing codes and getting some technical issues with my bot

unique nimbus
#

Thats coding for you

rugged patrol
#

quartz kindle
#

that botghost thingy looks pretty amazing actually, its quite new as well

#

apparently its owned by some unknown dude on twitter with only 100 followers

#

lets see how it goes

twin kestrel
#

Hello everyone!
I have a small problem for a few days.
My bot makes use of shards and I have a presence that is updated from time to time, with a new random activity. My problem is that two of these activities are: the total number of users and the total number of servers, and they are not updated with the change of presence, that is, after 3 days it continues to dial the same number of users and same servers (despite having a larger number).

I use discord.js and I hope you can help me with this.

Thanks in advance.

quartz kindle
#

show your updating code

twin kestrel
#
  setTimeout(function(){

 const promises = [
    client.shard.fetchClientValues('guilds.size'),
    client.shard.broadcastEval('this.guilds.reduce((prev, guild) => prev + guild.memberCount, 0)'),
];

Promise.all(promises)
    .then(results => {
        const totalGuilds = results[0].reduce((prev, guildCount) => prev + guildCount, 0);
        const totalMembers = results[1].reduce((prev, memberCount) => prev + memberCount, 0);

  setInterval(() => {
        let actividad = [
            "nada :(",
            `${totalMembers.toLocaleString()}` + " users",
            "Shards " + `${client.shard.id}/${client.shard.count}`,
            `${totalGuilds.toLocaleString()}` + " servers"
        ],
            index = Math.floor(Math.random() * (actividad.length - 1) + 1);
        client.user.setActivity(actividad[index], { type: "STREAMING"})
    }, 15000);
    })
      }, 20000);```
quartz kindle
#

yes, you are caching the values

#

you get the values once and save them into promises then every time the interval runs, you reuse the saved value in promises

#

you have to fetch values and broadcast eval again on every interval

twin kestrel
#

Okay, I'll try

hollow prawn
#

i've noticed my bot once a day restartin mby up to 5 times about 4pm to 3am (can be any time inbetween) but no logs of what caused the restart in first place (e.g. crash and etc) is it safe to assume the issue isn't on my side?

quartz kindle
#

it probably is on your side

amber fractal
#

@quartz kindle botghost?

quartz kindle
#

ye look it up

hollow prawn
#

well pm2 doesn't technically say the bot restarted, however I get messages sent in the logging channel when it has ran the on "ready" event

unique nimbus
#

Some free hosts restarts the server daily

hollow prawn
#

no i use my rasp pi to host my bot

unique nimbus
#

oh

quartz kindle
#

the ready event is run again when the bot disconnects and reconnects

#

maybe network issues?

sinful lotus
#

@hollow prawn language?

quartz kindle
#

or is your rpi disconnecting and reconnecting

hollow prawn
#

the same tim is moderator for discord.js

amber fractal
#

Oh a bot maker

quartz kindle
#

wut

twin kestrel
#

It works, thank you very much! ^^

amber fractal
#

Is it better than dbm then mmulu

#

Well that's not difficult lol

sinful lotus
#

if its node.js, do you know how to handle promises properly?

hollow prawn
#

well not moderator but profecient or w/e the role is xd
ig i'll have to see and get something to extend the wifi signal

sinful lotus
#

because it can be not your internet but the code

quartz kindle
#

you can enable discord.js's debugger to see if its really disconnecting

sinful lotus
#

but depends

#

promises inside an async function that is not handled is dangerous

quartz kindle
#

client.on("debug", m => console.log(m))

hollow prawn
#

eh the code is on github u can check it if u want (can send link here if it ok)

#

alright i'll enable that too but not a console log, would send it to a channel for debugging

sinful lotus
#

should be fine

quartz kindle
#

no it has to be the console

#

it cant sent to any channel if its disconnected

hollow prawn
#

btw the code should be relatively the same as the one i use, just some small changes here n there

quartz kindle
#

also, you said you send all logging to your logging channel, so have you actually checked the logs in the rpi? because when crashes happen, errors will not be sent to discord

sinful lotus
#

oh boi

#

this can crash anytime without logs lmao

#

your commands is async

#

so it means execute is a promise

hollow prawn
#

i have, thing is for the most cases no logging has been done, i run 2 bots on my rpi, later on one has had econnreset

sinful lotus
#

and thay execute is inside an async function

#

and is not awaited or .catched

hollow prawn
#

all promises should be resolved properly i think

sinful lotus
#

if that command errors, that will crash with no stack trace

quartz kindle
#

he does have a try catch block tho

#

only on the command execution part

sinful lotus
#

yes but its not awaited

#

thats useless

hollow prawn
#

I always test commands before I upload them to the rpi files

quartz kindle
#

yes its not awaited

sinful lotus
#

yes but no code is bug free

hollow prawn
#

hey man i like my spaghetti with some bugs in it tipsFedora

sinful lotus
#

first step to do is

#

fix your promises and handle them all properly

quartz kindle
#

not all of his commands are async

#

but some are

sinful lotus
#

i'd recommend making it all async so it would be fluent tbh

hollow prawn
#

shouldn't I use async only when necessary tho

quartz kindle
#

you can mix sync with async by using Promise.resolve()

sinful lotus
#

yes just make sure your command handler execute is awaited

hollow prawn
#

oh yeah I am

sinful lotus
#

and thats the same of making all your commands an async function

#

so its your choice

hollow prawn
#

except for some which are "fire and forget" promises as i've been told in d.js server

sinful lotus
#

for fire and forget instead of await, just put .catch()

quartz kindle
#

you dont fire and forget promisses without catching them

sinful lotus
#

.catch(() => null) is what I do for those

hollow prawn
#

I'm adding catch wherever possible

sinful lotus
#

if applicable

#

dont always do that

hollow prawn
#

hmm why not ?

sinful lotus
#

you can accidentally not know an error that causes you not knowing what to debug

hollow prawn
#

oh so it'd be better to have it on necessary parts of the code

quartz kindle
#

generally you would probably want .catch(console.log), if errors happen you can see them, but it wont stop the rest of your code

sinful lotus
#

yes for example cmd.execute would be better awaited so try catch can deal with error

#

instead of .catch

hollow prawn
#

well so far no crashes done because of the code itself and as i said I test everything by running the bot instance on my pc before I upload it to the rpi

#

and do as much as possible testing to deal with any issues that may occur

sinful lotus
#

dont expect the public is same on private

#

not because it dont on private, it will dont on pu lic as well

#

not because it works on you, it will work on everyone

#

other people will try to break your bot

hollow prawn
#

if they do i'll find out what's the issue from and solve it asap

sinful lotus
#

my experience on developing, and my own view on it is always expect the unexpected

hollow prawn
#

but they can't break my bot if I try to break it myself thinkan

sinful lotus
#

also I already mentioned one of your issues

#

your promises are so and so

#

handle it all

hollow prawn
#

that p much stands for everything, yee i'll run over the promises again and try to handle em all

sinful lotus
#

quick tip, async functions automatically returns a promise

hollow prawn
#

they do ? that something I didn't knew

sinful lotus
#

async function owo() { console.log('owo') };
console.log(owo())

#

that will return promise pending

modern elm
#

owo

sinful lotus
#

same on const stuff = async () => {}

grim aspen
#

it's kind of like when you're doing a eval with discord.js

hollow prawn
#

ah ic alrighty thanks

#

that's weird tho, it send the message "hi" but also promise pending

sinful lotus
#

because js is single thread

#

on that event loop, that promise is pending

#

then on next loop it will be resolved

#

or next next

#

or next x3

modern elm
#

Mucho logic

hollow prawn
#

ah i think i get it, well anyway thanks i'll be headin to the store atm then will check the promises

keen stream
#

hi, have you any way to give rewards when user vote on the website ?
(i use discord.js)
you can mention me 🙂

unique nimbus
#

I know some bots rewards are currency for their economy and they made some commands vote-locked

keen stream
mental solstice
#

there is documentation on setting up webhook listener for JS

grim aspen
hollow prawn
devout chasm
#

about what

hollow prawn
#

actually this might be the issue why my bot was restarting

#

the console output u see above in the image

devout chasm
#

am i missing something? I don't see something wrong

hollow prawn
#

so nvm

devout chasm
#

erm

hollow prawn
#

i kinda forgot I added that part eyes1 and ended up panicking for nothing thinking I may be doing discord api abuse lol

knotty steeple
#

@quartz kindle also the code returns undefined

quartz kindle
#

which code?

#

thats the normal debug log, if anything goes wrong with the connection, it will show there

#

like disconnects/reconnects/etc

#

heartbeats are normal

#

if you're confident the issue is not network-related, you can disable the debugger

knotty steeple
#

for command line args

#

it just returns an array of undefined

quartz kindle
#

which code?

#

show

knotty steeple
#

process.argv.slice(2).join(" ").split("--").map(t => {t.split(" ").filter(Boolean)})

#

E

grim aspen
#

is boolean defined?

knotty steeple
#
Boolean```
#

mmLol yes

quartz kindle
#

i mean

#

if you're using that on node args

#

since they are already an array

#

why not just use them?

#

node args split on spaces, do you need arguments that contain spaces in them?

knotty steeple
#

yes

quartz kindle
#

so like ``node file.js --arg some value here --otherarg`

knotty steeple
#

yes

quartz kindle
#

split("--") still requires a slice, else the first item is an empty string

#

so .split("--").slice(1)

#

then inside the map you have to again slice the first item

#

.map(t => t.split(" ").slice(1))

#

that should give you ["some value here ",""]

#

since the second arg doesnt have any value

#

to remove the trailing space you can add .trim() to t before splitting

#

and to get the key, take the first item before you slice it

#

t.split(" ")[0]

sinful lotus
#

@hollow prawn that has nothing to do with crashes as far as I can see

hollow prawn
#

yee i got it, its the debugging so i'll let it run and see where the issue comes from

sinful lotus
#

if its improper unhandled.promise 100% chances you wont see anything on that

#

your choice tho

hollow prawn
#

well it seems good so far tbh none of the issues/crashes were caused by running a command or a event

peak quail
tawdry sleet
#

@peak quail 🎉

peak quail
#

xd

slim heart
#

How do you even get that kinda thing

idle basalt
#

unicode border chars

wheat jolt
#

Any ideea how I can create backups of discord server in a mysql db?

topaz fjord
#

or just pipe the output from the shell to a code block

#

Backups of a discord server

#

God damn

wheat jolt
drowsy grail
#

backup a whole discord

dusky marsh
#

you could save the permissions for each channel and the channel structure, etc, into an obj, that you could save in a db

earnest phoenix
#

Was there recently any changes to discord.js that changed guild icon class? Just wondering since I had it in a embed but now it gives incalid url format error, worked fine before

west spoke
#

it shouldnt have

earnest phoenix
#

Ok

dusky mist
#
usuario.splice(usuario.indexOf(posicion), 1);
} ```
Why it doesn't work?
#

Im spanish so the variables are in spanish

small latch
#

Pass the variable to the function and return result of usurio.splice.

dusky mist
#

Ok ty its working now

small latch
#

Alright.

dusky mist
#

Which is the difference of parseFloat and parseInt? i always forgot it xD

late hill
#

I guess mainly that parseInt does integers meaning that it'll ignore decimals

#

2.9 for example would just become 2

harsh nova
#

yeah it did

#

epic

dusky mist
#

Ty @late hill

torpid juniper
#

const m = await channel.messages.find({ around: message, limit: 1 }).then(res => res.first());
(where channel is a textchannel and message is a snowflake)

this causes d.js to return TypeError: fn is not a function (because commando) but not leave behind a stack

#

and i don't understand why

amber fractal
#

If you comment that out does it work?

#

Because that doesnt describe the error you gave us, unless it's something internally in d.js

#

Which is a possibility

torpid juniper
#

well it's a

#

necessity for the command to work

#

this is why i use eris because you don't get vague errors like this and you always get stacks

amber fractal
#

Yeah, but that might not bethe cause of the error

torpid juniper
#

it is

#

it errors on that specific line

#

i already tested this

amber fractal
#

A stack trace isnt something given out by d.js MegaThonk it's js

torpid juniper
#

commando

#

kills

#

stacks

amber fractal
#

Dont

#

Use

#

Commando

torpid juniper
#

i have to

#

for this contract i'm working on

amber fractal
#

Oh

torpid juniper
#

also commando is alright so

amber fractal
#

Well that makes more sense

torpid juniper
#

makes d.js a bit more bearable

amber fractal
#

All it does is add bugs

#

From my experience

#

Anyways

#

Let mecheck something then

torpid juniper
#

ok ive just

#

changed it

#

await channel.messages.find(message) makes it shorter code

#

and does exactly what i want

#

it is most certainly that line that causes the error

#

figured it out

#

i was using find instead of fetch

#

and because commando eats stacktraces for breakfast i had to manually log it

#

to realise it was using map and not messagestore

mossy vine
#

eats stacktraces for breakfast
lol

amber fractal
#

Commando uses d.js stable ye

#

Was looking through commando code trying to find the error

earnest phoenix
#

Does anyone know of a way to make it so that caps don't matter. Basically I have a prefix that's "yo " but if someone does "Yo " it won't work any way to just remove the whole caps issue? Discord.js

#

tolowercase or touppercase the original string

quasi forge
#

In case of commando, it handles it itself

amber fractal
#

Still wouldnt recommend it

#

Making a command handler isnt hard

peak quail
#
    let Text = (`
    Command Run:
    User: ${msg.author.tag} (${msg.author.id})
    Server: ${msg.guild.name} (${msg.guild.id})
    Channel: ${msg.channel.name} (${msg.channel.id})
    Command: ${msg}`)
    fs.appendFile("../../Logs/Commands/Command.txt", Text,function(err){
      if(err) throw err;
      });

Error: ENOENT: no such file or directory, open 'C:\Users\Administrator\Logs\Commands\Command.txt'

earnest phoenix
#

well is it in the administrator/logs folder

#

because from what i'm seeing it isn't

peak quail
#

hmmm

#

yes

earnest phoenix
#

unless your files are in the administrator folder

topaz fjord
#

Commando

#

I prefer writing my own command handler framework thingy

knotty steeple
#

i have my own shitty command handler

wooden lance
#

Does anyone know how I can send console to a channel ID? I'm running discordjs on node.

winged ermine
#

Is it possible to use chart.js with a discord bot?

scarlet phoenix
#

@wooden lance I just wrote my own logger that does some stuff like that.
1 Determines log level (Error, warning, info, etc)
2 Sends it to graylog
3 Sends it to discord log channels based on level
4 Prints to console based on level

Then just make one for each class and use it for all of your logging needs. Works pretty well

wooden lance
#

Oh, okay! Thanks!

#

@scarlet phoenix came up with a good idea, using webhooks now. Here's the code if you want to use it.

const util = require('util');
const consoleHook = new Discord.WebhookClient("<webhook-id>", "<webhook-secret>");

console.log = function(d) {
  consoleHook.send(`${util.format(d)}`);
};
supple harbor
#

Hello, I'm trying to register a bot on the bot list, but I'm encountering the following error:

Unable to fetch application. Make sure you've provided the correct Client ID and that the application has a bot account.
#

What should I do?

scarlet phoenix
#

Double check that your clientId Is your bots id

knotty steeple
#

so how would i go by turning an array into an object

#

i tried searching for solutions but its not really want i want

scarlet phoenix
#

Completely depends on language, and what you even mean by that. A lot of languages treat arrays similarly to objects already

knotty steeple
#
[["thing", "thingie"], ["think", "thonk", "omegathonk"]]

into

{
    "thing": "thingie",
    "think": "thonk omegathonk"
}```
#

js btw

jaunty folio
#

Ok

scarlet phoenix
#

So you want an array of arrays -> Json?

heady salmon
#

Hi guys, I'm having some weird indentation issue.

    from .roleplay import Actions
  File "/home/olly/bot/cogs/roleplay.py", line 171
    return error
               ^
IndentationError: unindent does not match any outer indentation level```
knotty steeple
#

objects*

#

yes

supple harbor
#

Double checked my client ID, both from the Discord dev panel and by right clicking the bot > copy ID, still not working

west spoke
#

@heady salmon dont use [tab] fill it In with spaces

#

I hate it, but python is a jerk about indents

amber fractal
#

@knotty steeple you can use a for loop, or you can use reduce

#

There may be some other ways but that's what I know

knotty steeple
#

how would i use a loop

#

yes

amber fractal
#

With a loop, you just make an empty object, loop the array and set obj[arr[i][0]] = arr[i][1] where i is your index

heady salmon
#

@west spoke I just used a check for NSFW channels in the end

amber fractal
#

That above example uses reduce

heady salmon
#

I literally facepalmed when I found it in the discord.py docs

amber fractal
#

Oh wait

#

Nvm you said you were

west spoke
#

@heady salmon not in async

#

I have a workaround for it

heady salmon
#

Ah

#

I do use ASync though

west spoke
#

ah

#

There is no NSFW channel recognition in d.py async

amber fractal
#

Make the call yourself mmulu

sick cloud
#

install discord.js alongside and make a complex api to check nsfw channels for you

amber fractal
sick cloud
#

bloblamp or move to rewrite

amber fractal
#

@knotty steeple did you need any other help or did you get it?

knotty steeple
#

im looking at how array.reduce works

amber fractal
#

Ah

cedar shoal
#

🍋

#

hello

knotty steeple
#

so just doing this works ```js
let a = [["walk", "it"], ["like", "i"], ["talk", "it"]]
let obj = {}
for(let i = 0; i < a.length; i++) {
obj[a[i][0]] = a[i][1]
}
console.log(obj)

amber fractal
#

Yes

knotty steeple
#

{ walk: 'it', like: 'i', talk: 'it' }

#

ok nice

amber fractal
#

Which was the other thing I meant with loops

knotty steeple
#

im doing this for a very specific reason

#

ok so i applied this to my cli

#

works perfectly

#

😩 👌

amber fractal
#

👌

short ocean
#

This is just a test command bye

#

Btw*

#

Ping me on responses

knotty steeple
#

what does that mean

earnest phoenix
#

So im trying to do the tolowercase how would it work in this

amber fractal
#

@earnest phoenix what?

earnest phoenix
#

hold on

#

so basicly

#

i have a message.startswith

#

if (!message.startsWith.toLowerCase(prefix, prefix2)) return;

#

and Were do I put the toLowerCase

#

its not wrking

amber fractal
#

Uh

#

message is an object unless you redefined it

#

message.content is a string

#

Or null

#

So is your message a <Message>.content?

earnest phoenix
#

would this work

#

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

amber fractal
#

It's a function

earnest phoenix
#

ik

amber fractal
#

Dont forget the ()

earnest phoenix
#

wdym

amber fractal
#

toLowerCase()

earnest phoenix
#

can you edit this line

#

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

#

like were it is

amber fractal
#

Well it's fine

#

You just need the ()

earnest phoenix
#

so

#

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

amber fractal
#

Yep

#

Should work

earnest phoenix
#

kk

#

thanks it wokred

amber fractal
#

👌

knotty steeple
#
dlpercent(gotten, r.headers._headers["content-length"])
                                                    ^

TypeError: Cannot read property 'content-length' of undefined
#

i dont get why this is happening because it was working mostly

#
    async function download(url, path) {
        const res = await fetch(url);
        let r = await fetch(url, {
            method: "HEAD"
        })
        const fileStream = fs.createWriteStream(path);
        await new Promise((resolve, reject) => {
            let gotten = 0
            res.body.pipe(fileStream);
            res.body.on("error", (err) => {
              reject(err);
            });
            res.body.on("data", (chunk) => {
                gotten += chunk.length
                dlpercent(gotten, r.headers._headers["content-length"])
            })
            fileStream.on("finish", function() {
                resolve();
            });
        });
    }

    function dlpercent(gotten, size) {
        const progress = (gotten * 100) / size;
        console.log(progress);
    }
#

this is a function that is supposed to download a file from the url to a path

#

or did e6 api change

#

the function to download itself works but r.headers._headers

#

is just undefined

#

for some reason

#

am i dum

vital lark
#

is headers an object

knotty steeple
#

yes

vital lark
#

Maybe try r.headers['content-length']

knotty steeple
#

undefined

#

if i log r.headers i get

Headers {
  [Symbol(map)]:
   [Object: null prototype] {
     server: [ 'nginx' ],
     date: [ 'Wed, 11 Sep 2019 01:32:09 GMT' ],
     'content-type': [ 'image/jpeg' ],
     'content-length': [ '469553' ],
     'last-modified': [ 'Mon, 09 Sep 2019 16:45:43 GMT' ],
     connection: [ 'close' ],
     etag: [ '"5d7681b7-72a31"' ],
     expires: [ 'Sat, 12 Oct 2019 01:32:09 GMT' ],
     'cache-control': [ 'max-age=2678400' ],
     'accept-ranges': [ 'bytes' ] } }
#

@vital lark

vital lark
#

bruh

knotty steeple
#

yes

vital lark
#

"'content-length': [ '469553' ],"

#

r u dumb or what

knotty steeple
#

that

#

doesnt work