Open cattoman1 opened 2 years ago
Hello @Garyblu, can you send me a screenshot of your console, file of config.js (with removed "sensitive" data) to check if you set up everything right?
@Garyblu do you have updated this project? Do you have an object messages.status on line 100?
The {status}
variable should be replaced with ":white_check_mark: **ONLINE**"
.
@PetyXbron i know is old but i have the same problem
@blaze534 okay, so can you answer my question posted 3 months ago please?
do you have updated this project? Do you have an object messages.status on line 100. The {status} variable should be replaced with ":white_check_mark: ONLINE".
this is line 100 of config.js
//CONFIG DATA EXPLANATION - https://docs.petyxbron.cz/config/config-info module.exports = { //Your bot data bot: { token: "", //Your bot token - https://tinyurl.com/discordbot-token prefix: ".", //Your custom prefix of the bot, like "!" or "." presence: "test", //Custom activity/status text status: "ONLINE", //You can choose: ONLINE, IDLE, DND (do not disturb), INVISIBLE activity: "playing", //You can choose: PLAYING, LISTENING, WATCHING, COMPETING guildID: "1003269988859252758", //Your Discord server guild ID },
//Your Minecraft server data
server: {
name: "DogMC", //Your server name
type: "java", //"java" or "bedrock"
ip: "", //IP of your server - do not include port - e.g. "mc.hypixel.net"
port: "", //PORT of your server - empty => default port (JA 25565, BE 19132)
icon: "https://cdn.discordapp.com/icons/1003269988859252758/f6d327b504b7ac8c8662781b65b956c7.png", //Link to icon - like "https://website.com/icon.png"
version: "1.8.8-1.19", //Minecraft version of sever
vote: "" //Vote link - like "https://minecraftpocket-servers.com/server/80103/vote/"
},
//Basic code settings
//All settings are boolean wanted - Use "true" for enabling, "false" for disabling setting.
settings: {
warns: true, //Show warns?
debug: false, //Log most of the changes and updates (pretty spam)?
inviteLink: true, //Show bot invite link on bot start?
readyScan: true, //On bot's start, send to console server's basic info?
split: false, //Advanced - Extract only the version like "1.17" or "1.12" etc.
randomColor: false, //Enable random hex color generator for embeds? Overwrites embeds settings!
statusCH: false, //Enable auto-changing status message?
votingCH: false, //Enable voting channel?
countingCH: true //Enable counting channel?
},
//Period of auto changing status if you are using {onlinePlayers} or {maxPlayers} in bot's presence
autoStatus: {
time: "30s", //Period of auto changing status - like "3min", "20s" or "1min" etc.
offline: "Offline" //Changes bot's presence to this text if the server is offline / not found
},
//Auto changing status message
statusCH: {
channelID: "",
time: "30s" //Period of updating status message - like "3min", "20s" or "1min" etc.
},
//Voting channel - https://docs.petyxbron.cz/config/config-info#voting-ch
votingCH: {
channelID: "",
time: "30s", //Time for how long the cancel reaction should be deleted.
threads: {
enable: false, //Create discussion threads for each votingCH message
nameSyntax: "Voting {ID}", //Thread name ("{ID}" = ID of voting/suggestion)
idSyntax: "001", //ID syntax - choose how many zeros should IDs show (DON'T REMOVE INTEGER "1")
archiveTime: 1440 //Minutes after which the thread should archive in case of no recent activity
},
reactions: {
first: "๐", //First added reaction (the positive one)
second: "๐", //Second added reaction (the negative one)
cancel: "โ" //Third added reaction (cancel/remove button)
}
},
//Counting channel - auto updating channel name
countingCH: {
channelID: "1022848271326130206",
time: "1s", //Period of updating channel name - like "3min", "20s" or "1min" etc.
name: "{onlinePlayers} players online!", //Name of the channel
offline: "Il Server รจ offlin!" //Name of the channel if the server is offline / not found
},
//Embeds settings
embeds: {
colors: {
normal: "", //Main/successful color of embeds - choose HEX color here: https://htmlcolorcodes.com
error: "", //Error/unsuccessful color of embeds - choose HEX color here: https://htmlcolorcodes.com
}
},
//Program process console logging
console: {
emojis: {
success: "๐",
info: "๐",
warn: "๐",
error: "๐"
}
},
//All commands settings
commands: {
enableSlashes: true, //If you want to disable only specific slashes, leave this true and go down
//List of all commands:
help: {
enableNormal: true, //Enables normal command
enableSlash: true, //Enables slash command
aliases: [ //Only for normal commands
"commands", "menu"
],
text: { //Custom text settings (for translating or customization)
title: "{serverName} bot commands:",
description: "> **Prefix:** \`{prefix}\`\n> **Commands:**\n{commands}",
errorTitle: "Error! Command \"{arg0}\" doesn't exist.",
errorDescription: "Command `{arg0}` was not found.\nYou are entering the wrong alias or the command is disabled."
}
},
ip: {
enableNormal: true, //Enables normal command
enableSlash: true, //Enables slash command
aliases: [ //Only for normal commands
"i", "ip-address", "address", "connect", "join"
],
text: { //Custom text settings (for translating or customization)
title: "IP:",
description: "\`{serverIp}\`:\`{serverPort}\`"
}
},
list: {
enableNormal: true, //Enables normal command
enableSlash: true, //Enables slash command
aliases: [ //Only for normal commands
"l", "players", "plist"
],
text: { //Custom text settings (for translating or customization)
title: "Lista Player Online :",
description: "**{playersOnline}**/**{playersMax}**",
listFormat: "```{playersList}```"
}
},
status: {
enableNormal: true, //Enables normal command
enableSlash: true, //Enables slash command
aliases: [ //Only for normal commands
"s", "info", "server", "overview", "ov"
],
text: { //Custom text settings (for translating or customization)
title: "Stato del server:",
description:
`{status}
**Descrizione del server**
{motd}
**IP**
\`{serverIp}\`:\`{serverPort}\`
**Versione**
{serverType} {serverVersion}
**Players**
**{playersOnline}**/**{playersMax}**`,
}
},
test: {
enableNormal: true, //Enables normal command
//Test command doesn't have slash type. Is it really necessary?
aliases: [ //Only for normal commands
"t", "try", "testing"
],
text: { //Custom text settings (for translating or customization)
content: "Test message reply."
}
},
version: {
enableNormal: true, //Enables normal command
enableSlash: true, //Enables slash command
aliases: [ //Only for normal commands
"v", "ver"
],
text: { //Custom text settings (for translating or customization)
title: "Versione di Minecraft:",
description: "{serverType} {serverVersion}"
}
},
vote: {
enableNormal: true, //Enables normal command
enableSlash: true, //Enables slash command
aliases: [ //Only for normal commands
"votelink"
],
text: { //Custom text settings (for translating or customization)
title: "Coming Soon:",
description: "Coming Soon."
}
},
}
};
//CONFIG DATA EXPLANATION - https://docs.petyxbron.cz/config/config-info this is the entire config.js whithout sensitive data
I am not sure why is it happening. @blaze534 can you please explain the issue again? Is it a problem with the status command, right?
my /status run but the activity like playing or other it
Can you please send me a screenshot of full bots message response?
it dosent give an error
I mean screenshot of the Discord message in chat app
wait maybe i got misunderstood i am talking about the activity like watching playing what screenshot do you need visual studio? bot profile on Discord?the Console?
Oh, I see now
@blaze534 It's working for me in the latest version [1.6.8].
Can you please send me the output from command npm list
to check your dependencies versions installed?
โโโ @discordjs/rest@1.3.0 โโโ axios@0.27.2 โโโ chalk@4.1.2 โโโ discord-api-types@0.37.12 โโโ discord.js@14.6.0 โโโ fs@0.0.1-security โโโ minecraft-motd-util@1.1.12 โโโ minecraft-server-util@5.3.1 โโโ ms@2.1.3 โโโ quick.db@7.1.3 i have node 17.6.0
I am sorry, but I don't know what wrong have you set. Try to check all again on your site. If I will remember any fixes for you I will contact you. Also, try to keep your project updated for any possible fixes published.
ok txt
Hi, guys! ๐
I've identified the bug in the code, and it seems to be related to the code that injects the bot presence in the ready.js file. I went ahead and refactored the code to fix the issue. However, I can't be entirely sure that it's completely reliable.
Here's the refactored code:
const setBotPresence = async (presence, activity, status) => {
try {
await bot.user.setPresence({
activities: [{ name: presence, type: at[activity] }],
status: status,
afk: false
});
if (debug) console.log(`${bot.emotes.debug} Successfully set the bot presence to ${ma(`${activity} ${presence}`)}`);
} catch (error) {
if (debug) console.log(`${bot.emotes.debug} Could not set the Discord bot presence! Error:\n${error}`);
}
}
const getServerStatusData = async (type, ip, port) => {
let errored = false, response = undefined;
try {
response = await util.get(`https://api.mcstatus.io/v2/status/${type}/${ip}:${port}`);
} catch (error) {
if (debug) console.log(`${bot.emotes.debug} Could not receive server status data! Error:\n${error}`);
errored = true;
}
return { errored, response };
}
if (bot.pres) {
let { presence, status, activity } = config.bot;
status = status.toLowerCase();
activity = activity.charAt(0).toUpperCase() + activity.slice(1).toLowerCase();
if (bot.pres.includes("{onlinePlayers}") || bot.pres.includes("{maxPlayers}")) {
async function autoUpdatingPresence() {
let { errored, response } = await getServerStatusData(server.type, server.ip, server.port);
if (!errored) {
presence = presence.replaceAll("{onlinePlayers}", response.data.players.online)
.replaceAll("{maxPlayers}", response.data.players.max);
} else {
presence = config.autoStatus.offline;
}
await setBotPresence(presence, activity, status);
setTimeout(autoUpdatingPresence, ms(config.autoStatus.time));
}
await autoUpdatingPresence();
} else {
await setBotPresence(presence, activity, status);
}
}
Please review the changes and test the refactored code thoroughly to ensure it works as expected. If you encounter any issues or have any questions, feel free to reach out for further assistance.
@llsaintsll I think this issue is outdated with its version. There is a chance that this problem is already fixed in the newest dev
version.
Also, what did you exactly change? Which lines?
The screenshot by the creator of this issue doesn't look like it relates to Discord bot/client/user presence/activity.
This looks like the status
command embed output or embed message from the statusCH
feature.
The screenshot by the creator of this issue doesn't look like it relates to Discord bot/client/user presence/activity. This looks like the
status
command embed output or embed message from thestatusCH
feature.
Oh, I see... I thought it was related to the Bot presence, like the little message above the name, 'cause I was having this issue too.
@llsaintsll I think this issue is outdated with its version. There is a chance that this problem is already fixed in the newest
dev
version. Also, what did you exactly change? Which lines?
In the original code, the problem happens here:
if (!errored) {
// Code omitted for brevity... ๐
} else {
const presence = config.autoStatus.offline;
// More code omitted... ๐
}
presence = config.bot.presence;
The presence
variable is reset to its original value at the end of each iteration of the autoUpdatingPresence()
function, meaning that any changes that were made to it get overwritten.
So, I try to rewritte the equivalent part of the code like this:
if (!errored) {
presence = presence.replaceAll("{onlinePlayers}", response.data.players.online)
.replaceAll("{maxPlayers}", response.data.players.max);
} else {
presence = config.autoStatus.offline;
}
await setBotPresence(presence, activity, status);
In this version of the code, the presence
variable is not reset to its original value after each iteration, meaning that changes to it are preserved until the next time autoUpdatingPresence()
is called.
The key change that was made to fix the problem was to remove the line presence = config.bot.presence;
at the end of the autoUpdatingPresence()
function and instead to handle the updating of presence entirely within the if (!errored)
and else
branches of the code.
I hope my explanation makes sense! If you have any doubts, feel free to reach out me. I'll try the dev branch of the code. ๐
yea the status when using the status command is just {status} and the bot activity wont change