-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
85 lines (71 loc) · 2.38 KB
/
index.js
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
const Discord = require('discord.js');
const fetch = require('node-fetch')
//Adds Gateway Intents
const bot = new Discord.Client({ ws: { intents:['GUILDS','GUILD_MESSAGES']}});
//Date Vars
var today = new Date();
var dd = String(today.getDate()).padStart(2,'0');
var mm = String(today.getMonth()+1).padStart(2,'0');
//Console Log
bot.on('ready',() => {
console.log('Bot Logged In');
bot.user.setActivity('arafat-iqbal.netlify.app')
})
//If no prefix it will give an error
const prefix = '+'
bot.on('message',(msg) => {
if(msg.content[0] !== prefix){
console.log('No Prefix, Enter "!" Prefix Before Command');
return;
}
const args = msg.content.slice(prefix.length).trim().split(' ');
console.log(args);
const command = args.shift().toLowerCase();
console.log(command);
//Commands
if(command == 'prayer'){
//No Arguments provided for prayer function, print out info about Portland Oregon
if(!args.length){
msg.channel.send(`
\`\`\`
Error: Enter in Location
[ !prayer city state ]
\`\`\`
`)
}
else{
var c = args[0]
var city = c.charAt(0).toUpperCase() + c.slice(1)
var s = args[1]
var state = s.charAt(0).toUpperCase() + s.slice(1)
let getPrayer = async () => {
let result = await fetch(`http://api.aladhan.com/v1/calendarByCity?city=${city}&state=${state}&country=UnitedStates&method=2&month=${mm}`)
let json = await result.json()
return json
}
(async function(){
let prayer = await getPrayer()
msg.channel.send(`
Here are the prayer times for **${city} ${state}**:
\`\`\`
Fajr: ${JSON.stringify(prayer.data[dd-1].timings['Fajr'],null,'\t')}
Dhuhr: ${JSON.stringify(prayer.data[dd-1].timings['Dhuhr'],null,'\t')}
Asr: ${JSON.stringify(prayer.data[dd-1].timings['Asr'],null,'\t')}
Maghrib: ${JSON.stringify(prayer.data[dd-1].timings['Maghrib'],null,'\t')}
Isha: ${JSON.stringify(prayer.data[dd-1].timings['Isha'],null,'\t')}
\`\`\`
`)
})()
}
}
if(command == 'haram'){
let num = 2;
if (args[0]) {
num = parseInt(args[0]) + 1;
}
console.log(num);
msg.channel.bulkDelete(num);
msg.channel.send(`Deleted ${args[0]} Haram Posts... Astaghfirullah :fire:`);
}
})
bot.login(process.env.DJS_TOKEN);