#development

1 messages · Page 2021 of 1

stiff lynx
#
async function cercaCanale(client, id) {
    const canale = await client.channels.fetch(id)
    return canale
}
wheat mesa
#

Yes

stiff lynx
#

ty

restive barn
#
const db = require('quick.db');

module.exports = {
  name: "warn",
  description: "Use this to warn an user",
  usage: ">warn <Mention User> <Reason>",
  run: async (client, message, args) => {
   
    if (!message.member.hasPermission("MANAGE_MESSAGES")) {
      return message.channel.send("You don't have permission to use this command")
.setTitle("Only Moderator+ Commands")
     
message.channel.send(embed);
return;
   }
 
let Member = message.mentions.members.first() || message.guild.members.cache.get(``)
let member = message.mentions.users.first()

if(!member) {
  message.channel.send("Please mention a user with reason")
  return;
}

if(member.id === message.author.id) {
  message.channel.send("You cannot warn yourself.")
  return;
}

  if(member.id == client.user.id) {
  message.channel.send("You cannot warn me")
  return;
}
 
if(message.member.roles.highest.position < Member.roles.highest.peermission) {
  message.channel.send("This user is above you, so you cannot warn them noob.")
}
   
    let Reason = args.slice(1).join(" ");
 
client.db.add(`Warnings_${message.guild.id}_${member.id}`, 1)
 
let Warnings = client.db.get(`Warnings_${message.guild.id}_${member.id}`)

const embed = new Discord.MessageEmbed()
.setColor(`#FF0000`)
.setTitle(`${member.username} has been warned!`)
.setDescription(`**Reason:**
> ${Reason || "No Reason provided"}`)
.setFooter(`They now have ${Warnings} warnings`)
 
message.channel.send(embed)
member.send(`You have been warned in ${message.guild.name}. Reason: ${Reason}`)

member.send(embed)
//DM's the user that they have been warned
   
  }
}
lyric mountain
restive barn
#

Trying to ask a dev that use v12

carmine magnet
#

Don't use v12

earnest phoenix
#

Why are you still using v12?

restive barn
#

I use discord.js v12 as u can see but I try adding

message.guild.member.id but when I do I can't warn with id and I'm having trouble

restive barn
#

For me

lyric mountain
#

nope, it isn't

restive barn
#

Personally

lyric mountain
#

it's outdated, and will shoot you in the back

earnest phoenix
#

Even if it's better for you personally, doesn't really make it better in reality, v12 will stop working soon entirely

restive barn
#

I mean my bot still working and run like a champ with v13

#

V13*

#

V12*

#

But if I'm force to move v13 I will

#

But this free website that let me code and much easier support v12

lyric mountain
#

it's better to migrate slowly while you can than wait for it to force u to change

restive barn
#

I'm still new to coding

#

Still

lyric mountain
#

it's a matter of spending 1 hour over 10 days or spend 10 hours over 1 day

restive barn
#

I mean I am learning from @fringe jewel and she use v12

earnest phoenix
#

also you might also switch to another discord bot lib

lyric mountain
#

...you're missing the point entirely

restive barn
#

Okay yeah I get it

earnest phoenix
#

because well the d.js v14 changes are just ridicilous

lyric mountain
#

looking at d.js I'm happy JDA isn't as volatile as it

carmine magnet
restive barn
#

But if I use v13 I will have to change everything in the coding and it gonna be fucking hard since I'm a beginner at coding bots

lyric mountain
#

not to say all the QoL stuff they remove just because people were misusing it

earnest phoenix
#

i forgor the link

#

let me find it

carmine magnet
#

Thank you!

lyric mountain
carmine magnet
#

Throwing snowballs during summer

lyric mountain
#

you go, and go, and go.

when u note you have 1m lines to change because you left it for later

#

if you're a beginner perfect! you'll have less trouble migrating to new version

solemn latch
#

If you are just learning you kind of have an advantage learning the newer version anyway.

restive barn
#

But there is better tutorial on v13 then v12 right? I heard v12 never really had tutorial

lyric mountain
#

"tutorial" is subjective

#

if you mean videos depends, it's a real bad source of tutorials

#

the library documentation is there tho, as well as google

#

there's no better tutorial than documentation + google

earnest phoenix
#

Just look at the guide, it should tell you how to migrate from v12 to v13

restive barn
#

Not tutorial my bad, for example I said I need help figuring out the code so that people can use id to warn members

earnest phoenix
lyric mountain
#

well, that's up to you to write

#

you're not supposed to grab pre-made code around the net

restive barn
lyric mountain
#

by thinking

#

documentation will tell you what tools you have

#

you'll be the one baking the cake

restive barn
#

Oh okay

#

Well I gotta go and thank you once again @lyric mountain

lyric mountain
#

if you want I can give you some courses and guide links on JS

restive barn
#

If you can that would be great

restive barn
#

Ty

lyric mountain
#

those are the ones I know are good

restive barn
#

Tysm

lyric mountain
#

do note, none of those are about making bots, but about learning node.js

#

which is what you'll be using for bots

#

once you have the base, anything else is pretty easy to get the hang of

restive barn
#

Mhm

#

Okay!

#

Thank you so much

lyric mountain
#

yw

earnest phoenix
#

discord.js moment

lyric mountain
#

they named a class in full caps?

carmine magnet
#

RichEmbed > EmbedBuilder

pale vessel
#

isn't it just called Embed now

lyric mountain
#

Embed would be the resulting object no?

carmine magnet
#

It's EmbedBuilder now

earnest phoenix
carmine magnet
#

Djs bad now

pale vessel
#

huh, weird

#

thought they moved to builders package for embed builder

earnest phoenix
#

discord.js has always been like this, with every new update you have to rewrite your bot

pale vessel
#

that's why i use tiny-discord!!

#

don't even need to maintain my bot

earnest phoenix
#

v11 to v12 to v13 to v14 lmao

boreal iron
solemn latch
#

^
Most of the changes are the builders, which you really don't need

carmine magnet
#

v11 was a really good version
v12 was annoying with these cache everywhere
v13 is ok, no real breaking change
v14 is bad

solemn latch
#

V12 was an easy update though

sudden geyser
#

All the updates are pretty simple to upgrade from

carmine magnet
#

But annoying

boreal iron
#

That’s why god made search and replace all

solemn latch
#

Yeah

sudden geyser
#

Is annoying really a good answer to breaking change

carmine magnet
#

Best vscode feature

sudden geyser
#

If an update is annoying but provides you with much more functionality, is it really fair to dismiss it as "annoying"?

lament rock
#

v11 best. I still use v11 in production 💪

sudden geyser
#

Raw api moment

earnest phoenix
earnest phoenix
#

discord.js v11 lmao

pale vessel
solemn latch
#

I'm surprised v11 works still

carmine magnet
#

I agree that these changes provide some good functionality but is modifying everything a good solution?

earnest phoenix
sick agate
lyric mountain
#

but only remove 2 or 3 versions later

sick agate
#

discord.js team loves changing things for no reason and without warnings

lament rock
#

