#development

1 messages ยท Page 887 of 1

green vale
#

Wait wdym

turbid bough
#

since you are sharding, you are spawning multiple instances of index.js

#

and that means you are also trying to spawn multiple express.js servers

#

but im not sure if thats the original problem

#

you were only spawning one shard right?

green vale
#

Yes

#

Only one

turbid bough
#

oh yeah, your server might not have been closed then

#

idk, how js works

green vale
#

I'm going to try switching to sharding.js and I'll see if it prints "online" on the webpage

turbid bough
#

also, can you check if you are able to log down to client.login or something

green vale
#

Uhm

#

Well first off it's just timing out

turbid bough
#

what happens if you try to run the bot now?

#

without sharding

#

just index.js

green vale
#

Just running the bot normally works like a charm-

#

Wait

#

I think it's trying to run the file twice

turbid bough
#

uh, thats weird?

green vale
#

nope

#

it's still spamming

turbid bough
#

what is?

green vale
#

O_O

#

woah

#

So now it works

#

It was something so simple; the debugger

#

bruh im so dumb

#

But uh also I do have another issue

turbid bough
#

wait, so sharding works now?

#

ok?

green vale
#

debugger

#

But uh also another issue lmao

#

As soon as I pressed the stop debugger button and restarted Node

#

It worked

turbid bough
#

yeap

green vale
#

Do you use Discord.js? You said earlier that u didnt know how js works

turbid bough
#

webserver was probably running, trying to run another instance of it would error it out causing the program to not run anymore.

green vale
#

yeah

#

also o

restive furnace
#

i use eris

green vale
#

Do you have experience with DJS, @restive furnace?

restive furnace
#

yes, i was using it until wanted to get ram usage lower

green vale
#

yeah so you probably know v11

restive furnace
#

yes i know even v10

green vale
#

would client.shard.fetchClientValues(clientvalue) fetch the values for all of the shards

restive furnace
#

or what ever it is called

#

yes and return an array

green vale
#

how would i add them together? simple js question but yea

restive furnace
#

Returns: Promise<Array<*>>

turbid bough
#

for() total += value

golden condor
#

How do you shard on discord.js I am really confused by it.

green vale
#

do you need an example sir

turbid bough
#

wow we just finished talking about that

green vale
golden condor
#

Ok thanks

green vale
#

welcome, i just had a large bonanza w/ it

#

'bonanza'

restive furnace
#
ArrayReturnedFromTheFunction.reduce((prev, guildCount) => prev + guildCount, 0)``` @green vale
turbid bough
#

btw danny, you might want to change up even more things in your bot whilst sharding

#

things that are single-instance

green vale
#

what do you mean

turbid bough
#

i mean your webserver and logging.

#

since right now, having a second shard will basically give you the same error as before

restive furnace
#

and probably command handler too? if you eventually get 10k guilds, whats the point scanning the commands dir 10 times?

green vale
#

Hm

turbid bough
#

command handler is already handled by that isnt it?

#

since sharding should automatically do that for you wouldnt it?

#

im not sure exactly what your webserver is needed for so that it is required to have it

green vale
#

Well my host automatically puts projects to sleep if they aren't accessed within five minutes of the last visit

turbid bough
#

oh, its for heroku

green vale
#

I use Glitch

#

Not Heroku

turbid bough
#

glitch

#

lol

green vale
#

yeah ik

turbid bough
#

yeah i just had heroku in my head even when i read glitch

modest maple
#

Heroku and glitch :TM:

green vale
#

lol

#

I have it now so sharding.js has the require for keepOnline

#

So that won't be a problem

turbid bough
#

yeap

#

thats what i meant basically

green vale
#

Logging is fine I'll probably just remove logging at some point

turbid bough
#

ah nvm, you arent making a logging file

#

i think

green vale
#

no

#

it just logs in the console

turbid bough
#

ok then its fine

icy crane
#

So I'm trying to make it so that my bot accepts the mention as a command prefix, but it doesnt like this

    if (!message.content.startsWith(prefix) || !message.content.startsWith("@thorny beacon")) return;

not really sure what I would need to change for it to work

green vale
#

Hmm

#

Let me check my code

turbid bough
#

which language?

icy crane
#

js

green vale
#

JS

turbid bough
#

why does everyone use js lol

icy crane
#

idk

green vale
#

it's the most popular lang

icy crane
#

y not

green vale
#

It's also easy to learn because websites

icy crane
#

yeah

#

anyways, shouldnt that work?

#

It seems like it should...

green vale
#

I'm checking rn

icy crane
#

alr

turbid bough
#

<@ > not <@! >

#

or both

green vale
#

yeah

icy crane
#

<@!id> is for bots

#

<@id> is for users

#

<@&id> is for roles

green vale
#

Wait so then I assume that the mentionable is for a bot

#

So <@!num>?

icy crane
#

yeah

#

thats what it is

turbid bough
#

nope

green vale
#

My bot is so different

turbid bough
#

top one is one without changed name

#

the bottom one is when changed name

icy crane
#

if you console log the message content when you mention a bot, its <@!botid>

#

doing \ botmention doesnt show it correctly

turbid bough
#

also when the bot does not have a nickname?

turbid bough
#

huh

#

but message.contains("<@! id>") does not work?

icy crane
#

well you would want it at the start right

turbid bough
#

i found an example

#
const prefixRegex = new RegExp(`^(<@!?${client.user.id}>|${escapeRegex(prefix)})\\s*`);
if (!prefixRegex.test(message.content)) return;```
green vale
#

I'm being seriously compact here so would this be correct client.shard.fetchClientValues('guilds.size').reduce((prev, guildCount) => prev + guildCount, 0).toLocaleString()

#

It says that it isn't a function soo lol

turbid bough
#

from the official docs

green vale
#

Cxllm dude can you help me

golden condor
#

@green vale with what

#

What version d.js you on?

green vale
#

11.5

golden condor
#

What's the error

green vale
#

Oh no I need help with making the code

golden condor
#

What code

green vale
#

I tried doing something like client.shard.fetchClientValues('guilds.size').reduce((prev, guildCount) => prev + guildCount, 0).toLocaleString()

turbid bough
#

What error?

golden condor
#

I need serious help shardinh

green vale
#

It says that it isn't a function

#

I want to get the results from fetching client values and then add them together

golden condor
#

It's in the guide

green vale
#

Yeah ik

pale vessel
#

you don't that even need to shard yet

green vale
#

But I need to minify it all into one line

#

I'm only using one shard anyway

storm bluff
golden condor
green vale
#

Yes I'm using that

golden condor
#

I am not even sure how to set up shards atm

storm bluff
green vale
#

What's your host?

golden condor
#

Local

green vale
#

oh okay

#

Yeah you can just follow the instructions\

golden condor
#

Well on a server

green vale
golden condor
#

But same thing

#

Ok

green vale
#

It should be easy as pie to do it

golden condor
#

Ok thanks

storm bluff
#

,

golden condor
#

Do you put a number inside manager.spawn?

green vale
#

