#development

1 messages · Page 744 of 1

green kestrel
#

where possible, gut inspircd code to do it 😛

#

@modest maple to add to what you said earlier, ive once used a combination of json and mysql together. mysql 5.7+ and mariadb 10 support it. basically, you have standard mysql tables and you can put user defined data into a json data type in a column, it natively supports searching json with a search path

#

i used that in a commercial program to allow for the subscriber to add their own table 'columns', as far as they were concerned they were adding custom tables to the db, but obviously we didnt actually let them add tables or columns. if done right, you can even add indexes on json subparts

#

its basically a more correct and scalable way to do the antipattern of "entity-attribute-value"

severe gyro
#

@green kestrel Huh, can i help you with that project you have for today?

#

I suppose you're going to write it in C or C++?

green kestrel
#

already writing it in C++, yes

#

i have a whole raft of existing module loader code im going to reuse

severe gyro
#

Oh, awesome, can i join?

green kestrel
#

got some suggestions?

#

hmm, perhaps at a later date. once i have a module loading facility, it may be nice to bring on other team members

#

right now, the only place to put code is in the core, and thats icky

#

after xmas would be a good time 🙂

severe gyro
#

I know C and Assembly + some knowledge of ELF and PE

#

So, it's up to you to decide if i can join

green kestrel
#

do you know what my bot does?

severe gyro
#

No

green kestrel
#

find sporks on top.gg, take a look and see if its interesting to you 🙂

severe gyro
#

But i just love low-level stuff way too much

green kestrel
#

im currently modularising the javascript interpreter and the infobot routines

#

it integrates duktape so that it can be extended by channel owners

severe gyro
#

You're getting me to orgasm with these words, Duktape is my fav JS engine

green kestrel
#

i think i just found a dev friend 😄 😄

#

i'd definitely welcome the help, but i do need to get the code in a nicer state first

#

you can see how it is atm on github

severe gyro
#

Oh, okay

green kestrel
#

wont be long, i code fast 😄

severe gyro
#

Thanks, i'll be waiting

green kestrel
#

sent you an invite to my server, and a friend request

severe gyro
#

Ok, i've already accepted it

#

But i didn't get the invite tho

green kestrel
#

ok np

surreal sage
#

how to do custom prefix with a sql db

restive furnace
#

bruh

#

theres tons of tutorials on google

novel yarrow
#
channel.getGuild().ban(mentioned.get(0).getUser(), Integer.parseInt(""), "").queue();```
This should work?
grizzled jackal
#

Try it and find out

twilit rapids
winged remnant
#

Bonjour/bonsoir,

j'aurai besoin de vous pour une erreur que je ne comprends pas.

J'ai restart mon vps (mon bot était déjà dessus) et depuis cela, j'ai cette erreur:

#

Si vous avez une solution, je suis preneur.

flat pelican
#

in english, but "no such file or directory" means "il n'y a pas de tel fichier", tu essaies de chercher un fichier qui n'existe pas

winged remnant
#

J'avais bien compris

#

Mais pourtant, juste avant le restart du vps, tout fonctionnais

flat pelican
#

hm

winged remnant
#

Tout est good pourtant 😦

restive furnace
#

what u trying to do?

winged remnant
#

I'm trying to load my orders into each folder

modest maple
#

you dont apear to be giving it the right file path

#

for it to look for

#

i believe there is a command similar to python like os.listdir which returns a list of directories within the file path specifier

#

specified*

#

that might help if someone can tell them what the Js version of the command is

restive furnace
#

fs is like os.dirthings

winged remnant
#

Ok

#

So, what should I put? Because before the restart of the vps, everything worked very well ...

surreal sage
#

how to get your bot a certified bot?

fallen arch
#

how can i make the login button turn in to the users discord avatar or username
like after the auth
i receive the access_token

modest maple
#

what @fallen arch

fallen arch
#

am i allowed to put a small picture?

#

like send one?

modest maple
#

also @surreal sage you have to send a physical letter with the requirments

fallen arch
surreal sage
#

To what?

fallen arch
#

how can i turn this into the users avatar or username

modest maple
#

what are you trying todo with it is what im asking xD

fallen arch
#

im making a dashboard

modest maple
#
The ideal applicant

Here are some things we're looking for in bots that want to apply. Following this one or more things on this list gives you the best shot at being accepted in to the program.

    Bots that have a primary function which is executed and performs well
    Beautiful clear documentation for users of your bot
    Useful and fun bots
    Unique and Original Ideas
    Clear aspects of your bot that seperate it from the crowd
    Developers who can read all of this and understand the requirements for applying don't guarantee entry to the program
#

@surreal sage

surreal sage
#

ok

modest maple
#

Certain bots just aren't fit for our certification program and small edits/additions likely won't change this. Below is a list of things we're not looking for in our certification program at the moment

    Multipurpose Bots
        We prefer bots that are built for one or two features that are well made instead of hundred of useless/poorly designed features.
    8ball / coinflip / RNG based commands
        If one of your bots main/only commands is magic 8ball/coinflip or some other random number generated command don't bother applying
    Non-English Speaking Bots
        Your bot must support the English language. British English for extra points ;)
surreal sage
#

whats the type of a docs site?

#

wiki etc..

winged remnant
#

🤔

modest maple
#

what @surreal sage ?

surreal sage
#

whats the type of a documents site (wiki, etc..)

modest maple
surreal sage
#

no not that

#

you know site types: like: e-commerce, is "docs" a wiki type?

modest maple
surreal sage
#

no..

#

listen

modest maple
#

everything about discord's aoth system is in there @fallen arch

surreal sage
#

you know site types right?

fallen arch
#

okay

surreal sage
#

like webshop etc

#

i want to know: whats the type of site for docs for a "bot"

#

wiki?

#

or something?

modest maple
#

i have no idea what youre going on about

surreal sage
#

nvm

modest maple
#

do you mean like .readthedocs?

surreal sage
#

YES

modest maple
#

.readthedocs.io thats basically the first go to for any sort of documentation

surreal sage
#

thx

surreal sage
#
    if (command === "setavatar") {

        if(message.author.id !== botConfigs.ownerID) return;

        const args = message.content.split(' ').splice(1).join(' ');

        if(args === null) {

            const e = new Discord.RichEmbed()

            .setTitle(`:x:`)

            .setDescription('Oops! You', `'ve not entered a image url!`)

            .setColor('#ff0000')

            message.channel.send(e)

            }

        } else {

            if(args.startsWith('https://')) {

                client.user.setAvatar(args)

                const e = new Discord.RichEmbed()

                .setTitle(`You've set my new Avatar`)

                .setImage(args)

                .setColor('#ff1493')

                message.channel.send(e)

                }  

            } else if(args.startsWith('http://')) {

                client.user.setAvatar(args)

                const e = new Discord.RichEmbed()

                .setTitle(`You've set my new Avatar`)

                .setImage(args)

                .setColor('#ff1493')

                message.channel.send(e)

                }

            }

        }

}``` Theres a error and idk how to fix http://prntscr.com/q9a7u7 i know its something with: `)` `}` `;`
Lightshot

Captured with Lightshot

modest maple
#

read the error

surreal sage
#

i do

modest maple
#

X number 2 tells u what it wants

amber fractal
#

Be careful with that

#

Avatars are highly rate limited

surreal sage
#

manual

#

like if christmas

#

im not gonna go to discords dev page

#

to change

amber fractal
#

Yeah it uses the same backend.

modest maple
#

.setDescription('Oops! You', 've not entered a image url!)

surreal sage
#

i thought lol

modest maple
#

wtf is up with that command

#

im not saying thats the error or not

#

but it just doesnt look right

surreal sage
#

i fixed it

#
    if (command === "setavatar") {

        if(message.author.id !== botConfigs.ownerID) return;

        const args = message.content.split(' ').splice(1).join(' ');

        if(args === null) {

            const e = new Discord.RichEmbed()

            .setTitle(`:x:`)

            .setDescription(`Oops! You've not entered a image url!`)

            .setColor('#ff0000')

            message.channel.send(e)

            }

        } else {

            if(args.startsWith('https://')) {

                client.user.setAvatar(args)

                const e = new Discord.RichEmbed()

                .setTitle(`You've set my new Avatar`)

                .setImage(args)

                .setColor('#ff1493')

                message.channel.send(e)

                 

            } else {

            if(args.startsWith('http://')) {

                client.user.setAvatar(args)

                const e = new Discord.RichEmbed()

                .setTitle(`You've set my new Avatar`)

                .setImage(args)

                .setColor('#ff1493')

                message.channel.send(e)

            }

            }

        }

}``` fixed
#

it whas the else thing cuz it did not end properly

sudden geyser
#

I don't think that'll work, but okay

fathom pewter
#

Is there someome here who create a bot with python?

modest maple
#

ive made serveral bots with python yus

surreal sage
#
            .setTitle(hexes. + args)``` hexes a is a const of a json file, args are supposed to be: (example: red)
#

it says i got a error

#

Identifier expected.

modest maple
#

usual needs somthing like name=

surreal sage
#

wait

#

i can do const colorarg = hexes + .args right?

#

@modest maple

#
            const colorarg = hexes + . + args;```
modest maple
#

you need it to be a string probably

#

somthing like "." idk

surreal sage
#

yeah dots are annoying

#

no erros but hope it works

#

gonna try

#

startup ☑️

#

@modest maple

#

oof

#

make that a string?

#

the "hexes"

#

think so

modest maple
#

well hex codes are ints in python

#

idk xD

surreal sage
#

no string there lol

#

gonna try the dot without string

modest maple
#

are you trying to change the colour of the embed or send the colour name>?

surreal sage
#

yeah..

#

well the value of the color in the json is the hex

#

so it works

#

prob

#

does not start cuz of the dot

#

oof

#

dream

#

u know how to let the dot work but not make it a string

#

?

modest maple
#

i dont exactly get why you are adding + . + args

surreal sage
#

well

#

its a color command

modest maple
#

when normally embeds just take the hex code direct?

surreal sage
#

like: axhex <color>

#

like blue

#

it gets "blue" out of the json and the value of it is the hex of the color

#

but args is the same as name

#

the problem is

#

the dot

#

else it wont get it

#

i tried dot and hexes in strings but it showed: hexes.<colorname>

#

should i add a: js const hexes = require("./json/color-hexes.json")?

#

extra?

#

dream?

#

u know how to fix this?

#

@sullen yacht

#

help

sullen yacht
#

what

surreal sage
#

i have a problem with this dot

sullen yacht
#

idk i dont do js

surreal sage
#

rip

modest maple
#

both of us are Python xD

surreal sage
#

rip

late hill
#

what

surreal sage
late hill
#

What are you trying to do

surreal sage
#

exes: hexes is json file

#

umm

#

a color command that sends the hex color of a color

late hill
#

oh

surreal sage
#
    if (command === "hex" || command === "color") {

        const args = message.content.split(' ').splice(1).join(' ');

        if(args === null) {

            message.reply(`Oops! You've did not specify a color name.`)

        } else {

            const colorarg = hexes + . + args;

            const e = new Discord.RichEmbed()

            .setTitle(colorarg)

            .setColor(colorarg)

            message.channel.send(e)

        }

    }```
late hill
#

yes

surreal sage
#

but the error is the dot at color arg

late hill
#

object[property] works

#

where property is a string value

surreal sage
#

that happens if the dot is a string

late hill
#
let something = {
    test: true
}
console.log(something["test"]) // logs "true"```
surreal sage
#

i know

#

but in order to get that color hex from the json it requires: hexes

#

thats a const of my json

late hill
#

That's what you need, no?

surreal sage
#

no

#

is an error

late hill
#

Switch something with hexes in my example

surreal sage
#

how to fix

grim aspen
#

what is the error?

surreal sage
#

... thats not what i mean

late hill
#

and you'll be able to use hexes[argument]

#

It is what you mean

surreal sage
late hill
#

Yes, you want colorarg to be one of the hex values

surreal sage
#

nonono

late hill
#

?

surreal sage
#

thats not what mean

late hill
#

From what I'm getting, you want it to be a color that the user chooses

#

As in the user will enter the color in regular text format

surreal sage
late hill
#

Yes

surreal sage
late hill
#

Yes

surreal sage
#

and hexes is a const of the json

late hill
#

You want to use hexes.whateverTheUserEntered

sudden geyser
#

CD, search up bracket notation

surreal sage
#

yes

late hill
#

but that doesn't work

#

So instead

#

use hexes[whateverTheUserEntered]

#

Which will work

surreal sage
#

gonna try

#

no error

#

gonna try on my bo

#

bot

#

works

#

thx

late hill
#

Be aware that it'll be undefined if they enter something that's not in there

earnest phoenix
#

client.commands.find(cmd => cmd.help.aliases) returns
The regular cmd instance

fathom pewter
#

@modest maple can you teach me how to make a command code? Since i give up making it never worked

#

Btw sorry pinging you

modest maple
#

dw

#

and you basically just check if a message has the prefix and command or atleast what i do

#

in the on_message() function

#

should help u this

fathom pewter
#

Okay thanks

fathom pewter
restive furnace
#

ofc

west spoke
#

Yeah...

#

(Ew)

grizzled raven
#

what

slim heart
#

does anyone know why this happens. it's only when im put onto a smaller screen, gaps just come out of nowhere between the icons.
page;