The only reason it works as well as I have it is I've updated some abstractions and gutted the back end gateway and rest internally and switched to cloudstorm and snowtransfer

sick agate
#

nice

solemn latch
lament rock
sudden geyser
#

No, I think breaking changes should be discouraged. But I also think people complain about the less impactful ways discord causes breaking changes

pale vessel
#

don't bother

lament rock
#

managed libs 🤮

sick agate
lyric mountain
carmine magnet
#

Yeah Discord with their intents

lyric mountain
#

but it gets like minimal life support

carmine magnet
#

Interactions are a great feature but the message intent isn't necessary

sick agate
#

^^

solemn latch
#

Message intent is great imo

sick agate
#

nah

carmine magnet
#

No

sick agate
#

they never inspect shit before does it really need it or actively inspect

lyric mountain
#

the reason for it to exist is to protect user privacy

#

but they don't enforce it below 100 servers

#

so it's useless

#

spam/scam bots are always short-lived bots

solemn latch
#

Most bot invites are above 100 servers anyway

pale vessel
#

there's a reason why they pushed back the deadline to October (was it October or September, idr)

#

they're trying to make users switch, while polishing the interactions system

#

clearly end of April isn't enough

solemn latch
#

I'm still happy with the idea of it.
In the future I probably won't invite any bots that have the intent.

boreal iron
#

I doubt the next deadline will be enough, too

lyric mountain
#

regarding what I mentioned earlier

solemn latch
#

Hopefully they make that visible to users

lyric mountain
#

the crossed method is marked as obsolete, they don't just remove it from night to day

earnest phoenix
#

In other words, deprecated

carmine magnet
lyric mountain
#

ye

carmine magnet
#

Or they can add a new scope like "receive messages" that you can disable if you want

earnest phoenix
#

Discord plans and plans and plans, never works out well, plan on making slash-commands and interactions from the very start of Discord, implement it 6 years later, delay important features and mark a deadline earlier than you can ever implement and stabilize your APIs and features, mark a date to decommission older API versions and keep post-poning them and all that crazy stuff

#

Classic Discord™️, and then there's the discord.js™️, trying to be as "consistent" as possible troll

carmine magnet
fringe jewel
#

I was pinged here?

#

What going on?

carmine magnet
#

We should make our own library, made by top.gg's community

vivid fulcrum
#

that's like asking hellen keller to write a book

carmine magnet
#

I don't know who hellen keller is

lament rock
earnest phoenix
lyric mountain
fringe jewel
#

I didn't make a tutorial..

#

I'm just teaching him how to use discord.js v12...

#

And when I finally get used to v13 I'll teach em that.

#

but kk

hidden gorge
#
const { Client, Message } = require("discord.js")

module.exports.config = {
    name: "clean",
    group: 'fun',
    description: 'Clean recent bot messages',
    permissions: ['MANAGE_MESSAGES'],
    botperms: ['MANAGE_MESSAGES'],
    usage: '.clean [amount]',
    example: '.clean 5'
}

/**
 * 
 * @param {Client} client 
 * @param {Message} message 
 * @param {*} args 
 */

