#development

1 messages ยท Page 1829 of 1

shadow frigate
#

@split hazel

near stratus
#

can you please not send a screenshot
and copy paste the code on Discord
It helps us to see

thorny arch
#

oh sure

#
@client.command()
async def equip(ctx, *,item_name:str):
    cnx, cursor = make_connection()
    item = item_name.lower().replace(' ','_')
    query1 = 'SELECT %s FROM inventory where user_id = %s'
    cursor.execute(query1,(item,ctx.author.id))
    result = cursor.fetchone()
    if result[0] == 1:
        query2 = 'UPDATE economy_data SET equi_item = %s'
        cursor.execute(query2,(item_name.lower().replace(' ','_'),))
        cnx.close()
    else:
        await ctx.send("You don't have {} in your inventory.".format(item_name))
    cnx.close()
#

@near stratus

valid frigate
#

did you mean the typo in equi_item

thorny arch
#

not that i know of

#

the entire problem is that instead of getting the result as a 0 or a 1, iget it as the column name

valid frigate
#

i see

thorny arch
#

pls i need help

#

this has been driving me insane for the past few days

shadow frigate
#

How would I go about sending a user a message for upvoting my bot.
I have a webserver detecting the upvote webhook but it's not linked to the bot, and the bot is also sharded.
How would I send them a thank you message for upvoting?

shadow frigate
#

eh

#

oh, im not on about upvoting on this servers website btw

#

on about another one lmao

valid frigate
#

is your issue from the fact that your bot is sharded

obsidian flint
#

take it or leave it

shadow frigate
#

Well yes, because I would have logged in using the token in the webserver and i'd have access to the client then.

shadow frigate
#

But since it's sharded, I cannot do that

valid frigate
#

i see

shadow frigate
#

If so, then yes

valid frigate
#

for each instance of your bot you should be able to make it listen for the upvote webhook

#

broadcast that to your bot instances and have each one search for the user in their cache

#

if a match is found try to dm them

#

thats what im thinking

shadow frigate
#

Also, since it's sharded, if the user is in multiple servers across different shards, I don't want the message being sent twice

valid frigate
#

hmm this is also a valid concern

shadow frigate
#

I could cache incoming votes, like so:

[
  {
    "discord_id": "DISCORD-ID",
    "type": "upvote"
  },
  {
    "discord_id": "DISCORD-ID",
    "type": "donation"
  }
]
near stratus
shadow frigate
#

Oh

#

My

#

God

valid frigate
#

that also works

shadow frigate
valid frigate
#

also is it not possible to call this directly from the library hes using

shadow frigate
#

has to be node-fetch?

valid frigate
#

id think if its a wrapper this would have been the first thing he looked at

#

there should be a function that covers that

near stratus
obsidian flint
#

node-superfetch idk

shadow frigate
#

including unirest?

sudden geyser
near stratus
shadow frigate
near stratus
shadow frigate
#

Yup, so i'm assuming it'll work lmao

near stratus
#

with headers ?

shadow frigate
#

aye

#

the whole shebang

valid frigate
#

what library are you using btw

near stratus
#

then it'll work

valid frigate
#

djs

shadow frigate
#

Great

#

Thanks very much lmao

#

I actually didn't think of doing that

near stratus
#

Create a post request

url: "https://discord.com/api/users/@me/channels"
method: "POST"
headers: [
  "authorization": "Bot YOUR_BOT_TOKEN"
]
value: {
  "recipient_id": "THE_USER_ID"
}
shadow frigate
#

no url parameters?

#

it says there is on the site

#

/channels/{channel.id}/messages

#

or am i looking at the wrong one lol

#

and if it is that one, then would channel.id be replaced with the users ID?

near stratus
#

you can send message after the dm has been created

near stratus
shadow frigate
#

Okay

#

Thanks

#

How would I check if the DM creation is a success?

#

before sending the message

near stratus
# shadow frigate `/channels/{channel.id}/messages`

Then create another post request to /channels/{channel.id}/messages

url: "https://discord.com/api/channels/{channel.id}/messages"
method: "POST"
headers: [
  "authorization": "Bot BOT_TOKEN_HERE"
]
value: {
  content: "Pooooooooooooooog"
}
near stratus
#

*response

shadow frigate
near stratus
#

np

shadow frigate
near stratus
#

not sure tho

shadow frigate
#

Oh alright

#

Only one way to find out ๐Ÿ˜‚

near stratus
#

wait no

#

it returns a dmchannel object

#

it has an id

shadow frigate
#

okay

#

ty

earnest phoenix
#

Hello how to send embeds in inline replies? I'm using raw api. I assume we need to create a embed and

