#development

1 messages · Page 1617 of 1

viral mortar
#

if you start with python, like i did, it actually is quite helpful when laying out your code for other languages

lyric mountain
#

just like how you brush ur teeth to go see the dentist

viral mortar
lyric mountain
#

idk

latent heron
#

i never started with python

earnest phoenix
#

compare this to this lol

latent heron
#

my first programming lang was PHP

earnest phoenix
#

hikari is cool

pale vessel
latent heron
#

i don't regret it either honestly

#

PHP taught me a lot of valuable insight to OOP programming

#

and i was able to transfer a lot of my knowledge from PHP to other langs really easily with classes and such

quartz kindle
#

i learned a bit of php before i ever touched js

#

but i was never really good at it

earnest phoenix
#

php is kinda weird to me

latent heron
#

php is a freaky language to begin with

misty sigil
#

php is kinda weird

latent heron
#

it's also just abhorrently messy

viral mortar
latent heron
#

i feel like you have to be comfortable with writing a little messy if you want to make PHP work on your side

quartz kindle
#

i did atrocious things with php and wordpress back then, not proud xd

latent heron
#

getting it to look clean is really important to me imo because i care a lot about not only maintainability but accessibility

#

we all did :v

misty sigil
#

i've done atrocious things in all languages

latent heron
#

i coded a custom database in php

#

and i use it to piss off Nik now and then

quartz kindle
#

i did shit like ```php
$something = abc;
$something2 = $something + zyx;
$something3 = somefunc($something2, somethingelse);
$something4 = ...

#

lmao

latent heron
#

something i wish PHP had would be kwargs

#

python is nice about that

quartz kindle
#

ye

crimson vapor
#

cringe

latent heron
#

tim

#

ever heard of variable variables

quartz kindle
#

$$something?

latent heron
#

i like to use them often to remind people how shit PHP is

#

yeah

quartz kindle
#

xD

latent heron
#

they're horrifying

pale vessel
#

wait +?

#

not .?

latent heron
#

i absolutely despise how they just are so "logically" sound

#

both work

#

i think

quartz kindle
#

also

pale vessel
#

since when

quartz kindle
#

string concatentation in php

pale vessel
#

huh

quartz kindle
#

"abc".$something."xyz"

pale vessel
#

yeah

latent heron
#

string concat in php is bad

#

well it's that or string format

#

"abc{$something}xyz"

pale vessel
#

only works for "

#

oh wait

latent heron
#

if you use \" it should work too

pale vessel
#

i used "$something aa"

quartz kindle
#

i quit php long before i learned about string formatting, so all my php uses concatenation xd

latent heron
#

i don't like doing that method

#

it feels extremely wrong

pale vessel
#

i might go back to php since it has arrow functions now (since 7.4?)

latent heron
#

mhm

pale vessel
#

i love those

latent heron
#

with PHP 8 being out it really feels proper

quartz kindle
#

php 8 has the new match expression, which is amazing

#

i wish js had something like that

latent heron
#

oh yeah it does

near stratus
#

I promise I'll use PHP when they are gonna remove the $ signs and add Variable type

latent heron
#

also PHP 8 JIT

#

bye bye slow load times

quartz kindle
#

xD

earnest phoenix
#

Python is going to have that, isn't it

latent heron
#

not sure

#

also i see nothing wrong in $ variable declaration

#

it's just like JS using let

#

variable type also just forces a type condition and nothing more, so i don't see too much into why this is important

quartz kindle
#
$myvar = match (5) {
  1 => "Oh no!",
  2 => "This is what I expected",
  3 => "hehehe",
  4 => "nope",
  5 => "yes",
};

echo $myvar // yes
latent heron
#

oh wow

#

that's nice

quartz kindle
#

indeed

latent heron
#

it's like a built in foreach loop check

#

shitttt

#

that's so fucking useful

quartz kindle
#

its a switch that returns the case

latent heron
#

i can imagine so many uses

#

bruhh

#

i need to use this in TopPHP

#

that's insanely good

quartz kindle
latent heron
#

does it still support die though?

quartz kindle
#

idk, but i dont think so

latent heron
#

i appreciate the existence of the die statement a lot

near stratus
# latent heron it's just like JS using `let`

bruh
let is for declaration
like ```js
let p = "ggg";
console.log(p);

But you have to use $ every single time you use that variable in PHP
```php
$p = "ggg";
echo(p); //Won't work
echo($p);
quartz kindle
#

its like selecting a value from an array, but instead of indexes, using a switch statement

latent heron
#

i mean sure

#

but i still see no reason why that's bad

near stratus
latent heron
#

i guess

#

i'm not one to argue how code should look pretty or not

lyric mountain
#

the issue is that smaller codes range from "meh" to "ok"

#

but larger codes (10 lines) are unreadable

pale vessel
#

why code no work?php £foo = "a"; echo £foo;

crimson vapor
#

because cringe php

misty sigil
#

did someone say £100

#

loggers

near stratus
misty sigil
quartz kindle
#

lmao

viral mortar
near stratus
quartz kindle
#

i can totally see euro-php being a thing

#

replace all $ with euro signs

#

xD

misty sigil
#

nah

pale vessel
crimson vapor
#

lua is cringe

misty sigil
#

replace all $ with £

latent heron
#

lua has an interesting way of handling pairs though

misty sigil
#

because £ is worth more than $ and €

latent heron
#

i have to give lua that

pale vessel
#

pound it is

#

pphp 😳

crimson vapor
#

lua is yikes

misty sigil
#

lua with an actual relative path require system would be alright

crimson vapor
#

agreed

latent heron
#

lua has a built-in iterator method that can be stated or stateless

#

that's fairly nice

near stratus
#

Imagine everyone dumping every other language and working with discord.php

latent heron
#

PHP doesn't have that by default

#
function pairs (t)
  return next, t, nil
end
placid iron
#

How does an iterator be stateless

latent heron
#

loop method

#
for i, v in ipairs(t) do
  return i, v
end
severe pike
#

Right bois how do i edit this image?

#

in html editor on my bots page

viral mortar
near stratus
#

then edit with tag name

viral mortar
#
img {
  // stuff here
}
severe pike
#

oh tag name

#

cheers guys

viral mortar
#

lol

opal cave
#

$nomention $onlyPerms[Manage server;Do you think you can mute without permission you scrub] $mute[Muted] $title[Muted] $description[<@$mentioned[<]> was successfully muted]

lyric mountain
#

ew

opal cave
#

But when i have that i apparently dont have a muted role

viral mortar
#

@severe pike COME BACK

severe pike
#

WHATS UP

viral mortar
#
img.entity-header__image {
  // stuff here
}
#

thats it

#

its not just any image

opal cave
#

My bot has problems istg

severe pike
#

Legenddd thanks

opal cave
#

I have a muted role and it says i dont have one

near stratus
#

@severe pike

viral mortar
lyric mountain
#

ok, php syntax looks beautiful compared to bdfd

lyric mountain
#

bdfd

near stratus
#

BDFD ?

severe pike
#

Cry i hate html

umbral zealot
#

or fucking decorators in JS.

#

decorators are so damn ugly

severe pike
#
.entity-header__image:hover{
  border-radius: 10px;
}
</style>``` Shouldn't this be doing anything to the logo
latent heron
#