module.exports.run = async(client, message, args) => {
    let amount = args[0];
    if (!amount) return message.channel.send({ embeds: [ client.main ] });
    if (isNaN(amount)) return message.channel.send({ embeds: [ client.amountNum ] });

    if (amount > 100) amount = 99

    let collection = await message.channel.messages.fetch({
        limit: amount
    })

    const filter = collection.filter(m => m.author.id === client.user.id);

    message.channel.bulkDelete({ embeds: [ filter ] });
}```
#

What's the issue?

carmine magnet
#

What does the { embeds: [ filter ] } means?

earnest phoenix
#

The bulkDelete() method doesn't take an object with the embeds property

lament rock
#

You filter by messages in the channel and then pass IDs to bulkDelete that match a predicate

lyric mountain
#

VIP vc regions?

lament rock
#

VIP regions were deprecated. They're now just 320kbps

carmine magnet
#

I saw that they have been removed from new versions of the Discord api

lament rock
#

they used to belong to guilds with the PARTNERED feature

lyric mountain
#

ic, just now I noticed those enums exist (or used to)

lament rock
carmine magnet
#

Got removed in djs 14

sudden geyser
#

plus alternatives exist

split hazel
simple stump
#

How can I remove unnecessary dots in a string? Ex.

h.e.l.lo

The tricky thing is that if this is in a huge block of text like this:

h.e.l.lo! I do stuff. Sometimes. Not really...

I can't just replace . since that would become:

hello! I do stuff Sometimes Not really

I tried this:

for (let i = 0; i < text.split(" ").length; i++) {
  if (text.split(" ")[i].includes(".") && !text.split(" ")[i].endsWith(".")) {
    text.split(" ")[i] = text.split(" ")[i].replace(".", "");
  }
}

But that didn't seem to work for some reason. text is the string provided.

lyric mountain
#

you can't really, not without sacrificing the ... case

quartz kindle
#

separate by spaces to get words, count numer of dots in word and number of sequential dots in word, replace if more that 1 dot in word that is not sequential

earnest phoenix
#

You could use regex, but that wouldn't really be accurate either, such as

text.replace(/(\w)\.(\w)/g, '$1$2');
quartz kindle
#

or if dot is surrounded by non dot and non space

simple stump
lyric mountain
#

text.replace(/[^ .]?\.[^ .]?/g, "$1$2");

simple stump
lyric mountain
#

actually, mine wont work

#

it'll replace any dot

#

[^\s.]\.[^\s.]

simple stump
simple stump
lyric mountain
simple stump
earnest phoenix
simple stump
simple stump
lyric mountain
earnest phoenix
#

It doesn't for me

lyric mountain
#

type a text and input \w as regex

#

it'll stutter a bit

lament rock
#

A regex I made is this (\w)\.(?! |\.+$)

It matches if there is a character and then a . and there is not a space after it or if it doesn't have multiple .'s and is at the end of the string

#

the capture group is the character, so you can replace with $1

lyric mountain
lament rock
#

Negative lookahead is more appropriate for this situation and more accurate

simple stump
lyric mountain
#

\.[^\s.] ignores if a dot is followed by a space-like char or a dot

lament rock
#

you should be checking if its at the end of the string though

lyric mountain
#

for example in there was a pig... and it fleed

#

that's an intentional ...

lament rock
#

Then the +$ can be replaced with {2,3}

lyric mountain
#

will still replace

lament rock
#

Yours didn't match that last .

lyric mountain
#

because it shows only 1 match

lament rock
#

not the case

#

the g flag always makes it match many

earnest phoenix
lyric mountain
lament rock
#

Yes. I understand if the ... isn't at the end of the string, it will get replaced

#

currently trying to figure out a solution

lyric mountain
#

as I understand, regex doesn't overlap capture groups

#

that's why it didn't capture before

earnest phoenix
lament rock
#

their example showed it at the end

lyric mountain
#

ye, this one works fine

lament rock
#

people can throw in 3 .'s in between 2 chars and it breaks

lyric mountain
#

well, the rule states multiple .'s should be ignored

earnest phoenix
lyric mountain
#

ye, both suffer from that

earnest phoenix
#

It doesn't, it works the exact way they wanted it to

lament rock
#

I still think my version is the most logically correct

lyric mountain
earnest phoenix
#

I think it's better for it to just ignore the amount of dots in-between, it it can also just replace them if wanted

#

Instead of \., it can just be \.+

lyric mountain
lament rock
#

I'm working on it

earnest phoenix
lament rock
#

You also missed the $ in the regex

lyric mountain
earnest phoenix
lament rock
#

true™️

lyric mountain
#

this one also doesn't remove triple dots at the end

lament rock
#

Does it allow 3 dots in the string at the end of a word

quartz kindle
#

who the fuck types like that anyway wtf

earnest phoenix
lament rock
#

do share

lyric mountain
lament rock
#

oh I see

#

my brain glossed over that

lyric mountain
#

kekw

#

here ([^\s.])\.+((?![\s.]*(?:$|\s))) if u wanna break-test it

lament rock
#

I love how impossible to read regexes are, but they just work

lyric mountain
#

kekw

earnest phoenix
lyric mountain
#

having a highlighting does help

lament rock
#

@simple stump

#

either Kuu's or Voltrex's

lyric mountain
#

ah yes, forgot about the client

earnest phoenix
#

Now guess what time it is, regex speedtest time

lyric mountain
#

how?

lament rock
#

oh no

#

loops and ms spent

lyric mountain
#

send ur regex here volt

#

@earnest phoenix

earnest phoenix
#

I'm already testing them no need

lyric mountain
#

voooolt

earnest phoenix
#

KuuHaKu's regex: 9.243ms
My regex: 8.461ms

lyric mountain
#

source: trust me

earnest phoenix
#

In 99,999 iterations

lament rock
#

my source is I made it the fuck up

earnest phoenix
#

This is how I tested them

const text = 'H.e.l.l.o! I do stuff. Not really... wtf...t...f h...m...';

const regex = /* your regex */;

console.time();

for (let i = 0; i < 99_999; i++) regex.test(text);

console.timeEnd();
lyric mountain
#

welp, indeed

earnest phoenix
stiff lynx
#

new v of discord.js is already out?

earnest phoenix
#

Nope

stiff lynx
#

I was scaried about some messages that I've seen in this chat

lyric mountain
#

should be

stiff lynx
carmine magnet
#

Haha, it's because the v14 is available as a "dev" version

neat ingot
#

when is v14 expected to be properly released?

earnest phoenix
#

why is it saying "top.gg token missing"?

#

well ik why but I did put the token correctly

dry imp
#

if you put it correctly there should not be an error mmLol

sharp saddle
#
earnest phoenix
#
/workspace/node_modules/discord.js/src/client/Client.js:548
throw new TypeError('CLIENT_MISSING_INTENTS');
^
TypeError [CLIENT_MISSING_INTENTS]: Valid intents must be provided for the Client.
at Client._validateOptions (/workspace/node_modules/discord.js/src/client/Client.js:548:13)
at new Client (/workspace/node_modules/discord.js/src/client/Client.js:76:10)
at Object.<anonymous> (/workspace/trophylets.js:3:16)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/workspace/prefix_commands/useful/leaderboard.js:4:33) {
[Symbol(code)]: 'CLIENT_MISSING_INTENTS'
}
boreal iron
#

Did you import intents from djs?

earnest phoenix
#

import?

thorny flume
#

I'm passing

const timeZone = result.language === 'pt-br' ? 'America/Sao_Paulo' : 'America/New_York'
    
const date = moment(dateRecive).tz(timeZone)

but if i pass a date, like my bot's uptime, it returns me a wrong date

boreal iron
earnest phoenix
#

oh

boreal iron
#

Yeah exactly

earnest phoenix
#

same error

earnest phoenix
thorny flume
boreal iron
#

Which are before the error and belong to it

earnest phoenix
earnest phoenix
thorny flume
thorny flume
boreal iron
earnest phoenix
# thorny flume same thing

Then either the timezone passed is invalid or it's correct but it seems incorrect, also I recommend using something else rather than https://npmjs.com/package/moment since it's discontinued and no longer maintained, the updates are mostly security patches

boreal iron
#

Doesn’t have the native date class some methods to adjust the time offset for another timezone in JS?

thorny flume
#

I will use the Data class itself

earnest phoenix
#

You can just do

const covertedTz = new Date(
  new Date(client.uptime)
    .toLocaleString('en-US', { timeZone: ... })
);
boreal iron
#

Use the constructor to create a date based of a timestamp or string, than convert it to your timezone

thorny flume
#

yes yes...

earnest phoenix
#

hei hei, have someone an bot suggestion for bot message auto delete?

#

ik Dyno have auto prune but we wanna an bot with auto delete function for bot messages/embeds, it can be an bot with premium option

sharp saddle
#

I just updated something in Schema (mongoose/mongodb), but it didn't change anything topggLikeThis

austere surge
#

nice

sharp saddle
#

on collections:

#

if any expert can help me 👩‍🔬

austere surge
#

you need to edit the saved data

sharp saddle
#

wait

#

wdym?

austere surge
sharp saddle
austere surge
#

mongodb doesnt change them automatically

sharp saddle
#

this is not the only one...

austere surge
#

ohno

austere surge
sharp saddle
#

I don't want to do it manually 💀

earnest phoenix
grim flame
#

How can i get the biography of an user ( djs )

grim flame
sharp saddle
#

not yet

earnest phoenix
earnest phoenix
#

They probably will be exposed later on but may not be

grim flame
#

Thanks

lament rock
#

Check back when they add pronouns to user profiles. They might start including that data into the User payload since having to fetch /users/{user.id}/profile for each new user in chat would be stupid (assuming they show pronouns in chat ui)

austere surge
#

what

pearl trail
lament rock
pearl trail
#

ah yes

rich iron
#

I'm trying to add images https://imgur.com/smP4VCE and https://imgur.com/FPhzNRm to my server's top.gg page long description, but I'm slightly unsure as to how exactly to do it since I think I'm inputing the format incorreclty as the images don't actually show up. I've never used html formatting so I'm kinda clueless in this field KE_bestie

lyric mountain
#

imgur image urls start with i.imgur

#

copy the image url, not the page url

sharp saddle
#

@lyric mountain are you sure?

#

both return the same thing

rich iron
lyric mountain
boreal iron
#

Those are the preview links

lyric mountain
#

if u GET the imgur url u get the page itself, while the i.imgur returns the image

#

it's a trick most sites use, because the end user doesn't really bother to get the direct url, so they can add trackers as much as they want

sharp saddle
#

a

boreal iron
#

Yeah imagine providing the direct image URL with just the ability to log the request source instead of the entire client

boreal iron
drowsy flume
#
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/aiohttp/web_protocol.py", line 314, in data_received
    messages, upgraded, tail = self._request_parser.feed_data(data)
  File "aiohttp/_http_parser.pyx", line 546, in aiohttp._http_parser.HttpParser.feed_data
aiohttp.http_exceptions.BadStatusLine: 400, message="Bad status line 'invalid HTTP method'"
Error handling request```
what is going on here and how do I fix it
boreal iron
#

