Untitled

mail@pastecode.io avatar
unknown
javascript
a month ago
2.4 kB
2
Indexable
Never
const mongoose = require('mongoose');
const mongoURL = process.env.mongoURL;

module.exports = {
    name: 'ready',
    once: true,
    async execute(client) {
        console.log('Ready!');

        async function pickPresence () {
            const option = Math.floor(Math.random() * statusArray.length);

            try {
                await client.user.setPresence({
                    activities: [
                        {
                            name: statusArray[option].content,
                            type: statusArray[option].type,

                        },
                    
                    ],

                    status: statusArray[option].status
                })
            } catch (error) {
                console.error(error);
            }
        }

        if(!mongoURL) return;

        await mongoose.connect(mongoURL);

        if(mongoose.connect){
            console.log('I have connected to the database');
        }else{
            console.log('I cannot connect to the database');
        }
    },
};

const { Client, GatewayIntentBits } = require('discord.js');
const client = new Client({
    intents: [
        GatewayIntentBits.Guilds,
        GatewayIntentBits.GuildMessages,
        GatewayIntentBits.MessageContent,
        GatewayIntentBits.GuildMembers,
        GatewayIntentBits.GuildVoiceStates,
    ],
});
const TOKEN = process.env.token;


client.on('voiceStateUpdate', async (oldState, newState) => {
    console.log('Voice Channel Joined');
    const oldChannel = oldState.channel;
    const newChannel = newState.channel;

    try{
        await newState.member.send({ content: 'There Has Been A Channel Created For You!', ephemeral: true});

        const Channel = await newState.member.guild.channels.create({
            name: "Hello World",
            type: ChannelType.GuildVoice,
            parent: newState.channel.parent
        })
    } catch (err){
        return;
    }

})

client.login(TOKEN);


/*const VOICE_CHANNEL_ID = 1223995108618272798;
const TEXT_CHANNEL_ID = 1224736239509569576;

client.once('ready', () => {
    console.log('Bot is ready!');
});*/

/*client.on('voiceStateUpdate', async (oldState, newState) => { 
    console.log('Voice state update detected');
    const oldChannel = oldState.channel;
    const newChannel = newState.channel;
});*/