<div class="box">
    <% guilds.forEach(x=> {%>
    <div class="guild" value="<%=x.i%>">
        <div class="tooltip circleDiv" href="<%= base %>/<%=x.i%>">
            <% if(x.a) { %>
                <img class="guildPicture" src="https://cdn.discordapp.com/icons/<%= x.i%>/<%= x.a %>" alt="<%=x.n%>">
            <% } else { %>
                <p class="guildText"><%= x.n.match(/\b(\w)/g).join("").toUpperCase() %></p>
            <% } %>
            <span class="tooltiptext"><%= x.n %></span>
        </div>
    </div>
    <% }) %>
</div>```
(relevant) css
```css
.guild {
            float: left;
            background-color: #23272A;
            border-radius: 50%;
            width: 100px;
            cursor: pointer;
            text-align: center;
            margin-right: 10px;
        }
.box {
            padding: 0px 15% 5% 15%;
        }

Desktop screens are completely normal

valid frigate
#

i dont know man but that .box css rule seems to be the problem

#

do you have any mobile specific css rules

slim heart
#

absolutely none

valid frigate
#

ok then i'd probably guess that it's your .box css rule

#

on desktop it would look fine since it's a larger screen

slim heart
valid frigate
#

do you not want the gaps there?

slim heart
valid frigate
#

oh i see

#

have you ever heard of flexbox

slim heart
valid frigate
#

thats probably because you're using float

#

honestly dont quote me these are just guesses

#

based on my own experience with something similar

slim heart
valid frigate
#

hold on

#

el flexbox

slim heart
#

i use grid rn on the other pages

valid frigate
#

you should use the same concept on ur server list then

slim heart
#

but this seems like something that is completely unnecessary to use a tool like this

valid frigate
#

it's not a tool it's part of css

#

mdn only documents what css provides by itself

slim heart
#

no i know but my point is i shouldnt need to use something like flex or grid for a simple side to side thing

rugged minnow
#

hi, quick question (discord.js)

#

if i want to delete the author's message every time a command gets used, how would i do it?

#

i tried using message.author.delete() but it doesn't work

grizzled raven
#

message.delete()

vital lark
#

Author doesn't have the delete function

rugged minnow
#

message.delete() doesn't delete the cmd's message

modest maple
#

it does

#

you're deleting the object message

surreal sage
#

if you try it here it does not have the perms

rugged minnow
#

well, then there's something wrong with my bot

#

hold on

modest maple
#

what is your code

rugged minnow
#
  execute(message, args) {
    messageid = message.author.id;
    message.channel.send(messageid)
    message.delete()
    var server = message.guild;
    const debugEmbed = new Discord.RichEmbed()
      .setThumbnail("https://i.imgur.com/t1P6d5P.gif")
      .setColor("0xfeb637")
      .setTitle("Invite Party to your server!")
      .addField("You can invite me here:" , "[link here]")
      .setFooter("Party!", "https://i.imgur.com/B6QKBgC.png")
      .setTimestamp();
    message.author.send(debugEmbed);```
surreal sage
#

can i find out what my hosting systems are with a thing?

#

where is the if msg content lol

grizzled raven
#

a thing?

surreal sage
#

like it replys with like platform (win10)

rugged minnow
#

wait nvm i'm just stupid

mossy vine
#

process.os

surreal sage
#

thx

grizzled raven
#

really

#

?

#

bruh ive been mislead like 60 million times

#

and im sad

#

wait

#

nvm lol

rugged minnow
#

i accidentally deleted the channel a few minutes ago and the permissions got synchronized with the category

mossy vine
#

@surreal sage nvm

surreal sage
#

ok

surreal sage
#

ok

#

axeval message.reply(process.uptime)

#

axeval message.reply(process.uptime())

mossy vine
#

wrong channel

surreal sage
#

lol

mossy vine
#

lol haha xd 😂

earnest phoenix
#

+emojiler

surreal sage
#

does this work? ${message.client.user.username}

grizzled raven
#

if client is a property of message, yes

#

but i assume you didnt set message.client to client

#

so no

knotty steeple
#

why would you need to set it then

#

just use the client

mossy vine
knotty steeple
#

try it and SEEE

earnest phoenix
#

all that's missing is bill wurtz's voice :c

solar mauve
#

How I can add a second reaction to this?
event.getChannel().sendMessage(embed.build()).queue(message -> message.addReaction(args[3]).queue()); (JDA)

earnest phoenix
#

save the message in a variable

solar mauve
#

@earnest phoenix don't know how? Can you show me?

earnest phoenix
#

i don't know how JDA names entities

#

but that's java basics

#

saving a value into a variable

solar mauve
#

Yeah I know but in what kind of variable

earnest phoenix
#

nevermind you don't even have to do that

#

just do it in the queue callback

#

just expand your lambda expression to multiline

solar mauve
#

Have I but I wan't to add a second but this dosen't work

#

event.getChannel().sendMessage(embed.build()).queue(message -> message.addReaction(args[3]).queue());

earnest phoenix
#

just expand your lambda expression to multiline

solar mauve
#

Now I've got this:
event.getChannel().sendMessage(embed.build()).queue(message -> message.addReaction(args[5]).queue((Consumer<? super Void>) message.addReaction(args[3])));
And this:
ERROR RestAction - Encountered error while processing success consumer java.lang.ClassCastException: net.dv8tion.jda.internal.requests.RestActionImpl cannot be cast to java.util.function.Consumer
And I don't know how to fix. Can anybody help me?

earnest phoenix
#

you didn't do what i told you

#

you don't need a callback on addReaction

solar mauve
#

@earnest phoenix Oh now I have it Thank's!

earnest phoenix
#

Hi, I have a problem.
When I do a web request to a API JSON, and when I log that JSON in the console it looks like this but when I log json.reason it logs an empty message. How I can solve it?

#

(JavaScript)

amber fractal
#

That isnt json

modest maple
#

that is a dict within a list / array

#

why not just handle it how it is>?

amber fractal
#

OOOOH

#

json.reason doesnt exist

#

if json is the array, you need to index it

earnest phoenix
#

It needs to be json[0].reason?

amber fractal
#

json[index].reason

#

Yes

#

But it inst json so the variable name is wonk

earnest phoenix
#

It throw me this error:

(node:10894) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'reason' of undefined
(node:10894) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 19)
modest maple
#

read the error

#

👏 try 👏 catch 👏

earnest phoenix
#

OH 🤦

#

Tnx xd

#

try catching everything is not the solution

#

it's a lazy hack

#

you don't fix it you choose to ignore it

#
  const server = msg.guild;
  const type = 'category';
  
  //########################################################
  for(let  i = 0; i < Categories.length; i++){
    server.createChannel(Categories[i][0], {type,  
      permissionOverwrites: [{
      id: server.id,
      deny: Categories[i][2],
      allow: Categories[i][1]
      }]
    }
  )
}

  return new Promise(resolve => setTimeout(resolve, timeOutCat));
  
}```
#

node.js/discord.js

sudden geyser
#

what is categories (or at least what you pass for permissions)

earnest phoenix
#

@sudden geyser

sudden geyser
#

Not all of those are valid, like MANAGE_CHANNEL is actually MANAGE_CHANNELS (the S).

earnest phoenix
#

okay iwill try it thanks

#

the main problem is in this part and i really cant fix it please help if u can

#
    server.manage_channels(Categories[i][0], {type,  
      permissionOverwrites: [{
      id: server.id,
      deny: Categories[i][2],
      allow: Categories[i][1]
      }]
    }
  )
}

  return new Promise(resolve => setTimeout(resolve, timeOutCat));
  
}```
sudden geyser
#

You can fix it by passing valid permissions in the JSON tree you showed in the screenshot.

earnest phoenix
#

same problem

#

i think these are vilad

sudden geyser
#

Still not

dense patio
#

the tutorial used vultr, but i figured it would be essentially identical to digital ocean

rustic axle
#
server.dispatcher = connection.playStream(ytdl(server.q[song], {filter: 'audio', highWaterMark: 1*1000*10000 /* 10MB */, begin: begin}),  {highWaterMark: 1, bitrate: 64000})```
I use the above to stream a song over a connection using the ytdl library. I used to have for my pause command `server.dispatcher.end()` where it would save the playing song and the playlist. For the resume command I was basically unloading the paused queue and played the song using the above. However, I decided to use `server.dispatcher.pause()` and `.resume()` respectively. I understand that these are meant to pause/resume dispatchers and their streams, however it seems like it is only being paused and not resumed. Can anyone provide some insight on this? (Node v12.10.0, DJS 11.5.1)
#