Well you’re obviously using the wrong HTTP method

#

Figure out which one the endpoint expects then use it

#

(might be GET POST PATCH etc.)

drowsy flume
#

well

#

I am using

#
    client.topggpy = topgg.DBLClient(client, dbl_token)

    client.topgg_webhook = topgg.WebhookManager(client)
    client.topgg_webhook.webserver.router.add_post(path="/dbl", handler=bot_vote_handler)

    client.topgg_webhook.run(5000)```
#

is any of that wrong xd

boreal iron
#

You should provide details like that before the first one answers okeh

drowsy flume
#

that would have been smart wouldnt it

#

I also have the bot_vote_handler is that would help too

boreal iron
#

Does your error even come from that library?

drowsy flume
#

it literally just spams this in my logs

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/aiohttp/web_protocol.py", line 314, in data_received
    messages, upgraded, tail = self._request_parser.feed_data(data)
  File "aiohttp/_http_parser.pyx", line 546, in aiohttp._http_parser.HttpParser.feed_data
aiohttp.http_exceptions.BadHttpMessage: 400, message='invalid constant string'
Error handling request```
boreal iron
#

The webhook listener actually doesn’t do requests

drowsy flume
#

hmm

#

when I post the server count that would do it right

boreal iron
#

That sounds more like the source

#

You should begin to handle your promises

#

To properly catch errors and see where they come from

drowsy flume
#

well I have a on_command_error

#

but I guess it isnt good enough lol

#

I have found

#
@tasks.loop(minutes=30)
async def update_stats():
    conn = await client.pool.acquire()
    try:
        await client.topggpy.post_guild_count()
        print(f"Posted server count ({client.topggpy.guild_count})")
    except Exception as e:
        print(f"Failed to post server count\n{e.__class__.__name__}: {e}")
    await conn.close()```
#

this

#

thing

#

this is exactly what they say to put in the docs though

#

so I got no idea

boreal iron
#

That shouldn’t be the source as the exception would include the error message you can see

drowsy flume
#

hmmm

#

I dont think I post anything anywhere else

boreal iron
#

The error message has changed in your last quote

drowsy flume
#

oh shiiiiiit

#

it did

#

it posted that literally once

#

and the other 20 errors are the first one I sent

boreal iron
#

Hmm just comment the webhook listener out as well as the server count post

#

To make sure the errors aren’t coming from there

real rose
drowsy flume
#

the problem is that it happens randomly

real rose
drowsy flume
#

so it could take a day or a week to happen

sharp saddle
#

GO BACK TO YOUR HOUSE

real rose
#

I'm out for you bro 👀 Be nice

#

I'm always lurking

sharp saddle
real rose
boreal iron
#

You may have encountered that

drowsy flume
#

is there a way to make it not crash my whole bot if it happens lol

boreal iron
#

Yes

#

Handle your errors properly

drowsy flume
#

so just make a on_error instead of a on_command_error

boreal iron
#

Well I don’t speak py to help you with that

dry imp
#

on_error 💀

boreal iron
#

But defining a global exception handler shouldn’t be hard to do I guess

dry imp
#

i guess you could ignore it if it wasnt important troll

#

on_error seems fine ig

woeful pike
#

god phoenix has some of the best error screens I've ever seen

sudden geyser
#

what is pheonix (link pls)

woeful pike
#

it's dynamically typed you'll love it

rocky hearth
#

I want a regex that selects all symbols that are not underscore or alphanumeric

#

So I could replace them with a underscore.

#

FE, "algae.peach.%285" should be replaced with "algae_peach_285"

rustic nova
lament rock
#

Indeed it is!

pale vessel
rocky hearth
#

what's that, whitespace?

#

basically I want to convert the string, to be set as a unique username.
I want the username to follow the same convention as variables names in programming

pale vessel
rocky hearth
#

But can I do it so, it select all consecutive symbols, and replace with underscore

pale vessel
#

like \W+?

rocky hearth
#

incredible, regex is so powerfull

fickle arch
#

in term of database usage, how do I connect my bot with it if I'm using vps

stiff lynx
#

Pls help on this 😮‍💨

// function
async function cercaCanale(client, id) {
    const canale = await client.channels.fetch(id)
    return canale
}

//guildMemberAdd
const canale = await cercaCanale(client, cercaServer.channelID)
                if (canale == null) return
                await canale.send({
                    embeds: [embed],
                    files: [attachment],
                })

//error
TypeError: canale.send is not a function
at Client.<anonymous> (/root/novabotStable/events/guildMemberAdd.js:76:30)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
tall zenith
#

hey guys. can someone help me with writing TOS for my discord bot? it's necessary for verification

dry imp
#

bun already made that lemme see

lament rock
dry imp
#

surely people will read the whole tos Clueless

lament rock
#

you are legally allowed to put BS in there and it is other people's fault for not reading

dry imp
#

fr Aware

lament rock
#

Not like many people use what I make tho

#

would be surprised if someone tried to take me to court

tall zenith
earnest phoenix
pearl trail
#

before the console log i couldnt find the user, add console log error to see what error are you actually facing in

boreal iron
stiff lynx
#

Pls help on this 😮‍💨

// function
async function cercaCanale(client, id) {
    const canale = await client.channels.fetch(id)
    return canale
}

//guildMemberAdd
const canale = await cercaCanale(client, cercaServer.channelID)
                if (canale == null) return
                await canale.send({
                    embeds: [embed],
                    files: [attachment],
                })

//error
TypeError: canale.send is not a function
at Client.<anonymous> (/root/novabotStable/events/guildMemberAdd.js:76:30)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)```
cinder patio
#

console log canale

earnest phoenix
pearl trail
#

console log the error

earnest phoenix
#

ight 1 sec

earnest phoenix
#

the error code line

user.roles.add(role).catch(e => { console.log('Something went wrong, i cant add roles') })
boreal iron
#

You can’t assign roles to an user

#

But to guild members

#

I mean ask yourself where is that role going to be added?

earnest phoenix
#

lol

#

i forgot about it

#

thanks man

boreal iron
#

You got the role from your guild cache but didn’t assign it to the member in the guild but to a random discord user

#

Alright

earnest phoenix
#

i think this one will work

        let guildid= client.guilds.cache.get('928290243843604500')
        let role = guildid.roles.cache.get("942061236475002952")
        user.roles.add(role).catch(e => { console.log('Something went wrong, i cant add roles') })
#

right ?

boreal iron
#

If you wanna assign them to the user in your guild, make sure to check if the user is a member of the guild before

boreal iron
#

guild.members.fetch(user-ID)

#

If the user exists as guild member then fetch and assign the role

fickle arch
#

what site I could hire html programmer, fiverr is my last option for it.

vivid fulcrum
#

unprofessional? fiverr
professional? contact a company

fickle arch
#

like uh, freelancer

split hazel
#

so unprofessional

vivid fulcrum
#

you can also sniff around sites like mcmarket and ogusers

fickle arch
#

only need it for a single project.

