Skip to content

Commit 64575e0

Browse files
authored
Merge pull request Elfayer#41 from sustained/master
Add Vue-green buttons for a more vuetiful pagination experience.
2 parents 1647a24 + 86a109b commit 64575e0

File tree

2 files changed

+25
-11
lines changed

2 files changed

+25
-11
lines changed

src/utils/constants/index.js

+14
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,23 @@ const DISCORD_EMBED_FOOTER_LIMIT = 2048
6060
const DISCORD_EMBED_AUTHOR_LIMIT = 256
6161
const DISCORD_EMBED_TOTAL_LIMIT = 6000
6262

63+
/*
64+
The IDs of emojis that the bot will use in reactions, since bots have the
65+
ability to use cross-server emojis without Discord Nitro.
66+
*/
67+
const EMOJIS = {
68+
PAGINATION: {
69+
PREV: '661289441184317441',
70+
NEXT: '661289441674919946',
71+
FIRST: '661289441171865660',
72+
LAST: '661289441218002984',
73+
},
74+
}
75+
6376
export {
6477
USERS,
6578
ROLES,
79+
EMOJIS,
6680
OWNER_IDS,
6781
PROTECTED_USER_IDS,
6882
PROTECTED_ROLE_IDS,

src/utils/embed.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { RichEmbed } from 'discord.js'
2-
import { EMPTY_MESSAGE, DISCORD_EMBED_FIELD_LIMIT } from './constants'
2+
import { EMOJIS, EMPTY_MESSAGE, DISCORD_EMBED_FIELD_LIMIT } from './constants'
33
import { CommandMessage } from 'discord.js-commando'
44

55
export const DEFAULT_EMBED_COLOUR = '#42b883'
@@ -220,10 +220,10 @@ export async function respondWithPaginatedEmbed(
220220
embed: context.embed,
221221
})
222222

223-
await context.response.react('⏪')
224-
await context.response.react('⬅')
225-
await context.response.react('➡')
226-
await context.response.react('⏩')
223+
await context.response.react(msg.client.emojis.get(EMOJIS.PAGINATION.FIRST))
224+
await context.response.react(msg.client.emojis.get(EMOJIS.PAGINATION.PREV))
225+
await context.response.react(msg.client.emojis.get(EMOJIS.PAGINATION.NEXT))
226+
await context.response.react(msg.client.emojis.get(EMOJIS.PAGINATION.LAST))
227227

228228
/*
229229
Collect relevant reactions.
@@ -269,7 +269,7 @@ function _createCollector(
269269
return false
270270
}
271271

272-
return ['⏪', '⬅', '➡', '⏩'].includes(reaction.emoji.name)
272+
return Object.values(EMOJIS.PAGINATION).includes(reaction.emoji.id)
273273
},
274274
{
275275
time: observeReactionsFor,
@@ -299,17 +299,17 @@ function _handlePagination(
299299
{ inlineFields, itemsAreEmbeds, showDetailsInFooter }
300300
) {
301301
return async reaction => {
302-
switch (reaction.emoji.name) {
303-
case '⏪':
302+
switch (reaction.emoji.id) {
303+
case EMOJIS.PAGINATION.FIRST:
304304
pageCurrent = 1
305305
break
306-
case '⬅':
306+
case EMOJIS.PAGINATION.PREV:
307307
pageCurrent = Math.max(1, --pageCurrent)
308308
break
309-
case '➡':
309+
case EMOJIS.PAGINATION.NEXT:
310310
pageCurrent = Math.min(pageLast, ++pageCurrent)
311311
break
312-
case '⏩':
312+
case EMOJIS.PAGINATION.LAST:
313313
pageCurrent = pageLast
314314
break
315315
}

0 commit comments

Comments
 (0)