client.api.channels(message.channel.id).messages.post({
type: 1,
data: {
content: embed,
message_reference: { message_id: message.id }
}
})```
Correct?
quartz kindle
#

not in content

#

data: { content: "text", embeds: [ embed ] }

earnest phoenix
quartz kindle
#

content is text message

#

text outside of the embed

earnest phoenix
#

oh ok

#

ty

#

I have no text btw

#

Only embed

quartz kindle
#

so dont add content

earnest phoenix
#

ok

#

so embeds: [ embed ]

quartz kindle
#

yes

earnest phoenix
#

ty

timber fractal
quartz kindle
#

that code is generating an infinite amount of timers lol

timber fractal
#

oh shoot

timber fractal
quartz kindle
#

also this is not a thing (await guild.members.fetch()).get(userId)

#

the fetched member is already a member

#

there is no member.get()

#

wait, you're fetching ALL members?

#

why?

timber fractal
#

but how is it generating infinite timers

quartz kindle
#

you have this

timber fractal
#

is this better? (await guild.members.cache.fetch(userID))

quartz kindle
#
setInterval(() => {
  function abc() {
    setTimeout(abc, 600000)
  }
  abc();
}, 30000)
#

the interval calls abc every 30 seconds

#

then abc itself calls itself every 60000 seconds

timber fractal
#

oooh

quartz kindle
timber fractal
#

ok

#

shouldnt it be cache.get()?

quartz kindle
#

also, dont use .find() when you have the id

#

guild.roles.cache.get(roleID)

quartz kindle
timber fractal
#

oh k

#

cuz it still doesnt update the mutes

quartz kindle
#

you're not waiting for mongo to connect

#
async () => {
  await mongoose.connect();
  // do stuff
}

or

() => {
  mongoose.connect().then(() => {
    // do stuff
  }).catch()
}
#

.cache.fetch doesnt exist

#

its either .cache.get() or .fetch()

jagged yarrow
#

can someone help, when i add a .js file to my commands folder then do node . to run it in the terminal i get a err.

quartz kindle
#

well, what error?

jagged yarrow
quartz kindle
timber fractal
rocky hearth
#
    interaction.reply({
      content: connectFour.toString(),
      components: [
        {
          components: Array.from(Array(5), (_, i) =>
            new MessageButton()
              .setCustomId(`col_${i}`)
              .setLabel((i + 1).toString())
              .setStyle("PRIMARY")
          ),
        },
      ],
    })

Why im getting this error, for above code

earnest phoenix
#

Does someone know how to create multiple command files like commands/mod/kick.js
commands/music/play.js

#
const commands = readdirSync(join(__dirname, `commands`)).filter(file =>
  file.endsWith(".js")
); 
for (const file of commands) {
  const command = require(join(__dirname, `commands`, `${file}`));
  if (typeof command.name === "object") {
    command.name.forEach(x => {
      client.commands.set(x, command);
    });
  } else {
    client.commands.set(command.name, command);
  }
}
#

its my command handler

sudden geyser
#

the issue is you're filtering out all your sub folders/categories

earnest phoenix
#

Actually i didnt try to do it

#

I need some help for start to try

sudden geyser
#

well that is your issue at hand

#

you first read all the files and directories in commands

#

then you filter them out so only .js files remain

#

then you try finding all commands in the category

#

see the issue

#

your categories were filtered out

rocky hearth
#

@earnest phoenix

export async function getFiles(
  directory: string,
  extension: string,
  subdirectories = true
): Promise<Array<string>> {
  if (subdirectories) {
    const dirents: Array<fs.Dirent> = await new Promise((resolve, reject) => {
      fs.readdir(
        directory,
        { withFileTypes: true },
        (error: Error | null, dirents: Array<fs.Dirent>) => {
          if (error) {
            reject(error)
          } else {
            resolve(dirents)
          }
        }
      )
    })

    const names: Array<string> = []
    for (let folder of dirents.filter((dirent) => dirent.isDirectory())) {
      const files = await getFiles(`${directory}/${folder.name}`, extension, subdirectories)
      for (let name of files) {
        if (name.endsWith(extension)) names.push(`${folder.name}/${name}`)
      }
    }
    for (let file of dirents.filter((dirent) => dirent.isFile())) {
      if (file.name.endsWith(extension)) names.push(file.name)
    }
    return names
  } else {
    const names: Array<string> = await new Promise((resolve, reject) => {
      fs.readdir(directory, (error: Error | null, files: Array<string>) => {
        if (error) {
          reject(error)
        } else {
          resolve(files.filter((file) => file.endsWith(extension)))
        }
      })
    })
    return names
  }
}```
rain sphinx
#

its shit but it works

sudden geyser
#

unless music is also paired with a file like music.js

#

that's some massive spoonfeeding

rain sphinx
#

why is this not working, it creates string[] but i cant access any values

#

it logs empty line

rocky hearth
#

split(" "), seems to hv 2 spaces? No?

rain sphinx
#

single space

#

it works

#

but

#

i cant access any...

sudden geyser
#

are your logs being redirected elsewhere

rain sphinx
#

nah

#

nevermind... i just had to use " " instead of ' ' ๐Ÿ˜ญ

earnest phoenix
rain sphinx
#

it loads file and executes main() from command_file

earnest phoenix
#