split hazel
#

mc market is only for Minecraft bro

#

jk I know I've been there

fickle arch
#

guess gonna take a look at mcmarket first, thanks for the info.

split hazel
#

also does anyone know how to make unreal engine editor not run like shit

#

I get like 10fps on the preview

fickle arch
split hazel
#

though im not rendering anything special

#

very simple cubes on lowest presets

#

I swear you need a $3000 gaming rig to run this 💀

#

production builds run fine tho

#

worst case scenario I'll go back to unity

vivid fulcrum
#

that is indeed a worst case scenario 🥲

split hazel
#

I really don't like unity

#

just something about it

fickle arch
#

My PC crashed everytime I open Unity for some reason.

pulsar bone
#
if message.content.startswith('Get message'):
      print('\----------', end="\r")
      id = message.content.split(',')[1]
      print('\\---------', end="\r")
      g = await client.fetch_user(str(id))
      print('\\\--------', end="\r")
      async for message in g.history(limit=None):
        print('\\\\-------', end="\r")
        if message.attachments:
          print('\\\\\------', end="\r")
          user = await client.fetch_user("723927865544146954")
          print('\\\\\\-----', end="\r")
          attachments = message.attachments
          print('\\\\\\-----', end="\r")
          file = files = None
          print('\\\\\\-----', end="\r")
          if len(attachments) > 1:
            files = attachments
          else:
            file = attachments[0]
          print('\\\\\-----', end="\r")
          await channel.send(content=f'{message.content}', file=file, files=files)

whats wrong with this its not working also not giving any error

fervent moss
#

Well anybody here makes bit in pure node.js?

stiff lynx
lyric mountain
fervent moss
vivid fulcrum
#

with djs is pure node aswell

#

lmfao

lyric mountain
#

but at what point would it stop being "pure" (note that "pure js" isn't equal to "pure node.js")

vivid fulcrum
#

making a bot without using a library (especially if you're going to interact with the gateway) is just shooting yourself in the foot

fervent moss
#

My mistake

lyric mountain
dry imp
lyric mountain
#

you're an exception

vivid fulcrum
#

the skill differences are polar opposites

#

hehe

fervent moss
#

Well I also did but not completely I did make many bots in autocode where djs isn't supported >-<

lyric mountain
#

waitwaitwait

dry imp
#

autocode 💀

quartz kindle
#

lmao

lyric mountain
#

in what world would autocode be more pure than djs?

quartz kindle
#

pretty sure autocode uses djs behind the scenes

#

i mean, most other competitors do/did

pulsar bone
#

hello

carmine summit
#

why are some functions in js modifies the original value rather than make a copy of it? isnt it just simpler if they all just return a new value?

lyric mountain
#

because it's oop

wheat mesa
#

References

lyric mountain
#

like obj.setSomething(value) is expected to modify the object itself so you can work with states and keep logic inside themselves

quartz kindle
#

there are very few functions that actually modify the object

#

but they likely do it like that either for peformance reasons or because it makes logical sense

#

ie array.sort() and array.splice()

cinder patio
#

there should be an immutable array class which has all the methods Array has but they return a clone instead of mutating it

lyric mountain
#

Array.Prototype.cloneSort = () => { const arr = [...Array]; arr.sort(); return arr; }

carmine summit
#

how do I fix

#
# Fatal error in , line 0
# Fatal JavaScript invalid size error 169220804
#
#
#
#FailureMessage Object: 000000314EBBE980
 1: 00007FF79E4B7B7F v8::internal::CodeObjectRegistry::~CodeObjectRegistry+114079
 2: 00007FF79E3D25AF std::basic_ostream<char,std::char_traits<char> >::operator<<+65023
 3: 00007FF79F0B2772 V8_Fatal+162
 4: 00007FF79EC365C5 v8::internal::FactoryBase<v8::internal::Factory>::NewFixedArray+101
 5: 00007FF79EADFB83 v8::internal::FeedbackNexus::ic_state+62771
 6: 00007FF79EAF66E0 v8::debug::Script::GetIsolate+15840
 7: 00007FF79E96A231 v8::internal::CompilationCache::IsEnabledScriptAndEval+26913
 8: 00007FF79EE08F91 v8::internal::SetupIsolateDelegate::SetupHeap+494417
 9: 00000206B49899E5
lyric mountain
#

ur trying to create an array with invalid size

carmine summit
#

what's the max size?

#

How do I make my app eat more ram?

#

It is crashing only using 2gb of memory

quartz kindle
quartz kindle
carmine summit
quartz kindle
#

because 32bit is faster and uses less memory

#

why would you need an array with more than 4 billion items?

#

even if you fill it up with zeroes, it will still use stupid amounts of ram

#

minimum 4gb multiplied by whatever overhead array items have

solemn latch
#

If you need something that large I feel like js isn't the language for it anyway.

simple stump
#

Sorry this is sort of off-topic to this channel, but how can I download files directly from https://mega.nz? I'm trying to use this library: https://mega.js.org
But I can't seem to download the folder. I've also tried .decrypt (see code below), but that doesn't seem to work either. Most likely because the project is a fork of the original mega package.

let file = await mega.file(url);
let key = file.key;
console.log(file.directory); // true
await mega.decrypt(key).pipe(fs.createWriteStream("../file/" + file.name));
quartz kindle
#

why is your code different from their docs?

#

including logging in using the storage object, then finding the file object from it?

restive barn
#

I know I'm moving to v13

#

But is it even possible to make it when people vote for my bot on top.gg the bot is able to give the member anything

#

I dont see alot of these bot have this

#

Okay so it is possible

#

K thx

lyric mountain
restive barn
#

Well my bad

#

Sry

quartz kindle
#

only shit bots have this

split hazel
#

though actually 64-bit modern cpus apparently can process 64 bit integers faster than any other size

#

such as 16/8/32

compact pier
#

im trying to register a service worker

#

but it shows something like this

#

:/

quartz kindle
#

therefore they are nullable, aka not guaranteed to exist

compact pier
#

so what i have to do

#

grant it a value?

quartz kindle
#

so you have to either check for their existence first, or tell typescript that the value is not nullable

compact pier
#

mhmm

#

ok

#

i will try

#

mhmmm something new from react

modern summit
#

Umm

fickle arch
#

What is the standard price for hiring freelancer.

solemn latch
#

depends on their skill level

fickle arch
#

I see.

solemn latch
#

Speedy is only $5? Hype

#

Can you code everything for me

quartz kindle
#

and me

#

finish my api for me pls

solemn latch
cinder patio
#

god researching NFC programming is painful... every article I stumble across just tells me to use an app...

fickle arch
#

Finish my homework for 5$ 😀

lyric mountain
#

@quartz kindle I need ur master astrologician help

#

how could I get moon phases given a 0-365 day calendar?

#

is there like a pattern or formula?

cinder patio
#

use an API ez

quartz kindle
#

depends how accurate you want it to be

#

there are many premade calendars, you could make it on a calendar basis, or on an orbital basis

#

for example you can do some math with the moon's orbit and the sun's orbit speeds

#

If we were to draw a line between the Earth and the Sun, and time the duration the Moon takes to complete this cycle, we'll see that it takes roughly 29 days 12 hours 44 minutes 3 seconds or 29.53058770576 days. This is when the Moon is in the same position relative to the Sun, and so has the same lunar phase. This measure is of the Moon's orbit is known as a synodic month.

#

pick a starting epoch where the moon had an exact phase, and use those timings to proceed

#

that would be a fairly simplified but still accurate method (will likely lose some accuracy the further away from the starting epoch it gets)

lyric mountain
#

thx 😘

ancient nova
#

does anyone want to havea go at making my cs script actually work cause I'm too lazy

#

;]

simple stump
#

How could I make this part of my website better? I feel like the general layout feels too descriptive and not “eye catching”. This is the search results page by the way. I’m trying to play around with different search result layouts and just can’t find a way to make this feel more modernized.
Also I just realized the logo isn’t centered with the page whoops.

cinder patio
#

everything is off-centered so maybe you should focus on that first

stiff lynx
#

I have a question about buttons.

I'm trying to do a command with buttons that edit an embed.
If I handle the buttons in interactionCreate.js by their customId, how can I edit the embed?

quartz kindle
#

discord.js?

stiff lynx
quartz kindle
#

interaction.update()

stiff lynx
#

and how I add a field in the embed?

#

I would ask for help in a collector to do inside the file, but I dont know if someone has the time to explain how to do it

quartz kindle
#

you dont edit the embed, you replace the embed with a new one

#

the same as you do in message update

#

interaction.message should have the original message

#

the message should have the original embed

#

you can use it to create a copy of it

#

then do the changes, and send the new embed

stiff lynx
#

I'm sorry for not getting it, but I'm new with Buttons and also with editing embed, how I get the original one?

#

In the console.log(interaction.message) I see the embed and it is correct, but how I update it

quartz kindle
#

copy the information from the old embed into it

#

the MessageEmbed class also allows creating a new embed from an existing embed

#

new MessageEmbed(oldEmbed)

stiff lynx
quartz kindle
#

wdym?

slender wagon
#
input.value + 1

this no worki

#

why

#

should change the number

#

shit

#

had to use

#

Number()

dry imp
sharp geyser
#

Not really a development related question but more so a question about windows. So I am having the issue of windows not recognizing a previously recognizable hdd drive I setup for my pc which has all my projects and other important things that I do need and would like to not lose. I am wondering if anyone can help with this. I have already tried going through device manager and looking at it and it seems that it is registered as an Unknown Device

quartz kindle
#

what kind of disk is it?

sharp geyser
quartz kindle
#

internal? external? usb? sata? m2/nvme?

sharp geyser
#

Ah that is what you mean

#

I have it connected via a sata cable

quartz kindle
#

tried unplugging and replugging?

sharp geyser
#

Yep

wheat mesa
#

major sata issue

quartz kindle
#

tried a different sata port?

wheat mesa
#

Tried a different sata cable as well?

sharp geyser
#

Only other port is the port my ssd is connected to which is more important than my hdd

#

:^)

