#development

1 messages · Page 1555 of 1

lyric mountain
#

Let me see if I find the post

#

There

brisk gate
#

Huh, it's not a menu, it's like Slack does

#

just forms

lyric mountain
#

Kinda, but you can add buttons, images, fields, etc

#

Yeah, basically a form

#

Still an insane UX improvement

brisk gate
#

Slack had that for years

#

I think, Discord should just tell everyone "we'll slowly copy all Slacks good features"

lyric mountain
#

Lul

mellow kelp
#

i was reading the article like "wow, these guys really seem to like discord!"

brisk gate
#

It's hilarious that they call it "inovation"

mellow kelp
#

then i realized it was an article made by discord

trim saddle
#

maybe if discord made it based around any discord bots prefix

#

so we could easily add commands with easier arguments

solemn latch
#

O that would be nice

#

Or making selecting which bot your trying to use easier.
Slowest part of slash commands is when two bots have the same command and you have to get your mouse to select it.

trim saddle
#

indeed

#

now is anyone good with ts

lyric mountain
#

Tim

#

And cry maybe

trim saddle
#

well i have a weird logic error that i don't want to @ts-ignore

crystal wigeon
#

hey

#

this is not a dev question

#

but

#

can anyone help me out with this? my friend said for first 100 votes on your bot you get $15 and then $1 for every 1k vote

#

kinda confused about the whole process thing

#

marketing budget? like am i supposed to spend some $$?

delicate zephyr
crystal wigeon
#

gotcha

crimson vapor
#

in typescript if I want to say client.x = y, how can I get that typed without extending client?

sage bobcat
#

One message removed from a suspended account.

crimson vapor
#

huh

#

wdym

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

crimson vapor
#

I mean but ts will always say Property x does not exist on type Client

trim saddle
crimson vapor
#

hmm

#

ok

trim saddle
#

it's overall a better idea than just assigning variables

delicate zephyr
#

1 hour left of work ablobwobwork

trim saddle
#

luke sleep

#

smh

delicate zephyr
#

i cant

#

im at work

#

ffs

trim saddle
#

too fucking bad

delicate zephyr
trim saddle
#

i'm your boss take a nap or go home

delicate zephyr
#

cant go home

#

would literally get me fired

crimson vapor
#

your job is to stay awake

#

don't lose your job

lethal trout
#
const { inspect } = require("util");

const Discord = require("discord.js")

module.exports = {
    name: 'eval',
    description: '**ONLY DEVELOPER**',
    run: async (client, message, args) => {

        // Number Of Guilds! client.guilds.cache.map(s => s.name)

        const evalcommand = args.slice(0).join(" ")

        if (message.author.id !== "725945760629129277") return message.channel.send('![alertsign](https://cdn.discordapp.com/emojis/804384566600663080.webp?size=128 "alertsign") Only the Developer of the bot can use this command!')

        if (!evalcommand) return message.channel.send("Please specify something to Evaluate")

        try {
            const evaled = eval(evalcommand)

            let evalembed = new Discord.MessageEmbed()
                .setColor('#f03824')
                .setTitle('Evaluated')
                .addField(`Input`, `\`\`\`${evalcommand}\`\`\``)
                .addField(`Output`, `\`\`\`js\n${inspect(evaled, { depth: 0 })}\`\`\``)
                .addField(`TypeOf`, `\`\`\`${typeof (evaled)}\`\`\``)

            message.channel.send(evalembed)
        } catch (error) {
            let embed1 = new Discord.MessageEmbed()
                .setColor('#f03824')
                .setTitle('![alertsign](https://cdn.discordapp.com/emojis/804384566600663080.webp?size=128 "alertsign")Error![alertsign](https://cdn.discordapp.com/emojis/804384566600663080.webp?size=128 "alertsign")')
                .addField(`Error`, `${error}`)
            message.channel.send(embed1)
        }
    }
}

How can i make it to send it in many embeds?

pale vessel
#

paginate or split the value

lethal trout
river panther
#

@tight heath when i run that code it send it like this, i want the emoji name first then the id, how do i do that?

tight heath
#

switch .id and .name

river panther
#

done

#

it doesn't send the json then

tight heath
#

also please don't ever @mention me again

river panther
#

ok

nimble kiln
#

discord.js: Does anyone here have experience with the ratelimits when sending messages to multiple webhooks at once?

river panther
#

oh yes

#

worked

tight heath
#

each webhook has its own rate limits

#

also that's not really a djs thing

nimble kiln
#

ok true, then it's more a discord api question itself

#

But what would happen if I send one message to 400 webhooks at the same time? 🙂

tight heath
#

it'd work, probably

nimble kiln
#

Interesting Thonk

misty sigil
#

probably

tight heath
#

webhooks are independent kinda

nimble kiln
#

cause you know, there's a global ratelimit for regular messages (not webhook)

#

that's why I'm asking

misty sigil
#

how would they globally rate webhooks reliably

misty sigil
#

.substr()

nimble kiln
misty sigil
nimble kiln
#

I guess i should test it out then, lets see how well discord likes it when the numbers grow

lethal trout
misty sigil
#

n2 +

#

missing a plus bro

sudden geyser
rustic nova
#

Nah that's fine

sudden geyser
#

oh wait I'm blind

#

I didn't see the missing pluses

rustic nova
#

Matthew is right

misty sigil
#

finally I got something right

silent cloud
#

Hey guys, does anyone can help me

#

When im trying to play music through lavalink, i have this error

#

INVALID_HOST: No available node with 1

lethal trout
#
const { inspect } = require("util");

const Discord = require("discord.js")

module.exports = {
    name: 'eval',
    description: '**ONLY DEVELOPER**',
    run: async (client, message, args) => {

        // Number Of Guilds! client.guilds.cache.map(s => s.name)

        const evalcommand = args.slice(0).join(" ")

        if (message.author.id !== "725945760629129277") return message.channel.send('![alertsign](https://cdn.discordapp.com/emojis/804384566600663080.webp?size=128 "alertsign") Only the Developer of the bot can use this command!')

        if (!evalcommand) return message.channel.send("Please specify something to Evaluate")

        try {
            const evaled = eval(evalcommand)

            let evalembed = new Discord.MessageEmbed()
                .setColor('#f03824')
                .setTitle('Evaluated')
                .addField(`Input`, `\`\`\`${evalcommand}\`\`\``)
                .addField(`Output`, `\`\`\`js\n${inspect(evaled, { depth: 0 })}\`\`\``)
                .addField(`TypeOf`, `\`\`\`${typeof (evaled)}\`\`\``)

            message.channel.send(evalembed)
        } catch (error) {
            let embed1 = new Discord.MessageEmbed()
                .setColor('#f03824')
                .setTitle('![alertsign](https://cdn.discordapp.com/emojis/804384566600663080.webp?size=128 "alertsign")Error![alertsign](https://cdn.discordapp.com/emojis/804384566600663080.webp?size=128 "alertsign")')
                .addField('Error', `${error.message}`)
            message.channel.send(embed1)
        }
    }
}   
solemn jolt
#

@lethal trout try this

const { inspect } = require("util");

const Discord = require("discord.js")