If you don't put one then Discord decides what's best for you

pale vessel
#

why are you guys sharding

storm bluff
green vale
#

because we're preparing

pale vessel
#

that's not preparing

#

that's making your bot worse

green vale
#

Well I'm sharding now

#

I'm not using multiple shards

turbid bough
#

why is it making it worse by sharding?

green vale
#

Because we have less than 1k guilds

#

But I have only one shard so

turbid bough
#

yeah but like you can still have one shard.

green vale
#

One shard is practically the same as no shard

turbid bough
#

yeah

golden condor
#

I am using it on a beta bot

#

To test

storm bluff
#

and me?":\

turbid bough
#

my bot was already bad before sharding lol

#

it had like one second of delay each request

golden condor
#

I just wanna know how to shard for the future

green vale
#

I'm sharding just not sharding with multiple shards

icy crane
#

ty @turbid bough : )

golden condor
#

It's basically the same as without shards in that cade

#

@green vale you don't need the broadcast eval then

green vale
#

I am doing it just to prep

#

But anyway the command did work but it ended up just showing "Object promise"

golden condor
#

You need to await it then

#

I tgibk

turbid bough
#

i want to test out my bot to see how bad it is at handling traffic

golden condor
#

Or unpromisify it

turbid bough
#

are you coding on your phone?

green vale
#

Okay I'm just gonna use a variable to await it

#

LMAO coding on a phone

golden condor
#

No

#

I'm just on my phone atm lmao

green vale
golden condor
#

Why would you ever

turbid bough
#
if(users = "hi"){
    console.log(users);
}```
#

always true

green vale
#

It's just a placeholder

golden condor
#

@turbid bough lol cos there is only one =

green vale
#

Now be I back

earnest phoenix
#

@turbid bough imagine setting the users value instead of checking it

restive furnace
#

@golden condor that should work even only one =, but yeah.... ur linter/IDE might give errors.

earnest phoenix
#

it doesnt

#

one =: set the value of variable x, which returns true, always
Two ='s: Check if the value is equal to annother

tulip wave
earnest phoenix
#

Three ='s: check if value and type of variable are equal to annother

green vale
#

but yeah jade i want to have my handler read for just all shards instead of one

tulip wave
#

One = is an assignment
Two = is comparing
Three = is comparing in crack

green vale
#

Three is comparing but with steroids

tulip wave
#

@green vale there's no way to do it with d.js unless you use a different shard handler that does cache per cluster

#

As d.js has cache per shard

green vale
#

Is there such shard handler that does that that is compatible with DJS?

tulip wave
#

Yeah

#

It's a bit of a pain to setup thought

#

Though*

green vale
#

What's it called?

tulip wave
green vale
#

Is Kurasuta compatible with existing d.js broadcastEval and fetchClientValues functions?

tulip wave
#

It has its own

#

Everything is cluster based

#

Shards on the same cluster share memory

green vale
#

It says that Kurasuta's version of ShardClientUtil replaces DJS

tulip wave
#

Yes

#

As it doesn't feth from shards

#

It fetches from clusters

green vale
#

So I wouldn't have to change code much outside of the cluster setup

tulip wave
#

Yeah

green vale
#

How would I set it up then?

tulip wave
#

It's a bit complicated

#

And j can't rly help u as I gotta get ready for work soon

green vale
#

Ah alright

#

I'll try to see it myself

robust moth
obtuse niche
modest maple
#

yes]

hasty sparrow
#

Don't use the guild name as an identifier, the id is sufficient

tight plinth
#

just store them with guild id

#

coz names can change

#

when ID cant

golden condor
#

I am tryna lower memory usage

#

Upon starting this happens

tight plinth
#

well optimize ur bot

#

as simple as dat

golden condor
#

I dunno how

high bough
#

Guys, does why doesn't this work?

var nekoavatar = async() => await sfw.sfw.avatar()
tight plinth
#

read docs

high bough
#

Help?

green vale
#

I want to eventually switch over to a library like Eris

golden condor
#

I have removed every package I can

high bough
#

Which docs

tight plinth
#

@green vale dont, except if youre basically forced to

golden condor
#

done everything I can to omptimize

tight plinth
#

nekos.life docs

robust moth
restive furnace
#

@golden condor if you're using d.js, then you need to get bigger vps or switch to eris

green vale
#

What the heck is nekos.life

golden condor
#

The hosting is fine

hasty sparrow
#

@golden condor How many guilds is the bot in?

high bough
#

Uhmm, I'm not talking about that, I'm talking about the async await

tight plinth
#

@robust moth just use ID

golden condor
#

I'm not worried about mem usage

tight plinth
#

and dont use json as db

#

please

golden condor
#

It isn't affecting my bot

robust moth
#

Ok

restive furnace
#

kk but its cuz d.js caching

golden condor
#

How can I lower it

high bough
#

Uhmm, I'm not talking about that, I'm talking about the async await
@high bough @tight plinth

golden condor
#

I am in 161 servers @hasty sparrow

tight plinth
#

@high bough read the docs and look how they do

restive furnace
#

you cant lower if youre using d.js, only by switching to some ex discord.js-light or something. or just remove pointless caching

tight plinth
#

@golden condor the more servers, the ore ram

golden condor
#

ik

high bough
#

It didn't help @tight plinth I tried it, but it only works for one command

tight plinth
#

u can just edit discord.js files and use r own modded version @golden condor

#

show me code @high bough

golden condor
#

me?

earnest phoenix
#

@slim prawn

hasty sparrow
#

You can reduce cache amounts/times for messages to save a little RAM

high bough
#

show me code @high bough
@tight plinth It's fine, but if I try to async the command on client.ready and on client.message, it shows different pics

tight plinth
#

k

#

but show code

high bough
#

a sec

earnest phoenix
high bough
#
const clientneko = require('nekos.life');
const sfw = new clientneko();
var nekoavatar = await sfw.sfw.avatar()
var avatarURL = nekoavatar.url
```And basically repeat the variables on every client.on async functions
tight plinth
#

what

#

what u want to do with it

#

on every single client.on function

high bough
#

I want it outside of the client.on function, instead of in it

#

so i can generate just one link and use it for all of them

tight plinth
#

well just put it outside of it

high bough
#

it has to be in async duh

#

which is why i cant

tight plinth
#

make it async duh

#

like

high bough
#

Guys,~~ does~~ why doesn't this work?

var nekoavatar = async() => await sfw.sfw.avatar()

@high bough This is what I came up with

#

Didn't work

tight plinth
#
//code
var nekoavatar;
async function f () {
nekoavatar = await sfw.sfw.avatar
}
f()
//code```
#

not sure it will work

high bough
#

Hmm lemme try

#

nvm i tried that already, didn't work

tight plinth
#

oof

high bough
#
/home/kayuimineko/devindex.js:24
var avatarURL = nekoavatar.url
                           ^