and you guys are losing it over 1 dollar sign in php KEKW

severe pike
severe pike
#

Oh yes

#

i am dumb

lyric mountain
severe pike
#

ignore me

near stratus
#

remove the :hover

severe pike
#

thank you

lyric mountain
#

nah, they're fine

near stratus
umbral zealot
lyric mountain
#

idk, random google image

severe pike
#

Looks alot better 😄

#

thank you home dog

near stratus
viral mortar
severe pike
#
<style>
.entity-header__image{
  border-radius: 20px;
  transition: width 2s, height 4s;
}
</style>

How do transitions work?

latent heron
#

animation

#

they call a @keyframes method

cinder patio
#

you don't need an animation to make transitions work

latent heron
#

oh?

latent heron
#

i've always done an animation for my transitions 😳

viral mortar
#
  .entity-header__image {
    border-radius: 10px;
    animation: animate 3s;
    animation-iteration-count: infinite;
  }
  @keyframes animate {
      transition-timing-function: ease-in-out;
      0% {transform:}
        40% {transform:}
        60% {transform:}
       85% {transform:}
  }
latent heron
#

^

drifting shell
#

Discord died with formatting for code blocks on iOS kekw

latent heron
#

i really like discord's reply feature

sage bobcat
#

One message removed from a suspended account.

latent heron
#

i like that honestly

#

most people have small attention spans it seems here on discord

#

so the ping helps give a visual clue

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

misty sigil
#

it should be a setting

#

imo

latent heron
#

it is

misty sigil
#

it is?

#

what?

#

i mean by default

latent heron
#

idk

drifting shell
#

Just hit the @ on the right and then it doesn’t ping

latent heron
#

i don't think too many people are bothered

drifting shell
#

I think it stays that way too

latent heron
#

does not

drifting shell
misty sigil
misty sigil
cinder patio
#
.myclass {
 width: 10px;
 height: 10px;
 background-color: blue;
 transition: all ease-in-out 2s; 
}

.myclass:hover {
 background-color: red;
 width: 50px;
 height: 50px;
}

Example without using animation

misty sigil
#

nope

latent heron
#

hmm

#

well

#

if it at least remembered your choice

#

i think people would stop complaining

#

i mean in general a ping on discord is like the unholy spirit

drifting shell
#

@everyone when

latent heron
#

i like how typing @everyone on here angers people even when it doesn't work

solemn latch
#

Ah why did you ping me

severe pike
drifting shell
#

Yeah glaze why did you ping us

#

Angy

earnest phoenix
#

Hey, I created a tempban command, how to add "when his ban is finished, the bot unban him"?

#

my code

drifting shell
#

Have to have a scheduled task that repeats and then checks for the current time being past the expiration time

severe pike
#

What did i do ahha

viral mortar
#

that animation doesnt do anything

#

it was a shell of an animation

severe pike
#

lmfao ok thank you ill have a look at some w3 schools

viral mortar
#

jus wait

latent heron
#

w3schools

severe pike
#

bro w3 schools lit

viral mortar
severe pike
#

save me on the daily

viral mortar
#

yeup

severe pike
#

how to print hello world?

#

w3 schools

drifting shell
#

W3schools is Poggers

marsh oar
#

Hello I can't reduce my iframe I would like some help because on the top.gg site you need 300 characters

severe pike
#

how to add 1 to 1

#

w3 schools

latent heron
drifting shell
#

If you have to google how to add 1+1 youve got other issues

misty sigil
#

w3schools should just replace real schools

#

ez

severe pike
#

^

latent heron
#

i stg

#

i wonder how i learned coding from tinkernut tutorials

#

back when he used nothing but MS Notepad and IDLE

drifting shell
#

Anyone else remember minecraft and thebcbroz mmLol

latent heron
#

now i spend my time watching Sebastian Lague's videos on coding adventures

viral mortar
#

i still use idle to run scripts

latent heron
#

cursed

#

i use the terminal now

viral mortar
#

wouldnt want it any other way

viral mortar
#

oh wow

lyric mountain
#

ah, yes, cool

latent heron
marsh oar
#

Hello I can't reduce my iframe I would like some help because on the top.gg site you need 300 characters

latent heron
#

add markdown characters

earnest phoenix
viral mortar
#

ew js

#

(that should get their attention)

pure fractal
#

türküm yardım lazım

latent heron
#

(it usually triggers any JS dev within a 10 mi radius)

viral mortar
#

(mission success)

umbral zealot
austere goblet
#

I had a question, how do you guys manage monetization for your bots?

#

like

#

premium tiers

#

I want to add that to my pretty successful bot but I don't really know how

#

I am trying something with patreon

#

but it's going a bit...

#

yeah

latent heron
#

the patreon API is dogshit

#

don't feel bad to say it

austere goblet
#

yeah

latent heron
#

i'm doing the same too

