≪ °✾° ≫ 𝓓𝓮𝓵𝓽𝓪_𝓑𝓻𝓪𝓿𝓸92 ≪ °✾° ≫
≪ °✾° ≫ 𝓓𝓮𝓵𝓽𝓪_𝓑𝓻𝓪𝓿𝓸92 ≪ °✾° ≫
DIAdiscord.js - Imagine an app
Created by ≪ °✾° ≫ 𝓓𝓮𝓵𝓽𝓪_𝓑𝓻𝓪𝓿𝓸92 ≪ °✾° ≫ on 12/11/2023 in #djs-questions
Coding Amendment
Hey guys, I'm getting multiple errors (available if needed) in a specific file, but they all seem to relate to my
var userCount = guild.memberCount;
var userCount = guild.memberCount;
segment. I've tried to fix this myself and research the correct syntax (this is still on djs 12 as I have not had time to upgrade the bot to 14), however I cannot work out what it should be without causing the rest of the bot to crash. Any assistance with either the correct code, or guidance on what to search/where to look would be greatly appreciated. Current code file below:
function updateStats(client) {
const Discord = require('discord.js');
const config = require("../settings/configuration");
const settings = require("../settings/configuration");
const guild = client.guilds.cache.get(settings.BOT_SETTINGS.Guild_ID);
const totalUsers = client.channels.fetch('883654989271154728');
const onlineUsers = client.channels.fetch('883655041813200926');
setInterval(function() {
const interval = (async function() {
for await (const startTime of setInterval(interval, Date.now())) {
const now = Date.now();
console.log(now);
if ((now - startTime) > 1000)
break;
}
console.log(Date.now());
})();
console.log('Getting stats update..')
var userCount = guild.memberCount;
var onlineCount = guild.members.filter(m => m.presence.status === 'online').size
console.log("Total Users: " + userCount);
console.log("Online Users: " + onlineCount);
totalUsers.setName("Total Users: " + userCount)
.then(newChannel => console.log(`Stat channel renamed to: ${newChannel.name}`))
.catch(console.error);
onlineUsers.setName("Online Users: " + onlineCount)
.then(newChannel => console.log(`Stat channel renamed to: ${newChannel.name}`))
.catch(console.error);
}, 30000)
}
module.exports = {
updateStats
}
function updateStats(client) {
const Discord = require('discord.js');
const config = require("../settings/configuration");
const settings = require("../settings/configuration");
const guild = client.guilds.cache.get(settings.BOT_SETTINGS.Guild_ID);
const totalUsers = client.channels.fetch('883654989271154728');
const onlineUsers = client.channels.fetch('883655041813200926');
setInterval(function() {
const interval = (async function() {
for await (const startTime of setInterval(interval, Date.now())) {
const now = Date.now();
console.log(now);
if ((now - startTime) > 1000)
break;
}
console.log(Date.now());
})();
console.log('Getting stats update..')
var userCount = guild.memberCount;
var onlineCount = guild.members.filter(m => m.presence.status === 'online').size
console.log("Total Users: " + userCount);
console.log("Online Users: " + onlineCount);
totalUsers.setName("Total Users: " + userCount)
.then(newChannel => console.log(`Stat channel renamed to: ${newChannel.name}`))
.catch(console.error);
onlineUsers.setName("Online Users: " + onlineCount)
.then(newChannel => console.log(`Stat channel renamed to: ${newChannel.name}`))
.catch(console.error);
}, 30000)
}
module.exports = {
updateStats
}
6 replies
DIAdiscord.js - Imagine an app
Created by ≪ °✾° ≫ 𝓓𝓮𝓵𝓽𝓪_𝓑𝓻𝓪𝓿𝓸92 ≪ °✾° ≫ on 8/11/2022 in #djs-questions
Discord Intents
Hi all, Easy one, but I've confused myself with the documentation. I currently have the following code line:
const client = new Discord.Client({intents: Object.values(Discord.Intents.FLAGS)})
const client = new Discord.Client({intents: Object.values(Discord.Intents.FLAGS)})
I need to update this to the v14 version, but I've tripped myself up on what I need instead. Can anyone help, either with the code, or guidance for where I need to look, please?
20 replies
DIAdiscord.js - Imagine an app
Created by ≪ °✾° ≫ 𝓓𝓮𝓵𝓽𝓪_𝓑𝓻𝓪𝓿𝓸92 ≪ °✾° ≫ on 8/10/2022 in #djs-questions
Code Update
Hi all, just a quick one. I'm updating from v12 to v13, and need to amend about 90% of the bot's code. Once I've got the first part, I should be able to work out the rest, but can someone please help me with the updated code line for the following, please?
const Guild = Structures.get('Guild')
const Guild = Structures.get('Guild')
Many thanks in advance
15 replies
DIAdiscord.js - Imagine an app
Created by ≪ °✾° ≫ 𝓓𝓮𝓵𝓽𝓪_𝓑𝓻𝓪𝓿𝓸92 ≪ °✾° ≫ on 8/9/2022 in #djs-questions
VC Text Channel Logging
Hi all, So my bot has a logging function in it, whereby it tracks any messages deleted/edited etc that are posted. Since Discord introduced their text chat for VCs, however, I get the below error on my console whenever a user posts in a VC Text Chat, and the bot enters Zombie Connection, and has to be restarted. The error on the console is below, can anyone advise whether there is an update available that I can deploy to my Discord.JS, or if the issue is elsewhere in my bot? Discord sent a typing packet to a voice channel 906225549515554906 [Error] An exception happened in process: TypeError: Cannot read property 'cache' of undefined at MessageCreateAction.handle (/home/container/node_modules/discord.js/src/client/actions/MessageCreate.js:11:41) at Object.module.exports [as MESSAGE_CREATE] (/home/container/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32) at WebSocketManager.handlePacket (/home/container/node_modules/discord.js/src/client/websocket/WebSocketManager.js:384:31) at WebSocketShard.onPacket (/home/container/node_modules/discord.js/src/client/websocket/WebSocketShard.js:444:22) at WebSocketShard.onMessage (/home/container/node_modules/discord.js/src/client/websocket/WebSocketShard.js:301:10) at WebSocket.onMessage (/home/container/node_modules/ws/lib/event-target.js:132:16) at WebSocket.emit (events.js:400:28) at Receiver.receiverOnMessage (/home/container/node_modules/ws/lib/websocket.js:1068:20) at Receiver.emit (events.js:400:28) at Receiver.dataMessage (/home/container/node_modules/ws/lib/receiver.js:517:14)
4 replies
DIAdiscord.js - Imagine an app
Created by ≪ °✾° ≫ 𝓓𝓮𝓵𝓽𝓪_𝓑𝓻𝓪𝓿𝓸92 ≪ °✾° ≫ on 8/7/2022 in #djs-questions
NPM-Node Auto Update
Evening all! Only me again. Is there a way to get my bot to automatically check for, and install, node/npm updates? I currently have the following startup command running, and my console has told me that I have an npm update available: if [[ -d .git ]] && [[ 0 == "1" ]]; then git pull; fi; if [[ ! -z ${NODE_PACKAGES} ]]; then /usr/local/bin/npm install ${NODE_PACKAGES}; fi; if [[ ! -z ${UNNODE_PACKAGES} ]]; then /usr/local/bin/npm uninstall ${UNNODE_PACKAGES}; fi; if [ -f /home/container/package.json ]; then /usr/local/bin/npm install; fi; /usr/local/bin/node /home/container/index.js
3 replies
DIAdiscord.js - Imagine an app
Created by ≪ °✾° ≫ 𝓓𝓮𝓵𝓽𝓪_𝓑𝓻𝓪𝓿𝓸92 ≪ °✾° ≫ on 7/27/2022 in #djs-questions
UserID
Hey all, I have two code files: Warnings - https://pastebin.com/6TUnvkjB Unwarnings - https://pastebin.com/6yid1fdC The Warning file will allow a UserID to be used, however the Unwarn file will not. I've gone through the file several times, but I cannot find the part of the code that is allowing UserID to be used; can anyone help, please? D
7 replies
DIAdiscord.js - Imagine an app
Created by ≪ °✾° ≫ 𝓓𝓮𝓵𝓽𝓪_𝓑𝓻𝓪𝓿𝓸92 ≪ °✾° ≫ on 7/26/2022 in #djs-questions
Warning Checker
Hey guys, I have the following code file to issue user warnings.: https://codeshare.io/K894VE Upon addition/removal of a warning, it lists the existing warnings on the user. In short, I'm trying to build a command just to get their existing warnings, but can't find where I would set that. Any assistance greatfully received. D
5 replies