And, yes, it is still connected and recognized by discord. Its just not resuming as can be seen here

#

And when I log server.dispatcher.paused it comes back with true

#

wait

#

I may be stupid

green kestrel
#

@dense patio I'm concerned that tutorial doesn't mention backups anywhere

dense patio
#

i don't need to worry about those anyway

green kestrel
#

Famous last words

dense patio
#

true

green kestrel
#

😁

dense patio
#

if i need to enable them, there appears to be a simple setting in DO

green kestrel
#

The only other thing id change is, maybe Debian instead of Ubuntu, it's more lightweight, and also whatever SSH program they talked about, never heard of it, just use PuTTY

proper epoch
noble willow
#

What version are you using

#

For rewrite the latest is 1.2.5

proper epoch
#

hmm

#

no I'm up to date

noble willow
#

Ok

proper epoch
#

I just got a really weird error though

noble willow
#

Send it, I might be able to help, though I don't know

proper epoch
#

It's working now but it said type TextChannel doesn't have the name attribute

#

or someth like that

noble willow
#

odd

proper epoch
#

the error was for
if message.channel.name == '💡suggestions': #I made this for a specific server
AttributeError: 'DMChannel' object has no attribute 'name'

noble willow
#

ohhh

#

I use ctx for stuff like that

#

For me I use ctx.message.channel.name

quartz kindle
#

the error says it all

#

DMChannel

noble willow
#

Sooo someone ran the command in DM's then probably

proper epoch
#

ooh

#

thanks 🙂

earnest phoenix
zealous veldt
#

@earnest phoenix yes but wrong channel

fathom pewter
#

Can someone give me the code for Bot presence?

#

Sorry i just asking

cerulean salmon
#

bot started sending same message 2 times

bitter sundial
#

@fathom pewter dont expect to be spoonfed code

#

we can help you write the code for bot presence

#

but we will not just send you ready code for it

earnest phoenix
#

Hi, is it just me who is experiencing MongoDB issues which it will sometimes deletes the command executer’s data from the database?

#

It only happens sometimes so I don’t think its a problem in my code.

late hill
#

Never had any issues with it

lament meteor
#

check the code where you are deleting data if you are not then check if you are actually adding it

fathom pewter
#

Oh.. Okay then

#

Btw what happen with discord nowadays since the invite link embed seem broken lmao

compact oriole
#

Links in embeds work perfectly

fathom pewter
#

I mean like the member count

tidal parrot
#

What member count

elfin jasper
#

@tidal parrot can u help me set up the dyno and mee6 bot pls

quartz kindle
#

whats so hard about it?

earnest phoenix
#

@elfin jasper

#

Not a support server

elfin jasper
#

Oops

#

Can u Inv me to the right server

earnest phoenix
earnest phoenix
#

Just a question : how to check if a channel is NSFW?

#

(js)

mossy vine
#

d.js?

#

channel.nsfw

earnest phoenix
#

(edit : I found)

amber fractal
sage bobcat
#

One message removed from a suspended account.

livid rivet
#

helo guys I need a quick help

#

I am developing further with my discord bot, sooo, I need a function (or general help) to retrieve if and how my bot is into the ratelimit

earnest phoenix
#

Js

#

?

livid rivet
#

oh sorry no

#

python

compact oriole
#

It isnt ratelimited if everything works

#

You dont need to know it

earnest phoenix
#

Oh

compact oriole
#

Because it will error out if you are limited

livid rivet
#

I mean I should make a web request probably

compact oriole
#

wdym

#

you dont need to know, as you just catch exceptions

livid rivet
#

nahh i want to make large style commands for big servers that don't violate the rate limit

compact oriole
#

yea???

livid rivet
#

yeah

compact oriole
#

why do you need that

#

rate limit is there to stop you

#

automatically

#

and you just dont do anything

livid rivet
#

thats not the idea behind ratelimit

#

I want to get it verified you know?

compact oriole
#

you cant control users

livid rivet
#

duh tell me how webrequests work and where I should make them to retrieve the JSON

winged thorn
#

Check the headers of the request to see info about the ratelimit

compact oriole
#

duh ok figure it out yourself copy pasta

livid rivet
#

not lesson me on how my bot should be semi legal

compact oriole
#

@winged thorn right

#

thats what I said

livid rivet
#

yeah I mostly need the url for those

#

where I should do await async.request

winged thorn
#

you can get all of discord's endpoints from their developer documentation

livid rivet
#

or is it a different everytime

#

okay here we are, thanks

#

where can I find them?

compact oriole
#

it aint that hard to find out yourself

#

on discords site

winged thorn
#

have fun

#

You probably want the ones for resources

livid rivet
#

yeah

#

allright thanks alot

#

💚

sinful lotus
#
int input = 1;
int[] numbers = new int[]{ 1, 2, 3, 4, 5 };
for (int number : numbers) {
  int sum = number + input;
  System.out.println("The sum of " + number + " and " + input + " is " + sum);
}

I did something like that based on the question

#

