-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Status Message Reply. - Added events listener. - Organized Code
- Loading branch information
NooberPro
committed
Apr 30, 2023
1 parent
f743318
commit df4768e
Showing
8 changed files
with
98 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const fs = require("fs"); | ||
module.exports = (message, client) => { | ||
if (message.content === "!setstatus") { | ||
console.log(message.channel.id); | ||
const channel = client.channels.cache.get(message.channel.id); | ||
if (!channel) return console.error("Invalid channel ID."); | ||
channel | ||
.send(`:gear:Checking the status...\nWaiting for bot to restart.`) | ||
.then((msg) => { | ||
const json = { | ||
messageId: null, | ||
channelId: null, | ||
}; | ||
fs.writeFileSync("data.json", JSON.stringify(json)); | ||
const data = JSON.parse(fs.readFileSync("data.json")); | ||
data.messageId = msg.id; | ||
data.channelId = message.channel.id; | ||
fs.writeFileSync("data.json", JSON.stringify(data)); | ||
console.log(`The status channel has been set to #${channel.name}.`); | ||
}) | ||
.catch(console.error); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const config = require("../../../config.js"); | ||
const { data } = require("../../index.js"); | ||
module.exports = (message) => { | ||
if (config.status_reply.enabled === false) return; | ||
if ( | ||
config.status_reply.triggerWords.some((word) => | ||
message.content.includes(word) | ||
) | ||
) { | ||
if (data.online === true && data.players.max > 0) { | ||
message.reply( | ||
`**Yes, server is :green_circle:\`ONLINE\` with \`${data.players.online}\` players playing.**` | ||
); | ||
} else { | ||
message.reply("**The Server is currently :red_circle:`Offline`.**"); | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = (client) => { | ||
console.log( | ||
`✅ ${client.user.tag} is online.\nInvite the bot with https://discord.com/oauth2/authorize?client_id=${client.user.id}&permissions=93184&scope=bot%20applications.commands` | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const fs = require("fs"); | ||
const config = require("../../../config.js"); | ||
const data = JSON.parse(fs.readFileSync("data.json")); | ||
const { statusRetrival } = require("../../index.js"); | ||
module.exports = (client) => { | ||
if (data.channelId === null) { | ||
console.log( | ||
"To set server status, send a `!setstatus` message in the desired channel." | ||
); | ||
} else { | ||
setInterval(statusRetrival, config.bot.updateInterval * 1000); | ||
statusRetrival(); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters