#development

1 messages ยท Page 1432 of 1

old cliff
#

if I change variable name in 1st statement then it shows no error

pure lion
#

People seem angry

#

@old cliff what did you do

#

What have you done ooohhhhh

old cliff
#

read @pure lion

pale vessel
#

It depends on the block

pure lion
#

It should be in the same scope

pale vessel
#

Do you use {} for your cases?

old cliff
#

no

pale vessel
#

If not it'll error

#

Yeah

old cliff
#

: for a case

pure lion
#

Flashbacks to when I used a switch case block for my commands ๐Ÿคฎ

pale vessel
#

case "a": {

}
won't error

old cliff
#

ok

#

i'll try

#

Yeah that works

#

thanks

old cliff
#

Anyone knows a cheat way to know which property of a channel changed when it is edited ? to just get a list of all edits make in that channel ? cause it takes way too much effort to check every property.

dull bramble
#

Hey does anyone know how to make the bot send the current slowmode in the channel the command was fired in? (discord.js)

old cliff
#

find it using message.channel property

dull bramble
#

mhm

reef mantle
#

Hello

#

Can someone help me with welcome command pls?

old cliff
#

message.channel.rateLimitPerUser @dull bramble

#

gives the slowmode

#

in seconds

dull bramble
#

ty

reef mantle
#

@old cliff can ya help me too?

#

@dull bramble maybe?

#

Can anyone help?

#

How to make a welcome code?

silent cloud
#

You guys, can somebody help me

#

My friend gave me this code part, but it haves an error

#
bot.setInterval(()=> { bot.sweepMesages(86400)}, 3600000);```
#

bot.sweepMesages is not a function
at Timeout._onTimeout

#

That's part should clear memory cache every hour

reef mantle
#

I guess you can help me

#

Do you know a code for a welcome command?

dull bramble
#

Yo, anyone know how I could make a set slowmode command?

reef mantle
#

Slowmode like with Time out?

dull bramble
#

Like normal discord channel slowmode

old cliff
#

@silent cloud its messages not mesages

#

U have a typo

#

use this

#

bot.setInterval(()=> { bot.sweepMessages(86400)}, 3600000);

silent cloud
old cliff
#
{
  'rateLimitPerUser': '10'
}
);```

replace 10 with new slowmode
dull bramble
#

Alright

silent cloud
#

Thz jaguar now it workinf

old cliff
#

if your bot does logging then removing messages from cache is not recommended

#

cause then the event will not trigger

#

if a message is deleted,edited,etc.

#

@silent cloud

silver lintel
#
const config = require('../../config.json');
const $ = require("discord.js").MessageEmbed;
module.exports = {
  name: 'help',
  aliases: ['commands'],
  cooldown: 3,
  description: 'List all of my commands or info about a specific command',
    usage: '<command>',
  type: 'info',
  permissions: ['SEND_MESSAGES'],
  execute: (message, args) => {
    const embed = new $()
.setColor(config.color)
.......
  }
}

cannot access 'config' before initialization

reef mantle
#

Guys

lusty quest
silver lintel
#

thats how im loading them

lusty quest
#

in your bot on ready event or in your main file?

reef mantle
#

My log says
UnhandledPromiseRejectionWarning : FetchError: request to discord.com/api/v7/gateway/bot failed, reason: getaddrinfo ENOTFOUND discord.com

silver lintel
#

main file

reef mantle
#

What does this mean guys?

lusty quest
#

is your json static or for god not say it a Database

reef mantle
#

Me?

silver lintel
lusty quest
silver lintel
#

json?

lusty quest
#

the config you load in your command is a json file

#

also is the path to the json correct?

silver lintel
#

static

silver lintel
lusty quest
#

strange.

#

i dont see why it wont load the json

silver lintel
#

hm

lusty quest
#

what is the output if you use a console.log(config) in your command

old cliff
#

try using a different variable name

silver lintel
#

its not logging

lusty quest
#

did you comment out the error?