but I'm not sure if that actually the right understanding on that problem

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

sinful lotus
#

I know I need to use a for statement in java on that

#

the problem Im facing is the numbers I need to add

sage bobcat
#

One message removed from a suspended account.

sinful lotus
#

it says 5 values, I assumed the predefined values are 5 or something idk

sage bobcat
#

One message removed from a suspended account.

sinful lotus
#

I cant actually understand what do the questionaire even want me to sum one per line

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

sinful lotus
#

first integer = the numbers of values remaining to be entered

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

sinful lotus
#

I know java but its useless if I cant comprehend the way of english on the problem pandasad

sage bobcat
#

One message removed from a suspended account.

green kestrel
surreal sage
#

somewhere theres a error of args but idk ```js
if (command === "courses") {
const e = new Discord.RichEmbed()
.setTitle('Courses')
.setAuthor('Axyx', boticon)
.setColor('#ff1493')
//fields
.addField(course1.title + 'By: ' + course1.author + '', 'To view this course \nUse axcourse c1')
//send
message.channel.send(e)
}
//course 1
if (command === "course") {
if(!args) return;
message.reply('Please specify the course.')
const args = message.content.split(' ').slice(1).join(' ')
} else {
if(args === "c1") {
const e = new Discord.RichEmbed()
.setTitle(course1.title)
.setAuthor(course1.author, course1.authori)
.setDescription(course1.desc)
.addField(course1.pages + ' Pages', 'Switch from pages: \naxcourse c1 <page>')
message.channel.send(e)
}
}
//pages
if (command === "course") {
const args = message.content.split(' ').slice(1).join(' ')
return;
} else {
if(args === "c1") {
if(args === "c1 1") {
const a = new Discord.RichEmbed()
.setAuthor('1/2')
.setImage(course1.page1i)
.setColor('#1e90ff')
message.channel.send(a)
} else {
if(args === "c1 2") {
const a = new Discord.RichEmbed()
.setAuthor('2/2')
.setImage(course1.page2i)
.setColor('#1e90ff')
message.channel.send(a)
}
}
}
}

compact oriole
#

then how could we find it out?

#

shouldn't you find it yourself, as you understand it

#

as idk what your code does

sage bobcat
#

One message removed from a suspended account.

surreal sage
#

gonna retry rn

grim aspen
#

are there any errors?

charred loom
sudden geyser
#

The error message tells you what you did wrong

earnest phoenix
#

how do you do what

charred loom
#

Well how to solve the problem that I also tried .setDescription

sudden geyser
#

You need to make sure the table you make is not over the limit (either by capping or slicing anything past it)

charred loom
#

Well, those do ..., I ask

earnest phoenix
#

hey
My bot has a command folder which contains all commands of my bot. I want to make folders into this command folder for organization. Here is the script (https://prnt.sc/q9xscj) who checks all the js files in my bot. How to edit it? (ex : I want him to check commands/fun/filename.js, commands/mod/filename.js...

Lightshot

Captured with Lightshot

mossy vine
#

read directories recursively

earnest phoenix
#

?

#

how i count bots users total members of the server in my bot

peak ivy
#
<Guild>.members.filter(x => x.user.bot).size
grizzled jackal
#

that's what happens when you copy paste things

grim aspen
vital lark
#

he's asking for bots

sudden geyser
#

@earnest phoenix, they mean to read the directory for each category, or do it recursively (if you plan on having more folders inside folders in the future). For example,

let commandCategories = fs.readdirSync("./commands/");

for (const category of commandCategories) {
   let commandFiles = fs.readdirSync(...); // Use logic here to get categories, like how you do it for commands
}```
earnest phoenix
#

like ```js
let commandFiles = fs.readdirSync("./commands/fun" || "./commands/mod")

sudden geyser
#

no

mossy vine
#

no

#

that wont work

earnest phoenix
#

🤦

mossy vine
vital lark
#

what your trying to do in that line of code is

earnest phoenix
#

oh

sudden geyser
#

you just need to loop over each category the same way you loop over the command directory to load each command

#

like ./commands/${category}/${stuff}

earnest phoenix
#

oh

compact oriole
sudden geyser
#

ew

earnest phoenix
#

ew

valid frigate
#

no

compact oriole
#

glob good

mossy vine
#

its very light (56kb) and useful, idk why yall instantly say ew

#

but yeah its pretty unnecessary for this purpose

compact oriole
#

I use it to get all .ts files

mossy vine
#

for what

earnest phoenix
#

code **Users** ${message.guild.members.filter((m) => m.user.bot = false).size} error (node:1810) UnhandledPromiseRejectionWarning: DiscordAPIError: 401: Unauthorized at item.request.gen.end (/rbd/pnpm-volume/b99409d4-7b2f-4afb-9263-e5e20c3823a2/node_modules/.registry.npmjs.org/discord.js/11.5.1/node_modules/discord.js/src/client/rest/RequestHandlers/Sequential.js:85:15) at then (/rbd/pnpm-volume/b99409d4-7b2f-4afb-9263-e5e20c3823a2/node_modules/.registry.npmjs.org/snekfetch/3.6.4/node_modules/snekfetch/src/index.js:215:21) at process._tickCallback (internal/process/next_tick.js:68:7) (node:1810) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2) (node:1810) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

mossy vine
#

cant you already do that with tsc

earnest phoenix
#

want to count users

vital lark
#

why need to use a dependency that is so easy to do natively

compact oriole
#

I use it for registering commands

mossy vine
#

lmao why are you getting 401 on that

earnest phoenix
#

dont know

compact oriole
#

thats weird

valid frigate
#

mfw

earnest phoenix
#

they're getting a 401 at logging in but don't know how to debug properly

#

that stuff is websocket

#

also that's not how filtering works

#

i want to count only users

vital lark
#

ur doing Boolean checks wrong

earnest phoenix
#

of the server

vital lark
#

it's usually

!aaaa = false
aaaa = true

compact oriole
#

@earnest phoenix Is he the new CDeveloper copy pasta dev?

vital lark
#

if doing if statements or predications (filter, map, etc)

earnest phoenix
#

i guess lol

#

there are a lot of people here who only know how to press ctrl, c, v

vital lark
#

yep

mossy vine
#

its literally the only keys on their keyboards

earnest phoenix
#

it showing me a is not define

mossy vine
#

lmaooooo

vital lark
#

literally

#

aaaa was an example Kanna_facepalm

earnest phoenix
vital lark
#

replace aaaa with what ur doing

earnest phoenix
#

🤦‍♂️

vital lark
#

i.e x => !x.user.bot

sudden geyser
#

What if we took V for paste, and changed it to P to make it harder

compact oriole
earnest phoenix
modest maple
#

why you should always write the code yourself

grizzled jackal
#

And that friend of yours copy pasted that code from a js guide

#

Kinda ironic

surreal sage
#

how to do likee: if args include "a" make a -> b

#

so a becomes b and b becomes c

#

etc

#

like mors code

mossy vine
#

thats not morse code at all tf are you on

earnest phoenix
#

lol what

grizzled jackal
#

lmao

surreal sage
#

example

grizzled jackal
#

look up ascii code

mossy vine
#

caesar cipher with a shift of +1

surreal sage
#

where?

mossy vine
#

the fuck do you mean where

earnest phoenix
#

lmao

mossy vine
#

where you want it to shift

grizzled jackal
#

funnily enough I did that in C earlier

earnest phoenix
#

do some research

surreal sage
#

"look up ascii" code

grizzled jackal
#

Google

earnest phoenix
#

k i found a solution

#

ctrl+c --> ctrl+v --> editing some things

grizzled jackal
#

oh boi

mossy vine
#

the first 2 steps is what most people in this channel do

grizzled jackal
#

copy pasting is fine as long as you understand what it does and how it works

#

otherwise its pointless

compact oriole
#

stackoverflow

#

a coder cant know everything

#

but you need to still make it yourself

#

find some snippets and understand your code

slim heart
#

what are the things i should know if i want to do a thing where you can add multiple channels and itll make a webhook for each of them. and then everyday it loops through them and sends something?
like is ratelimiting a thing in that cuz they'd all be different webhooks

earnest phoenix
#

all endpoints have ratelimits

#

all ratelimits are per token

sudden geyser
#

The bot can have a nickname (<@!)

modest maple
earnest phoenix
#

thx

glacial mango
#

I want to check if a string starts with the current server prefix. But I get this error:
ReferenceError: prfx is not defined

var str = '.hello'
const prfx = `${server.tag}
`
if (str.startsWith(`${prfx}`)) {
msg.channel.send("Yes")
} else {
msg.channel.send("No") }```
compact oriole
#

