Skip to content

Commit 719f36d

Browse files
authored
[DISC-120] Adjust data type for file (#193)
* Declare file type for requiring data * Use json as opposed to js data file
1 parent d2ff9ac commit 719f36d

File tree

3 files changed

+125
-127
lines changed

3 files changed

+125
-127
lines changed

data/lunch_buddy_locations.js

Lines changed: 0 additions & 121 deletions
This file was deleted.

data/lunch_buddy_locations.json

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
[
2+
{
3+
"value": "Upper Campus Food Court",
4+
"sub": [
5+
{
6+
"name": "Tropical Green Pho"
7+
},
8+
{
9+
"name": "Pho House"
10+
},
11+
{
12+
"name": "Classic Kebab"
13+
},
14+
{
15+
"name": "Chinese Takeaway"
16+
},
17+
{
18+
"name": "Tori Sushi"
19+
},
20+
{
21+
"name": "Gradu-eat"
22+
},
23+
{
24+
"name": "The Little Marionette Cafe"
25+
},
26+
{
27+
"name": "Lhaksa Delight"
28+
},
29+
{
30+
"name": "Bioscience building Cafe (XS Espresso)"
31+
}
32+
]
33+
},
34+
{
35+
"value": "Subway Zone",
36+
"sub": [
37+
{
38+
"name": "Subway"
39+
},
40+
{
41+
"name": "Boost"
42+
},
43+
{
44+
"name": "Southern Wok"
45+
},
46+
{
47+
"name": "Cafe Brioso"
48+
},
49+
{
50+
"name": "Penny Lane"
51+
}
52+
]
53+
},
54+
{
55+
"value": "Quadrangle Food Court",
56+
"sub": [
57+
{
58+
"name": "Soul Origin"
59+
},
60+
{
61+
"name": "PappaRich"
62+
},
63+
{
64+
"name": "Nene Chicken"
65+
},
66+
{
67+
"name": "Plume Cafe"
68+
}
69+
]
70+
},
71+
{
72+
"value": "Lower Campus",
73+
"sub": [
74+
{
75+
"name": "Stellinis Pasta Bar"
76+
},
77+
{
78+
"name": "Guzman Y Gomez"
79+
},
80+
{
81+
"name": "Mamak Village"
82+
},
83+
{
84+
"name": "Yallah Eats Kebab and Shawarma"
85+
},
86+
{
87+
"name": "Sharetea"
88+
},
89+
{
90+
"name": "Maze Coffee & Food"
91+
},
92+
{
93+
"name": "Campus Village Cafe"
94+
},
95+
{
96+
"name": "Home Ground Kiosk"
97+
}
98+
]
99+
},
100+
{
101+
"value": "J17 Ainsworth",
102+
"sub": [
103+
{
104+
"name": "Coffee on Campus Cafe"
105+
}
106+
]
107+
},
108+
{
109+
"value": "Other Options",
110+
"sub": [
111+
{
112+
"name": "Sport"
113+
},
114+
{
115+
"name": "On Campus Study"
116+
}
117+
]
118+
}
119+
]

events/lunch_buddy.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const { EmbedBuilder, ButtonBuilder, ActionRowBuilder } = require("discord.js");
22
const cron = require("node-cron");
3-
const lunchBuddyLocations = require("../data/lunch_buddy_locations.js");
3+
const lunchBuddyLocations = require("../data/lunch_buddy_locations.json");
44
const config = require("../config/lunch_buddy.json");
55

66
const maxRowButtons = 4;
@@ -18,7 +18,7 @@ const generalLocationInfo =
1818
"This lunch buddy vote commenced at 10am, you must vote for the location by 12pm, when one will be chosen.";
1919

2020
const getLocations = (area) => {
21-
for (const object of lunchBuddyLocations.locations) {
21+
for (const object of lunchBuddyLocations) {
2222
if (object.value === area) {
2323
return object;
2424
}
@@ -27,7 +27,7 @@ const getLocations = (area) => {
2727
};
2828

2929
const generateAreasEmbed = (areaVotes) => {
30-
const areas = lunchBuddyLocations.locations.map(
30+
const areas = lunchBuddyLocations.map(
3131
(element) => `${element.value}: ${areaVotes ? areaVotes[element.value].length : 0}`,
3232
);
3333
areas.push(`Any: ${areaVotes ? areaVotes["Any"].length : 0}`);
@@ -69,9 +69,9 @@ const generateLocationsEmbed = (area, votes) => {
6969
);
7070
};
7171

72-
const areasList = lunchBuddyLocations.locations.map((element) => element.value);
72+
const areasList = lunchBuddyLocations.map((element) => element.value);
7373
areasList.push("Any");
74-
const areasButtons = lunchBuddyLocations.locations.map(
74+
const areasButtons = lunchBuddyLocations.map(
7575
(element) =>
7676
new ButtonBuilder({
7777
style: "PRIMARY",
@@ -93,7 +93,7 @@ areasButtons.push(
9393
customId: `Remove${areaButtonCustomId}`,
9494
}),
9595
);
96-
const areasButtonsIds = lunchBuddyLocations.locations.map(
96+
const areasButtonsIds = lunchBuddyLocations.map(
9797
(element) => `${element.value}${areaButtonCustomId}`,
9898
);
9999
areasButtonsIds.push(`Any${areaButtonCustomId}`);

0 commit comments

Comments
 (0)