silver lintel
#
module.exports = {
  name: 'help',
  aliases: ['commands'],
  cooldown: 3,
  description: 'List all of my commands or info about a specific command',
    usage: '<command>',
  type: 'info',
  permissions: ['SEND_MESSAGES'],
  execute: (message, args) => {
    console.log(config)
}}``` when i do this config is what config.json is
lusty quest
#

wired

silver lintel
#

ik its not efficient ;-;

lusty quest
#

wtf. lookup how to make a dynamic generated help command

silent cloud
#

Was 150mb now 175mb

#

It rising

lusty quest
#

without setColor and setThumpnail does it work?

lusty quest
silent cloud
#

I have memory leaks

lusty quest
#

how did you know this?

silent cloud
#

I want to fix it or clear memory cache every hour

silent cloud
#

But bot doing nothing

lusty quest
#

this doesnt indicate directly a memory leak

#

did you use stuff that renders to the buffer?

silent cloud
#

And my friend say about that, he 100% knows

lusty quest
#

what language did you use?

silent cloud
#

Node js

lusty quest
#

libary?

silent cloud
#

Uhhhh

lusty quest
#

discord.js?

silent cloud
#

V12

#

Ye

lusty quest
#

ok. if you have issues with high ram usage maybe look into discord.js-light. your increasing ram usage could be that the bot starts to Cache more and more users, messages and the other stuff

silent cloud
#

What?

lusty quest
#

this is a thing i dislike on D.js v12 it caches everything

silent cloud
#

Change discord.js to discord.js-light?

lusty quest
#

yes its pretty much the same but with way more control about what is cached

silent cloud
#

Hmmm

lusty quest
#

the creator of the lib is also here on the discord server

gusty quest
#

(node:9432) UnhandledPromiseRejectionWarning: ReferenceError: response is not defined but its defined here const response = await msg.awaitReactions(filter, { max: 1, time: 8.64e+7 });

lusty quest
#

i think the time is the issue

gusty quest
#

oh

#

okay let me see

silent cloud
#

Sounds good

lusty quest
#

but with d.js-light you have to code certain stuff differently

#

not much but its needed to get it to work

gusty quest
#

its not :d

#

time issue

quartz kindle
#

@gusty quest show more code

gusty quest
#

im gonna send u in dm

quartz kindle
#

You have return undefined

silent cloud
#

Ok

#

I installed it

quartz kindle
#

Also youre not actually calling the function?

silent cloud
#

Lets try

quartz kindle
#

Actually just remove the function lol, use the code directly

silent cloud
#

Oh yea

lusty quest
#

also tim here is the creator of d.js-light

silent cloud
#

Old discord was 150mb, now 130-134mb

#

Rly?!?!?

lusty quest
#

you can get the ram usage even more down i guess. how many guilds did you use?

silent cloud
#

I have 25 guilds

#

And 5 shards

lusty quest
#

wtf?

#

why

silent cloud
#

Lol ye?

lusty quest
#

you dont need a shard if you are not close to 1k guilds

gusty quest
silent cloud
#

Yep, but im looking in future

lusty quest
#

i have ~100MB ram usage with ~300 Guilds

silent cloud
#

And now idk how to up my guilds

#

Bcs i want to verify my bot

lusty quest
#

the running shards could cause your memory usages

quartz kindle
#

I have 130mb with 6000 guilds

silent cloud
#

Maybe create only 2 shards?

lusty quest
#

you only need 1

quartz kindle
#

Are you using the sharding manager?

silent cloud
#

Ye

quartz kindle
#

You can switch to internal sharding

silent cloud
#

What it doing?

quartz kindle
#

Sharding manager is 1 shard = 1 process

#

So 5 shards = 5 processes, aka, 5 node.js running at once

#

Internal sharding is 1 process = multiple shards

#

So you only have 1 nodejs running and all shards are inside it

silent cloud
#

Hmmm

#

Sound good, but how

quartz kindle
#

Delete the sharding manager

#

And in your main file, put in your client options: shards:[0,1]

#

For 2 shards

#

Or [0,1,2,3,4] for 5 shards

silent cloud
#

Understood

#

Lets try

#

And yo

#

Discord.js-light cool

#

Bcs now it use onlt 127mb

#

So cool rly

quartz kindle
#

Thx :)

#

If you code it right, you can use as little as 50mb

lusty quest
#

but then it starts to get annoying

quartz kindle
#

Lmao

#

You need to give up on permissions and a bunch of other stuff

lusty quest
#

with running a better memory allocator you can also cut down on a bit of memory usage

#

but yea

silent cloud
#

Hm tim

#

Why now bot doesnt show users size

lusty quest
#

if you have a dumb bot with only a few commands or run all configs over a website you could get it to work

silent cloud
#

It say i have only 1 users

lusty quest
#

bcs users are not cached

silent cloud
#

But was over 40k

#

Oh

#

Rly

quartz kindle
#

Its written in the readme

silent cloud
#

I need change false to true?

quartz kindle
#

Users are "all or nothing"

silent cloud
#

Ohhh

quartz kindle
#

If you want users, you need to fetchAllUsers

#

Those 40k you had are not all users

#

Only a part of them

#

Anyhow having them cached is not needed most of the time

silent cloud
#

I dont understand what to do

quartz kindle
#

If you can use guild.memberCount for counting users

silent cloud
#

I need not guild member

#

I need all bot members

quartz kindle
#

If you need users, you have to use fetchAllMembers

#

In your client options

#

fetchAllMembers:true

#

But this will make your bot use much more memory

#

If you need that, better stick with discord.js

silent cloud
#

Ohhhhh

#

Better i delete *users command and users on shard from bot status

quartz kindle
#

You can use guild.memberCount

#

That will give you the total number of members in a server, including bots and including offlines

#

You can filter servers by guild.shardID

#

And add the member counts of each server and each shard id

silent cloud
#

Bruh

#

Rly, bettee i will remove just users.size

gusty quest
#

so i now made to remove users reaction but it removes all reactions here is code msg.reactions.cache.get("๐Ÿ”‡").remove(message.author.id)

earnest phoenix
#

discord bot animated avatar??

junior anvil
#

uhh does anyone here use discord js?

earnest phoenix
#

yap

#

i am

junior anvil
#

oh ok

#

Nice

lusty quest
#

discord bots can use gifs as avatars

gusty quest
#

how

junior anvil
#

hmm

earnest phoenix
#

@lusty quest OOO YES THANKS

junior anvil
#

maybe go to the application and add the gif

#

i think...

eternal osprey
#

hey could anybody help me with a heroku problem?

lusty quest
eternal osprey
#

postinstall script permission denied

lusty quest
#

heroku doesnt allow all npm modules

eternal osprey
#

damn

#

i was thinking

lusty quest
#

one reason more why free hoster suck

eternal osprey
#

can't i just use pm2 on a vmbox to let it run 24/7

lusty quest
#

where?

eternal osprey
#

on virtualbox

gusty quest
lusty quest
#

on your pc, a server or samsung smart fridge?

eternal osprey
#

it basically isn't my pc anymore

lusty quest
gusty quest
#

yes

eternal osprey
#

it is a virutal computer basically.

gusty quest
#

im not good at english

#

so idk what did u say

#

bruh

#

its time for google transtlate

quartz kindle
lusty quest
#

buy somewhere a raspberry pi and let it run off there

timber fractal
#
const canva = require('canvacord');
const Discord = require('discord.js')

module.exports = {
    name: "trigger",
    description: "Trigegr yourself",


    async run (client, message, args) {
        if(args[0]) return 
        let avatar = message.author.displayAvatarURL({dynamic: false, format: "png"});

        let image = await canva.Canvas.trigger(avatar);
    
        let triggered = new Discord.MessageAttachment(image, "triggered.gif")
            
        message.channel.send(triggered);
    
        const member = message.mentions.members.first() || message.guild.members.cache.get(args[0]);

        if(!member) return message.channel.send(`Please enter a VALID member!`)

        let avatar2 = member.displayAvatarURL({dynamic: false, format: "png"});

        let image2 = await canva.Canvas.trigger(avatar2);

        let triggered2 = new Discord.MessageAttachment(image2, "triggered.gif")

        message.channel.send(triggered2)
    }
}``` Why is this not working??
lusty quest
#

did you still havent figured out how to debug it?

eternal osprey
#

same goes with pm2 right?

timber fractal
#

@lusty quest me??

lusty quest
#

