Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
chapterForEmojiName[STROKE_ORDER_EMOTE] =
strokeOrderNavigationChapterInformation.navigationChapter;
}
/* Create the examples (E) chapter */
const examplesNavigationChapter = createNavigationChapterInformationForExamples(
authorName,
word,
);
chapterForEmojiName[EXAMPLES_EMOTE] = examplesNavigationChapter;
/* Create the navigation. */
return new Navigation(authorId, true, JISHO_EMOTE, chapterForEmojiName);
}
function createFoundResult(msg, pronounceInfo, navigationManager, logger) {
const navigationDataSource = new PronunciationDataSource(
msg.author.username,
pronounceInfo,
logger,
);
const navigationChapter = new NavigationChapter(navigationDataSource);
const chapterForEmojiName = { a: navigationChapter };
const hasMultiplePages = pronounceInfo.entries.length > 1;
const authorId = msg.author.id;
const navigation = new Navigation(authorId, hasMultiplePages, 'a', chapterForEmojiName);
return navigationManager.show(navigation, constants.NAVIGATION_EXPIRATION_TIME, msg.channel, msg);
}
function createFoundResult(msg, pronounceInfo, navigationManager, logger) {
const navigationDataSource = new PronunciationDataSource(
msg.author.username,
pronounceInfo,
logger,
);
const navigationChapter = new NavigationChapter(navigationDataSource);
const chapterForEmojiName = { a: navigationChapter };
const hasMultiplePages = pronounceInfo.entries.length > 1;
const authorId = msg.author.id;
const navigation = new Navigation(authorId, hasMultiplePages, 'a', chapterForEmojiName);
return navigationManager.show(navigation, constants.NAVIGATION_EXPIRATION_TIME, msg.channel, msg);
}
word,
false,
);
if (strokeOrderNavigationChapterInformation.hasAnyPages) {
chapterForEmojiName[STROKE_ORDER_EMOTE] =
strokeOrderNavigationChapterInformation.navigationChapter;
}
const examplesNavigationChapter = createNavigationChapterInformationForExamples(
authorName,
word,
false,
).navigationChapter;
chapterForEmojiName[EXAMPLES_EMOTE] = examplesNavigationChapter;
const navigation = new Navigation(authorId, true, JISHO_EMOTE, chapterForEmojiName);
return navigationManager.show(navigation, constants.NAVIGATION_EXPIRATION_TIME, msg.channel, msg);
}
function createNavigationForKanji(msg, authorName, authorId, kanji, navigationManager) {
const navigationChapterInformation = createNavigationChapterInformationForKanji(
authorName,
kanji,
true,
msg.prefix,
);
const chapterForEmojiName = {};
chapterForEmojiName[KANJI_EMOTE] = navigationChapterInformation.navigationChapter;
const navigation = new Navigation(
authorId,
navigationChapterInformation.hasMultiplePages,
KANJI_EMOTE,
chapterForEmojiName,
);
return navigationManager.show(navigation, constants.NAVIGATION_EXPIRATION_TIME, msg.channel, msg);
}
async function createNavigationForExamples(authorName, authorId, keyword, msg, navigationManager) {
const searchResults = await scrapeWebPage(keyword);
if (searchResults.data.sentences.length === 0) {
return throwPublicErrorInfo('用例.jp', `I didn't find any results for **${keyword}**.`, 'No results');
}
const chapters = {};
chapters[SENTENCES_EMOTE] = createNavigationChapterForSentences(searchResults, authorName, false);
chapters[FULLTEXT_EMOTE] = createNavigationChapterForSentences(searchResults, authorName, true);
chapters[USAGE_EMOTE] = createNavigationChapterForUsage(searchResults, authorName);
const navigation = new Navigation(authorId, true, SENTENCES_EMOTE, chapters);
return navigationManager.show(navigation, constants.NAVIGATION_EXPIRATION_TIME, msg.channel, msg);
}
function createNavigationForExamples(msg, authorName, authorId, word, navigationManager) {
const navigationChapterInformation =
createNavigationChapterInformationForExamples(authorName, word, true);
const chapterForEmojiName = {};
chapterForEmojiName[EXAMPLES_EMOTE] = navigationChapterInformation.navigationChapter;
const navigation = new Navigation(authorId, true, EXAMPLES_EMOTE, chapterForEmojiName);
return navigationManager.show(navigation, constants.NAVIGATION_EXPIRATION_TIME, msg.channel, msg);
}