TypeError: Cannot read property 'url' of undefined
    at Object.<anonymous> (/home/kayuimineko/devindex.js:24:28)
    at Module._compile (internal/modules/cjs/loader.js:1123:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1143:10)                                                       
    at Module.load (internal/modules/cjs/loader.js:972:32)
    at Function.Module._load (internal/modules/cjs/loader.js:872:14)                                                                
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)                                             
    at internal/main/run_main_module.js:17:47
[nodemon] app crashed - waiting for file changes before starting...      
tight plinth
#

f().then(() => {
//all ur code
})

high bough
#

That would mean putting my entire index code into f()

#

You sure?

tight plinth
#

idk

#

no idea

#

cant u just do ```js
var nekoavatar = sfw.sfw.avatar().then(res => res)

#

?

high bough
#

how do i use it?

#

i want to put nekoavatar.url into avatarURL

tight plinth
#

why tho

green vale
#

any of y'all have used kurasuta before?

tight plinth
#

timo have

green vale
#

yes

high bough
#

why tho
@tight plinth To generate a random avatar everytime the bot loads

green vale
#

but beesides him

tight plinth
#

ak him

green vale
#

"beesides"

tight plinth
#

@high bough thats completely useless and can maybe lead to api abuse

high bough
#

Umm, I mean, I won't reboot every 5 secs

versed narwhal
#

@icy crane i just checked and my bot always crashes on trying to get the owner tag of this server

tight plinth
#

still

high bough
#

Only once every reboot

versed narwhal
#

,-,

tight plinth
#

i just checked and my bot always crashes on trying to get the owner tag of this server
@versed narwhal owner is not cached

#

it's oliy's alt

#

and its always offline

versed narwhal
#

i tried caching but it then gives me an error

tight plinth
#

try to fetch it first

#

fetch, not cache

#

like

green vale
#

ez as go fetch

high bough
#

try to fetch it first
@tight plinth LMAO your f() code works well thanks

tight plinth
#

<guild>.members.fetch(<guild>.ownerID)

#

lol

versed narwhal
#

hm

oak cairn
tight plinth
#

no .cache needed in v12

versed narwhal
#

so it should be like this?

message.guild.members.fetch(message.guild.owner.user.username)}#${message.guild.members.fetch(message.guild.owner.user.discriminator)
tight plinth
#

no

#

first you fetch it

#

THEN you use it as normal

green vale
#

Eh I won't get too many guilds any time soon

earnest phoenix
#

I get Cannot read property 'map' of undefined error on: js let arr = [] bot.commands.map(x => {arr.push(x.help.name)})

hasty sparrow
#

bot.commands is undefined

digital ibex
#

hi

#

.includes(string), whats the equivalent for an array? like .something(array) ? If that makes sense

#

with javascript

hasty sparrow
#

.includes()

digital ibex
#

that takes a string

#

not an array

green vale
#

how would i make this correct:

 music(client, ({
                 
  });
hasty sparrow
#

Oh, an array as parameter

green vale
#

I'm doing so many things wrong

digital ibex
#

wdym?

earnest phoenix
#

how can i do more commander example: play, p, joinjs if (command === 'play') {

green vale
#

nvm i figured it out

hasty sparrow
#

You can use ||, check whether the command is in an array of aliases, etc.

earnest phoenix
#
if (command === 'play' || 'p' || 'join') {```
#

??

digital ibex
#
if (command === 'play' || command === 'p' || commmand === 'join') {
// 
}
earnest phoenix
#

o thanks

versed narwhal
#

dk!serverinfo

split hazel
versed narwhal
#

i know

#

it wont work

#

here

#

it was just to see if it will crash or not

#

Im trying to get user tag instead but the bot then crashes

summer torrent
#

owner is not cached

versed narwhal
#

would that be a problem

#

bcs this is the only server it happens

summer torrent
#

which library do you use

versed narwhal
#

d.js

#

i also have seen other bots getting the same in testing channels

summer torrent
#

you can fetch it from guild members

high bough
#

Guys, quick question, if I use setInterval, will it be run once the bot starts or just after the interval has passed?

versed narwhal
#

how so? i really cant get around the fetch thingie

summer torrent
#

bcs this is the only server it happens
@versed narwhal that is problem of large guilds

versed narwhal
#

noticed that

summer torrent
#

<Guild>.members.fetch(<Guild>.ownerID)

versed narwhal
high bough
#
const guildid = message.guild.id
const guilds = await <client>.guilds.cache.get(guildid)
message.channel.send("<@" + guilds.owner.user.id + ">")
#

@versed narwhal

versed narwhal
#

hm?

high bough
#

Try this

versed narwhal
#

im using MessageEmbed

high bough
#

You can't fetch a guild member

#

Use cache.ger

versed narwhal
#

i can try doing eval on it 1 second

high bough
#

cache.get

versed narwhal
high bough
#

Not here lmao

versed narwhal
#

i always forget

#

xd

summer torrent
#

object promise with it
@versed narwhal resolve promise

#

await/async

#
const guildid = message.guild.id
const guilds = await <client>.guilds.cache.get(guildid)
message.channel.send("<@" + guilds.owner.user.id + ">")

@high bough owner is not cached in large guilds

high bough
#

