forked from mahmud-aura/HINATA
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtime.js
More file actions
46 lines (38 loc) · 1.27 KB
/
Copy pathtime.js
File metadata and controls
46 lines (38 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
const axios = require('axios');
const baseApiUrl = async () => {
const base = await axios.get("https://raw.githubusercontent.com/mahmudx7/exe/main/baseApiUrl.json");
return base.data.mahmud;
};
module.exports = {
config: {
name: "time",
version: "1.7",
author: "MahMUD",
countDown: 2,
role: 0,
category: "utility",
guide: "{pn} [country] | {pn} list\n\nExamples:\n{pn} bangladesh\n{pn} london\n{pn} list"
},
onStart: async function ({ message, args }) {
const country = args[0]?.toLowerCase() || "bangladesh";
try {
const baseUrl = await baseApiUrl();
if (country === "list") {
const listRes = await axios.get(`${baseUrl}/api/time/list`, {
headers: { "author": module.exports.config.author }
});
return listRes.data.message
? message.reply(listRes.data.message)
: message.reply("⚠️ Unable to fetch country list.");
}
const timeRes = await axios.get(`${baseUrl}/api/time/${country}`, {
headers: { "author": module.exports.config.author }
});
return timeRes.data.message
? message.reply(timeRes.data.message)
: message.reply("⚠️ Unable to fetch time.");
} catch (error) {
return message.reply("⚠️ An error occurred. Please try again later.");
}
}
};