yes

timber fractal
#

yes i did but now i tried 1 so u can also trigger someone else

#

like

#

it worjs

#

works*

#

but i want it so u can trigger someone else

lusty quest
#

your error yesterday stated that trigger where not working, then someone told you that you used an outdated tutorial

timber fractal
#

yes

#

but i fixed that

#

and now i tried to make it so u can also trigger someone else

lusty quest
#

if you want to use an other user with an mention work with mentions

timber fractal
#

i just want it so u can trigger someone else

lusty quest
#

a random user or a spezific one

timber fractal
#

specific like u say trigger @Superbrain8#4020

#

and than it triggers u

lusty quest
#

then learn how to handle mentions

timber fractal
#

-_-

#

i used something like this too in another command and that works

lusty quest
#

what exactly does your current code?

timber fractal
#

it sends a gif with you and under that there is "TRIGGERED"

lucid prawn
#

my error
DiscordapiError cant send an empty message
just stated now

timber fractal
molten yarrow
lusty quest
#

but in a different way

molten yarrow
#

thats why i told him, he should add it on the first line

lucid prawn
molten yarrow
#

your message is empty

lucid prawn
#

but it not

timber fractal
#

@molten yarrow i used this code

const canva = require('canvacord');
const Discord = require('discord.js')

module.exports = {
    name: "trigger",
    description: "Trigegr yourself",


    async run (client, message, args) {
        const member = message.mentions.members.first() || message.guild.members.cache.get(args[0]);
        if(args[0]) return 
        let avatar = message.author.displayAvatarURL({dynamic: false, format: "png"});

        let image = await canva.Canvas.trigger(avatar);
    
        let triggered = new Discord.MessageAttachment(image, "triggered.gif")
            
        message.channel.send(triggered);

        if(!member) return message.channel.send(`Please enter a VALID member!`)

        let avatar2 = member.displayAvatarURL({dynamic: false, format: "png"});

        let image2 = await canva.Canvas.trigger(avatar2);

        let triggered2 = new Discord.MessageAttachment(image2, "triggered.gif")

        message.channel.send(triggered2)
    }
}```
and it tells this
molten yarrow
cursive forge
#

abort(DiscordAPIError: Missing Permissions) How would I make it say Missing Embed links permission

molten yarrow
lusty quest
#

get the image from the member not the author

molten yarrow
lucid prawn
timber fractal
#

@molten yarrow i have this

const canva = require('canvacord');
const Discord = require('discord.js')

module.exports = {
    name: "trigger",
    description: "Trigegr yourself",


    async run (client, message, args) {
        const member = message.mentions.members.first() || message.guild.members.cache.get(args[0]);
        if(args[0]) return 
        let avatar = member.displayAvatarURL({dynamic: false, format: "png"});

        let image = await canva.Canvas.trigger(avatar);
    
        let triggered = new Discord.MessageAttachment(image, "triggered.gif")
            
        message.channel.send(triggered);

        if(!member) return message.channel.send(`Please enter a VALID member!`)

        let avatar2 = member.displayAvatarURL({dynamic: false, format: "png"});

        let image2 = await canva.Canvas.trigger(avatar2);

        let triggered2 = new Discord.MessageAttachment(image2, "triggered.gif")

        message.channel.send(triggered2)
    }
}```
and it still gives my image
lusty quest
#

you dont need avatar2 image2 and triggered2 anymore

timber fractal
#

ok

#
const canva = require('canvacord');
const Discord = require('discord.js')

module.exports = {
    name: "trigger",
    description: "Trigegr yourself",


    async run (client, message, args) {
        const member = message.mentions.members.first() || message.guild.members.cache.get(args[0]);
        if(args[0]) return 
        let avatar = member.displayAvatarURL({dynamic: false, format: "png"});

        let image = await canva.Canvas.trigger(avatar);
    
        let triggered = new Discord.MessageAttachment(image, "triggered.gif")
            
        message.channel.send(triggered);
    }
}```
#

now i have this

lusty quest
#

alyo your member line is still not completely right

timber fractal
#

so it should work???

lusty quest
#

try and see

timber fractal
#

it doesnt work

#

how to fix it

lusty quest
#

did you saved the code?

timber fractal
#

yes

lusty quest
#

and updated it where every you run the code?

timber fractal
#

yes

lusty quest
#

then it should work

lucid prawn
molten yarrow
eternal osprey
#

is it possible to create your own vps at home?

lucid prawn
molten yarrow
lusty quest
#

use a NAS or a Raspberri pi

lucid prawn
#

all my commands

molten yarrow
#

you get it on all your commands?

eternal osprey
#

nas?

lusty quest
#

network attached storage

eternal osprey
#

aha nvm

#

got it

lucid prawn
#

yes it just stated @molten yarrow

eternal osprey
#

yeah

molten yarrow
timber fractal
#
const canva = require('canvacord');
const Discord = require('discord.js')

module.exports = {
    name: "trigger",
    description: "Triggers yourself",


    async run (client, message, args) {
        const member =  message.mentions.members.first() || message.author

        let avatar = member.displayAvatarURL({dynamic: false, format: "png"});

        let image = await canva.Canvas.trigger(avatar);

        let triggered = new Discord.MessageAttachment(image, "triggered.gif")

        message.channel.send(triggered);
    }
}```
i used this but now it sayss this
```(node:18720) UnhandledPromiseRejectionWarning: TypeError: member.displayAvatarURL is not a function```
#

how to fix it

restive furnace
#

r u sure ur on v12

timber fractal
#

yes

restive furnace
timber fractal
#

ok

eternal osprey
#

will pm2 stop once my pc quits?

#

yeah right?

molten yarrow
#

yes

timber fractal
#
const canva = require('canvacord');
const Discord = require('discord.js')