Can i use like that const cmdFiles = ["mod","music"]
Join dirname, cmdFiles.forEach(x => x.filter

rain sphinx
#

i dont see why u couldnt

#

u have to require it tho

crystal furnace
#

where was my 15$ of fake credit

#

how to claim it ?

near stratus
crystal furnace
rain sphinx
near stratus
earnest phoenix
quartz kindle
#

you have to add an action row

#

then add buttons to the action row

earnest phoenix
#
const commands = readdirSync(join(__dirname, `commands/${cmdDirs}`)).filter(file =>
  file.endsWith(".js")
); 
for (const file of commands) {
  const command = require(join(__dirname, `commands/${cmdDirs}`, `${file}`));
  if (typeof command.name === "object") {
    command.name.forEach(x => {
      client.commands.set(x, command);
    });
  } else {
    client.commands.set(command.name, command);
  }
}
#

I want to do like this

rain sphinx
#

are u getting any errors or

earnest phoenix
#

I get error on this

#

No such a file or dir not found commands/music,mod

#

I need to use foreach for queue them but dont know how to use on it

rain sphinx
#

try to make your own command handler so u can do wtf u want ๐Ÿ˜ณ

earnest phoenix
#

Actually it works like i want

#

I need to duplicate it for each folder

rain sphinx
#

maybe make 2 commands

#

commandsMusic = readdirsync..
commands = readdirsync...
then u can easily separate em

quartz kindle
rapid zealot
#

MRX.exe

timber fractal
quartz kindle
#

you're still doing infinite timeouts

#

remove setTimeout(checkMutes, 1000 * 60 * 10)

#

did you check if your variables are correct?

#

add some console.logs to see if the code is working as expected

#

for example put a console.log inside the if(results && results.length)

#

to see if there are any actual results

lament rock
#

@quartz kindle Got around to trying if a different user agent worked for requesting googlevideo urls and it didn't, so. Still left clueless

#

Not asking you to do anything about it, just letting you know

quartz kindle
#

well rip

nimble kiln
#

I'm currently using
message.channel.send('Long code snippet', {code:'xl'})

How would I go ahead and use that when I use interaction.reply()? Sending it like above will just send it as regular text, not wrapped into code tags
Adding ` could be an option but is there a way to use {code:'xl'} in interaction replies?

quartz kindle
#

it was removed altogether in v13

vivid fulcrum
#

just insert the codeblock directly into your string

wheat mesa
#

You could just make a function that inserts ``` before and after the string you pass in, if you're worried about readability

crimson vapor
#

I prefer doing js message.channel.send( '``\`js\n' + code + '\n' + '``\`' )

#

damn it I hate code blocks in code blocks

eternal osprey
#

hey! How would i save all the messages from a textchannel to a txt file?

vivid fulcrum
#

practically, you can't

#

theoretically, keep fetching all messages in the channel until you hit the beginning on the channel and then just format and save

#

this is often going to lead to ratelimits, api bans etc.

#

can take a day or more to finish

#

it's possible, not advisable

rocky hearth
earnest phoenix
#
const cmdF = ["mod", "music"]
cmdF.forEach(x => {
const commands = readdirSync(join(__dirname, `commands/${x}`)).filter(file =>
  file.endsWith(".js")
); 
for (const file of commands) {
  const command = require(join(__dirname, `commands/${x}`, `${file}`));
  if (typeof command.name === "object") {
    command.name.forEach(x => {
      client.commands.set(x, command);
    });
  } else {
    client.commands.set(command.name, command);
  }
}
});
#

I did that

#

Thanks for whoever tried to help

nimble kiln
earnest phoenix
#

Then can anyone show an example using the raw api in python ?

sudden geyser
#

which api

hushed crescent
#

oh whoops wrong channel haha

feral aspen
#

Yoo.

#

I have this !buy command code whereas it would take from this array of objects called items...

module.exports = [
    {
        id: "attitudecoin",
        aliases: ["coin"]
    },
]
const embedError = new MessageEmbed()
.setColor(red)

const itemToBuy = args[0];

if (!itemToBuy) {
    embedError.setDescription(":x: Please mention the item ID that you want to buy from the shop.");
    return await message.channel.send(embedError);
};

const validItem = !!items.find((val) => val.id.toLowerCase() === itemToBuy);

if (!validItem) {
    embedError.setDescription(":x: The item ID you entered is invalid.");
    return await message.channel.send(embedError);
};
#

You see up.. I made it return a boolean whereas if the item is not valid.. then it would return by checking for its id.. but what tip do you guys give me for checking its aliases as well?

#

I've seen .includes() work.. meaning to check for aliases in this code. items.find((val) => val.aliases === itemToBuy)

#

.. not sure how to check for the aliases as well.. little help.

quartz kindle
#

do you also need to use the item later, or do you only need to validate and nothing else?

feral aspen
#

My only concern is how to merge aliases.

#

I know checking aliases first is the first step or else it would just return from the very beginning.

quartz kindle
#

val => [val.id, ...val.aliases].includes(itemToBuy)

#

only works if all items have aliases, or at least [] if they have no alias

feral aspen
quartz kindle
#

if you have items with no aliased field at all, you can do val => val.aliases ? [val.id, ...val.aliases].includes(item) : val.id === item

#

the commas are the spread operator

#

they "spread" the items in the array

#

for example

#

[1,2,3, ...[5,6,7]] = [1,2,3,4,5,6]

feral aspen
#

Yup.. rest operator and spread operator.

quartz kindle
#

yes, they have two names, because they do different things in different situations

feral aspen
#

Merging multiple values in an array and spreading an array into multiple values.

quartz kindle
#

ye

feral aspen
#

Rest.. spread.

#

.. so the code here.

feral aspen
#

This basically checks if the id or the list of the aliases array includes the items I mentioned to buy, right?

quartz kindle
#

yes

feral aspen
#

Works only if all items have aliases.. so by using the ternary operator to check if the item has alias.. I can apply the code or else I would check for the ID only, right?

quartz kindle
#

yup

feral aspen
#

Sweet sweet.. thanks! ๐Ÿ‘

quartz kindle
#

and for the case check, its better to convert the case of the user input

#

so itemToBuy.toLowerCase()

feral aspen
#

Yup.

#
const validItem = !!items.find((val) => val.id.toLowerCase() === itemToBuy);
#

..toLowerCase()

#
val => val.aliases ? [val.id, ...val.aliases].includes(item).toLowerCase() : val.id.toLowerCase() === item
quartz kindle
#

if val.id is made by you, then you can guarantee all of them are lowercase, so you dont need to case check them

#

unless the vals can be created by users

feral aspen
#

.. no, created by me.

feral aspen
quartz kindle
#

you case check the item that the user gave you

#

not your items

#

.includes(item.toLowerCase())

feral aspen
#

Oh.

#

Wait..

#

.. my bad. ๐Ÿ˜‚ I've been making the ID in the object lowercased instead of the input of the ID made by the user.

quartz kindle
#

ye xd

feral aspen
#

Yup.. my bad. ๐Ÿ‘

#

Thanks for it though. ๐Ÿ‘

quartz kindle
#

๐Ÿ‘

last tapir
#

hey

#

so i have an array ["a", "b", "c"]
I want to make a switch statement whereas those cases are those elements in the array

#

is it possible?

split hazel
last tapir
#

Im trying to speed the process

#

instead of writing

case "a":
case "b":
case "c":
case "d":
case "e":
case "f":
#

I do an array

split hazel
#

i mean cant you just iterate over it in that case

#

if i understand correctly

last tapir
#

I can't have 26 of them in a row. ๐Ÿ˜

split hazel
#

you could try chunking the elements in the array every x elements?

split hazel
#

so what are you trying to do exactly

#

a bit more detail

#

there is definitely a better way to do whatever you're trying to do

last tapir
#

instead of doing it like those.. I want to put the cases in an array and make a case whereas if this case is one of the elements in the array, then it would execute the code I specified

feral aspen
#

case ["a", "b", "c"]:

#

.. doesn't that work?

split hazel
#

ah now i understand

#

thanks person above

#

i dont think that'll work

last tapir
#

oh, it wont?

split hazel
#

you can try

#

if you do it faster than me:)

#

actually

#

fuck i need to test the code before i say something

boreal iron
#

If you switch to one case with 26 possible matches as you said youโ€™re probably doing something wrong.

last tapir
#

well the array of 26 indexes are the cases ...

#

instead of writing 26 cases.. i make one case which this case is considered as one of the element in the array

boreal iron
#

What does the array store and in which form?

last tapir
split hazel
#

yeah there is no clean way to do it with switch statements

last tapir
#

instead of case a, case b, case c, I do case [either a, or b, or c]

feral aspen
boreal iron
#

What does the array store and in which form?

split hazel
#

yeah we need more context

last tapir
#

FakE, i appreciate the help.. turns out it doesnt work

boreal iron
#

Well tbh I canโ€™t help. I missed the context or you havenโ€™t told us what I wanna know yet.

#

Can you give us an example of your array with some accurate items it stores?

feral aspen
#

Well..

quartz kindle
#

what exactly do you mean with a switch case here?

boreal iron
#

Nobody knows okeh

quartz kindle
#

what is the connection with each value in the array?

#

what is the switch case supposed to with each of those values?

feral aspen
#

You see in switch statements how you do something like..

switch (val) { case "a": case "b": case "c": case "d": case "e":  }

This can sometimes get very unorganised especially when having a lot of cases.. like 30 or 40.. so he's trying to see a way whereas instead of doing this.. he would check with one case and this case checks in the array if it equals to one of the indexes like case ["a", "b", "c"]

split hazel
#

myth: js developers can read peoples minds

feral aspen
#

Is this what you mean, Chill?

prime mist
quartz kindle
#

yes but... what does each case do?

feral aspen
feral aspen
quartz kindle
#

when simplifying code, you have to look into repeated patterns, so you can join them and reuse them

#

if each case is doing something completely unrelated, you cant simplify

#

so it depends what each case does

boreal iron
#

Instead of checking 26 similar cases, check all others and use default as case

feral aspen
#

.. all the cases does something equal.

#

Meaning case "a", "b", etc.. does the same code.

