Marwan
Marwan
DIAdiscord.js - Imagine a boo! 👻
Created by Marwan on 10/1/2023 in #djs-questions
BOT SEND MULTIPLE MESSAGE
Hey I have a problem my bot spam message in channel but I want just send one message and update it and I don’t know how to do this
10 replies
DIAdiscord.js - Imagine a boo! 👻
Created by Marwan on 9/29/2023 in #djs-questions
DISCORD STATUT
Hey I want set a statut to my bot discord but he don’t set this is my code :
const { Client, GatewayIntentBits } = require('discord.js');
const axios = require('axios');

const intents = [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
];

const client = new Client({ intents });

const token = 'retired';
const serverStatusURL = 'https://bp.userr00t.com/serverbrowser/api/';
const myServerIP = '154.51.39.124';
const myServerPort = 5006;
const serverListURL = 'https://brokeprotocol.com/servers.json';

client.on('ready', () => {
console.log(`Connecté en tant que ${client.user.tag}`);

updateBotStatus();
});

async function updateBotStatus() {
try {
console.log('Starting bot status update...');

const axiosConfig = {
timeout: 5000,
headers: {
'User-Agent': 'YourBotName/1.0',
},
};

console.log('Sending request to the server...');
const response = await axios.get(serverListURL, axiosConfig);
console.log('Response received successfully.');

const serverList = response.data;

const myServer = serverList.find(server => server.IP === myServerIP && server.Port === myServerPort);

if (myServer) {
const playerCount = myServer.PlayerCount;
const playerLimit = myServer.PlayerLimit;

// Set the bot's status to the player count
client.user.setActivity(`${playerCount} players`, { type: 'PLAYING' });
console.log(`Bot status set to: ${playerCount} players`);
} else {
// If server not found, set status to 'Server offline'
client.user.setActivity('Server offline', { type: 'WATCHING' });
console.log('Bot status set to: Server offline');
}

console.log('Bot status update completed.');
} catch (error) {
console.error('Error updating bot status:', error);
}
}

setInterval(updateBotStatus, 10 * 60 * 1000);

client.login(token);
const { Client, GatewayIntentBits } = require('discord.js');
const axios = require('axios');

const intents = [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
];

const client = new Client({ intents });

const token = 'retired';
const serverStatusURL = 'https://bp.userr00t.com/serverbrowser/api/';
const myServerIP = '154.51.39.124';
const myServerPort = 5006;
const serverListURL = 'https://brokeprotocol.com/servers.json';

client.on('ready', () => {
console.log(`Connecté en tant que ${client.user.tag}`);

updateBotStatus();
});

async function updateBotStatus() {
try {
console.log('Starting bot status update...');

const axiosConfig = {
timeout: 5000,
headers: {
'User-Agent': 'YourBotName/1.0',
},
};

console.log('Sending request to the server...');
const response = await axios.get(serverListURL, axiosConfig);
console.log('Response received successfully.');

const serverList = response.data;

const myServer = serverList.find(server => server.IP === myServerIP && server.Port === myServerPort);

if (myServer) {
const playerCount = myServer.PlayerCount;
const playerLimit = myServer.PlayerLimit;

// Set the bot's status to the player count
client.user.setActivity(`${playerCount} players`, { type: 'PLAYING' });
console.log(`Bot status set to: ${playerCount} players`);
} else {
// If server not found, set status to 'Server offline'
client.user.setActivity('Server offline', { type: 'WATCHING' });
console.log('Bot status set to: Server offline');
}

console.log('Bot status update completed.');
} catch (error) {
console.error('Error updating bot status:', error);
}
}

setInterval(updateBotStatus, 10 * 60 * 1000);

client.login(token);
20 replies