module.exports = {
    name: "trigger",
    description: "Triggers yourself",

    async run (client, message, args) {
        const member =  message.mentions.members.first() || message.author

        let avatar = member.displayAvatarURL({dynamic: false, format: "png"});

        let image = await canva.Canvas.trigger(avatar);

        let triggered = new Discord.MessageAttachment(image, "triggered.gif")

        message.channel.send(triggered);
    }
}``` If i use this it works if u try it on yourself but if you try it on someone else it says `member.displayAvatarURL is not a function`
lucid prawn
timber fractal
#

how to fix it

molten yarrow
timber fractal
lusty quest
#

or you get the 1 year free credits for AWS or Google Cloud Platforms

timber fractal
#

@lusty quest do u know a answer on my problem

lusty quest
#

does member contains a member object?

timber fractal
#

im new to this sorry

lusty quest
#

contains the member variable a member object? (console.log(member))

timber fractal
#

uhm

#

i have const member = message.mentions.members.first() || message.author

lusty quest
#

if you still dont know how to debug your own code i suggest to learn some more js

timber fractal
#

ok

#

but can you help

#

@lusty quest

lusty quest
#

ive gave you instructions in what to do

eternal osprey
#

i cannot get my fucking build to start because of postinstall

timber fractal
eternal osprey
#

and i don't want to spend money on a vps.

bright crag
#

Avatar is not a property of a guild member

boreal iron
lusty quest
#

5$/month is not much

eternal osprey
timber fractal
lusty quest
#

the message say what you should do

timber fractal
#

who can help me

timber fractal
bright crag
timber fractal
#

oh wait

#

nvm

#

i have members

lusty quest
#

if it will contain a member object then the error is somewhere else

timber fractal
#

and not users

#

i will try

bright crag
#

yeah change it

timber fractal
#

thx @bright crag it worked

bright crag
#

ok cool

lucid prawn
molten yarrow
earnest phoenix
#

i can set gif as avatar for my bot??

lusty quest
#

i think so, saw other bots using it

earnest phoenix
#

i tried but only allows png jpg

lucid prawn
molten yarrow
lusty quest
#

well then you cant use a gif

earnest phoenix
#

is the nekos.life sfw gifs allowed?

lusty quest
#

the entire api is banned

earnest phoenix
#

oh darn but thanks i dont wanna get declined again

cursive forge
#

how to make a bot know when its disconnected discord js?

upper swallow
#

Hey, I'm trying to log in with my bot, but I'm getting an invalid token error. I've regenerated the token multiple times but still the same response. Has the bot been compromised? (I've had this bot for some time and I haven't booted it up for quite a bit)

leaden cliff
#

Can someone check if my code is correct?

#

?

lusty quest
#

you can pass your token from your json config into client.login. and the bot will run on every message that contains oing

#

the on ready event is fine

leaden cliff
#

I have 2 places for the Token.

#

Ik how to get Token.

#

It looks weird.

lusty quest
#

its fine

#

you just dont use prefix or token anywhere

leaden cliff
#

So I remove the config.json file?

lusty quest
#

no keep it

leaden cliff
#

K.

lusty quest
#

in your client.login add in there your token variable

#
client.login(token)
#

this will then load your token from the json

leaden cliff
#

I have added it in the index.js one.

lusty quest
#

having the token somewhere coded in your files is bad

#

the only way i can think on rn is looping over each user in the guild

#

but its not that efficent

outer perch
#

so, @lusty quest remember when I asked about multilanguage?

lusty quest
#

could work

outer perch
#

what about module.exports? it won't get the variable that says 'Use this language!'

#

cuz it'll be above the execute

lusty quest
#

how is your command made?

#

bcs everyone does it a bit different

#

stuff like command names wont work

outer perch
#

I didn't set the lang variable for this file yet

lusty quest
#

yea they wont work

#

atleast it depends on how you pass in the translations.

outer perch
#

so maybe I should create a .json file for the help only

#

like, en-help

lusty quest
#

you cant reference any guild in there

#

so you cant load any guild spezific translation

outer perch
#

or even use the en.json and create a set of properties for help only

lusty quest
#

this will break the command

outer perch
#

I won't delete the name

#

the rest I can delete

lusty quest
#

this will break the help command

outer perch
#

and then, in the help.js

#

wait

#

hold-on

#

instead of searching the command info in the command

lusty quest
#

would be possible

outer perch
#

so it gets the command info from there

outer perch
#

going through all the 'language.json' to write the info

lusty quest
#

well you do the initial translation and then the additional ones

outer perch
#

ยฏ_(ใƒ„)_/ยฏ

leaden cliff
#

How do I get another command working on it?

lusty quest
outer perch
leaden cliff
#

How to get a command handler?

lusty quest
#

nah command handler looks always better

outer perch
#

u can always use switch if u want 4 or 5 commands

outer perch
lusty quest
leaden cliff
#

I am on that.

outer perch
#

but as a beginner, I used switch case until I got 15 commands or so, lmao

lusty quest
#

then go to command Handling

leaden cliff
#

I am on this.

#

Idk how to add another command.

outer perch
#

ykw?

#

follow the guide from the beginning

leaden cliff
outer perch
#

you'll get in there

leaden cliff
#

Where do I put it?

outer perch
lusty quest
#

follow the guide. it will tell you everything

outer perch
leaden cliff
lusty quest
#

? it makes sense for me

leaden cliff
lusty quest
#

well you try to run a else statement inside a if statement

leaden cliff
#

Where do I put it?

lusty quest
#

did you know basic js?

leaden cliff
#

?

lusty quest
#

you ask really basic questions about how to use javascript. i suggest to learn this first

leaden cliff
#

I do not like Javascript.

lusty quest
#

you try to code a bot with it lol

leaden cliff
#

I using Node.

lusty quest
#

node is javascript

leaden cliff
#

Oh.

lusty quest
#

i wont babysit you throu the entire process. learn some basic js.

main trench
#

@leaden cliff smh add a } on the line above the else if statement

#

And like Super was saying you should learn basic coding languages before using them it will help you alot

bright flame
#

Hey guyz could you tell me how to host a java bot for free

#

or is there any method to get vps for free

main trench
#

You can host it in your code editor

ionic dawn
bright flame
ionic dawn
#

You can use your own machine as a host

main trench
#

Example if your using node.js if you do node . in the terminal it turns the bot on

ionic dawn
#

just keep it 24/7 on

main trench
#

^

bright flame
#

oh that i know but i cant keep it 24/7

ionic dawn
#

or just buy a raspi one Lace_shrug_FB

#

there's no "free vps"

main trench
#

Fancy KEKW

bright flame
#

not in js

ionic dawn
#

I suggest you check pinned messages

main trench
#

^

ionic dawn
#

mathew explains very good "Free Hosts"

lusty quest
#

free doesnt exist

pearl trail
#

heroku exist

ionic dawn
#

well

lusty quest
#

heroku is crap

pearl trail
ionic dawn
bright flame
#

?

pearl trail
#

still useful for beginners

lusty quest
#

they dont support a large amount of stuff

bright flame
lusty quest
#

lol grab 5$/Month and you start with a way better platform to grow

#

heroku wont get you past 1k

bright flame
#

my bot is just like 40mb

lusty quest
#

maybe even not past 500

bright flame
#

including all the files, apis, and all stuff

#

i searched for glitch but i didnt found it cool cause you have to start your bot again and again after every 5 mins

#

or so

main trench
#

You could use uptime manager for glitch

#

But I wouldn't recommend using glitch to code a bot

bright flame
#

why tho

lusty quest
#

uptime manager will get you banned from glitch bcs it violates the TOS

pearl trail
# bright flame can u teach me how to host java bot there
  1. you need to push your bot to github
  2. Make Procfile file and fill it with worker: node <your_main_file>
  3. Open heroku, make account if not exist, and create new app
  4. Go to deploy section, choose github for deployment method, find your repo and connect it.
  5. Click on deploy branch
  6. If success, refresh page, and go to resource section
  7. Disable web and enable worker
main trench
lusty quest
#

when did they changed it?

#

anyways free hosts suck

main trench
#

Indeed

bright flame
main trench
#

Self host like a normal guy smirk

lusty quest
#

buy a Raspberry pi or banana pi if you dont want to get a VPS

bright flame
main trench
#

I self host and mine didn't get declined

lusty quest
#

self host in a VPS lol

main trench
#

Yours was probably just offline

bright flame
main trench
#

Lmao

#

Self host is both a blessing and a nightmare

#

Its easy to fix errors but if you get one the project is offline

lusty quest
#

there is a easy way to prevent this. Dont develop on a working system

main trench
#

True

river thistle
#

I'm looking for a method to split a string into multiple parts, based on a maxLength, but not just using a simple substring, but cutting at the end of a word

#

I don't know if I explained it correctly

lusty quest
#

?

#

where?

outer perch
#

is it possible to pass a parsed .json to another command?

lusty quest
#

what is the error

#

you already forgot to close one (

cursive forge
#

how to make a bot know when its disconnected discord js?

lusty quest
main trench
#

@cursive forge what?

cursive forge
#

client

#

I need it to know when someone disconnects it manually

#

so it clears the queue

#

Yeah it crashes but instead of crashing I want it to queue.delete(guild.id)

#

but I need to know what can detect if the client is in the vc or not

tardy hornet
#

is it right to say codes are?

lusty quest
#

ditch discord.js and use a microservice structure. then your bot can be shown as online but no command will work bcs there is no api client aviable

cursive forge
#

how to make a bot know when its disconnected discord js?

lusty quest
#

look into events

cursive forge
#

What?

#

How does this help me?

#

How would I even add that lol

main trench
#

@sharp birch send the error here

sharp birch
#

wait I'ma screen shot for error

main trench
#

You could just copy and paste it KEKW

sharp birch
#

emm

#

this

#

data

#

eeeeee

main trench
#

Looks like you don't have the js package

#

You should install that

sharp birch
#

I have that bruh

cursive forge
#

@earnest phoenix Then how would I use that to make it where if someone disconnects it it returns queue.delete(guild.id)

sharp birch
#

only one problem

main trench
#

Did you install it in the project then @sharp birch

sharp birch
#

I have package-lock.json

#

damn

#

I didn't install that

main trench
#

In the terminal do npm i discord.js

outer perch
#

uh

sharp birch
#

npm discord.js?

main trench
#

^

sharp birch
#

alr

cursive forge
#

@earnest phoenix So how would I do and if statment with it?

main trench
#

i is short for install

sharp birch
#

it's still error

main trench
#

@sharp birch then you don't have the discord api

sharp birch
#

I have

main trench
#

Are you trying to use node.js?

sharp birch
main trench
#

Did you Install it from the site?

sharp birch
#

yes

main trench
#

Did you do npm init?

earnest phoenix
#

Did u install all the packages in ur package.json?

#

lol

sharp birch
#

alr it's work thx

main trench
#

Lmao that was fast

sharp birch
#

yay my bot working

earnest phoenix
#

Lol

sharp birch
main trench
#

No idea what that is KEKW

earnest phoenix
#

and now we wait for him to get roasted

main trench
#

Yes

sharp birch
#

Im so lazy using visual studio slonk

#

I wonder why

#

..

#

idk

main trench
#

Vsc is nice

#

Easy to code in it and easy to host in it

sharp birch
#

oof

lusty quest
#

dont host in vsc

#

its not ment for production systems

main trench
#

Oh well it worked for my old bot KEKW

sharp birch
#

I have one question

main trench
#

Once I have a job ill buy a vps

sharp birch
#

what is that "package-lock.json"?

main trench
#

@sharp birch just information on your js version, discord version all that fun stuff

#

Nothing you'll ever need to mess with

eternal osprey
#

hey guys

willow mirage
#

ฦฐhat

fallen oak
#

Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien

willow mirage
#

what

eternal osprey
fallen oak
#

Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien

main trench
#

Should we get a mod?

willow mirage
#

dude

#

NO

#

only 1 erson

lusty quest
blissful oxide
#

A mod

small plume
#

-atmods @eternal osprey

gilded plankBOT
#

@eternal osprey

Please do not mention (ping) more than one or two moderators for help, unless there is an emergency.

Here are some examples of emergencies:

  • Raids / Multiple members mass spamming.
  • Severe disruption of Discord's ToS (NSFW content, etc)
  • Anything that requires more than 2 moderators to handle.
willow mirage
#

person

eternal osprey
#

fuck sorry

blissful oxide
#

not 25

fallen oak
#

Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien Bande de chien

eternal osprey
#

sorry

willow mirage
#

rip @fallen oak

blissful oxide
#

-m 417624128120684544 spamming | 2d

gilded plankBOT
#

๐Ÿค Muted Witrold#8598 (@fallen oak)

eternal osprey
#

sorry mods!

willow mirage
#

dude

#

._.

main trench
#

@eternal osprey whats are you trying to do with the stats?

willow mirage
#

Only one mod who has status online

#

BRRR

eternal osprey
willow mirage
#

@eternal osprey did you tried

setInterval()
eternal osprey
#

but it does not update.

main trench
#

If you want it to update use a interval

eternal osprey
#

`` js

willow mirage
#
setInterval(() => {
  //your function
}, 15000)
eternal osprey
#

    client.user.setActivity(`!help || Serving on ${client.guilds.cache.size} servers, for a total of ${client.users.cache.size} users`);
``` this is that code
#

