-
Notifications
You must be signed in to change notification settings - Fork 27
/
jisho_kanji_search.js
40 lines (36 loc) · 1.46 KB
/
jisho_kanji_search.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
const { throwPublicErrorInfo } = require('./../common/util/errors.js');
const createKanjiNavigationChapter = require('./../discord/create_kanji_search_navigation_chapter.js');
const { Navigation } = require('monochrome-bot');
const constants = require('./../common/constants.js');
module.exports = {
commandAliases: ['kanji', 'k'],
canBeChannelRestricted: true,
cooldown: 3,
uniqueId: 'jishokanji54094',
shortDescription: 'Search for information about a kanji.',
longDescription: 'Search Jisho for information about a kanji character. For most kanji, I will show JLPT level, frequency information, readings, examples, and more. If you enter more than one character, I\'ll show results for all of them.',
usageExample: '<prefix>kanji 少',
action(bot, msg, suffix, monochrome) {
if (!suffix) {
const { prefix } = msg;
return throwPublicErrorInfo('Kanji', `Say **${prefix}kanji [kanji]** to search for kanji. For example: **${prefix}kanji 瞬間**. Say **${prefix}help kanji** for more help.`, 'No suffix');
}
const { navigationChapter, pageCount } = createKanjiNavigationChapter(
suffix,
msg.author.username,
msg.prefix,
false,
);
const navigation = Navigation.fromOneNavigationChapter(
msg.author.id,
navigationChapter,
pageCount > 1,
);
return monochrome.getNavigationManager().show(
navigation,
constants.NAVIGATION_EXPIRATION_TIME,
msg.channel,
msg,
);
},
};