Oh, I always use this ```js
const client = new Discord.Client({fetchAllMembers: true});

#

lmao CPU usage 60%

summer torrent
#

ยฏ_(ใƒ„)_/ยฏ

sacred mountain
#

Iโ€™ve been trying to find a documentation on how to log how many guilds a bot is in but canโ€™t find one. Does anyone know how I could log how many guilds my bot is in when it is started?

modest maple
#

๐Ÿ‘ in ๐Ÿ‘ what ๐Ÿ‘ language ๐Ÿ‘

high bough
#

Iโ€™ve been trying to find a documentation on how to log how many guilds a bot is in but canโ€™t find one. Does anyone know how I could log how many guilds my bot is in when it is started?
@sacred mountain client.guilds.cache.size

#

djs v12

#

lmao

sacred mountain
#

Thanks

high bough
#

NP

versed narwhal
#
module.exports.run = async (bot, message, client, args, guild) => {
    console.log(message.author.tag, 'used the serverinfo command.') 
    let sEmbed = new Discord.MessageEmbed()
    .setColor()
    .setThumbnail(message.guild.iconURL())
    .setAuthor(`${message.guild.name} Info`, message.guild.iconURL())
    .addField("**Guild Name:**", `${message.guild.name}`, true)
    .addField("**Guild Owner:**", `${"<@" + message.guild.ownerID + ">"}`, true)
    .addField("**Member Count:**", `${message.guild.memberCount}`, true)
    .addField("**Role Count:**", `${message.guild.roles.cache.size}`, true)
    .setTimestamp()
    .setFooter(`darkness`, bot.user.displayAvatarURL());
    message.channel.send({embed: sEmbed}).catch(console.error);
}

this is the code that shows up here the mention id

#

without fetch

#

which i dont really know how to get it going, my friend tried to explain but it was a complete mess

earnest phoenix
versed narwhal
#

ยฏ_(ใƒ„)_/ยฏ

#

on v11 i could just use message.guild.owner

#

and it woud give me the tag or something

earnest phoenix
#

v12 is dumb tbh so

versed narwhal
#

idr and i have no backup

earnest phoenix
#

npm i discord.js@11.5.1

versed narwhal
#

and if i try the tag way on v12 it will be a pain in the ass

#

lol nope

#

already did mass replace

#

with embeds and stuff

earnest phoenix
#

oof

versed narwhal
#

i needed caching

earnest phoenix
#

v11 does too

versed narwhal
#

usure

earnest phoenix
#

ye

versed narwhal
#

then why i was never able to get it going by cache

earnest phoenix
#

you just dont have access to the .cache property

#

but it does caching

#

you just dont see it

versed narwhal
#

and i dont have access to node_modules if you mean editing something there

earnest phoenix
#

Does anybody know how to solve the Segmentataion fault error on npm?

#

When i do any command of the npm module it returns Segmentation fault

hasty sparrow
#

Which version of npm?

earnest phoenix
#

npm version to check

#

Lemme try

#

Even when i try to check the version it gives me the same error

hasty sparrow
#

Tried reinstalling?

earnest phoenix
#

I tried

summer torrent
#

npm -v

earnest phoenix
#

I did that

#

Still segmentation fault

#

npm cache clear -f

#

try clearing cache

#

(The npm was working and after i updated my phone to android 10 it caused this to happen)

#

..

#

phone

#

what

hasty sparrow
#

Wait what

earnest phoenix
#

(I code on Termux basically)

#

if u tell me u use npm on phone

#

hgfjkadgfh

#

whats funny?

hasty sparrow
#

Try a fresh install of everything node after completely purging the old one

earnest phoenix
#

Why u not using a host?

#

Cuz self-hosting is a true man of culture move

#

:/

#

w h a t

twilit rapids
#

I wouldn't recommend doing such a thing on mobile

earnest phoenix
#

So how do you purge the thing or whatever you talking about i forgot @hasty sparrow

digital ibex
#

hi hello

hasty sparrow
#

Completely uninstall it, but it seems you already are by using apt

earnest phoenix
#

Yea i did try to uninstall and reinstall it but no luck...

#

Hmm

digital ibex
#

how can i use something like .includes for an array?

#

like, .includes(string), whats .includes(array) ?

#

ik its not .includes for array, in javascript

earnest phoenix
#

@hasty sparrow so any ideas? I'm confused

#

array.some(element => {annotherarray.includes(element)})

#

i think

digital ibex
#

hm

hasty sparrow
#

Unfortunately no

earnest phoenix
#

ah fuck

#

wait

#

return statement

#

im dumb

#

array.some(el=>{return annotherarray.includes(el)})

digital ibex
#
let oof = ['hi', 'how', 'are', 'ya', '?'];
let hi = [];
hi.some((e) => { oof.includes(oof) });
#

the last line makes no sense to me

earnest phoenix
#

return oof.includes(e)*

digital ibex
#

confusiion

earnest phoenix
#
let oof = ['hi', 'how', 'are', 'ya', '?'];
let hi = [];
hi.some((e) => { return oof.includes(e) });
#

lets say hi is ["hi"]

#

the last line will return true

#

hi is ["H"] and the last line will return false

digital ibex
#

yeah, it returns false

#

is that the correct way to go on making an auto mod sort of system?

earnest phoenix
#

Welp i think Rip npm for me...

#

i'd use message.content.toLowerCase().includes for that but

#

its a way

digital ibex
#

but then i'd have to hard code every word?

#

like

#
if (args.join(' ').includes('ur mom').toLowerCase()) { message.delete(); }
if (args.join(' ').includes('ur dad').toLowerCase()) { message.delete(); }
#

or not?

earnest phoenix
#
badwords.some(w => {return message.content.toLowerCase().includes(w.toLowerCase())})?(function() {message.delete().catch()}()):null
#

oneliner

#

or two with the bad words defined

digital ibex
#

what would badwords type be?

earnest phoenix
#

array

digital ibex
#

hm, ok, thank you

earnest phoenix
#

np

digital ibex
#

i'll look into it more

tight plinth
#

discordjs v12

digital ibex
#

cool, js a!e let badwords = ['hi']; badwords.some(w => {return message.content.toLowerCase().includes(w.toLowerCase())})?(function() {message.delete().catch()}()):null

#

deletes the message

#

thank u

earnest phoenix
#

np

pale vessel
#

you don't need function ()

earnest phoenix
#

just realized too

#

im doodoo

digital ibex
#

o, ok

#

use eris to avoid djs' wack sharding manager

pale vessel
#

and you can just put w in lowercase and omit the toLowerCase for w

digital ibex
#

make life easier Lumap

tight plinth
#

but I tried eris

#

its a mess

pale vessel
#

even I moved to eris

digital ibex
#

its not lol

tight plinth
#

I gave up

#

multiple times

pale vessel
#

Eris is good

digital ibex
#

i 100 % recommend it

tight plinth
#

docs r shit

pale vessel
#

no, you're shit

digital ibex
#

they're not that bad

pale vessel
#

docs are okay

digital ibex
#

if u can read docs, u can read eris docs

tight plinth
#

I tried using it with ytdl, I got some eris ffmpeg compilation error

earnest phoenix
#

eris doesnt seem that bad tho

tight plinth
#

its just very different

pale vessel
#

did you install py and some other stuff?

tight plinth
#

yes

digital ibex
#

eris is fun

#

like

pale vessel
#

also, there's no dispatcher, we use connection straight away

tight plinth
#

ofo

pale vessel
#

pog

digital ibex
#

if u think u know js from starting with djs

#

u don't

#

think again

tight plinth
#

I dont started js with djs

pale vessel
#

d.js is good too though

tight plinth
pale vessel
#

you'll have to convert numbers to decimal and stuff on eris

#

but it was worth it for me

digital ibex
#

good 4 beginner 13 year old devs yeah

tight plinth
#

even if I switch to eris I dont have a good reason to do it

pale vessel
#

eris doesn't make you cooler though

#

yeah true

digital ibex
#

what about sharding?

pale vessel
#

wym

digital ibex
#

like, djs' sharding manager bs

pale vessel
#

use some other sharding manager

#

bowser sent one

digital ibex
#

how does that even work tho?

golden condor
#

When using shards

digital ibex
#

like, the sharding manager

golden condor
#

How can I make it so the port with dbl doesn't try reset

#

Like

digital ibex
#

i understand what shards are for and how they work, just confused what djs' sharding manager duz

golden condor
#

Everytime the shards start

#

The dbl webhook tries activating twice

tight plinth
#
Error: input stream: Error parsing config: Unexpected token ; in JSON at position 51669```aah, I love ytdl
golden condor
#

imma try youtube-dl over ytdl

raven urchin
#

How can i track the times the commands from my bot got used?

tight plinth
#

when command is exeuted, console.log it

#

its dat ez

pale vessel
#

he wants to track them

digital ibex
#

what

pale vessel
#

so probably a counter for every commands

digital ibex
#

u need a db