aha okay.

willow mirage
#

you need to loop it

#

but not less then 15s

#

cuz ur gonna get banned

main trench
#

Mine updates every 2 min

lusty quest
#

i recomend 5 minutes

eternal osprey
#
setInterval(() => {
        
      
    client.user.setActivity(`!help || Serving on ${client.guilds.cache.size} servers, for a total of ${client.users.cache.size} users`);
}, 60000)```
#

like this right?

willow mirage
#

good

main trench
#

Now the bot will not have a status until it reaches the specified time btw

willow mirage
#
    client.user.setActivity(`!help || Serving on ${client.guilds.cache.size} servers, for a total of ${client.users.cache.size} users`);
setInterval(() => {
    client.user.setActivity(`!help || Serving on ${client.guilds.cache.size} servers, for a total of ${client.users.cache.size} users`);
}, 60000)
#

done

main trench
#

Lmao

eternal osprey
#

i am still flabbergasted about how the fuck i got 605 users to use my bot

#

that's hot asf

outer perch
#

so I did this in bot.js

const lang = require('./languages/en.json');

and then tried to pass lang to the commands

command.execute(bot, message, command, args, db, await prefixDev, lang, supportServerEmojis);

but lang logs [] in the other commands

main trench
#

Whats lang supposed to do?

lusty quest
#

605 is easy. if you get like one or two larger servers

main trench
#

^

outer perch
#

that's a snippet

main trench
#

Interesting

outer perch
#

in english, goes to en.json

#

if in spanish for example, es.json

main trench
#

So it just changes the language depending on the user?

outer perch
#

*server

#

I am using only en.json just for testing

#

so i can know if the commands are reading the object

main trench
#

Ah sounds like a neat feature

outer perch
#

but I need an answer for my problem

lusty quest
#

how did you define what language file gets loaded?

outer perch
#

I did that way just to test

#

should I add await?

lusty quest
#

this is not really a smart system

#

since you hardcode one language

outer perch
#

??

#

it's dynamic in the bot

#

in the dev one, it's just like this

#

I just want to pass the object to the other commands

outer perch
lusty quest
#

no

#

you hardcode the bot to only use english

outer perch
#

no....?

lusty quest
#

the code you showed does it

outer perch
#

I know it does @lusty quest

#

but that's not the issue, it's for testing

#

I just want the object in the other commands, but appears as [] @lusty quest

earnest phoenix
#

I'm starting to learn JS again as I forgot about most of it yet I'm just getting an error when I try to npm i dotenv/types

#

(it didnt already install that alongwith dotenv)

summer torrent
lusty quest
#

does the package exist?

#

lol he is in development

earnest phoenix
#

Not really sure

lusty quest
earnest phoenix
#

I have code referencing to dotenv/types but that throws an err trying to install it

lusty quest
#

try dotenv-types

#

this package exist

#

or @types/dotenv

#

but later one is deprecated

earnest phoenix
#

yeah

#

it's asking for /

#

@types/dotenv doesn't work either

lusty quest
#

why did you want to use it? bcs the package is deprecated

#

atleast @types/dotenv

earnest phoenix
#

i previously used dotenv to actually turn on my bot as i dont know any other way

#

ill just try to use .json then i didnt realise they deprecated it

lusty quest
#

lol dotenv still is a thing

#

but not really for turning on bots, it provides a file that will be loaded into the enviroment

earnest phoenix
#

yeah

sudden geyser
#

wdym they deprecated it

lusty quest
#

@types/dotenv is deprecated bcs it got merged with dotenv or so

sudden geyser
#

o

#

good

#

less typescript (jk)

fallow agate
#

Hello

earnest phoenix
#

hi

fallow agate
#

how can i get user info with discord api?

limber flume
#

Hey, I'm trying to get the milliseconds of when the bot starts listening for a message and when the user types in the correct message. But it sometimes goes -. I'm using datetime

earnest phoenix
#

you mean id username joindate and stuff

limber flume
earnest phoenix
#

yeah

fallow agate
#

adamm

#

with api

#

h

#

wait

earnest phoenix
#

๐Ÿ‘ read ๐Ÿ‘ the ๐Ÿ‘ docs ๐Ÿ‘

fallow agate
#

not in top gg

#

bu

#

but

main trench
#

@fallow agate read the discord.js docs

limber flume
#

stop spamming messages, write them in one.

main trench
#

Or whatever language docs you're using

sudden geyser
#

Azy what library are you using

earnest phoenix
#

its called linestacking

limber flume
#

now nobody gonna see what i asked for kek

summer torrent
main trench
#

Ah yes dev portal

limber flume
fallow agate
#

cant see in it aw

limber flume
#

at all*

fallow agate
#

also discord.dev link not works?

main trench
#

@fallow agate its a issue with your discord app settings

limber flume
#

but sometimes, shows - kappa_smh

sudden geyser
#

But it sometimes goes -. I'm using datetime
What is -? I don't think you should even be using strftime for this.

limber flume
#

o-

#

but i want to format it into milliseconds

lusty quest
#

could be also a bug with the api or your code

sudden geyser
#

probably not

limber flume
#

yea probably not xd

#

well, my code yes.

#

but sometimes one is larger than the other maybe?

#

and that's why it goes -

main trench
#

@leaden cliff example
If {
Command 1
} else if {
Command 2
}

earnest phoenix
main trench
#

Or use a switch statement

limber flume
main trench
#

But honestly learn basic js first

limber flume
#

@earnest phoenix Welp. That worked! Thanks.

sudden geyser
#

I don't exactly think using datetime.now().strftime(...) for this situation is appropriate, but this is how I did it in one of my bots: ```py
from time import time