austere goblet
#

the patreon api is doggshit

#

but how are you doing it?

latent heron
#

by crying

#

did you make your client?

earnest phoenix
latent heron
#

bruh you did not just copy paste that

austere goblet
#

I am making a system where when you join the patreon, it gives you a role in the support server which allows you to run a command y!claim which adds you to the premium user database

latent heron
#

bro wtf

#

that's the same concept as mine

austere goblet
#

yeah

#

it's kinda bad

#

but it works

latent heron
#

well

#

you should try this

#

you join the patreon, it has a "gives discord benefits" option where you join support

austere goblet
#

yeah

latent heron
#

then when you join support it writes the user ID as an entry to a DB

#

you can set up a listener event for it instead of a command

austere goblet
#

yeah

austere goblet
#

when*

latent heron
#

yup

austere goblet
#

hmmm

safe creek
#

is this a good extention for my db so i can connect it to my bot or?

latent heron
#

if you have it already handing out the role

austere goblet
#

how do I add a listener for a role?

latent heron
#

what lang you using

austere goblet
#

javascript

latent heron
#

oh lol well

#

i wouldn't know the d.js method but

safe creek
latent heron
#

in d.py it's something like this:

@bot.event
async def on_member_join(guild, user):
  role = discord.utils.get(ctx.guild.roles, name = "Patron")

  for _role in user.roles:
    if _role.id == role.id:
      print("we got it")
earnest phoenix
#

extensions are better

#

to use

latent heron
#

you'd have to write it in whatever fancy way d.js does it all

#

but you just need to fetch the role object, then check the ID of it in the users roles

austere goblet
#

does that actually work?

#

did you try it?

latent heron
#

it's pseudocode

#

i didn't bother trying it

#

i'm writing it out mentally the step process

austere goblet
#

because the patreon bot has a similar thing

#

but then when your bot runs the code before the patreon bot...

#

it doesn't work

latent heron
#

then don't make your bot hand the role out

#

¯_(ツ)_/¯

austere goblet
#

you'll have to put at least a timer on it of 10 seconds or something

latent heron
#

you don't really need a timer

austere goblet
latent heron
#

you can just set a loop

austere goblet
#

the patreon bot in your server sets it

latent heron
#

why would you do the API if you have a patreon integration in your server

austere goblet
#

I'm talking about the patreon bot, the role integration

#

the patreon bot adds the role to the user

#

and then you want your bot to check it

#

but you'll need a timer, otherwise it will run at the same time resulting in your bot not seeing the role yet

solemn latch
#

It would probably be best to just use the patreon api at that point

viral mortar
#

yeah

safe creek
#

how would i check if a user is a bot? so a user doesnt ban/kick a bot by accident?

austere goblet
#

yeah it's the best thing but how tf am I able to know who(on discord) bought patreon tier

safe creek
#

isnt there an error handler for that

solemn latch
#

The same way patreon does it

#

Lol

safe creek
#

ahh ok ty @viral mortar

viral mortar
#

thats for python

#

idk abt js

safe creek
#

yup im using py

viral mortar
#

oh good

safe creek
#

i was about to say

#

why you said oh god xd

#

like python isnt that bad is it CouncilLaugh

viral mortar
#

no its the best

#

its the best

#

maybe if i keep repeating it ill believe it

past hedge
jolly mortar
#

does anyone know what this is? i havent gotten it before and i didnt get a direct dm from discord or an email

misty sigil
#

It’s a token leak

#

or verification

#

open it, see which one it is!

old cliff
#

100% token leak

viral mortar
earnest phoenix
#

Hey, I made a tempmute commande but i have a problem.
normally, when his mute is finished, the bot unmute him auto with a text to say the member is unmuted but the problem:
the bot mute him but says the unmute text and don't unmute after the time

#

my code ⏫

lusty quest
earnest phoenix
earnest phoenix
#

how to do this?

tired panther
earnest phoenix
#

i tested but he's not unmute

lusty quest
# earnest phoenix i think no :/

for such stuff i would suggest using redis. this will make the "timer" persistent over restarts also got one or two other benefits. with redis you set a ttl for each data entry and if the ttl reaches 0 redis will fire a event you can listen to.
here a suggestion for a workflow
-> Mute command gives user the Mute role -> Store the Member id and the mute time into redis (mute time = ttl) -> listen for the Redis event for run out lifetimes, if a lifetime runs out you should get the member id that you can then use to remove the role

earnest phoenix
#

its a npm redis?

tired panther
#
   setTimeout(() => {
                member.roles.add(mutedRole);
                message.channel.send(`Le mute temporaire de ${member} est écoulé. Ce membre a été unmute !`);
      }, 1000*("Seconds"))