module.exports = {
    name: 'eval',
    description: '**ONLY DEVELOPER**',
    run: async (client, message, args) => {

        // Number Of Guilds! client.guilds.cache.map(s => s.name)

        const evalcommand = args.slice(0).join(" ")

        if (message.author.id !== "725945760629129277") return message.channel.send(':alertsign: Only the Developer of the bot can use this command!')

        if (!evalcommand) return message.channel.send("Please specify something to Evaluate")

        try {
            const evaled = eval(evalcommand)

            let evalembed = new Discord.MessageEmbed()
                .setColor('#f03824')
                .setTitle('Evaluated')
                .addField(`Input`, `\`\`\`${evalcommand}\`\`\``)
                .addField(`Output`, `\`\`\`js\n${inspect(evaled, { depth: 0 })}\`\`\``)
                .addField(`TypeOf`, `\`\`\`${typeof (evaled)}\`\`\``)

            message.channel.send(evalembed)
        } catch (error) {
            let embed1 = new Discord.MessageEmbed()
                .setColor('#f03824')
                .setTitle(':alertsign:Error:alertsign:')
                .addField("Error", error)
            message.channel.send(embed1)
        }
    }
}   
solemn jolt
#

Line 33 change addfield

lethal trout
#

ko

#

ok

dark thorn
#

Okay so, I'm trying to make the bot return an action if "botin" value is = null, tried with botin = ; == ; === null/undefined not sure what I'm doing wrong

P.s: Trying to make it join a voice channel.

Here's the code:

const botin = message.guild.me.voice.channel.id;
if(botin === null) {

        bot.channels.cache.get(channel).join()
        const embed = new Discord.MessageEmbed()
        .setTitle('Join')
        .setColor('BLUE')
        .setDescription('Bot has joined your channel!')
        message.channel.send(embed);

    }

And basically this is the error:

(node:19896) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'id' of null

Ping me if you answer ^^

misty sigil
#

try !botin

#

lmfao

solemn jolt
dark thorn
#

Doesn't works because it's supposed to be a null value

#

And the ! still not define anything

restive furnace
# solemn jolt Why?

spoonfed him, usually we just guide these to go right way, not giving the answer immodialely

dark thorn
#

!null = null

sacred aurora
restive furnace
solemn jolt
dark thorn
#

The thing is that I need it to be null

sacred aurora
dark thorn
#

And if it detects that it's a null value, then return

sacred aurora
sacred aurora
solemn jolt
#
const botinC = message.guild.me.voice.channel;
if (botinC) {
  let botin = botinC.id
}

And this is for getting channel id

sacred aurora
#

yeah thats the same

solemn jolt
sacred aurora
#

can i use mongodb to store a file?

#

hmmm broken lang

solemn jolt
#

I think yes

sacred aurora
#

just simply save it?

#

or should i save it as binary

solemn jolt
sacred aurora
#

wait really??

solemn jolt
#

Yes 👍

sacred aurora
#

but how

#

i mean file like images

#

or a audio file

#

not a simple text

solemn jolt
#

If database key is Alex
Just type
Alex.save()

solemn jolt
#

For img just you can save the URL or Link

sacred aurora
#

welp

dark thorn
#
const channel = message.member.voice.channel.id;
const botin = message.guild.me.voice.channel.id;
 
let isPlaying = bot.player.isPlaying(message.guild.id);
    if(isPlaying) {
        let embedno = new Discord.MessageEmbed()
        .setTitle('Error')
        .setColor('RED')
        .setDescription('The bot is already playing into another channel!')
        message.channel.send(embedno);
    } else if(botin === null) {

        bot.channels.cache.get(channel).join()
        const embedyes = new Discord.MessageEmbed()
        .setTitle('Join')
        .setColor('BLUE')
        .setDescription('Luxury has joined your channel!')
        message.channel.send(embedyes);

    } else if (botin === channel) {
        const embedin = new Discord.MessageEmbed()
        .setTitle('Error')
        .setColor('RED')
        .setDescription('Luxury already joined your channel!')
        message.channel.send(embedin);

    } else {
        bot.channels.cache.get(channel).join()
        const embedyes = new Discord.MessageEmbed()
        .setTitle('Join')
        .setColor('BLUE')
        .setDescription('Luxury has joined your channel!')
        message.channel.send(embedyes);
    }
}

This is the full command code tho, I'm trying to make a "join" command for a music bot. (P.s: Maybe here you can see why I can't simply use const botin = message.guild.me.voice.channel;)

sacred aurora
#

does discord attachment have expired date

dark thorn
#

No, anyways already tried it and still not works

solemn jolt
#
const channel = message.member.voice.channel;
const botin = message.guild.me.voice.channel;
 
let isPlaying = bot.player.isPlaying(message.guild.id);
    if(isPlaying) {
        let embedno = new Discord.MessageEmbed()
        .setTitle('Error')
        .setColor('RED')
        .setDescription('The bot is already playing into another channel!')
        message.channel.send(embedno);
    } else if(botin === null) {

        channel.join()
        const embedyes = new Discord.MessageEmbed()
        .setTitle('Join')
        .setColor('BLUE')
        .setDescription('Luxury has joined your channel!')
        message.channel.send(embedyes);

    } else if (botin === channel) {
        const embedin = new Discord.MessageEmbed()
        .setTitle('Error')
        .setColor('RED')
        .setDescription('Luxury already joined your channel!')
        message.channel.send(embedin);

    } else {
        channel.join()
        const embedyes = new Discord.MessageEmbed()
        .setTitle('Join')
        .setColor('BLUE')
        .setDescription('Luxury has joined your channel!')
        message.channel.send(embedyes);
    }
}
dark thorn
#

But that's not the point, is it possible in JS to return if the value is null?

sacred aurora
#

but isn't it spoonfeed again bruh

dark thorn
#

Awesome, worked

#

What did you do btw?

solemn jolt
#

@dark thorn bro when you get a key for channel you don't need type bot.channels.cache.get(. . .)
Just if key === channel
Type channel.join()

dark thorn
#

Weird, tried doing channel.join() before and didn't worked

#

Anyways, thx for the help

solemn jolt
#

And for channel you can type
const botinC = message.guild.me.voice.channel.id
This but I'd message.guild.me.voice.channelvalue === null
The bot getting error becouse can't get channel id if channel is null

sacred aurora
#

well its an id before

solemn jolt
dark thorn
#

Gotcha

earnest phoenix
#

Wouldn't just the else block be sufficient though

quasi forge
#

Hello, I was adding some stuff to https://disco-oauth.now.sh/. I just added the ability to have https://discord.com/developers/docs/topics/oauth2#state-and-security this. I was also working on adding some optional middleware for various server modules so users can just have it all set up in 1 go. Does anyone have ideas on what settings can I allow the user to modify besides the following: -

/**
 * Path settings for middleware functions.
 * @typedef {Object} PathSettings
 *
 * @property {String} auth The path where the user needs to be redirected to for authentication.
 * @property {Array<String>|String} all The paths where all of the user's data will be available.
 * @property {Array<String>|String} user The paths where just the user object will be available.
 * @property {Array<String>|String} guilds The paths where just the user's guilds will be available.
 * @property {Array<String>|String} connections The paths where just the user's connections will be available.
 */

/**
 * Helper middleware settings
 * @typedef {Object} MiddlewareSettings
 *
 * @property {String} id The discord application's client ID.
 * @property {String} secret The discord application's client secret,
 * @property {Array<String>} scopes The OAuth2 scopes that will authorize.
 * @property {String} base The base url for all the paths in Path settings.
 * @property {PathSettings} paths The path settings for various purposes.
 * @property {String} redirect The url where the user will be redirected to after authentication.
 */
lament rock
#

while not strictly what you're asking, you should use string instead of String for type defs. Same for boolean vs Boolean and number vs Number
the capital variants reference the Constructor Function of the respective types while the lower case versions reference the primitive types which is intentional

quasi forge
#

Wait, you're right, why had I not realised that yet

lament rock
#

Common mistake. It's fine :)

crimson vapor
#

Hello PapiOphidian

quasi forge
near stratus
#

Can anyone show me a slash command oauth2 URL format ?
I know it should contain applications.commands or something but how should it look like ?

#

anyone ?

earnest phoenix
#

I made some events but the bot only replies on the last event . There is no error too