milliseconds = lambda: int(time() * 1000)Then I could call `milliseconds` to get the current time in milliseconds.py
start = milliseconds()

... wait a bit ...

elapse = milliseconds() - start```

limber flume
#

oh, i could try this.

#

Thanks, Lite.

slender thistle
#

Isn't time() already in ms?

sudden geyser
#

It's in seconds, but uses decimal points

limber flume
#

yes lol

sudden geyser
slender thistle
#

huh

#

well, datetime > time mmlol

limber flume
#

@sudden geyser Works, Thanks! I got both times by just doing elapse/1000!

#

/ obviously meaning divide.

earnest phoenix
#

could this get me rate limited?

@tasks.loop(seconds=300)
async def cpucheck(self):
        print(self.bot.index)
        self.bot.index += 1
        cpunorm = 10.0
        cpuhigh = 20.0
        if psutil.cpu_percent() < cpunorm:
            await self.bot.change_presence(status=discord.Status.online,activity=discord.Game(name=status))
        elif psutil.cpu_percent() > cpunorm:
            await self.bot.change_presence(status=discord.Status.idle,activity=discord.Game(name=status))
        elif psutil.cpu_percent() > cpuhigh:
            await self.bot.change_presence(status=discord.Status.dnd,activity=discord.Game(name=status))
        else:
            print("Error")
sudden geyser
#

well you're only going it once every 5 minutes

hasty mulch
#

Status change?

sudden geyser
#

I wouldn't say so

earnest phoenix
#

it changes state based on the cpu load

tribal siren
#

i always wondered: why do we need the client secret and the public key?

earnest phoenix
#

high load dnd

boreal iron
#

Clients may only update their [...] status 5 times per 20 seconds.

#

So no.

earnest phoenix
#

ah ok, thanks

slender thistle
#

4 times per 20 seconds actually

#

Actually, I'm unsure, disregard that

lusty quest
#

i think its higher

#

2 times per 10 minutes iirc

boreal iron
#

5 times per 20 seconds quoting Discord docs

leaden cliff
#

(I removed the Token due to it being stolen.)

earnest phoenix
#

Hello can we use a multi language for the bot? For coding

leaden rover
#

in the ping command, you need to have a ( before the '

leaden cliff
cinder patio
atomic vault
leaden cliff
main trench
#

@leaden cliff add a } above the second if statement

#

Smh

leaden cliff
#

oh.

main trench
#

Wait maybe

#

Your code is a little strange

#

Oh

#

Add a third =

#

@leaden cliff

leaden cliff
earnest phoenix
molten yarrow
#

its just (command == 'ping')

main trench
#

Is it?

atomic vault
main trench
#

I don't do else if statements so I don't remember how they work

leaden cliff
#

If I remove the { it makes it fail.

main trench
#

Then don't remove it

leaden cliff
#

But I have a problem.

#

With it.

atomic vault
#

how to add role for a user only sing tis username and discriminator
Like nandan#8628

main trench
#

Id say rey adding a third = to see if that helps

leaden cliff
main trench
#

@atomic vault you canr really since the bot needs to find a user in the guild

leaden cliff
main trench
#

@leaden cliff take away ( then add the { back

molten yarrow
#

dude dont make it even worse xD

leaden cliff
main trench
#

Omfg

leaden cliff
#

Like that?

molten yarrow
#
if(command == 'ping') {
  message.channel.send('pong!')
}
main trench
#

^

molten yarrow
#

i cant look at this...

main trench
#

I now see why I switched to command handlers

atomic vault
molten yarrow
#
if(command == 'ping') message.channel.send('pong!')

would also work

leaden cliff
#

@atomic vault Yay!

molten yarrow
main trench
#

@leaden cliff I'll just say this again you should really learn basic js first man

#

It will make your life so much easier

molten yarrow
#

yep

leaden cliff
#

Wait.

#

It is still does not work.

#

Their are no errors.

main trench
leaden cliff
#

The terminal won't work.

atomic vault
#

@main trench ya

leaden cliff
#

๐Ÿ˜ญ

#

Wait.l

main trench
#

Did you do "node ."

leaden cliff
#

F me.

main trench
#

Smh

leaden cliff
#

I forgot to add the Token back in.

#

It works.

#

Thx.

main trench
#

Now to add another command do else if under the last } for the ping command

#

And repeat the same process

leaden cliff
#

K.

main trench
#
  message.channel.send('pong!')
} else if(command == 'name 2') {
Code here
}```
#