tight plinth
#

just create a counter that increaseson every command

#

and export it

golden condor
#

@tight plinth youtube-dl is much better

tight plinth
#

o

golden condor
#

Join music 1

tight plinth
#

k

golden condor
#

2

raven urchin
#

Like in the status

golden condor
#

sounds tons better

tight plinth
#

my ytdl setup works

#

no reason to change

raven urchin
#

Like 500 messages

tight plinth
#

til it breaks

#

@raven urchin updating status after each command executed can lead to api abuse

raven urchin
#

Yikes

tight plinth
#

bad idea

raven urchin
#

It's like the zira bot

earnest phoenix
#

I still haven't figured out how to fix the segmentation fault of npm...
Any ideas?

tight plinth
#

no, sorry

earnest phoenix
#

Oof

#

F

raven urchin
#

Ok so i have the status part to watching but it has the playing

earnest phoenix
tight plinth
#

dont host ur bot on phone

earnest phoenix
#

Ik... I'll get a pc soon so don't worry

pale vessel
#

try sudo

tight plinth
#

#rootOnly

earnest phoenix
#

(My phone is not rooted to use sudo)

pale vessel
#

well rip

tight plinth
#

well rip

earnest phoenix
#

F

tight plinth
#

try uninstalling apt package nodejs

#

not with --autoremove

earnest phoenix
#

Like i got this issue after updating my phone to android 10... I wonder how did that cause the issue

tight plinth
#

never update if not needed

earnest phoenix
#

Hmm... It was needed tho but anyways lemme try

split hazel
#

Maybe some os restrictions?

#

Dont know what android you on but I just installed what you installed and it works fine

#

On mobile of course

earnest phoenix
#

@split hazel you on Android 10?

split hazel
#

android 9

#

emui 9

earnest phoenix
#

It works fine in android 9

#

I upgraded to android 10 and it doesn't work

split hazel
#

android 10 must have some strange memory management

earnest phoenix
#

Hmm... Might be... But thank God that i'll be getting a pc soon lol

#

I might have fixed this segmentation fault issue if my phone was rooted to use sudo but whatever

nocturne grove
#

Hey

const channels = guild.channels.cache.filter(c => c.type == 'text' && c.permissionsFor(guild.me).has('SEND_MESSAGES') && c.permissionsFor(guild.me).has('VIEW_CHANNEL')).array();```
This code should work without errors, am I right? Lately this gave an error, I thought it was a `GET` error. But what is going wrong?
After this it will fetch 1 message in each of these channels, that should be possible without errors right?
knotty steeple
#

why do u want to do that first of all

golden condor
#

you could do

pale vessel
#

array is cached btw

golden condor
#

message.guild.me.permissions.has

nocturne grove
#

well, that doesn't change anything sadly ;) but
my bot will send a welcome message if it joins a server (it has some conditions though)

golden condor
#

What is better ytdl-core-discord or ytdl-core?

#

for a music bot

knotty steeple
#

ytdl-core

nocturne grove
#

message.guild.me.permissions.has
@golden condor but I want to check channel perms, so permissionsFor or permissionsIn is needed

golden condor
#

try

pale vessel
#

yeah because permissions are global

golden condor
#

^

pale vessel
#

so no

#

he needed to check channel perms

#

so permissionsFor

nocturne grove
#

no? Permissions are not always global

#

admin, kick/ban and nickname things etc. are global, this isn't

pale vessel
#

who are you talking to

nocturne grove
#

to Cxllm

pale vessel
#

yeah he was contradicting

nocturne grove
#

yes but doesn't matter

pale vessel
#

what kind of error did you get, specifically?

nocturne grove
#

it was a messages get error, so I guess it was with this line: js const messages = await channel.messages.fetch({ limit: 1 });

#

it's doing that for each of the previously cached channels

pale vessel
#

const messages except that it's actually a message lol

nocturne grove
#

oh yes ๐Ÿ˜‚
will change that

pale vessel
#

what do you need the message for?

#

that's the last message right?

nocturne grove
#

wait maybe it's missing READ_MESSAGE_HISTORY so it can't fetch the message

pale vessel
#

maybe

#

but you should've gotten permission error

#

like i said what's the full error?

#

"GET error" is not enough

nocturne grove
#

it will send a welcome message to 1 channel, in which the last message was sent less than a minute ago

#

I don't have the error anymore (bot restarted for some vague reason) but I know it was an error caused by message fetching

#

like this: path: '/api/v7/channels/aChannelId/messages/limit=1 (or something)', code: idkthisone, method: 'GET'

pale vessel
#

try ```js
const channels = guild.channels.cache.filter(c => c.type == 'text' && c.permissionsFor(guild.me).has(['SEND_MESSAGES', 'VIEW_CHANNEL', 'READ_MESSAGE_HISTORY'])).array();

nocturne grove
#

oh can I just make an array of the perms? Thanks

pale vessel
#

read message history, mb

#

yeah you can

golden condor
#

I have my dbl stuff

#

When sharding

#

how can I stop it doing it again

