Untitled

mail@pastecode.io avatar
unknown
javascript
2 months ago
2.1 kB
3
Indexable
Never
require('dotenv').config();
const { Client, IntentsBitField } = require('discord.js');

const client = new Client({
  intents: [
    IntentsBitField.Flags.Guilds,
    IntentsBitField.Flags.GuildMembers,
    IntentsBitField.Flags.GuildMessages,
    IntentsBitField.Flags.MessageContent,
  ],
});

client.on('ready', () => {
    console.log(`✅ ${client.user.tag} is online.`);
});

client.on('messageCreate', async (message) => {
    if (message.author.bot) {
        return;
    }

    if (message.content === 'hello') {
        message.reply('hello');
    }

    
    if (message.channel.id === 'specific_channel_id' && message.content.startsWith('http')) {
        const link = message.content;
        const sender = message.author;
        const farmingRole = message.guild.roles.cache.find(role => role.name === 'farming');

        
        const firstChannel = client.channels.cache.get('first_destination_channel_id');
        if (firstChannel) {
            firstChannel.send(`🌟 ${farmingRole} 🌟\n\n:sparkling_heart: **A NEW FARMING SERVER IS OUT** :sparkling_heart:\n\n:cherry_blossom: *MAKE SURE TO READ FARMING INFO AND THE RULES BEFORE JOINING!* :cherry_blossom:\n*IF YOU NEED HELP JOINING GO TO TUTORIAL*\n\n**HOST:** ${sender}\n**LINK:** ${link}`);
        } else {
            console.log('First destination channel not found.');
        }

        
        setTimeout(() => {
            const secondChannel = client.channels.cache.get('second_destination_channel_id');
            if (secondChannel) {
                secondChannel.send(`🌟 ${farmingRole} 🌟\n\n:sparkling_heart: **A NEW FARMING SERVER IS OUT** :sparkling_heart:\n\n:cherry_blossom: *MAKE SURE TO READ FARMING INFO AND THE RULES BEFORE JOINING!* :cherry_blossom:\n*IF YOU NEED HELP JOINING GO TO TUTORIAL*\n\n**HOST:** ${sender}\n**LINK:** ${link}`);
            } else {
                console.log('Second destination channel not found.');
            }
        }, 60000); 
    }
});

client.login(process.env.TOKEN);
Leave a Comment