#development

1 messages · Page 1665 of 1

opal plank
#

but this is really outside of my scope

dusky lagoon
#
 if (args[0] === suggest.names.en) {
        return message.channel.send(embed);
    }

    message.channel.send(embed);``` Im trying to connect args with a string  so that it will do something like this
But ofcourse that doesnt work any ideas??
modern granite
#

Why do I get this every 5 minutes

#

Tho I don't have such a guild id in the json file

modern granite
vivid fulcrum
#

stop using json as your db

modern granite
#

Bruh

earnest phoenix
modern granite
#

That was not the question

modern granite
earnest phoenix
#

when someone sends a message on a guild which its id isn't in the json, it'll raise that error.

modern granite
#

Oh

#

Got it

opal plank
#

recommendation

#

stop it

#

using json will only bring you problems

umbral zealot
#

Agreed. You shouldn't use json as a database.

modern granite
#

I AM NOT

#

Please

#

Stop

#

Telling me that

umbral zealot
#

you literally are

opal plank
#

dude

#

theres 5 devs here telling you that its bad, stop being stubborn

modern granite
#

Ik

earnest phoenix
#

@umbral zealot when i try changing the prefix of my server, i get this error

The key "820395515698085950" does not exist in the enmap "settings"
``` do you need the code?
umbral zealot
#

literally using a JSON as a database.

modern granite
#

I don't say its good, ok?

#

IK

#

I said I am using

#

Just to make the prefix change command

umbral zealot
modern granite
#

Nothing else

#

I don't need a real database for now

umbral zealot
#

Yeah ok but when you lose your entire file and all your prefixes, that'll be your fault

modern granite
#

Ok

earnest phoenix
umbral zealot
opal plank
#

@vivid fulcrum managed to snoop something out of that mess?

earnest phoenix
#

bot.settings.set(message.guild.id, value.join(" "), prefix) i already have the set()

earnest phoenix
umbral zealot
#

Ok but you must have forgotten something

#

because the error is saying you aren't using ensure() before using that set()

earnest phoenix
#

im not

vivid fulcrum
earnest phoenix
#

i dont see the ensure() in the guide though?

opal plank
umbral zealot
#

wait actually hold on

#

you're using autoEnsure

earnest phoenix
#

yeah

umbral zealot
#

can you tell me what version of enmap you're using? npm ls enmap

dusky lagoon
#

How do i connect a args with a string ```js
if (args[0] === suggest.names.en) {
return message.channel.send(embed);
}

message.channel.send(embed);``` i want to make something like this
#

Can someone help

earnest phoenix
#

6.14.11

#

@umbral zealot

opal plank
umbral zealot
#

uhhh

boreal iron
#

god damn, embeding links for users should be removed

umbral zealot
earnest phoenix
#

oh

#

wait

#

LMAO

opal plank
#

actually

#

i think thats the same thing

earnest phoenix
#

this is not a command

boreal iron
earnest phoenix
#

oh wait nvm

umbral zealot
#

npm ls enmap in your project folder will tell you what version of enmap is currently intalled

earnest phoenix
#

i thought it was 1s not ls

umbral zealot
#

ls for list

earnest phoenix
#

yeah its 5.8.4

opal plank
#

lol the thing i sent is legit the same shit

umbral zealot
#

hmm

opal plank
#

without downgrading node, can i even force it to use the older version instead/

umbral zealot
#

Autoensure not working is... weird.

earnest phoenix
#

alright how do i manually ensure then

#

same as like with new members etc?

umbral zealot
#
bot.settings.ensure(message.guild.id, {
        prefix: "g.",
        welcomeChannel: "welcome",
        welcomeMessage: "Grelle Sutcliff greets {{user}}, welcome to the server!"
    })
#

basically

#

but autoEnsure not working is very strange.

earnest phoenix
#

oh

opal plank
#

ads

earnest phoenix
#

@umbral zealot now i get this warning WARNING: Saving "820395515698085950" autoEnsure value was provided for this enmap but a default value has also been provided. The defaultValue will be ignored, autoEnsure value is used instead. along with the same error as before

umbral zealot
#

ok I'm really confused now kekface

earnest phoenix
#

maybe i didnt put it in the right spot

umbral zealot
#

Are you sure you only have one enmap?

earnest phoenix
#

yes

umbral zealot
#

then that's real weird, it means autoEnsure is working but at the same time now

#

I'll have to take a look at this as a bug but unfortunately I'm at work right now and don't have time to look at such a complex problem

earnest phoenix
#

are you sure there cant be any other reason?

#

also i want to make sure, did i do this right? const [prefix, value] = args;

#

@umbral zealot

umbral zealot
#

that looks right, yes

earnest phoenix
#

okay what about this, are there any errors here? ``` if(command === "setprefix" && message.member.hasPermission("ADMINISTRATOR")) {

const [prefix, value] = args;

if(!bot.settings.has(message.guild.id, prefix)) {
    message.channel.send("You have no prefix for this server.");
    return;
}

bot.settings.set(message.guild.id, value.join(" "), prefix)
.catch(console.error);

message.channel.send(`The prefix for this server has been changed to \`${value.join(" ")}\``);
return;

}```
tulip ledge
#

should I do my database stuff on a different thread?

#

using this ^^

umbral zealot
#

I don't see how this can even possibly cause the error you had.

#

hmm.

#

hold on can you try to remove this completely ```js
if(!bot.settings.has(message.guild.id, prefix)) {
message.channel.send("You have no prefix for this server.");
return;
}

#

somehow I don't even think you should have that at all, tbh.

tulip ledge
#

Hey hindsight

#

u know if doing my db stuff on a different thread is good or no?

umbral zealot
#

you aren't providing nearly enough context for me to answer that question

tulip ledge
#

what else should I provide

earnest phoenix
umbral zealot
# tulip ledge what else should I provide

Uh... why do you think you need to do any "database stuff" on a different thread? Are you experiencing performance issues due to very complex or intensive database queries like complicated multiple joins, or extremely large data sets?

umbral zealot
tulip ledge
#

no, my friend told me it'd be good as I'd use less ram

umbral zealot
#

that's... wrong

earnest phoenix
umbral zealot
#

no I meant the full stack, but clearly value is undefined here

