#development

1 messages Β· Page 865 of 1

modest maple
#

What program

velvet zenith
#

was

tough relic
#

putting you code in?

#

Like a text editor?

velvet zenith
#

ya

modest maple
#

which editor

velvet zenith
#

i need a free thing to put my code in the bot

tough relic
#

Put your code in the bot ❓

modest maple
#

I think you have the wrong idea of bot making

velvet zenith
#

well

opaque kite
#

Tons of free python tutorials out there, check it out

velvet zenith
#

i need a program that lets me put my code in

#

but i dont have money

modest maple
#

Search up Python IDE

velvet zenith
#

ok

fleet chasm
#

^

opaque kite
#

Use vscode

tough relic
#

If you search a text editor to code: Sublime Text, Visual studio code πŸ™‚

modest maple
#

I mean python already has an inbuilt ide

#

However

opaque kite
#

Vscode is dashing ;)

modest maple
#

You should not start by programming bot if you've never coded before

velvet zenith
#

ill look up

#

the programs

modest maple
#

You are gonna need to learn the basics first

velvet zenith
#

ok

#

shouldent be that hard i learn fast

#

and where do we inplant the code

tough relic
#

@velvet zenith search like freecodecamp python tutorial on youtube and you'll find some good things!

velvet zenith
#

ok

#

xd a little off topic ima youtuber

#

anyways

#

can someone give me the code for a dm bot

golden condor
#

@velvet zenith that's called spoonfeeding

#

And we don't do that here

velvet zenith
#

OK

regal saddle
#

ill give you nkio

unkempt ivy
tight plinth
#

#dev @robust moth

#

(fuck,we are in development)

#

What you want to do exactly

regal saddle
#

that isnt js right?

mystic violet
#

AngeryBOYEspin is typing

tight plinth
#

It's a mix between json and js

#

@mystic violet no u

peak quail
#

i could send a post request on a webhook every 10sec and i will not trigger the rate limit?

robust moth
#

@regal saddle it's json out put

tight plinth
#

Json with list?

regal saddle
tight plinth
#

No

#

Json output be like json { "guild.id": { "msg.author.id": { "text" : "id", "voice": "id" } } }

#

YES I KNOW

#

It's been 3 times you repost it

#

Well do code

balmy knoll
#

I am using Glitch to do some tests on my bot, the code has no errors, but the bot does not come online? What could be the problem?

tight plinth
#

Token

balmy knoll
#

@tight plinth The token is right, I have also regenerated a new token

tight plinth
#

Show code

frigid sierra
#

using the guilds scope, what's the best way of getting partial guild info for a single guild

#

i.e. /users/@me/guilds will not work because i cannot specify one snowflake

modest maple
#

@fleet chasm @regal saddle I'd like you two to think about what this chat is for rather than shit posting:

#development and #topgg-api are NOT the place for shit posting and in general being unhelpful, you have no right to mislead people or troll people who are new regardless of how much or how little prior experience they have.
In the 25 minutes I watched this chat and attempted to help someone who, yes they did not know what they were doing the 2 of you did not help the situation at all I don’t care what you say in off-topic but if you have nothing useful to contribute don’t say anything at all, when someone asks to be spoon fed tell them β€œNo, we won’t do that for these reasons…'' Don't be that person who says β€œsure I'll give you the code” only to troll that person, it is not fair on them.
All you do when doing that is confuse them and make it harder for the people who are actually trying to help explain.
TL;DR = If you have nothing productive to say in #development or #topgg-api don't say it at all, don’t be that asshole who trolls and mocks people simply trying to learn or achieve something.

#

Aimed mostly at lukas this

regal saddle
#

aPES_Salute k sir

wind solstice
#

You should not start by programming bot if you've never coded before
@modest maple well, it actually worked to me OMEGALUL

grizzled raven
#

my first encounter with coding was with discord bots

wind solstice
#

same

grizzled raven
#

is glitch on debian or ubuntu

mossy vine
#

run neofetch and see for urself lol

grizzled raven
#

oh

#

bruh ok

#

why is glitch being bad now

#

ok whatever

prime cliff
#

@peak quail yes also webhooks are special and they can send multiple embeds in one message

cinder yew
#

hi, i'm using open source nadeko, and i was wondering how I would go about changing the .kick command to send an embed to a specific channel when it's used?

#

essentially logging it, but without having to mess with the logging system it already has

earnest phoenix
#

go to the nadeko guild

#

nadeko is a clusterfuck

slender thistle
cinder yew
#

i asked there but

#

they're not the most helpful

#

:l

slender thistle
#

If they ain't able to help, I don't think we will be

cinder yew
#

not that they weren't able to, they just don't lmfao

slender thistle
calm shore
#
bot.on('message', message => {
    let preId = "698950081038254240"
  if(!message.guild.member.find(preId)) return;
    if(message.content === `${prefix}help`) {

        let helpembed = new Discord.RichEmbed()
        .setAuthor("Teht")
        .setColor("#ff7600")
        .setDescription("asd")
        .setFooter(` ❀️ Teht - Thank you for Joining Us!`);
        message.channel.send("You have been dmed a list of Commands!").then(message => {message.delete(6000)});
        message.author.send(helpembed);

    }
    else if(message.guild.member.find(preId)) {
      let helpembedpremium = new Discord.RichEmbed()
      .setAuthor("Teht")
      .setColor("#ff7600")
      .setDescription("Gay")
      .setFooter(` ❀️ Teht - Thank you for Joining Us!`);
      message.channel.send("You have been dmed a list of Premium Commands!").then(message => {message.delete(6000)});
      message.author.send(helpembedpremium);
    }
});```
anyone know how to make this a valid function
I want it to find a certain user id. And if the certain id is in the server, then the member running the command will get sent a completely different embed
---------------
The ID of a certain bot. So if the ID of a certain bot is PRESENT in the server, then anyone running the command will get sent the else statement embed, in this case "**Gay**"
But  if the ID of a certain bot isnt PRESENT in the server,then anyone running the command will get sent the main statement embed, in this case "**Asd**"
sudden geyser
#

.find takes a function, with the first argument being a GuildMember. So, pass a function and check the member's User object and see if their ID matches. If it does, do whatever you plan on doing.

#

Though, wouldn't you mean something like if (the member with the id was found) {...} else {...}?

summer torrent
#

also members.find, not member.find

calm shore
#

members.find wouldn't work

crimson vapor
#

it would

#

but only if the member was cached

calm shore
#

I tried it gave an error

crimson vapor
#

one sec

#

wait

#

ur on 12 or 11?

calm shore
#

11

#

if (typeof value === 'undefined') throw new Error('Value must be specified.');
^

Error: Value must be specified.

#

thats the error

#

if i use members.find

crimson vapor
#

it should be message.guild.members.find(preId)

calm shore
#
bot.on('message', message => {
    let preId = "698950081038254240"
  if(!message.guild.members.find(preId)) return;
    if(message.content === `${prefix}help`) {

        let helpembed = new Discord.RichEmbed()
        .setAuthor("Teht")
        .setColor("#ff7600")
        .setDescription("Commands!\n\n1. -clear \n2. -ask (Question) {8ball CMD}\n3. -members\n4. -server\n5. -suggest\n6. -meme\n7. -botinfo\n8. -invites\n9. -blacklist {on/off}\n(This prevents discord links from being sent!)\n\nPage 1 >> (-page 2) in dms")
        .setFooter(` ❀️ Teht - Thank you for Joining Us!`);
        message.channel.send("You have been dmed a list of Commands!").then(message => {message.delete(6000)});
        message.author.send(helpembed);

    }
    else if(message.guild.members.find(preId)) {
      let helpembedpremium = new Discord.RichEmbed()
      .setAuthor("Teht")
      .setColor("#ff7600")
      .setDescription("Gay")
      .setFooter(` ❀️ Teht - Thank you for Joining Us!`);
      message.channel.send("You have been dmed a list of Premium Commands!").then(message => {message.delete(6000)});
      message.author.send(helpembedpremium);
    }
});```
#