quartz kindle
#

tried unplugging and replugging the power cable? assuming 3.5 inch disk

sharp geyser
#

I have tried unplugging and plugging the cables back in yes

wheat mesa
#

Have you tried booting without it, shutting back down, and then booting with it plugged in?

#

I had to do that for my GPU once

#

Scared the ever living fuck out of me

#

PC wouldn’t boot (for the first boot I ever did on this one), unseated the GPU and unplugged it, booted without it, shut down, seated and plugged it back in, and then it worked perfectly on the next boot

quartz kindle
#

hdds are hot swappable tho

#

you can replug them with the pc on

neat ingot
sharp geyser
#

I just tried with it on and it appeared again

neat ingot
#

was more tears cause of no pc than noises though 😂

sharp geyser
#

but in the past when it has came back it usually goes away after a while

neat ingot
#

how old is this drive? it sounds a little temperamental

sharp geyser
#

No idea how old the drive itself is

#

I got this pc in a trade

quartz kindle
#

so the disk worked again?

sharp geyser
#

For now yes

neat ingot
#

back it all up now

quartz kindle
#

can be a bad sata port or cable then

#

interminnent connection

sharp geyser
#

I have another sata cable somewhere

#

if it disconnects again I will just find it and try it

neat ingot
#

backup your important projects to some private github repo 🙂

quartz kindle
#

upload to google drive or mega

neat ingot
#

yea, any 'off site' place tbh

#

just back it up 😄

#

which is better?

austere surge
#

2

#

whys minimize an _ tho

neat ingot
#

idk, it just does 😄

austere surge
#

mk

neat ingot
#

discord minimizes uses an '-'

austere surge
#

- is beter imo

neat ingot
#

yea, seems to be neater, and a more common way to show minimize

austere surge
#

ye

neat ingot
#

idk why bootstraps minimize icon is so low

pale oasis
#

I’m dealing with an array that has around about 250 objects. Should I just do a simple for loop to find the object I need. Also to find where that object is inside the array, or should I use something else?

neat ingot
#

use the find method?

#

array.find(element => element.thing === 5)

#

or the some method

#

array.some(element => element.thing === 5)

#

an array of 250 elements is considered tiny

austere surge
#

9874275

neat ingot
restive barn
#

When a user vote it failed putting 10k coins into there bal

austere surge
neat ingot
#

i honestly dread to think what kind of data your farming if your array has 4 thousand million elements 😄

austere surge
#

tru

neat ingot
split hazel
#

tf does this mean

#

want to join a big code help server but getting this

#

because i need some aspiring c developers to help me which i dont think this server has

wheat mesa
#

big code help server probably gonna have less good c devs than in here tbh

#

I might get automodded for this but I'll give it a shot for you @split hazel

#

hell yeah I didn't get automodded

austere surge
#

nic

split hazel
#

yeah if youre a bot dev you get link passes

wheat mesa
#

It says C++ but they do C in there

austere surge
#

time to get realmodded :troll:

split hazel
#

epic i'll give it a shot

quartz kindle
#

you cant do C++ without C

#

its kinda like doing TS without JS

wheat mesa
restive barn
#

is there discord.js server? LMFAO

wheat mesa
#

but I can't vouch for the knowledge of the people in that one since I'm not in it

#

I know the C++ people in there are expert level nerds

split hazel
quartz kindle
restive barn
split hazel
#

tho its more of an operating system question (no not my os)

restive barn
#

Need help

quartz kindle
#

everyone knows it

restive barn
#

Bet

#

What the code to join?

quartz kindle
#

just go to their website and click join discord lol

restive barn
#

nvm it js

split hazel
#

was wondering if its possible to open a file with both read and write and be able to append data at the end

#

or would i have to open another handle with append

quartz kindle
#

you can create multiple handles to the same file

split hazel
#

yeah just was wondering if its possible to do it with one

quartz kindle
#

probably yes, but you'd have to do it more manually i guess

#

not sure what append does for you that r+ doesnt

split hazel
#

guess not since theres one function which accepts data and how that data is accepted depends on the handle mode

split hazel
#