``` where did you defined the time?! ![blobfacepalm](https://cdn.discordapp.com/emojis/580592842381066251.webp?size=128 "blobfacepalm")
lusty quest
#

there is a redis package. but keep in mind redis is a Database

#

there are free hosted databases for redis

tired panther
earnest phoenix
lusty quest
tired panther
earnest phoenix
#

here

tired panther
lusty quest
tired panther
#

@earnest phoenix

earnest phoenix
#

oh i'm dumb

#

i will test i changed

smoky herald
#

hello again... is there a way to see all reviews as the bot owner?
I'd love to know what are people unsatisfied with P_pepeHmm

lusty quest
cinder patio
#

that's only a client, though

earnest phoenix
cinder patio
#

you also need to get the server

lusty quest
#

they offer free servers

cinder patio
#

it's also linux only

tired panther
cinder patio
#

^ the only reason I haven't tried out redis

tired panther
lusty quest
lusty quest
earnest phoenix
#

yes but its instant unmute after with the settimeout, setTimeout its when the time is finished no?

tired panther
lusty quest
#

the redis server itself?

tired panther
earnest phoenix
cinder patio
#

depends on the content, obviously

earnest phoenix
#

but how to make mins to timeout?

tired panther
earnest phoenix
#

where?

lusty quest
tired panther
earnest phoenix
#

OOF

tired panther
earnest phoenix
#

oh but

lusty quest
#

the bot got around 270 Guilds

#

and about 24 fields

earnest phoenix
#

@tired panther my script in minutes if I put 1 to the mute command, the bot will mute 1 minute?

tired panther
lusty quest
#

i cache my mongoDB calls

#

since my MongoDB is local anyways there is not much difference but i would say its good practise anyways

#

if you dont want to use redis you could use a map instead

cinder patio
#

you can't get banned from mongoDb if you are hosting the server yourself

lusty quest
#

he probably uses MongoDB atlas

lusty quest
#

if you do, i would look for some different software

tired panther
lusty quest
#

but i would not cache stuff that changes a lot

tired panther
earnest phoenix
#

yes

tired panther
#

there is a package name ms, it parses time strings like : 1 day or 10m in milliseconds

#

npm install ms

earnest phoenix
#

already installed

#

and after?

tired panther
tired panther
earnest phoenix
#

I added const ms to the mute.js

#

what I need to add ms("1minutes") ///will give out: 360000

#

?

lusty quest
#

rip broke my MongoDB Grafana dashboard

earnest phoenix
#

@tired panther Yes after? O_O

tired panther
# earnest phoenix I added const ms to the mute.js

let timetowait = ms(args[0]) /// !mute 2d @Meister#9667 hs ddewde

   setTimeout(() => {
                member.roles.remove(mutedRole);
                message.channel.send(`Le mute temporaire de ${member} est écoulé. Ce membre a été unmute !`);
      }, timetowait)
#

@earnest phoenix

earnest phoenix
#

yes wait

#

2d is 48h?

#

1m = 60000 minutes

#

O_O

solemn latch
#

1 minute = 60000 minutes?

lyric mountain
#

1 meter

solemn latch
#

oh yes

#

thats how fast i can go fatboi

tired panther
tired panther
tired panther
earnest phoenix
#

Its in french but look

#

1m = 60000 minutes what

tired panther
#

Je suis parle francais xD

earnest phoenix
#

xDDD

tired panther
earnest phoenix
#

minutes is:

{ name: `Durée :`, value: `${mins} minutes` },
#

in the embed

tired panther
earnest phoenix
#

I change minutes to what?

lusty quest
tired panther
tired panther
cinder patio
#

mins is not actually in minutes so maybe you should rename it

earnest phoenix
#

oh yess

cinder patio
#

to avoid confusion

tired panther
#

that was before , I have rewritten my code xD

lusty quest
#

yea this is worse

earnest phoenix
#

oKI

#

omg

#

works

#

@tired panther a last thing

tired panther
earnest phoenix
#

"2m" how to change like: 2 minutes and if its 3h: 3 heures

tired panther
#

or you can use replace

earnest phoenix
#

oh! xD

#

yes replace

#

how? xD

tired panther
earnest phoenix
#

i'm a noob noob noob dev

#

xD

tired panther
#

First learn basic js then ==> programm your bot

earnest phoenix
#

I don't understand this:

const p = 'The quick brown fox jumps over the lazy dog. If the dog reacted, was it really lazy?';

console.log(p.replace('dog', 'monkey'));
// expected output: "The quick brown fox jumps over the lazy monkey. If the dog reacted, was it really lazy?"


const regex = /Dog/i;
console.log(p.replace(regex, 'ferret'));
// expected output: "The quick brown fox jumps over the lazy ferret. If the dog reacted, was it really lazy?"

#

with the replace

#

i'm dumb = i'm french

cinder patio
#

what confuses you

tired panther
earnest phoenix
tired panther
cinder patio
#

p.replace('dog', 'monkey') tells js to replace the first instance of "dog" with "monkey"

earnest phoenix
#

so, m to " minutes

tired panther
#
const time = ms(milliseconds);
if(time.includes("m")) time.replace("m", "minute")

#

do this for d,h,s
days, hours, seconds

earnest phoenix
#

oki thx

marble juniper
#

you don't need to use replace

#

lol

tired panther
earnest phoenix
#

@tired panther milliseconds is not defined

marble juniper
#

oh

#

ok

#

bruhhh

#

that was boilerplate

#

lol

cinder patio
#

Don't blindly copy code

earnest phoenix
#
const Discord = require('discord.js');
const { deletionTimeout, reactionError, reactionSuccess, pinEmojiId } = require('../../config.json');
const ms = require('ms');
const time = ms(milliseconds);
if(time.includes("m")) time.replace("m", "minute")
#

owo

tired panther
marble juniper
#

maybe they don't know what boilerplate means

tired panther
tired panther
earnest phoenix
#

What is the recommended cooldown for fetching members?

#

@tired panther my variable to time is mins

#

so I replace milliseconds ton mins?

marble juniper
#

y e s

earnest phoenix
#

its not this O_O

#

const Discord = require('discord.js');
const { deletionTimeout, reactionError, reactionSuccess, pinEmojiId } = require('../../config.json');
const ms = require('ms');
const time = ms(mins);
if(time.includes("m")) time.replace("m", "minute")

#

owo

tired panther
#

yes

earnest phoenix
#

NoT wOrKs

#

mins is not defined

#

...

#

oh i'm dumb

#
  setTimeout(function(){
    db.delete(`mutes_${tomute.id}`)
    tomute.roles.remove(muterole.id);
    message.channel.send(`<@${tomute.id}> removed mutes!`);
  }, ms(mutetime));```
tired panther
#

@earnest phoenix found the solution

earnest phoenix
#

😮