It should be like that

#

I miss the mobile code blocks ๐Ÿ˜”

gusty quest
#

um ReferenceError: Intents is not defined``````const intents = new Intents(); intents.add( 'GUILD_MEMBERS', 'GUILDS', 'GUILD_MESSAGES', );

#

but its defined

molten yarrow
gusty quest
#

?

molten yarrow
gusty quest
#

i have that

#
const client = new Discord.Client(config, { ws: { intents: intents } });```
atomic vault
#

how can i get user id and give a role to user

main trench
#

@atomic vault discord.js?

atomic vault
#

ya
and mysql

near stratus
#

client.fetchUser ?

earnest phoenix
#

I'm gonna make a discord bot in note pad

atomic vault
near stratus
#

Not even notepad

earnest phoenix
#

0_0

near stratus
atomic vault
#

client.fetchUser

near stratus
#

then try this

client.users.cache.find(user => user.id === 'ID_Here')
#

if it doesn't work I don't know what will

atomic vault
main trench
#

I think he is making it so you mention a user

near stratus
atomic vault
#

i am making a bot which gives a role for a member how enter his username or id or anything by that my bot can give a role with mysql

molten yarrow
main trench
#

Message.mentions.members.first()

atomic vault
near stratus
#

how do you want the commands to be ?
like
!give @user @role ??

atomic vault
#

no it will give role when he registers in that site

molten yarrow
near stratus
#

What does the site take as input ?
Id or name ?
also is the user already in your server ?
You might need an api

atomic vault
molten yarrow
#

than use oauth2 to login with discord

atomic vault
#

how to make it

molten yarrow
near stratus
#

We're not supposed to spoonfed codes

atomic vault
#

thanks i will try it

leaden cliff
#

I have fixed all the other errors.

#

Except from this.

#

@main trench

gusty quest
#

DiscordjsError: Request to use token, but token was unavailable to the client. what to do? this is code: ```
const Discord = require('discord.js');

