Skip to content

Commit cd0492b

Browse files
authored
Merge pull request #20 from BrayanbotDev/dev
Merge Dev to Main
2 parents af26b11 + cd4f3ca commit cd0492b

File tree

5 files changed

+67
-5
lines changed

5 files changed

+67
-5
lines changed

Commands/General/uptime.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
const Discord = require("discord.js"), ms = require("ms"),
2+
Utils = require("../../Modules/Utils"),
3+
{ lang, config, commands } = require("../../index");
4+
5+
6+
module.exports = {
7+
name: "uptime",
8+
type: "general",
9+
commandData: commands.General.Uptime,
10+
};
11+
12+
/**
13+
*
14+
* @param {Discord.Client} bot
15+
* @param {Discord.Message} message
16+
* @param {Array} args
17+
* @param {Object} config
18+
*/
19+
module.exports.run = async (bot, message, args, config) => {
20+
message.reply(Utils.setupMessage({
21+
configPath: lang.General.Uptime,
22+
variables: [
23+
...Utils.userVariables(message.member),
24+
...Utils.botVariables(bot),
25+
{ searchFor: /{uptime}/g, replaceWith: ms(bot.uptime, { long: true }) },
26+
],
27+
}));
28+
};
29+
30+
/**
31+
*
32+
* @param {Discord.Client} bot
33+
* @param {Discord.Interaction} interaction
34+
*/
35+
module.exports.runSlash = async (bot, interaction) => {
36+
interaction.reply(Utils.setupMessage({
37+
configPath: lang.General.Uptime,
38+
variables: [
39+
...Utils.userVariables(interaction.member),
40+
...Utils.botVariables(bot),
41+
{ searchFor: /{uptime}/g, replaceWith: ms(bot.uptime, { long: true }) },
42+
],
43+
}));
44+
};

Modules/Utils/createCustomConfig.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@ module.exports = function (name, configData, addonName) {
66
let addon_config = null;
77
const generateConfig = function (path, data, type, name) {
88
if (["yml", "yaml"].includes(type.toLowerCase())) {
9-
fs.writeFileSync(
10-
path,
11-
YAML.stringify(data, { indent: 2, prettyErrors: true })
12-
);
9+
data = (YAML.stringify(data, { indent: 2, prettyErrors: true })).replace(/("|')?~(\d+)?("|')?:\s("|')?.+("|')?/g, match => "# " + match.replace(/("|')?~(\d+)?("|')?:\s/g, '').replace(/("|')/g, ''))
10+
fs.writeFileSync(path, data);
1311
addon_config = data;
1412
} else if (["json"].includes(type.toLowerCase())) {
1513
fs.writeFileSync(path, JSON.stringify(data, null, 4));

Modules/Utils/setupMessage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ module.exports = (settings, ephemeral = false, components = null) => {
301301

302302
if (Label) button.setLabel(Label);
303303
if (Emoji) button.setEmoji(Emoji);
304-
if (Disbled) button.setDisabled(true);
304+
if (Disabled) button.setDisabled(true);
305305
rows[i].addComponents([button]);
306306
}
307307
} else if (!CustomID) {

commands.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,17 @@ General:
2626
Data:
2727
Name: ping
2828
Description: "Displays Bot Pings"
29+
Uptime:
30+
Description: "View Your Bot's Current Uptime"
31+
Usage: "uptime"
32+
Aliases: []
33+
Permission:
34+
- "@everyone"
35+
SlashCommand:
36+
Enabled: true
37+
Data:
38+
Name: uptime
39+
Description: "View Your Bot's Current Uptime"
2940
ServerInfo:
3041
Description: "View Server's Information"
3142
Usage: "serverinfo"

lang.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@ General:
2323
Footer: "{user-tag}"
2424
FooterIcon: "{user-pfp}"
2525
Timestamp: true
26+
Uptime:
27+
Embeds:
28+
- Author: "{bot-tag}'s Uptime"
29+
AuthorIcon: "{bot-pfp}"
30+
Description: |-
31+
> **Current Uptime**: {uptime}
32+
Footer: "{user-tag}"
33+
FooterIcon: "{user-pfp}"
34+
Timestamp: true
2635
ServerInfo:
2736
Embeds:
2837
- Title: "💭 Server Info - {guild-name} [1/2]"

0 commit comments

Comments
 (0)