tired panther
#
const buff = Buffer.from("bGVhcm4gY29kaW5nISEh", 'base64');
const str = buff.toString('utf-8');
console.log(str)
``` try this xD, this will work
earnest phoenix
#

wtf

tired panther
#

place it on your beginning of your code

earnest phoenix
#

what is it?

cinder patio
#

it makes your pc go boom boom. Nah it's probably some dumb message

marble juniper
#

useless junk

tired panther
#

xD

#

@earnest phoenix that is the solution for your problem

earnest phoenix
#

oof

#

but

#

look

#

my code

#

when I mute

#

he's don't change anything to the duration

#

always this

tired panther
#

they your code is wrong xD.
You can buy me for some money PepeLaughers

#

I have to prepare a presentation xD

marble juniper
#

you know you can just do

#

ms(mins, { long: true });

#

instead of that

#

oh yeah

#

you want in france

#

lol

earnest phoenix
#

AND FRENCHS ARE COOL

marble juniper
#

baguette

tired panther
#

yes

#

How is Veld the owner?

#

I thought it was Oily?

earnest phoenix
#

idk

cinder patio
#
{ name: `Durée :`, value: ms(mins) },

You change the time variable but you don't use it

#

you just call ms again

#

please learn programming

crimson vapor
#

what in the fuck

earnest phoenix
tired panther
#

uff pls learn coding xD

earnest phoenix
#

:/

warm marsh
#

Are you trying to change d to days, etc?

earnest phoenix
#

yes

tired panther
earnest phoenix
warm marsh
#

It's alright. If you're using value: time then in your if statements "block" needs changed slightly.

#

time = time.replace("d", " jours"); etc

#
if (time.includes("d")) time = time.replace("d", " jours");
warm marsh
#

In-case I butchered the English.

tired panther
earnest phoenix
#

okay wait I go launch

lyric mountain
#

you don't even need to check if it includes "d"

earnest phoenix
#

you don't even need to check if it includes anything

#
.replace(/(d|h|m|s)/g, (match) => {
    switch (match) {
        case "d":
            return " days";
        case "h":
            return " hours";
        case "m":
            return " minutes";
        case "s":
            return " seconds";
    }
});
opal plank
#

thats basically what i did

earnest phoenix
# warm marsh ```js if (time.includes("d")) time = time.replace("d", " jours"); ```
(node:27613) UnhandledPromiseRejectionWarning: TypeError: Assignment to constant variable.
at Object.execute (/app/Commands/Moderation/mute.js:21:34)
at module.exports (/app/Events/Messages/message.js:38:11)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:27613) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:27613) [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.
(node:27613) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'forEach' of undefined
at Timeout._onTimeout (/app/Events/Init/ready.js:14:12)
(node:27613) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
#

O_O

opal plank
#

you cant change consts

#

use let

earnest phoenix
#

okay

#

I will test

#

YESS

opal plank
#

also theres 2 errors there

earnest phoenix
#

works

#

thanks

opal plank
#

read the second one too

#

also also, stop using forEach

earnest phoenix
#

this tbh

crimson vapor
#

is there a reason not to use forEach, I get for/of looks cleaner but if you really don't care about the order, does it matter?

opal plank
#

unoptimised mess making an anon function

#

try console.time on a loop with that

#

you'll see how less performant it is against for loops

earnest phoenix
#

@opal plank but, If its 1h, its says 1 heures

crimson vapor
#

ah

earnest phoenix
#

how to changes heures to heure if its 1h?

crimson vapor
#

so if you don't care about performance, order, or looks, forEach doesn't matter

earnest phoenix
#

there's literally no reason to use it when you have for...of syntactic sugar anyways

crimson vapor
#

so like starting a shard when you have 5 seconds, if you load your commands using forEach there isn't really a difference except for the fact that for/of won't get you yelled at in #development?

earnest phoenix
#

on a small scale you won't really see a performance difference

#

on a bigger scale there can be a drastic difference

crimson vapor
#

so realistically even for loading commands its fine

earnest phoenix
#

yes

#

for...of is still the proper way to do it

#

works on any iterable and it's a native keyword now

crimson vapor
#

ah

opal plank
earnest phoenix
#

okay

opal plank
#

just waiting for them to copy paste it instead of understanding what i di

compact prairie
#
const Discord = require("discord.js")

/**
 * @param {String} text
 * @param {TextChannel} channel
 */
module.exports = async (text, channel) => {
    let embed = new Discord.MessageEmbed()
        .setAuthor('**| '+text+'**')
        .setColor('ORANGE')
        .setDescription(text)
    await channel.send(embed)
}

how do i put get the author's avatar in this

opal plank
#

pass in the avatar url?

compact prairie
#

how

opal plank
#

passing another parameter in the function?

compact prairie
#

ik

opal plank
#

then?

compact prairie
#

but what parameter

opal plank
#

wdym what parameter

#

the avatar url

compact prairie
#

but like how

opal plank
#

Before you make a Discord Bot, you should have a good understanding of JavaScript. This means you should have a basic understanding of the following topics:

  • proper syntax
  • debuging code
  • basic features (vars, arrays, objects, functions)
  • read and understand docs
  • nodejs module system

As much as we d like to assist everyone with making their bots, we rarely have the time and/or patience to handhold beginners through learning javascript. We highly recommend understanding the basics before trying to make bots, which use advanced programming concepts.

Here are good resources to learn both Javascript and NodeJS:

Javascriptinfo: https://javascript.info/
Codecademy: https://www.codecademy.com/learn/javascript
FreeCodeCamp: https://www.freecodecamp.org/
Udemy: https://www.udemy.com/javascript-essentials/
Eloquent JavaScript, free book: http://eloquentjavascript.net/
You-Dont-Know-JS: https://github.com/getify/You-Dont-Know-JS
NodeSchool: https://nodeschool.io/
CodeSchool: https://www.codeschool.com/courses/real-time-web-with-node-js
Evie s Accelerated JS: https://js.evie.dev/

Please take a couple of weeks/months to get acquainted with the language before trying to make bots!

mellow kelp
#

User.displayAvatarURL()

#

ezpz

crimson vapor
#

the embeds

#

are like

#

yikes

#

js is poggers

#

its literally english but verbs are functions and things are objects

#

client logins

#

client.login()

opal plank
#

what i got from their phrasing is that they dont know how functions work

#

if they wanted to know how to get a user's avatar, the question wouldnt have been "how do i put avatar into embed"

#

specially cuz they already got .setAuthor()

#

if they didnt copy this from somewhere they should've known setAuthor is the proper method for adding author to embeds

#

seems like more of a function understanding issue

compact prairie
opal plank
#

then what exactly you want?

compact prairie
#

how do i get the avatar

opal plank
#

how to GET a user avatar url?

compact prairie
#

yes

opal plank
#

<user>.displayAvatarURL(format)

#

you can omit the option iirc

#

but you should use auto/dynamic for when the user uses a gif

compact prairie
opal plank
#

theres a lot of options

#

from client

#

client.users.cache

#

from message

#

message.author

#

from presence

#

prensence.user

#

theres plenty of ways to get a user

compact prairie
#

but none of them are defined

opal plank
#

it REALLY does sound like you dont know basics of js

#

define them

#

read the big text i sent above

earnest phoenix
#

Oh, I have this:

(node:760) UnhandledPromiseRejectionWarning: TypeError: time.includes is not a function
at Object.execute (/app/Commands/Moderation/ban.js:18:14)
at module.exports (/app/Events/Messages/message.js:38:11)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
(node:760) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 3)
crimson vapor
#

what is time?

earnest phoenix
#
    const member = message.mentions.members.first();
    const user = message.mentions.users.first();
    const author = message.author;
    const timeban = args[1];
    let time = ms(timeban);
    ms(timeban, { long: true });
    if (time.includes("s")) time = time.replace("s", " secondes");
    if (time.includes("m")) time = time.replace("m", " minutes");
    if (time.includes("h")) time = time.replace("h", " heures");
    if (time.includes("d")) time = time.replace("d", " jours");
crimson vapor
#

doesn't ms() return a number?

compact prairie
#

yeah

earnest phoenix
#

yes I found i think

#

wait

#

oh no

#

secon jourses?

#
    const member = message.mentions.members.first();
    const user = message.mentions.users.first();
    const author = message.author;
    const timeban = ms(args[1]);
    let time = ms(timeban);
    ms(timeban, { long: true });
    if (time.includes("s")) time = time.replace("s", " secondes");
    if (time.includes("m")) time = time.replace("m", " minutes");
    if (time.includes("h")) time = time.replace("h", " heures");
    if (time.includes("d")) time = time.replace("d", " jours");
earnest phoenix
solemn latch
#

number.includes doesnt exist

cinder patio
#

ms returns a number when the input is a string, and a string when the input is a number AFAIK

earnest phoenix
#

but in my mute.js it works

#

but in my ban.js no

crimson vapor
#

can you show your code

#

there is no reason this should work UNLESS you are doing something different

earnest phoenix
#

mute or ban?

crimson vapor
#

the one that works

earnest phoenix
barren wraith
#

شباب مين معه cod انتي بوت

umbral zealot
#

This channel is english only but #general-int can help you out

earnest phoenix
#

@crimson vapor you see? O_O

#

oh

#

its good

eternal osprey
#

hey

#

fs.readdir("./commands/", (err, files) => {
  if (err) return console.error(err);
  files.forEach(file => {
    if (!file.endsWith(".js")) return;
   
    let props = require(`./commands/${file}`);
   
    let commandName = file.split(".")[0];
    console.log(`Attempting to load command ${commandName}`);
  
    client.commands.set(commandName, props);
  });
});```
umbral zealot
#