Why do you do it like that???

earnest phoenix
#
var str = '.hello'
const prfx = server.tag
if (str.startsWith(prfx)) {
msg.channel.send("Yes")
} else {
msg.channel.send("No") }
compact oriole
#

str.startsWith(server.tag)

earnest phoenix
#

but why like that

#

@glacial mango is server definied?

glacial mango
#

should be, lemme check

grizzled jackal
#

lmao

#

just casually ignoring the answer

sudden geyser
#

Are you sure the error's from that snippet of code (or edited)

desert heron
quartz kindle
#

4014 Disconnected Either the channel was deleted or you were kicked. Should not reconnect.

desert heron
#

it is a private server - the channel definitely was not deleted nor was anyone kicked

quartz kindle
#

welp, thats what your logs say

#

either you got the wrong log, or ask in the d.py server

desert heron
#

ive asked in the dpy server

#

they have no clue

quartz kindle
#

neither do i

fluid basin
#

well maybe it just means someone kicked it out of vc

#

or another bot did it though chances are unlikely

desert heron
#

i believe the 4th line might actually be from Lavalink and not the bot itself. regardless, it wasnt kicked from VC

fluid basin
#

hmm

#

ok that seems weird

#

seems like discord is disconnecting you

desert heron
#

i see. any idea why they would do that? it isnt spamming voice or anything weird like that

#

and it is seemingly random. could happen after 5 minutes, could be 5 hours

modest maple
#

the bot got remotely disconnected, apparently from discord's websocket

#

what version of D.py r u on?

desert heron
#

1.2.5

#

the 4th line is seemingly from lavalink and not the bot itself - it will dispatch that event when it detects it has been disconnected from voice

modest maple
#

only thing it might be is a shard switch over?

fluid basin
#

and from that it does seem like voice ws

modest maple
#

if the server voice its on and the bot randomly gets disconnected and reconnected

#

like if you have high ping on a VC normally

#

it sometimes disconnects you

fluid basin
#

yeh thats possible

modest maple
#

but in bot's cases the API doesnt auto reconnect

fluid basin
#

or it was a user action

#

they did state on the docs that 4014 shouldnt reconnect

#

which means likely shouldnt be random

desert heron
modest maple
#

actually thinking about it now, recently alot of VC have been breaking and failing to be deleted / changed and discord's been going through alot and resetting them

desert heron
#

one thing that should be noted. i changed my websocket to use websockets rather than aiohttp since aiohttp would randomly dc from the lavalink server. with that said, the stuff involving connecting to a voice channel hasnt changed at all

modest maple
#

maybe try curl

#

idk

#

audio isnt my thing in python

hidden haven
#

Arab chat?

modest maple
#

err no.

surreal sage
modest maple
#

well its a json

#

so just handle it like a json