umbral zealot
earnest phoenix
#
    
    const [prefix, value] = args;

    bot.settings.set(message.guild.id, value.join(" "), prefix)
    .catch(console.error);

    message.channel.send(`The prefix for this server has been changed to \`${value.join(" ")}\``);
    return;
    }```
umbral zealot
#

well, this means you only provided one argument.

tulip ledge
#

so why is threading a good thing then?

lyric mountain
#

threading in js

umbral zealot
# tulip ledge so why is threading a good thing then?

Threading is only good if you actually need to use the power from multiple CPUs, because your single thread is taking the entire CPU and you need to take advantage of multiple cores. That's usually not necessary for small-ish projects, even medium sized ones.

#

if you were doing image processing for example, you might consider that. Or extremely large mathematical or data analysis.

#

But, like, an unsharded bot with a database? Nobody needs threading for that.

tulip ledge
#

alright tyvm

earnest phoenix
umbral zealot
#

well ok so why are you expecting value to be a thing then

#

prefix is "-" but value is undefined.

#

I think maybe you're a little confused.

earnest phoenix
#

the command itself doesnt count as an argument?

umbral zealot
#

it doesn't, no.

earnest phoenix
#

oh

umbral zealot
#

set(key, value, path) , path should be a string, btw. not prefix but 'prefix'

#

since you want to change the prefix path

#

So, set(message.guild.id, "%", "prefix") for example, would modify the prefix for that guild to "%"

onyx hare
#

im stressing over something that could be a easy fix but me being me is blinded to it my avatar line doesn't display the img just the URL how do i get it to show the IMG instead of the URL? ive tried removing URL from the call but it goesd "displayAvatar is not a function"

let av = member.user.displayAvatarURL({ format: "png"})
  let memberCount = member.guild.members.cache.filter(member => !member.user.bot).size;
  let rules = "800870206427627541" //Channel ID Here
  const welcomeEmbed = new Discord.MessageEmbed()

  welcomeEmbed.setColor('GREEN')
  welcomeEmbed.setAuthor(av)
earnest phoenix
umbral zealot
#

your "value" is prefix in this case, the variable

#

or, args[0], basically

#

think about const [ prefix ] = args; as doing const prefix = args[0]; or in this case, say, const prefix = "%";

#

So prefix, the variable, contains a string that is your prefix value.

#

you don't need any other variable for this to work, that one is sufficient.

earnest phoenix
#

ohh

#

but dont i want to change the value?

#

@umbral zealot

umbral zealot
#

you want to change the prefix, don't you?

earnest phoenix
#

yes

#

isnt the prefix the value inside the key?

umbral zealot
#

no

#

ok look

#
const settings = { 
  prefix: "$",
  welcomeMessage: "Hi, welcome",
}

This is an object

#

prefix: "$" is a key in that object

umbral zealot
#

the path to the "$" value is "prefix"

#

because settings.prefix , right?

earnest phoenix
#

yeah

umbral zealot
#

ok, so, your path is "prefix"

#

your value is the new prefix you want to set

#

and that new prefix is in the variable called prefix

#

let's change your code to be a bit clearer. ```js
if(command === "setprefix" && message.member.hasPermission("ADMINISTRATOR")) {

const newPrefix = args[0];

bot.settings.set(message.guild.id, newPrefix , "prefix");

message.channel.send(`The prefix for this server has been changed to \`${prefix}\``);
return;

}

#

does that make more sense now?