isnt that what i did

sudden geyser
#

You should be passing a function?

crimson vapor
#

oh yeah

#

they changed it

calm shore
#

What

#

?

crimson vapor
#

find(m => m.id == preId)

calm shore
#

if(!message.guild.members.find(m => m.id == preId)) return;
^

TypeError: Cannot read property 'members' of null

crimson vapor
#

why is message.guild null?

twilit rapids
#

Are you running this command in a DM?

#

Or any message

crimson vapor
#

oh yea

calm shore
#

Dms

crimson vapor
#

no guild makes it null

calm shore
#

Wait

#

no

prime cliff
crimson vapor
#

yeah it needs to be in a guild channel

calm shore
#

but it sends a dm

#

Im running the command in the server

prime cliff
#

Well if it's trying to get the dm channel or message guild will always be null

wide wharf
#
/home/container $ node app.js
/home/container/app.js:1223
client.channels.get(698983333782093925).send('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ \nServer: ' + message.guild.name + ' \nChannel: ' + message.channel.name + ' \nUser: ' + message.author.username + ' \nMessage: ' + message.content')
^^
SyntaxError: Invalid or unexpected token
at new Script (vm.js:79:7)
at createScript (vm.js:251:10)
at Object.runInThisContext (vm.js:303:10)
at Module._compile (internal/modules/cjs/loader.js:656:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
at Function.Module._load (internal/modules/cjs/loader.js:529:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:741:12)
at startup (internal/bootstrap/node.js:285:19)
``` πŸ€” Error... (It's for logging)
prime cliff
#

line 79

calm shore
#

thats why if(!message.guild) return;

crimson vapor
#

is that one line?

wide wharf
#

Yeah?

true ravine
#

Isn't it because the snowflake is given as an int not string?

#

Don't you need to put "" around it

prime cliff
#

I usually just newline my code after a "\n" visual studio auto adds the extra + "

calm shore
#

this is the whole new code

#
bot.on('message', message => {
  if(!message.guild) return;
    let preId = "698950081038254240"
  if(!message.guild.members.find(m => m.id == preId)) return;
    if(message.content === `${prefix}help`) {

        let helpembed = new Discord.RichEmbed()
        .setAuthor("Teht")
        .setColor("#ff7600")
        .setDescription("ASD")
        .setFooter(` ❀️ Teht - Thank you for Joining Us!`);
        message.channel.send("You have been dmed a list of Commands!").then(message => {message.delete(6000)});
        return message.author.send(helpembed);

    }
    else if(message.guild.members.find(m => m.id == preId)) {
      let helpembedpremium = new Discord.RichEmbed()
      .setAuthor("Teht")
      .setColor("#ff7600")
      .setDescription("Gay")
      .setFooter(` ❀️ Teht - Thank you for Joining Us!`);
      message.channel.send("You have been dmed a list of Premium Commands!").then(message => {message.delete(6000)});
      return message.author.send(helpembedpremium);
    }
});```
twilit rapids
#

Still the same error?

calm shore
#

It gives me this error

#

one sec

wide wharf
#

Don't you need to put "" around it
@true ravine I did?

#

but with ''

#

'...'

prime cliff
#

Wait why are you not checking if the message starts with the prefix?

mystic violet
#
const result = request(`${this.path}/set`, {
        method:'post',
        body: {'key':a, 'value':b},
        headers: { 'Content-Type': 'application/json', 'authorization': this.password }
      })```

Req.body is {} and not "{key....}"

```js
this.app.post("/set", async(req,res) => {
            if(req.headers.authorization == this.password) {
                console.log(req.body)
                res.send(await db.set(req.headers.key, req.headers.value))
            } else {
                res.send("Unauthorized")
            }
        })```
crimson vapor
#

he is

#

kinda

true ravine
wide wharf
#

Owh

#

Okay

#

πŸ˜‚

prime cliff
#

But it's not the prefix command is 1 if but the else if will always run on a message

fallen pagoda
calm shore
#

It sends them both

#

You have been dmed a list of Commands!
You have been dmed a list of Premium Commands!

true ravine
#

Funky

prime cliff
#

if(message.content === ${prefix}help) {

}
else if(message.guild.members.find(m => m.id == preId)) {

}
fallen pagoda
#

welp

calm shore
#

NOPE

prime cliff
#

The else if will always run without a prefix and command

twilit rapids
#

The formatting should explain itself right?

calm shore
#

It spams my chat with
You have been dmed a list of Premium Commands! Everytime i run the command

twilit rapids
#

You forgot to close your string somewhere

fallen pagoda
#

have you tried putting β€œ;” at the end

prime cliff
calm shore
#
bot.on('message', message => {
  if(!message.guild) return;
  let preId = "698950081038254240"
  if(!message.guild.members.find(m => m.id == preId)) return;
    if(message.content === `${prefix}help`) {

        let helpembed = new Discord.RichEmbed()
        .setAuthor("Teht")
        .setColor("#ff7600")
        .setDescription("Commands!\n\n1. -clear \n2. -ask (Question) {8ball CMD}\n3. -members\n4. -server\n5. -suggest\n6. -meme\n7. -botinfo\n8. -invites\n9. -blacklist {on/off}\n(This prevents discord links from being sent!)\n\nPage 1 >> (-page 2) in dms")
        .setFooter(` ❀️ Teht - Thank you for Joining Us!`);
        message.channel.send("You have been dmed a list of Commands!").then(message => {message.delete(6000)});
        message.author.send(helpembed);
        return;

    } else if(message.guild.members.find(m => m.id == preId)) {
      let helpembedpremium = new Discord.RichEmbed()
      .setAuthor("Teht")
      .setColor("#ff7600")
      .setDescription("Gay")
      .setFooter(` ❀️ Teht - Thank you for Joining Us!`);
      message.channel.send("You have been dmed a list of Premium Commands!").then(message => {message.delete(6000)});
      message.author.send(helpembedpremium);
      return;
    }
});```
#

I closed it

#

tho

prime cliff
#

You're not checking the prefix and command correctly

wide wharf
#

Uh @true ravine

/home/container $ node app.js
/home/container/app.js:1223
client.channels.get('698983333782093925').send('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ \nServer: ' + message.guild.name + ' \nChannel: ' + message.channel.name + ' \nUser: ' + message.author.username + ' \nMessage: ' + message.content')
^^
SyntaxError: Invalid or unexpected token
at new Script (vm.js:79:7)
at createScript (vm.js:251:10)
at Object.runInThisContext (vm.js:303:10)
at Module._compile (internal/modules/cjs/loader.js:656:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
at Function.Module._load (internal/modules/cjs/loader.js:529:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:741:12)
at startup (internal/bootstrap/node.js:285:19)
mystic violet
#

message event for every command AngryEyes

true ravine
wide wharf
#

Okay?

calm shore
#

Timo

wide wharf
#

Owh yeah Im dumb forgot that xD

calm shore
#

Dm me

prime cliff
#

You need to be checking if the message starts with the prefix and return if it's not

crimson vapor
#

Builder he is kinda

#
 if (message.content === `${prefix}help`) {```
fallen pagoda
prime cliff
#

It's not

#

if(message.content === ${prefix}help) {

}
else if(message.guild.members.find(m => m.id == preId)) {

}
quartz kindle
#

hes checking the prefix, then running the other code if no prefix

prime cliff
#

The else if will run regardless of prefix and command except for the fine role

quartz kindle
#

the other code always runs

prime cliff
#

^

fallen pagoda
#

i was afraid of my dog crapping om my floor when i went to take a shower s i took her with me and when i came back she had made a bed out of one of the mats

crimson vapor
#

oh

#

I see now

#

my bad

#

Hazy wrong channel

quartz kindle
#

@wide wharf show your code

fallen pagoda
#

pork

wide wharf
#

@quartz kindle Uh

/home/container $ node app.js
/home/container/app.js:1224
});
SyntaxError: Unexpected end of input
at new Script (vm.js:79:7)
at createScript (vm.js:251:10)
at Object.runInThisContext (vm.js:303:10)
at Module._compile (internal/modules/cjs/loader.js:656:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
at Function.Module._load (internal/modules/cjs/loader.js:529:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:741:12)
at startup (internal/bootstrap/node.js:285:19)
``` ^^^^^^
buoyant totem
#

So it turns out my entire bot script was deleted

quartz kindle
#

the code

#

not the error

buoyant totem
#

Im depressed now

wide wharf
#

Owh

buoyant totem
#

It was just completely overwritten

wide wharf
#
client.on('message', message => {
    if (!message.guild) return;
    client.channels.get('698983333782093925').send('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ \nServer: ' + message.guild.name + ' \nChannel: ' + message.channel.name + ' \nUser: ' + message.author.username + ' \nMessage: ' + message.content)
``` @quartz kindle^^^^
fallen pagoda
#

ngl, poop

quartz kindle
#

show more code

wide wharf
#

Uh but there must be the error... cuz thats the new code

calm shore
#

if(!message.guild.members.find(m => m.id == preId)) return;
^

TypeError: Cannot read property 'members' of null

bot.on('message', message => {
  let preId = "698950081038254240"
  if(!message.guild.members.find(m => m.id == preId)) return;
    if(message.content === `${prefix}help`) {

        let helpembed = new Discord.RichEmbed()
        .setAuthor("Teht")
        .setColor("#ff7600")
        .setDescription("Commands!\n\n1. -clear \n2. -ask (Question) {8ball CMD}\n3. -members\n4. -server\n5. -suggest\n6. -meme\n7. -botinfo\n8. -invites\n9. -blacklist {on/off}\n(This prevents discord links from being sent!)\n\nPage 1 >> (-page 2) in dms")
        .setFooter(` ❀️ Teht - Thank you for Joining Us!`);
        message.channel.send("You have been dmed a list of Commands!").then(message => {message.delete(6000)});
        message.author.send(helpembed);

    } else if(message.guild.members.find(m => m.id == preId)) {
      let helpembedpremium = new Discord.RichEmbed()
      .setAuthor("Teht")
      .setColor("#ff7600")
      .setDescription("Gay")
      .setFooter(` ❀️ Teht - Thank you for Joining Us!`);
      message.channel.send("You have been dmed a list of Premium Commands!").then(message => {message.delete(6000)});
      message.author.send(helpembedpremium);
    };
});```
It also sends both instead of one
quartz kindle
#

show the full message event

#

i want to see if you're closing it properly

wide wharf
#

Fixed xD, I forgot some ) and }

#

πŸ˜„

quartz kindle
#

thats what i thought

calm shore
#

can yall help me

quartz kindle
#

good that you found it

fallen pagoda
#

dont care didnt ask

crimson vapor
#

btw that code will result in an error

wide wharf
#

Thx πŸ˜ƒ

crimson vapor
#

wait no

calm shore
#

Million ik

#

if(!message.guild.members.find(m => m.id == preId)) return;
^

TypeError: Cannot read property 'members' of null

bot.on('message', message => {
  let preId = "698950081038254240"
  if(!message.guild.members.find(m => m.id == preId)) return;
    if(message.content === `${prefix}help`) {

        let helpembed = new Discord.RichEmbed()
        .setAuthor("Teht")
        .setColor("#ff7600")
        .setDescription("Commands!\n\n1. -clear \n2. -ask (Question) {8ball CMD}\n3. -members\n4. -server\n5. -suggest\n6. -meme\n7. -botinfo\n8. -invites\n9. -blacklist {on/off}\n(This prevents discord links from being sent!)\n\nPage 1 >> (-page 2) in dms")
        .setFooter(` ❀️ Teht - Thank you for Joining Us!`);
        message.channel.send("You have been dmed a list of Commands!").then(message => {message.delete(6000)});
        message.author.send(helpembed);

    } else if(message.guild.members.find(m => m.id == preId)) {
      let helpembedpremium = new Discord.RichEmbed()
      .setAuthor("Teht")
      .setColor("#ff7600")
      .setDescription("Gay")
      .setFooter(` ❀️ Teht - Thank you for Joining Us!`);
      message.channel.send("You have been dmed a list of Premium Commands!").then(message => {message.delete(6000)});
      message.author.send(helpembedpremium);
    };
});```
It also sends both instead of one
#

It shows the error above

crimson vapor
#

I was talking to ProCrafter tbh

calm shore
#

oh

crimson vapor
#

but I didnt see a line

quartz kindle
#

@calm shore did you actually do the changes you were suggested?

#

properly check for prefix

calm shore
#

What changed

#

changes?

quartz kindle
#

several people gave you things to do

calm shore
#

Oh wait

#

And i did them tim

#

no need to be rude abt it

crimson vapor
#

if( message doesnt starts with prefix) return;

#

Tim isnt being rude

quartz kindle
#

im not being rude, i want to see if you changed your code, because youre showing the same old code without any changes

#

i need to see your current updated code

calm shore
#

I tried what you suggested and it didnt work so i reverted back to the original

quartz kindle
#

then we're back to the same problem

crimson vapor
#

also Wobbly, when you create a variable that is 2 words, its common to capitalize the 2nd word's first letter

quartz kindle
#

we have to fix it one step at a time

calm shore
#

I added this

#

if(!prefix) return;

crimson vapor
#

no

quartz kindle
#

thats not it

#

you need to change your if else structure

#

for example

calm shore
#

Ohhh ik what you mean

prime cliff
#

if (message.content !== "prefixhelp")
return;

#

Basically that

crimson vapor
#

not exactly

prime cliff
#

So that it does not trigger on anything but commands

crimson vapor
#

you have a startsWith functon you can use

quartz kindle
#

you have this ```js
if(message.content === ${prefix}bla) {
// do something
} else if(members.find(bla)) {
// do something else
}

if you do that, you will have a piece of code that will ignore the prefix and attempt to run on messages without prefix or command
calm shore
#

I changed it to this

#
bot.on('message', message => {
  if(!prefix) return;
  let preId = "698950081038254240"
  if(!message.guild.members.find(m => m.id == preId)) {
    if(message.content === `${prefix}help`) {

        let helpembed = new Discord.RichEmbed()
        .setAuthor("Teht")
        .setColor("#ff7600")
        .setDescription("Commands!\n\n1. -clear \n2. -ask (Question) {8ball CMD}\n3. -members\n4. -server\n5. -suggest\n6. -meme\n7. -botinfo\n8. -invites\n9. -blacklist {on/off}\n(This prevents discord links from being sent!)\n\nPage 1 >> (-page 2) in dms")
        .setFooter(` ❀️ Teht - Thank you for Joining Us!`);
        message.channel.send("You have been dmed a list of Commands!").then(message => {message.delete(6000)});
        message.author.send(helpembed);
      }
    } else if(message.guild.members.find(m => m.id == preId)) {
      if(message.content === `${prefix}help`) {
      let helpembedpremium = new Discord.RichEmbed()
      .setAuthor("Teht")
      .setColor("#ff7600")
      .setDescription("Gay")
      .setFooter(` ❀️ Teht - Thank you for Joining Us!`);
      message.channel.send("You have been dmed a list of Premium Commands!").then(message => {message.delete(6000)});
      message.author.send(helpembedpremium);
    }
    };
});```
#

11

crimson vapor
#

no 11

#

Wobbly you need to check if the message content startsWith the prefix

calm shore
#

Thats the code

wide wharf
#
client.on('message', message => {
    if (!message.guild) return;
    client.channels.get('698983333782093925').send('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ \nServer: ' + message.guild.name + ' \nChannel: ' + message.channel.name + ' \nUser: ' + message.author.username + ' \nMessage: ' + message.content)});
``` @quartz kindle How can I do that the bot doesn't send messages of server with id (...) ?
crimson vapor
#

what spam?

royal portal
#

Anyone know what the process exit number is to restart a discord.js bot

crimson vapor
#

it was deleted

quartz kindle
#

@calm shore good, a bit wonky but it will work. now add an if(!message.guild) return at the beginning

crimson vapor
#

yes, I understand, I dont think he meant to though

quartz kindle
#

@wide wharf if(message.guild.id === "id") return

wide wharf
#

Ty!!

royal portal
#

Wait is it even possible to reload bot using process.exit

quartz kindle
#

yes if you have a process manager or an external monitoring process

royal portal
#

I tried process.exit(1) but that just stops the bot

finite bough
#

()

crimson vapor
#

if using pm2 I think process.exit() will just restart it

#

but I am not sure

royal portal
#

maybe something like

#

client.destroy

#

then client.login

crimson vapor
#

that will only relog the bot

#

you would need to put you event and command handler in that ready event as well as everything you want to happen at start iirc

finite bough
#

require('child_process').exec('refresh');

crimson vapor
#

that works?

finite bough
#

yes

royal portal
#

so i replace the process.exit with that

crimson vapor
#

I did not get it to work

finite bough
#

are u using an eval cmd?

crimson vapor
#

I did test with eval

finite bough
#

it didnt?

crimson vapor
#

no

finite bough
#

hmm

#

it only works for some domains

#

like glitch

#

client.destroy() without a rebooter = ded

astral yoke
#

I’m sorry but if your still using glitch and not like vs that’s kinda wonky

crimson vapor
#

yea

balmy knoll
#

How can I change the name of a channel that I specify via id (discord.js)?

finite bough
#

who said I am

astral yoke
#

β€œlike glitch”

#

kinda you

crimson vapor
#

other way around

finite bough
#

half of the server does

crimson vapor
#

client.destroy()
client.login()

royal portal
#

why would you login then destroy

#

destroy then login

finite bough
#

^

crimson vapor
#

Simo you need to fetch or grab the channel then you need to rename it

quartz kindle
#

destroy then login will restart the discord connection and state, but not the process

finite bough
#

boys times up big boy tim is here

balmy knoll
#

@crimson vapor I know the channel id that i want rename

crimson vapor
#

so you can either fetch it or grab it from cache

finite bough
#

use get

royal portal
#

works πŸ‘

crimson vapor
#

then you use the function to rename it

royal portal
#
client.destroy()
client.login('token here')
#

i just put an embed before it saying 'Restarted'

crimson vapor
#

yes but that would not really do what you want in most cases

#

you would need to reload ALL of your commands

#

and I Think you need to add back all of your events

royal portal
#

for some reason, i get an error in my console saying 'discordapierror'

crimson vapor
#

what error?

royal portal
#

its nothing to do with the restart

#

its an unban cmd

crimson vapor
#

ik

#

what error

royal portal
#

discordapi

crimson vapor
#

yes but what is the error?

royal portal
#

if someone wants to unban someone, they can still ping them when they are banned

#

lemme see

#

value <userid> is not snowflake

#

because the person tries to unban the user by mentioning the banned user

#

im not sure why discord lets us mention banned users

quartz kindle
#

mentions are global

royal portal
#

also

quartz kindle
#

they resolve differently to each user

royal portal
#

if I save my code and use that client.destroy and client.login, will it update the bot to that code

finite bough
#

u cant mention a member who is not cached in ur discord app

quartz kindle
#

you can

finite bough
#

or fails to cache it

quartz kindle
#

@royal portal no

royal portal
#

so if i save my code and use restart cmd it wont update the code?

quartz kindle
#

nope

finite bough
#

r u using a vps?

vague kite
#

Any mongoDB users that can help me out??

finite bough
#

with?

crimson vapor
#

sure what do you need Jaay

summer torrent
#

πŸ‘€

royal portal
#

i fixed my unban cmd

#

i just add .catch

vague kite
#

So I've been working on my bot for a while and recently I've been told to increase my Pool Size for the bot but I wasn't sure what to increase it

royal portal
#

does anyone know what exactly client.destroy and client.login does

#

for like a restart command

quartz kindle
#

@royal portal i told you what it does

royal portal
#

oh

#

connection and state

quartz kindle
#

it destroys the discord library and resets its state, then recreates it and logs in again

crimson vapor
#

sorry Jaay, I dont know about Pool Size

vague kite
#

Ahh okay that's fine I'll just keep on researching and trying to find the best option then ❀️

quartz kindle
#

pool size depends on how you use mongo, which library, which connection method, etc

vague kite
#

Ahh okay

royal portal
#

im gonna set up a bot

#

for 24/7

#

and see if it breaks

#

well if the status breaks

#

because when i try to host bot

#

status works for like 30 mins

icy crane
#

when doing process.cpuUsage();
what do these numbers actually mean? They have no real meaning to me

#
{ user: 329382193, system: 48866771 }
royal portal
#

the user is an integer represents the time elapsed by user

#

the system is an integer represents the time elapsed by system

icy crane
#

ah so... huh

#

ok

ripe lantern
#

can someone help me with just, coding a bot in general? because i dont know anything about how to do it

#

i cant find any reliable source to learn, because their code never works

icy crane
#

If you dont know the language that you plan to code in, I would recommend starting there

ripe lantern
#

i use python 3.6

icy crane
#

Do you have a general understanding for how it works?

ripe lantern
#

wym?

icy crane
#

Do you understand python. Can you code in regular python

#

without the use of i think d.py

#

i think thats the library for python

ripe lantern
#

kinda, just really basic stuff

icy crane
#

Well, I would recommend learning a bit before moving onto making a discord bot, as if you don't you wont really be learning anything and youll just be writing down what other people have done

ripe lantern
#

oh

#

where do i go to learn?

icy crane
#

Not sure, i code in nodejs

#

so

#

Β―_(ツ)_/Β―

#

Heres a page from a quick google search though

ripe lantern
#

should i just go with java?

icy crane
#

I mean, if you want to learn Java then sure

ripe lantern
#

yea, because everyone uses java anyways

finite bough
#

if u want to focus on making discord boys as a beginner

#

js

#

coz it has more docs and guides

icy crane
#

discord boys

#

: )

amber fractal
ripe lantern
#

lmao

icy crane
#

Alright, do you know of an easier way to calc cpu usage? Cause I used one method, but it ended up not working as it was just getting higher and higher as time went on

royal portal
#

@quartz kindle does the client.destroy and client.login reset setActivity too?

small spire
#

can i detect who is updated channel by using .on(ChannelUpdate with discord.js v11

icy crane
amber fractal
#

Yeah it's time, it goes up the longer it's running, are you looking for % cpu usage?

icy crane
#

Yeah

#

Ive tried different things, and even resorted to just straight up googling it cough cough stack overflow aylmao , but everything that ive tried just gets higher with time

small spire
#

@icy crane i couldn't see anything about the user who updated the channel on that docs page

icy crane
#

Then you probably can't

amber fractal
#

may help for what you want

#

but I don't think it's per process

icy crane
#

lol theres so many os packages, i have the default one, "os" then "os-utils" and now "node-os-utils"

amber fractal
#

lol yeah

#

I think os-utils does it as well

summer torrent
#

what is "client"

#

show full code

icy crane
#

@vivid cargo he meant what is client defined as

gritty bolt
#

all of the "stuff" is replaced text for simplicity

quartz kindle
#

first remove this

#

const bot = new discord.Client();

#

then show how you call that function, ie: where you do command.run()

royal portal
#

is there a way to set bot activity after client.destroy and client.login

quartz kindle
#

should be the same way as before

royal portal
#

i tried putting client.user.setActivity after client.login

#

didnt work

quartz kindle
#

it has to be in the ready event

royal portal
#

so is it not possible to do it by message?

#

how would I make it do the ready event when I reload

icy crane
#

@amber fractal sorry for the ping, but I just wanted to thank you! Works great!

quartz kindle
#

you want to set a different presence than you set before?

amber fractal
#

πŸ‘

royal portal
#

no I want it to show the status when reloaded

quartz kindle
#

the ready event should still work after re-logging in

royal portal
#

it doesn't

quartz kindle
#

so it should pick up the same code from there

royal portal
#

i dont know why but it doesnt even do the console.log in ready when i restart

quartz kindle
#

can you console.log(client._events) after destroy and login?

royal portal
#

only when I start bot it does it

#

lemme see

#

Object: null prototype

#

ready: function

#

message: function, function, asyncfunction, asyncfunction, function, function, asyncfunction

quartz kindle
#

so the events are still there, the ready event should fire again

royal portal
#

not sure why it doesnt

quartz kindle
#

can you show your full code?

royal portal
#

for restart?

quartz kindle
#

for restart and the main file

royal portal
#
const Discord = require('discord.js');
const client = new Discord.Client();

client.on('ready', () => {
  console.log(`Logged in as ${client.user.tag}!`);
  client.user.setActivity("with discord.js");
});

client.on('message', msg => {
  if (msg.content === 'ping') {
    msg.reply('Pong!');
  }
});

client.on("message", message => {
if (message.author.bot) return;
if (message.channel. type === 'dm') return;
if (message.author.id !== '364836696149458944') return;

  if (msg.content === 'restart') {
msg.reply("Restarted.");
client.destroy();
client.login('token');
console.log(client._events);
}
}
});

client.login('token');
empty owl
#

a

amber fractal
#

why do you have 2 message events?

royal portal
#

its a test code

#

so its fine

elder garnet
#

how do i get guild usercount?

empty owl
#

what lib

elder garnet
#

?

#

discordjs

empty owl
#

guildObject.members.size

elder garnet
#

guildobject?

empty owl
#

is this a command or what

elder garnet
#

wats da const

empty owl
#

what

elder garnet
#

for example

#

guildobject is not defined

#

so

#

what do i define it

empty owl
#

you switch guildObject with

#

whatever guild object u have

#

like message.guild

#

or sometihng

#

its supposed to return an object

grizzled raven
#

if you merge branches, github replaces the whole file with the new file, right?

royal portal
#

tim i sent code

quartz kindle
#

@royal portal so apparently the client does indeed remove the events but forgets to clean them up in client._events somehow

#

i cant find the source code for this, but i tested it

grizzled raven
#

like say if old file is ```js
let hello = 3
let s = 2
hello + s + 3

and new file is ```js
let s = 2
s + 3

will the final file be just what the new file is, or the origional as newfile is a subset of it

quartz kindle
#

so you do need to rebind/re-add all the events

royal portal
#

how would I do that

grizzled raven
#

i assume it replaces but idk this conflicts thing makes things confusing

royal portal
#

i can't add the events after client.login

empty owl
#

why dont u put clientlogin at the end

#

then

royal portal
#

it is

grizzled raven
#

nevermind

empty owl
#

then why do u need top add events after it

royal portal
#

because it removes it

#

im trying to use setActivity after client.destroy and client.login

grizzled raven
#

oh i commited to the wrong branch

#

come on

quartz kindle
#

you can probably hack it like this js for(let event in client._events) { client.on(event,client._events[event]) }

#

i didnt test this tho

royal portal
#

i'll test it

#

do i put it at the end of client.login

grizzled raven
#

wait

#

nah nvm

quartz kindle
#

afaik doesnt matter, as long as its after destroy()

royal portal
#

event is not defined

quartz kindle
#

for(let event in client._events)

royal portal
#

wait

#

i wrot

quartz kindle
#

i forgot the variable declaring

royal portal
#

i wrote for(event in event._events) {

#

hm lemme see for(let event in client._events)

#

wrote events instead of event

quartz kindle
#

events?

royal portal
#

I mean event

quartz kindle
#

there is no variable named events

royal portal
#
for(let event in client._events) {
  client.on(event,client._events[event])
}
#

ah

#

i would need to make it then

quartz kindle
#

no...

#

show the full error

royal portal
#

I meant

#

"listener" argument must be of type function. received an instance of array at checklistener

warm marsh
#

client._events[event] doesn't return a function.

grizzled raven
#

it does

#

or an array, if theres multiple

warm marsh
#

Like the error states. It's returning an Array.

near ether
#

how do collectors cause memory leaks?

#

is it only when you dont stop them?

royal portal
#

so what would I do to make 'listener' argument a type function

warm marsh
#

Use the console?

#

See what works best for you.

#
for (const event of client._events) 
{
  console.log(client._events[ event ]); 
}```
grizzled raven
#
client.on(event, typeof client._events[event] === "function" ? client._events[event] : client._events[event][0])
quartz kindle
#

@royal portal im testing it here but i cant figure out what exactly the destroy() function is doing, it seems to me that it leaves behind a dirty client

#

for example, the client status is still marked as "ready" after using destroy()

royal portal
#

yeah

quartz kindle
#

so the ready event will not fire again

royal portal
#

im not sure of another way to restart bot

warm marsh
#

process?

#

or pm2

royal portal
#

but to fire event again

quartz kindle
#

if i were you i would not even attempt to do what you're doing

#

it makes no sense in the first place

royal portal
#

okay

quartz kindle
#

everyone does it the process way

royal portal
#

process.exit?

quartz kindle
#

its the correct way because it leaves no dirty code behind

#

its a true clean start

royal portal
#

would i use process.exit

warm marsh
#

Yes

royal portal
#

but then that will just exit

warm marsh
#

Hence why I said use pm2.

quartz kindle
#

thats what i told you in the very beginning on this conversation

#

use a process manager

#

or a monitoring process

warm marsh
#

Use child_process to restart pm2.

#

I forgot the module name.

quartz kindle
#

child_process.exec()

warm marsh
#

Close enough

quartz kindle
#

@royal portal once a process is dead, its dead and thats it. it cant magically restart itself, it needs help from outside. a process manager can do such things, like monitor your process and auto-restart it when it closes

royal portal
#

do I need to add it to the code

#

a process manager

#

like separate js code

quartz kindle
#

most solutions out there, like pm2, dont require extra code

royal portal
#

im not sure how to use pm2 in the code

quartz kindle
#

with pm2 for example, you just need to install it, then run pm2 start index.js, instead of node index.js

grizzled raven
#

npm i pm2

#

or wait

#

eh whatever

royal portal
#

oh

warm marsh
#

npm i pm2 --save
npx pm2 start index.js

royal portal
#

so i dont node my code

quartz kindle
#

you probably want -g

warm marsh
#

or globally

quartz kindle
#

for global pm2

#

you can read all about it here

royal portal
#

so is it possible to add the pm2 code after the restart message

warm marsh
#

Yes.

quartz kindle
#

there is no need for that

#

instead of running your bot as a single node process, you make pm2 run it instead, and let pm2 take care of managing it

#

then your process will run inside pm2

#

once running in pm2, every time it exits, it automatically restarts

royal portal
#

so for my restart

quartz kindle
#

so you can just do process.exit() in your restart command

royal portal
#

do i do

#

process.exit

#

oh

#

i tried pm2

warm marsh
#

Don't you need a flag for that to be possible?

royal portal
#

command error

#

pm2

#

command not found

elder vine
#

What command?

warm marsh
#

run it in the terminal?

quartz kindle
#

did you install pm2?

royal portal
#

yes

#

am i doing this wrong

#

im running my bot code in pm2

elder vine
#

And it's running?

quartz kindle
#

how are you running it

warm marsh
#

pm2 start <botfile>.js

royal portal
#

oh

elder vine
#

not quite

royal portal
#

so i wrote

#

pm2 start bot.js

#

and

#

i saved it

#

as pm2.js

#

then in terminal i did

quartz kindle
#

what

elder vine
#

Hmm???

royal portal
#

pm2 start bot.js

#

and command error

elder vine
#

pm2 start 0

quartz kindle
#

you dont need to save any file

warm marsh
#

Have you done npm i -g pm2?

royal portal
#

its already installed

#

u

#

i have a file named

#

pm2.js

warm marsh
#

Why?

elder vine
#

wth?

royal portal
#

and it has the command in it

quartz kindle
#

you have to install it as a global installation, with the -g option

#

you dont need to create any file

warm marsh
#

Otherwise you need to use npx or filepath it.

quartz kindle
#

stop doing weird things on your own and listen to us lol

royal portal
#

i'll do npm i -g pm2

elder vine
#

yep

royal portal
#

now what

warm marsh
#

pm2 start bot.js --name Bot

#

optional flag

icy crane
#

wait, kinda just jumping in, if you do process.exit() or whatever, pm2 will auto restart it?

warm marsh
#

Yeah should do

elder vine
#

Yes @icy crane

icy crane
#

alright, cool

#

ty

royal portal
#

ok i did the thing

#

it says Done.

warm marsh
#

pm2 logs

elder vine
#

Alright

royal portal
#

and it says

#

id 0

elder vine
#

do pm2 list

#

ok

royal portal
#

ok

elder vine
#

pm2 start 0

warm marsh
#

0 should already be started

royal portal
#

it started

warm marsh
#

Do pm2 logs

royal portal
#

wait

#

missing something after argument list

#

lemme fix it real quick

gaunt torrent
#

Hi, who knows a bot that puts a reaction to every message in a specific channel?

royal portal
#

why?

warm marsh
#

That's not a good idea for a bot due to rate limiting.

royal portal
#

i checked logs

#

it had too many unstable restarts

#

16

#

stopped.

#

missing ) after argument list

warm marsh
#

That's an error in your bot code.

royal portal
#

its for process.exit

elder vine
#

You need () after process.exit

royal portal
#

process.exit();
}
})
}
});

elder vine
#

What??

warm marsh
#

oh no

#

indent

grizzled raven
#

anyone here use atom

elder vine
#

I "used" to use Atom.

grizzled raven
#

if so, the env file isnt coloured, would thta mean anything?

royal portal
#

is it

warm marsh
#

Normal

elder vine
#

Most likely not.

royal portal
#

process.exit();
}
})
});

grizzled raven
#

like a created a file called .env

#

ok cool

warm marsh
#

It's not coloured in many editors.

grizzled raven
elder vine
#

:)

grizzled raven
#

just wondering

regal saddle
#

noob, i thought i was in off topic pandasad

grizzled raven
#

liek i

#

like i feel like it was before

#

but

royal portal
#

or do I need to add something after

grizzled raven
#

/sheug

regal saddle
#

F

elder vine
#

Maybe u got a different theme?

grizzled raven
#

seems like glitch is one of the only ones that has it coloured lmao

quartz kindle
#

@royal portal you need to show a proper code block that includes the entire function you want to fix, else we dont understand anything you're saying

elder vine
#

If I'm not wrong VSC has it too

#

When I use a theme xD

warm marsh
#

Nope

grizzled raven
warm marsh
#

vim has it defaulted

grizzled raven
#

well

#

time to update my bot

#

when i first got the vps i had no idea i needed dotenv, so when .env didnt work i resorted to a env.js file lmao

royal portal
#

I fixed it

#

it says logged in

warm marsh
#

dotenv isn't needed

elder vine
#

It's handy for when you upload to github tho

warm marsh
#

You just need to put the environment variables into env

royal portal
#

works

#

perfectly

elder vine
#

Good.

grizzled raven
#

that wasnt the case for me then

warm marsh
#

export TOKEN="token"

royal portal
#

but where does .catch go to

grizzled raven
#

holdon what

royal portal
#

does it log it in the pm2 logs

elder vine
warm marsh
#

Yes

#

@royal portal pm2 logs is just your console

royal portal
#

also

#

pm2 start bot.js --name Bot

#

do i need that --name bot part

warm marsh
#

no

royal portal
#

ah ok

grizzled raven
#

huh

#

well i'll use dotenv anyway lmao

warm marsh
#

Fair

royal portal
#

the only thing is

grizzled raven
#

.env used to just return undefined

#

and .env had its own vars from the vps

royal portal
#

missing ) after argument list

grizzled raven
#

add a )

elder vine
#

Wow, I just discovered pm2 monitor

warm marsh
elder vine
#

That's awesome

royal portal
#
const Discord = require('discord.js');
const client = new Discord.Client();

client.on('ready', () => {
  console.log(`Logged in as ${client.user.tag}!`);
  client.user.setActivity("with discord.js");
});

client.on('message', msg => {
  if (msg.content === 'ping') {
    msg.reply('Pong!');
  }
});

client.on("message", msg => {
if (message.author.bot) return;
if (message.channel. type === 'dm') return;
if (message.author.id !== '364836696149458944') return;

  if (msg.content === 'restart') {
msg.reply("Restarted.");
process.exit();
};
});

client.login('token');
elder vine
#

Oml the indents

royal portal
#

yeah

warm marsh
#

Use something like eslint

elder vine
#

Fix xD

warm marsh
#

wtf

elder vine
#

Remove the top }) ones

#

from the message event

warm marsh
#

yes

royal portal
#

like that?

elder vine
#

Yes.

#

Now, try it :)

royal portal
#

wait

#

how do i stop pm2

elder vine
#

pm2 stop 0

#

pm2 restart 0

#

pm2 start 0

#

ez pz

royal portal
#

how to remove from list

warm marsh
#

pm2 stop id && pm2 delete id

#

Might cause an error on windows but idk

royal portal
#

and

#

to start the process

elder vine
#

pm2 start 0

royal portal
#

but its deleted

warm marsh
#

pm2 start bot.js

elder vine
#

Why would you delete it?

quartz kindle
#

pm2 is wonky with package changes

royal portal
#

errors

elder vine
#

What error?

royal portal
#

missing ) after argument list

quartz kindle
#

sometimes i update or change a package and do pm2 restart, and the old packages are still being used

royal portal
#

for the thing you said

elder vine
#

Show code again.

royal portal
#
const Discord = require('discord.js');
const client = new Discord.Client();

client.on('ready', () => {
  console.log(`Logged in as ${client.user.tag}!`);
  client.user.setActivity("with discord.js");
});

client.on('message', msg => {
  if (msg.content === 'ping') {
    msg.reply('Pong!');
  }
});

client.on("message", msg => {
if (message.author.bot) return;
if (message.channel. type === 'dm') return;
if (message.author.id !== '364836696149458944') return;

  if (msg.content === 'restart') {
msg.reply("Restarted.");
process.exit();
};
});

client.login('token');
#

its the }; part

warm marsh
#

remove the semi colon

elder vine
#

Shouldn't matter

royal portal
#

i did

quartz kindle
royal portal
#

now missing ) after argument list

#

oh

elder vine
#

yikes

royal portal
#

still

#

i fixed it

#

and

#

still same thing

#

wait

#

thats because

#

i still have

#

client.login

#

.-.

elder vine
#

?

royal portal
#

because i copied code from rpi

elder vine
#

because i copied code from rpi
Why?

#

Well, as long as you understand, right?

royal portal
#

missing ) after argument list

elder vine
#

Which line?

royal portal
#

the }

warm marsh
#

You might want to add a .then or await to your message.reply

quartz kindle
#

then you need to post your current code

royal portal
#

ok

warm marsh
#

as process will call at the exact same time.

elder vine
#

That will not work

#

since bot restarts

royal portal
#
const Discord = require('discord.js');
const client = new Discord.Client();

client.on('ready', () => {
  console.log(`Logged in as ${client.user.tag}!`);
  client.user.setActivity("with discord.js");
});

client.on('message', msg => {
  if (msg.content === 'ping') {
    msg.reply('Pong!');
  }
});

client.on("message", msg => {
if (message.author.bot) return;
if (message.channel.type === 'dm') return;
if (message.author.id !== '364836696149458944') return;

if (msg.content === 'restart') {
msg.reply("Restarted.");
process.exit();
}
});

client.login('token');
warm marsh
#
message.reply('Restarting...').then(() => process.exit());
elder vine
#

Why do you have two message events...?

quartz kindle
#

can you post the full error?

royal portal
#

}

#

syntax error

elder vine
#

The full error

#

Copy the error

royal portal
#

ok let me email myself that

elder vine
#

?

quartz kindle
#

wt

elder vine
#

Are you on mobile or smth?

warm marsh
#

Control right click it

elder vine
#

Just take a pic

royal portal
#

i cant

#

its on my rpi

quartz kindle
#

even mobile lets you long press, select and copy

warm marsh
#

Oh

elder vine
#

Oh

quartz kindle
#

@royal portal how are you accessing/viewing your rpi?

warm marsh
#

Just ssh to it?

royal portal
#

through my rpi

#

ik i can use putty

#

hold on let me do that

warm marsh
#

Putty?

#

If you're on the latest version of windows there isn't a requirement for putty

#

Unless that's just a 'pro' thing

elder vine
#

Snowflake works good for me :)

royal portal
#
0|bot  | /home/pi/Desktop/Other/DiscordBot/bot.js:19
0|bot  | }
0|bot  | ^
0|bot  | SyntaxError: missing ) after argument list
0|bot  |     at wrapSafe (internal/modules/cjs/loader.js:1072:16)
0|bot  |     at Module._compile (internal/modules/cjs/loader.js:1122:27)
0|bot  |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
0|bot  |     at Module.load (internal/modules/cjs/loader.js:1002:32)
0|bot  |     at Function.Module._load (internal/modules/cjs/loader.js:901:14)
0|bot  |     at Object.<anonymous> (/home/pi/.config/nvm/versions/node/v12.16.1/lib/node_modules/pm2/lib/ProcessContainerFork.js:32:23)
0|bot  |     at Module._compile (internal/modules/cjs/loader.js:1158:30)
0|bot  |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
0|bot  |     at Module.load (internal/modules/cjs/loader.js:1002:32)
0|bot  |     at Function.Module._load (internal/modules/cjs/loader.js:901:14)
warm marsh
#

message.reply line

royal portal
#

it isnt

warm marsh
#

According to the code block you sent line 19 points to the msg.reply line.

royal portal
#

i dont get whats wrong with it

warm marsh
#

Oh I bet it's due to that indenting

royal portal
#

yeah

quartz kindle
#

js doesnt care about indentation

#

the last code you posted has nothing wrong as far as i can see

royal portal
#

so if i do

#

message.reply('Restarting...').then(() => process.exit());

#

unexpected token )

#

message.reply('Restarting...').then(() => process.exit());

#

for that part

#

that I made bold

#

if I remove it, should work

warm marsh
#

That's not the error then.

#

Do you know how it works?

gritty bolt
warm marsh
#

jesus where's darkmode?

gritty bolt
#

I asked earlier and changed a few things, but I'm still getting nothing with no errors

royal portal
#

its just that }

blazing portal
#

so many rows without semicolon... ree

royal portal
#

on mine?

warm marsh
#

no

gritty bolt
#

on mine?

blazing portal
#

nah, Sbss

warm marsh
#

JS isn't bothered for semi-colons

quartz kindle
#

@gritty bolt you need to show how you use that code

#

how you call it

blazing portal
#

i know, it's stil triggering me πŸ˜„

warm marsh
#

Yeah

royal portal
#

now about

gritty bolt
#
//FS Reading
    fs.readdir("./Commands", (err, files) => {
        if (err) console.log(err);
        let jsfile = files.filter(f => f.split(".").pop() === "js");
        if (jsfile.length <= 0) {
            console.log("Couldn't find commands.");
            return;
        }
        jsfile.forEach((f, i) => {
            let props = require(`./Commands/${f}`);
            console.log(`${f} loaded!`);
            bot.commands.set(props.help.name, props)
        })
    });
//Command Starter
    bot.on("message", async message => {
        if (message.author.bot) return;
        if (message.channel.type === "dm") return;
        let prefix = ">";
        let messageArray = message.content.split(" ");
        let cmd = messageArray[0];
        let args = messageArray.slice(1);

        let commandfile = bot.commands.get(cmd.slice(prefix.length));
        if (commandfile) {
            if(cmd.startsWith(prefix)) {
            commandfile.run(bot, message, args)
    }}});```
royal portal
#

if (message.content === 'restart') {
if (message.author.id !== '364836696149458944') return;
message.channel.send('Restarted.').then(() => {
process.exit(1);
})
};

warm marsh
#

Yea

royal portal
#

would that work

warm marsh
#

Yeah

royal portal
#

but then wouldnt i need }) to close it off

earnest phoenix
#

@royal portal want to restart the bot?

royal portal
#

at end

#

yea

warm marsh
#

Why?

earnest phoenix
#

That will not work

#

That will just shutdown the bot instead of restarting it

royal portal
#

no

#

pm2

earnest phoenix
#

Using pm2?

royal portal
#

yea

warm marsh
#
client.on('message', function(msg) {
  // checks

  // commands
  if (msg.content == 'restart') {
    if (msg.id == 'id')
      msg.reply('Restarting...').then(() => process.exit());
  }
});```
earnest phoenix
#

@warm marsh process.exit(1)

warm marsh
#

It's not required

#

It's an optional code.

earnest phoenix
#

Is it tho?...

warm marsh
#

Yes

earnest phoenix
#

Hmm if it doesn't work then add that 1 anyway

warm marsh
#

Closes the node process

earnest phoenix
#

Hmm ok...

royal portal
#

unexpected end of input

#

on a line that doesnt exist

warm marsh
#

Typical js

royal portal
#

but

warm marsh
#

Get a linter

royal portal
#

it still works

earnest phoenix
#

I also have a command like that but it's only for shuting down the bot

quartz kindle
#

@royal portal the only explanation for that is that you didnt show your full code

#

you either left something out of it, or you posted an outdated code

warm marsh
#

Also don't use multiple message listeners for commands that's a very inefficient way.

#

And considering the default max is 10. You can only get 9 commands and ready listener.

quartz kindle
#

@royal portal also, just to confirm, are you doing pm2 restart everytime you update your code?

royal portal
#

no

#

pm2 delete 0

#

pm2 start bot.js

warm marsh
#

Add --watch

#

until you're done developing

royal portal
#

why --watch

warm marsh
#

pm2 start bot.js --watch

royal portal
#

does it like update code everytime i save

warm marsh
#

Yes

royal portal
#

and restart

earnest phoenix
#

Is there any other module that can restart the bot?

warm marsh
#

It restarts the process everytime you save.

#

pm2?

earnest phoenix
#

Because i can't install pm2 on my Termux on my phone lmao

warm marsh
#

Lmao

royal portal
#

here's the code

#
client.on("message", message => {
  if (message.author.bot) return;
  if(message.channel.type === "dm") return;
  if (message.author.id !== '364836696149458944') return;
 
  let prefix = "-";
  if (message.content.indexOf(prefix) !== 0) return;
 
  const args = message.content.slice(prefix.length).trim().split(/ +/g);
  const command = args.shift().toLowerCase();

 if (command === "restart") {
   
  const embed = new Discord.MessageEmbed()
  .setDescription(":computer: Restarted.")
  .setColor(0x00AE86)
  message.channel.send(embed).then(() => process.exit());
    }
});
warm marsh
#

Idk in termux but there is alternate ways.

royal portal
#

is that the problem

#

unexpected end of input

warm marsh
#

No

#

Wait

royal portal
#

not on that code

#

all of my code

#

like after client.login line

#

right at end of whole code

#

it says 207 line

#

but i didnt write anything in that line

icy crane
#

of what file

earnest phoenix
#

@royal portal you're missing either a bracket or parentheses or something

icy crane
#

send the whole error

quartz kindle
#

@royal portal when the error is on a non-existent line at the end of the file, the real problem is a missing ) or } somewhere in the file. it can be anywhere

#

thats why you need to post the FULL code

#

the entire file

blazing portal
#

a linter would also help here

earnest phoenix
#

He is missing either } ) or something or he misplaced them

warm marsh
#

use hastebin and send all the code in the file excluding token

earnest phoenix
#

Yea that would help

gritty bolt
#

This is my FS code```js
//FS Reading
fs.readdir("./Commands", (err, files) => {
if (err) console.log(err);
let jsfile = files.filter(f => f.split(".").pop() === "js");
if (jsfile.length <= 0) {
console.log("Couldn't find commands.");
return;
}
jsfile.forEach((f, i) => {
let props = require(./Commands/${f});
console.log(${f} loaded!);
bot.commands.set(props.help.name, props)
})
});
//Command Starter
bot.on("message", async message => {
if (message.author.bot) return;
if (message.channel.type === "dm") return;
let prefix = ">";
let messageArray = message.content.split(" ");
let cmd = messageArray[0];
let args = messageArray.slice(1);

    let commandfile = bot.commands.get(cmd.slice(prefix.length));
    if (commandfile) {
        if(cmd.startsWith(prefix)) {
        commandfile.run(bot, message, args)
}}});```

@gritty bolt

quartz kindle
#

@gritty bolt what is the problem again?

warm marsh
#

No error

gritty bolt
#

im running my command and nothing is happening

#

no error

warm marsh
#

Does any command run?

gritty bolt
#

yes

#

its just this one

warm marsh
#

Then that's not the error.

#

It's the code itself.

quartz kindle
#

try adding a console.log at the beginning of the command

#

to see if it logs

gritty bolt
#

ok

royal portal
#

i cant save

#

in hastebin

#

'something went wrong'

gritty bolt
#

i think its down

quartz kindle
#

then use some other bin

gritty bolt
#

i had the same issue, hence why i used pastebin

earnest phoenix
#

@royal portal how long is your code lol?

royal portal
gritty bolt
#

i got it

royal portal
#

@quartz kindle

quartz kindle
#

you posted your token

gritty bolt
#

im stupid i used the wrong number of args

royal portal
#

oh

#

i regenerated it

#

@quartz kindle no one can access it if i regenerated it now?

blazing portal
#

correct

earnest phoenix
#

@royal portal i literally saw no Missing } or ) or anything else...
And also why are you making a message event for every single one of your commands? Isn't just one enough?

royal portal
#

its fine

#

im not sure why i get that error tho

#

did i accidentally type something

earnest phoenix
#

Hmm... Something is 100% missing but i wasn't able to find it...

royal portal
#

im not sure what

#

everything works fine its just that weird line

blazing portal
#

row 204, look at the end

#

what is that

royal portal
#

oh

#

ya

#

fixed

#

it just shows old error log

#

why

#

@blazing portal thanks for finding that mistake

earnest phoenix
#

@royal portal can you show us what did you edit?

blazing portal
#

you're welcome

royal portal
#

row 204

#

the end part

#

it had a symbol

#

a straight line

earnest phoenix
#

Hmm... I saw...

#

But don't you say it's showing the same error?

quartz kindle
#

thats a bitwise OR operator

royal portal
#

no i mean

#

it shows

#

my token error when i changed token

#

the token is right now

#

kitty-error.log last 15 lines

earnest phoenix
#

Oh ok

royal portal
#

how do i make it so it just forgets that log

#

because the token is now corrct

earnest phoenix
#

@blazing portal you got an eagles eye ngl...

#

@royal portal huh wdym?

royal portal
#

ok i fixed it

#

i deleted old error log files

earnest phoenix
#

Lol

royal portal
#

and also

#

can someone help me

#

on my unban cmd

#
client.on("message", async message => {
  if (message.author.bot) return;
  if(message.channel.type === "dm") return;
 
  let prefix = "-";
  if (message.content.indexOf(prefix) !== 0) return;
 
  const args = message.content.slice(prefix.length).trim().split(/ +/g);
  const command = args.shift().toLowerCase();
 
 if (command === "unban") {
 if (!message.guild.me.hasPermission('BAN_MEMBERS')) return message.channel.send('Error: I don\'t have the permission to unban members.');
 if (!message.member.roles.cache.some(role => role.name === 'Server Administrator')) return;
 
        let bannedMember = await client.users.fetch(args[0]).then().catch(console.error);
        if(!bannedMember) return message.channel.send("Please provide a userID to unban someone.")
 
    let reason = args.slice(1).join(" ")
        if(!reason) reason = "No reason given."
        let logsChannel = message.guild.channels.cache.find(ch => ch.name === "mod-log");
 
    let embed = new Discord.MessageEmbed()
.setTitle('Unban')
.addField('User', `${bannedMember.tag} (<@${bannedMember.id}>)`, true)
.addField('Moderator', message.author.tag, true)
.addField('Reason', reason)
.setColor("#00ff00")
.setTimestamp();
 
    if(!message.guild.me.hasPermission(["BAN_MEMBERS", "ADMINISTRATOR"])) return message.channel.send("Error: I don't have permission to perform this command.")|
    message.delete()
    try {
        message.guild.members.unban(bannedMember).then().catch(console.error);
        logsChannel.send(embed).then().catch(console.error);
    } catch(e) {
        console.log(e.message)
    }
  }
});
earnest phoenix
#

What's the issue?

royal portal
#

for some reason, you can unban a user which is already unbanned and it still logs the unban embed to mod-logs channel

#

and since I have .catch, it logs the error into my console saying unknown ban

#

not sure how to make it so if user already unbanned then just do nothing