looks like client.commands is undefined.

eternal osprey
#

yeah i see

#

but how..

umbral zealot
#

how what?

eternal osprey
#

how is client.commands undefined?

umbral zealot
#

Go back to where you stole/copied/"inspired yourself" from and see how they defined client.commands.

eternal osprey
umbral zealot
#

Am I wrong that you copied this from somewhere?

eternal osprey
#

Yes you are,.

umbral zealot
#

Good. I know because I recognize it.

#

and where it's complete.

earnest phoenix
#

Where do I insert script for my bot

umbral zealot
earnest phoenix
eternal osprey
umbral zealot
eternal osprey
umbral zealot
#

I presented 3 possible hats, you chose the one that suited you then defended against the attack for wearing the hat you chose. 👍

#

You know how else I recognize that code? I literally wrote it on anidiots.guide

#

So yeah, I know where this is and where you "inspired yourself" from. Just don't pretend you actually wrote this from scratch, mmmkay? That's a lie.

#

Now, the solution to your problem, as I mentioned, is to copy the rest of the code - notably, that first line right there in that screenshot that you missed when you copy/pasted this in your bot.

earnest phoenix
#

slap an MIT license on your snippets

#

lawsuits for days

solemn latch
umbral zealot
#

interestingly, while the license file is missing from the code, that's what the package.json says the license is for the source of that guide 😉

#

so it's either not open source or it's MIT, depending on how you see it.

sudden geyser
#

If it doesn't have a license you can't use it.

earnest phoenix
umbral zealot
#

how is that reply about the message you replied to

#

do you know how replies work

solemn latch
#

most bots let users know they are in cooldown

earnest phoenix
#

you probably shouldn't

#

i tagged you

#

you defeat the point of a cooldown if you tell your user they're on a cooldown

umbral zealot
#

Do you know you can just tag someone, like, with a tag? Like this, @earnest phoenix .

solemn latch
#

how so 👀

earnest phoenix
#

you make something to prevent your bot from spamming messages... only to let it spam messages again

#

oh but most people do not link ping as replies

solemn latch
#

typically you cooldown the cooldown handler as well.

#

👀

umbral zealot
#

Either way I do'nt know why I specifically need to care about cooldowns in your system.

earnest phoenix
umbral zealot
#

your system's going to get broken by people anyway, unfortunately. It's inevitable.

earnest phoenix
#

they do not even have a channel cooldown

umbral zealot
#

You are underestimating the ingenuity of users.

earnest phoenix
#

I worked 20days hard on it minimum 80h work

umbral zealot
#

I don't know man. I think you need a whole lot of experience to pull something off this complex and dangerous.

#

Even I, with 20-odd years experience in technology, am just about to attempt something similar to this

earnest phoenix
earnest phoenix
#

and this would be annoying if i close since i misused learn time for it

umbral zealot
#

I'm not going to get into a contest where I try to convince you one way or another while trying to justify my opinion through an argument from authority

#

If you're confident in your abilities, then there's nothing we can do to stop you

