-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresponses.js
More file actions
190 lines (190 loc) · 6.39 KB
/
responses.js
File metadata and controls
190 lines (190 loc) · 6.39 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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
module.exports = {
welcome: function() {
return 'Sup. Thanks for inviting me to the team!\n\nIf you haven\'t already, you\'ll likely be prompted by me for a Spotify auth code. A browser window should have opened up at some point kicking off the whole process, but if didn\'t see it, you can always restart me and I\' show it to you again.\n\nAlso, if you feel so inclined, you could make a public channel, invite me, add the channel name to the bot-setup.js file, and then I\'ll broadcast updates stuff goes down.';
},
addedToPlaylist: function(channelId, userName, trackInfo) {
return {
channel: channelId,
text: `*${userName}* just added a song to the playlist.`,
mrkdwn_in: ['text'],
attachments: [{
fallback: `${trackInfo.formattedTrackTitle} from the album - *${trackInfo.album}*`,
text: `Title: _${trackInfo.name}_\nArtist: *${trackInfo.artist}*\nAlbum: *${trackInfo.album}*`,
color: '#23CF5F',
thumb_url: trackInfo.artworkUrls.small,
mrkdwn_in: ['text']
}]
};
},
help: function() {
var canSay = '*up next* - _I\'ll tell you what the next three tracks are_\n' +
'*info* - _I\'ll tell you about this track_\n' +
'*detail* - _I\'ll tell you more about this track_';
var add = 'If you\'d like to add a track to the queue, direct message me:\n\n' +
'\t`add [Spotify URI]` _(without the square brackets)_\n\n' +
'where `[Spotify URI]` can be one of the following:\n\n' +
'\t• a Spotify URI - e.g. Spotify:track:*[track id]*\n' +
'\t• a Spotify song link - e.g. https://open.Spotifycom/ *[track id]*';
var search = 'If you\'d like to search for a track to add, direct message:\n\n' +
'\t`search [search query]` _(again, without the square brackets)_\n\n' +
'and I\'ll show you the top 3 results from Spotify. You\'ll then be able to either add one of the results or start over and search again.';
var protip = 'PROTIP: right click on a track in Spotify to copy either a song URI or link';
return {
attachments: [{
title: 'Commands',
fallback: canSay,
text: canSay,
color: '#23CF5F',
mrkdwn_in: ['text']
}, {
title: 'Adding Music:',
fallback: add,
text: add,
color: '#23CF5F',
footer: protip,
mrkdwn_in: ['text', 'footer']
}, {
title: 'Searching Music:',
fallback: search,
text: search,
color: '#23CF5F',
mrkdwn_in: ['text']
}]
};
},
detail: function(trackInfo) {
return {
attachments: [{
fallback: `${trackInfo.formattedTrackTitle} from the album - *${trackInfo.album}*`,
text: `Title: _${trackInfo.name}_
Artist: *${trackInfo.artist}*
Album: *${trackInfo.album}*
Spotify ID: ${trackInfo.trackId}`,
color: '#23CF5F',
thumb_url: trackInfo.artworkUrls.small,
mrkdwn_in: ['text']
}]
};
},
info: function(track) {
return `This is _${track.name}_ by *${track.artist}*`;
},
upNext: function(nextTracks) {
var responseString = '';
nextTracks.forEach(function(track, index) {
responseString += `${index + 1}. _${track.name}_ by *${track.artist}* \n`;
});
return {
attachments: [{
fallback: responseString,
text: responseString,
color: '#23CF5F',
mrkdwn_in: ['text']
}]
};
},
proceed: function(trackInfo) {
var yesText = ['Yes', 'Absolutely', 'yesss!', 'Duuuuuh', 'Of Course', ':+1::skin-tone-3:', ':ok_hand::skin-tone-3:'];
var noText = ['No', 'Nope', 'Negative', ':thumbsdown::skin-tone-3:', ':poop:'];
var randomYesText = yesText[Math.floor(Math.random() * yesText.length)];
var randomNoText = noText[Math.floor(Math.random() * noText.length)];
var stringifiedTrackInfo = JSON.stringify(trackInfo);
return {
replace_original: true,
attachments: [{
fallback: trackInfo.formattedTrackTitle,
callback_id: 'add_this_track',
pretext: '*It looks like you\'re trying to add:*',
color: '#23CF5F',
thumb_url: trackInfo.artworkUrls.medium,
attachment_type: 'default',
footer: 'is this correct?',
mrkdwn_in: ['pretext'],
fields: [{
title: 'Song',
value: trackInfo.name,
short: true
}, {
title: 'Artist',
value: trackInfo.artist,
short: true
}, {
title: 'Album',
value: trackInfo.album,
short: true
}, {
title: 'Spotify ID',
value: trackInfo.trackId,
short: true
}],
actions: [{
name: 'yes',
text: randomYesText,
value: stringifiedTrackInfo,
type: 'button',
style: 'primary'
}, {
name: 'no',
text: randomNoText,
value: 'no',
type: 'button',
style: 'danger'
}]
}]
};
},
searchResults: function(searchResults) {
var resultsActions = searchResults.map(function(result, index) {
return {
name: index + 1,
text: index + 1,
value: JSON.stringify(searchResults[index]),
type: 'button'
};
});
var nvmAction = {
name: 'nvm',
text: 'nvm',
value: 'nvm',
type: 'button',
style: 'danger'
};
var resultsAttachments = searchResults.map(function(result, index) {
return {
title: index + 1 + '.',
thumb_url: result.artworkUrls.medium,
color: '#23CF5F',
fields: [{
title: 'Song',
value: result.name,
short: true
}, {
title: 'Artist',
value: result.artist,
short: true
}, {
title: 'Album',
value: result.album,
short: true
}, {
title: 'Spotify ID',
value: result.trackId,
short: true
}]
};
});
var actionAttachment = {
footer: 'make a selection:',
fallback: 'Interactive Messages Not Supported',
callback_id: 'select_a_track',
attachment_type: 'default',
actions: resultsActions
};
resultsActions.push(nvmAction);
resultsAttachments.push(actionAttachment);
return {
replace_original: true,
attachments: resultsAttachments
};
}
};