-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathembedbuilder.js
More file actions
151 lines (110 loc) · 4.07 KB
/
Copy pathembedbuilder.js
File metadata and controls
151 lines (110 loc) · 4.07 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
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
const Discord = require("discord.js");
const Utils = require("./utils");
const prefix = Utils.prefix;
exports.fetchMatchDetails = (json) => {
let fields = [];
json["content"]["innings"].map((item) => {
fields.push({
name: item["title"],
value: item["total"],
inline: true,
});
});
const matchDetails = new Discord.MessageEmbed({
color: 0x0099ff,
title: json["header"]["title"],
setDescription: `\n ${json["meta"]["homeTeamName"]} vs ${json["meta"]["awayTeamName"]}`,
author: {
name: `🏏${Utils.getBattingBowlingTeam(json).battingTeam["displayName"]}`,
iconURL: `${Utils.logoBaseUrl}${
Utils.getBattingBowlingTeam(json).battingTeam["logoUrl"]
}`,
},
fields: fields,
footer: {
text: `🥎${Utils.getBattingBowlingTeam(json).bowlingTeam["displayName"]}`,
iconURL: `${Utils.logoBaseUrl}${
Utils.getBattingBowlingTeam(json).bowlingTeam["logoUrl"]
}`,
},
});
return matchDetails;
}
exports.FetchAllmatchesToday = (json) => {
let finalMessage = [];
for (i = 1; i < json.length; i++) {
singleMatchId = `${json[i]["id"]}`;
singleMatch = ` ${json[i]["t1"]} vs ${json[i]["t2"]}`;
finalMessage.push({
value: ` Match ID: ${singleMatchId}`,
name: `${singleMatch}`,
});
}
const allMatches = new Discord.MessageEmbed({
color: 0x0099ff,
thumbnail: "https://static.toiimg.com/photo/msid-70056441/70056441.jpg",
title: "🏏 Current Live Matches are:",
fields: finalMessage,
footer: {
text: `\n Send \`${prefix}match match_id \` for details`,
},
});
return allMatches;
};
exports.fetchScoreCard = (json, param1, param2) => {
let fields =[];
let inningsNo = json["content"]["innings"].length;
var no = (param1 -1);
if( param1 <= inningsNo && no >=0 && param2 === "bat") {
fields.push({
name: json["content"]["innings"][no]["title"],
value: `Total: ${json["content"]["innings"][no]["total"]}`,
inline: false,
});
json["content"]["innings"][no]["batsmen"].map((battingPlayer)=>{
fields.push({
name: battingPlayer["name"],
value: ` ** Runs: ${battingPlayer["runs"]} (${battingPlayer["ballsFaced"]})** \n ${battingPlayer["shortText"]} \nFours:(${battingPlayer["fours"]})\nSixes:(${battingPlayer["sixes"]}) \n Strike Rate:${battingPlayer["strikeRate"]}`,
inline: true,
});
});
}
else if( param1 <= inningsNo && no >=0 &¶m2 === "ball"){
fields.push({
name: "Bowling Scorecard",
value: `Total: ${json["content"]["innings"][no]["extras"]}`,
inline: false,
})
json["content"]["innings"][no]["bowlers"].map((bowlingPlayer)=>{
fields.push({
name: bowlingPlayer["name"],
value: ` Overs: ${bowlingPlayer["overs"]} \n Maidens:${bowlingPlayer["maidens"]} \n Conceded: ${bowlingPlayer["conceded"]} \n WICKETS:**${bowlingPlayer["wickets"]}** \n Economy:(${bowlingPlayer["economyRate"]}) \n Wides:${bowlingPlayer["wides"]} \n No Balls:${bowlingPlayer["noballs"]}`,
inline: true,
});
});
}
else{
fields.push({
name: `** Invalid Innings Number / MatchID ** OR **Innings yet to be Played** `,
value:` Please Enter ${prefix}scorecard MatchID [Innings number] [bat/ball] `
})
}
const scoreCard = new Discord.MessageEmbed({
color: 0x0099ff,
title: ` Score: ${json["header"]["matchEvent"]["statusText"]}`,
setDescription: `\n ${json["meta"]["homeTeamName"]} vs ${json["meta"]["awayTeamName"]}`,
author: {
name: `🏏${Utils.getBattingBowlingTeam(json).battingTeam["displayName"]}`,
iconURL: `${Utils.logoBaseUrl}${
Utils.getBattingBowlingTeam(json).battingTeam["logoUrl"]
}`},
fields: fields,
footer: {
text: `🥎${Utils.getBattingBowlingTeam(json).bowlingTeam["displayName"]}`,
iconURL: `${Utils.logoBaseUrl}${
Utils.getBattingBowlingTeam(json).bowlingTeam["logoUrl"]
}`,
},
});
return scoreCard;
}