earnest phoenix
#
    
    const [prefix, value] = args;

    bot.settings.set(message.guild.id, prefix, "prefix");

    message.channel.send(`The prefix for this server has been changed to \`${prefix}\``);
    return;
    }``` this should work, no?
umbral zealot
#

yes, but value is still undefined here so it's not useful to have it at all

tulip ledge
#

no, you only need 1 argument, wich is the new prefix

onyx hare
dusky lagoon
# boreal iron be more specific what you wanna do

ok so i have this json list with animes that looks like this js { "id": 138, "names": { "en": "Beyond the Boundary", "jp": "境界の彼方", "ep": "12" }, "from": { "link": "https://anilist.co/anime/18153/Beyond-the-Boundary/", "type": "Anime", "time": "24 mins" }, "url": "https://s4.anilist.co/file/anilistcdn/media/anime/cover/large/bx18153-oDqA9zQzQPOq.png" } and i have 140 different of these and i want it to make that if i type $anime {anime name} that it sends the embed message with that anime but its all string related

tulip ledge
#

glad it worked 🙂

boreal iron
#

still think message.member.hasPermission("ADMINISTRATOR") is outdated
should be message.member.permissions.has("ADMINISTRATOR") now
@umbral zealot

lyric mountain
dusky lagoon
#

already did

tulip ledge
lyric mountain
#

object

tulip ledge
#

no but like

dusky lagoon
tulip ledge
#

object with objects

#

or array with objects

dusky lagoon
#

array with objects if im correct

lyric mountain
#

btw, why are you manually collecting anime data?

sand seal
#

Can anyone tell me the command for discord bot which tells the server name??

umbral zealot
# earnest phoenix

now we need to see your message event to see how you're getting that prefix.

lyric mountain
#

depends

#

what language?

earnest phoenix
#

or do both work

lyric mountain
#

bold of yall to assume he's using d.js

dusky lagoon
#

or can see

lyric mountain
#

wrong reply

#

but like

#

why?

#

you'll never be able to be on par with anime releases

#

let alone with 1% listed anime

tulip ledge
#

Guess you could do:

let name = args[0];
let index = animeList.filter(anime => {
  Object.values(anime.names).includes(name)
})

let anime = animeList[index];
// Build your embed
#

@dusky lagoon

lyric mountain
#

holy hell no

dusky lagoon
#

hu

lyric mountain
#

just use an object of objects instead of an array

tulip ledge
#

but wasn't he using an array

lyric mountain
#

probably

earnest phoenix
lyric mountain
#

but change it to object asap

umbral zealot
#

looks good. Can you maybe log guildConfig and make sure you get the right prefix? that could help debug the issue

lyric mountain
#

having to lookup an array for a specific anime everytime is unnecessary

earnest phoenix
umbral zealot
#

no it doesn't

#

that's an array

#

lol

lyric mountain
umbral zealot
#

I'm starting to see a bit of a pattern here, which is a very unfortunate one.

boreal iron
#

I bet you got then from your clipboard

umbral zealot
#

read what I linked, you'll see.

earnest phoenix
#

oh

#

yeah im kind of new

umbral zealot
#

Yes, that's exceedingly clear.

earnest phoenix
#

this is my way to learn coding though

#

yeah i know

umbral zealot
#

Your way to learn coding is to be a help vampire and get everyone else to code for you?

boreal iron
#

but you don't actually learn to code by asking others how it works, you need to know the basics almost to understand more complex structures

lyric mountain
dusky sundial
#

You won't learn a language by listening to others speaking it.. you need to actually read into what everything means

lyric mountain
#

it's like going uphill by the cliff side instead of the road

umbral zealot
#

Actually it's like learning to cook while trying to make a Beef Wellington and having never used a stove, a mixer, or a knife.

lyric mountain
#

ew, rare steak

boreal iron
#

or like learn to drive a vehicle without ever touching a vehicle... imagine all the dead dogs and cats being stuck in your vehicle grill

earnest phoenix
# umbral zealot Actually it's like learning to cook while trying to make a Beef Wellington and h...

yeah i admit, its probably one of the worst ways to get into coding but i still learn a lot and believe it or not but a majority of the coding i do i figure out myself, its just in instances like these where theres a complete new set of structures that i havent really worked with before i get help, take in the information, then in the future i minimize my mistakes and i can handle more on my own

umbral zealot
#

Now, in all those scenarios, it's possible to get through with proper training... Which, usually, requires you to pay the trainer

umbral zealot
#

we're here to guide you and help you, not handhold you every step of the way.

#

And right now, you need to be guided to an appropriate online course so you learn the basics.

lyric mountain
#

I feel I've heard that "I figure out myself" before

umbral zealot
#

yeah right now you're not figuring out anything yourself. you're literally asking us to figure everything out for you

#

you're not self-learning, you're not handling things yourself, you're relying on us every minute to do things for you. That's not learning. That's being a help vampire. don't be that.

earnest phoenix
#

I need two servers running on my repl, one is the Hardhat Network local blockchain, the other is the actual server for my app. The problem is, I only have one node instance so running server code for one server blocks the other one and vice versa. I'm trying to use child_process to fix this but it ain't working:

const express = require("express");
const app = express();
const path = require("path");
const ethers = require("ethers");
const { execSync } = require("child_process");

app.use(express.static(path.join(__dirname, "frontend")));

const listener = app.listen(process.env.PORT, () => {
    console.log(`Listening on port ${listener.address().port}`);
    console.log(`Starting hardhat network on port 8585`);
    execSync("npm start");
    console.log(`Deploying contract Box.sol`);
    execSync("npm run deploy");
});

Is there a way to run two node processes alongside each other so one doesn't block the other?

umbral zealot
#

You're trying to run a blockchain on repl.it?

#

lol

earnest phoenix
umbral zealot
#

Why not just use two repl instances

#

it's not like you're limited to one

#

¯_(ツ)_/¯

earnest phoenix
#

time to that exactly ¯_(ツ)_/¯

#

lmao changing execSync to exec fixed the problem

boreal iron
#

that's the fundation of try and see lmao

earnest phoenix
#

i thought the sync part was blocking the code

#

turned out it actually was

boreal iron
earnest phoenix
#

only problem i have now is that repl is confused between which server to take me to when i go to smartcontracttest.code913.repl.co

boreal iron
#

is there a way to see who mentioned your name and where on the browser version like on mobile?

earnest phoenix
#

or discord?

boreal iron
#

lol discord

earnest phoenix
#

goto your @ tab

#

it shows your recent mentions

boreal iron
#

got pingen somewhere in general and cant find it

#

WTF

#

there's no @ tab on the browser version

#

that's why I'm asking

earnest phoenix
#

how are you using browser on the mobile version

lusty quest
#

isnt there the drawer on the top Right in the browser version next to the search field?

boreal iron
#

that's my secret... but I'm actually talking about a PC browser

earnest phoenix
#

anyways if you wanna see your mentions goto the channel and search from:weeb#6969

earnest phoenix
boreal iron
#

yeah know about the search field but wanna know if there's a feature like on mobile actually shows all the mentions

#

probably not I guess

lusty quest
#

yes if you open the side tab there is a @ at the bottom,

earnest phoenix
boreal iron
#

there is NO side tab in the browser version

lusty quest
#

wait where are you rn

boreal iron
#

only the user list

earnest phoenix
#

how are you even using the browser version on mobile. for me the css is soooo bad i cant do anything besides see the server tab

lusty quest
#

browser on mobile?

boreal iron
#

is there a way to see who mentioned your name and where on the browser version like on mobile?

#

that means I am on the browser

earnest phoenix
#

send screenshot of your phone

lyric mountain
#

Literally

vivid fulcrum
#

oh also let me remind you about something semi related, discord promised they're working on allowing bots to use the message search endpoint two and a half years ago

boreal iron
#

DAMN a PC BROWSER

lyric mountain
#

Then click mentions

boreal iron
lusty quest
#

i guess the Browser version for Mobile is a bit fucked

lyric mountain
#

But I always use pc browser

boreal iron
#

I bet you're all trolling

earnest phoenix
#

cant do anything

lyric mountain
#

Dude

boreal iron
#

I am on a P C B R O W S E R

lyric mountain
#

Right to the side of the members icon

#

Click that fucking icon

earnest phoenix
boreal iron
#

The inbox icon?

earnest phoenix
#

yep

lyric mountain
#

Yes

lusty quest
#

yes

earnest phoenix
#

me first

lyric mountain
#

Then select mentions

earnest phoenix
#

cry what are you typing for so long

vivid fulcrum
#

desktop sucks ass because it's electron
browser sucks ass because it can't do half the things desktop can and font rendering is ugly
and mobile is just mobile, the devs are incompetent so the app is basically unusable

boreal iron
#

Oh there we go

lusty quest
#

well ive mentioned this a few messages ago

#

and he said its wrong

vivid fulcrum
#

so basically

#

everything sucks

boreal iron
#

lmao... why is that part hidden in inbox wtf

lyric mountain
#

It's not

boreal iron
#

hover over the icon, say INBOX

earnest phoenix
lyric mountain
#

They literally had a notification pop-up for about 1 month when they changed

vivid fulcrum
lyric mountain
#

Also, mentions do go in inbox

#

You get mentioned -> goes to your inbox

boreal iron
#

I wonder why there's no icon like on mobile

lyric mountain
#

Like a mailing system

lyric mountain
boreal iron
#

nvm ... ty actually know where it is right now

#

even if the road to get this knowledge was complicated

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

earnest phoenix
#

why is tjabo typing for so long

umbral zealot
#

Writing a super long-winded explanation trying to justify why they don't want to go actually learn shit

boreal iron
#

lmao

umbral zealot
#

And prefer relying on us fixing everything for them

scenic kelp
#

i think there you need the news @sage bobcat

earnest phoenix
#

i dont get why repl redirects to the wrong port even tho i used process.env.PORT which is supposed to be the default port

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
#

any way to fix

#

with h4cks

sage bobcat
#

One message removed from a suspended account.

scenic kelp
#

like new string[] {...}, new string[][] {...}

sage bobcat
#

One message removed from a suspended account.

scenic kelp
#

OH

#

for jagged arrays you need to initialiaze all the child arrays

sage bobcat
#

One message removed from a suspended account.

umbral zealot
sage bobcat
#

One message removed from a suspended account.

sage bobcat
lyric mountain
#

That was a weird way to put things

scenic kelp
#

{ new string[] {...}, new string[] {...}, ...}

sage bobcat
#

One message removed from a suspended account.

earnest phoenix
#

hm
listening on port 80 throws error

lyric mountain
#

Port 80 is http

boreal iron
#

bc the repl site is listening for that port already

earnest phoenix
#

and any other port works but repl doesnt redirect to that

#

it still goes to the hardhat server at 8585

boreal iron
#

on that port, for that port... what ever is correct

earnest phoenix
# umbral zealot Oh you mean when we stop permitting you to suck us dry, you actually think for y...

look at this any way you want but im just thankful you taught me how to do it and i always just sit for a moment to read all the new code ive written to figure out what everything means, i just needed this help so i'll be able to work with databases in this way in the future, so thank you :)
if you want an example, from this i can figure out how to create an economy system without too much trouble or with an exceeding amount of help

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

earnest phoenix
#

faith.smart = false;

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

earnest phoenix
sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

earnest phoenix
#

same

dry cosmos
#

helpme

earnest phoenix
#

no help me

dry cosmos
#

i want to download bot maker app

#

where that app or name

lyric mountain
#

Why

earnest phoenix
#

why

dry cosmos
#

i want to code bot

#

what u use to code bot

lyric mountain
#

Code

earnest phoenix
#

we use actual programming software

dry cosmos
#

i see some users send some codes

#

what software

earnest phoenix
earnest phoenix
lyric mountain
#

Ohno

earnest phoenix
#

like visual studio code or sublimetext or repl.it

dry cosmos
#

how to code with visual studio code

#

i have visual studio code

earnest phoenix
dry cosmos
#

but dont know to controll

#

can u tell me how 1st add bot with visual studio code

earnest phoenix
#

discordjs.guide is a pretty nice website for learning to write bots in djs

lyric mountain
#

If you're choosing to code with actual code congratulations for not choosing the lazy path

earnest phoenix
#

kudos to you

lyric mountain
#

But you'll need to learn how to program at first

#

There are a ton of tutorials

#

So first learn the language, then start bots

earnest phoenix
#

so umm

#

still cant figure out a way to get redirected to the correct port

#

@quartz kindle lord i need halp

quartz kindle
#

wut

earnest phoenix
#

trying to run two servers in node on replit and it keeps taking me to the wrong one

quartz kindle
#

explain

earnest phoenix
#

I have two servers running in node: one at port 8585 (which i dont want to get taken to) and the other at 8080 (which I do want to get taken to)
but when i go to myrepl.code913.repl.co it takes me to the first one which i dont want to go to
anyway to fix this

old cliff
#

Replit issues

quartz kindle
earnest phoenix
#

yep

#
const express = require("express");
const app = express();
const path = require("path");
const ethers = require("ethers");
const { exec, execSync } = require("child_process");
const server = require("https").createServer(app);
app.use(express.static(path.join(__dirname, "frontend")));

console.log(`Starting hardhat network on port 8585`);
exec("npm start");
console.log(`Deploying contract Box.sol`);
exec("npm run deploy");

const listener = server.listen(8080, () => console.log(`Listening on port ${listener.address().port}`));
quartz kindle
#

whichever comes first in the code

#

not sure if they support multiple ports

earnest phoenix
#

hmm

quartz kindle
#

try accessing myrepl.code913.repl.co:8080

earnest phoenix
#

even tho im using https

quartz kindle
#

but does it hit the right server?

earnest phoenix
quartz kindle
#

just click on continue anyway or whatever

#

when it shows the ssl warning

earnest phoenix
#

and also no output from console.log

#

why are you doing this to me repl

quartz kindle
#

try opening a new private window in your browser

#

and try accessing it directly, without https

heavy marsh
#

in d.js v12
Will ```js
let ownerID = await message.guild.members.fetch(message.guild.ownerID);