surreal sage
#
const url = https://some-random-api.ml/meme
url.image```?
#

i know theres something with the link

modest maple
#

w-what

surreal sage
#

make it a string?

amber fractal
#

Seems to return json

#

Parse json then treat it as an object

surreal sage
#

what

modest maple
#

hes using an api

#

just send a url request

#

get json object

#

treat as dictionary

#

get image url

surreal sage
#

uhhhh

modest maple
#

problem solved

surreal sage
#

no

modest maple
#

if you dont know how

#

welcome to the basics of JS

amber fractal
#

That's how you treat that.

surreal sage
#

ok

#

do i need any modules?

amber fractal
earnest phoenix
#
client.on('message', async (message) => {
    if (message.content.startsWith(`dtest`)) {
        if(message.author.id != config.owner)return;
        let entry = await message.guild.fetchAuditLogs({type: 'BOT_ADD'}).then(audit => audit.entries.first())
        let userr = []
        userr = entry.executor.id
        let acct = []
        acct = entry.action
      message.channel.send("<@"+userr+">\n\n"+acct)
}});

Why acct = undefined?

#

Resolved

rugged minnow
#

@surreal sage i use this

const fetch = require('node-fetch');
const response = await fetch('https://some-random-api.ml/animu/hug').then(response => response.json());
[...]
earnest phoenix
#

please don't spoonfeed 👀

rugged minnow
#

perhaps i put too much code

modest maple
#

that wasnt too much code that was a full course meal

#

filled with pudding and starters

rugged minnow
#

yeah, well, i'm too lazy to pick stuff

surreal sage
#

i dont need it any more :P

rugged minnow
#

oh ok

amber fractal
#

Being too lazy to pick stuff hurts others.

split hazel
#

Is it possible to restore a corrupt sequelise sqlite3 database?

#

Only some actions return that the database is malformed, not all

surreal sage
#

same

pseudo whale
#

If i use this: if (!bot.member.hasPermission("SEND_MESSAGES")) return; bot.member will not be the bot in that guild right?

earnest phoenix
#

Client#member isn't a thing, if your client is the discord client

#

docs are helpful

#

and Guild#me is your bot in that guild as a member object

vital lark
#

@earnest phoenix u know ur converting an array to a string right

pseudo whale
#

So i would use message.guild.me.hasPermission

#

I think so

earnest phoenix
#

yes

pseudo whale
#

K thanks

earnest phoenix
#

np

#

@vital lark what?my problem je resolved 🤨

vital lark
#

oh it was resolved then?

#

ok

earnest phoenix
#

Yes but thank you

vital lark
#

i didn't read the Resolved part. my bad xD

earnest phoenix
#

Lol

#

Np

pseudo whale
#

So ive got if (!message.guild.me.hasPermission("SEND_MESSAGES")) return message.author.send("I cannot send messages in " + message.guild.name); in my message event before i run anything. But when i test it my bot just errors out and doesnt dm me

#

Any reason this is?

earnest phoenix
#

you didn't send any error so

dense patio
#

i started my bot using pm2 on digital ocean but it still isn't online, in the command line it says that index.js was started but the bot is offline

#

@green kestrel got anything?

pseudo whale
#

@earnest phoenix what do you mean?

green kestrel
#

Nope, try running it without pm2 and see what error appears

dense patio
#

provide an error message

#

how do i do that

late hill
#

or check pm2 logs

dense patio
#

wait

green kestrel
#

Depends, it's your code

#

You tell me

dense patio
#

it says "cannot find module discord.js"

green kestrel
#

There's your answer :)

earnest phoenix
#

install discord.js

surreal sage
#

did you required the module in your script?

dense patio
#

i assumed it would've been downloaded since it was in the package.json i moved in

surreal sage
#

no

sudden geyser
#

@pseudo whale what's the error you get.

green kestrel
sudden geyser
#

ing, I think you should do the comparison twice

pseudo whale
#

@sudden geyser Discord API Error: Missing Permissions

surreal sage
#

@earnest phoenix that doesnt work cuz its invalid

earnest phoenix
#

the error is self explanatory

sudden geyser
#

like if (event.d.message_id === 'ID' || event.d.message_id === "2ndID")

earnest phoenix
#

you either blocked your bot, or you disabled your dms

surreal sage
#

you have to duplicate

sudden geyser
#

The error's probably not coming from that snippet of code, Matievis

#

If the user blocked it, it'd be Cannot send message to this user

earnest phoenix
#

oh yeah actually my bad

#

yeah sorry

pseudo whale
#

Its in my message event

#

Before i run any commands

sudden geyser
#

You'll need to get the colum and line number to figure out exactly what line was causing it

pseudo whale
#

Urm wherr do i get that? It doesnt seem to show it in the error

sudden geyser
#

Can you share the stacktrace

pseudo whale
#

This is the entire error (node:7767) UnhandledPromiseRejectionWarning: DiscordAPIError: Missing Permissions at item.request.gen.end (/rbd/pnpm-volume/4fd4dbbb-ae95-4584-a8a2-26a80b2bb456/node_modules/.registry.npmjs.org/discord.js/11.5.1/node_modules/discord.js/src/client/rest/RequestHandlers/Sequential.js:85:15) at then (/rbd/pnpm-volume/4fd4dbbb-ae95-4584-a8a2-26a80b2bb456/node_modules/.registry.npmjs.org/snekfetch/3.6.4/node_modules/snekfetch/src/index.js:215:21) at <anonymous> at process._tickCallback (internal/process/next_tick.js:189:7) (node:7767) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 8)

modest maple
#

thats missing perms

pseudo whale
#

Ik

modest maple
#

catch error

surreal sage
#

like if you want a allias on your cmd: js if (command === "1" || command === "2") {}

modest maple
#

problem solved

pseudo whale
#

I denied it perms on purpose

surreal sage
#

i made a pastebin post command :P

sudden geyser
#

try and catch not always solution 🙅

Matievis, can you share your message listener in a paste (e.g. hastebin)

dense patio
#

hey @green kestrel i'm getting no error messages but the index.js process instantly errors after i start it

late hill
#

did you install the missing packages

dense patio
#

i believe so

late hill
#

did you use npm install

dense patio
#

i haven't gotten another message about it

#

yeah

late hill
#

There's no errors?

dense patio
#

nope

late hill
#

With pm2 or just regularly using node

green kestrel
#

How do you know it errors then

dense patio
#

i did pm2 list and it said errored

late hill
#

check the logs

#

pm2 logs id/name

green kestrel
#

I really must look into pm2 for running native programs.

late hill
#

might wanna add --lines 100 or something because it's pretty small by default

green kestrel
#

Can someone please do me a favour and go to #commands and type @sporks sudo modules

pseudo whale
#

Frick

#

Lag sry

late hill
#

Unrelated to your error but you really shouldn't have that check up there

#

If it wasn't commented out (and also not broken) it would dm anyone that sends a message in a channel where your bot can't send messages

#

That's horrible

pseudo whale
#

Yea

#

Thats why i commented it out

green kestrel
#

Thanks :)

pseudo whale
#

It comment out my not working code until i get the thing to work

dense patio
#

is there a problem with memory or something

green kestrel
#

29mb is nothing

dense patio
#

yeah

green kestrel
#

Does the bot work when ran outside pm2

dense patio
#

but it's the only thing i can reason

late hill
#

Check the logs

sudden geyser
#

Missing Permissions can really be anything (from sending a message to setting a guild role). You may want to watch as your code executes to track down exactly what caused it to error (through debugging).

dense patio
#

yeah

late hill
#

pm2 logs 0 --lines 100

dense patio
#

it's been on glitch for a couple months

green kestrel
#

Do you have other deps like DBL updater

#

That run on a timer

#

And are those installed

dense patio
#

uh

earnest phoenix
pseudo whale
#

The only code being executed is the bot sending a message into the channel

green kestrel
#

I'm betting it errors out when hitting the require of such a dep

#

@earnest phoenix why does that penguin have boobs

dense patio
#

oh apparently sqlite isn't installed even though i just installed it just in case

earnest phoenix
#

its a pokemon

#

dum dum

green kestrel
#

Oh, kids cartoons 👍

late hill
#

Simply running npm install should install everything in your package.json

dense patio
#

ah ok

#

how do i get the thing back

#

that let's me type commands

late hill
#

ctrl c

dense patio
#

ah thanks

green kestrel
#

@late hill I don't do npm or glitch, are these things all automatic on glitch which is why @dense patio is stuck now after moving it to proper hosting?

late hill
#

probably

green kestrel
#

Just trying to understand why someone can run a bot for months and not know about these things

late hill
#

or he just forgot

#

I forget to install packages too sometimes when I switch hosts

green kestrel
#

Yeah, seemed like it should have been prerequisite knowledge

split blade
#

Just developed my first bot over the past week and im now waiting for approval. It should be pretty lit.

dense patio
#

hm

#

when i did npm install

green kestrel
#

I fell into same trap with my bot yesterday forgetting to put -rdynamic onto the g++ command and wondering why modules wouldn't load

#

Proper captain obvious moment

dense patio
#

it just hit me with a bunch of warns saying "no such file or directory"

#

and an error sayin "This is related to npm not being able to find a file."

green kestrel
#

I heard u leik deps, so I gave your deps some deps

#

🤣

late hill
#

Maybe your working directory is set wrong

dense patio
#

how do i change it

green kestrel
#

I'm actually learning as much as @dense patio ATM as node isnt my bag so I'm learning how to support you all lol

late hill
#

use pwd to see the current working directory

dense patio
#

lol

#

ok

late hill
#

and cd PATH to change it

dense patio
#

oh yeah i was in the right one

late hill
#

oh

#

uh

#

If it's just warns you can usually ignore them

dense patio
#

yeah but it still isn't working

#

there was also a few errors

vital lark
#

it cant rename files

#

give it sudo perms and

green kestrel
#

Hmmm

dense patio
#

why would it be renaming files

vital lark
green kestrel
#

I got something important to ask asap

late hill
#

yes

#

It's also not a great idea to run stuff from root

green kestrel
#

Type whoami please @dense patio

late hill
dense patio
#

here?

green kestrel
#

@late hill that

prime cliff
#

Why don't you just test your own commands?

dense patio
#

whoami

green kestrel
#

No, in your shell

late hill
#

not a bot command

topaz fjord
#

try npm cache clear

dense patio
#

OH

late hill
#

;d

dense patio
#

lol

green kestrel
#

Does it say root?

dense patio
#

yes

green kestrel
#

Ok....

#

Important advice

#

Make a new non root user

#

Set up your bot there

#

Running it as root is like running Windows XP as administrator

topaz fjord
#

tbh it doesn't really matter what account you set it up on

dense patio
#

yeah what would that change

green kestrel
#

It definitely does

prime cliff
#

That does not really effect much unless you had some kind of eval command

topaz fjord
#

^^

dense patio
#

what does it affect

green kestrel
#

Everything?

topaz fjord
#

nothing

late hill
#

ok boys

prime cliff
#

Nothing unless you have an eval command

green kestrel
#

Root isn't supposed to be used to run user programs

#

Ever

late hill
#

you're familiar with windows right

topaz fjord
#

then root shouldn't exist

dense patio
#

eh

#

not the cmd

prime cliff
#

Noone can "hack" a Discord bot and even if they got your token it's a seperate session

late hill
#

That annoying run as administrator thing you need sometimes

topaz fjord
#

holy shit i hate this new discord markdown preview

dense patio
#

yeah

late hill
#

Gives you time to think before doing something stupid

topaz fjord
#

no

green kestrel
#

@prime cliff what if one of your deps has a security vulnerability, or node does

dense patio
#

yeah what about it

late hill
#

That's the same reason why you shouldn't be using root for regular things

#

Especially being new to linux

prime cliff
#

Still does not effect anything

topaz fjord
#

@dense patio try npm cache clear for your issue

late hill
#

You might mess up everything with 1 wrong command

prime cliff
#

They can't leverage that unless it's with an eval command

late hill
#

Yes

#

But for him

#

He's new to linux

green kestrel
#

Never ever run any public service as root. Apache and ngix don't run as root, nor does any other Linux Daemon, you shouldn't make one that does

late hill
#

The bot would work fine

topaz fjord
#

i run nginx as root

#

works fine

dense patio
#

ok so how do i change it so it's not on root

late hill
#

But it still isn't a good idea to run everything from root

prime cliff
green kestrel
#

add a user with adduser

topaz fjord
#

nginx as root doesn't do shit

#

except run

green kestrel
#

Then set a password on it

#

Login as that user instead

#

Set up your bot there

dense patio
#

just type adduser?

#

or do i add a name after

topaz fjord
#

that's a waste of time but ok

green kestrel
#

It will have a separate empty home dir

#

Name after yes

dense patio
#

ok

topaz fjord
#

add -m if you want it to create a home dir

green kestrel
#

@topaz fjord really, I think this is a conversation for those who know what they're talking about

dense patio
green kestrel
#

Re the "this isn't needed"

dense patio
#

ok...

topaz fjord
#

implying I don't know what I'm talking about

green kestrel
#

Yes that's exactly what I implied

topaz fjord
#

I've run all my bots as root and haven't had an issue for 2 years

#

so fuck off

dense patio
#

@green kestrel what do i do from here

green kestrel
#

I'm not often blunt and offensive but telling a newbie root is fine, is really really bad advice

topaz fjord
#

telling a newbie it's fine when it is fine isn't bad advice

dense patio
#

@green kestrel don't worry about it, i'm listening to you

green kestrel
#

Ok so you'll need to ssh into the server, but use those new credentials

dense patio
#

i think i'm in already, no?

green kestrel
#

Yes

#

Then set up your bot in there

dense patio
#

ok

green kestrel
#

You can either do it all again or you can go back in as root and do something like:

dense patio
#

i moved all of the files to the new user

green kestrel
#

cp -r /root/bot /home/panicakr/bot; chown panicakr:panicakr /home/panicakr/bot

dense patio
#

well, it's currently transferring

green kestrel
#

You'll need to change its ownership as above

dense patio
#

alright i got the new files on the new user

#

what next

green kestrel
#

Or reupload will do the correct permission

#

Carry on where you left off

#

Your bot is now more secure than it was

#

👍

topaz fjord
#

very secure isn't it mmLol

dense patio
#

ok it's cool that it's secure

#

but it's still not online

topaz fjord
#

TIL that adding a new user makes a piece of code secure

green kestrel
#

Well, a programming error can't accidentally wipe the whole server now or kill it. And you have the options to set /etc/security/limits.conf etc.

topaz fjord
#

it technically can

green kestrel
#

How?

topaz fjord
#

os.exec

green kestrel
#

How can a non root user wipe the server

dense patio
#

alright brain

#

how do i get the bot online

green kestrel
#

And setting limits.conf will prevent fork bombs or memory consumption beyond a sane limit

#

But you can't do that running as root

modest maple
#

tbf brain i turned my school's server system OS into a webpage

#

on a student account

#

so its defo possible

topaz fjord
#

mmLol good school

modest maple
#

ik

dense patio
#

i still get the rename error

green kestrel
#

Try running the bot without pm2, see what happens

topaz fjord
#

legit

green kestrel
#

Look at output for errors

topaz fjord
#

run npm cache clear

dense patio
#

how do i run it without pm2

topaz fjord
#

it's a fucking npm error not a pm2 error

#

@earnest phoenix that's hot

green kestrel
#

Now go with what turtle says :)

dense patio
green kestrel
#

I know Linux not node