quartz kindle
#

then show what is the code

#

and i'll show how to simplify

boreal iron
#

If a, b, c does the same, then check d, e, f as case and use default: for the rest

last tapir
#

hamood's example, this. ```js
switch (val) {
case "a":
case "b":
case "c":
case "d":
case "e":
console.log("Successful.")
};

#

as in easy

#

.. but the half of the entire alphabets

boreal iron
#

Weโ€™re still missing an example with accurate items the array will store

feral aspen
#

Yeah.. 13 cases is kind-of too much.

quartz kindle
#

so basically if val matches any of those, run something?

last tapir
#

yes

quartz kindle
#

if(["a","b","c"].includes(val)) { run something }

last tapir
#

doesnt work for switch statements?

quartz kindle
#

wdym doesnt work for switch statements

prime mist
#

Who says you have to use a switch statement lol?

boreal iron
#

No it does not as it iterates through the array

last tapir
#
switch (val) { case ["a","b","c"].includes(val): console.log("Succeed"); }
#

doesnt work like that?

quartz kindle
#

no that doesnt work

boreal iron
#

Makes no sense

quartz kindle
#

it works if you do switch(true)

boreal iron
#

If your case isnโ€™t another array

last tapir
#

hm.. alright.. that's fine. ๐Ÿ‘

#

thanks for the help

boreal iron
#

very confusing

last tapir
#

nope

quartz kindle
last tapir
#

works for if statements but not for switch, makes sense now

quartz kindle
#

if you do switch(true) you can override the cases with your own logic

#

but at that point its just a glorified if else

boreal iron
last tapir
#

alright

quartz kindle
#

the way a switch works is that the case is compared to the value you put in the switch

#
switch(123) {
  case (is this 123?):
  case (is this 123?):
  case (is this 123?):
}
#

so if you use true, it becomes more flexible

#
switch(true) {
  case (is this true?):
  case (is this true?):
  case (is this true?):
}
#

meaning you can put anything in there, as long as it evaluates to true

earnest phoenix
#

Hi

boreal iron
quartz kindle
#

yes, its just a glorified if else

#

but with very long and completely unrelated conditions, it can be better than if else

#

more organized

earnest phoenix
#

I want code when bot enter for a server kicked

boreal iron
#

Imagine putting an extra line for each case for the break

earnest phoenix
#

I did not enjoy an achievement

quartz kindle
#

@earnest phoenixwhat? i did not understand anything you said

boreal iron
#

He said he wants code, so give him code! smirk

quartz kindle
#

yes, gimme all you are py code

boreal iron
#

You will get exactly 0 lines as nobody uses python eww

sudden geyser
#

(I (only (have (parentheses (for (you))))))

#

though I have some python for you, but you can't see it

wooden kindle
#

I use dynox rn to host my bot on there Free VPS option i want to switch to a place that is really cheap but cheap enough for a good amount of memory ect any suggestions

split hazel
wooden kindle
#

Lemme give it a look

#

Ahh yes there $5 package looks good tbh thanks @split hazel

split hazel
#

though i dont know what kind of tactics they use to keep prices low

#

would rather not know

quartz kindle
#

50 ssds in raid virtualized as ram

#

:^)

boreal iron
#

A different form of a ramdisk lol

#

Much more slowly

split hazel
#

plot twist they use sd cards

#

capable of 100mbps+

#

you could actually do that

#

i wanna do that now

#

the smallest wannabe ram

quartz kindle
#

with good enough ssds you get near-ram speeds

#

the problem is randomness

#

ssds are not good at that

#

you can get ssds working at 2-3gbps, ram works at 20-30gbps

#

put 4 ssds in a 4-way raid, you're already at 10-15gbps

#

not too far

#

but thats mostly sequential speed

#

once ssds start doing random access like ram does, the speed crumbles

boreal iron
#

lol the amount of IO will kill it very fast anyway

quartz kindle
#

ye

#

but if you do a 50-way raid

#

who knows

#

xDDD

split hazel
#

actually wont that be more expensive than just directly buying huge amounts of ram

boreal iron
#

lmao

split hazel
#

since you're having to replace ssds

quartz kindle
#

in the long run probably

#

but in the short run, you can sell petabytes of ram in vpses

#

xD

boreal iron
#

Imagine a RAID 10 RAM in hotswap
Plug and play RAM without loosing data

split hazel
#

i wonder if their dedis do the same

#

they sell dedicated servers

#

well in quotes

split hazel
#

seamless ssd rollover

boreal iron
split hazel
#

random access memory more like direct access memory

quartz kindle
#

put all your ssds as ram, and run the entire system in a ramdisk

#

sell a vps wth 10gb ram and 0 disk

boreal iron
#

lol

split hazel
#

inb4 contabo goes on a budget and starts using hdds

#

every few ssds lmao

quartz kindle
#

who says they didnt already?

#

:^)

split hazel
#

damn

#

that rw head be dancing up inside there

#

its amazing how reliable hdds are considering their architecture

boreal iron
#

Also depends on the architecture and cache

#

Good NAS HDDs can last 2 decades or more

#

At least my HDD do

split hazel
#

thats a long time

#

at this point im just waiting for my hdd to either fail or a smart alert to pop up

boreal iron
#

Yeah and still a RAID1

split hazel
#

usual commercial hdds apparently last around 2-6 years or longer

boreal iron
#

*but

split hazel
#

if you dont spend too much

boreal iron
#

For reasons

#

Yeah I only trust Seagates Ironwolfs

#

WD Red is a good Choice as well

#

Expensive but reliable and up to 10y of warranty depending on the package you buy

quartz kindle
#

hdds these days ship with 1 year warranty

#

absolutely terrible

#

i've had great results with WD Reds tho

#

terrible results with Seagate barracudas

zenith terrace
#

blah man

boreal iron
earnest phoenix
#

why I can not
make muen MessageOption

sudden geyser
#

did you mean .setLabel

errant flax
#

MessageMenu doesnt have a .setLabel?

valid frigate
#

Does anyone have an idea if per-guild avatars on the discord api are finalized, or still being worked on

#

There is a pr on the discord api docs repo highlighting this change but they noted that they want to wait until it's stable

pale vessel
#

It's still in A/B testing but it doesn't look like there's anything else for them to add

#

Everything is there (endpoint wise)