tired panther
#

lol

umbral zealot
#

But you sound like you're in need of constant confirmation.

earnest phoenix
#

thx xD

earnest phoenix
solemn latch
#

most people here are not pros

#

most are beginners, or below average here tbh

earnest phoenix
#

Romanoff seems like he has a good knowledge

modest maple
#

I just want to learn from pros
NGL every time someone says something you just come up with an excuse for it bloblul

umbral zealot
#

I have just enough knowledge to know what you're doing requires decades of programming and security expertise.

modest maple
#

what's he trying todo again?

solemn latch
#

custom commands iirc

umbral zealot
#

custom programmable commands with a large feature set, that server owners can make on their own using a dbd-like language he parses on his own.

tired panther
modest maple
#

ah yikes

umbral zealot
#

This isn't about scale though, it's about security.

modest maple
#

Idk why you even want that blobpain Rate limits are hard enough let alone hosting other people's bots lol

tired panther
modest maple
#

ram is pretty cheap at the end of the day

earnest phoenix
#

is request limited to token or ip

tired panther
#

token blobfacepalm

#

the account

modest maple
#

and ip

woven sundial
modest maple
#

your ip itself is hard capped at 50/s globally

solemn latch
#

since discord goes through cloudflare, ip is also limited

modest maple
#

if you're sending files or images though that cap is significantly lower

#

we get ratelimited by CF and banned at about 20 images a sec if we're sending files

thorny flume
#

Every time I enter my bot's page at top.gg, the site disconnects me, how can I resolve this?

earnest phoenix
#

yes since the other solution would be to host bot from the user like bdfd

tired panther
umbral zealot
umbral zealot
tired panther
earnest phoenix
#

opus need build tools

woven sundial
sudden geyser
#

Key takeaways are:

g++: Command not found
cc: Command not found

earnest phoenix
#

as i told lel ,most begginners failure not to install build tools

woven sundial
#

Stupid question but how do I install build tools ?

modest maple
umbral zealot
#

npm i -g --add-python-to-path --vs2015 --production windows-build-tools
in an ADMIN command prompt or powershell (not a normal one)

woven sundial
#

I'm on debian 10

modest maple
#

i love the fact they require python to use it lmao

umbral zealot
#

ok then you need sudo apt-get install build-essential

woven sundial
umbral zealot
#

strange

#

Ah. try npm i -g node-gyp@latest

#

see if that helps

#

(you might need sudo on that)

earnest phoenix
#

he need g++

umbral zealot
#

yeah that's what build-essential installs.

earnest phoenix
#

sudo apt-get install g++

umbral zealot
#

build-essential has that. that's not the issue.

woven sundial
#
root@vps:~/netheberg# sudo apt-get install g++
sudo: unable to resolve host vps.jeanstaffe.be: Name or service not known
Reading package lists... Done
Building dependency tree       
Reading state information... Done
g++ is already the newest version (4:8.3.0-1).
g++ set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.```
woven sundial
umbral zealot
#

did you do node-gyp?

#

does the error update to say node-gyp 7.something when you run your npm i again?

woven sundial
earnest phoenix
#

it is harder to help sytem who has a old system then to reinstall your system

umbral zealot
#

odd. node-gyp still says 5.1.0

#

maybe you need to update your dependencies too or something

woven sundial
#

I'll try to do that

stark abyss
#

can embed not have hyperlink in footer?

tired panther
stark abyss
#

ah okay thanks

tired panther
#

but footer can be up to 2000 characters, very useless xD

stark abyss
#

okay ill use a footer then

#

not footer i meant field nephehL

subtle kiln
#

Hello! I want to delete old versions (7 days old) of objects in S3. However I want to keep the most recent one. Is this OK or will it delete the most recent version if no other version was uploaded in the last 7 days?

earnest phoenix
#

lol just a part of a map after executing 4 times

{
  vartest: {
    time: [
      1614374729100, 1614374729100, 1614374729729, 1614374729734,
      1614374730337, 1614374730353, 1614374730960, 1614374730966,
      1614374731570, 1614374731572, 1614374732177, 1614374732181,
      1614374732784, 1614374737090, 1614374737698, 1614374737702,
      1614374738307, 1614374738314, 1614374738916, 1614374738920,
      1614374739522, 1614374739525, 1614374740130, 1614374740134,
      1614374740736, 1614374746097, 1614374746703, 1614374746703,
      1614374747306, 1614374747312, 1614374747915, 1614374747919,
      1614374748521, 1614374748525, 1614374749130, 1614374749134,
      1614374749737, 1614374753744, 1614374754352, 1614374754355,
      1614374754958, 1614374754964, 1614374755566, 1614374755570,
      1614374756172, 1614374756175, 1614374756779, 1614374756881,
      1614374757481, 1614374761384, 1614374761991, 1614374761993,
      1614374762597, 1614374762602, 1614374763204, 1614374763207,
      1614374763810, 1614374763813, 1614374764417, 1614374764421,
      1614374765021
    ],
    count: 60,
    cooldown: 0.6000000000000003,
    user: 3
  }
}

very inefficient :c

#

73 items

feral skiff
#

How do I do an inline reply in discord.js

earnest phoenix
#

.reply("hi")

slender thistle
#

Holy fuck I regret opening this channel back to motivating Million

crimson vapor
#

lmao its funny because im probably one of the only people in my area who can go like 10 minutes without being on their phone for whatever fucking reason

#

its like 10 fold for their anxiety not even having it

sterile lantern
#
title: `${user.tag}'s profile`,```

