#DiscountedJames DiscordBot Help

1 messages · Page 1 of 1 (latest)

wicked wave
#

@sullen wind

sullen wind
#

Oh hi

wicked wave
#

This is it

sullen wind
#

Ok so basically heres what you need

wicked wave
#

ok

sullen wind
#

rename the thread to "DiscountedJames DiscordBot Help"

#

or something like that bc a mod might take this down if it is "ok"

wicked wave
#

DiscountedJames DiscordBot Help

sullen wind
#

alright thats better

#

k Ima send you a snippet of my code

#
try {
    client.commands.get(commands).execute(client, message, args);
  
} catch (e) {
      message.reply(`there was an error trying to execute that command! \`${e}\``).then((e) =>{
console.log(e)
    })
    console.log(error)
      }```
#

oh wait let me fix somethings for you

wicked wave
#

ok

sullen wind
#

Alr where is your command

#

can you give me a screenshot?

wicked wave
sullen wind
#

ok so its message.reply('Test is working')

wicked wave
#

This is the error

signal lodge
#
const [cmd, ...args] = message.content
            .slice(prefix.length)
            .trim()
            .split(/ +/g);
#

i did this

sullen wind
#

oh you using v13

#

well it still should work

#

oh you need to define commands lol

signal lodge
#
const command = client.commands.get(cmd.toLowerCase()) || client.commands.find(c => c.aliases?.includes(cmd.toLowerCase()));

sullen wind
#

nope

signal lodge
wicked wave
#

all on one line?

signal lodge
#

lemi send the whole file

sullen wind
#

k

signal lodge
#
if (
            message.author.bot ||
            !message.guild ||
            !message.content.toLowerCase().startsWith(prefix)
        )
            return;
        if (!message.channel.permissionsFor(message.guild.me).has("SEND_MESSAGES")) return

        const [cmd, ...args] = message.content
            .slice(prefix.length)
            .trim()
            .split(/ +/g);
    
        const command = client.commands.get(cmd.toLowerCase()) || client.commands.find(c => c.aliases?.includes(cmd.toLowerCase()));
    
        if (!command) return;
        try{    
            await command.run(client, message, args);
        } catch(err) {
            console.log(err)
        }
#

wait are u making slash command?

wicked wave
#

no

sullen wind
#

no hes/she not

signal lodge
#

then u can use this

sullen wind
#

idk

wicked wave
#

Where do I add this bit tho

sullen wind
#

I'm using v12 because I understand it better when I'm making a new bot

sullen wind
#

but I understand v13

#

I hate it honestly

#

its way too confusing

signal lodge
#

its not

sullen wind
#

especially for a simple bot

#

eh for me it is

signal lodge
#

and removed

wicked wave
#

I have this

signal lodge
sullen wind
#

I had to dig up an old repl that still had discord.js v12

wicked wave
sullen wind
#

bc you can't download it anymore

#

and v13 doesn't work on repl

#

bc their node isn't up to date

signal lodge
#
client.on("messageCreate", async (message){


})
#

in there

sullen wind
#

they are on node version 8

signal lodge
#

sad

sullen wind
#

yea

#

npm version is

#

...

wicked wave
sullen wind
#

6.14.15

signal lodge
sullen wind
signal lodge
#

it should be updated

wicked wave
signal lodge
#

latest is like 17

#

huh

sullen wind
#

oh

#

I know

#

just put }) at the end

signal lodge
#

show the ending

wicked wave
sullen wind
#

yea see that lonely bracket

wicked wave
#

yeah

signal lodge
#

no.

sullen wind
#

give it a friend

#

)

signal lodge
#

there isnt

#

no n

#

tht

sullen wind
#

yea }

signal lodge
#

}

#

is from try catch

sullen wind
#

oh then uhh

wicked wave
sullen wind
#

try adding another })

#

and if that gives you an error remove the }

#

thats what I do

#

lol

signal lodge
#

show the whole file

sullen wind
#

use source bin

signal lodge
#

yeh

sullen wind
#

rip airpod

wicked wave
signal lodge
sullen wind
#

no like not a screen shot

sullen wind
#

just remove your token

signal lodge
#

oh wait

#

ik

wicked wave
signal lodge
#

it will be a function

#

arrow function

#

(message) => {

#

add the

#

=>

#

after mesage

#

like that

sullen wind
#

yea

signal lodge
#

we are dum

sullen wind
#

thats what I was about to say

wicked wave
#

It works but the commands responds with nothing

sullen wind
#
client.on("messageCreate", async (message) => {```
signal lodge
#