crystal furnace
#
if (await bot.users.fetch(bUser).then((user) => {user.send(embed).then(message.channel.send(":white_check_mark: Successfully to **send message** to user."))})) {
}
else if (await bot.users.fetch(bUser).then((user) => {user.send(embed).catch(error => { message.channel.send(`By **user setting** or **(some ERROR:) ${error} (s)**, the message can not be sent directly to the banned user, very sorry to say that :(`) })
})){
}
}```
#

why the bot run both cases?

split hazel
#

jesus save me

#

who taught you js

crystal furnace
split hazel
#

now you made me feel bad

#

but you have your entire code inside the if condition

crystal furnace
split hazel
#

it should be something like

const user = await bot.users.fetch(bUser).catch(() => null);

if (user) {
   user.send(embed).catch(error => {
      // send dm cannot be send
   });
}

if i understood

rocky hearth
#

I can only send a max of 5 buttons per row, right?

paper frigate
#

How do I interact with Discord's API on a website?

split hazel
split hazel
errant flax
#

like a dashboard or something?

split hazel
#

but anything to do with discord api is best done server side

paper frigate
errant flax
#

cant u just do that on discord

#

like message collectors or something misosface

#

instead of making a website where u can just request an api for a captcha then complete the captcha in bot's dms or something

paper frigate
#

yeah I already have that

#

but like

#

there are no faults with it

#

just like

#

yeah

lament rock
#

Look into oauth

errant flax
#

that could work as well ig?

lament rock
#

oauth is a blanket term

#

not so much getting data from Discord, but a flow to authenticate a session

oak merlin
#

uff may ik the commands for Your Manager BOT

errant flax
#

what bot?

oak merlin
#

Yourmanager bot

errant flax
#

also this is development channel

oak merlin
#

ok sry mb

paper frigate
#

I mean I could probably keep my current verification system

earnest phoenix
#

anyone know steam API well?

sage bobcat
#

One message removed from a suspended account.

lament rock
#

@quartz kindle I figured out my error. new URL(string).pathname does not include query string

earnest phoenix
#
def addUpvoteRecord(userid):
  with open("vote.json") as f:
      vote_list = json.load(f)

  if not userid in vote_list:
      vote_list[userid] = []

  with open("vote.json", "w+") as f:
      json.dump(vote_list, f)

@client.event
async def on_message(message) :

    if message.channel.id == 870147153706750022 :
        data = message.content.split(" ")
        user = re.sub("\D", "", data[5])
        addUpvoteRecord(user)
    
    await client.process_commands(message) ```

i am getting this error 

> TypeError: list indices must be integers or slices, not str

can anyone help me??
lyric mountain
#

Isn't userid a string?

earnest phoenix
earnest phoenix
#

does anyone know why my output in console is the playercount but in the embed it displays as [object Object]

lyric mountain
#

Although keep in mind ids are actually long/bigint

#

Idk if it makes difference in python

rocky hearth
#

can I edit and change <Message>.components = [] directly?

round cove
earnest phoenix
round cove
#

No. You want to add a new embed field for each part of the player object.

earnest phoenix
#

oh so instead of doing value: result.data i would put players?

crimson vapor
#

you literally forgot to add the []