want to be able to seek certain structs in a file as well as add new ones at the end

restive barn
#

bruh js hub server turn chat off

#

smh

split hazel
#

@quartz kindlewait seeking to the end of the file then writing works

#

i swear that didnt work for me before

#

well great i guess

quartz kindle
#

xd

split hazel
#

@quartz kindle dynamic array allocation stack vs heap

#

i see a lot of people using the heap unnecessarily when the data they're storing is temporary so they should just use the fast stack

#

find it pretty cool how you can allocate space on the stack by doing char items[size]

quartz kindle
#

but you need to know the size at compile time

#

if you know the maximum possible size that can happen, you can just reserve a big enough stack array for that

#

otherwise you have to use heap

split hazel
#

i can make arrays with dynamically acquired sizes on runtime

quartz kindle
#

since when

split hazel
#

right time to look stupid

#

brb

#

@quartz kindleyeah you can

#

no errors

#

i mean its not a surprise its possible

quartz kindle
#

huh weird

split hazel
#

in assembly form its a simple subtract x from stack pointer

quartz kindle
#

last time i tried doing that it didnt work

earnest phoenix
#

pls help me

split hazel
#

yeah compiles and runs without an issue

#

i'll have a look at the assembly

earnest phoenix
#

i want make the msp glitch

quartz kindle
#

Programming languages that support VLAs include Ada, Algol 68 (for non-flexible rows), APL, C99 (although subsequently relegated in C11 to a conditional feature, which implementations are not required to support;[2][3] on some platforms, could be implemented previously with alloca() or similar functions) and C# (as unsafe-mode stack-allocated arrays), COBOL, Fortran 90, J, and Object Pascal (the language used in Borland Delphi and Lazarus, that uses FPC).

#

i guess my compiler didnt like it? idk

earnest phoenix
#

what this

#

?

wheat mesa
quartz kindle
#

talking to speedy

earnest phoenix
#

talking germany ?

quartz kindle
#

what

wheat mesa
#

What?

#

What is “the msp glitch”

earnest phoenix
#

where ist he invite tracker

#

I think just wrong server moment

#

i want to make the mso hair gkitch does anyone know to do it?

quartz kindle
#

???

earnest phoenix
#

What is that

split hazel
earnest phoenix
#

movistarplanet

quartz kindle
#

what??

split hazel
earnest phoenix
wheat mesa
earnest phoenix
#

can you help me ?

split hazel
#

well mostly c since you have references in c++

wheat mesa
#

Yes

#

C# is more like Java than C/C++ though

#

But still has pointer capability

#

Just only when marked as unsafe

split hazel
#

actually i can see why its unsafe @quartz kindle

#

if you were to provide a negative integer to it for example it would accept it without question possibly overwriting stack variables and causing segmentation faults

#

since theres no runtime checks

#

but other than that if you have validation checks you should be fine

sharp geyser
#

@quartz kindle so now every time I try and delete something from the hdd it disconnects and reconnects

quartz kindle
#

backup asap

sharp geyser
#

I can't do anything with it

#

It disconnects every time I try

quartz kindle
#

rip

lament rock
#

chkdsk would fail

quartz kindle
wheat mesa
#

My brain is too fried to think about this after working with ASP.NET for the last 5 hours: if I have a postgresql database with a column of keys called "id", if I delete one entry via ID, is there a nice way to shift all of the other elements back? Ex: IDs = [1, 2, 3, 4, 5, 6] and values = [6, 5, 4, 3, 2, 1], DELETE ID = 5, IDs becomes [1, 2, 3, 4, 5] and values becomes [6, 5, 4, 3, 1]

#

(ping on replies, gonna get off for the night so no rush)

restive barn
#

I use discord.js v12 and I am trying to make the bot send the message to a specific channel and I dont know if this is right or not Im confuse?

client.channel.cache.get(channel_ID).send(``)

quartz kindle
#

channels

lament rock
#

actually. You shouldn't do that because there's an internal int being incremented to use as the next available ID

#

you could also change that but ???

fickle basalt
#

How can i get votes of a user

boreal iron
#

For example by listening to the webhooks topgg can send to your endpoint

marble juniper
earnest phoenix
#

and heres your second issue: you use discord.js

dry imp
#

here is your third issue: you use discord

austere surge
#

heres your fourth issue, you live

rocky hearth
#

I'm trying to deploy a express app on heroku, do I need web dyno or worker dyno for that?/

pearl trail
#

web

civic scroll
fickle arch
#

do I need to limited dm command to owner only ?

#

because my friend said it could be abuse by people

pearl trail
#

correct me if i'm wrong but you can limit it to server admins

#

that's what most moderation bot did

real rose
fickle arch
#

so like from author

#

ah alright then, I'm probably just gonna limited it to bot owner since I don't want people to misuse it for advertising and such, gonna add where the message come from either.

winged obsidian
#

wht shld i enter here

rich iron
fickle arch
winged obsidian
#

oh

winged obsidian
#

i entered the url

fickle arch
#

I'm not really using webhook neither know much about it, maybe try send test.

winged obsidian
wheat mesa
rocky hearth
#

what's diff, in these 2

let a = function(x, y) {
   return x * y;
}

// And

function a(x, y) {
   return x * y;
}
fickle arch
#

uh how do I make bot send who sent the dm to a user.

woeful pike
#

the second is hoisted to the top

sudden geyser
#

And the first is anonymous

woeful pike
#
{
  function a(x, y) {
     return x * y;
  }
}
a() // works
{
  const a = function(x, y) {
     return x * y;
  }
}
a() // doesn't work
#

pretty pointless distinction imo

rocky hearth
#

for named functions

woeful pike
#

accessible within the scope of the function they're located in, much like var

#

but also

a() // works
function a(x, y) {
  return x * y;
}
a() // doesn't work
const a = function(x, y) {
  return x * y;
}
#

function names are registered before execution, anonymous functions don't get that because they don't have names

rocky hearth
#

hmmm, now I get it. Named functions are very similar to how var works

woeful pike
#

well var won't behave like above

rocky hearth
#

but it doesnt throws exception atleast

woeful pike
#

it does

rocky hearth
#

if used before declaration

#

it does only in strict mode 🤔

fickle arch
#

djs 13 change haspermission to permission.has ? tried it but ended up with undefined reading has

fathom sonnet
fickle arch
#

I already did

fathom sonnet
#

hmm

#

let me see the code

#

maybe there is typeerror beafore .permission

fickle arch
#
if(!message.member.permission.has("MANAGE_MESSAGES")) return message.channel.send('You do not have permission to use this command!')```
#

bruh I still can't put the code properly on discord

fathom sonnet
#

typo

#

its need to be permissions

#

if(!message.member.permissions.has('MANAGE_MESSAGES'))

rocky hearth
#

what's issue here?

type OnlyNumAndString = <T>(arg: T) => void

// TS-Error: Type 'T' is not assignable to type 'number'.
const fun:OnlyNumAndString = (a:number) => {}

Also I want T to be only of type number and string

true ravine
#

Can't you do ```js
<T extends number|string>

fickle arch
#