yep

wicked wave
signal lodge
#

yes

#

now run

sullen wind
#

try now

wicked wave
signal lodge
#

uhhh

#

whats the prefix?

wicked wave
sullen wind
#

oh

signal lodge
#

have u exported client?

#

from index

#

to that file

wicked wave
sullen wind
#

no

signal lodge
#

or u are in main file?

sullen wind
#

I told him to

#

or her

signal lodge
#

hmmm

wicked wave
#

also where in here does it say to go to my test.js file

signal lodge
#

u see

#

the

#

command.run

wicked wave
#

yeha

#

Wont I need to put test.js somewherer

signal lodge
#

client.commands.get

#

here

#

see that

wicked wave
sullen wind
#

yea its not command.run

signal lodge
#

no no

sullen wind
#

no its not

signal lodge
#

its searching for the test.cjs there

sullen wind
#

but its not right

#

command.run doesn't exist

wicked wave
#

How does it know which one though the folder could have a ban.cjs there

sullen wind
#

OH

#

your using CJS

#

thats why

signal lodge
#

whats cjs..?

sullen wind
#

its commando js

signal lodge
#

oh.

sullen wind
#

its only v12

signal lodge
#

thats y..

sullen wind
#

thats why

signal lodge
#

welp then im out..

sullen wind
#

same

signal lodge
#

idk much v12

wicked wave
sullen wind
#

good luck @wicked wave

wicked wave
#

I changed it

#

to js

signal lodge
#

are u using

#

commando?

sullen wind
#

Yes

wicked wave
#

not sure tbh

signal lodge
#

open the

sullen wind
#

ok for starters you can't just change the file name

signal lodge
#

main directory

#

and open cmd

#

and run

wicked wave
#

index.js right

sullen wind
#

you have to install regular discord.js

signal lodge
#

npm ls discord.js

#

do that

wicked wave
sullen wind
#

ok so

signal lodge
#

ok that is good

sullen wind
#

it is discord.js

signal lodge
#

y were u using cjs?

sullen wind
#

probably new to it lol

signal lodge
#

ig

sullen wind
#

yea commando is v12 only

wicked wave
#

bc when I used test.js it got an error in console to change it to cjs

sullen wind
#

theres v14?

signal lodge
#

nop

sullen wind
#

lol the one I am using is officially unsupported

#

but it will still work hopefully

signal lodge
#

show ur messagecreate file

#

pls

sullen wind
#

alr well I'm out

wicked wave
#

the test.js file?

sullen wind
#

best of luck you you james

signal lodge
#

no

#

the event

#

bot..on

#

one

signal lodge
#

welp he is gone

#

i will try my best to help

#

can u

#

do

#

const prefix = "-"

#

on the top

wicked wave
#
import DiscordJS, { Intents } from 'discord.js'
import dotenv from 'dotenv'
dotenv.config()

const client = new DiscordJS.Client({
    intents: [
        Intents.FLAGS.GUILDS,
        Intents.FLAGS.GUILD_MESSAGES,
    ]
})

const prefix = '-';

import fs from 'fs'
 
client.commands = new DiscordJS.Collection();
 
const commandFiles = fs.readdirSync('./commands/').filter(file => file.endsWith('.cjs'));
for(const file of commandFiles){
    const command = import(`./commands/${file}`);
 
    client.commands.set(command.name, command);
}


client.on('ready', () => {
    console.log('worker is Online')
    client.user.setActivity({ type: "PLAYING", name: `nothing` })



    const guildID = '866288311416913932'
    const guild = client.guilds.cache.get(guildID)
    let commands

    if (guild) {
        commands = guild.commands
    }   else {
        commands = client.application?.commands
    }

    commands?.create({
        name: 'test',
        description: 'Test CMD',
    })
})
#
client.on('interactionCreate', async (interaction) => {
    if (!interaction.isCommand()) {
        return
    }

    const { commandName, options } = interaction

    if (commandName === 'test') {
        interaction.reply({
            content: 'Test is working',
            ephemeral: true,
        })
    }
})