tulip cradle
#
const ownerid2 = "744578635780063293"; //Drix
if ((message.author.id == ownerid1 && ownerid2)) {

this work with ownerid1 , why

#

anyone have solution ?

round cove
#

So this is saying

if message.author.id IS EQUAL TO ownerid1 AND if ownerid2 has value```
It does NOT say 

if message.author.id IS EQUAL TO ownerid1 OR IF EQUAL TO ownerid2```

wheat mesa
#

^^

round cove
#

What you have to do is have it compare the value of message.author.id to BOTH ownerid1 and ownerid2

#

That's not how that works.

wheat mesa
#

Is my brain dead

round cove
#

Yes

wheat mesa
#

Hold up

round cove
#
if ((message.author.id === ownerid1) || (message.author.id === ownerid2)) {
  // code
}```
wheat mesa
#

Shoot

#

My brain lmao

#

been awake for far too long at this point

#

However what my brain is certain about is that it's likely far easier to use an array and just use Array.includes()

tulip cradle
#

thank you guys

frozen mesa
wheat mesa
#

I think the best improvement in that version is that you can now do amazing stuff inside that if statement

round cove
#

not const okaybuddy

obsidian flint
#

with userid being the thing you want

earnest phoenix
#

I was just about to say using an array is better

#

lol

restive furnace
amber thistle
#

so im making a bot list and im working on webhooks, why do u need to provide a Webhook Authorization? for example, if a user votes on a bot, my frontend would send a POST request to the webhook given by the user who submitted by their bot, no Webhook Authorization needed

earnest phoenix
#

How the hell do decorators work in typescript.

#

I am trying to experiment with them and make one to use on a class when you are making slash commands, to provide metadata, such as the command name, description, and even options.

earnest phoenix
#

Already read it

#

Doesn't make much sense to me

#

I get what they do but not how to make it useful to me

#

For example typeorm uses decorators to declare a class an entity

#

And to declare columns

amber thistle
#

wdym by "right place"? aren't they the ones who provide the URL?

obsidian flint
errant flax
#

is this correct?

const app = require("express").Router()
const {Webhook} = require("@top-gg/sdk")
const wh = new Webhook(process.env.voteWhPass)

app.post("/vote",wh.listener((vote)=>{
  console.log(vote)
}))

app.get("/vote",(req,res)=>{
  res.send("a")
})

module.exports = app
#

ping me when reply

pale vessel
rocky hearth
#

I copied some emojies from discord and tried to check the length

cinder patio
#

some emojis use more than 1 character

rocky hearth
#

why is it so?, there is no white space in between them

#

Ooh

errant flax
#

idk whats wrong

#

im even using like a get request with the same path

#

and it works

cinder patio
#

what error?

errant flax
#

this is the error that i was talking about

#

wait the pass dog_kek

#

ill change it

cinder patio
#

And what's the URL to your webhook?

errant flax
#

do i send it here?

cinder patio
#

why not

errant flax
#

give me a sec

#

?

#

???

#

@cinder patio help?

cinder patio
#

Here you're just creating a router

#

what do you do with the router? @bleak jungle

errant flax
#

wrong mention

bleak jungle
#

why pong

errant flax
cinder patio
#

The route does nothing by itself

errant flax
#

? i dont understand what u mesn

cinder patio
#

Why don't you use the actual example from the lib's readme?

#

because clearly you don't know express

#

just use the example

#
const express = require('express')
const Topgg = require('@top-gg/sdk')

const app = express() // Your express app

const webhook = new Topgg.Webhook('topggauth123') // add your Top.gg webhook authorization (not bot token)

app.post('/dblwebhook', webhook.listener(vote => {
  // vote is your vote object
  console.log(vote.user) // 221221226561929217
})) // attach the middleware

app.listen(3000) // your port
errant flax
#
const express = require("express")
const app = express()
const {Webhook} = require("@top-gg/sdk")
const wh = new Webhook(process.env.whPass)

app.post("/vote",wh.listener((vote)=>{
  console.log(vote)
}))
app.get("/",(req,res)=>{
  res.send("yo")
})

app.listen(2000)

this is now what i use

#

updated my code

cinder patio
#

...and it still errors?

errant flax
#

u mean the code?
if so no

errant flax
cinder patio
#

Okay so do you still get the error?

errant flax
#

@cinder patio bonk

errant flax
#

??

small tangle
#

you are not having errors on your side? like in your console

errant flax
#

nope

#

made a post request form nodefetch seems to be fine

small tangle
#

you can try it with postman or insomnia

#

if it works there, it should be an issue on topgg side

signal estuary
#

Can someone tell me whats the different between the user and the member?

let user = msg.mentions.users.first()
let member = await msg.guild.members.fetch(user);
earnest phoenix
#

Well member will be the guild member

#

and user will be the user object

#

A user is basically them not associated with the guild

#

You'd only get basic info like their username, avatar, discrim, id, etc

#

My question is why are you fetching the user?

earnest phoenix
#

and then bam you already have their info

signal estuary
signal estuary
#

not my code

earnest phoenix
#

Oh

#

Well whoever did that idk what they were thinking

#

You can get the member by mention as well

#

and iirc it caches them

hollow depot
#

is there a way in discord.js to get the user who invited the bot in a server?

tired panther
#

nope you cant

hollow depot
#

k, thanks

eternal osprey
#

hey! I have a react to the moji to create a ticket system, however how would i remove the reactions (except the bot's one)?

pale vessel
#

You can remove the user's reaction (only) by using reaction.users.remove(user)

#

That'll keep the bot's reaction

eternal osprey
#

mhmm, alright.

#

And i assume that reaction needs to be changed to something else?

#

ah wait nvm

signal estuary
#

Why does the bot still throw an error when the part is into a try catch block?

            try {
                user.send("You were kick because: " + reason.toString())
            } catch { msg.channel.send("I could not send a message to this user") }

error: ```
DiscordAPIError: Cannot send messages to this user

quartz kindle
#

because you didnt await it

earnest phoenix
signal estuary
earnest phoenix
#

You can use members instead users

signal estuary
earnest phoenix
#

Yes

quartz kindle
#

because you didnt await it

signal estuary
quartz kindle
#

try catch can only catch promises if they are awaited

earnest phoenix
#

You can try send you were kicked msg before kick code

#

Then it send message to user and kick him , but if bot cant kick him it causes wrong warn

eternal osprey
#
  let collector = channel.createMessageCollector(m => m.author.id === member.id)
  collector.on("collect", m => {
    if(m.content.toUpperCase() === captcha.value) {
     m.delete()
      verifycode.delete()
      member.roles.add(vrole)
      channel.send(`:white_check_mark: Correct code. **Congratulations ${member}. You have been verified!**`)
    } else if(m.content.toUpperCase() !== captcha.value) {
      warns[member.id].warns++;
      fs.writeFile("./warnings.json", JSON.stringify(warns), (err) => {
        if (err) console.log(err)
      });
      member.send(`:x: Wrong code. You supplied the wrong code. Please try again ${member}.`)
      verifycode.delete()
      m.delete()
      
     
        
    } else {
      verifycode.delete()
    }
    ```how do i make sure that this code runs 2 times? (to give the users 2 shots to verify)
#

i can literally copy and paste this whole snippet in my vsc ofc, but is there any other better way to do it

grim sundial
eternal osprey
#

yeah i just figured. I am dumb sometimes lol

obsidian flint
earnest mural
#

i dont really understand why i am getting interaction error

small tangle
#

i mean whats the error

earnest mural
#

when i click either rock, paper or scissors it should give me an output

#

but instead its just interaction error

#

so i tried to make a simple interaction button and i got the same issue

obsidian flint
#

add an event

solemn latch
#

Are you responding to the interaction?

obsidian flint
#

idk the event name for py

earnest mural
#

i should be

solemn latch
#

Did you code something to respond to it? In an event like economy said.

Otherwise discords just sending the event to you and your not responding with anything so it fails.

obsidian flint
earnest mural
#

its rock paper scissors v_dead

solemn latch
#

No idea tbh. I would expect so, but wouldn't assume so

obsidian flint
#

what package are u using?

earnest mural
#

discord-components

obsidian flint
#

ok

solemn latch
obsidian flint
#

searching for an event name

earnest mural
#

and i used the example

obsidian flint
#

@earnest mural welp

#

uh

#

ok event name is button_click but I guess just search yt vids

earnest mural
#

i think just waiting for discord.py 2.0 to be released is a better idea

solemn latch
#

You have this part right?

interaction = await bot.wait_for("select_option", check = lambda i: i.component[0].value == "A") await interaction.respond(content = f"{interaction.component[0].label} selected!") ```
#

Shoot I copied wrong part

obsidian flint
solemn latch
#

That part just for buttons KEKW

obsidian flint
#

lol

earnest mural
#

lmao

obsidian flint
#
interaction = await bot.wait_for("button_click", check = lambda i: i.component.label.startswith("WOW"))

    await interaction.respond(content = "Button clicked!")
``` this part is prob the event
earnest mural
#

yeah

#

or it might be because replit is stupid

#

imma try with vsc

obsidian flint
earnest mural
#

but i doubt it

obsidian flint
solemn latch
#

๐Ÿ‘€ what's the issue with the underlines.
I dont know the meanings of py issues ๐Ÿ‘€

#

Looks like it might be a spacing issue from the copy paste.

obsidian flint
#

that's prob the warning

earnest mural
#

the thing got sqaushed

obsidian flint
#

not sure tho

obsidian flint
solemn latch
#

So why the green underline? Typically signifies a problem or something that needs addressing.

earnest mural
#

from this i think

obsidian flint
#

improvable

#

suggestions?

#

this is too much for my js brain ;-;

earnest mural
#

but its python

obsidian flint
earnest phoenix
#

ay guys

obsidian flint
earnest phoenix
#

is there a way to see if a user has upvoted the bot

#

?

#

i mean

#

u can use api

#

but idk how to use

solemn latch
#

Docs cover how to use it

earnest phoenix
#

it says this

solemn latch
earnest mural
#

oh

#

wait it is that

earnest phoenix
#

this is right?

halcyon nymph
#

Anyone know which modules are requred for spotify links that can play music???

marble juniper
#

I would like some advice

#

should I use sequelize or keyv

#

both are ORMs

subtle niche
#

hm

marble juniper
#

keyv is obviously the easiest to use

#

but still

#

lol

subtle niche
#

4 badges

#

cool

marble juniper
#

keyv seems to be used a lot at least

earnest mural
#

i dunno i looked through google and people saying sequelize is good

#

i dunno

#

usually its best to use the most used one

marble juniper
#

true

#

keyv is kinda like

#

map api but support for stuff like mongodb

#

and promise based

#

lol

earnest mural
#

lol

long crow
#

keyv unable to be installed on v16 for some ppl, though I can install it on my linux ubuntu iirc and got vulnerability last time I installed it

#

some injection stuff. forgot

pale vessel
#

Corona injection

cedar quarry
#
  if(message.Member.roles.highest.position <= Member.roles.highest.position)
#

help me pls

pale vessel
#

Member in undefined in your code

signal estuary
#
module.exports = {
    name: 'messageDelete',
    async execute(messageDelete) {
        try {
              let user = messageDelete.author
              let logEmbed = new Discord.MessageEmbed()
                  .setAuthor(`${user.tag}`, user.avatarURL({ dynamic: true }))
        }
    }
}
TypeError: Cannot read property 'tag' of null

Does anybody know why there comes this error when a message will be deleted and the event gets triggered?

marble juniper
obsidian folio
#

Hello

obsidian folio
#

Can I get help

marble juniper
#

and even then

#

my code is gonna be running in docker

#

just like the database

obsidian folio
#

I need help with a bot

marble juniper
#

so I can easily adjust the nodejs version if I want to

obsidian folio
#

That is noumenon bot how to invite it

slender thistle
signal estuary
#
client.on('messageDelete', async messageDelete=> {
        try {
              let user = messageDelete.author
              let logEmbed = new Discord.MessageEmbed()
                  .setAuthor(`${user.tag}`, user.avatarURL({ dynamic: true }))
        }
}
TypeError: Cannot read property 'tag' of null

Does anybody know why there comes this error when a message will be deleted and the event gets triggered?

signal estuary
#

sry I wrote it myself to discord lol

eternal elbow
#

How can I scroll the user to the top when switching to another page?(react-router-dom)

signal estuary
#

messageDelete.author is null

pale vessel
primal plinth
#

ah

crystal furnace
#

Is sharding on heroku count as a app

pale vessel
#

Perfect

near stratus
#

Why is the image not attaching ?

const emb = new Discord.MessageEmbed()
    .setTitle("Sowwy... ยฐ ^ ยฐ")
    .setDescription(`Put a looong text here`)
    .setColor('RANDOM')
    .setImage("https://i.imgur.com/SV4cFKe.jpg")
message.channel.send(emb);
#

Everything else is working but not the image.

errant flax
#

seems fine to me

near stratus
#

oh nvm It was cached I guess

signal estuary
near stratus
#

It's fixed now

errant flax
#

or message isnt cached

pale vessel
#

It could be a partial

#

Have you tried logging the message?\

#

\

errant flax
#

<Message>.fetch() - fetching a message if its partial
<Message>.author.fetch() - fetching the author if its not cached

#

try those methods iara_sunglasses_cool

pale vessel
#

null.fetch()

errant flax
#

then fetch the message first

#

wait check the message type actually

#

check if its a default message by:

if (<Message>.type!=="DEFAULT") return

dunno if the message types r different in stable cuz i use master bonk

#

so ur code should be

const m = await <Message>.fetch()
if (m.type!=="DEFAULT") return
const user = await m.author.fetch()
crystal furnace
#

how to edit this ?

#

worker

signal estuary
#

How do I get the author of a message which gots deleted?

client.on('messageDelete', message => {
    console.log(`A message by ${message.author.tag} was deleted`)
});

doesnt work

pale vessel
pale vessel
pale vessel
#

What's the output?

signal estuary
#

author is null

pale vessel
#

The whole message, not just the author

signal estuary
pale vessel
#

Yeah

signal estuary
pale vessel
#

Yeah so it's a partial

#

Only the ID exists

#

You can't do anything about it; Discord.js relies on cache and the deleted message isn't cached

#

Just do if (message.partial) return; to prevent errors I suppose

signal estuary
pale vessel
#

That only works if the deleted message was cached

#

Try sending a new message and delete it

#

It should log that one fine

signal estuary
nova basin
#

Someone can help

pale vessel
#

But if you send a message, restart your bot (where cache will be invalidated) and delete the message after your bot restarts it'll emit a partial instead

nova basin
#

I'am new on discord.js is I don't know how start I have a lot error zerotwocry

signal estuary
pale vessel
signal estuary
#

thx

pale vessel
#

You can add that on top of your code before accessing any properties in message

#

It'll simply ignore the deleted message

eternal osprey
#
root@STGSecurity:~/stgverifier# sudo npm install canvas
sudo: unable to resolve host STGSecurity: Name or service not known

> canvas@2.8.0 install /root/stgverifier/node_modules/canvas
> node-pre-gyp install --fallback-to-build

sh: 1: node-pre-gyp: Permission denied
npm WARN verifierbot@1.1.0 No repository field.
npm WARN verifierbot@1.1.0 No license field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.2 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 126
npm ERR! canvas@2.8.0 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 126
npm ERR!
npm ERR! Failed at the canvas@2.8.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2021-08-02T14_37_24_519Z-debug.log
``` what is happening again?
tulip ledge
#

Install node-pre-gyp

signal estuary
#

Event handler: ```js
for (const file of eventFiles) {
const event = require(./events/${file});
if (event.once) {
client.once(event.name, (...args) => event.execute(...args));
} else {

    client.on(event.name, (...args) => event.execute(...args));

}

}

event file:
```js
module.exports = {
    name: 'messageDelete',
    async execute(messageDelete) {
        try {
                    const fetchedLogs = await messageDelete.guild.fetchAuditLogs({
                        limit: 1,
                        type: 'MESSAGE_DELETE',
                    });
        } catch(e) { console.log(e) }

Error:

SyntaxError: await is only valid in async functions and the top level bodies of modules
pale vessel
#

Do you have the full stack trace?

crystal furnace
#

Do herouku run a sharding bot like a normal bot

#

Like counting as a only app

earnest phoenix
#

did v13 already go released official?

crystal furnace
earnest phoenix
#

but why did they update .guide to v13

pale vessel
#

Soonโ„ข๏ธ

earnest mural
#

so my bot was working fine then out of nowhere this bad boy shows up with a fat error

lyric mountain
#

free dynos and specs just aren't enough

pale vessel
#

It can be enough

lyric mountain
#

only if you're tim

near stratus
#

no actually I know someone running 4k guilds on heroku

lyric mountain
#

cacheless?

near stratus
#

and I don't know shit about python

lyric mountain
#

neither

tired panther
#

Is there a limit on extends when extending class?

lyric mountain
#

nope

summer torrent
#

limit for what?

lyric mountain
#

at least as far as I know

tired panther
# lyric mountain nope

weird, I tried on 2 and it works as soon I add the third Class , it doesnt let me show

lyric mountain
#

what kind of limits are we talking about?

tired panther
lyric mountain
#

that's cursed

tired panther
#

the Classes, which is in the ( )

lyric mountain
#

doesn't js have implements? because extending more than 1 class is so fckd up

latent heron
#

extending more than 1 class is fine tbh

lyric mountain
#

js is weird

latent heron
#

we extend and implement numerous classes and interfaces all the time in PHP

#

it's purposefully meant to be done like that to keep class instances modular

lyric mountain
#

I guess I got too used to java's inheritance then

#

like, 1 extension N implements

near stratus
#
class Pog extends (Number, String, Array, Map, Date, Math) {
}
latent heron
#

although we do it like this

near stratus
#

like ?

latent heron
#
class       giveAnimePng
extends     Request, Database
implements  Struct\giveAnimePng
{}
lyric mountain
#

thanks I hate php

latent heron
#

it looks fine to me

near stratus
#

This looks weird

latent heron
earnest phoenix
#

How would I go about creating a command that bulk deletes every message in a server that includes a specific word? All I have right now is an array with the words lmao.

lyric mountain
#

you don't

latent heron
#

we do it that way so that we don't get those long extend tuples

#

like you have there in JS

near stratus
earnest phoenix
#

fair enough

latent heron
#

alright memelord

#

haha $

tired panther
#

is there something wrong here?

lyric mountain
earnest phoenix
lyric mountain
#

unless you're fine with week-long bulk deletes

near stratus
latent heron
#

ok

near stratus
#

this.interaction is null

#

There's no chance that code will run

tired panther
earnest mural
#

i have no clue why im still getting this error

near stratus
#

if it was typescript it was understable

tired panther
tired panther
near stratus
#

what is this in this.reply ?

pale vessel
#

One odd thing about PHP is that the && and || operator actually gives you boolean, instead of last evaluated expression, unlike other programming languages. You'd have to resort to using ternary/elvis operator for a fallback value

#

Which is well, Idrm

tired panther
# near stratus what is this in this.reply ?

its the Response Class

class Responses {
    constructor(data) {
        this.interaction = data.interaction;
        this.message = data.message;
        this.client = data.client;
        this.args = data.args;
        this.settings = data.settings
    }
    async reply(content) {
        if(this.interaction){
            return this.interaction.reply(content)
        } 
        return this.message.reply(content)
    }
...

When I do not extend Collector , this.reply works fine. When I extend it, it doesnt work anymore

pale vessel
#

It's still a nice language

tired panther
lyric mountain
#

I always thought &&/|| passed a boolean to the next check

pale vessel
#

The if statement turns the value to a boolean

lyric mountain
#

no, like, if I do (1 > 0 && 99 < 100) == true it works

#

that in java

pale vessel
#

> and < turns a boolean naturally though

lyric mountain
#

wdym then?

pale vessel
#

"" || "a" will be true instead of "a" in PHP

lyric mountain
#

tbf, I never heard of a programming lang except JS that allows that

tired panther
#

Any ideas?

crimson vapor
#

but its such a nice feature

pale vessel
#

Yeah I agree

crimson vapor
#

perfect for defaulting shit

pale vessel
#

It is what it is

sudden geyser
#

It's more about being dynamic.

pale vessel
#

You can still do $value ?: "Fallback" as a "shortcut" to $value ? $value : "Fallback"

#

But the ?: operator evaluates it once

sudden geyser
#

python treating empty lists as falsely triggers me

crimson vapor
#

that would be nice for js

sudden geyser
#

trust me it's awful

wicked pivot
#

hello, I want to do a custom embed command example! embed random ${message.author.username} the problem is that it sends me the embed with '${message.author.username}' and not the name of the user how to do?

sudden geyser
#

If you could do that arbitrarily you'd be in trouble.

sudden geyser
#

You could replace it manually, or make a list of valid identifiers to represent values. For example, embed random $user and replace $user for message.author.username

wicked pivot
#

I know, but that's not what I want to do x)

sudden geyser
wicked pivot
#

as I explained it is that if in the command I specify ${message.author.username} that sends me the user that I do not have to add in the code .replace('$user', `${message.author.username}`)

near stratus
#

also why are you using `` in the first place
you can just use
.replace(`$user`, message.author.username)

wicked pivot
#

no no no, I explain again if I do! embed $ {message.author.user} that answers me Tony Kun I do not want! embed $ user and in the code a replace of $ user

near stratus
#

Lemme be clear

#

someone does

#

!embed ${message.author.username}

#

and you show the embed with

#
Tony Kun
wicked pivot
#

yes !

near stratus
#

and .replace isn't working ?

wicked pivot
#

since message.content = of the string I can't do what I want

near stratus
#
message.content.replace('${message.author.username}', message.author.username)
#

like this ?

wicked pivot
#

the problem is that the person is not necessarily going to do $ {message.author.username} that would make me do a lot of replacing it would be endless

near stratus
#

Oh now I get it

#

you want to eval it

#

(How can I do that without regex ?)

wicked pivot
#

oh it's a good idea if i evaluate the code it will necessarily send me the username?

near stratus
#

no

#

someone might do
!embed ${client.token}

#

and you're fucked

wicked pivot
#

yes yes don't worry about that thanks

wheat mesa
#

eval commands should likely be owner only

#

It just prevents a lot of the things users can do to exploit it

quaint wasp
#

ya they can use it for bad things

#

very... veryy bad things

wicked pivot
#

that's not what I'm going to do, I explained it like that to make it easier to explain

wheat mesa
#

Like !embed ${process.exit}

#

Etc

#

Something like that

#

Idk if that would work in an embed but it technically should

quaint wasp
#

or dm every user the bot has accese to

#

or ping everyone

#

ect

near stratus
wicked pivot
#
.setDescription(eval('${message.author.name} cc'))```

SyntaxError: Unexpected token '{'```

wheat mesa
#

You need to use ` to start your string in order to use interpolation

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

wicked pivot
#

message.content = 'string'

near stratus
crimson vapor
#

what the fuck are you trying to do?

near stratus
sage bobcat
#

One message removed from a suspended account.

sudden geyser
#

.setDescription(client.token)

near stratus
#

with an eval command

sage bobcat
#

One message removed from a suspended account.

near stratus
#

*mean

sage bobcat
#

One message removed from a suspended account.

crimson vapor
#

most people do

sage bobcat
#

One message removed from a suspended account.

crimson vapor
#

prevents accidental evals like @pale vessel does

near stratus
#

I don't have an eval command

#

It was way too much work

sage bobcat
#

One message removed from a suspended account.

crimson vapor
#

well doing eval client will show the token

near stratus