#
const DBL = require('dblapi.js');
const discord = require('discord.js')
const client = new discord.Client()
const { TOKEN, dbltoken } = require('./config.json')
const dbl = new DBL(dbltoken, { webhookPort: 3000, webhookAuth: '' }, client);
let channel;
client.on('ready', () => {
    channel = client.channels.cache.get('683615385920077871')
})
dbl.webhook.on('ready', hook => {
    console.log(`Discord Bot List Webhook is running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.webhook.on('vote', vote => {
    console.log(`User with ID ${vote.user} just voted!`)
    const embed = new Discord.MessageEmbed()
        .setTitle("New vote!")
        .setDescription(`<@${vote.user}> just voted on [top.gg](https://top.gg/bot/660818351638970370) and they have recieved vote locked features!`)
        .setFooter("User ID: " + vote.user)
        .setColor('#00AAFF')
    channel.send(embed);
    client.shard.broadcastEval(`this.users.cache.get(${vote.user}).send("Thank you for voting Corynth, you have now unlocked vote locked features for 12 hours.")`)
});
client.login(TOKEN)
module.exports = { dbl }```
nocturne grove
#

read message history, mb
@pale vessel oh oops np.
This noob just copied it ๐Ÿ˜‚

golden condor
#
 const DBL = require('dblapi.js');
 const discord = require('discord.js')
 const client = new discord.Client()
 const { TOKEN, dbltoken } = require('./config.json')
 const dbl = new DBL(dbltoken, { webhookPort: 3000, webhookAuth: '' }, client);
 let channel;
 client.on('ready', () => {
    channel = client.channels.cache.get('683615385920077871')
 })
 dbl.webhook.on('ready', hook => {
     console.log(`Discord Bot List Webhook is running at http://${hook.hostname}:${hook.port}${hook.path}`);
 });
 dbl.webhook.on('vote', vote => {
     console.log(`User with ID ${vote.user} just voted!`)
     const embed = new Discord.MessageEmbed()
         .setTitle("New vote!")
         .setDescription(`<@${vote.user}> just voted on [top.gg](https://top.gg/bot/660818351638970370) and they have recieved vote locked features!`)
         .setFooter("User ID: " + vote.user)
         .setColor('#00AAFF')
   channel.send(embed);
     client.shard.broadcastEval(`this.users.cache.get(${vote.user}).send("Thank you for voting Corynth, you have now unlocked vote locked features for 12 hours.")`)
});
client.login(TOKEN)
module.exports = { dbl }```
Please I need to fix the sharding issues with the dbl webhook
pale vessel
#

wtf

#

you sent this already

knotty steeple
#

dont send it twice

nocturne grove
#

If I could help you I would, but I don't know anything about that

knotty steeple
#

just get the message link

#

use internal sharding mmLol

split hazel
#

Honestly please it hurts seeing that code

#

Firstly on the broadcast eval, other shards will think you're passing in an integer this.users.cache.get(ID)

#

Your console will also be spammed with errors if someone votes

earnest phoenix
#

Why client isnt working on broadcast eval ?

split hazel
#

Since the users don't exist on all shards

golden condor
#

My console gets spammed with errors atm

split hazel
#

And do you even need sharding?

golden condor
#

Saying that 3000 is already in use

pale vessel
#

he doesn't

split hazel
#

How many servers is the bot in

golden condor
#
e CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 254)
0|index  | events.js:288
0|index  |       throw er; // Unhandled 'error' event
0|index  |       ^
0|index  | Error: listen EADDRINUSE: address already in use :::3000
0|index  |     at Server.setupListenHandle [as _listen2] (net.js:1309:16)
0|index  |     at listenInCluster (net.js:1357:12)
0|index  |     at Server.listen (net.js:1445:7)
0|index  |     at DBLWebhook._startWebhook (/home/cxllm/Bots/Corynth/node_modules/dblapi.js/src/webhook.js:45:18)
0|index  |     at new DBLWebhook (/home/cxllm/Bots/Corynth/node_modules/dblapi.js/src/webhook.js:27:12)
0|index  |     at new DBLAPI (/home/cxllm/Bots/Corynth/node_modules/dblapi.js/src/index.js:69:22)
0|index  |     at Object.<anonymous> (/home/cxllm/Bots/Corynth/dbl.js:6:14)
0|index  |     at Module._compile (internal/modules/cjs/loader.js:1158:30)
0|index  |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
0|index  |     at Module.load (internal/modules/cjs/loader.js:1002:32)
0|index  |     at Function.Module._load (internal/modules/cjs/loader.js:901:14)
0|index  |     at Module.require (internal/modules/cjs/loader.js:1044:19)
0|index  |     at require (internal/modules/cjs/helpers.js:77:18)
0|index  |     at Object.<anonymous> (/home/cxllm/Bots/Corynth/events/ready.js:2:17)
0|index  |     at Module._compile (internal/modules/cjs/loader.js:1158:30)
0|index  |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
0|index  | Emitted 'error' event on Server instance at:
0|index  |     at emitErrorNT (net.js:1336:8)
0|index  |     at processTicksAndRejections (internal/process/task_queues.js:84:21) {
0|index  |   code: 'EADDRINUSE',
0|index  |   errno: 'EADDRINUSE',
0|index  |   syscall: 'listen',
0|index  |   address: '::',
0|index  |   port: 3000
0|index  | }```
pale vessel
#

he wants to "test"

#

i said don't but he still wanted to try

golden condor
#

it was working

knotty steeple
#

well ur hosting the webhook multiple times arent u

split hazel
#

Spare yourself the troubles of sharding for the future, when you don't need sharding, you will just get increased memory usage, more headaches and etc

#

Your performance will barely improve

pale vessel
#

it'll get worse in fact

knotty steeple
#

i mean i did sharding on my 2 server bot to test

#

i didnt have to change much

split hazel
#

Having a sharded bot is a pain ๐Ÿ˜ญ

earnest phoenix
#

No

split hazel
#

On my bots features it indeed is

#

When pretty much every feature relies on communicating with other shards/clusters

earnest phoenix
#

Clusters?

split hazel
#

Yes, each cluster gets assigned a couple of shards to handle

#

Which are on different processes

knotty steeple
#

clusters are packed up shards

#

which makes half of a mirror

#

they manage multiple shards at a time

turbid bough
#

how do you make clusters?

split hazel
#

So there isn't a need to start a new process for every shard

knotty steeple
#

or use internal sharding

#

i wonder how long someone can go with that

split hazel
#

Internal sharding instantly crashes my bot

#

Not suitable

#

It's best used as a quick sharding

#

Until you can install proper sharding for the future

turbid bough
#

@golden condor if you are sharding that bot you cant launch a server within that shard.

knotty steeple
#

launch?

#

also he is using broadcastEval or is trying to

turbid bough
#

const dbl = new DBL(dbltoken, { webhookPort: 3000, webhookAuth: '' }, client);

#

Error: listen EADDRINUSE: address already in use :::3000

heavy anchor
#

I am making a very simple bot that serves one purpose, I need a database for storing different prefixes for servers but I dont think I need a sqlite server just for that, Do you think it would be acceptable to use JSON in this situation?

knotty steeple
#

it would not

turbid bough
#

json is never acceptable

knotty steeple
#

also sqlite isnt a server

#

its a db file

golden condor
#

@turbid bough then what should I do

heavy anchor
#

ik That's what I meant

knotty steeple
#

no its not

blazing portal
#

What is the problem with an sqlite file?

knotty steeple
#

thats just saying something wrong

split hazel
#

Just use sqlite if you can, if you have no clue about sql use something like keyv, sequelize etc

turbid bough
#

idk how js work, but you can try making an instance before you create the shards

golden condor
#

I tried

knotty steeple
#

u cant

turbid bough
#

not on bot.js, but on index.js

#

u. cant?

golden condor
#

i tried starting dbl.js on it's own

#

It says the port is already in use

turbid bough
#

uh, do you have something running already then?

golden condor
#

No

turbid bough
#

like, a bot