module.exports = {
name: 'die',
description: "this is a die command!",
execute(client, message, args){

    const ownerID = '735890738721718363'

    if(message.member.id === ownerID) {
        const kurac = new Discord.MessageEmbed()
        .setAuthor('Among Bot', 'https://i.imgur.com/ti8MDoI.png')
        .setDescription(':tam: This is my last message before die, sorry i must go for some time! :Yes~3:')
        message.channel.send(kurac);

        client.destroy();
    } else {
        message.channel.send('Only bot developers can do this command. :No~3:')
    }
}

}```

molten yarrow
leaden cliff
#

When I say ping it says ping instead of pong.

delicate shore
#

Send your code

leaden cliff
#

I got it to work but it was not doing the thing from ping.js.

sudden geyser
#

that doesn't make sense

leaden cliff
#

Does.

sudden geyser
#

doubt

leaden cliff
#

How to do it then?

umbral zealot
molten yarrow
#

we told him already, but he dont like javascript because he using Node

umbral zealot
#

LearnNodePlzPlzPlz

leaden cliff
#

Omg.

#

Just tell me how to fix it!

umbral zealot
#

No. Go learn the language

earnest phoenix
#

by learning node

umbral zealot
#

it's not our job to hand hold you through every single line of writing your bot

#

Nobody wants to do that.

leaden cliff
#

I have fixed many errors on my own.

sudden geyser
#

ping.js is a file in commands/ping.js. You want to call the execute function defined in the exports. message.channel.send(...) has nothing to do with it, so what you're really looking to do is require commands/ping.js and call execute(...).

You'll need to learn the language & Node because you can do this.

restive furnace
#

just use old good yanderdev way instead

earnest phoenix
#
@tasks.loop(seconds=300)
    async def cpucheck(self):
        print(self.bot.index)
        self.bot.index += 1
        print(psutil.cpu_percent())
        if psutil.cpu_percent() == None:
            cpuuse = 0 
        elif psutil.cpu_percent() != None:
            cpuuse = int(round(psutil.cpu_percent() / 10)) 
        print(cpuuse)
        cpunorm = 10
        cpuhigh = 50
        if cpuuse ==None:
            print("Waiting for cpu reading")
        elif cpuuse < cpunorm:
            await self.bot.change_presence(status=discord.Status.online,activity=discord.Game(name=status))
        elif cpuuse > cpunorm:
            await self.bot.change_presence(status=discord.Status.idle,activity=discord.Game(name=status))
        elif cpuuse > cpuhigh:
            await self.bot.change_presence(status=discord.Status.dnd,activity=discord.Game(name=status))

Everytime the bot start i get an exception

#

idk whats wrong

hollow sedge
#

Yes

stark abyss
#
    let isUser;
    pool.query(`SELECT * from lotterystats WHERE id = ${message.author.id}`, (err, res) => {
      if(err) return console.log(err);
      if(!res.rows[0]){
        console.log("false")
        isUser = 'false'
        return;
      }
      console.log(res.rows[0] + " res 0 ")
      isUser = res.rows[0].id
    })
    return console.log(isUser  +  " is user last"); 

so it's console logging is user last first and then false for that reason isUser stays undefined Confused

#

i did try doing await pool.query but it doesn't work

floral creek
#

Why des my bot asks for permision when edditing the help cmd

#

?

stark abyss
#

what kek?

#

show error / code

floral creek
#

O no, solved it

loud ingot
#
module.exports = {
   name: "ping",
   description: "this is a ping command!",
   
   execute(message, args) => {
       message.channel.send('\:ping_pong: Pong!'
    }
}
near cipher
cosmic forum
#

anyone know what the best db to use for nodejs is?

umbral zealot
#

There is no "best" DB.

cosmic forum
#

Well, most popular db?

umbral zealot
#

There are local dbs, server dbs, sql, nosql, etc

near cipher
lusty quest
#

i like MongoDB

umbral zealot
#

What do you need to store, aakhilv?

cosmic forum
#

Local/server is fine

#

Um, just values for log channels and stuff

umbral zealot
#

Then you could just use my enmap module, it should be fine for you

#

even got a per-server configuration example in the docs ๐Ÿ˜„

cosmic forum
#

Alright, do you mind linking it?

umbral zealot
#
cosmic forum
#

thx

lusty quest
#

enmap has some downsides

#

ive used it for a while

umbral zealot
#

Such as?

lusty quest
#

until it used 1 GB ram

umbral zealot
#

Well it does store things in memory so yes. And it can't scale to sharded bots. but it's good for starters.

lusty quest
#

thats true

pale vessel
#

PagChamp 1gb

leaden cliff
umbral zealot
umbral zealot
leaden cliff
#

I am learning it!

umbral zealot
#

No you're not, you're struggling to make a bot , not learning javascript.

stark abyss
#
    let isUser;
    pool.query(`SELECT * from lotterystats WHERE id = ${message.author.id}`, (err, res) => {
      if(err) return console.log(err);
      if(!res.rows[0]){
        console.log("false")
        isUser = 'false'
        return;
      }
      console.log(res.rows[0] + " res 0 ")
      isUser = res.rows[0].id
    })
    return console.log(isUser  +  " is user last"); 

so it's console logging is user last first and then false for that reason isUser stays undefined Confused
I did try await pool.query same response

umbral zealot
#

That's because pool.query isn't a promise so you can't await it.

stark abyss
#

oh

#

really?

umbral zealot
#

It's clearly a callback method, not a promise one. You'll have to use a better module that uses promises

#

Better yet, don't use mysql, it's crap ๐Ÿ˜›

stark abyss
#

i am using postgres what do u recommend using then

#

๐Ÿค”

umbral zealot
#

Ah! nevermind then, pgsql is fine

stark abyss
#

yeah

umbral zealot
#

But find a pgsql module that supports promises