Flamingavin
Flamingavin
DIAdiscord.js - Imagine an app
Created by Flamingavin on 7/22/2024 in #djs-questions
DJS v12 to v14 or newest help
So I am really outdated with my old bot I’ve tried to figure out the new docs and I don’t know I am use to v12 so I am needing g like a little bit of guidance or smh.
7 replies
DIAdiscord.js - Imagine an app
Created by Flamingavin on 7/19/2024 in #djs-questions
Bot status
require('module-alias/register');
const mongo = require('./mongo');
const { Client, Collection } = require('discord.js');
const client = new Client({ partials: ['MESSAGE', 'REACTION'] });

client.config = require('./config');
client.commands = new Collection();

const { registerEvents, registerCommands } = require('./utils/registry');

client.once('ready', async () => {
console.log(`Connected to Discord as ${client.user.tag}`);
await mongo().then(async () => console.log('Connected to Mongo'));
await registerEvents(client, '../events');
await registerCommands(client, '../commands');

updateBotStatus(); // Initial status update

// Update status when the bot joins or leaves a guild
client.on('guildCreate', updateBotStatus);
client.on('guildDelete', updateBotStatus);
});

client.login(client.config.token);

function updateBotStatus() {
const serverCount = client.guilds.cache.size;
const statusMessage = `Serving ${serverCount} servers`;
console.log(`Updating status to: ${statusMessage}`);
client.user.setPresence({
activities: [{ name: statusMessage, type: 'WATCHING' }],
status: 'online'
}).then(() => {
console.log('Status set successfully');
}).catch(console.error);
}
require('module-alias/register');
const mongo = require('./mongo');
const { Client, Collection } = require('discord.js');
const client = new Client({ partials: ['MESSAGE', 'REACTION'] });

client.config = require('./config');
client.commands = new Collection();

const { registerEvents, registerCommands } = require('./utils/registry');

client.once('ready', async () => {
console.log(`Connected to Discord as ${client.user.tag}`);
await mongo().then(async () => console.log('Connected to Mongo'));
await registerEvents(client, '../events');
await registerCommands(client, '../commands');

updateBotStatus(); // Initial status update

// Update status when the bot joins or leaves a guild
client.on('guildCreate', updateBotStatus);
client.on('guildDelete', updateBotStatus);
});

client.login(client.config.token);

function updateBotStatus() {
const serverCount = client.guilds.cache.size;
const statusMessage = `Serving ${serverCount} servers`;
console.log(`Updating status to: ${statusMessage}`);
client.user.setPresence({
activities: [{ name: statusMessage, type: 'WATCHING' }],
status: 'online'
}).then(() => {
console.log('Status set successfully');
}).catch(console.error);
}
7 replies