//TEST CMD
client.on('messageCreate', (message) => {
    if (message.content === 'test') {
        message.reply({
            content: 'Test is working',
        })
    }
})



//Prefix TEST CMD
client.on("messageCreate", async (message) => {
    if (
            message.author.bot ||
            !message.guild ||
            !message.content.toLowerCase().startsWith(prefix)
        )
            return;
        if (!message.channel.permissionsFor(message.guild.me).has("SEND_MESSAGES")) return

        const [cmd, ...args] = message.content
            .slice(prefix.length)
            .trim()
            .split(/ +/g);
    
        const command = client.commands.get(cmd.toLowerCase()) || client.commands.find(c => c.aliases?.includes(cmd.toLowerCase()));
    
        if (!command) return;
        try{    
            await command.run(client, message, args);
        } catch(err) {
            console.log(err)
        }

})

client.login(process.env.TOKEN)
#

Thats my index.js

signal lodge
#

wait u dont have

wicked wave
signal lodge
#

//TEST CMD
client.on('messageCreate', (message) => {
if (message.content === 'test') {
message.reply({
content: 'Test is working',
})
}
})

#

this works?

wicked wave
#

yes.

signal lodge
#

ok niec

#

change the endsWith

#

to .js

wicked wave
#

done

#

Then I get this error

signal lodge
#

huh

wicked wave
signal lodge
#

that is weird..

#

what node version u have?

wicked wave
signal lodge
#

ok ok u dont define description

#

remove tht line

#

and did u do node test.js?

wicked wave
#

no

signal lodge
#

weird..

#

did u do node index.js?

wicked wave
#

no

signal lodge
#

how do u start ur bot?

wicked wave
#

I run the bot on a vps

#

Using Pterodactyl

signal lodge
#

so u need to do a command

#

to start it

#

oh

#

ic

wicked wave
#

?

signal lodge
#

lemi think

#

did u update the code on the vps?

wicked wave
#

yeah

signal lodge
#

ok so

wicked wave
#

The console error

signal lodge
#

whts the startup command?

wicked wave
#

let me find it

signal lodge
#

its in the startup tab

wicked wave
#

if [[ -d .git ]] && [[ 0 == "1" ]]; then git pull; fi; if [[ ! -z ${NODE_PACKAGES} ]]; then /usr/local/bin/npm install ${NODE_PACKAGES}; fi; if [[ ! -z ${UNNODE_PACKAGES} ]]; then /usr/local/bin/npm uninstall ${UNNODE_PACKAGES}; fi; if [ -f /home/container/package.json ]; then /usr/local/bin/npm install; fi; /usr/local/bin/node /home/container/index.js

signal lodge
#

wtf

#

what host?

wicked wave
signal lodge
#

ima give u a github link to a template

wicked wave
#

ok

signal lodge
#

use that its very good

wicked wave
#

ok thanks

signal lodge
#

u have to change smthing

#

in the handler folder there is index.js file

wicked wave
#

yeha

signal lodge
#

so in that file

#

there will be a part like this

wicked wave
#

yeha

#

the guild id?

signal lodge
#

so u see the .get("740082553561808906")

#

so in there

#

u put ur guid id if u want slash commands for 1 guild

wicked wave
#

yeah ok

signal lodge
#

or do this for every guild

wicked wave
#

yeah like this

signal lodge
#

yeh

#

and comment the other lines

#

await etc

wicked wave
#

yeh I see

#

OK thanks! for your help

#

have a good day

signal lodge
#

it works?

#

also 1 more this the commands u make will be in a subfolder not in

#

the commands folder

#

like this

#
module.exports = {
    name: 'ping',
    run: async (client, message, args) => {
        message.channel.send(`${client.ws.ping}ms ping!`)
        
    }
}
#

and this is how to make

#

commands

wicked wave
#

yeah I see