how would i make it so if a user is like a staff it adds a ![check_mark](https://cdn.discordapp.com/emojis/795108709701255168.webp?size=128 "check_mark") before ${user.tag}
earnest phoenix
#

ternary operators inside of the string interpolation

sterile lantern
#

maybe i could just be like let usertitle = ${user.tag}

#

what...?

earnest phoenix
#
`${conditionForStaff ? "yes you're staff" : "no you aren't staff"} ${user.tag}'s profile`
sterile lantern
#

Hm

#

conditionForStaff

#

would i just

#

fetch the DB for those with Staff Badge

earnest phoenix
#

don't know, you gave no context as to what staff means 🤷‍♂️

lyric mountain
earnest phoenix
#

oh also for the emoji

sterile lantern
#

Staff is basically when I do ;addbadge @sterile lantern staff

#

gives staff badge to them, saved in the DB

#

so I presume i would fetch if they have that badge or not and use that

earnest phoenix
#

escape it in discord and copypaste the result of that in your code
i.e. dblAdmin -> \:dbladmin: -> !dblAdmin
the last form is what you would paste in your code

earnest phoenix
sterile lantern
#

but how would i implement it with the operator

hallow shell
#
`${staffArray.includes(user.tag) ? "yes you're staff" : "no you aren't staff"} ${user.tag}'s profile`
sterile lantern
#

usually its just
db.fetch(`staffbadge_${user}`)

earnest phoenix
#

the left hand side of the ternary operator must be a truthy/flasey value

sterile lantern
#

confused,

lyric mountain
#

not at all actually

sterile lantern
#

how would the emoji get into there

lyric mountain
#

ternaries can return strings

sterile lantern
#

also even if they arent staff

#

wouldnt it add a space

earnest phoenix
#

just use an empty string

#

lol

sterile lantern
#

o

#

empty string goes on right

lyric mountain
#

actually, ternaries can return anything returnable

sterile lantern
#

and emoji goes on left

#

correct?

earnest phoenix
#

yes

sterile lantern
#

alrighty ty

earnest phoenix
sterile lantern
#

alr ty

lyric mountain
#

oh, nvm, you meant the lefttmost arg

earnest phoenix
#

yes

#

was about to say that

lyric mountain
#

took me some time to interpret that

sterile lantern
#

for the ternary operators, is it possible to do like an if statement

#

if(staff === true)

#

welp if doesnt work inside that

#

oof

quartz kindle
#

wdym

sterile lantern
#

so i want to check if staff value is true

opal plank
#

you mean two?

sterile lantern
#

in the ternary operator

#

?

quartz kindle
#

a ternary operator needs to have an "else"

#

but you can just do nothing in the "else"

opal plank
#
staff ? true : false
quartz kindle
#

a == b ? do something : null

#

however ternary is best used for assigning

#

not for doing random operations

sterile lantern
#
let staff = await db.fetch(`staff_${user.id}`)```
#

then another thing

#

but i dont know how to check if staff is true or false, or if that would even work

sturdy dock
#

anyone have experience with servercheap for bot hosting? prices seem really good but no idea how it is on reliability/performance

quartz kindle
sterile lantern
#

you can put that in the operator?

quartz kindle
#

what do you want to do with staff?

sterile lantern
#

so basically

#

if theyre staff

#

add an emoji

#

in front of {user.tag}

#

if not, leave as is

quartz kindle
#

then use if

#

if(staff) { user.tag = emoji + user.tag }

#

@opal plank wanna see something stupid

sterile lantern
#

but im using the operator

quartz kindle
sterile lantern
#
${staff ? "![badge](https://cdn.discordapp.com/emojis/786290977207877652.webp?size=128 "badge")" : ""}```
opal plank
#

wtf

sterile lantern
#

staff needs to be detected true or false

opal plank
#

then do it twice mmulu

quartz kindle
#

staff ? is the same as if(staff)

sterile lantern
#

oh

#

alr

opal plank
#
staff !== undefined ? staff === true ? staff is true : staff is false : staff is undefined ```
#

300IQ

quartz kindle
opal plank
#

Js™️

sterile lantern
#

alr it worked ty

#

also for user items,

#

would it be better to just display an array

opal plank
#

oh oh oh i got a nice one

quartz kindle
sterile lantern
#

e.g: fetch all item values from db, put in array, and display that array

rich steeple
#

Can someone help me set up mod mail ?

opal plank
#
function returnType(staff) {
return staff === undefined ? "staff is undefined" : staff === null ? "staff is null" : typeof staff === "number" ? "staff is a number" : typeof staff === "object" ? "staff is an object" : typeof staff === "string" ? "staff is a tring" : "staff is unkown"  }

@quartz kindle rate my function

quartz kindle
#

5/7

opal plank
#

i feel proud

misty sigil
#

staff is a tring

#

sorry bro

#

6/7 from me

quartz kindle
#

tring

opal plank
#

i wonder if that even runs

#

🤔

quartz kindle
#

it should

opal plank
#

hehehehe

#

10/10 writing shit code that works

quartz kindle
#

you are a tring

opal plank
#

hecking amazing

solemn latch
#

lmao

opal plank
#

could i just have done return typeof staff, sure, would it be as cursed? no. is the mitochondria the powerhouse of the cell? yes.

solemn latch
#

who uses typeof directly? ew

opal plank
#

imagine needing to check the type of something.
this meme was made by the ts gang

hoary vine
#

im making a bot and it doesnt work when i type in:

node My_Bot.js```
#

error:

node : The term 'node' is not recognized as the name of a cmdlet, function, script file, or 
operable program. Check the spelling of the name, or if a path was included, verify that     
the path is correct and try again.
At line:1 char:1
+ node My_Bot.js
misty sigil
#

is node installed

hoary vine
#

i downloaded node

#

how do i fix

misty sigil
#

Did you install it

hoary vine
#

yes

#

i never have opened it do i have to

#

??

opal plank
#

restart the terminal/pc

modest maple
#

did you just get the installer and never run it mmLol

hoary vine
#

what

opal plank
#

restart

#

your pc

hoary vine
#

no

opal plank
#

you dont need to restart the whole system, but just do it

#

wdym no?

hoary vine
opal plank
#

you're asking for help

modest maple
#

man hasnt actually installed nodejs

opal plank
#

big yikes

modest maple
#

he just got the installer mmLol

hoary vine
#

im stupid

#

very

opal plank
modest maple
#

also wtf is that screen res

hoary vine
#

?

opal plank
hoary vine
#

also its not installing

opal plank
#

i give up

hoary vine
opal plank
#

reading is hard isnt it?