give you the owner id
earnest phoenix
sick fable
#

My bot is not coming online even after hosting it on heroku

sick fable
#

And made requirements.txt file too

quartz kindle
#

it wont give you the exact same thing you already have

#

it gives you the full member object for the owner

heavy marsh
quartz kindle
#

no

earnest phoenix
#

@quartz kindle wait curl does work

quartz kindle
#

guild.owner may be null
guild.ownerID is never null

heavy marsh
#

ooh ok thanks

earnest phoenix
sand seal
#

Hi can anyone tell me command which tells the server name??

earnest phoenix
#

and removing the port number shows an <a>permanent redirect to <site name with https></a>

lyric mountain
earnest phoenix
sand seal
lyric mountain
#

What language?

sand seal
lyric mountain
#

And library?

#

Discord.js?

sand seal
lyric mountain
quartz kindle
#

but the repl.it url can only point to one of them

earnest phoenix
#

sigh im making a new repl to interact with the old one

cinder iron
#

wait which python server what's the name of it?

earnest phoenix
#

somewhere a value is undefined or null in message.channel.send

earnest phoenix
#

spam console.log everywhere

#

¯_(ツ)_/¯

dusky lagoon
#
run: (message, name, client) => {

    if (!name){
      return message.channel.send(`\\❌ **${message.author.tag}**,Please specify the id!`);
    };

    let selected = market.find(x => x.name == name);

    if (!selected){
      return message.channel.send(`\\❌ **${message.author.tag}**, Could not find the item with that id!`);
    };

    return message.channel.send(`name: **${selected.type}**`)
  }``` Ok so this code sends a information that i want to find in a .json file lthat is connected to a string like `$help avatar` and send info about avatar But it only works with 1 word not when the name is 2 words how can i fix it i maybe thought with a args
odd stratus
#

Most cases you can use args.join(' ') for that

dusky lagoon
#

but in what way because you can use args for multiple reasons

cinder patio
#

whut

#

What is name? Your first arg?

dusky lagoon
#

Ok so name is a string lets say $help kill then in this case kill is name

#

and it works but only with names that consist of 1 word

cinder patio
#

you'll need pass the rest of the args to the function

#

are you using your own command handler or a framework?

dusky lagoon
#

yep

#

im using my own framework

#

as in .json file

cinder patio
#

well then pass all args to the run function, not only the first argument

#

and then do what Mihimur said

ornate otter
#

So whenever i try to install nodejs with NVM it just gets stuck on checksums matched

thin merlin
#

does anybody know how to set the embed color to the bot's top role color in discord.py?
i tried client.user.color but it didn't work...

grizzled raven
#

msssage.guild.me.displayColor

soft glade
#

Anyone know how to add a status to a bot in discord.py

earnest phoenix
#

._.

soft glade
#

Thx that will help

earnest phoenix
#

just a tip, 90% of questions have been asked before

thin merlin
earnest phoenix
#

Just stick it into google & I promise you you will most likely find an answer

boreal iron
earnest phoenix
#

It's why 90% of coding at this level is google and 10% is thinking

umbral zealot
#

It's the other way around tbh

thin merlin
scarlet rose
#

Hey guys I'm trying to set the vote api but every time i press test it doesn't send any request to my server

earnest phoenix
#

not in my experience but fair enough

ornate otter
#

So, Does anyone know why i cant use NVM to install nodejs it just gets stuck on checksums matched

earnest phoenix
#

im not excited to work with the vote api

#

in fact

#

im dreading it

#

ive been avoiding it for weeks

#

not because its difficult but bc i have to intergrate it with a bunch of database stuff

#

and im not in the mood

scarlet rose
#

NVM fixed lol typo error

ornate otter
#

?

opaque seal
#

Do you guys know if there is a way to make Discord keep multiple spaces in an embed text?

lyric mountain
#

Spaces or newlines?

soft glade
thin merlin
soft glade
#

thats what i was going to ask thanks

thin merlin
#

👌

#

no problem

earnest phoenix
#

does anyone know if ffmpeg would work on heroku for playing music in a discord vc

lyric mountain
#

Idk if you'd even be able to run it on such limited specs

old rivet
#

nodeJs > PHP

vague spindle
#

vuejs > react

quartz kindle
#

html css js > vuejs

#

:^)

boreal iron
old rivet
feral aspen
#

I can't seem to get rid of the Missing Permissions error that floods the entire console.

#

400 errors an hour.

boreal iron
#

well handle them and supress them

#

not needed to get informed about missing permissions

feral aspen
#

I did this.

#
    let commandfile = bot.commands.get(cmd) || bot.commands.get(bot.aliases.get(cmd));
    if(commandfile) try {
        await commandfile.run(bot, message, args);
    } catch (error) {
        console.log(error);
    };
boreal iron
#

that's absolutly no what I was talking about

#

handle the errors and sort out permission errors

#

console.log(error); prints all errors to the console

#

there's no handling

feral aspen
#

How do you want me to handle this, then?

#

I did this.

#

Every command has this line if(!message.guild.me.hasPermission(["SEND_MESSAGES", "EMBED_LINKS"])) return;

#

Every command has a try catch block when it wants to do an action such as adding roles or stuff.

#

Are the 400 errors, can it be from events?

boreal iron
#

it's an API response

#

the bot has no permissions to send a chat message for example, proves your permission doesn't work as it should

#

I am actually checking the permissions for the channel each message event

feral aspen
#

What can I do, instead.

boreal iron
#

not the whole guild, but I don't know if that even makes a difference

old cliff
boreal iron
#

I mean the bot could also miss "VIEW_CHANNEL" permission

#

oh there we go, you see

Permissions are for channels not guilds

old cliff
#

Its something similar

#

Check the docs

boreal iron
#

shouldn't it be message.channel.permissionsFor()

old cliff
#

Typo

boreal iron
#

there we go

#

that's how you have to check the permissions for the bot

feral aspen
#

So, to get rid of the missing permissions, I should do what exactly, in summary, just to start working

old cliff
#

Change your methods

boreal iron
#

get rid of checking guild permissions

#

the bot needs permissions in the ACTUAL channel

boreal iron
old cliff
#

Oof

boreal iron
#

shame is real

earnest phoenix
#

Can anyone guide me how to add slash command in my existing bot project

old cliff
#

They aren't officially supported in djs

#

You can still use external libs

#

Or manually send api requests

soft glade
#

anyone know how make a ping command if that makes sense

i'm wanting my bot to have a commands called "d/ping"
and i want it to respond with Pong! (The Bots Latency)

but everything i have tried hasn't been working
my bot is written in python

tranquil marsh
#

Could someone help me with javascript?

boreal iron
#

just ask

#

nobody will send u DM

tranquil marsh
#

yeah ummmm

#

How can i insert string variable into a "" bracket

old cliff
tranquil marsh
#

i did this but it doesnt work

old cliff
tranquil marsh
#

template what

cinder patio
#

template literals*

earnest phoenix
#

^

boreal iron
old cliff
#

`${code} text`

tranquil marsh
#

ohhh

earnest phoenix
boreal iron
#

But I recommend to follow Feuds message

old cliff
#

Nvm I have bad spellings

boreal iron
#

still

tranquil marsh
#

what is the difference between ' and "

boreal iron
#

none

modest maple
#

nothing to most languages

tranquil marsh
#

kay

modest maple
#

for Go lang it's the diffrence between a string and rune litterals

boreal iron
#

the syntax highlighting is different in most IDEs

earnest phoenix
#
bot.on("guildMemberAdd", member => {
    
    bot.settings.ensure(member.guild.id, defaultSettings);
    
    let welcomeMessage = bot.settings.get(member.guild.id, "welcomeMessage");
    
    welcomeMessage = welcomeMessage.replace("{{user}}", member.user.tag);
    
    welcomeMessage = welcomeMessage.replace("{{server}}", member.guild.name);

    member.guild.channels.cache
    .find(channel => channel.name === bot.settings.get(member.guild.id, "welcomeChannel"))
    .send(welcomeMessage)
    .catch(console.error);

})
``` can anyone see any errors? ive been trying for a good hour now and i cant figure it out, im not getting any errors logged either
old cliff
#