golden condor
#
Error: listen EADDRINUSE: address already in use :::3002
1|dbl  |     at Server.setupListenHandle [as _listen2] (net.js:1309:16)
1|dbl  |     at listenInCluster (net.js:1357:12)
1|dbl  |     at Server.listen (net.js:1445:7)
1|dbl  |     at DBLWebhook._startWebhook (/home/cxllm/Bots/Corynth/node_modules/dblapi.js/src/webhook.js:45:18)
1|dbl  |     at new DBLWebhook (/home/cxllm/Bots/Corynth/node_modules/dblapi.js/src/webhook.js:27:12)
1|dbl  |     at new DBLAPI (/home/cxllm/Bots/Corynth/node_modules/dblapi.js/src/index.js:69:22)
1|dbl  |     at Object.<anonymous> (/home/cxllm/Bots/Corynth/dbl.js:5:13)
1|dbl  |     at Module._compile (internal/modules/cjs/loader.js:1158:30)
1|dbl  |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
1|dbl  |     at Module.load (internal/modules/cjs/loader.js:1002:32) {
1|dbl  |   code: 'EADDRINUSE',
1|dbl  |   errno: 'EADDRINUSE',
1|dbl  |   syscall: 'listen',
1|dbl  |   address: '::',
1|dbl  |   port: 3002
1|dbl  | }
1|dbl  | Error: listen EADDRINUSE: address already in use :::3002
1|dbl  |     at Server.setupListenHandle [as _listen2] (net.js:1309:16)
1|dbl  |     at listenInCluster (net.js:1357:12)
1|dbl  |     at Server.listen (net.js:1445:7)
1|dbl  |     at DBLWebhook._startWebhook (/home/cxllm/Bots/Corynth/node_modules/dblapi.js/src/webhook.js:45:18)
1|dbl  |     at new DBLWebhook (/home/cxllm/Bots/Corynth/node_modules/dblapi.js/src/webhook.js:27:12)
1|dbl  |     at new DBLAPI (/home/cxllm/Bots/Corynth/node_modules/dblapi.js/src/index.js:69:22)
1|dbl  |     at Object.<anonymous> (/home/cxllm/Bots/Corynth/dbl.js:5:13)
1|dbl  |     at Module._compile (internal/modules/cjs/loader.js:1158:30)
1|dbl  |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
1|dbl  |     at Module.load (internal/modules/cjs/loader.js:1002:32) {
1|dbl  |   code: 'EADDRINUSE',
1|dbl  |   errno: 'EADDRINUSE',
1|dbl  |   syscall: 'listen',
1|dbl  |   address: '::',
1|dbl  |   port: 3002
1|dbl  | }```
#

No I don't

blazing portal
#

then maybe the port is already used by another application thonkku

turbid bough
#

thats what i just said lol

knotty steeple
#

no

turbid bough
#

try rebooting

#

that will fix those issues

knotty steeple
#

@golden condor does it work and also give multiple errors

#

thats not the issue

golden condor
#

It says 3000 is in use when I know it isn't

split hazel
#

Sometimes happens to me too when I listen to a port and restart

golden condor
#

I rebooting

split hazel
#

You need to kill the port

golden condor
#

*rebooted

#

ok it is back up now

#

Still got errors

pale vessel
#

just don't shard

#

bruh

wise quartz
#

Hey, so i was wondering something, My bot is made with GWcodesPython (Python) so if i wanted to make a dashboard/website for it in the future and as we know a websites requires HTML, CSS & JS so will that be possible or i'll have to remake it with GWcodesJs (JavaScript) ? MegaThonk
Ping on response

pale vessel
#

dude

#

you need backend language

wise quartz
#

And what exactly is that?

golden condor
#

I need answers

pale vessel
#

like php or nodejs

wise quartz
#

Aha

pale vessel
#

take on me

wise quartz
#

Alr ty.

split hazel
#

@golden condor this is probably caused because your thing keeps restarting/crashing and the os doesn't clean the dead port listeners quick enough, so this error will occur. If you need it now, kill the listening port, Google OSNAME kill specific port

digital ibex
#

hi

#

i'm setting up auto mod for my bot and uh, for now, it shud delete every message which contains a swear i added

    let badwords = [ 'hi', 'bye' ];
    badwords.some((e) => {
        return message.content.toLowerCase().includes(e.toLowerCase());
    })
        ? (function() {
                message.delete().catch();
            })()
        : null;
``` does anyone know why the message is not getting deleted?
#

i'm using eris

pale vessel
#

try js let badwords = ['hi', 'bye']; badwords.some(e => message.content.toLowerCase().includes(e.toLowerCase())) ? message.delete().catch(e => { return; }) : null;

digital ibex
#

ok, thank u

mossy vine
#

@pale vessel python has good webserver libraries too like flask or django

pale vessel
#

i'm a php guy mmulu

digital ibex
#

nope, doesn't delete

#

nope, doesn't delete and there are no errors

#

i added console.log(e) in the .catch

#

thing

pale vessel
#

but still no errors?

digital ibex
#

no errors

#

bot has admin, my alt has no permissions

pale vessel
#

by the way, why did you check whether the channel type was a category channel?

digital ibex
#

o

#

mb

#

which one is dm?

pale vessel
#

just make it guild text channel only, which is 0

#

because there's like group dms and stuff

digital ibex
#

kk

pale vessel
#

so != 0

#

i got it

#

did you try putting the bad word inside a command

#

the bot wouldn't respond otherwise

digital ibex
#

oh, no

pale vessel
#

unless you already did that

#

if not, put the filter on top of everything

digital ibex
#

wait, wdym put the bad words inside a command?

pale vessel
#

before you defined command and args

digital ibex
#

kk

pale vessel
#

because the bot wouldn't respond to non-commands

#

so it can't see anything (because it didn't detect a command)

digital ibex
#

ohh

pale vessel
#

put it before let prefix

#

and change args.join() to message.content

digital ibex
#

works, thank u

#

how can i ignore members who have a certain permission?

pale vessel
#

add it to the condition

digital ibex
#