it ended up like this

#

I already typed the message tho

quartz kindle
rocky hearth
#

I want it to auto detect, for number or string

quartz kindle
#

not sure if you can use T without generics

cinder patio
#

(arg: string|number) => void

rocky hearth
cinder patio
#

that's either one of them?

#

Either a string or a number

quartz kindle
#

pretty sure you'll have to use generics

spark flint
#

is anyone here good at docker

rigid jacinth
#

docker terrifies me

cinder patio
#

You'll always need to provide the type if you don't want to use an union...

#

unless you set a default to the type parameter

fickle arch
#

anyone know how to solve this

spark flint
#

don't send an empty message

sudden geyser
#

Don't send a message with no content

#

That includes for embeds

fickle arch
#

It's not a empty message.

sudden geyser
#

The error disagrees

#

You'll need to find where the error is coming from

#

Which can help spot the issue

fickle arch
#

deleted the embed part, and it worked, but the embed was supposed to tell where/who the message send

lyric mountain
#

just show the previous code

fickle arch
#
 run: async (client, message, args, cmduser, text, prefix) => {
if (message.author.id !== ownerID)
      return message.channel.send('You are not the owner of this bot')
    let user = message.mentions.users.first() || message.guild.members.cache.get(args[0])
    if (!user)
      return message.channel.send('Please mention a user or provide a valid ID')
    let msg = args.slice(1).join(' ')
    if (!msg)
      return message.channel.send('Please provide a message')
    let dm = new Discord.MessageEmbed()
      .setTitle('DM')
      .setDescription(`${message.author} has sent you a DM`)
      .addField('Message', msg)
      .setColor('#00ff00')
    user.send(dm)
    message.channel.send(`DM has been sent to ${user}`)```
#

this was the previous one

fickle arch
#

yes

proud ore
#

also, there can be a error if the user has closed dm so add a .catch((e) => {return message.channel.send('Your DM is closed!')}) to the user.send()

fickle arch
#

oh right, I forget to add the error part if the user closed their dms/blocked the bot

pale oasis
fickle arch
#
let dm = new Discord.MessageEmbed()
          .setTitle('DM')
          .setDescription(`${message.author} has sent you a DM`)
          .addField('Message', msg)
          .setColor('CYAN')
          user.send({embeds:[dm]})
          .catch(e) => {return message.channel.send('User DM is closed!')})
        message.channel.send(`DM has been sent to ${user}`)
  }
}```
like this ?
spark flint
#

I installed redis-server on ubuntu 20.04

#

and its running and active

#

but I can't seem to access it from my docker container

fickle arch
quartz kindle
fickle arch
#

make senses.

pearl trail
#

use .then for a success promise

fickle arch
#
try {
            await user.send(msg)
          } catch (e) {
            return message.channel.send(`${user} has their DMs closed`)
          }
          message.channel.send(`DM sent to ${user}`)

  }
}```
Tried this and it's still sending the message twice (if the user has his dm closed)
rigid jacinth
#

i wonder if the return is only returning out of the catch function

#

instead of the whole try function

restive barn
rigid jacinth
fickle arch
#

what

rigid jacinth
restive barn
civic scroll
#

plus

#

why don't you check if the channel exists

#

if it doesn't you are performing "send" on undefined

#

with will throw a reference exception

rigid jacinth
#

if the channel is undefined it shouldn't send the message in the dms

simple stump
#

I'm having an issue with my bot not being able to ping a role. It has full permissions and normal users can ping a role perfectly fine, but the bot isn't able to for some reason.

interaction.channel.send("<@&" + roles.queuePing + ">");

The role is sent with colors and whatnot, it just doesn't send the notification.

restive barn
civic scroll
rigid jacinth
#

that might work?

civic scroll
#

assume the block is async

rigid jacinth
civic scroll
rigid jacinth
#

ohhh-

#

yeah that makes sense

civic scroll
#

which rejection is DiscordAPIError

rigid jacinth
civic scroll
#

plus it looks cleaner than callback chains

rigid jacinth
#

fair

fickle arch
rigid jacinth
#

ok wait so do you mean it sent both of the channel messages

#

or it sent the dm and said that the dms were closed

fickle arch
#

this basically

#

sent the message twice on the dms

#

for the channel it doesn't send the one saying user dms is closed.

rigid jacinth
fickle arch
#

yeh the dm is the msg I tried to send to the user dm

rigid jacinth
#

because if so, you have user.send({embeds: [dm]}) written once already, and then

#

user.send(msg) written in the try statement

#

so it sends the dm and then sends the msg, so delete the user.send that's outside of the try statement

fickle arch
#
let dm = new Discord.MessageEmbed()
          .setTitle('DM')
          .setDescription(`${message.author} has sent you a DM`)
          .addField('Message', msg)
          .setColor('ORANGE')
            user.send({embeds:[dm]})
    
          try {
            await user.send(msg);
            message.channel.send(`DM sent to ${user}`);
          }
          catch (e) {
            message.channel.send(`${user} has their DMs closed`);
          }
        }
      }``` 
I'm probably mistaking the placement of it
rigid jacinth
#

let dm = new Discord.MessageEmbed()
.setTitle('DM')
.setDescription(${message.author} has sent you a DM)
.addField('Message', msg)
.setColor('ORANGE')
user.send({embeds:[dm]}) //delete this

      try {
        await user.send(msg); //change this to await user.send({embeds:[dm]})
        message.channel.send(`DM sent to ${user}`);
      }
      catch (e) {
        message.channel.send(`${user} has their DMs closed`);
      }
    }
  }
civic scroll
#

delete this statement

    user.send({embeds:[dm]})
rigid jacinth
civic scroll
#

why do you send that message twice to the same location

rigid jacinth
#

i can give a quick explanation if you need

rigid jacinth
fickle arch
civic scroll
#

delete the 1st one i mentioned

rigid jacinth
#

so a try statement will run the code inside of the block, all it's saying is that if it fails it will run the catch statement instead of logging an error and stopping the app

fickle arch
#

deleted the user.send embed and put it below the await

rigid jacinth
#

but if it's successful, the code inside a try block still runs

civic scroll
#

now try executing again

rigid jacinth
civic scroll
fickle arch
rigid jacinth
fickle arch
#

alright the code is working but if only the user block the bot somehow

rigid jacinth
#

huh?

fickle arch
#

so basically I sent the test dm to my friend, he have dm closed, the bot still send the message but if he block the bot, it send the other message

#

after the bot is blocked

royal herald
#

how do i set user agent on electorns webview

#
   app.setAttribute("useragent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) discord/1.0.45 Chrome/91.0.4472.164 Electron/13.6.6 Safari/537.36");
``` this doesnt work
lyric mountain
lyric mountain
#

or user-agent

#

u forgot the dash

royal herald
#

huh

simple stump
#

I'm having an issue with my bot not being able to ping a role. It has full permissions and normal users can ping a role perfectly fine, but the bot isn't able to for some reason.

interaction.channel.send("<@&" + roles.queuePing + ">");

The role is sent with colors and whatnot, it just doesn't send the notification.

lament rock