How to use the monochrome-bot.Navigation.fromOneDimensionalContents function in monochrome-bot

To help you get started, we’ve selected a few monochrome-bot examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mistval / kotoba / bot / src / discord_commands / help.js View on Github external
description: `Say **${prefixedHelpCommand} CommandNameHere** to see more information about a specific command.`,
      author: {
        name: `${EMBED_TITLE} (page ${pageNumber} of ${numPages})`,
        icon_url: EMBED_ICON_URI,
        url: WEB_COMMANDS_URI,
      },
      url: WEB_COMMANDS_URI,
      fields,
      color: EMBED_COLOR,
      footer,
    };

    pages.push({ embed });
  }

  return Navigation.fromOneDimensionalContents(commandMessage.author.id, pages);
}
github mistval / kotoba / src / discord / shiritori_forever_helper.js View on Github external
function createScoresNavigation(monochrome, msg, scoresPages) {
  const contents = scoresPages.map(page => createDiscordContentForScoresPage(page));
  const navigation = Navigation.fromOneDimensionalContents(msg.author.id, contents);

  return monochrome.getNavigationManager().show(navigation, 1800000, msg.channel, msg);
}
github mistval / kotoba / bot / src / discord_commands / hispadic.js View on Github external
if (!suffix) {
      const { prefix } = msg;
      return throwPublicErrorInfo('Español', `Usa ${prefix}español [palabra] para buscar una palabra. Por ejemplo: ${prefix}español 瞬間`, 'No suffix');
    }

    const hispadicIndex = await awaitHispadicIndex;
    const allResults = hispadicIndex.search(suffix, MAX_RESULTS);
    const qualityResults = allResults.filter(r => r.matchType > 1);
    const results = qualityResults.length > 0 ? qualityResults : allResults;

    if (results.length === 0) {
      return throwPublicErrorInfo('Español', `No encontré ningún resultado para **${suffix}**.`, 'No results');
    }

    const contents = createNavigationContents(results, suffix, msg.author.username);
    const navigation = Navigation.fromOneDimensionalContents(msg.author.id, contents);

    return monochrome.getNavigationManager().show(
      navigation,
      constants.NAVIGATION_EXPIRATION_TIME,
      msg.channel,
      msg,
    );
  },
};
github mistval / kotoba / bot / src / discord / create_anime_search_navigation.js View on Github external
async function createNavigationForAnime(authorName, authorId, keyword) {
  const searchResults = await searchAnime(keyword);

  if (searchResults.length === 0) {
    return throwPublicErrorInfo('Kitsu Anime Search', `I didn't find any results for **${keyword}**.`, 'No results');
  }

  const discordContent = formatAnimeData(searchResults, authorName);
  const navigation = Navigation.fromOneDimensionalContents(authorId, discordContent);

  return navigation;
}
github mistval / kotoba / src / common / kitsu_anime_search.js View on Github external
async function createNavigationForAnime(authorName, authorId, keyword, msg, navigationManager) {
  const searchResults = await searchAnime(keyword);

  if (searchResults.length === 0) {
    return throwPublicErrorInfo('Kitsu Anime Search', `I didn't find any results for **${keyword}**.`, 'No results');
  }

  const discordContent = formatAnimeData(searchResults, authorName);
  const navigation = Navigation.fromOneDimensionalContents(authorId, discordContent);
  return navigationManager.show(navigation, constants.NAVIGATION_EXPIRATION_TIME, msg.channel, msg);
}
github mistval / kotoba / src / discord_commands / leaderboard.js View on Github external
const commandInvokersRow = sortedScores[commandInvokersIndex];

      if (commandInvokersIndex < elementStartIndex || commandInvokersIndex > elementEndIndex) {
        content.embed.fields.push(createFieldForScorer(
          commandInvokersIndex,
          commandInvokersRow.username,
          commandInvokersRow.score,
        ));
      }
    }

    navigationContents.push(content);
  }

  const authorId = msg.author.id;
  const navigation = Navigation.fromOneDimensionalContents(authorId, navigationContents);
  return navigationManager.show(navigation, constants.NAVIGATION_EXPIRATION_TIME, msg.channel, msg);
}
github mistval / kotoba / src / discord_commands / help.js View on Github external
description: `Say **${prefixedHelpCommand} CommandNameHere** to see more information about a specific command.`,
      author: {
        name: `${EMBED_TITLE} (page ${pageNumber} of ${numPages})`,
        icon_url: EMBED_ICON_URI,
        url: WEB_COMMANDS_URI,
      },
      url: WEB_COMMANDS_URI,
      fields,
      color: EMBED_COLOR,
      footer,
    };

    pages.push({ embed });
  }

  return Navigation.fromOneDimensionalContents(commandMessage.author.id, pages);
}
github mistval / kotoba / bot / src / discord / shiritori_forever_helper.js View on Github external
function createScoresNavigation(monochrome, msg, scoresPages) {
  const contents = scoresPages.map(page => createDiscordContentForScoresPage(page));
  const navigation = Navigation.fromOneDimensionalContents(msg.author.id, contents);

  return monochrome.getNavigationManager().show(navigation, 1800000, msg.channel, msg);
}