NotOreoo
NotOreoo

Reputation: 21

Discord bot not coming online despite no error messages?

I have recently spent a long time making a discord ticket bot, and all of a sudden now, it isnt turning on. There are no error messages when I turn the bot on, and the webview says the bot is online. I am hosting on repl.it

Sorry for the long code, but any genius who could work this out would be greatly appreciated. Thanks in advance.

const fs = require('fs');

const client = new Discord.Client();

const prefix = '-'

client.commands = new Discord.Collection();

const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));

for (const file of commandFiles){

  const command = require(`./commands/${file}`)

  client.commands.set(command.name, command);

}

require('./server.js')

client.on("ready", () => {

  console.log('Bot ready!');
  client.user.setActivity('-help', { type: "LISTENING"} ).catch(console.error)

})

client.on("message", async (message) => {

  if (message.author.bot) return;

  const filter = (m) => m.author.id === message.author.id;
 
  if (message.content === "-ticket") {

    let channel = message.author.dmChannel;
    if (!channel) channel = await message.author.createDM();

    let embed = new Discord.MessageEmbed();
    embed.setTitle('Open a Ticket')
    embed.setDescription('Thank you for reaching out to us. If you have a question, please state it below so I can connect you to a member of our support team. If you a reporting a user, please describe your report in detail below.')
    embed.setColor('AQUA')

    message.author.send(embed);
    channel  
      .awaitMessages(filter, {max: 1, time: 1000 * 300, errors: ['time'] })
      .then ( async (collected) => {

        const msg = collected.first();
        
        message.author.send(`
        >>> ✅ Thank you for reaching out to us! I have created a case for your inquiry with out support team. Expect a reply soon!
❓ Your question: ${msg}
        `);

        let claimEmbed = new Discord.MessageEmbed();
        claimEmbed.setTitle('New Ticket')
        claimEmbed.setDescription(`       
        New ticket created by ${message.author.tag}: ${msg}

        React with ✅ to claim!
        `)
        claimEmbed.setColor('AQUA')
        claimEmbed.setTimestamp()

        try {
          let claimChannel = client.channels.cache.find(
            (channel) => channel.name === 'general',
          );
          
          let claimMessage = await claimChannel.send(claimEmbed);

          claimMessage.react('✅');

          const handleReaction = (reaction, user) => {
            
            if (user.id === '923956860682399806') {
              return;
            }

            const name = `ticket-${user.tag}`
            
            claimMessage.guild.channels
              .create(name, {
                type: 'text',             
              }).then(channel => {
                console.log(channel)
              })

            claimMessage.delete();
            
          }

          client.on('messageReactionAdd', (reaction, user) => {

            const channelID = '858428421683675169'
            
            if (reaction.message.channel.id === channelID) {
              handleReaction(reaction, user)
            }
          })

        } catch (err) {
          throw err;
        }
      })
      .catch((err) => console.log(err));
    
  }
})

client.login(process.env['TOKEN'])

Upvotes: 0

Views: 214

Answers (1)

RatInChat
RatInChat

Reputation: 140

Your problem could possibly be that you have not put any intents. Intents look like this:

const { Client } = require('discord.js');
const client = new Client({
    intents: 46687,
});

You can always calculate your intents with this intents calculator: https://ziad87.net/intents/ Side note: If you are using discord.js v14 you change client.on from message to messageCreate.

Upvotes: 1

Related Questions