hasty mulch
#

REEEEE, having API issues again

#
...
embed=discord.Embed(
    type='rich',
    colour=discord.Color(0x4C128E),
    description=f'''
...

**Alert(s):** {res3.get('title')}

(Please note that alerts and sunrise/sunset times come in as EST while server time is 1 hour ahead of EST)
'''
    )
embed.set_author(name="CURRENT SERVER WEATHER", icon_url='https://cdn.discordapp.com/attachments/781808819705217034/789673205018525706/8fb49e66641f72b64cf9ce1b9568dc65.png')
embed.set_footer(text="Developed by LIPD Producctions Inc.#1205")
embed.timestamp=datetime.datetime.utcnow() + datetime.timedelta(hours=1)
channel = self.bot.get_channel(771353867694506026)
await channel.send(embed=embed)

Produces: (Rest of code does not affect problem area)

#

Data when I do {res3['alerts'):

[{'regions': ['Western Bergen', ' Northern Middlesex', ' Eastern Passaic', ' Richmond (Staten Is.)', ' Rockland', ' Southern Fairfield', ' Eastern Union', ' Western Passaic', ' Southern Queens', ' Western Union', ' New York (Manhattan)', ' Southern Middlesex', ' Hudson', ' Northern New Haven', ' Northern Queens', ' Western Essex', ' Northern New London', ' Eastern Bergen', ' Southwest Suffolk', ' Northern Westchester', ' Southern Nassau', ' Kings (Brooklyn)', ' Putnam', ' Bronx', ' Eastern Essex', ' Southern Westchester', ' Northwest Suffolk', ' Southern New Haven', ' Northern Nassau', ' Northern Fairfield'], 'ends_utc': '2021-02-02T11:00:00', 'effective_local': '2021-01-30T03:40:00', 'onset_utc': '2021-02-01T05:00:00', 'expires_local': '2021-01-30T15:00:00', 'expires_utc': '2021-01-30T20:00:00', 'ends_local': '2021-02-02T06:00:00', 'uri': 'https://api.weather.gov/alerts/NWS-IDP-PROD-4745120-3838902', 'onset_local': '2021-02-01T00:00:00', 'effective_utc': '2021-01-30T08:40:00', 'severity': 'Warning', 'title': 'Winter Storm Watch issued January 30 at 3:40AM EST until February 2 at 6:00AM EST by NWS New York NY', 'description': '* WHAT...Heavy snow possible. Total snow accumulations of 6 to 9\ninches possible. Winds could gust as high as 45 mph.\n\n* WHERE...Portions of northeast New Jersey, southern Connecticut\nand southeast New York.\n\n* WHEN...From late Sunday night through late Monday night.\n\n* IMPACTS...Travel could be very difficult. The hazardous\nconditions could impact the morning and evening commute.'}]

#

Language is Python

earnest phoenix
#

so why are you getting the title from res3 instead?

hasty mulch
earnest phoenix
#

you should've done something like res3['alerts'][0]['title'], right?

#

what you're doing is res3['title'] instead

hasty mulch
earnest phoenix
#

you can't index a list with string, so for loop. Or just a list comprehension.

fluid basin
#

python list comprehension, google it if you dont know what it is

#

basically its a loop

earnest phoenix
#

a 1 line loop

#

assuming title is nullable and you're using 3.8+, [title for i in res3['alerts'] if (title:=i.get('title'))] will return a list of titles.

hasty mulch
#

And will this put each title instance on a new line?

earnest phoenix
#

just join them shrug

hasty mulch
#

That’s what I’m trying to figure out

earnest phoenix
hasty mulch
#

@earnest phoenix ```py
res3 = {"alerts": [{"title": "one"}, {"title": "two", "other": 33333}]}
newline = '\n'
a = f'''
...

Alert(s): {' '.join(alert['title'] for alert in res3.get('alerts', []).split(newline))}

(Please note that alerts and sunrise/sunset times come in as EST while server time is 1 hour ahead of EST)
'''
print(a)

As an example?
earnest phoenix
#

you're joining it with space

#

why are you splitting it with newline though?

hasty mulch
#

Can’t use backslash in f-string

earnest phoenix
#

I mean

#

newline.join(...

hasty mulch
#

Says it’s invalid syntax

earnest phoenix
#

huh?

#

what did you type?

hasty mulch
#
res3 = {"alerts": [{"title": "one"}, {"title": "two", "other": 33333}]}
newline = '\n'
a = f'''
...

**Alert(s):** {' 'newline.join(alert['title'] for alert in res3.get('alerts', []))}

(Please note that alerts and sunrise/sunset times come in as EST while server time is 1 hour ahead of EST)
'''
print(a)
earnest phoenix
#

I mean ofc it's invalid syntax, ' ' is still there

hasty mulch
#

Oh

#

Can I do newline newline or just save the trouble and do a double \n in the reference?

earnest phoenix
#

I know one of it is invalid, but just try it and see lol

hasty mulch
#

Lol, I’m going to get you back for that! 😂

hasty mulch
#

I will be getting you back though Kappa

earnest phoenix
#

👍

quick ridge
#

In mongoose connection i got operation server.findOne() buffering timed out after 10000ms error spam what can i do

lusty quest
#

the connection is successfully made?

#

and server is your model?

quick ridge
#

Sometimes yes

#

Yep

lusty quest
#

sometimes?

quick ridge
#

Yes sometimes connection is done succes

lusty quest
#

this could be the issue then

#

where is your bot and your database hosted?

quick ridge
#

I use vps

lusty quest
#

both on the same machine?

quick ridge
#

Nope

lusty quest
#

so one VPS for Bot and one for Database?

quick ridge
#

Its atlas not local

lusty quest
#

ok

#

is your VPS ip whitelisted?

quick ridge
#

I was try it for my vps ip

#

Its not works

lusty quest
#

did you know how to whitelist the IP?

quick ridge
#

I was did in here

lusty quest
#

wtf no NEVER whitelist 0.0.0.0

#

this gives everyone access

quick ridge
#

When i use my own ip adress its not working too

lusty quest
#

add the IP of you VPS

quick ridge
#

Just right

#

Just my vps ip

lusty quest
#

and if you want to connect from your PC with compass add your Pcs IP but with a TTL

quick ridge
#

I will try ty

#

Just 1 ip its works i think

lusty quest
#

ive used Atlas for a while and you can whitelist more than one IPs

quick ridge
#

I always did with 0.0.0.0

lusty quest
#

0.0.0.0 binds it to no IP -> everyone who knows your connection string could try to bruteforce into your DB

quick ridge
#

I understand ty for helping bro

lusty quest
#

also they dont even need to know the string

#

they could just scan for open ports

quick ridge
#

Thank you so much bro <3

golden condor
#

There is some excuses for it, such as having a dynamic IP, or using a service where you don't know the IP

lusty quest
#

Use a VPN then

#

there is not really a excuse for an Open port, exept you want people having access to it

hasty mulch
#

@earnest phoenix It gave an error

#
Unhandled exception in internal background task 'weatherembed_loop'.
Traceback (most recent call last):
  File "/home/pi/.local/lib/python3.8/site-packages/discord/ext/tasks/__init__.py", line 101, in _loop
    await self.coro(*args, **kwargs)
  File "/home/pi/Documents/Room_Sealer/cogs/room-sealer-weather.py", line 99, in weatherembed_loop
    **Alert(s):** {newline.join(alert['title'] for alert in res3.get('alerts', []))}
AttributeError: 'list' object has no attribute 'get'
earnest phoenix
#

what is res3

#

are you shadowing res3 with a list

hasty mulch
#

No

#

Res3 is literally pulled from the API, I’m not touching it

earnest phoenix
#

tru printing it then

#

Is it possible to check if the user has admin perms without members intent

hasty mulch
earnest phoenix
#

print it lol

hasty mulch
#

And the eval I showed you did work

earnest phoenix
#

`@client.command(pass_context=True)
@commands.has_permissions(manage_messages=True)
async def clear(ctx, limit: int):
await ctx.channel.purge(limit=limit)
await ctx.send('Cleared by {}'.format(ctx.author.mention))
await ctx.message.delete()

@on_error
async def clear_error(ctx, error):
if isinstance(error, commands.MissingPermissions):
await ctx.send("You are missing the permission to manage message to use that!")`

#

what should i use instead on @on_error

slender thistle
#

try-except is reasonable

hasty mulch
earnest phoenix
#

@slender thistle

#

dobol ping

#

oh

#

sorry

#

now i will get mute so bye pandasad

quartz kindle
slender thistle
#

Your reply already mentioned me, no need for another one

Meaning you can handle errors with a simple try-except branch instead of using an on_error

earnest phoenix
earnest phoenix
#

you use @clear.error not @on_error

slender thistle
#

@hasty mulch show what res3 outputs

earnest phoenix
#

if you wish to handle MissingPermissions from all commands, then use on_command_error

#

try and except won't work since the function won't run in the first place ig

slender thistle
#

In the command itself

earnest phoenix
#

unless you're handling the error from purge

slender thistle
#

Oh for fuck's sake

earnest phoenix
slender thistle
#

Ya, fix the decorator

hasty mulch
earnest phoenix
#

it's indeed a dict, not a list, so there's no way it raised that error think

slender thistle
#

'Tis why I slap typing annotations everywhere

earnest phoenix
#

does it make any difference in python though?

#

Aren't those ignored

digital beacon
#

Hey, I have a small question

slender thistle
#

They are, but if you use an IDE, it's quite convenient

digital beacon
#

Well I want to add a Levelsystem to my musicbot, so each second the user is in the same channel as the bot AND the bot is playing counts as XP

slender thistle
#

Ya, my IDE yells at me for incorrect types and i love it

hasty mulch
earnest phoenix
#

that's why you print that, it won't harm you lol

hasty mulch
#

@earnest phoenix I can’t

cobalt spruce
#

Fleche1CODEFleche2
it took me 5 sec to make lol

digital beacon
digital beacon
lament rock
#

in a structured database

quartz kindle
#

compare timestamps when a user joins or leaves the voice channel

digital beacon
lament rock
#

You might need to store how long a user has been listening once a method which pauses playback/stops is called. You could increment the amount of time by the last time the queue was paused/started if last pause is null or whatever. Then if a user leaves or queue stops, you could write changes

#

Instead of dealing with an interval or what have you, I feel like that would be more efficient

quartz kindle
#

exactly

#

dont count how many seconds the person is inside the room, write down then they entered and when they left, and calculate the time spent inside

digital beacon
#

Okay, thanks :)

#

Only thing there is, that I can't have live levelups

earnest phoenix
#

you can calculate when it's going to happen

#

remember that you're the one who has the data

silent cloud
#

Tim

#

Are you here?

quartz kindle
#

no

silent cloud
#

Bruh

#

Okey, can you help me

pale vessel
#

he said he's not here 😩

earnest phoenix
#

who's tim

silent cloud
#

Lie!

#

When i trying to play music trough lavalink i have this error

#

INVALID_HOST: No available node with 1

#

Lavalink 100% connected to my server, and code is correct

lusty quest
#

if the code would be correct it would work

silent cloud
#

...

#

Check terminap

lusty quest
#

there is somewhere an error in your code.

silent cloud
#

YOU GENIUS

pale vessel
lusty quest
#

there is no need to get salty about it

silent cloud
#

Why do I come across such geniuses?

lusty quest
#

but you try to connect to a lavalink instance with probably the wrong credentials

silent cloud
#

Node_modules that's my code ?

tribal siren
#

How to get the attachment from a message?

silent cloud
#

?

#

Wrong credentials?

lusty quest
#

if you dont want help just say it, i dont really enjoy working with salty people

tribal siren
eternal osprey
#

hey guys

#
Debugger attached.
TypeError: message.author.setNickname is not a function```
tribal siren
#

that should work

eternal osprey
#
 const myArray = [
        "slut","good dancer","i am gay","playboy","Schoolshooter","Diamond Hoe","Isaac Newton","gayboy","Official Retard","i am a retard","asshole","Lonely ass boy", "tiktok famous",  "racist" ,  "rapist" ,  "Sweet home alabama", "child predator" ,"Weak ass boy","Balls o'steel","Mike Coxlong"
      ];
      
      const randomItem = myArray[Math.floor(Math.random()*myArray.length)]
      if(message.author.id !== client.user.id){
      message.author.setNickname(randomItem)
      
      }```
silent cloud
#

I need help, but why did you say about my code wrong, if error incoming from node_modules file

eternal osprey
#

i suppose message.member and message.author are the same.

tribal siren
#

not quite

lusty quest
eternal osprey
#

owh

tribal siren
#

message.author == message.member.user

tribal siren
#

setNickname is not a user function

marble juniper
#

its a member function

eternal osprey
#

owh okay

marble juniper
#

the user object has nothing to do with the server

lusty quest
marble juniper
#

only the member object

tribal siren
#

or use message.author.edit({ nickname: YOUR_NICKNAME })

#

both cases work

silent cloud
#

Yea

#

Thats my .env

eternal osprey
#
  var pingperson1 = message.guild.members.cache.random()
      pingperson1.setNickname(randomItem)```
#

this would work too i suppose, but not for the author. It just selects 1 random member which is okay in my case.

hasty mulch
#

@earnest phoenix Bot just needed a fucking restart

silent cloud
#

LAVALINK_NODES=[{"host": "here is my ip, ye", "port": port is here, "password": "password is here", "region": "eu"}]

lusty quest
#

did you pass everything as needed as string or as number?

#

bcs it gets a 1

#

this is why i guess you added the ip as number not as string

silent cloud
#

No

#

My ip not in number

#

It de17.falix........

lusty quest
#

so you use a domain?

silent cloud
#

Nope

lusty quest
#

there is not much left lol

eternal osprey
#
 const randomItem = myArray[Math.floor(Math.random()*myArray.length)]
      if(message.author.id !== client.user.id){
        message.author.edit({ nickname: randomItem })
      
      }
    ```i still get the same error btw
silent cloud
#

Hosting gives me ip and port actually

eternal osprey
#

TypeError: message.author.edit is not a function

lusty quest
#

yea but what you supplied is either a domain or hostname

silent cloud
#

Check

lusty quest
#

but you make sure everything you supply is in the needed format?

silent cloud
#

Thats ip

marble juniper
#

nipe ip

lusty quest
#

thats not an ip

silent cloud
#

And after : that's port

lusty quest
#

thats an hostname

marble juniper
#

lol

#

thats not an ip

silent cloud
#

I saw it in video wtf

#

I can give link on video

lusty quest
#

but should still work

#

but you got somewhere a 1 in your connection stuff that just say 1.

silent cloud
#

Hm

#

Lavalink server sais it successfully sends song

#

Check

lusty quest
#

but you still have the same error?

lusty quest
#

the error is still the same?

silent cloud
#

Of course

#

I sit on it error around 3 days, and cant find answer

#

Everywhere

lusty quest
#

i dont do music bots bcs they are a pain in the ass to work with, but give me a sec maybe i find something

pale vessel
pale vessel
#

and it's { nick } not { nickname }

lusty quest
# silent cloud Kk

what lavalink package did you use and what version is your lavalink server?

silent cloud
#

Ohhhh

#

Wait

#

Im using last lavalink package and....

pale vessel
lusty quest
#

there are like 2 or 3 different lavalink packages

pale vessel
#

That's latest stable

lusty quest
#

there are a few

silent cloud
#

Lavacord

lusty quest
#

when you define your nodes did you give them ids?

silent cloud
#

@lavacord/discord.js

#

Package

silent cloud
#

Nodes id

#

Hmmmm

#

Yes, i think yes

lusty quest
#
const nodes = [
    { id: "1", host: "localhost", port: 2333, password: "youshallnotpass" }
];
``` this is how they want it to be in the github repo
silent cloud
#

=> i need to add id: ""

#

?

#

Thats it?

lusty quest
#

idk never used the package

#

try the id you got there but idk if its the correct one

silent cloud
#

Ohhh, lets try

#

Ohhhh, daemon down again

#

BRUH

young flame
#

ooof

#

i think its beause canvas constructor has been updated and i didnt install it

#

gimmie a sec

lusty quest
silent cloud
#

Try delete it

#

And install again

#

It helped for me

young flame
#

im using canvas-constructor

#

not really canvas itself

silent cloud
#

Oh

young flame
#

lol

#

uH

#

according to the docs its right tho

#

o

#

i was looking at outdated docs

#

rip

silent cloud
#

Lol

young flame
#

wlep

#

i updated code and it still no work

#

guess i have to learn canvas

#

H

earnest phoenix
#

How to check if the bot has permission to send a message in the channel

#
let channels = client.guilds.cache.get(message.guild.id).me.permissions.has("EMBED_LINKS").channels
 console.log(channels)```
#

Pls help me

earnest phoenix
#

Türkmüsün

#

?

#

@earnest phoenix

#

how do i remove

slender thistle
rustic nova
#

remove code grant

slender thistle
#

make sure that thing is off

#

P.S. it's on your bot's application page

earnest phoenix
#

I closed and I will try

#

Thnx

cobalt spruce
#

does any one here code with dart?

tribal siren
#

What does Client Secret do?

umbral zealot
#

It's for use with OAuth2 flows.

#

aka "Login With Discord"

tribal siren
#

and what's the public key for?

#

OAuth2 too?

lyric mountain
#

Most stuff in applications are for oauth2

#

Bot stuff are inside bot section

barren brook
#
    at Client.<anonymous> (C:\Users\YouTu\go\src\hello-world\hello-world\index.js:22:1)
    at Client.emit (events.js:315:20)
    at MessageCreateAction.handle (C:\Users\YouTu\go\src\hello-world\hello-world\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
    at Object.module.exports [as MESSAGE_CREATE] (C:\Users\YouTu\go\src\hello-world\hello-world\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
    at WebSocketManager.handlePacket (C:\Users\YouTu\go\src\hello-world\hello-world\node_modules\discord.js\src\client\websocket\WebSocketManager.js:384:31)
    at WebSocketShard.onPacket (C:\Users\YouTu\go\src\hello-world\hello-world\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)
    at WebSocketShard.onMessage (C:\Users\YouTu\go\src\hello-world\hello-world\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
    at WebSocket.onMessage (C:\Users\YouTu\go\src\hello-world\hello-world\node_modules\ws\lib\event-target.js:132:16)
    at WebSocket.emit (events.js:315:20)
    at Receiver.receiverOnMessage (C:\Users\YouTu\go\src\hello-world\hello-world\node_modules\ws\lib\websocket.js:825:20)```
I do not know how to define this, Its suppost to be a embed but idk how to make it send.
umbral zealot
#

message.channel maybe?

barren brook
#

I feel like an idiot, Thanks.

young flame
#

@umbral zealot question

#

does enmap has ruby support

umbral zealot
#

Or just ask your question

#

RUBY???

young flame
#

or like c#-

umbral zealot
#

Dude I write node.js. Javascript.

young flame
#

whats funny .__.

umbral zealot
#

Who the fuck still uses Ruby

young flame
#

im not using ruby i just asked if it had it

#

smh

umbral zealot
#

It also doesn't have clojure, php, python, c++, dotnet, asp, rust, kotlin, c, d, e, f, g, h, i, j, k or r support. Because it's a NODE modules.

young flame
#

i mean

#

you could've just said its node only

green cosmos
#

uh oh, how do i set details when compiling c++ using g++

#

i cant seem to find anthn

umbral zealot
#

Didn't think I needed to say it was node only considering it's written in JS and is available on NPM.

young flame
#

lavalnk has support for many lags and its written in java on NPM so

barren brook
#
(Use `node --trace-warnings ...` to show where the warning was created)
(node:12608) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:12608) [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.```
Anyone?
rustic nova
#

Handler.js, line 39 probably

#

check

young flame
#

just check to see if its a file you have

#

like if it says error at /libs/LIB/process handler or something its probs not you

#

or you coded it le weong

#

wrong*

barren brook
#

Ok, I have nothing wrong in the coding tho?

young flame
#

show code

barren brook
#

    if (message.content === "=pinging")
    var pingEmbed = new Discord.MessageEmbed()
    .setColor("GREEN")
    .setTitle('Pinging Administrative Users')
    .setAuthor("Flyer Empire", "https://i.imgur.com/fG9jEUE.jpg","https://i.imgur.com/fG9jEUE.jpg")
    .setDescription("If you need help please make a ticket, Do not ping admins, Punishments could be given!")
    .setThumbnail("https://i.imgur.com/fG9jEUE.jpg")
    .setImage('https://i.imgur.com/fG9jEUE.jpg')
    .setTimestamp()
    .setFooter('Flyer Empire Ping Message', 'https://i.imgur.com/fG9jEUE.jpg')

message.channel.send(pingEmbed)
});```
Trying to make a basic embed
young flame
#

why dont you like

#

use let

#

instead of var

#

var is variable

barren brook
#

Ok

young flame
#

its mainly used for arrays

#

let and const should work fine

barren brook
#
    ^^^

SyntaxError: Lexical declaration cannot appear in a single-statement context
←[90m    at wrapSafe (internal/modules/cjs/loader.js:979:16)←[39m
←[90m    at Module._compile (internal/modules/cjs/loader.js:1027:27)←[39m
←[90m    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)←[39m
←[90m    at Module.load (internal/modules/cjs/loader.js:928:32)←[39m
←[90m    at Function.Module._load (internal/modules/cjs/loader.js:769:14)←[39m
←[90m    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)←[39m
←[90m    at internal/main/run_main_module.js:17:47←[39m```
young flame
#

hm

#

its javascrip or node js

#

javascript*

barren brook
#

it is discord.js, So javascript

young flame
#


const prefix = '=';

    if (message.content.startsWith(prefix + 'pinging') {
    let pingEmbed = new Discord.MessageEmbed()
    .setColor("GREEN")
    .setTitle('Pinging Administrative Users')
    .setAuthor("Flyer Empire", "https://i.imgur.com/fG9jEUE.jpg","https://i.imgur.com/fG9jEUE.jpg")
    .setDescription("If you need help please make a ticket, Do not ping admins, Punishments could be given!")
    .setThumbnail("https://i.imgur.com/fG9jEUE.jpg")
    .setImage('https://i.imgur.com/fG9jEUE.jpg')
    .setTimestamp()
    .setFooter('Flyer Empire Ping Message', 'https://i.imgur.com/fG9jEUE.jpg')

    message.channel.send(pingEmbed)
} 
#

missing brackets

#

and you should add startsWith

barren brook
#

Ok

young flame
#

instead*

quartz kindle
barren brook
#
←[90m    at wrapSafe (internal/modules/cjs/loader.js:979:16)←[39m
←[90m    at Module._compile (internal/modules/cjs/loader.js:1027:27)←[39m
←[90m    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)←[39m
←[90m    at Module.load (internal/modules/cjs/loader.js:928:32)←[39m
←[90m    at Function.Module._load (internal/modules/cjs/loader.js:769:14)←[39m
←[90m    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)←[39m
←[90m    at internal/main/run_main_module.js:17:47←[39m``` This came up with your code @young flame
young flame
#

o they removed the old lavalink

quartz kindle
#

npm is a package manager for javascript, it doesnt have stuff for other langs

#

it may have stuff that is "based" on something else in another lang, but still provides ways to use it in javascript

south sinew
#

I'm encountering errors with voice connections currently, my bot will at random throw a 522 error while in a vc causing it to crash, is anyone else having this issue and/or is there a known fix?
It's signifying a timed out connection, which doesn't make a ton of sense considering sometimes it happens when the bot is playing an audio stream without any hitches

lusty quest
#

will help you finding this stuff you struggle with

barren brook
#

Thank you @lusty quest

young flame
#

wut

young flame
lusty quest
young flame
#

it got removed

south sinew
young flame
#

its le linkus

barren brook
#

its the links?

young flame
#

ye

south sinew
#

it's originating from ws, specifically in /ws/lib/websocket.js at line 604

lusty quest
barren brook
#

How do i fix them, Do you got a uploader?

south sinew
young flame
#

remove the links on the .setAauthor

#

author*

barren brook
#

k

barren brook
sacred aurora
#

the link shouldn't be the problem

#

can i see the code?

lusty quest
#

did you installed the error lense?

#

if yes it should highlight the line that errors

sacred aurora
barren brook
#

Yea

quartz kindle
sacred aurora
#

this one missing )

if (message.content.startsWith(prefix + 'pinging')
#

it should be

if (message.content.startsWith(prefix + 'pinging'))
#

isn't it?

#

is it fixed?

#

hmmm

#

ffs

barren brook
#

Nope

sacred aurora
#

welp

earnest phoenix
#

help

                let user = message.guild.members.get(message.content.split(' ')[1]) || message.mentions.members.first();
                                                 ^

TypeError: message.guild.members.get is not a function
barren brook
#

did u define members if u need to?

earnest phoenix
#

wha_

#

?

sacred aurora
#

djs ver 12 right

#

@barren brook whats the error??

barren brook
#

@sacred aurora You fixed the error but now it wont send.

sacred aurora
#

check the line

#

hmmmmm

#

is there an error in the console

barren brook
#

Nope

#

Not even when you try the command

sacred aurora
#

its not being called then

#

bruh

barren brook
#

How do I fix it?

earnest phoenix
sacred aurora
#

members

#
let user = message.guild.members.cache.get(message.content.split(' ')[1]) || message.mentions.members.first();
opal plank
sacred aurora
opal plank
#

actually, nvm

young flame
#

it should be

cinder patio
#

It's message.guild.members

#

oh someone already amswered it

young flame
#

message.guild.memebers.cache.get

opal plank
#

splitting and getting [1] out of it might be bad too

#

idk what your first argument is

young flame
#

if your getting it by id

opal plank
#

but you better check if it has more than 1

#

specially cuz arrays starts at 0

#

not 1

young flame
#

message.guild.memebers.cache.get[1] or something

#

like get it by args

cinder patio
young flame
#

like if its warn

earnest phoenix
#

You should have a variable that holds the arguments instead of repeatedly splitting it

young flame
#

warn reason then mention

opal plank
opal plank
#

i modify message object itself before sending it out, so that doesnt happen

cinder patio
#

This guy definitely needs a command handler

opal plank
#

100%

lament rock
#

efficient memory management was never a strong point of novice JS devs

opal plank
earnest phoenix
#
client.on("message", message => {
        if (!prefixes[message.guild.id])
                prefixes[message.guild.id] = {
                        prefix: process.env.PREFIX
                };
        var prefix = prefixes[message.guild.id].prefix;
        if (message.content.startsWith(prefix + "warn")) {
                if (!message.channel.guild)
                        return message.channel
                                .send("THIS COMMAND IS ONLY FOR SERVERS")
                                .then(m => m.delete(7000));
                if (!message.member.hasPermission("MANAGE_MESSAGES"))
                        return message.channel.send("sorry but u dont have ``MANAGE_MESSAGES`` prems");
                let user = message.guild.members.cache.get(message.content.split(' ')[1]) || message.mentions.members.first();
                let warn = new Discord.MessageEmbed()
                        .setFooter(`WARNED By ${message.author.tag}`, `${message.author.avatarURL}`)
                        .setAuthor('Warn', 'https://cdn3.iconfinder.com/data/icons/musthave/256/Delete.png')
                        .setThumbnail(user.avatarURL)
                        .setDescription(` reason :  **${args.join("  ")}**`)
                        .setColor(RANDOM);
                user.sendEmbed(warn);
                message.delete();
                message.channel.send("**Done **")
        }
});
fs.writeFile("./prefixes.json", JSON.stringify(prefixes), err => {
        if (err) console.error(err);
});
//server
#

this is code

sacred aurora
#

copy paste?

opal plank
#

well, as you can see from the error, args is not defined

#

you didnt define it

earnest phoenix
sacred aurora
#

define the args first

#

hmm

earnest phoenix
#

Using JSON as database

cinder patio
#

Do you have a message listener for every command?

earnest phoenix
#

🗿

opal plank
sacred aurora
#

bruh

earnest phoenix
#

Wtf

#

Bro please consider making a command handler

opal plank
#

if you follow the guide you'll have a good 7/10 bot by the end of it

#

currently i'd rate it a good 1/10

earnest phoenix
#

They don't even check what the command is on the event listener so all commands will be executed at once

#

-1/10

#

Wait nvm they do, PepegaBlind

opal plank
# earnest phoenix <:okeh:585884138314137600>

trying to give you a personal evaluation so you have a rough idea of how bad things are as is, and im being honest. You only realise how bad it is once someone experience rates it. My old code is garbage, but i only learned its garbage after i learned more about js

#

you might not care about my opinion either, which is fine, the code will work but its horribly optimized

earnest phoenix
#

Imagine if JS wasn't as friendly as it already is, most of them would just stop programming them until learning how it all works KEKW

pure lion
#

if js was replaced with rust cold turkey the world would be a better place KEKW

earnest phoenix
#

And don't use JSON as a database

#

JSONs are prone to corruption

earnest phoenix
#

Lol

cinder patio
#

It's prone to corruption

opal plank
# earnest phoenix So what ur tip for my

First and most important:
use a command handler https://discordjs.guide/command-handling/
second, stop using vars, they are really annoying to work with since they get hoisted internally. TLDR, dont use vars, EVER. You likely wont have a proper use case for it.
lower your complexity, stop using that many if's, merge them to check what you need before running it.
stop using embed builder, they are horrible, start sending an object direct to the channel.send() method directly instead.
properly check your content before sending it, you dont check if message.content after being split has more than 1 argument.
wrap your user.sendEmebed() under a try catch, you wont always be able to message a user if they have dms disabled
stop using a json database, that is prone to corruption

All that in 20 lines of code, thats why i meant its a 1/10 right now, and thats only on the message event

earnest phoenix
#

@opal plank btw this guy loves nsfw

opal plank
#

who?

earnest phoenix
#

The guy who u just pinged

opal plank
earnest phoenix
#

No, idea ima head out

opal plank
#

no problemo

main oak
#

Could someone help me? I'm new to discord bot development and im having trouble finding out how to find a certain role in a server to ping it. Ex: I want my bot to find the role mine craft and ping that role. (I code in JS)

opal plank
#

filter guild roles and then send it in the channel you want

opal plank
#

speaking of rating, @cinder patio do you mind peering a lib and tell me things you think might be worth adding/improving?

cinder patio
#

(Find is probably the right function for this but ye)

cinder patio
#

Yeah sure! Just gimme a minute to get on my pc

opal plank
#

alrighty

honest perch
#

is it possible to output node canvas as an svg?

opal plank
cinder patio
#

I'm here

opal plank
#

aight, heres a couple points i already know are bad and already being worked on:
refactoring, most methods can be simply refarctored as they are too similar:
wrong usage of class functions, they are inside the constructor

the majority of what im looking for in feedback goes with the logic and optimization

earnest phoenix
opal plank
umbral zealot
opal plank
#

they didnt even add a client.login evie lmao

earnest phoenix
#

its there

opal plank
#

not where you sent it

earnest phoenix
#

i didnt share

#

beco ztoken

umbral zealot
#

That's what I figured

#

So, what happens when you run it?

earnest phoenix
#

it remains offlkine

#

offline

umbral zealot
#

Specifically, exactly, precisely, what happens when you type node index.js or whatever, in your command prompt?

#

not what happens on discord. What happens in the command prompt

opal plank
#

wait what

earnest phoenix
#

no response

opal plank
#

multiple client message events

earnest phoenix
#

in terminal

opal plank
#

what the heck

#

dude

earnest phoenix
#

oh

#

my god

#

yes

opal plank
#

you're nesting events what the heck

misty sigil
#

ew

#

ewww

earnest phoenix
#

sed

#

moment

#

What the fuck is that formatting

umbral zealot
#

I mean I also just get a syntax error from that code overall so... I Dunno

misty sigil
#

it looks like well

#

someone HAS COPY PASTED

opal plank
silent cloud
#

not erwin yooo

misty sigil
silent cloud
#

maybe you can help me

opal plank
umbral zealot
#

I would have formatted it had it not had a syntax error

opal plank
#

it was just missing 2} and 1 )'s

young flame
umbral zealot
#

Ah yes indeed now I see it clearly

earnest phoenix
#

ok now works

silent cloud
earnest phoenix
#

thenx

silent cloud
umbral zealot
#

clearly ban command was copy/pasted randomly in there

opal plank
silent cloud
#

bruh

earnest phoenix
opal plank
opal plank
#

ctually

opal plank
#

yeah, install it

earnest phoenix
#

i am making a vid

#

thats why

umbral zealot
#

so you copy/pasted from a vid

opal plank
#

a video for what?

umbral zealot
#

ok

earnest phoenix
#

aa impact yt channel

#

tutorials

#

burh

umbral zealot
#

You think "I copied from a vid" is different than "I copied from github"? lol.

opal plank
#

you're making a tutorial on how to do a discord bot when you dont know how to make a discord bot?

earnest phoenix
#

ik

#

trying .js

#

now

opal plank
#

shouldnt you learn js before making a tutorial on it?

umbral zealot
#

Ok well here's a hint: copy/pasting shit from the internet doesn't work well in JS any better than it worked in python

earnest phoenix
#

yes

cinder patio
opal plank
#

i already started that a while back on the refactor

#

here

#

actually

#

there

#

not sure if thats what you meant with the caching logic though

cinder patio
#

yea not exactly

opal plank
#

that answers the first half you said about abstracting all methods, but im not sure what you meant regarding the cache

#

this is as much abstraction as i could do with the methods without majorly updating it

cinder patio
#
class Characters extends Map {
  client: ...
  constructor(client: ...) {
     super();
     this.client = client;
}

   //.. all methods that deal with characters are here.
}

That's how I would do it

opal plank
#

whats the advantages of doing that?

cinder patio
#

it's cleaner

opal plank
#

i dont understand why you extending map to each cache

earnest phoenix
#

sed

#

momenta

opal plank
#

hmmm i kinda see what you mean, but wouldnt that create unecessary references for the cache?

#

that'd be setting client on everything

earnest phoenix
#

whats disadvantage of command handler?

cinder patio
opal plank
#

hmmm i see what you mean

#

wouldnt that make the code unecessary longer though?

earnest phoenix
#

yes

opal plank
#

currently all cache is being intiated with new Map(); if i go your route that'd mean for each double methods(getCharacter, getCharacters for example) would need to be extended with that

cinder patio
#

yeah but I don't think that's a problem, it makes it look cleaner and easier to understand

earnest phoenix
#

difficult to manage

#

in a single file

quiet coral
#

how can i create a bot webhook?

opal plank
#

did you find more stuff other than that?

quiet coral
#

like?

opal plank
#

that would mainly fall under readability, im more concerned about performance rn

earnest phoenix
opal plank
#

since i'll be doing a whole refactoring, that'll fall under when i do thgat

earnest phoenix
#

i removed unnessary on messages

#

client.on mssg

cinder patio
earnest phoenix
#

then why is it offline?

opal plank
#

theres only 2 character methods

earnest phoenix
#

it is offline since 3 days

opal plank
#

character and characterS

earnest phoenix
#

since when i hosted it

opal plank
#

CharacterProfile is a different one

#

Region is another

barren brook
#
    at Client.<anonymous> (C:\Users\YouTu\go\src\hello-world\hello-world\index.js:18:12)
    at Client.emit (events.js:315:20)
    at MessageCreateAction.handle (C:\Users\YouTu\go\src\hello-world\hello-world\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
    at Object.module.exports [as MESSAGE_CREATE] (C:\Users\YouTu\go\src\hello-world\hello-world\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
    at WebSocketManager.handlePacket (C:\Users\YouTu\go\src\hello-world\hello-world\node_modules\discord.js\src\client\websocket\WebSocketManager.js:384:31)
    at WebSocketShard.onPacket (C:\Users\YouTu\go\src\hello-world\hello-world\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)
    at WebSocketShard.onMessage (C:\Users\YouTu\go\src\hello-world\hello-world\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
    at WebSocket.onMessage (C:\Users\YouTu\go\src\hello-world\hello-world\node_modules\ws\lib\event-target.js:132:16)
    at WebSocket.emit (events.js:315:20)
    at Receiver.receiverOnMessage (C:\Users\YouTu\go\src\hello-world\hello-world\node_modules\ws\lib\websocket.js:825:20)```
Anyone?
opal plank
#

most of the methods are doubled, so theres a method for specific one , and for all of them, which is just the base + S on the end

#

when you mentiond Character i assume you want me to extend this one or completely make a new class?

#
class Characters extends Character extends Map {
super()
}```
cinder patio
#

wait I'm confused where's the code in the screenshot

sudden geyser
#

You reek of Java.

opal plank
#

dont look at the refactor, look at the main one i sent, its here

cinder patio
#

oh I'm looking at the refactor

opal plank
#

nono, the refactor is still working in progress

#

refactor will only change readability, nothing logic-wise

#

what im concerned about currently is logic

#

performance and logic

sudden geyser
#

Anyway do you really need to prepend every method with get

opal plank
#

yes, some future methods will have post

#

and it makes sense for methods to start with a verb

#

get

#

fetch

#

do

#

post

cinder patio
#
if (data.headers['x-ratelimit-remaining'] !== undefined)
          this._quota = data.headers['x-ratelimit-remaining'];
        if (data.headers['x-ratelimit-limit'] !== undefined)
          this._quotaMax = data.headers['x-ratelimit-limit'];
        if (data.headers['x-ratelimit-reset'] !== undefined)
          this._reset = data.headers['x-ratelimit-reset'];

you should probably put this in a function if you haven't in the refactor, it's in 14 different places in your code

opal plank
#

i did

#

its in refacto as setHeaders

honest perch
opal plank
honest perch
#

they are all for html canvas

opal plank
#

which works almost the same as canvas for js

#

canvas.js is mimic'ing html canvas

cinder patio
#

Othar than the stuff I already mentioned, everything looks fine. I would store all the settings in an interface rather than in the main class itself, other than that everything looks fine

#

but that's not a big deal and just a personal preference ^

opal plank
#

Thank you a lot for the feedback, i'll put a bunch of what you said into the refactor as soon as its finished

#

this project might turn into a big one so im concerned about stability and performance

ornate otter
#
Warning: got packets out of order. Expected 5 but received 1
Warning: got packets out of order. Expected 5 but received 1
Warning: got packets out of order. Expected 5 but received 1
Warning: got packets out of order. Expected 5 but received 1
Warning: got packets out of order. Expected 5 but received 1
Warning: got packets out of order. Expected 5 but received 1
Warning: got packets out of order. Expected 5 but received 1
Warning: got packets out of order. Expected 5 but received 1
Warning: got packets out of order. Expected 5 but received 1```
#

send hulp

opal plank
cinder patio
#

np! You should definitely refactor it, but if it gets big then people are gonna start contributing to it and making the code better

#

you just have to make it readable!

opal plank
#

i assume it'll grow a bit too much, rn theres nobody advertising it, but its the only API usable for genshin

#

every other NPM package that claims to be an API or genshin package is just straight up bullshit with a json db

earnest phoenix
#

sed

opal plank
#

look at my competitors
json db https://github.com/xhayper/genshin-impact-wrapper#readme
json db https://www.npmjs.com/package/genshin-impact-api
json db https://github.com/HerixOfficial/genshin-impact/tree/master/src/info

EY an actual API https://www.npmjs.com/package/@teyvatdev/node-sdk

This is an actual API wrapper, unlike most npm packages that stores json databases containing character data, this fetches and caches it locally from the API real time, so if the values change, you would normally require the author of the package to manually update their database, which forces users to need to update their package. This leads to apps needed to be shutdown for upgrades and updates. Unlike those, we fetch this data dynamically and check periodically for changes in the API itself, so the only updates you'll need to do on this package are major API changes, not related to the data, which is handled internally.
there isnt a SINGLE api on npm other than mine```

Its so polluted with modules that claim to be API's that i had to put this on my front end
earnest phoenix
#

genshin impact?

#

i heard it

#

somewhere

cinder patio
#

Yeah using an api is definitely better than packaging up a json file with all the characters in it lmao

opal plank
earnest phoenix
#

k

opal plank
#

i dont see why you need to await for this rather than keep it in memory or just straight up sync read, but oh well

#

that just comes to show how bad they are, and they are call themselves API's

cinder patio
#

here have a star, even though I've never played the game and will probably never use it

opal plank
#

❤️

#

hayper probably gonna be sad when they wake up

cinder patio
#

why lol

opal plank
pale vessel
#

LOL hayper's

opal plank
#

they were trying to flex on their new update on the server

pale vessel
#

Have you seen marvin's api?

opal plank
#

before realising both the owner of the API and me who's the owner of the SDK were in the server

opal plank
pale vessel
#

You should

#

It looks cool and well maintained

young flame
#

lmfao flaze

#

bot startup so fast it took -1ms

opal plank
#

theres only 1 other api competing with yoroshi's

#

with with genshin api, which is not even 10% done

pale vessel
opal plank
#

yoroshi was the main dev of that project flaz

pale vessel
#

Ah

opal plank
#

the whole project crumbled, and yoroshi alone alreayd made all this

honest perch
pale vessel
#

Grr nobody told me that

#

But yeah that API is nice

opal plank
#

that API is done by 5 devs, yoroshi ALONE made more than those 5 people combined in 1 and a half weeks

pale vessel
#

YOOO

opal plank
pale vessel
#

It uses GraphQL

opal plank
#

yeah

pale vessel
#

That's fucking pog

opal plank
#

shameless plug btw

#

if you want to use it with ts/js

cinder patio
#

now code review me

earnest phoenix
#

O

opal plank
earnest phoenix
opal plank
#

i'll check it in a bit, i gotta go to the market grab food for today

honest perch
#

cool finding, node canvas supports svg out of the box

young flame
#

@lament rock oi

#

u awake

lament rock
earnest phoenix
young flame
#

o

earnest phoenix
#

Pokecord bot

opal plank
honest perch
opal plank
#

this chat for development

earnest phoenix
opal plank
honest perch
#

then just ```js
res.type('text/html');
res.send(canvas.toBuffer());

young flame
#

o i didnt know that

#

welp

honest perch
lament rock
#

Did you need something

cinder patio
young flame
#

i was gonna recode canva-conductor anyways

opal plank
#

i'll take a look at it shortly, let me get to the market rq

earnest phoenix
opal plank
#

@slender thistle

young flame
#

courage the cowardly bot

young flame
cinder patio
young flame
#

and the github for the sorcecode is private

gilded olive
#

pokecord shut down a long time ago

lament rock
earnest phoenix
#

I know

young flame
#

gimmie a sec

gilded olive
#

there is poketwo

honest perch
#

@cinder patio looks great, well done

earnest phoenix
#

Yea

young flame
#

o

slender thistle
earnest phoenix
#

ohk

young flame
slender thistle
#

And there are very low chances you will find any code that does what Pokecord used to.

young flame
#

idk if negative 1 is good or bad

earnest phoenix
young flame
#

KEK nt sure if its a valid number to

earnest phoenix
#

1 guy is a pokemon bot maker

young flame
#

mmm

#

no not really

#

since he had a team to help manage it

#

speaking or help manage it i should see how miles is doing brb

earnest phoenix
#

@crude ember this

lament rock
#

Or logic to determine latency is flawed

young flame
#

kk

#

i thought it went godspeed

lament rock
#

negative latency doesn't actually exist

#

it's just flawed logic

#

Everything will always take positive time

#

even the fastest operations

crude ember
young flame
#

welp

#

time to update npm

buoyant aspen
#

Are DMs sent to users or members?

lament rock
#

Users. If you're using Discord.js, GuildMember does implement PartialTextbasedChannel, so you could do GuildMember.send

young flame
#

^^^

#

or member send

#

depending on the identifier

buoyant aspen
#

can I do something like client.users.fetch(id).send()?

young flame
#

memeber.send*

#

member*

lament rock
#

fetch returns a Promise. You will need to resolve the Promise<User> with await or a .then

young flame
#

it will be a fn.bind() error

#

just use cache,get

buoyant aspen
#

ah alr

#

good point

lament rock
#

fetch defaults to resolving with a Promise from cache if it's in cache

earnest phoenix
young flame
#

client.users.cache.get(id).send(msg)

buoyant aspen
#

does client.users.fetch() just get the /user/:id endpoint?

lament rock
#

if the user is not in the UserManager.cache Collection, then yes

buoyant aspen
#

interesting

#

thanks

young flame
#

wait

restive furnace
#

client.api.users.get("id") what it basically is

young flame
#

you can download discord.js docs

#

wut

restive furnace
#

to previous discussion

#

not ur qu

young flame
mellow kelp
#

yea

#

PWAs are very pog

opal plank
#

@cinder patio apart from some inferred types that dont perticularly need to be there, everything looks good

#

stuff like this, when you return its inferred type, no need for explicitly typing it

#

its same redundancy as ```ts

let aNumber:number = 1

cinder patio
#

it's an eslint setting

opal plank
#

logic wise i didnt catch anything, only stuff like that

#

oh, then its fine

cinder patio
#

makes return types required

opal plank
#

then its 100% fine

#

4 stars now

cinder patio
#

nicee ❤️ thanks

opal plank
limber flume
#

pog

opal plank
limber flume
#

@opal plank Thanks! 🙂

honest perch
#

how do i make a circle in node canvas and fill it with an image?

mellow kelp
#

you can arc a circle and crop the context