like, if (!message.member.permission.has('oof') { the code i just had? }

pale vessel
#
message.content.toLowerCase().includes(e.toLowerCase()) && message.member.permission(etc etc)```
digital ibex
#

oh, ok

pale vessel
#

but still though, only staff can swear? that's odd

#

i'd suggest leaving it as is

digital ibex
#

i'll add it to a higher role so like, the higher staff can

pale vessel
#

that sounds unfair, does it not?

digital ibex
#

and yeh, i'd also leave it but shrug

pale vessel
#

well anyway, now that it worked, you can do your thing now

digital ibex
#

not really, the only reason y i'm doing it is because i'd have it like that configured for my server

#

1 othe rthing

#

something liek hilo would also get deleted

#

how can i make it, if the content of the message includes it, just hi then delete

#

like

#
- hiall <----- dont delete
+ hi all <---- delete
summer torrent
#

split message content

digital ibex
#

message.content.split(' ').. ?

summer torrent
#

.split(" ") creating an array with words of string

#

for example

#
"hi all".split(" ") // ["hi", "all"]```
earnest phoenix
#

I'd suggest using a regex to ensure that there are no empty strings

digital ibex
#

i'm shit at regex

earnest phoenix
#

For example if you had 2 spaces next to each other you'd get an empty string in between them

#

You'd use \\s+

#

meaning "any amount of whitespaces"

pale vessel
#

split(/\s+/).includes(e)

limpid pulsar
pale vessel
#

yes you can

#

using code { }

limpid pulsar
#
.blob p {
    font-size: 15px !important;
  }
<div class="blob">
<span class="subtitle"><b>what is videonet?</b></span><br>
<p class="textblobz">videonet is a new discord bot that allows you to create a simulation of a YouTube Channel on Discord! It's a simulation game that allows you to manage your very own virtual youtube channel! Upload videos, earn money and find your way through the leaderboard!</p>
</div>
#

thats what Im using

#

ignore the missing style tags

#

i didnt want to paste everything

digital ibex
#
badwords.some((e) => message.content.toLowerCase().includes(e.toLowerCase()) && message.member.permission.has('manageGuild')
//not above 
message.content.split(/\s+/).includes(e) && message.member.permission.has('manageGuild')
#

like, i can use the bottom one instead?

pale vessel
#

smh

#

message content

#

you split it

#

yes

digital ibex
#

o, ok

#

thank

limpid pulsar
#

any idea why it doesnt change?

pale vessel
#

i'm not sure which one you want to change

#

the paragraph?

limpid pulsar
#

yeah

pale vessel
#

try p.textblobz

limpid pulsar
#

textblobx

digital ibex
#
    let badwords = [ 'hi', 'bye' ];
    message.content.split(/\s+/).includes(badwords) && message.member.permission.has('manageGuild')
            ? message.delete().catch((e) => {
                console.log(e);
                return;
            })
        : null;
``` like this?
pale vessel
digital ibex
#

kk

limpid pulsar
#

Nope, didn't work

#

oh okay

#

turns out that was 15 lolol

digital ibex
#

er

#

doesn't delete

#

no errors

earnest phoenix
#

So i'm trying to get rid of songs in the song list to app||ear like this because they use 2 of these |'s which|| is actually ||very annoying|| to read..
I was told to use .replace(/\|/g, '\|') but this is not fixing anything

#

Why is it not fixing the spoiler tags, and how do i get them fixed?

turbid bough
#

.replace("||", "\|\|") ?

mossy vine
#

.replace(/\|/g, '\\|')

turbid bough
#

cause if you have | d | and | nothing | will happen right?

earnest phoenix
#

nothing gets escaped tho

mossy vine
#

or just add a zws

turbid bough
#

\| already does what it does

#

\| works

earnest phoenix
#

that won't even be executed because its not replacing anything

hasty sparrow
#

You could also use .replace(/\|\|/g, '\|\u200B\|') which will add the zero width space character and "preserve" the song name

earnest phoenix
#

/\|\|/g doesnt let the embed be sent at all tho, it seems to replace everything

turbid bough
#

can anyone tell me why .replace("||", "\|\|") this would work?

sudden geyser
#

You need two backslashes on one | to escape the spoiler markdown like Cyber showed. You'd need to replace it twice.

#

That won't work because replace will only do it once in a string.

earnest phoenix
#

oh so .replace(/\|/g, '\\|')

sudden geyser
#

as in if the same character sequence occurs, the second one won't be replaced.

#

if you use regex with the global flag, it'll replace all sequences in the string

turbid bough
#

oh, so js wont replace all || ?

earnest phoenix
#

Wow..

hasty sparrow
#

| is a special character in regexes

earnest phoenix
#

I still dont get why i need \\|

#

oh

#

that explains it

mossy vine
#

@turbid bough thats why you need the global flag ๐Ÿ˜ฉ

hasty sparrow
#

So you escape the escaping ๐Ÿ˜„

mossy vine
#

^

turbid bough
#

@"" would ignore escapings woulnt it?

earnest phoenix
#

I escape the escaping.. which escapes the escape.. which escapes the character that has to be escaped...

mossy vine
#

correct

hasty sparrow
#

Something like that

earnest phoenix
#

Well thanks it finally works now

sudden geyser
#

oh, so js wont replace all || ?
@turbid bough not unless you use a regex with the global flag.

turbid bough
#

good

mossy vine
#

'\|' will result in '|', which is still the same character so discord wont escape it

pale vessel
#

regex is cool once you get to know it

earnest phoenix
#

yeah well in normal messages \| does get escaped, doesn't it?

turbid bough
#

well, in c# it replaces all lol

pale vessel
#

no yes actually

earnest phoenix
#

||test||

#

yeah it does

#

in normal messages it does

mossy vine
#

yes, but you are doing extra string parsing in js

earnest phoenix
#

Guess thats how i f*ed up

mossy vine
#

yeah

turbid bough
#

oh wow ok i see so /text/gi isnt a string?

#

what is js

mossy vine
#

thats.. a regex

pale vessel
#

wait what

turbid bough
#

yeah i know

pale vessel
#

it's not

mossy vine
#

/text/flags literally denotes a regular expression..

turbid bough
#

im used to having regular expressions in a string.

mossy vine
#

for once thats not js being weird, its expect behavior when writing regex

pale vessel
#

what

mossy vine
#

then stay to your RegExp()

pale vessel
#

what language?

turbid bough
#

c#

pale vessel
#

yeah use RegExp() instead

mossy vine
#

you can use both

#

literally no difference

pale vessel
#

i mean if you want to pass a variable

turbid bough
#

idk Regex still inputs a string when i search for it

#

with regex on it

#

unless you are talking js right now

#

ah yeah, you are, with that docs

obtuse niche
#

How to add catagories in the help command. (discord.py)

slender thistle
#

Are you using plain on_message or commands.Bot?

obtuse niche
#

commands.Bot

slender thistle
#

Use cogs blobshrug

#

The default help command will consider cogs as categories for commands

obtuse niche
#

Ah okay thank you!

earnest phoenix
#

Hi I made this stopwatch code but instead of a time it's spitting out NaN heres the code function stopwatch(arguments, receivedMessage){
if(arguments == "start"){
receivedMessage.createdTimestamp
}
if(arguments == "stopw"){

    let i = receivedMessage.createdTimestamp - Date.now
   receivedMessage.channel.send("Elapsed time:"+i)
}

}
this is what it's spitting out- Elapsed time:NaN

#

what is wroong with it

split hazel
#

Date.now is a function @earnest phoenix

heavy anchor
#

^

earnest phoenix
#

Ik

heavy anchor
#

also to keep it clean and easier to read please send the code like this

function stopwatch(arguments, receivedMessage){
    if(arguments == "start"){
     receivedMessage.createdTimestamp
    }
    if(arguments == "stopw"){

        let i = receivedMessage.createdTimestamp - Date.now
       receivedMessage.channel.send("Elapsed time:"+i)
    }
}```
earnest phoenix
#

how u do that

turbid bough
#

i dont think you want to take lower date - higher date

earnest phoenix
#

ik

#

1 sec

#

still nan

quartz kindle
#

did you change Date.now into a function like speedy said?

earnest phoenix
#

umm no

quartz kindle
#

you said you know

earnest phoenix
#

idk how to

#

i said that to @turbid bough

quartz kindle
heavy anchor
#

Date.now()```
turbid bough
#

thats spoonfeeding

earnest phoenix
#

oh ya changed that

heavy anchor
#

ok lol

earnest phoenix
#

thx guys

#

it worked

turbid bough
#

lol

#

told you we shouldnt spoonfeed

#

now he fixed it without learning anything at all, and we did all the work

earnest phoenix
#

no

#

i saw my mistakes

#

yes they halped but it doesnt mean *spoon feeding

hasty eagle
#

Guys

#

What I need to put at website urlM

#

?

#

@everyone

cursive dagger
#

The URL to your website

hasty eagle
#

If I don't have one

#

?