Do you have intents enabled?

earnest phoenix
#

yes

old cliff
#

Member intents?

cinder patio
earnest phoenix
#

yeah on the application page

old cliff
#

It should work...

#

Any Error?

earnest phoenix
#

no, nothing gets logged

boreal iron
#

log the actual event

old cliff
#

Yew try that...

boreal iron
#

bot.on("guildMemberAdd", member => { console.log(member)

#

looks like an intents issue

old cliff
#

It doesn't get triggered without intents

boreal iron
#

or called partials now... idk whatever

old cliff
#

^intents

#

Partials are for getting events for things not in cache

tranquil marsh
#

da hell is this (Quick.db)

earnest phoenix
#

oh shit turns out i thought i turned on intents on this bot not my other bot, its the other way around

#

so i enabled them

boreal iron
#

🤦‍♂️

earnest phoenix
#

now im getting an error but i want to do it myself :)

#

thanks for reminding me anyway

soft glade
#

anyone know how make a ping command if that makes sense

i'm wanting my bot to have a commands called "d/ping"
and i want it to respond with Pong! (The Bots Latency)

but everything i have tried hasn't been working
my bot is written in python

tranquil marsh
tranquil marsh
#

if(Command === bal) {
let bal = db.get("user_" + message.author.username + ".bal")
const embed = new Discord.MessageEmbed()
.setTitle('Your Balance')
.setDescription('${bal} coins')
.setColor("GRAY")
.setTimestamp
message.reply(embed)
}

boreal iron
#

and ping command never makes sense anyway due the nature of source and target

tranquil marsh
boreal iron
#

a ping from US to RU will take longer than EU to RU for example, which makes ping results useless

modest maple
old cliff
#

Define it

tranquil marsh
#

but i did.

modest maple
boreal iron
#

not sure, guess discord is using a cdn

modest maple
#

everything in the API is in the US

old cliff
#

Discors api server is in USA or eu?

modest maple
#

NY servers

#

only the voice and TURN servers are geolocated

boreal iron
#

might be, I dunno know didn't investigate yet bc who cares KEKW

modest maple
#

its why if you want the lowest latency for you bot between Discord you want to be as close to NY as possible

old cliff
#

NY?

modest maple
#

New York

old cliff
#

Ok

#

Say NYC

modest maple
#

Well that would be New York City

boreal iron
#

nope NY

modest maple
#

not the state of New York

old cliff
#

I don't like short forms angeryBOYE

modest maple
#

its not short forms

boreal iron
#

the codes have an ISO norm

old cliff
#

Bro I am not from us

tranquil marsh
#

what features SHOULD a discord bot have?

modest maple
#

One is a State the other is a City

boreal iron
#

not needed to discuss that anyways

tranquil marsh
#

oof cant think of anything....

boreal iron
#

any lmao

quartz kindle
#

let feature: any = new Feature()

boreal iron
#

ew what

#

that's TS?

quartz kindle
#

yes

boreal iron
#

eww shoo move on

quartz kindle
#

xD

boreal iron
old cliff
#

||A high level language compiled into another high level language||

quartz kindle
#

yes

boreal iron
#

as long as it doesn't look like so I'm not willing to use it $super_feature = new Feature();

#

that syntax is ... grr nice

quartz kindle
#

char * feature = new Feature()

boreal iron
#

oh god... that physical pain

#

I'm too old to learn new things, you know

old cliff
#

bit a = 0

#

?

boreal iron
#

Stop harassing me for being old!

old cliff
#

How old?

boreal iron
#

too old

old cliff
#

18?

quartz kindle
#

Lol

boreal iron
#

that's what u think old means

#

lmao

old cliff
#

69?

boreal iron
#

ahahhaah stop it

#

not gonna share private stuff in the 'net

quartz kindle
#

who cares

#

im 30

old cliff
#

I thought u were like 24

quartz kindle
#

i look young

boreal iron
#

if these 6 years would make any difference lol

#

keep in mind to prepare yourself for the midlife crisis, Tim

quartz kindle
#

i have drunk the elixir of life, i age slowly

boreal iron
#

lol

quartz kindle
#

im already there

#

lmao

boreal iron
#

oh dang, poor boy

#

Discord should really allow to specify a short message if you invite somebody, allowing [a-Z0-9] only

old cliff
#

We can send a message with an invite link tho

boreal iron
#

you don't actually know if somebody randomly invites you if there's at least a reason to now ignore him

#

I'm speaking about friend invitations

cinder patio
#

Not a terrible idea

tardy hornet
#

how can i do a command that will work in a specific guild? is it:

if(message.guild.id != "754604182995992609") return;
boreal iron
#

let's call it invite topic or reason, with a limited amount of chars and like I said [a-Z0-9] only

tardy hornet
#

?

feral aspen
#

I think there is a way to do this in the message.js, where if you mention the bot, it would return a message?

#

Anyone knows what it is?

quartz kindle
#

wut

lusty quest
#

check if the message mention is the one for your bot, then just return the message

floral island
#

Hi

feral aspen
feral aspen
tardy hornet
#
case 'setboost':
                          if(message.author.id != '723081690792067143'){
                            message.reply('only my creator can use it.');
                            return;
                          }
                          const role = message.mentions.roles.first()
                          const channel = message.mentions.channel.first()
                      
                          if(!role) return message.reply("please mention the boost role!")
                          if(!channel) return message.reply("please mention the boosts channel")
                      
                              if(role && channel){
                      
                                  db.set("boostrole_" + message.guild.id, role.id)
                                  db.set("boostchannel_" + message.guild.id,  channel.id)
                                  var boostUsing = db.fetch("boostUsing")
                                  if(boostUsing == null) boostUsing = []
                      
                                  boostUsing.push(message.guild.id)
                      
                                  db.set("boostUsing", boostUsing)
                                  message.channel.send("Successfully set the role to be " + role.name)
                      
                              }
                      
                          
                      
                          break;

TypeError: Cannot read property 'first' of undefined

quartz kindle
steady yarrow
lusty quest
#

Heroku doesnt allow a ton of stuff

quartz kindle
lusty quest
#

mostly stuff that handles sound, since it usually needs more resources

steady yarrow
#

im trying to install those extra packages through aptfile

#

as perscribed by heroku

lusty quest
#

Heroku just say nope

steady yarrow
#

yeah basically

lusty quest
#

its also a common issue with Music bots

steady yarrow
#

is there a workaround/other platform

lusty quest
#

buy a VPS

steady yarrow
#

oh

#

anything free?

quartz kindle
#

google compute engine f1-micro

lusty quest
#

rule of thump is, you get what you pay and if its free it usually sucks

quartz kindle
#

but you need a credit card to register

steady yarrow
#

thanks for the help

lusty quest
#

there are some really good and realtively cheap VPS hosts, you can get a decent VPS that will beat heroku for like 3$/Month

steady yarrow
#

alright ill look into it

boreal iron
vapid briar
#

who loves goanimate and vyond and legacy video maker (lvm clones) me yes

lusty quest
quartz kindle
#

i mean, learning how to operate a linux machine through ssh is not that hard, you learn as you go

vapid briar
#

who loves goanimate and vyond and legacy video maker (lvm clones) me yes

boreal iron
#

well that's a terrible idea to let somebody start on a machine which has access to the 'net

vapid briar
#

who loves goanimate and vyond and legacy video maker (lvm clones) me yes

boreal iron
#

just one more potential bot server

#

@sinful belfry chat spammer, see above

#

without any knowledge about administration, network (incl.) firewall it's just a risk for anybody else in the network

lusty quest
# boreal iron just one more potential bot server

like i said, not everyone got a way to do it from Home, so a VPS is a good way to start, sure you may fail and do some mistakes, but not everyone got the luxuary to start a VM with linux and hack around until it breaks

boreal iron
#

if I would recommend something to a beginner, than rent a managed server

lusty quest
#

the thing is most beginner cant afford a Managed Server

#

they can easy go for 40-60$/month

boreal iron
#

aye which doesn't change the fact of being a god damn huge security risk for any network or hoster

#

I know why it's been recommended to anyone in here but just to say it's a horrible suggestion tho

lusty quest
#

then give a solution lol, there are no cheap managed Servers that are around 3-7$/Month

#

i guess a safer way would be giving them a Docker Container with only one or two ports open to hack around

#

but they are a bit limited again

boreal iron
#

never said it's cheap but throwing more and more security risks into public networks can't be a justified reason just because of an expensive price

lusty quest
#

welcome to the market, people who write a new Discord bot wont rent a managed Server for 40$/Month to have a bot using 200MB Ram running on it

boreal iron
#

I'm administrating and managing servers for more than 14 y... you might have no clue how the amount of attacks, sniffs, bot server etc. has grown the last years

frosty valve
#

what is the problem with this code? ```js
require('dotenv').config()
const Discord = require("discord.js");
const client = new Discord.Client()
const fs = require("fs");

client.on("ready", () => {
console.log(Logged in as ${client.user.username});
client.user.setActivity("with my tail"); // Status
});
client.login(process.env.token).catch(console.log);```

lusty quest
boreal iron
#

I know just wanted to add that part to the general "bad practises" discussion

frosty valve
#

no error

feral aspen
#
if(/*Is there a code to determine if the error is missing permissions*/) return;
console.log(error)
#

^

lyric mountain
lusty quest
frosty valve
lyric mountain
#

like, even a chmod 777 / -R is an easy fix if you're just learning

lusty quest
lyric mountain
#

and a beginner wouldn't have an intricate system set up

lusty quest
#

like leaving ssh unsecured and ports open are common mistakes

feral aspen
boreal iron
lyric mountain
#

for a beginner? that's small stuff

#

as your bot grow you'll also grow

lusty quest
#

unless your vps gets pirated and ends up in a botnet

lyric mountain
#

noone would try to invade a smallish bot vps

lusty quest
#

you are innocent lol

lyric mountain
#

I'm not

boreal iron
boreal iron
lyric mountain
#

I'm just saying those are big world problems

#

not a "unknown nobody" thing

#

you rarely get targeted if you're anonymous

lusty quest
#

back when i worked as sysadmin for a small company we had some special offer for 1€ VPS servers, a ton of them ended up with chinese customers bcs cheap VPS server, and a lot of them where badly secured, causing a lot of them ending up in a botnet

#

like they had 1 Shared CPU and 250mb ram

dusky lagoon
#
const market = require('../json/market.json');

module.exports = {
  name: 'test3',

  run: (message, name, client) => {

    if (!name){
      return message.channel.send(`\\❌ **${message.author.tag}**,Please specify the id!`);
    };

    let selected = market.find(x => x.name == name);

    if (!selected){
      return message.channel.send(`\\❌ **${message.author.tag}**, Could not find the item with that id!`);
    };

    return message.channel.send(`name: **${selected.type}**`)
  }
};``` I made this small code for my .json file so it can search and send strings like `$help ban` and it will send the info about ban but i found out that it isnt able to read nams longer then 1 word so lets say `$help server info` doesnt work how could i fix this
boreal iron
#

wrong context

boreal iron
# lyric mountain I'm not

dude the 'net been searched the whole day long by other bots, scanning for potiental security risks, in websites, frameworks, ports etc.

lyric mountain
#

well, you eventually learn how to secure stuff

#

if you don't own a vps you'll never learn how to deal with one

cinder patio
lyric mountain
#

what I'm pointing is that putting someone down for beginning with a vps is bullshit

dusky lagoon
#

well im still strugling

boreal iron
lyric mountain
#

so, how?

boreal iron
#

network security is no learn by doing compromiss

#

never

#

NEVER

cinder patio
lyric mountain
#

ok, so?

boreal iron
#

you can learn from bigger attacks but we're not talking about that scale

lyric mountain
#

are you saying he should take 3 year network security university to be able to own a vps?

dusky lagoon
boreal iron
#

we're talking about somebody renting a VM and being a damn security issue for the whole network bc he has no clue to secure the server or to setup a proper firewall or how to deal with attacks or injections

lusty quest
#

i know a few good youtube videos about basic security, they help already a lot with securing servers

dusky lagoon
#

my brain isnt that strong ok

#

its OOGA BOOGA

cinder patio
lyric mountain
#

still

dusky lagoon
#

so you want me to show how it is connected or

lyric mountain
#

you shouldn't put someone down for beginning

#

if you care that much about security, teach 'em

#

or at least give an alternative

dusky lagoon
#
{
    "id": 2,
    "name": "Default Pattern",
    "description": "Default pattern for profile command.",
    "type": "pattern",
    "deletable": false,
    "giftable": false,
    "price": 0,
    "assets": {
      "link": "https://i.imgur.com/nx5qJUb.png"
    }
  }``` this is how it is connected
cinder patio
#

That's not what I mean at all

#

How do you call the run function

dusky lagoon
#

just run run: (message, name, args, client) => {

cinder patio
#

If you can't answer me that then you should reevaluate your codebase because it appears that you don't know much about it

dusky lagoon
#

BRUHHHH

boreal iron
lyric mountain
#

what doesn't belong to security?

earnest phoenix
#
    newMember.guild.channels.cache.get(channel => channel.name === bot.settings.get(newMember.guild.id, "leaveChannel")).send(leaveMessage);

i get an error saying send is undefined, i think its because it cant find the channel but i really cant figure out whats wrong?

heres an image showing that the leaveChannel is a channel id so it should work?

dusky lagoon
boreal iron
#

but it's okay to have an own opinion and to see things differently

lyric mountain
#

it's not different opinions

boreal iron
#

that doesn't belong to security questions

lyric mountain
#

sorry? were you born with alien-level security concepts pre-installed?

#

you had to start, right?

cinder patio
boreal iron
#

there's no "beginning" to learn how security works ON the production side
if so you will always make sure to be in a sandbox

lyric mountain
#

that's my point

#

give them a place to start then

boreal iron
#

A rented VM is live in the 'net, learning security at this point is already too late

lyric mountain
#

instead of saying "no you can't"

earnest phoenix
#

um

lyric mountain
#

point them to the docs, tutorials or whatever

boreal iron
#

well install Hyper-V role and play around at home

lyric mountain
#

now we're talking

boreal iron
#

of course you can also use other virtualisation platforms

#

Just to add one last thing about this conversation

modest maple
#

I mean if you're on windows Professional or above you should already have Hyper-V installed

#

although they really are desperately trying to get people to use WSL2 over Hyper-V

boreal iron
#

Renting a server (no matter it's a virtual one or not) and risking your providers network just bc of missing administration/security knowledge can lead to fines you don't even think of

tardy hornet
#

the bot crash because of that:

boreal iron
#

Written down in the ToS of each provider

earnest phoenix
#

wha

earnest phoenix
boreal iron
#

the best case always is they will lock your server and resign the contract, the wort case... well let's not talk about that

grizzled raven
boreal iron
#

@lyric mountain Recommending anyone to rent a live environment (in the 'net) without any knowledge probably also means to buy/rent something without understanding the responsibility and concequenses it can have

#

to come to an end

earnest phoenix
lyric mountain
#

or at least point to some resource they can use to learn

#

period

boreal iron
#

well I'm not recommending to do so in the first place, but wanted to say, it may be a good tip to inform somebody about the responsibilities and concequenses it can have

quartz kindle
#

you wont get fined for mismanaging a server lol, its not illegal to not know what you're doing

boreal iron
#

for people recommending this

quartz kindle
#

plus, to actually cause damage to the hosting company requires actually knowing what you're doing, you cant accidentally cause damage

lusty quest
#

well here are laws that require that you have to properly secure servers

boreal iron
#

here, too

lusty quest
#

if someone pirates your server you are responsible for it

quartz kindle
#

properly secured servers for a public service, yes

boreal iron
#

that may not be the same anywhere

quartz kindle
#

if you are offering a public service properly registered in a company

boreal iron
#

you're still responsible for what's written down in your contract

quartz kindle
#

yes, most times its just "dont do anything illegal"

boreal iron
#

which can contain fines as well

quartz kindle
#

like torrenting

feral aspen
#
(node:2084) Warning: Accessing non-existent property 'MongoError' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)

What does this mean?

boreal iron
#

but like I said a simple contract resign of your provider in the first place

lusty quest
#

when ive started my Linux Journey with a Managed Server, ive had a 2 1/2 hours talk with a Sys Admin, he gave me some really good pointers also mentioned the laws that exist

feral aspen
#

Nothing to worry about I guess?

lusty quest
#

wait for them to fix it

feral aspen
#

Ok.

boreal iron
quartz kindle
#

i had 0 experience with linux over ssh when i rented my first vps

#

learn as you go is the best way, dont scare newcomers into not renting a vps for the first time out of fear

lusty quest
#

yea same here, but ive had a friend who got a Hosting company, he helped me to get the basics

boreal iron
#

lol me too, but the times were different

boreal iron
lusty quest
#

but yea, if you start with Linux, one of the first things you should learn is securing the server

boreal iron
#

not just suggesting something without proper info

lusty quest
#

well not only linux but windows is kinda holding the hand a bit already

boreal iron
#

that's not really different to Windows servers

#

yeah

#

permanent scans for opened up RDP port and brute force attacks

quartz kindle
#

most OS images supplied by the host are already preconfigured with a bunch of stuff

boreal iron
#

that's right

quartz kindle
#

but yeah its a good idea to look into stuff like fail2ban

lusty quest
#

my last server had only the update repos routed over theyre local caching the rest where barebones

quartz kindle
#

but you wont get hacked in 5 minutes if you dont either

boreal iron
#

got VMs without an activated firewall, no matter ufw or itables, nothing was active or installed

#

just a system core

lusty quest
#

it wont happen instantly, if you are not at some shady hoster who got already all IPs listed somewhere in the darknet as easy to grab VPS

boreal iron
#

it wont happen instantly
it actually does

#

created my VMs on the root these days, being online for a few minutes and booms, the network log is growing

#

general sniffers for framework security risks, like WP etc., port listeners etc.

#

if anything was found it doesn't take long until automated attacks start

#

that's how it is today

#

just try it and open up a general service port, like RDP or MySQL and log the traffic

lusty quest
#

i actually know a guy who had one of the largest Botnets in Europe, idk why he stopped with it but i guess he got his reasons.

boreal iron
#

doesn't take long to scan all exisiting IPv4

tulip ledge
#

So I have an array of users, each user has a dead property nwo I need to get the next user in line that isn't dead, the current user is being saved as this.turn how would I do this?

lusty quest
#

language?

tulip ledge
#

js

quartz kindle
#

if you have an array, you need to store the current index of the user

#

not the user itself

tulip ledge
#

alright

#

but

#

how would I get the next player inline that isn't dead?

quartz kindle
#

you'll need to use a loop

#

or rather, use indexOf

#

nah you need a loop

tulip ledge
#
  setNextTurn() {
    // Get index of the current turn player
    let i = this.handler.players.findIndex((p) => p.user.id === this.turn);
    // Set the turn to the next player in the array
    this.turn = this.handler.players[i+1];
    // If the player does not exist, set it back to player one.
    if (!this.turn) this.turn = this.handler.players[0].user.id;
    // If the player does exist, set the turn viarable to the users's ID.
    else this.turn = this.turn.user.id;

    // Get the player who's turn it is
    let p = this.handler.players.find((p) => p.user.id === this.turn);
    // If the player is dead, go back to square one (Back to the top of this method)
    if (p.dead) this.setNextTurn();
  }

We did this

lusty quest
#

would it help to just loop over the array and return the first key with the property that is not dead

quartz kindle
#
currentIndex = 55;
for(let i = currentIndex; i < array.length; i++) {
  if(array[i].dead) {
    currentIndex = i;
    break;
  }
}
tulip ledge
#

It's working

#

but

#

is it efficient?

quartz kindle
#

if you are working with subsets of an array, findIndex is not efficient

#

because findIndex will process the full array, not only the relevant subset

#

with a for loop you can do the same thing but only in a subset of the array, starting from index X until index Y

tulip ledge
#

alright

#

but the array si max 4 indexes big

#

so it shouldn't be that bad right

quartz kindle
#

yeah its not bad

jovial shoal
#

IK this is kinda advertising but it’s not Bcs I don’t get a benefit from it but I’m making a coding group for anyone who likes to develop bots

vivid fulcrum
earnest phoenix
#
  leaveChannel: '820395516226830369',

i have leaveChannel set to this channel id, and i find the id with this:

    oldMember.guild.channels.cache.find(channel => channel.name === bot.settings.get(oldMember.guild.id, "leaveChannel")).send(leaveMessage);

but it doesnt work and i get an error saying send is undefined? however, when i find it by just replacing bot.settings.get(oldMember.guild.id, "leaveChannel") with '820395516226830369' which is practically the same thing, then it works just fine?

quartz kindle
#

because thats not how you get something

earnest phoenix
#

this is what it said in the docs?

quartz kindle
#

assuming bot.settings is a Map or a Collection

boreal iron
#

ahaha lmao, dig not installed on proxmox

quartz kindle
#

.set(key, value)
.get(key)

#

there is no .get(key, value)

vivid fulcrum
#

also that comparison

#

you're comparing names to ids

#

also

#

the docs explicitly say not to use find if you're looking up via the id

earnest phoenix
quartz kindle
#

then you're not using a Map nor a Collection

#

what are you using?

earnest phoenix
#

im using enmap

quartz kindle
#

then you should have said so lul

#

and see what it returns

earnest phoenix
lyric mountain
#

You need to return 2xx status

#

Else it'll retry up to 10 times

earnest phoenix
#

ok

earnest phoenix
#

sorry for late reply btw my friend messaged me

#

i really dont see whats wrong

vivid fulcrum
quartz kindle
#

youre checking if the channel name equals the id?

#

is the channel named like that?

boreal iron
earnest phoenix
#

oh.

#

oh.

#

i am actually a dumbass

#

well, i fixed it

boreal iron
#

You god damn old brick KEKW

earnest phoenix
#

channel.name > channel.id (2 hours of work)

snow urchin
vivid fulcrum
#

yikes

#

consider switching to flexboxes for alignment

boreal iron
#

Thought you would be even younger

snow urchin
#

ill consider flexboxes some other time, for now, help me with this fankz

boreal iron
#

Gonna call you grandpa in the future
Guess we’re increasing the age average a little

quartz kindle
#

xD

cinder patio
snow urchin
#

reasons

#

🤷‍♂️

vivid fulcrum
#

it takes less than a few minutes

#

display flex on parent container

#

three children containers that have flex set to their respective amount of space

#

put your stuff inside of those

#

boom, done

cinder patio
#

flexbox is op

vivid fulcrum
#

this tbh

opaque acorn
#

` const cmd = client.commands.get(command);

if (!cmd) return;

cmd.run(client, message, args);
}; `

#

Does anyone know how I can get this to work in glitch?

vivid fulcrum
#

that snippet isn't affected by a platform or anything of that sort

umbral zealot
#

Yeah glitch or not makes no difference to that code.

unreal estuary
opaque acorn
#

if I don't remove it, it doesn't work

umbral zealot
#

define "Doesn't work"

unreal estuary
#

do u get an error?

opaque acorn
#

does not detect the commands if not

#

nonono

unreal estuary
umbral zealot
#

If you remove this, it cannot possibly be running your commands.

#

Unless you have other code that runs your commands, of course.

opaque acorn
#

fck

umbral zealot
#

What do you mean "from outside the module.exports"? Can you show us more of the code?

opaque acorn
#

`module.exports = (client, message) => {
if (message.author.bot) return;

if (message.content.indexOf(client.config.Prefix) !== 0) return;

const args = message.content
.slice(client.config.Prefix.length)
.trim()
.split(/ + /g);
const command = args.shift().toLowerCase();

const cmd = client.commands.get(command);

if (!cmd) return;

cmd.run(client, message, args);
};`

dusky lagoon
#
    message.channel.send(embed)

      const query = message.content.split(/ +/).slice(1).join(' ');
      let suggested = suggestion.find(x => x.names.en === query); 

      if (!suggested){
        return message.channel.send(`Not able to find this name`);
      };
  
      return message.channel.send(`${suggested.url}`)

``` there are two commands in one name so `$anime` that sends a random anime  and `$anime {name} to get info about the anime` only they send at the same time how do i fix it that when i say `$anime` it only sends a random anime and same for `$anime {name} to get info about the anime`
umbral zealot
#

I mean that looks like a shittier version of the AIG command handler but I'd still like to see.

soft glade
#

does anyone know how to make a meme gen in python
like how you can do with dank memer

cinder patio
#

but there are others as well

soft glade
#

ok

opaque acorn
#

you mean the command?

umbral zealot
#

i mean where you load them