Update wiki from JSDoc
336
DebugBuilder.html
Normal file
336
DebugBuilder.html
Normal file
@@ -0,0 +1,336 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title> DebugBuilder</title>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js"></script>
|
||||
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
|
||||
<script src="./build/entry.js"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link href="https://fonts.googleapis.com/css?family=Roboto:100,400,700|Inconsolata,700" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
|
||||
<link type="text/css" rel="stylesheet" href="https://jmblog.github.io/color-themes-for-google-code-prettify/themes/tomorrow-night.min.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/app.min.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/iframe.css">
|
||||
<link type="text/css" rel="stylesheet" href="">
|
||||
<script async defer src="https://buttons.github.io/buttons.js"></script>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
|
||||
|
||||
<body class="layout small-header">
|
||||
<div id="stickyNavbarOverlay"></div>
|
||||
|
||||
|
||||
<div class="top-nav">
|
||||
<div class="inner">
|
||||
<a id="hamburger" role="button" class="navbar-burger" aria-label="menu" aria-expanded="false">
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
</a>
|
||||
<div class="logo">
|
||||
|
||||
|
||||
</div>
|
||||
<div class="menu">
|
||||
|
||||
<div class="navigation">
|
||||
<a
|
||||
href="index.html"
|
||||
class="link"
|
||||
>
|
||||
Documentation
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="main">
|
||||
<div
|
||||
class="sidebar "
|
||||
id="sidebarNav"
|
||||
>
|
||||
|
||||
<nav>
|
||||
|
||||
<h2><a href="index.html">Documentation</a></h2><div class="category"><h3>Classes</h3><ul><li><a href="DebugBuilder.html">DebugBuilder</a></li><li><a href="PresenceManager.html">PresenceManager</a></li></ul><h3>Global</h3><ul><li><a href="global.html#addEnabledCommands">addEnabledCommands</a></li><li><a href="global.html#addEnabledEventListeners">addEnabledEventListeners</a></li><li><a href="global.html#autocomplete">autocomplete</a></li><li><a href="global.html#checkIfNodeHasOpenDiscordClient">checkIfNodeHasOpenDiscordClient</a></li><li><a href="global.html#checkIfNodeIsConnectedToVC">checkIfNodeIsConnectedToVC</a></li><li><a href="global.html#execute">execute</a></li><li><a href="global.html#getAllSocketsConnectedToVC">getAllSocketsConnectedToVC</a></li><li><a href="global.html#getAvailableNodes">getAvailableNodes</a></li><li><a href="global.html#getNodeDiscordID">getNodeDiscordID</a></li><li><a href="global.html#getNodeDiscordUsername">getNodeDiscordUsername</a></li><li><a href="global.html#getSocketIdByNuid">getSocketIdByNuid</a></li><li><a href="global.html#getUserVoiceChannel">getUserVoiceChannel</a></li><li><a href="global.html#joinNode">joinNode</a></li><li><a href="global.html#nearbySystemsUpdateWraper">nearbySystemsUpdateWraper</a></li><li><a href="global.html#nodeDisconnectWrapper">nodeDisconnectWrapper</a></li><li><a href="global.html#nodeLoginWrapper">nodeLoginWrapper</a></li><li><a href="global.html#nodeUpdateWrapper">nodeUpdateWrapper</a></li><li><a href="global.html#promptNodeSelection">promptNodeSelection</a></li><li><a href="global.html#refreshActiveCommandsWrapper">refreshActiveCommandsWrapper</a></li><li><a href="global.html#requestBotLeaveServer">requestBotLeaveServer</a></li><li><a href="global.html#requestNodeJoinSystem">requestNodeJoinSystem</a></li><li><a href="global.html#requestNodeUpdate">requestNodeUpdate</a></li><li><a href="global.html#sendNodeCommand">sendNodeCommand</a></li><li><a href="global.html#unregisterAllCommands">unregisterAllCommands</a></li><li><a href="global.html#updateFeeds">updateFeeds</a></li><li><a href="global.html#writeToLog">writeToLog</a></li></ul></div>
|
||||
|
||||
</nav>
|
||||
</div>
|
||||
<div class="core" id="main-content-wrapper">
|
||||
<div class="content">
|
||||
<header class="page-title">
|
||||
<p>Class</p>
|
||||
<h1>DebugBuilder</h1>
|
||||
</header>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
|
||||
<header>
|
||||
|
||||
<h2><span class="attribs"><span class="type-signature"></span></span>DebugBuilder<span class="signature">(appName, fileName)</span><span class="type-signature"></span></h2>
|
||||
|
||||
<div class="class-description">Create the different logging methods for a function
|
||||
Namespace template = ("[app]:[fileName]:['INFO', 'WARNING', 'DEBUG', 'ERROR']")</div>
|
||||
|
||||
|
||||
</header>
|
||||
|
||||
<article>
|
||||
<div class="container-overview">
|
||||
|
||||
|
||||
<div class='vertical-section'>
|
||||
<div class="members">
|
||||
<div class="member">
|
||||
<div class=name>
|
||||
<span class="tag">Constructor</span>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<h4 class="name" id="DebugBuilder">
|
||||
<a class="href-link" href="#DebugBuilder">#</a>
|
||||
|
||||
<span class="code-name">
|
||||
|
||||
new DebugBuilder<span class="signature">(appName, fileName)</span><span class="type-signature"></span>
|
||||
|
||||
</span>
|
||||
</h4>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h5>Parameters:</h5>
|
||||
|
||||
<div class="table-container">
|
||||
<table class="params table">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
<th>Name</th>
|
||||
|
||||
|
||||
<th>Type</th>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<th class="last">Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
|
||||
|
||||
|
||||
<tr class="deep-level-0">
|
||||
|
||||
<td class="name"><code>appName</code></td>
|
||||
|
||||
|
||||
<td class="type">
|
||||
|
||||
|
||||
<code class="param-type">string</code>
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="description last">The name of the app to be used in the 'app' portion of the namespace</td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<tr class="deep-level-0">
|
||||
|
||||
<td class="name"><code>fileName</code></td>
|
||||
|
||||
|
||||
<td class="type">
|
||||
|
||||
|
||||
<code class="param-type">string</code>
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="description last">The name of the file calling the builder to be used in the 'fileName' portion of the namespace</td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dl class="details">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<p class="tag-source">
|
||||
<a href="modules_debugger.mjs.html" class="button">View Source</a>
|
||||
<span>
|
||||
<a href="modules_debugger.mjs.html">modules/debugger.mjs</a>, <a href="modules_debugger.mjs.html#line44">line 44</a>
|
||||
</span>
|
||||
</p>
|
||||
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h3 class="subsection-title">Classes</h3>
|
||||
|
||||
<dl>
|
||||
<dt><a href="DebugBuilder.html">DebugBuilder</a></dt>
|
||||
<dd></dd>
|
||||
</dl>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</article>
|
||||
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<footer class="footer">
|
||||
<div class="content has-text-centered">
|
||||
<p>Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a></p>
|
||||
<p class="sidebar-created-by">
|
||||
<a href="https://github.com/SoftwareBrothers/better-docs" target="_blank">BetterDocs theme</a> provided with <i class="fas fa-heart"></i> by
|
||||
<a href="http://softwarebrothers.co" target="_blank">SoftwareBrothers - JavaScript Development Agency</a>
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
</div>
|
||||
<div id="side-nav" class="side-nav">
|
||||
</div>
|
||||
</div>
|
||||
<script src="scripts/app.min.js"></script>
|
||||
<script>PR.prettyPrint();</script>
|
||||
<script src="scripts/linenumber.js"> </script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
1060
PresenceManager.html
Normal file
1060
PresenceManager.html
Normal file
File diff suppressed because it is too large
Load Diff
169
discordBot_commands_connections.mjs.html
Normal file
169
discordBot_commands_connections.mjs.html
Normal file
@@ -0,0 +1,169 @@
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title> discordBot/commands/connections.mjs</title>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js"></script>
|
||||
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
|
||||
<script src="./build/entry.js"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link href="https://fonts.googleapis.com/css?family=Roboto:100,400,700|Inconsolata,700" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
|
||||
<link type="text/css" rel="stylesheet" href="https://jmblog.github.io/color-themes-for-google-code-prettify/themes/tomorrow-night.min.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/app.min.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/iframe.css">
|
||||
<link type="text/css" rel="stylesheet" href="">
|
||||
<script async defer src="https://buttons.github.io/buttons.js"></script>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
|
||||
|
||||
<body class="layout small-header">
|
||||
<div id="stickyNavbarOverlay"></div>
|
||||
|
||||
|
||||
<div class="top-nav">
|
||||
<div class="inner">
|
||||
<a id="hamburger" role="button" class="navbar-burger" aria-label="menu" aria-expanded="false">
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
</a>
|
||||
<div class="logo">
|
||||
|
||||
|
||||
</div>
|
||||
<div class="menu">
|
||||
|
||||
<div class="navigation">
|
||||
<a
|
||||
href="index.html"
|
||||
class="link"
|
||||
>
|
||||
Documentation
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="main">
|
||||
<div
|
||||
class="sidebar "
|
||||
id="sidebarNav"
|
||||
>
|
||||
|
||||
<nav>
|
||||
|
||||
<h2><a href="index.html">Documentation</a></h2><div class="category"><h3>Classes</h3><ul><li><a href="DebugBuilder.html">DebugBuilder</a></li><li><a href="PresenceManager.html">PresenceManager</a></li></ul><h3>Global</h3><ul><li><a href="global.html#addEnabledCommands">addEnabledCommands</a></li><li><a href="global.html#addEnabledEventListeners">addEnabledEventListeners</a></li><li><a href="global.html#autocomplete">autocomplete</a></li><li><a href="global.html#checkIfNodeHasOpenDiscordClient">checkIfNodeHasOpenDiscordClient</a></li><li><a href="global.html#checkIfNodeIsConnectedToVC">checkIfNodeIsConnectedToVC</a></li><li><a href="global.html#execute">execute</a></li><li><a href="global.html#getAllSocketsConnectedToVC">getAllSocketsConnectedToVC</a></li><li><a href="global.html#getAvailableNodes">getAvailableNodes</a></li><li><a href="global.html#getNodeDiscordID">getNodeDiscordID</a></li><li><a href="global.html#getNodeDiscordUsername">getNodeDiscordUsername</a></li><li><a href="global.html#getSocketIdByNuid">getSocketIdByNuid</a></li><li><a href="global.html#getUserVoiceChannel">getUserVoiceChannel</a></li><li><a href="global.html#joinNode">joinNode</a></li><li><a href="global.html#nearbySystemsUpdateWraper">nearbySystemsUpdateWraper</a></li><li><a href="global.html#nodeDisconnectWrapper">nodeDisconnectWrapper</a></li><li><a href="global.html#nodeLoginWrapper">nodeLoginWrapper</a></li><li><a href="global.html#nodeUpdateWrapper">nodeUpdateWrapper</a></li><li><a href="global.html#promptNodeSelection">promptNodeSelection</a></li><li><a href="global.html#refreshActiveCommandsWrapper">refreshActiveCommandsWrapper</a></li><li><a href="global.html#requestBotLeaveServer">requestBotLeaveServer</a></li><li><a href="global.html#requestNodeJoinSystem">requestNodeJoinSystem</a></li><li><a href="global.html#requestNodeUpdate">requestNodeUpdate</a></li><li><a href="global.html#sendNodeCommand">sendNodeCommand</a></li><li><a href="global.html#unregisterAllCommands">unregisterAllCommands</a></li><li><a href="global.html#updateFeeds">updateFeeds</a></li><li><a href="global.html#writeToLog">writeToLog</a></li></ul></div>
|
||||
|
||||
</nav>
|
||||
</div>
|
||||
<div class="core" id="main-content-wrapper">
|
||||
<div class="content">
|
||||
<header class="page-title">
|
||||
<p>Source</p>
|
||||
<h1>discordBot/commands/connections.mjs</h1>
|
||||
</header>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="prettyprint source linenums"><code>import { DebugBuilder } from "../../modules/debugger.mjs";
|
||||
const log = new DebugBuilder("server", "discordBot.command.ping");
|
||||
import { SlashCommandBuilder } from "discord.js";
|
||||
|
||||
// Exporting data property that contains the command structure for discord including any params
|
||||
export const data = new SlashCommandBuilder()
|
||||
.setName("connections")
|
||||
.setDescription("Check to see what bots are online.");
|
||||
|
||||
// Exporting other properties
|
||||
export const example = "/connections"; // An example of how the command would be run in discord chat, this will be used for the help command
|
||||
export const deferInitialReply = false; // If we the initial reply in discord should be deferred. This gives extra time to respond, however the method of replying is different.
|
||||
|
||||
/**
|
||||
* Function to give the user auto-reply suggestions
|
||||
* @param {any} nodeIo The nodeIO server for manipulation of sockets
|
||||
* @param {any} interaction The interaction object
|
||||
*/
|
||||
/*
|
||||
export async function autocomplete(nodeIo, interaction) {
|
||||
const focusedValue = interaction.options.getFocused();
|
||||
const choices = []; // The array to be filled with the autocorrect values
|
||||
const filtered = choices.filter(choice => choice.name.startsWith(focusedValue));
|
||||
log.INFO(focusedValue, choices, filtered);
|
||||
await interaction.respond(filtered.map(choice => ({name: choice.name, value: choice.name})));
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* The function to run when the command is called by a discord user
|
||||
* @param {any} nodeIo The nodeIO server for manipulation of sockets
|
||||
* @param {any} interaction The interaction object
|
||||
*/
|
||||
export const execute = async (nodeIo, interaction) => {
|
||||
try {
|
||||
const sockets = await nodeIo.allSockets();
|
||||
log.DEBUG("All open sockets: ", sockets);
|
||||
let socketMessage = "";
|
||||
|
||||
// Create the message for discord with each socket on a new line
|
||||
sockets.forEach((socket) => {
|
||||
socketMessage += `\n${socket}`;
|
||||
});
|
||||
|
||||
await interaction.reply(`**Online Sockets: '${socketMessage}'**`);
|
||||
//await interaction.reply('**Pong.**');
|
||||
//await interaction.channel.send('**Pong.**');
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
// await interaction.reply(err.toString());
|
||||
}
|
||||
};
|
||||
</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<footer class="footer">
|
||||
<div class="content has-text-centered">
|
||||
<p>Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a></p>
|
||||
<p class="sidebar-created-by">
|
||||
<a href="https://github.com/SoftwareBrothers/better-docs" target="_blank">BetterDocs theme</a> provided with <i class="fas fa-heart"></i> by
|
||||
<a href="http://softwarebrothers.co" target="_blank">SoftwareBrothers - JavaScript Development Agency</a>
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
</div>
|
||||
<div id="side-nav" class="side-nav">
|
||||
</div>
|
||||
</div>
|
||||
<script src="scripts/app.min.js"></script>
|
||||
<script>PR.prettyPrint();</script>
|
||||
<script src="scripts/linenumber.js"> </script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
246
discordBot_commands_join.mjs.html
Normal file
246
discordBot_commands_join.mjs.html
Normal file
@@ -0,0 +1,246 @@
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title> discordBot/commands/join.mjs</title>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js"></script>
|
||||
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
|
||||
<script src="./build/entry.js"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link href="https://fonts.googleapis.com/css?family=Roboto:100,400,700|Inconsolata,700" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
|
||||
<link type="text/css" rel="stylesheet" href="https://jmblog.github.io/color-themes-for-google-code-prettify/themes/tomorrow-night.min.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/app.min.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/iframe.css">
|
||||
<link type="text/css" rel="stylesheet" href="">
|
||||
<script async defer src="https://buttons.github.io/buttons.js"></script>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
|
||||
|
||||
<body class="layout small-header">
|
||||
<div id="stickyNavbarOverlay"></div>
|
||||
|
||||
|
||||
<div class="top-nav">
|
||||
<div class="inner">
|
||||
<a id="hamburger" role="button" class="navbar-burger" aria-label="menu" aria-expanded="false">
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
</a>
|
||||
<div class="logo">
|
||||
|
||||
|
||||
</div>
|
||||
<div class="menu">
|
||||
|
||||
<div class="navigation">
|
||||
<a
|
||||
href="index.html"
|
||||
class="link"
|
||||
>
|
||||
Documentation
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="main">
|
||||
<div
|
||||
class="sidebar "
|
||||
id="sidebarNav"
|
||||
>
|
||||
|
||||
<nav>
|
||||
|
||||
<h2><a href="index.html">Documentation</a></h2><div class="category"><h3>Classes</h3><ul><li><a href="DebugBuilder.html">DebugBuilder</a></li><li><a href="PresenceManager.html">PresenceManager</a></li></ul><h3>Global</h3><ul><li><a href="global.html#addEnabledCommands">addEnabledCommands</a></li><li><a href="global.html#addEnabledEventListeners">addEnabledEventListeners</a></li><li><a href="global.html#autocomplete">autocomplete</a></li><li><a href="global.html#checkIfNodeHasOpenDiscordClient">checkIfNodeHasOpenDiscordClient</a></li><li><a href="global.html#checkIfNodeIsConnectedToVC">checkIfNodeIsConnectedToVC</a></li><li><a href="global.html#execute">execute</a></li><li><a href="global.html#getAllSocketsConnectedToVC">getAllSocketsConnectedToVC</a></li><li><a href="global.html#getAvailableNodes">getAvailableNodes</a></li><li><a href="global.html#getNodeDiscordID">getNodeDiscordID</a></li><li><a href="global.html#getNodeDiscordUsername">getNodeDiscordUsername</a></li><li><a href="global.html#getSocketIdByNuid">getSocketIdByNuid</a></li><li><a href="global.html#getUserVoiceChannel">getUserVoiceChannel</a></li><li><a href="global.html#joinNode">joinNode</a></li><li><a href="global.html#nearbySystemsUpdateWraper">nearbySystemsUpdateWraper</a></li><li><a href="global.html#nodeDisconnectWrapper">nodeDisconnectWrapper</a></li><li><a href="global.html#nodeLoginWrapper">nodeLoginWrapper</a></li><li><a href="global.html#nodeUpdateWrapper">nodeUpdateWrapper</a></li><li><a href="global.html#promptNodeSelection">promptNodeSelection</a></li><li><a href="global.html#refreshActiveCommandsWrapper">refreshActiveCommandsWrapper</a></li><li><a href="global.html#requestBotLeaveServer">requestBotLeaveServer</a></li><li><a href="global.html#requestNodeJoinSystem">requestNodeJoinSystem</a></li><li><a href="global.html#requestNodeUpdate">requestNodeUpdate</a></li><li><a href="global.html#sendNodeCommand">sendNodeCommand</a></li><li><a href="global.html#unregisterAllCommands">unregisterAllCommands</a></li><li><a href="global.html#updateFeeds">updateFeeds</a></li><li><a href="global.html#writeToLog">writeToLog</a></li></ul></div>
|
||||
|
||||
</nav>
|
||||
</div>
|
||||
<div class="core" id="main-content-wrapper">
|
||||
<div class="content">
|
||||
<header class="page-title">
|
||||
<p>Source</p>
|
||||
<h1>discordBot/commands/join.mjs</h1>
|
||||
</header>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="prettyprint source linenums"><code>import { DebugBuilder } from "../../modules/debugger.mjs";
|
||||
import { SlashCommandBuilder } from "discord.js";
|
||||
import {
|
||||
joinNode,
|
||||
getAvailableNodes,
|
||||
promptNodeSelection,
|
||||
getUserVoiceChannel,
|
||||
} from "../modules/wrappers.mjs";
|
||||
import {
|
||||
getAllSystems,
|
||||
getSystemByName,
|
||||
} from "../../modules/mongo-wrappers/mongoSystemsWrappers.mjs";
|
||||
|
||||
const log = new DebugBuilder("server", "discordBot.command.join");
|
||||
|
||||
// Exporting data property
|
||||
export const data = new SlashCommandBuilder()
|
||||
.setName("join")
|
||||
.setDescription("Listen to the selected radio system in your channel")
|
||||
.addStringOption((system) =>
|
||||
system
|
||||
.setName("system")
|
||||
.setDescription("The radio system you would like to listen to")
|
||||
.setRequired(true)
|
||||
.setAutocomplete(true),
|
||||
);
|
||||
|
||||
// Exporting other properties
|
||||
export const example = "/join";
|
||||
export const deferInitialReply = true;
|
||||
|
||||
/**
|
||||
* Function to give the user auto-reply suggestions
|
||||
* @param {any} nodeIo The nodeIO server for manipulation of sockets
|
||||
* @param {any} interaction The interaction object
|
||||
*/
|
||||
export async function autocomplete(nodeIo, interaction) {
|
||||
const focusedValue = interaction.options.getFocused();
|
||||
const choices = await getAllSystems();
|
||||
const filtered = choices.filter((choice) =>
|
||||
choice.name.startsWith(focusedValue),
|
||||
);
|
||||
|
||||
log.DEBUG(focusedValue, choices, filtered);
|
||||
|
||||
try {
|
||||
await interaction.respond(
|
||||
filtered.map((choice) => ({ name: choice.name, value: choice.name })),
|
||||
);
|
||||
} catch (e) {
|
||||
log.WARN("Autocomplete interaction failure", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle join command execution
|
||||
* @param {any} nodeIo The nodeIO server for manipulation of sockets
|
||||
* @param {any} interaction The interaction object
|
||||
*/
|
||||
export async function execute(nodeIo, interaction) {
|
||||
try {
|
||||
// Validate user is in a voice channel
|
||||
const channelToJoin = getUserVoiceChannel(interaction);
|
||||
if (!channelToJoin) return;
|
||||
|
||||
// Get the selected system
|
||||
const selectedSystemName = interaction.options.getString("system");
|
||||
const system = await getSystemByName(selectedSystemName);
|
||||
|
||||
// Check if there was a system found by the given system name
|
||||
if (!system) {
|
||||
await interaction.editReply({
|
||||
content: `System '${selectedSystemName}' not found.`,
|
||||
ephemeral: true,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the available nodes for this system
|
||||
const availableNodes = await getAvailableNodes(
|
||||
nodeIo,
|
||||
interaction.guild.id,
|
||||
system,
|
||||
);
|
||||
|
||||
// Check if there are available nodes
|
||||
if (availableNodes.length === 0) {
|
||||
// If not, let the user know
|
||||
await interaction.editReply(
|
||||
`<@${interaction.member.id}>, the selected system has no available nodes`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// If there is one available node, request that node join
|
||||
if (availableNodes.length === 1) {
|
||||
await joinNode(
|
||||
nodeIo,
|
||||
interaction,
|
||||
availableNodes[0].id,
|
||||
system,
|
||||
channelToJoin,
|
||||
);
|
||||
}
|
||||
|
||||
// If there are more than one available, prompt the user for their selected node
|
||||
else {
|
||||
await promptNodeSelection(
|
||||
interaction,
|
||||
availableNodes,
|
||||
async (selectedNode) => {
|
||||
await joinNode(
|
||||
nodeIo,
|
||||
interaction,
|
||||
selectedNode,
|
||||
system,
|
||||
channelToJoin,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
} catch (err) {
|
||||
log.ERROR(err);
|
||||
await interaction.editReply({
|
||||
content: `An error occurred: ${err.message}`,
|
||||
ephemeral: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<footer class="footer">
|
||||
<div class="content has-text-centered">
|
||||
<p>Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a></p>
|
||||
<p class="sidebar-created-by">
|
||||
<a href="https://github.com/SoftwareBrothers/better-docs" target="_blank">BetterDocs theme</a> provided with <i class="fas fa-heart"></i> by
|
||||
<a href="http://softwarebrothers.co" target="_blank">SoftwareBrothers - JavaScript Development Agency</a>
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
</div>
|
||||
<div id="side-nav" class="side-nav">
|
||||
</div>
|
||||
</div>
|
||||
<script src="scripts/app.min.js"></script>
|
||||
<script>PR.prettyPrint();</script>
|
||||
<script src="scripts/linenumber.js"> </script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
198
discordBot_commands_leave.mjs.html
Normal file
198
discordBot_commands_leave.mjs.html
Normal file
@@ -0,0 +1,198 @@
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title> discordBot/commands/leave.mjs</title>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js"></script>
|
||||
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
|
||||
<script src="./build/entry.js"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link href="https://fonts.googleapis.com/css?family=Roboto:100,400,700|Inconsolata,700" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
|
||||
<link type="text/css" rel="stylesheet" href="https://jmblog.github.io/color-themes-for-google-code-prettify/themes/tomorrow-night.min.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/app.min.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/iframe.css">
|
||||
<link type="text/css" rel="stylesheet" href="">
|
||||
<script async defer src="https://buttons.github.io/buttons.js"></script>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
|
||||
|
||||
<body class="layout small-header">
|
||||
<div id="stickyNavbarOverlay"></div>
|
||||
|
||||
|
||||
<div class="top-nav">
|
||||
<div class="inner">
|
||||
<a id="hamburger" role="button" class="navbar-burger" aria-label="menu" aria-expanded="false">
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
</a>
|
||||
<div class="logo">
|
||||
|
||||
|
||||
</div>
|
||||
<div class="menu">
|
||||
|
||||
<div class="navigation">
|
||||
<a
|
||||
href="index.html"
|
||||
class="link"
|
||||
>
|
||||
Documentation
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="main">
|
||||
<div
|
||||
class="sidebar "
|
||||
id="sidebarNav"
|
||||
>
|
||||
|
||||
<nav>
|
||||
|
||||
<h2><a href="index.html">Documentation</a></h2><div class="category"><h3>Classes</h3><ul><li><a href="DebugBuilder.html">DebugBuilder</a></li><li><a href="PresenceManager.html">PresenceManager</a></li></ul><h3>Global</h3><ul><li><a href="global.html#addEnabledCommands">addEnabledCommands</a></li><li><a href="global.html#addEnabledEventListeners">addEnabledEventListeners</a></li><li><a href="global.html#autocomplete">autocomplete</a></li><li><a href="global.html#checkIfNodeHasOpenDiscordClient">checkIfNodeHasOpenDiscordClient</a></li><li><a href="global.html#checkIfNodeIsConnectedToVC">checkIfNodeIsConnectedToVC</a></li><li><a href="global.html#execute">execute</a></li><li><a href="global.html#getAllSocketsConnectedToVC">getAllSocketsConnectedToVC</a></li><li><a href="global.html#getAvailableNodes">getAvailableNodes</a></li><li><a href="global.html#getNodeDiscordID">getNodeDiscordID</a></li><li><a href="global.html#getNodeDiscordUsername">getNodeDiscordUsername</a></li><li><a href="global.html#getSocketIdByNuid">getSocketIdByNuid</a></li><li><a href="global.html#getUserVoiceChannel">getUserVoiceChannel</a></li><li><a href="global.html#joinNode">joinNode</a></li><li><a href="global.html#nearbySystemsUpdateWraper">nearbySystemsUpdateWraper</a></li><li><a href="global.html#nodeDisconnectWrapper">nodeDisconnectWrapper</a></li><li><a href="global.html#nodeLoginWrapper">nodeLoginWrapper</a></li><li><a href="global.html#nodeUpdateWrapper">nodeUpdateWrapper</a></li><li><a href="global.html#promptNodeSelection">promptNodeSelection</a></li><li><a href="global.html#refreshActiveCommandsWrapper">refreshActiveCommandsWrapper</a></li><li><a href="global.html#requestBotLeaveServer">requestBotLeaveServer</a></li><li><a href="global.html#requestNodeJoinSystem">requestNodeJoinSystem</a></li><li><a href="global.html#requestNodeUpdate">requestNodeUpdate</a></li><li><a href="global.html#sendNodeCommand">sendNodeCommand</a></li><li><a href="global.html#unregisterAllCommands">unregisterAllCommands</a></li><li><a href="global.html#updateFeeds">updateFeeds</a></li><li><a href="global.html#writeToLog">writeToLog</a></li></ul></div>
|
||||
|
||||
</nav>
|
||||
</div>
|
||||
<div class="core" id="main-content-wrapper">
|
||||
<div class="content">
|
||||
<header class="page-title">
|
||||
<p>Source</p>
|
||||
<h1>discordBot/commands/leave.mjs</h1>
|
||||
</header>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="prettyprint source linenums"><code>import { DebugBuilder } from "../../modules/debugger.mjs";
|
||||
import { SlashCommandBuilder } from "discord.js";
|
||||
import {
|
||||
requestBotLeaveServer,
|
||||
getSocketIdByNuid,
|
||||
} from "../../modules/socketServerWrappers.mjs";
|
||||
import { checkOnlineBotsInGuild } from "../modules/wrappers.mjs";
|
||||
|
||||
const log = new DebugBuilder("server", "discordBot.command.leave");
|
||||
|
||||
// Exporting data property
|
||||
export const data = new SlashCommandBuilder()
|
||||
.setName("leave")
|
||||
.setDescription("Disconnect a bot from the server")
|
||||
.addStringOption((system) =>
|
||||
system
|
||||
.setName("bot")
|
||||
.setDescription("The bot you would like to disconnect")
|
||||
.setRequired(true)
|
||||
.setAutocomplete(true),
|
||||
);
|
||||
|
||||
// Exporting other properties
|
||||
export const example = "/leave *{Bot Name}*";
|
||||
export const deferInitialReply = true;
|
||||
|
||||
/**
|
||||
* Function to give the user auto-reply suggestions
|
||||
* @param {any} nodeIo The nodeIO server for manipulation of sockets
|
||||
* @param {any} interaction The interaction object
|
||||
*/
|
||||
export async function autocomplete(nodeIo, interaction) {
|
||||
const focusedValue = interaction.options.getFocused();
|
||||
const choices = await checkOnlineBotsInGuild(nodeIo, interaction.guild.id);
|
||||
|
||||
log.DEBUG(choices);
|
||||
|
||||
const filtered = choices
|
||||
.filter((choice) => choice.name.startsWith(focusedValue))
|
||||
.map((choice) => ({ name: choice.name, value: choice.nuid }));
|
||||
|
||||
log.DEBUG(focusedValue, choices, filtered);
|
||||
|
||||
try {
|
||||
await interaction.respond(filtered);
|
||||
} catch (e) {
|
||||
log.WARN("Autocomplete interaction failure", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The function to run when the command is called by a discord user
|
||||
* @param {any} nodeIo The nodeIO server for manipulation of sockets
|
||||
* @param {any} interaction The interaction object
|
||||
*/
|
||||
export async function execute(nodeIo, interaction) {
|
||||
try {
|
||||
const selectedNode = interaction.options.getString("bot");
|
||||
const socket = await getSocketIdByNuid(nodeIo, selectedNode);
|
||||
|
||||
if (!socket) {
|
||||
await interaction.editReply({
|
||||
content: `Bot '${selectedNode}' not found or not connected.`,
|
||||
ephemeral: true,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
await requestBotLeaveServer(socket, interaction.guild.id);
|
||||
|
||||
await interaction.editReply(
|
||||
`Ok <@${interaction.member.id}>, the bot is leaving shortly.`,
|
||||
);
|
||||
} catch (err) {
|
||||
log.ERROR("Failed to disconnect bot:", err);
|
||||
await interaction.editReply({
|
||||
content: `An error occurred: ${err.message}`,
|
||||
ephemeral: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<footer class="footer">
|
||||
<div class="content has-text-centered">
|
||||
<p>Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a></p>
|
||||
<p class="sidebar-created-by">
|
||||
<a href="https://github.com/SoftwareBrothers/better-docs" target="_blank">BetterDocs theme</a> provided with <i class="fas fa-heart"></i> by
|
||||
<a href="http://softwarebrothers.co" target="_blank">SoftwareBrothers - JavaScript Development Agency</a>
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
</div>
|
||||
<div id="side-nav" class="side-nav">
|
||||
</div>
|
||||
</div>
|
||||
<script src="scripts/app.min.js"></script>
|
||||
<script>PR.prettyPrint();</script>
|
||||
<script src="scripts/linenumber.js"> </script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
162
discordBot_commands_ping.mjs.html
Normal file
162
discordBot_commands_ping.mjs.html
Normal file
@@ -0,0 +1,162 @@
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title> discordBot/commands/ping.mjs</title>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js"></script>
|
||||
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
|
||||
<script src="./build/entry.js"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link href="https://fonts.googleapis.com/css?family=Roboto:100,400,700|Inconsolata,700" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
|
||||
<link type="text/css" rel="stylesheet" href="https://jmblog.github.io/color-themes-for-google-code-prettify/themes/tomorrow-night.min.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/app.min.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/iframe.css">
|
||||
<link type="text/css" rel="stylesheet" href="">
|
||||
<script async defer src="https://buttons.github.io/buttons.js"></script>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
|
||||
|
||||
<body class="layout small-header">
|
||||
<div id="stickyNavbarOverlay"></div>
|
||||
|
||||
|
||||
<div class="top-nav">
|
||||
<div class="inner">
|
||||
<a id="hamburger" role="button" class="navbar-burger" aria-label="menu" aria-expanded="false">
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
</a>
|
||||
<div class="logo">
|
||||
|
||||
|
||||
</div>
|
||||
<div class="menu">
|
||||
|
||||
<div class="navigation">
|
||||
<a
|
||||
href="index.html"
|
||||
class="link"
|
||||
>
|
||||
Documentation
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="main">
|
||||
<div
|
||||
class="sidebar "
|
||||
id="sidebarNav"
|
||||
>
|
||||
|
||||
<nav>
|
||||
|
||||
<h2><a href="index.html">Documentation</a></h2><div class="category"><h3>Classes</h3><ul><li><a href="DebugBuilder.html">DebugBuilder</a></li><li><a href="PresenceManager.html">PresenceManager</a></li></ul><h3>Global</h3><ul><li><a href="global.html#addEnabledCommands">addEnabledCommands</a></li><li><a href="global.html#addEnabledEventListeners">addEnabledEventListeners</a></li><li><a href="global.html#autocomplete">autocomplete</a></li><li><a href="global.html#checkIfNodeHasOpenDiscordClient">checkIfNodeHasOpenDiscordClient</a></li><li><a href="global.html#checkIfNodeIsConnectedToVC">checkIfNodeIsConnectedToVC</a></li><li><a href="global.html#execute">execute</a></li><li><a href="global.html#getAllSocketsConnectedToVC">getAllSocketsConnectedToVC</a></li><li><a href="global.html#getAvailableNodes">getAvailableNodes</a></li><li><a href="global.html#getNodeDiscordID">getNodeDiscordID</a></li><li><a href="global.html#getNodeDiscordUsername">getNodeDiscordUsername</a></li><li><a href="global.html#getSocketIdByNuid">getSocketIdByNuid</a></li><li><a href="global.html#getUserVoiceChannel">getUserVoiceChannel</a></li><li><a href="global.html#joinNode">joinNode</a></li><li><a href="global.html#nearbySystemsUpdateWraper">nearbySystemsUpdateWraper</a></li><li><a href="global.html#nodeDisconnectWrapper">nodeDisconnectWrapper</a></li><li><a href="global.html#nodeLoginWrapper">nodeLoginWrapper</a></li><li><a href="global.html#nodeUpdateWrapper">nodeUpdateWrapper</a></li><li><a href="global.html#promptNodeSelection">promptNodeSelection</a></li><li><a href="global.html#refreshActiveCommandsWrapper">refreshActiveCommandsWrapper</a></li><li><a href="global.html#requestBotLeaveServer">requestBotLeaveServer</a></li><li><a href="global.html#requestNodeJoinSystem">requestNodeJoinSystem</a></li><li><a href="global.html#requestNodeUpdate">requestNodeUpdate</a></li><li><a href="global.html#sendNodeCommand">sendNodeCommand</a></li><li><a href="global.html#unregisterAllCommands">unregisterAllCommands</a></li><li><a href="global.html#updateFeeds">updateFeeds</a></li><li><a href="global.html#writeToLog">writeToLog</a></li></ul></div>
|
||||
|
||||
</nav>
|
||||
</div>
|
||||
<div class="core" id="main-content-wrapper">
|
||||
<div class="content">
|
||||
<header class="page-title">
|
||||
<p>Source</p>
|
||||
<h1>discordBot/commands/ping.mjs</h1>
|
||||
</header>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="prettyprint source linenums"><code>import { DebugBuilder } from "../../modules/debugger.mjs";
|
||||
const log = new DebugBuilder("server", "discordBot.command.ping");
|
||||
import { SlashCommandBuilder } from "discord.js";
|
||||
|
||||
// Exporting data property that contains the command structure for discord including any params
|
||||
export const data = new SlashCommandBuilder()
|
||||
.setName("ping")
|
||||
.setDescription("Replies with your input!");
|
||||
|
||||
// Exporting other properties
|
||||
export const example = "/ping"; // An example of how the command would be run in discord chat, this will be used for the help command
|
||||
export const deferInitialReply = false; // If we the initial reply in discord should be deferred. This gives extra time to respond, however the method of replying is different.
|
||||
|
||||
/**
|
||||
* Function to give the user auto-reply suggestions
|
||||
* @param {any} nodeIo The nodeIO server for manipulation of sockets
|
||||
* @param {any} interaction The interaction object
|
||||
*/
|
||||
/*
|
||||
export async function autocomplete(nodeIo, interaction) {
|
||||
const focusedValue = interaction.options.getFocused();
|
||||
const choices = []; // The array to be filled with the autocorrect values
|
||||
const filtered = choices.filter(choice => choice.name.startsWith(focusedValue));
|
||||
log.INFO(focusedValue, choices, filtered);
|
||||
await interaction.respond(filtered.map(choice => ({name: choice.name, value: choice.name})));
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* The function to run when the command is called by a discord user
|
||||
* @param {any} nodeIo The nodeIO server for manipulation of sockets
|
||||
* @param {any} interaction The interaction object
|
||||
*/
|
||||
export const execute = async (nodeIo, interaction) => {
|
||||
try {
|
||||
const sockets = await nodeIo.allSockets();
|
||||
log.DEBUG("All open sockets: ", sockets);
|
||||
//await interaction.reply(`**Online Sockets: '${sockets}'**`);
|
||||
await interaction.reply("**Pong.**");
|
||||
//await interaction.channel.send('**Pong.**');
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
// await interaction.reply(err.toString());
|
||||
}
|
||||
};
|
||||
</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<footer class="footer">
|
||||
<div class="content has-text-centered">
|
||||
<p>Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a></p>
|
||||
<p class="sidebar-created-by">
|
||||
<a href="https://github.com/SoftwareBrothers/better-docs" target="_blank">BetterDocs theme</a> provided with <i class="fas fa-heart"></i> by
|
||||
<a href="http://softwarebrothers.co" target="_blank">SoftwareBrothers - JavaScript Development Agency</a>
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
</div>
|
||||
<div id="side-nav" class="side-nav">
|
||||
</div>
|
||||
</div>
|
||||
<script src="scripts/app.min.js"></script>
|
||||
<script>PR.prettyPrint();</script>
|
||||
<script src="scripts/linenumber.js"> </script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
208
discordBot_commands_rssAdd.mjs.html
Normal file
208
discordBot_commands_rssAdd.mjs.html
Normal file
@@ -0,0 +1,208 @@
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title> discordBot/commands/rssAdd.mjs</title>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js"></script>
|
||||
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
|
||||
<script src="./build/entry.js"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link href="https://fonts.googleapis.com/css?family=Roboto:100,400,700|Inconsolata,700" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
|
||||
<link type="text/css" rel="stylesheet" href="https://jmblog.github.io/color-themes-for-google-code-prettify/themes/tomorrow-night.min.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/app.min.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/iframe.css">
|
||||
<link type="text/css" rel="stylesheet" href="">
|
||||
<script async defer src="https://buttons.github.io/buttons.js"></script>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
|
||||
|
||||
<body class="layout small-header">
|
||||
<div id="stickyNavbarOverlay"></div>
|
||||
|
||||
|
||||
<div class="top-nav">
|
||||
<div class="inner">
|
||||
<a id="hamburger" role="button" class="navbar-burger" aria-label="menu" aria-expanded="false">
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
</a>
|
||||
<div class="logo">
|
||||
|
||||
|
||||
</div>
|
||||
<div class="menu">
|
||||
|
||||
<div class="navigation">
|
||||
<a
|
||||
href="index.html"
|
||||
class="link"
|
||||
>
|
||||
Documentation
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="main">
|
||||
<div
|
||||
class="sidebar "
|
||||
id="sidebarNav"
|
||||
>
|
||||
|
||||
<nav>
|
||||
|
||||
<h2><a href="index.html">Documentation</a></h2><div class="category"><h3>Classes</h3><ul><li><a href="DebugBuilder.html">DebugBuilder</a></li><li><a href="PresenceManager.html">PresenceManager</a></li></ul><h3>Global</h3><ul><li><a href="global.html#addEnabledCommands">addEnabledCommands</a></li><li><a href="global.html#addEnabledEventListeners">addEnabledEventListeners</a></li><li><a href="global.html#autocomplete">autocomplete</a></li><li><a href="global.html#checkIfNodeHasOpenDiscordClient">checkIfNodeHasOpenDiscordClient</a></li><li><a href="global.html#checkIfNodeIsConnectedToVC">checkIfNodeIsConnectedToVC</a></li><li><a href="global.html#execute">execute</a></li><li><a href="global.html#getAllSocketsConnectedToVC">getAllSocketsConnectedToVC</a></li><li><a href="global.html#getAvailableNodes">getAvailableNodes</a></li><li><a href="global.html#getNodeDiscordID">getNodeDiscordID</a></li><li><a href="global.html#getNodeDiscordUsername">getNodeDiscordUsername</a></li><li><a href="global.html#getSocketIdByNuid">getSocketIdByNuid</a></li><li><a href="global.html#getUserVoiceChannel">getUserVoiceChannel</a></li><li><a href="global.html#joinNode">joinNode</a></li><li><a href="global.html#nearbySystemsUpdateWraper">nearbySystemsUpdateWraper</a></li><li><a href="global.html#nodeDisconnectWrapper">nodeDisconnectWrapper</a></li><li><a href="global.html#nodeLoginWrapper">nodeLoginWrapper</a></li><li><a href="global.html#nodeUpdateWrapper">nodeUpdateWrapper</a></li><li><a href="global.html#promptNodeSelection">promptNodeSelection</a></li><li><a href="global.html#refreshActiveCommandsWrapper">refreshActiveCommandsWrapper</a></li><li><a href="global.html#requestBotLeaveServer">requestBotLeaveServer</a></li><li><a href="global.html#requestNodeJoinSystem">requestNodeJoinSystem</a></li><li><a href="global.html#requestNodeUpdate">requestNodeUpdate</a></li><li><a href="global.html#sendNodeCommand">sendNodeCommand</a></li><li><a href="global.html#unregisterAllCommands">unregisterAllCommands</a></li><li><a href="global.html#updateFeeds">updateFeeds</a></li><li><a href="global.html#writeToLog">writeToLog</a></li></ul></div>
|
||||
|
||||
</nav>
|
||||
</div>
|
||||
<div class="core" id="main-content-wrapper">
|
||||
<div class="content">
|
||||
<header class="page-title">
|
||||
<p>Source</p>
|
||||
<h1>discordBot/commands/rssAdd.mjs</h1>
|
||||
</header>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="prettyprint source linenums"><code>import { SlashCommandBuilder } from "discord.js";
|
||||
import { DebugBuilder } from "../../modules/debugger.mjs";
|
||||
import { addSource } from "../../rss-manager/sourceManager.mjs";
|
||||
const log = new DebugBuilder("server", "discordBot.command.rssAdd");
|
||||
|
||||
// Exporting data property that contains the command structure for discord including any params
|
||||
export const data = new SlashCommandBuilder()
|
||||
.setName("rss-add")
|
||||
.setDescription("Add RSS Source")
|
||||
.addStringOption((option) =>
|
||||
option
|
||||
.setName("title")
|
||||
.setDescription("The title of the RSS feed")
|
||||
.setRequired(true),
|
||||
)
|
||||
.addStringOption((option) =>
|
||||
option
|
||||
.setName("link")
|
||||
.setDescription("The link to the RSS feed")
|
||||
.setRequired(true),
|
||||
)
|
||||
.addStringOption((option) =>
|
||||
option
|
||||
.setName("category")
|
||||
.setDescription('The category for the RSS feed *("ALL" by default")*')
|
||||
.setRequired(false),
|
||||
);
|
||||
|
||||
// Exporting other properties
|
||||
export const example =
|
||||
"/rss-add [title] [https://domain.com/feed.xml] [category]"; // An example of how the command would be run in discord chat, this will be used for the help command
|
||||
export const deferInitialReply = false; // If we the initial reply in discord should be deferred. This gives extra time to respond, however the method of replying is different.
|
||||
|
||||
/**
|
||||
* Function to give the user auto-reply suggestions
|
||||
* @param {any} nodeIo The nodeIO server for manipulation of sockets
|
||||
* @param {any} interaction The interaction object
|
||||
*/
|
||||
|
||||
// TODO - Setup autocorrect for the category
|
||||
/*
|
||||
export async function autocomplete(nodeIo, interaction) {
|
||||
const focusedValue = interaction.options.getFocused();
|
||||
const choices = [];
|
||||
const filtered = choices.filter(choice => choice.name.startsWith(focusedValue));
|
||||
log.DEBUG(focusedValue, choices, filtered);
|
||||
await interaction.respond(filtered);
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* The function to run when the command is called by a discord user
|
||||
* @param {any} nodeIo The nodeIO server for manipulation of sockets
|
||||
* @param {any} interaction The interaction object
|
||||
*/
|
||||
export const execute = async (nodeIo, interaction) => {
|
||||
try {
|
||||
var title = interaction.options.getString("title");
|
||||
var link = interaction.options.getString("link");
|
||||
var category = interaction.options.getString("category");
|
||||
|
||||
if (!category) category = "ALL";
|
||||
await interaction.reply(
|
||||
`Adding ${title} to the list of RSS sources, please wait...`,
|
||||
);
|
||||
|
||||
await addSource(
|
||||
title,
|
||||
link,
|
||||
category,
|
||||
interaction.guildId,
|
||||
interaction.channelId,
|
||||
(err, result) => {
|
||||
log.DEBUG("Result from adding entry", result);
|
||||
|
||||
if (result) {
|
||||
interaction.editReply(
|
||||
`Successfully added ${title} to the list of RSS sources`,
|
||||
);
|
||||
} else {
|
||||
interaction.editReply(
|
||||
`${title} already exists in the list of RSS sources`,
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
} catch (err) {
|
||||
log.ERROR(err);
|
||||
await interaction.editReply(err.toString());
|
||||
}
|
||||
};
|
||||
</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<footer class="footer">
|
||||
<div class="content has-text-centered">
|
||||
<p>Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a></p>
|
||||
<p class="sidebar-created-by">
|
||||
<a href="https://github.com/SoftwareBrothers/better-docs" target="_blank">BetterDocs theme</a> provided with <i class="fas fa-heart"></i> by
|
||||
<a href="http://softwarebrothers.co" target="_blank">SoftwareBrothers - JavaScript Development Agency</a>
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
</div>
|
||||
<div id="side-nav" class="side-nav">
|
||||
</div>
|
||||
</div>
|
||||
<script src="scripts/app.min.js"></script>
|
||||
<script>PR.prettyPrint();</script>
|
||||
<script src="scripts/linenumber.js"> </script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
186
discordBot_commands_rssRemove.mjs.html
Normal file
186
discordBot_commands_rssRemove.mjs.html
Normal file
@@ -0,0 +1,186 @@
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title> discordBot/commands/rssRemove.mjs</title>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js"></script>
|
||||
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
|
||||
<script src="./build/entry.js"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link href="https://fonts.googleapis.com/css?family=Roboto:100,400,700|Inconsolata,700" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
|
||||
<link type="text/css" rel="stylesheet" href="https://jmblog.github.io/color-themes-for-google-code-prettify/themes/tomorrow-night.min.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/app.min.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/iframe.css">
|
||||
<link type="text/css" rel="stylesheet" href="">
|
||||
<script async defer src="https://buttons.github.io/buttons.js"></script>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
|
||||
|
||||
<body class="layout small-header">
|
||||
<div id="stickyNavbarOverlay"></div>
|
||||
|
||||
|
||||
<div class="top-nav">
|
||||
<div class="inner">
|
||||
<a id="hamburger" role="button" class="navbar-burger" aria-label="menu" aria-expanded="false">
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
</a>
|
||||
<div class="logo">
|
||||
|
||||
|
||||
</div>
|
||||
<div class="menu">
|
||||
|
||||
<div class="navigation">
|
||||
<a
|
||||
href="index.html"
|
||||
class="link"
|
||||
>
|
||||
Documentation
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="main">
|
||||
<div
|
||||
class="sidebar "
|
||||
id="sidebarNav"
|
||||
>
|
||||
|
||||
<nav>
|
||||
|
||||
<h2><a href="index.html">Documentation</a></h2><div class="category"><h3>Classes</h3><ul><li><a href="DebugBuilder.html">DebugBuilder</a></li><li><a href="PresenceManager.html">PresenceManager</a></li></ul><h3>Global</h3><ul><li><a href="global.html#addEnabledCommands">addEnabledCommands</a></li><li><a href="global.html#addEnabledEventListeners">addEnabledEventListeners</a></li><li><a href="global.html#autocomplete">autocomplete</a></li><li><a href="global.html#checkIfNodeHasOpenDiscordClient">checkIfNodeHasOpenDiscordClient</a></li><li><a href="global.html#checkIfNodeIsConnectedToVC">checkIfNodeIsConnectedToVC</a></li><li><a href="global.html#execute">execute</a></li><li><a href="global.html#getAllSocketsConnectedToVC">getAllSocketsConnectedToVC</a></li><li><a href="global.html#getAvailableNodes">getAvailableNodes</a></li><li><a href="global.html#getNodeDiscordID">getNodeDiscordID</a></li><li><a href="global.html#getNodeDiscordUsername">getNodeDiscordUsername</a></li><li><a href="global.html#getSocketIdByNuid">getSocketIdByNuid</a></li><li><a href="global.html#getUserVoiceChannel">getUserVoiceChannel</a></li><li><a href="global.html#joinNode">joinNode</a></li><li><a href="global.html#nearbySystemsUpdateWraper">nearbySystemsUpdateWraper</a></li><li><a href="global.html#nodeDisconnectWrapper">nodeDisconnectWrapper</a></li><li><a href="global.html#nodeLoginWrapper">nodeLoginWrapper</a></li><li><a href="global.html#nodeUpdateWrapper">nodeUpdateWrapper</a></li><li><a href="global.html#promptNodeSelection">promptNodeSelection</a></li><li><a href="global.html#refreshActiveCommandsWrapper">refreshActiveCommandsWrapper</a></li><li><a href="global.html#requestBotLeaveServer">requestBotLeaveServer</a></li><li><a href="global.html#requestNodeJoinSystem">requestNodeJoinSystem</a></li><li><a href="global.html#requestNodeUpdate">requestNodeUpdate</a></li><li><a href="global.html#sendNodeCommand">sendNodeCommand</a></li><li><a href="global.html#unregisterAllCommands">unregisterAllCommands</a></li><li><a href="global.html#updateFeeds">updateFeeds</a></li><li><a href="global.html#writeToLog">writeToLog</a></li></ul></div>
|
||||
|
||||
</nav>
|
||||
</div>
|
||||
<div class="core" id="main-content-wrapper">
|
||||
<div class="content">
|
||||
<header class="page-title">
|
||||
<p>Source</p>
|
||||
<h1>discordBot/commands/rssRemove.mjs</h1>
|
||||
</header>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="prettyprint source linenums"><code>import { SlashCommandBuilder } from "discord.js";
|
||||
import { DebugBuilder } from "../../modules/debugger.mjs";
|
||||
import {
|
||||
getAllFeeds,
|
||||
deleteFeedByTitle,
|
||||
} from "../../modules/mongo-wrappers/mongoFeedsWrappers.mjs";
|
||||
const log = new DebugBuilder("server", "discordBot.command.rssRemove");
|
||||
|
||||
// Exporting data property that contains the command structure for discord including any params
|
||||
export const data = new SlashCommandBuilder()
|
||||
.setName("rss-remove")
|
||||
.setDescription("Add RSS Source")
|
||||
.addStringOption((option) =>
|
||||
option
|
||||
.setName("title")
|
||||
.setDescription("The title of the RSS feed")
|
||||
.setRequired(true)
|
||||
.setAutocomplete(true),
|
||||
);
|
||||
|
||||
// Exporting other properties
|
||||
export const example = "/rss-remove [title]"; // An example of how the command would be run in discord chat, this will be used for the help command
|
||||
export const deferInitialReply = false; // If we the initial reply in discord should be deferred. This gives extra time to respond, however the method of replying is different.
|
||||
|
||||
/**
|
||||
* Function to give the user auto-reply suggestions
|
||||
* @param {any} nodeIo The nodeIO server for manipulation of sockets
|
||||
* @param {any} interaction The interaction object
|
||||
*/
|
||||
|
||||
export async function autocomplete(nodeIo, interaction) {
|
||||
const focusedValue = interaction.options.getFocused();
|
||||
const choices = (await getAllFeeds()) ?? [];
|
||||
log.INFO("RSS Remove Choices:", choices);
|
||||
const filtered = choices.filter((choice) =>
|
||||
choice.title.startsWith(focusedValue),
|
||||
);
|
||||
log.DEBUG(focusedValue, choices, filtered);
|
||||
await interaction.respond(
|
||||
filtered.map((choice) => ({ name: choice.title, value: choice.title })),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* The function to run when the command is called by a discord user
|
||||
* @param {any} nodeIo The nodeIO server for manipulation of sockets
|
||||
* @param {any} interaction The interaction object
|
||||
*/
|
||||
export const execute = async (nodeIo, interaction) => {
|
||||
try {
|
||||
var title = interaction.options.getString("title");
|
||||
await interaction.reply(
|
||||
`Removing ${title} from the list of RSS sources, please wait...`,
|
||||
);
|
||||
|
||||
const results = await deleteFeedByTitle(title);
|
||||
if (!results) {
|
||||
log.WARN(`Failed to remove source: ${title}`);
|
||||
await interaction.editReply(`Failed to remove source: '${title}'`);
|
||||
return;
|
||||
}
|
||||
await interaction.editReply(
|
||||
`${title} was successfully removed from the RSS sources.`,
|
||||
);
|
||||
} catch (err) {
|
||||
log.ERROR(err);
|
||||
await interaction.editReply(err.toString());
|
||||
}
|
||||
};
|
||||
</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<footer class="footer">
|
||||
<div class="content has-text-centered">
|
||||
<p>Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a></p>
|
||||
<p class="sidebar-created-by">
|
||||
<a href="https://github.com/SoftwareBrothers/better-docs" target="_blank">BetterDocs theme</a> provided with <i class="fas fa-heart"></i> by
|
||||
<a href="http://softwarebrothers.co" target="_blank">SoftwareBrothers - JavaScript Development Agency</a>
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
</div>
|
||||
<div id="side-nav" class="side-nav">
|
||||
</div>
|
||||
</div>
|
||||
<script src="scripts/app.min.js"></script>
|
||||
<script>PR.prettyPrint();</script>
|
||||
<script src="scripts/linenumber.js"> </script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
164
discordBot_commands_rssTrigger.mjs.html
Normal file
164
discordBot_commands_rssTrigger.mjs.html
Normal file
@@ -0,0 +1,164 @@
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title> discordBot/commands/rssTrigger.mjs</title>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js"></script>
|
||||
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
|
||||
<script src="./build/entry.js"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link href="https://fonts.googleapis.com/css?family=Roboto:100,400,700|Inconsolata,700" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
|
||||
<link type="text/css" rel="stylesheet" href="https://jmblog.github.io/color-themes-for-google-code-prettify/themes/tomorrow-night.min.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/app.min.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/iframe.css">
|
||||
<link type="text/css" rel="stylesheet" href="">
|
||||
<script async defer src="https://buttons.github.io/buttons.js"></script>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
|
||||
|
||||
<body class="layout small-header">
|
||||
<div id="stickyNavbarOverlay"></div>
|
||||
|
||||
|
||||
<div class="top-nav">
|
||||
<div class="inner">
|
||||
<a id="hamburger" role="button" class="navbar-burger" aria-label="menu" aria-expanded="false">
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
</a>
|
||||
<div class="logo">
|
||||
|
||||
|
||||
</div>
|
||||
<div class="menu">
|
||||
|
||||
<div class="navigation">
|
||||
<a
|
||||
href="index.html"
|
||||
class="link"
|
||||
>
|
||||
Documentation
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="main">
|
||||
<div
|
||||
class="sidebar "
|
||||
id="sidebarNav"
|
||||
>
|
||||
|
||||
<nav>
|
||||
|
||||
<h2><a href="index.html">Documentation</a></h2><div class="category"><h3>Classes</h3><ul><li><a href="DebugBuilder.html">DebugBuilder</a></li><li><a href="PresenceManager.html">PresenceManager</a></li></ul><h3>Global</h3><ul><li><a href="global.html#addEnabledCommands">addEnabledCommands</a></li><li><a href="global.html#addEnabledEventListeners">addEnabledEventListeners</a></li><li><a href="global.html#autocomplete">autocomplete</a></li><li><a href="global.html#checkIfNodeHasOpenDiscordClient">checkIfNodeHasOpenDiscordClient</a></li><li><a href="global.html#checkIfNodeIsConnectedToVC">checkIfNodeIsConnectedToVC</a></li><li><a href="global.html#execute">execute</a></li><li><a href="global.html#getAllSocketsConnectedToVC">getAllSocketsConnectedToVC</a></li><li><a href="global.html#getAvailableNodes">getAvailableNodes</a></li><li><a href="global.html#getNodeDiscordID">getNodeDiscordID</a></li><li><a href="global.html#getNodeDiscordUsername">getNodeDiscordUsername</a></li><li><a href="global.html#getSocketIdByNuid">getSocketIdByNuid</a></li><li><a href="global.html#getUserVoiceChannel">getUserVoiceChannel</a></li><li><a href="global.html#joinNode">joinNode</a></li><li><a href="global.html#nearbySystemsUpdateWraper">nearbySystemsUpdateWraper</a></li><li><a href="global.html#nodeDisconnectWrapper">nodeDisconnectWrapper</a></li><li><a href="global.html#nodeLoginWrapper">nodeLoginWrapper</a></li><li><a href="global.html#nodeUpdateWrapper">nodeUpdateWrapper</a></li><li><a href="global.html#promptNodeSelection">promptNodeSelection</a></li><li><a href="global.html#refreshActiveCommandsWrapper">refreshActiveCommandsWrapper</a></li><li><a href="global.html#requestBotLeaveServer">requestBotLeaveServer</a></li><li><a href="global.html#requestNodeJoinSystem">requestNodeJoinSystem</a></li><li><a href="global.html#requestNodeUpdate">requestNodeUpdate</a></li><li><a href="global.html#sendNodeCommand">sendNodeCommand</a></li><li><a href="global.html#unregisterAllCommands">unregisterAllCommands</a></li><li><a href="global.html#updateFeeds">updateFeeds</a></li><li><a href="global.html#writeToLog">writeToLog</a></li></ul></div>
|
||||
|
||||
</nav>
|
||||
</div>
|
||||
<div class="core" id="main-content-wrapper">
|
||||
<div class="content">
|
||||
<header class="page-title">
|
||||
<p>Source</p>
|
||||
<h1>discordBot/commands/rssTrigger.mjs</h1>
|
||||
</header>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="prettyprint source linenums"><code>import { DebugBuilder } from "../../modules/debugger.mjs";
|
||||
const log = new DebugBuilder("server", "discordBot.command.rssTrigger");
|
||||
import { SlashCommandBuilder } from "discord.js";
|
||||
import { updateFeeds } from "../../rss-manager/feedHandler.mjs";
|
||||
|
||||
// Exporting data property that contains the command structure for discord including any params
|
||||
export const data = new SlashCommandBuilder()
|
||||
.setName("rss-trigger")
|
||||
.setDescription("Manually triggers an RSS feed update");
|
||||
|
||||
// Exporting other properties
|
||||
export const example = "/rss-trigger"; // An example of how the command would be run in discord chat, this will be used for the help command
|
||||
export const deferInitialReply = false; // If we the initial reply in discord should be deferred. This gives extra time to respond, however the method of replying is different.
|
||||
|
||||
/**
|
||||
* Function to give the user auto-reply suggestions
|
||||
* @param {any} nodeIo The nodeIO server for manipulation of sockets
|
||||
* @param {any} interaction The interaction object
|
||||
*/
|
||||
/*
|
||||
export async function autocomplete(nodeIo, interaction) {
|
||||
const focusedValue = interaction.options.getFocused();
|
||||
const choices = [];
|
||||
const filtered = choices.filter(choice => choice.name.startsWith(focusedValue));
|
||||
log.INFO(focusedValue, choices, filtered);
|
||||
await interaction.respond(filtered);
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* The function to run when the command is called by a discord user
|
||||
* @param {any} nodeIo The nodeIO server for manipulation of sockets
|
||||
* @param {any} interaction The interaction object
|
||||
*/
|
||||
export const execute = async (nodeIo, interaction) => {
|
||||
try {
|
||||
//const sockets = await nodeIo.allSockets();
|
||||
//await interaction.reply(`**Online Sockets: '${sockets}'**`);
|
||||
await interaction.reply("Triggering RSS update");
|
||||
await updateFeeds(interaction.client);
|
||||
await interaction.editReply("RSS Update Completed");
|
||||
//await interaction.channel.send('**Pong.**');
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
// await interaction.reply(err.toString());
|
||||
}
|
||||
};
|
||||
</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<footer class="footer">
|
||||
<div class="content has-text-centered">
|
||||
<p>Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a></p>
|
||||
<p class="sidebar-created-by">
|
||||
<a href="https://github.com/SoftwareBrothers/better-docs" target="_blank">BetterDocs theme</a> provided with <i class="fas fa-heart"></i> by
|
||||
<a href="http://softwarebrothers.co" target="_blank">SoftwareBrothers - JavaScript Development Agency</a>
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
</div>
|
||||
<div id="side-nav" class="side-nav">
|
||||
</div>
|
||||
</div>
|
||||
<script src="scripts/app.min.js"></script>
|
||||
<script>PR.prettyPrint();</script>
|
||||
<script src="scripts/linenumber.js"> </script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
156
discordBot_commands_update.mjs.html
Normal file
156
discordBot_commands_update.mjs.html
Normal file
@@ -0,0 +1,156 @@
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title> discordBot/commands/update.mjs</title>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js"></script>
|
||||
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
|
||||
<script src="./build/entry.js"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link href="https://fonts.googleapis.com/css?family=Roboto:100,400,700|Inconsolata,700" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
|
||||
<link type="text/css" rel="stylesheet" href="https://jmblog.github.io/color-themes-for-google-code-prettify/themes/tomorrow-night.min.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/app.min.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/iframe.css">
|
||||
<link type="text/css" rel="stylesheet" href="">
|
||||
<script async defer src="https://buttons.github.io/buttons.js"></script>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
|
||||
|
||||
<body class="layout small-header">
|
||||
<div id="stickyNavbarOverlay"></div>
|
||||
|
||||
|
||||
<div class="top-nav">
|
||||
<div class="inner">
|
||||
<a id="hamburger" role="button" class="navbar-burger" aria-label="menu" aria-expanded="false">
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
</a>
|
||||
<div class="logo">
|
||||
|
||||
|
||||
</div>
|
||||
<div class="menu">
|
||||
|
||||
<div class="navigation">
|
||||
<a
|
||||
href="index.html"
|
||||
class="link"
|
||||
>
|
||||
Documentation
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="main">
|
||||
<div
|
||||
class="sidebar "
|
||||
id="sidebarNav"
|
||||
>
|
||||
|
||||
<nav>
|
||||
|
||||
<h2><a href="index.html">Documentation</a></h2><div class="category"><h3>Classes</h3><ul><li><a href="DebugBuilder.html">DebugBuilder</a></li><li><a href="PresenceManager.html">PresenceManager</a></li></ul><h3>Global</h3><ul><li><a href="global.html#addEnabledCommands">addEnabledCommands</a></li><li><a href="global.html#addEnabledEventListeners">addEnabledEventListeners</a></li><li><a href="global.html#autocomplete">autocomplete</a></li><li><a href="global.html#checkIfNodeHasOpenDiscordClient">checkIfNodeHasOpenDiscordClient</a></li><li><a href="global.html#checkIfNodeIsConnectedToVC">checkIfNodeIsConnectedToVC</a></li><li><a href="global.html#execute">execute</a></li><li><a href="global.html#getAllSocketsConnectedToVC">getAllSocketsConnectedToVC</a></li><li><a href="global.html#getAvailableNodes">getAvailableNodes</a></li><li><a href="global.html#getNodeDiscordID">getNodeDiscordID</a></li><li><a href="global.html#getNodeDiscordUsername">getNodeDiscordUsername</a></li><li><a href="global.html#getSocketIdByNuid">getSocketIdByNuid</a></li><li><a href="global.html#getUserVoiceChannel">getUserVoiceChannel</a></li><li><a href="global.html#joinNode">joinNode</a></li><li><a href="global.html#nearbySystemsUpdateWraper">nearbySystemsUpdateWraper</a></li><li><a href="global.html#nodeDisconnectWrapper">nodeDisconnectWrapper</a></li><li><a href="global.html#nodeLoginWrapper">nodeLoginWrapper</a></li><li><a href="global.html#nodeUpdateWrapper">nodeUpdateWrapper</a></li><li><a href="global.html#promptNodeSelection">promptNodeSelection</a></li><li><a href="global.html#refreshActiveCommandsWrapper">refreshActiveCommandsWrapper</a></li><li><a href="global.html#requestBotLeaveServer">requestBotLeaveServer</a></li><li><a href="global.html#requestNodeJoinSystem">requestNodeJoinSystem</a></li><li><a href="global.html#requestNodeUpdate">requestNodeUpdate</a></li><li><a href="global.html#sendNodeCommand">sendNodeCommand</a></li><li><a href="global.html#unregisterAllCommands">unregisterAllCommands</a></li><li><a href="global.html#updateFeeds">updateFeeds</a></li><li><a href="global.html#writeToLog">writeToLog</a></li></ul></div>
|
||||
|
||||
</nav>
|
||||
</div>
|
||||
<div class="core" id="main-content-wrapper">
|
||||
<div class="content">
|
||||
<header class="page-title">
|
||||
<p>Source</p>
|
||||
<h1>discordBot/commands/update.mjs</h1>
|
||||
</header>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="prettyprint source linenums"><code>import { DebugBuilder } from "../../modules/debugger.mjs";
|
||||
const log = new DebugBuilder("server", "discordBot.command.update");
|
||||
import { SlashCommandBuilder } from "discord.js";
|
||||
import { requestNodeUpdate } from "../../modules/socketServerWrappers.mjs";
|
||||
|
||||
// Exporting data property that contains the command structure for discord including any params
|
||||
export const data = new SlashCommandBuilder()
|
||||
.setName("update")
|
||||
.setDescription("Updates all nodes currently logged on");
|
||||
|
||||
// Exporting other properties
|
||||
export const example = "/update"; // An example of how the command would be run in discord chat, this will be used for the help command
|
||||
export const deferInitialReply = false; // If we the initial reply in discord should be deferred. This gives extra time to respond, however the method of replying is different.
|
||||
|
||||
/**
|
||||
* The function to run when the command is called by a discord user
|
||||
* @param {any} nodeIo The nodeIO server for manipulation of sockets
|
||||
* @param {any} interaction The interaction object
|
||||
*/
|
||||
export const execute = async (nodeIo, interaction) => {
|
||||
try {
|
||||
const openSockets = [...(await nodeIo.allSockets())]; // TODO - Filter the returned nodes to only nodes that have the radio capability
|
||||
log.DEBUG("All open sockets: ", openSockets);
|
||||
|
||||
// Check each open socket to see if the node has the requested system
|
||||
await Promise.all(
|
||||
openSockets.map((openSocket) => {
|
||||
openSocket = nodeIo.sockets.sockets.get(openSocket);
|
||||
requestNodeUpdate(openSocket);
|
||||
}),
|
||||
);
|
||||
//await interaction.reply(`**Online Sockets: '${sockets}'**`);
|
||||
await interaction.reply("All nodes have been requested to update");
|
||||
//await interaction.channel.send('**Pong.**');
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
// await interaction.reply(err.toString());
|
||||
}
|
||||
};
|
||||
</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<footer class="footer">
|
||||
<div class="content has-text-centered">
|
||||
<p>Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a></p>
|
||||
<p class="sidebar-created-by">
|
||||
<a href="https://github.com/SoftwareBrothers/better-docs" target="_blank">BetterDocs theme</a> provided with <i class="fas fa-heart"></i> by
|
||||
<a href="http://softwarebrothers.co" target="_blank">SoftwareBrothers - JavaScript Development Agency</a>
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
</div>
|
||||
<div id="side-nav" class="side-nav">
|
||||
</div>
|
||||
</div>
|
||||
<script src="scripts/app.min.js"></script>
|
||||
<script>PR.prettyPrint();</script>
|
||||
<script src="scripts/linenumber.js"> </script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
247
discordBot_discordBot.mjs.html
Normal file
247
discordBot_discordBot.mjs.html
Normal file
@@ -0,0 +1,247 @@
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title> discordBot/discordBot.mjs</title>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js"></script>
|
||||
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
|
||||
<script src="./build/entry.js"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link href="https://fonts.googleapis.com/css?family=Roboto:100,400,700|Inconsolata,700" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
|
||||
<link type="text/css" rel="stylesheet" href="https://jmblog.github.io/color-themes-for-google-code-prettify/themes/tomorrow-night.min.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/app.min.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/iframe.css">
|
||||
<link type="text/css" rel="stylesheet" href="">
|
||||
<script async defer src="https://buttons.github.io/buttons.js"></script>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
|
||||
|
||||
<body class="layout small-header">
|
||||
<div id="stickyNavbarOverlay"></div>
|
||||
|
||||
|
||||
<div class="top-nav">
|
||||
<div class="inner">
|
||||
<a id="hamburger" role="button" class="navbar-burger" aria-label="menu" aria-expanded="false">
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
</a>
|
||||
<div class="logo">
|
||||
|
||||
|
||||
</div>
|
||||
<div class="menu">
|
||||
|
||||
<div class="navigation">
|
||||
<a
|
||||
href="index.html"
|
||||
class="link"
|
||||
>
|
||||
Documentation
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="main">
|
||||
<div
|
||||
class="sidebar "
|
||||
id="sidebarNav"
|
||||
>
|
||||
|
||||
<nav>
|
||||
|
||||
<h2><a href="index.html">Documentation</a></h2><div class="category"><h3>Classes</h3><ul><li><a href="DebugBuilder.html">DebugBuilder</a></li><li><a href="PresenceManager.html">PresenceManager</a></li></ul><h3>Global</h3><ul><li><a href="global.html#addEnabledCommands">addEnabledCommands</a></li><li><a href="global.html#addEnabledEventListeners">addEnabledEventListeners</a></li><li><a href="global.html#autocomplete">autocomplete</a></li><li><a href="global.html#checkIfNodeHasOpenDiscordClient">checkIfNodeHasOpenDiscordClient</a></li><li><a href="global.html#checkIfNodeIsConnectedToVC">checkIfNodeIsConnectedToVC</a></li><li><a href="global.html#execute">execute</a></li><li><a href="global.html#getAllSocketsConnectedToVC">getAllSocketsConnectedToVC</a></li><li><a href="global.html#getAvailableNodes">getAvailableNodes</a></li><li><a href="global.html#getNodeDiscordID">getNodeDiscordID</a></li><li><a href="global.html#getNodeDiscordUsername">getNodeDiscordUsername</a></li><li><a href="global.html#getSocketIdByNuid">getSocketIdByNuid</a></li><li><a href="global.html#getUserVoiceChannel">getUserVoiceChannel</a></li><li><a href="global.html#joinNode">joinNode</a></li><li><a href="global.html#nearbySystemsUpdateWraper">nearbySystemsUpdateWraper</a></li><li><a href="global.html#nodeDisconnectWrapper">nodeDisconnectWrapper</a></li><li><a href="global.html#nodeLoginWrapper">nodeLoginWrapper</a></li><li><a href="global.html#nodeUpdateWrapper">nodeUpdateWrapper</a></li><li><a href="global.html#promptNodeSelection">promptNodeSelection</a></li><li><a href="global.html#refreshActiveCommandsWrapper">refreshActiveCommandsWrapper</a></li><li><a href="global.html#requestBotLeaveServer">requestBotLeaveServer</a></li><li><a href="global.html#requestNodeJoinSystem">requestNodeJoinSystem</a></li><li><a href="global.html#requestNodeUpdate">requestNodeUpdate</a></li><li><a href="global.html#sendNodeCommand">sendNodeCommand</a></li><li><a href="global.html#unregisterAllCommands">unregisterAllCommands</a></li><li><a href="global.html#updateFeeds">updateFeeds</a></li><li><a href="global.html#writeToLog">writeToLog</a></li></ul></div>
|
||||
|
||||
</nav>
|
||||
</div>
|
||||
<div class="core" id="main-content-wrapper">
|
||||
<div class="content">
|
||||
<header class="page-title">
|
||||
<p>Source</p>
|
||||
<h1>discordBot/discordBot.mjs</h1>
|
||||
</header>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="prettyprint source linenums"><code>import { DebugBuilder } from "../modules/debugger.mjs";
|
||||
import { Client, GatewayIntentBits, Collection } from "discord.js";
|
||||
import { registerActiveCommands } from "./modules/registerCommands.mjs";
|
||||
import { RSSController } from "../rss-manager/rssController.mjs";
|
||||
import { join, dirname } from "path";
|
||||
import { readdirSync } from "fs";
|
||||
import { fileURLToPath } from "url";
|
||||
import PresenceManager from "./modules/presenceManager.mjs";
|
||||
|
||||
import dotenv from "dotenv";
|
||||
dotenv.config();
|
||||
|
||||
const log = new DebugBuilder("server", "discordBot");
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
|
||||
/**
|
||||
* Add the enabled commands to the bot to be used by users in discord
|
||||
* (commands that end in '.mjs' will be enabled, to disable just remove the extension or replace with '.mjs.disabled')
|
||||
* @param {any} serverClient
|
||||
* @param {any} _commandsPath="./commands"
|
||||
* @returns {any}
|
||||
*/
|
||||
export const addEnabledCommands = async (
|
||||
serverClient,
|
||||
_commandsPath = "./commands",
|
||||
) => {
|
||||
// Setup commands for the Discord bot
|
||||
serverClient.commands = new Collection();
|
||||
const commandsPath = join(__dirname, _commandsPath);
|
||||
const commandFiles = readdirSync(commandsPath).filter((file) =>
|
||||
file.endsWith(".mjs"),
|
||||
);
|
||||
|
||||
for (const file of commandFiles) {
|
||||
const filePath = await join(commandsPath, file);
|
||||
log.INFO(`Adding enabled command: ${filePath}`);
|
||||
await import(`file://${filePath}`).then((command) => {
|
||||
if (command.data instanceof Promise) {
|
||||
command.data.then(async (builder) => {
|
||||
command.data = builder;
|
||||
log.DEBUG("Importing command: ", command.data.name, command);
|
||||
// Set a new item in the Collection
|
||||
// With the key as the command name and the value as the exported module
|
||||
serverClient.commands.set(command.data.name, command);
|
||||
});
|
||||
} else {
|
||||
log.DEBUG("Importing command: ", command.data.name, command);
|
||||
// Set a new item in the Collection
|
||||
// With the key as the command name and the value as the exported module
|
||||
serverClient.commands.set(command.data.name, command);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Register the commands currently in use by the bot
|
||||
await registerActiveCommands(serverClient);
|
||||
};
|
||||
|
||||
/**
|
||||
* Add the enabled event listeners to the bot
|
||||
* (events that end in '.mjs' will be enabled, to disable just remove the extension or replace with '.mjs.disabled')
|
||||
* @param {any} serverClient
|
||||
* @param {any} _eventsPath="./events"
|
||||
* @returns {any}
|
||||
*/
|
||||
export function addEnabledEventListeners(
|
||||
serverClient,
|
||||
_eventsPath = "./events",
|
||||
) {
|
||||
const eventsPath = join(__dirname, _eventsPath);
|
||||
const eventFiles = readdirSync(eventsPath).filter((file) =>
|
||||
file.endsWith(".mjs"),
|
||||
);
|
||||
|
||||
for (const file of eventFiles) {
|
||||
const filePath = join(eventsPath, file);
|
||||
log.INFO(`Adding enabled event listener: ${filePath}`);
|
||||
import(`file://${filePath}`).then((event) => {
|
||||
log.DEBUG("Adding event: ", event);
|
||||
if (event.once) {
|
||||
serverClient.once(event.name, (...args) =>
|
||||
event.execute(serverClient.nodeIo, ...args),
|
||||
);
|
||||
} else {
|
||||
serverClient.on(event.name, (...args) =>
|
||||
event.execute(serverClient.nodeIo, ...args),
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// The discord client
|
||||
export const serverClient = new Client({
|
||||
intents: [
|
||||
GatewayIntentBits.Guilds,
|
||||
GatewayIntentBits.GuildVoiceStates,
|
||||
GatewayIntentBits.GuildMessages,
|
||||
GatewayIntentBits.MessageContent,
|
||||
GatewayIntentBits.GuildMembers,
|
||||
GatewayIntentBits.GuildPresences,
|
||||
],
|
||||
});
|
||||
|
||||
// Run when the bot is ready
|
||||
serverClient.on("ready", async () => {
|
||||
log.INFO(`Logged in as ${serverClient.user.tag}!`);
|
||||
|
||||
// Set the presence to default
|
||||
const pm = new PresenceManager(serverClient);
|
||||
await pm.resetToDefault();
|
||||
|
||||
// Add and register commands
|
||||
await addEnabledCommands(serverClient);
|
||||
|
||||
// Config the discord bot with events
|
||||
await addEnabledEventListeners(serverClient);
|
||||
|
||||
// Start the RSS Controller
|
||||
serverClient.RSSController = await new RSSController(serverClient);
|
||||
serverClient.RSSController.start();
|
||||
|
||||
log.INFO("RSS Controller:", serverClient.RSSController);
|
||||
});
|
||||
|
||||
// Startup the discord bot
|
||||
log.INFO(`Logging into discord with ID: ${process.env.DISCORD_TOKEN}`);
|
||||
serverClient.login(process.env.DISCORD_TOKEN);
|
||||
</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<footer class="footer">
|
||||
<div class="content has-text-centered">
|
||||
<p>Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a></p>
|
||||
<p class="sidebar-created-by">
|
||||
<a href="https://github.com/SoftwareBrothers/better-docs" target="_blank">BetterDocs theme</a> provided with <i class="fas fa-heart"></i> by
|
||||
<a href="http://softwarebrothers.co" target="_blank">SoftwareBrothers - JavaScript Development Agency</a>
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
</div>
|
||||
<div id="side-nav" class="side-nav">
|
||||
</div>
|
||||
</div>
|
||||
<script src="scripts/app.min.js"></script>
|
||||
<script>PR.prettyPrint();</script>
|
||||
<script src="scripts/linenumber.js"> </script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
229
discordBot_modules_presenceManager.mjs.html
Normal file
229
discordBot_modules_presenceManager.mjs.html
Normal file
@@ -0,0 +1,229 @@
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title> discordBot/modules/presenceManager.mjs</title>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js"></script>
|
||||
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
|
||||
<script src="./build/entry.js"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link href="https://fonts.googleapis.com/css?family=Roboto:100,400,700|Inconsolata,700" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
|
||||
<link type="text/css" rel="stylesheet" href="https://jmblog.github.io/color-themes-for-google-code-prettify/themes/tomorrow-night.min.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/app.min.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/iframe.css">
|
||||
<link type="text/css" rel="stylesheet" href="">
|
||||
<script async defer src="https://buttons.github.io/buttons.js"></script>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
|
||||
|
||||
<body class="layout small-header">
|
||||
<div id="stickyNavbarOverlay"></div>
|
||||
|
||||
|
||||
<div class="top-nav">
|
||||
<div class="inner">
|
||||
<a id="hamburger" role="button" class="navbar-burger" aria-label="menu" aria-expanded="false">
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
</a>
|
||||
<div class="logo">
|
||||
|
||||
|
||||
</div>
|
||||
<div class="menu">
|
||||
|
||||
<div class="navigation">
|
||||
<a
|
||||
href="index.html"
|
||||
class="link"
|
||||
>
|
||||
Documentation
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="main">
|
||||
<div
|
||||
class="sidebar "
|
||||
id="sidebarNav"
|
||||
>
|
||||
|
||||
<nav>
|
||||
|
||||
<h2><a href="index.html">Documentation</a></h2><div class="category"><h3>Classes</h3><ul><li><a href="DebugBuilder.html">DebugBuilder</a></li><li><a href="PresenceManager.html">PresenceManager</a></li></ul><h3>Global</h3><ul><li><a href="global.html#addEnabledCommands">addEnabledCommands</a></li><li><a href="global.html#addEnabledEventListeners">addEnabledEventListeners</a></li><li><a href="global.html#autocomplete">autocomplete</a></li><li><a href="global.html#checkIfNodeHasOpenDiscordClient">checkIfNodeHasOpenDiscordClient</a></li><li><a href="global.html#checkIfNodeIsConnectedToVC">checkIfNodeIsConnectedToVC</a></li><li><a href="global.html#execute">execute</a></li><li><a href="global.html#getAllSocketsConnectedToVC">getAllSocketsConnectedToVC</a></li><li><a href="global.html#getAvailableNodes">getAvailableNodes</a></li><li><a href="global.html#getNodeDiscordID">getNodeDiscordID</a></li><li><a href="global.html#getNodeDiscordUsername">getNodeDiscordUsername</a></li><li><a href="global.html#getSocketIdByNuid">getSocketIdByNuid</a></li><li><a href="global.html#getUserVoiceChannel">getUserVoiceChannel</a></li><li><a href="global.html#joinNode">joinNode</a></li><li><a href="global.html#nearbySystemsUpdateWraper">nearbySystemsUpdateWraper</a></li><li><a href="global.html#nodeDisconnectWrapper">nodeDisconnectWrapper</a></li><li><a href="global.html#nodeLoginWrapper">nodeLoginWrapper</a></li><li><a href="global.html#nodeUpdateWrapper">nodeUpdateWrapper</a></li><li><a href="global.html#promptNodeSelection">promptNodeSelection</a></li><li><a href="global.html#refreshActiveCommandsWrapper">refreshActiveCommandsWrapper</a></li><li><a href="global.html#requestBotLeaveServer">requestBotLeaveServer</a></li><li><a href="global.html#requestNodeJoinSystem">requestNodeJoinSystem</a></li><li><a href="global.html#requestNodeUpdate">requestNodeUpdate</a></li><li><a href="global.html#sendNodeCommand">sendNodeCommand</a></li><li><a href="global.html#unregisterAllCommands">unregisterAllCommands</a></li><li><a href="global.html#updateFeeds">updateFeeds</a></li><li><a href="global.html#writeToLog">writeToLog</a></li></ul></div>
|
||||
|
||||
</nav>
|
||||
</div>
|
||||
<div class="core" id="main-content-wrapper">
|
||||
<div class="content">
|
||||
<header class="page-title">
|
||||
<p>Source</p>
|
||||
<h1>discordBot/modules/presenceManager.mjs</h1>
|
||||
</header>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="prettyprint source linenums"><code>import {
|
||||
getConfig,
|
||||
setConfig,
|
||||
} from "../../modules/mongo-wrappers/mongoConfigWrappers.mjs";
|
||||
import { ActivityType, PresenceUpdateStatus, Client } from "discord.js";
|
||||
|
||||
class PresenceManager {
|
||||
/**
|
||||
* Creates an instance of PresenceManager.
|
||||
* @param {Client} client - The Discord client instance.
|
||||
*/
|
||||
constructor(client) {
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the bot's presence.
|
||||
* @param {"online"|"idle"|"dnd"} status - The status of the bot (online, idle, dnd).
|
||||
* @param {"PLAYING"|"STREAMING"|"LISTENING"|"WATCHING"|"COMPETING"} activityType - The type of activity.
|
||||
* @param {string} activityName - The name of the activity.
|
||||
* @param {string} [url=null] - The URL for STREAMING activity type (optional).
|
||||
*/
|
||||
async setPresence(status, activityType, activityName, url = null) {
|
||||
const activityOptions = {
|
||||
type: this.convertActivityType(activityType),
|
||||
name: activityName,
|
||||
};
|
||||
|
||||
if (activityType.toUpperCase() === "STREAMING" && url) {
|
||||
activityOptions.url = url;
|
||||
}
|
||||
|
||||
await this.client.user.setPresence({
|
||||
status: this.convertStatus(status),
|
||||
activities: [activityOptions],
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the bot's presence to the default state.
|
||||
*/
|
||||
async resetToDefault() {
|
||||
let defaultPresence = await getConfig("presence");
|
||||
|
||||
if (!defaultPresence) {
|
||||
defaultPresence = {
|
||||
status: "idle",
|
||||
activities: [
|
||||
{
|
||||
name: "your commands",
|
||||
type: "LISTENING",
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
await setConfig("presence", defaultPresence);
|
||||
}
|
||||
|
||||
console.log("Default Presence:", defaultPresence);
|
||||
|
||||
// Update your bot's presence using this configuration
|
||||
await this.setPresence(
|
||||
defaultPresence.status,
|
||||
defaultPresence.activities[0].type,
|
||||
defaultPresence.activities[0].name,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a string activity type to the corresponding ActivityType enum.
|
||||
* @param {string} activityType - The activity type string.
|
||||
* @returns {ActivityType} - The corresponding ActivityType enum.
|
||||
*/
|
||||
convertActivityType(activityType) {
|
||||
switch (activityType.toUpperCase()) {
|
||||
case "PLAYING":
|
||||
return ActivityType.Playing;
|
||||
case "STREAMING":
|
||||
return ActivityType.Streaming;
|
||||
case "LISTENING":
|
||||
return ActivityType.Listening;
|
||||
case "WATCHING":
|
||||
return ActivityType.Watching;
|
||||
case "COMPETING":
|
||||
return ActivityType.Competing;
|
||||
default:
|
||||
throw new Error("Invalid activity type");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a string status to the corresponding PresenceUpdateStatus enum.
|
||||
* @param {string} status - The status string.
|
||||
* @returns {PresenceUpdateStatus} - The corresponding PresenceUpdateStatus enum.
|
||||
*/
|
||||
convertStatus(status) {
|
||||
switch (status.toLowerCase()) {
|
||||
case "online":
|
||||
return PresenceUpdateStatus.Online;
|
||||
case "idle":
|
||||
return PresenceUpdateStatus.Idle;
|
||||
case "dnd":
|
||||
return PresenceUpdateStatus.DoNotDisturb;
|
||||
case "invisible":
|
||||
return PresenceUpdateStatus.Invisible;
|
||||
default:
|
||||
throw new Error("Invalid status");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default PresenceManager;
|
||||
</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<footer class="footer">
|
||||
<div class="content has-text-centered">
|
||||
<p>Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a></p>
|
||||
<p class="sidebar-created-by">
|
||||
<a href="https://github.com/SoftwareBrothers/better-docs" target="_blank">BetterDocs theme</a> provided with <i class="fas fa-heart"></i> by
|
||||
<a href="http://softwarebrothers.co" target="_blank">SoftwareBrothers - JavaScript Development Agency</a>
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
</div>
|
||||
<div id="side-nav" class="side-nav">
|
||||
</div>
|
||||
</div>
|
||||
<script src="scripts/app.min.js"></script>
|
||||
<script>PR.prettyPrint();</script>
|
||||
<script src="scripts/linenumber.js"> </script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
223
discordBot_modules_registerCommands.mjs.html
Normal file
223
discordBot_modules_registerCommands.mjs.html
Normal file
@@ -0,0 +1,223 @@
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title> discordBot/modules/registerCommands.mjs</title>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js"></script>
|
||||
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
|
||||
<script src="./build/entry.js"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link href="https://fonts.googleapis.com/css?family=Roboto:100,400,700|Inconsolata,700" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
|
||||
<link type="text/css" rel="stylesheet" href="https://jmblog.github.io/color-themes-for-google-code-prettify/themes/tomorrow-night.min.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/app.min.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/iframe.css">
|
||||
<link type="text/css" rel="stylesheet" href="">
|
||||
<script async defer src="https://buttons.github.io/buttons.js"></script>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
|
||||
|
||||
<body class="layout small-header">
|
||||
<div id="stickyNavbarOverlay"></div>
|
||||
|
||||
|
||||
<div class="top-nav">
|
||||
<div class="inner">
|
||||
<a id="hamburger" role="button" class="navbar-burger" aria-label="menu" aria-expanded="false">
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
</a>
|
||||
<div class="logo">
|
||||
|
||||
|
||||
</div>
|
||||
<div class="menu">
|
||||
|
||||
<div class="navigation">
|
||||
<a
|
||||
href="index.html"
|
||||
class="link"
|
||||
>
|
||||
Documentation
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="main">
|
||||
<div
|
||||
class="sidebar "
|
||||
id="sidebarNav"
|
||||
>
|
||||
|
||||
<nav>
|
||||
|
||||
<h2><a href="index.html">Documentation</a></h2><div class="category"><h3>Classes</h3><ul><li><a href="DebugBuilder.html">DebugBuilder</a></li><li><a href="PresenceManager.html">PresenceManager</a></li></ul><h3>Global</h3><ul><li><a href="global.html#addEnabledCommands">addEnabledCommands</a></li><li><a href="global.html#addEnabledEventListeners">addEnabledEventListeners</a></li><li><a href="global.html#autocomplete">autocomplete</a></li><li><a href="global.html#checkIfNodeHasOpenDiscordClient">checkIfNodeHasOpenDiscordClient</a></li><li><a href="global.html#checkIfNodeIsConnectedToVC">checkIfNodeIsConnectedToVC</a></li><li><a href="global.html#execute">execute</a></li><li><a href="global.html#getAllSocketsConnectedToVC">getAllSocketsConnectedToVC</a></li><li><a href="global.html#getAvailableNodes">getAvailableNodes</a></li><li><a href="global.html#getNodeDiscordID">getNodeDiscordID</a></li><li><a href="global.html#getNodeDiscordUsername">getNodeDiscordUsername</a></li><li><a href="global.html#getSocketIdByNuid">getSocketIdByNuid</a></li><li><a href="global.html#getUserVoiceChannel">getUserVoiceChannel</a></li><li><a href="global.html#joinNode">joinNode</a></li><li><a href="global.html#nearbySystemsUpdateWraper">nearbySystemsUpdateWraper</a></li><li><a href="global.html#nodeDisconnectWrapper">nodeDisconnectWrapper</a></li><li><a href="global.html#nodeLoginWrapper">nodeLoginWrapper</a></li><li><a href="global.html#nodeUpdateWrapper">nodeUpdateWrapper</a></li><li><a href="global.html#promptNodeSelection">promptNodeSelection</a></li><li><a href="global.html#refreshActiveCommandsWrapper">refreshActiveCommandsWrapper</a></li><li><a href="global.html#requestBotLeaveServer">requestBotLeaveServer</a></li><li><a href="global.html#requestNodeJoinSystem">requestNodeJoinSystem</a></li><li><a href="global.html#requestNodeUpdate">requestNodeUpdate</a></li><li><a href="global.html#sendNodeCommand">sendNodeCommand</a></li><li><a href="global.html#unregisterAllCommands">unregisterAllCommands</a></li><li><a href="global.html#updateFeeds">updateFeeds</a></li><li><a href="global.html#writeToLog">writeToLog</a></li></ul></div>
|
||||
|
||||
</nav>
|
||||
</div>
|
||||
<div class="core" id="main-content-wrapper">
|
||||
<div class="content">
|
||||
<header class="page-title">
|
||||
<p>Source</p>
|
||||
<h1>discordBot/modules/registerCommands.mjs</h1>
|
||||
</header>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="prettyprint source linenums"><code>import { DebugBuilder } from "../../modules/debugger.mjs";
|
||||
const log = new DebugBuilder("server", "discordBot.modules.registerCommands");
|
||||
import { REST, Routes } from "discord.js";
|
||||
|
||||
import dotenv from "dotenv";
|
||||
dotenv.config();
|
||||
|
||||
const discordToken = process.env.DISCORD_TOKEN;
|
||||
|
||||
export const registerActiveCommands = async (serverClient) => {
|
||||
const guildIDs = serverClient.guilds.cache;
|
||||
const clientId = serverClient.user.id;
|
||||
const commands = await serverClient.commands.map(
|
||||
(command) => (command = command.data.toJSON()),
|
||||
);
|
||||
|
||||
// Construct and prepare an instance of the REST module
|
||||
const rest = new REST({ version: "10" }).setToken(discordToken);
|
||||
|
||||
// and deploy your commands!
|
||||
guildIDs.forEach((guild) => {
|
||||
log.INFO("Deploying commands for: ", guild.id);
|
||||
log.DEBUG("Commands", commands);
|
||||
(async () => {
|
||||
try {
|
||||
log.DEBUG(
|
||||
`Started refreshing application (/) commands for guild ID: ${guild.id}.`,
|
||||
);
|
||||
// The put method is used to fully refresh all commands in the guild with the current set
|
||||
const data = await rest.put(
|
||||
Routes.applicationGuildCommands(clientId, guild.id),
|
||||
{ body: commands },
|
||||
);
|
||||
|
||||
log.DEBUG(
|
||||
`Successfully reloaded ${data.length} application (/) commands for guild ID: ${guild.id}.`,
|
||||
);
|
||||
} catch (error) {
|
||||
// And of course, make sure you catch and log any errors!
|
||||
log.ERROR(
|
||||
"ERROR Deploying commands: ",
|
||||
error,
|
||||
"Body from error: ",
|
||||
commands,
|
||||
);
|
||||
}
|
||||
})();
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Remove all commands for a given bot in a given guild
|
||||
*
|
||||
* @param {any} serverClient The discord bot client
|
||||
*/
|
||||
export const unregisterAllCommands = async (serverClient) => {
|
||||
const guildIDs = serverClient.guilds.cache;
|
||||
const clientId = serverClient.user.id;
|
||||
commands = [];
|
||||
|
||||
const rest = new REST({ version: "10" }).setToken(discordToken);
|
||||
guildIDs.forEach((guild) => {
|
||||
log.INFO("Removing commands for: ", clientId, guild.id);
|
||||
(async () => {
|
||||
try {
|
||||
log.DEBUG(
|
||||
`Started removal of ${commands.length} application (/) commands for guild ID: ${guild.id}.`,
|
||||
);
|
||||
// The put method is used to fully refresh all commands in the guild with the current set
|
||||
const data = await rest.put(
|
||||
Routes.applicationGuildCommands(clientId, guild.id),
|
||||
{ body: commands },
|
||||
);
|
||||
|
||||
log.DEBUG(
|
||||
`Successfully removed ${data.length} application (/) commands for guild ID: ${guild.id}.`,
|
||||
);
|
||||
} catch (error) {
|
||||
// And of course, make sure you catch and log any errors!
|
||||
log.ERROR(
|
||||
"ERROR removing commands: ",
|
||||
error,
|
||||
"Body from error: ",
|
||||
commands,
|
||||
);
|
||||
}
|
||||
})();
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* This named wrapper will remove all commands and then re-add the commands back, effectively refreshing them
|
||||
* @param {any} serverClient The discord bot client object
|
||||
* @returns {any}
|
||||
*/
|
||||
export const refreshActiveCommandsWrapper = async (serverClient) => {
|
||||
// Remove all commands
|
||||
log.INFO(
|
||||
"Removing/Unregistering all commands from all connected servers/guilds",
|
||||
);
|
||||
await unregisterAllCommands(serverClient);
|
||||
// Deploy the active commands
|
||||
log.INFO("Adding commands to all connected servers/guilds");
|
||||
await registerActiveCommands(serverClient);
|
||||
return;
|
||||
};
|
||||
</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<footer class="footer">
|
||||
<div class="content has-text-centered">
|
||||
<p>Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a></p>
|
||||
<p class="sidebar-created-by">
|
||||
<a href="https://github.com/SoftwareBrothers/better-docs" target="_blank">BetterDocs theme</a> provided with <i class="fas fa-heart"></i> by
|
||||
<a href="http://softwarebrothers.co" target="_blank">SoftwareBrothers - JavaScript Development Agency</a>
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
</div>
|
||||
<div id="side-nav" class="side-nav">
|
||||
</div>
|
||||
</div>
|
||||
<script src="scripts/app.min.js"></script>
|
||||
<script>PR.prettyPrint();</script>
|
||||
<script src="scripts/linenumber.js"> </script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
356
discordBot_modules_wrappers.mjs.html
Normal file
356
discordBot_modules_wrappers.mjs.html
Normal file
@@ -0,0 +1,356 @@
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title> discordBot/modules/wrappers.mjs</title>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js"></script>
|
||||
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
|
||||
<script src="./build/entry.js"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link href="https://fonts.googleapis.com/css?family=Roboto:100,400,700|Inconsolata,700" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
|
||||
<link type="text/css" rel="stylesheet" href="https://jmblog.github.io/color-themes-for-google-code-prettify/themes/tomorrow-night.min.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/app.min.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/iframe.css">
|
||||
<link type="text/css" rel="stylesheet" href="">
|
||||
<script async defer src="https://buttons.github.io/buttons.js"></script>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
|
||||
|
||||
<body class="layout small-header">
|
||||
<div id="stickyNavbarOverlay"></div>
|
||||
|
||||
|
||||
<div class="top-nav">
|
||||
<div class="inner">
|
||||
<a id="hamburger" role="button" class="navbar-burger" aria-label="menu" aria-expanded="false">
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
</a>
|
||||
<div class="logo">
|
||||
|
||||
|
||||
</div>
|
||||
<div class="menu">
|
||||
|
||||
<div class="navigation">
|
||||
<a
|
||||
href="index.html"
|
||||
class="link"
|
||||
>
|
||||
Documentation
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="main">
|
||||
<div
|
||||
class="sidebar "
|
||||
id="sidebarNav"
|
||||
>
|
||||
|
||||
<nav>
|
||||
|
||||
<h2><a href="index.html">Documentation</a></h2><div class="category"><h3>Classes</h3><ul><li><a href="DebugBuilder.html">DebugBuilder</a></li><li><a href="PresenceManager.html">PresenceManager</a></li></ul><h3>Global</h3><ul><li><a href="global.html#addEnabledCommands">addEnabledCommands</a></li><li><a href="global.html#addEnabledEventListeners">addEnabledEventListeners</a></li><li><a href="global.html#autocomplete">autocomplete</a></li><li><a href="global.html#checkIfNodeHasOpenDiscordClient">checkIfNodeHasOpenDiscordClient</a></li><li><a href="global.html#checkIfNodeIsConnectedToVC">checkIfNodeIsConnectedToVC</a></li><li><a href="global.html#execute">execute</a></li><li><a href="global.html#getAllSocketsConnectedToVC">getAllSocketsConnectedToVC</a></li><li><a href="global.html#getAvailableNodes">getAvailableNodes</a></li><li><a href="global.html#getNodeDiscordID">getNodeDiscordID</a></li><li><a href="global.html#getNodeDiscordUsername">getNodeDiscordUsername</a></li><li><a href="global.html#getSocketIdByNuid">getSocketIdByNuid</a></li><li><a href="global.html#getUserVoiceChannel">getUserVoiceChannel</a></li><li><a href="global.html#joinNode">joinNode</a></li><li><a href="global.html#nearbySystemsUpdateWraper">nearbySystemsUpdateWraper</a></li><li><a href="global.html#nodeDisconnectWrapper">nodeDisconnectWrapper</a></li><li><a href="global.html#nodeLoginWrapper">nodeLoginWrapper</a></li><li><a href="global.html#nodeUpdateWrapper">nodeUpdateWrapper</a></li><li><a href="global.html#promptNodeSelection">promptNodeSelection</a></li><li><a href="global.html#refreshActiveCommandsWrapper">refreshActiveCommandsWrapper</a></li><li><a href="global.html#requestBotLeaveServer">requestBotLeaveServer</a></li><li><a href="global.html#requestNodeJoinSystem">requestNodeJoinSystem</a></li><li><a href="global.html#requestNodeUpdate">requestNodeUpdate</a></li><li><a href="global.html#sendNodeCommand">sendNodeCommand</a></li><li><a href="global.html#unregisterAllCommands">unregisterAllCommands</a></li><li><a href="global.html#updateFeeds">updateFeeds</a></li><li><a href="global.html#writeToLog">writeToLog</a></li></ul></div>
|
||||
|
||||
</nav>
|
||||
</div>
|
||||
<div class="core" id="main-content-wrapper">
|
||||
<div class="content">
|
||||
<header class="page-title">
|
||||
<p>Source</p>
|
||||
<h1>discordBot/modules/wrappers.mjs</h1>
|
||||
</header>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="prettyprint source linenums"><code>import { DebugBuilder } from "../../modules/debugger.mjs";
|
||||
const log = new DebugBuilder("server", "discordBot.modules.wrappers");
|
||||
import {
|
||||
checkIfNodeIsConnectedToVC,
|
||||
getNodeDiscordID,
|
||||
getNodeDiscordUsername,
|
||||
checkIfNodeHasOpenDiscordClient,
|
||||
getNodeCurrentListeningSystem,
|
||||
requestNodeJoinSystem,
|
||||
} from "../../modules/socketServerWrappers.mjs";
|
||||
import { getAllDiscordIDs } from "../../modules/mongo-wrappers/mongoDiscordIDWrappers.mjs";
|
||||
import { ActionRowBuilder, ButtonBuilder, ButtonStyle } from "discord.js";
|
||||
|
||||
export const checkOnlineBotsInGuild = async (nodeIo, guildId) => {
|
||||
let onlineBots = [];
|
||||
const openSockets = [...(await nodeIo.allSockets())];
|
||||
await Promise.all(
|
||||
openSockets.map(async (openSocket) => {
|
||||
openSocket = await nodeIo.sockets.sockets.get(openSocket);
|
||||
const connected = await checkIfNodeIsConnectedToVC(
|
||||
nodeIo,
|
||||
guildId,
|
||||
openSocket.node.nuid,
|
||||
);
|
||||
log.INFO("Connected:", connected);
|
||||
if (connected) {
|
||||
const username = await getNodeDiscordUsername(openSocket, guildId);
|
||||
const discordID = await getNodeDiscordID(openSocket);
|
||||
onlineBots.push({
|
||||
name: username,
|
||||
discord_id: discordID,
|
||||
nuid: openSocket.node.nuid,
|
||||
});
|
||||
}
|
||||
}),
|
||||
);
|
||||
|
||||
return onlineBots;
|
||||
};
|
||||
|
||||
export const getAvailableTokensInGuild = async (nodeIo, guildId) => {
|
||||
try {
|
||||
// Execute both asynchronous functions concurrently
|
||||
const [discordIDs, onlineBots] = await Promise.all([
|
||||
getAllDiscordIDs(), // Fetch all Discord IDs
|
||||
checkOnlineBotsInGuild(nodeIo, guildId), // Check online bots in the guild
|
||||
]);
|
||||
|
||||
// Use the results of both promises here
|
||||
log.INFO("Available Discord IDs:", discordIDs);
|
||||
log.INFO("Online bots in the guild:", onlineBots);
|
||||
|
||||
// Filter any discordIDs that are not active
|
||||
const availableDiscordIDs = discordIDs
|
||||
.filter((discordID) => discordID.active == true)
|
||||
.filter(
|
||||
(discordID) =>
|
||||
!onlineBots.some(
|
||||
(bot) => Number(bot.discord_id) == discordID.discord_id,
|
||||
),
|
||||
);
|
||||
|
||||
// Return the unavailable discordIDs
|
||||
return availableDiscordIDs;
|
||||
} catch (error) {
|
||||
console.error("Error getting available tokens in guild:", error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the nodes with given system that are available to be used within a given server
|
||||
* @param {any} nodeIo The nodeIO object contained in the discord server object
|
||||
* @param {any} guildId The guild ID to search in
|
||||
* @param {any} system The system to filter the nodes by
|
||||
* @returns {any}
|
||||
*/
|
||||
export const getAvailableNodes = async (nodeIo, guildId, system) => {
|
||||
// Get all open socket nodes
|
||||
const openSockets = [...(await nodeIo.allSockets())]; // TODO - Filter the returned nodes to only nodes that have the radio capability
|
||||
log.DEBUG("All open sockets: ", openSockets);
|
||||
|
||||
var availableNodes = [];
|
||||
// Check each open socket to see if the node has the requested system
|
||||
await Promise.all(
|
||||
openSockets.map(async (openSocket) => {
|
||||
openSocket = await nodeIo.sockets.sockets.get(openSocket);
|
||||
// Check if the node has an existing open client (meaning the radio is already being listened to)
|
||||
const hasOpenClient = await checkIfNodeHasOpenDiscordClient(openSocket);
|
||||
if (hasOpenClient) {
|
||||
let currentSystem = await getNodeCurrentListeningSystem(openSocket);
|
||||
if (currentSystem != system.name) {
|
||||
log.INFO(
|
||||
"Node is listening to a different system than requested",
|
||||
openSocket.node.name,
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the bot has an open voice connection in the requested server already
|
||||
const connected = await checkIfNodeIsConnectedToVC(
|
||||
nodeIo,
|
||||
guildId,
|
||||
openSocket.node.nuid,
|
||||
);
|
||||
log.INFO("Connected:", connected);
|
||||
if (!connected) {
|
||||
// Check if this node has the requested system, if so add it to the availble array
|
||||
if (system.nodes.includes(openSocket.node.nuid)) {
|
||||
availableNodes.push(openSocket);
|
||||
}
|
||||
}
|
||||
}),
|
||||
);
|
||||
|
||||
log.DEBUG(
|
||||
"Availble nodes:",
|
||||
availableNodes.map((socket) => socket.node.name),
|
||||
);
|
||||
|
||||
return availableNodes;
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets the voice channel the user is currently in.
|
||||
* @param {any} interaction - The interaction object.
|
||||
* @returns {any} - The voice channel object, or null if the user is not in a voice channel.
|
||||
*/
|
||||
export const getUserVoiceChannel = (interaction) => {
|
||||
if (!interaction.member.voice.channel) {
|
||||
interaction.editReply({
|
||||
content: `<@${interaction.member.id}>, you need to enter a voice channel before using this command`,
|
||||
ephemeral: true,
|
||||
});
|
||||
return null;
|
||||
}
|
||||
return interaction.member.voice.channel;
|
||||
};
|
||||
|
||||
/**
|
||||
* Joins a node to a specified system and voice channel.
|
||||
* @param {any} nodeIo - The nodeIO server for manipulation of sockets.
|
||||
* @param {any} interaction - The interaction object.
|
||||
* @param {string} nodeId - The ID of the node to join.
|
||||
* @param {any} system - The system object to join.
|
||||
* @param {any} channel - The voice channel to join.
|
||||
*/
|
||||
export const joinNode = async (
|
||||
nodeIo,
|
||||
interaction,
|
||||
nodeId,
|
||||
system,
|
||||
channel,
|
||||
) => {
|
||||
try {
|
||||
const openSocket = await nodeIo.sockets.sockets.get(nodeId);
|
||||
const discordTokens = await getAvailableTokensInGuild(
|
||||
nodeIo,
|
||||
interaction.guild.id,
|
||||
);
|
||||
|
||||
if (discordTokens.length === 0) {
|
||||
await interaction.editReply({
|
||||
content: `<@${interaction.member.id}>, there are no free bots available.`,
|
||||
ephemeral: true,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
log.INFO(
|
||||
"Joining node:",
|
||||
nodeId,
|
||||
system.name,
|
||||
channel.id,
|
||||
openSocket.node.name,
|
||||
discordTokens[0].token,
|
||||
);
|
||||
await requestNodeJoinSystem(
|
||||
openSocket,
|
||||
system.name,
|
||||
channel.id,
|
||||
discordTokens[0].token,
|
||||
);
|
||||
|
||||
await interaction.editReply({
|
||||
content: `<@${interaction.member.id}>, a bot will join your channel listening to '${system.name}' shortly.`,
|
||||
ephemeral: true,
|
||||
});
|
||||
} catch (err) {
|
||||
log.ERROR("Failed to join node:", err);
|
||||
await interaction.editReply({
|
||||
content: `<@${interaction.member.id}>, an error occurred while joining the node: ${err.message}`,
|
||||
ephemeral: true,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Prompts the user to select a node from available nodes.
|
||||
* @param {any} interaction - The interaction object.
|
||||
* @param {Array} availableNodes - The list of available nodes.
|
||||
* @param {Function} onNodeSelected - Callback function to handle the selected node.
|
||||
*/
|
||||
export const promptNodeSelection = async (
|
||||
interaction,
|
||||
availableNodes,
|
||||
onNodeSelected,
|
||||
) => {
|
||||
const nodeSelectionButtons = availableNodes.map((node) =>
|
||||
new ButtonBuilder()
|
||||
.setCustomId(node.id)
|
||||
.setLabel(node.node.name)
|
||||
.setStyle(ButtonStyle.Primary),
|
||||
);
|
||||
|
||||
const actionRow = new ActionRowBuilder().addComponents(nodeSelectionButtons);
|
||||
|
||||
const response = await interaction.editReply({
|
||||
content: `<@${interaction.member.id}>, please select the Node you would like to join with this system:`,
|
||||
components: [actionRow],
|
||||
ephemeral: true,
|
||||
});
|
||||
|
||||
const collectorFilter = (i) => i.user.id === interaction.user.id;
|
||||
try {
|
||||
const selectedNode = await response.awaitMessageComponent({
|
||||
filter: collectorFilter,
|
||||
time: 60_000,
|
||||
});
|
||||
await onNodeSelected(selectedNode.customId);
|
||||
} catch (e) {
|
||||
log.ERROR("Node selection timeout:", e);
|
||||
await interaction.editReply({
|
||||
content: "Confirmation not received within 1 minute, cancelling.",
|
||||
components: [],
|
||||
});
|
||||
}
|
||||
};
|
||||
</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<footer class="footer">
|
||||
<div class="content has-text-centered">
|
||||
<p>Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a></p>
|
||||
<p class="sidebar-created-by">
|
||||
<a href="https://github.com/SoftwareBrothers/better-docs" target="_blank">BetterDocs theme</a> provided with <i class="fas fa-heart"></i> by
|
||||
<a href="http://softwarebrothers.co" target="_blank">SoftwareBrothers - JavaScript Development Agency</a>
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
</div>
|
||||
<div id="side-nav" class="side-nav">
|
||||
</div>
|
||||
</div>
|
||||
<script src="scripts/app.min.js"></script>
|
||||
<script>PR.prettyPrint();</script>
|
||||
<script src="scripts/linenumber.js"> </script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
3131
global.html
Normal file
3131
global.html
Normal file
File diff suppressed because it is too large
Load Diff
129
index.html
Normal file
129
index.html
Normal file
@@ -0,0 +1,129 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title> Home</title>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js"></script>
|
||||
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
|
||||
<script src="./build/entry.js"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link href="https://fonts.googleapis.com/css?family=Roboto:100,400,700|Inconsolata,700" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
|
||||
<link type="text/css" rel="stylesheet" href="https://jmblog.github.io/color-themes-for-google-code-prettify/themes/tomorrow-night.min.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/app.min.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/iframe.css">
|
||||
<link type="text/css" rel="stylesheet" href="">
|
||||
<script async defer src="https://buttons.github.io/buttons.js"></script>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
|
||||
|
||||
<body class="layout small-header">
|
||||
<div id="stickyNavbarOverlay"></div>
|
||||
|
||||
|
||||
<div class="top-nav">
|
||||
<div class="inner">
|
||||
<a id="hamburger" role="button" class="navbar-burger" aria-label="menu" aria-expanded="false">
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
</a>
|
||||
<div class="logo">
|
||||
|
||||
|
||||
</div>
|
||||
<div class="menu">
|
||||
|
||||
<div class="navigation">
|
||||
<a
|
||||
href="index.html"
|
||||
class="link"
|
||||
>
|
||||
Documentation
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="main">
|
||||
<div
|
||||
class="sidebar "
|
||||
id="sidebarNav"
|
||||
>
|
||||
|
||||
<nav>
|
||||
|
||||
<h2><a href="index.html">Documentation</a></h2><div class="category"><h3>Classes</h3><ul><li><a href="DebugBuilder.html">DebugBuilder</a></li><li><a href="PresenceManager.html">PresenceManager</a></li></ul><h3>Global</h3><ul><li><a href="global.html#addEnabledCommands">addEnabledCommands</a></li><li><a href="global.html#addEnabledEventListeners">addEnabledEventListeners</a></li><li><a href="global.html#autocomplete">autocomplete</a></li><li><a href="global.html#checkIfNodeHasOpenDiscordClient">checkIfNodeHasOpenDiscordClient</a></li><li><a href="global.html#checkIfNodeIsConnectedToVC">checkIfNodeIsConnectedToVC</a></li><li><a href="global.html#execute">execute</a></li><li><a href="global.html#getAllSocketsConnectedToVC">getAllSocketsConnectedToVC</a></li><li><a href="global.html#getAvailableNodes">getAvailableNodes</a></li><li><a href="global.html#getNodeDiscordID">getNodeDiscordID</a></li><li><a href="global.html#getNodeDiscordUsername">getNodeDiscordUsername</a></li><li><a href="global.html#getSocketIdByNuid">getSocketIdByNuid</a></li><li><a href="global.html#getUserVoiceChannel">getUserVoiceChannel</a></li><li><a href="global.html#joinNode">joinNode</a></li><li><a href="global.html#nearbySystemsUpdateWraper">nearbySystemsUpdateWraper</a></li><li><a href="global.html#nodeDisconnectWrapper">nodeDisconnectWrapper</a></li><li><a href="global.html#nodeLoginWrapper">nodeLoginWrapper</a></li><li><a href="global.html#nodeUpdateWrapper">nodeUpdateWrapper</a></li><li><a href="global.html#promptNodeSelection">promptNodeSelection</a></li><li><a href="global.html#refreshActiveCommandsWrapper">refreshActiveCommandsWrapper</a></li><li><a href="global.html#requestBotLeaveServer">requestBotLeaveServer</a></li><li><a href="global.html#requestNodeJoinSystem">requestNodeJoinSystem</a></li><li><a href="global.html#requestNodeUpdate">requestNodeUpdate</a></li><li><a href="global.html#sendNodeCommand">sendNodeCommand</a></li><li><a href="global.html#unregisterAllCommands">unregisterAllCommands</a></li><li><a href="global.html#updateFeeds">updateFeeds</a></li><li><a href="global.html#writeToLog">writeToLog</a></li></ul></div>
|
||||
|
||||
</nav>
|
||||
</div>
|
||||
<div class="core" id="main-content-wrapper">
|
||||
<div class="content">
|
||||
<header class="page-title">
|
||||
<p></p>
|
||||
<h1>Home</h1>
|
||||
</header>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h3> </h3>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<footer class="footer">
|
||||
<div class="content has-text-centered">
|
||||
<p>Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a></p>
|
||||
<p class="sidebar-created-by">
|
||||
<a href="https://github.com/SoftwareBrothers/better-docs" target="_blank">BetterDocs theme</a> provided with <i class="fas fa-heart"></i> by
|
||||
<a href="http://softwarebrothers.co" target="_blank">SoftwareBrothers - JavaScript Development Agency</a>
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
</div>
|
||||
<div id="side-nav" class="side-nav">
|
||||
</div>
|
||||
</div>
|
||||
<script src="scripts/app.min.js"></script>
|
||||
<script>PR.prettyPrint();</script>
|
||||
<script src="scripts/linenumber.js"> </script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
195
modules_debugger.mjs.html
Normal file
195
modules_debugger.mjs.html
Normal file
@@ -0,0 +1,195 @@
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title> modules/debugger.mjs</title>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js"></script>
|
||||
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
|
||||
<script src="./build/entry.js"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link href="https://fonts.googleapis.com/css?family=Roboto:100,400,700|Inconsolata,700" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
|
||||
<link type="text/css" rel="stylesheet" href="https://jmblog.github.io/color-themes-for-google-code-prettify/themes/tomorrow-night.min.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/app.min.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/iframe.css">
|
||||
<link type="text/css" rel="stylesheet" href="">
|
||||
<script async defer src="https://buttons.github.io/buttons.js"></script>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
|
||||
|
||||
<body class="layout small-header">
|
||||
<div id="stickyNavbarOverlay"></div>
|
||||
|
||||
|
||||
<div class="top-nav">
|
||||
<div class="inner">
|
||||
<a id="hamburger" role="button" class="navbar-burger" aria-label="menu" aria-expanded="false">
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
</a>
|
||||
<div class="logo">
|
||||
|
||||
|
||||
</div>
|
||||
<div class="menu">
|
||||
|
||||
<div class="navigation">
|
||||
<a
|
||||
href="index.html"
|
||||
class="link"
|
||||
>
|
||||
Documentation
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="main">
|
||||
<div
|
||||
class="sidebar "
|
||||
id="sidebarNav"
|
||||
>
|
||||
|
||||
<nav>
|
||||
|
||||
<h2><a href="index.html">Documentation</a></h2><div class="category"><h3>Classes</h3><ul><li><a href="DebugBuilder.html">DebugBuilder</a></li><li><a href="PresenceManager.html">PresenceManager</a></li></ul><h3>Global</h3><ul><li><a href="global.html#addEnabledCommands">addEnabledCommands</a></li><li><a href="global.html#addEnabledEventListeners">addEnabledEventListeners</a></li><li><a href="global.html#autocomplete">autocomplete</a></li><li><a href="global.html#checkIfNodeHasOpenDiscordClient">checkIfNodeHasOpenDiscordClient</a></li><li><a href="global.html#checkIfNodeIsConnectedToVC">checkIfNodeIsConnectedToVC</a></li><li><a href="global.html#execute">execute</a></li><li><a href="global.html#getAllSocketsConnectedToVC">getAllSocketsConnectedToVC</a></li><li><a href="global.html#getAvailableNodes">getAvailableNodes</a></li><li><a href="global.html#getNodeDiscordID">getNodeDiscordID</a></li><li><a href="global.html#getNodeDiscordUsername">getNodeDiscordUsername</a></li><li><a href="global.html#getSocketIdByNuid">getSocketIdByNuid</a></li><li><a href="global.html#getUserVoiceChannel">getUserVoiceChannel</a></li><li><a href="global.html#joinNode">joinNode</a></li><li><a href="global.html#nearbySystemsUpdateWraper">nearbySystemsUpdateWraper</a></li><li><a href="global.html#nodeDisconnectWrapper">nodeDisconnectWrapper</a></li><li><a href="global.html#nodeLoginWrapper">nodeLoginWrapper</a></li><li><a href="global.html#nodeUpdateWrapper">nodeUpdateWrapper</a></li><li><a href="global.html#promptNodeSelection">promptNodeSelection</a></li><li><a href="global.html#refreshActiveCommandsWrapper">refreshActiveCommandsWrapper</a></li><li><a href="global.html#requestBotLeaveServer">requestBotLeaveServer</a></li><li><a href="global.html#requestNodeJoinSystem">requestNodeJoinSystem</a></li><li><a href="global.html#requestNodeUpdate">requestNodeUpdate</a></li><li><a href="global.html#sendNodeCommand">sendNodeCommand</a></li><li><a href="global.html#unregisterAllCommands">unregisterAllCommands</a></li><li><a href="global.html#updateFeeds">updateFeeds</a></li><li><a href="global.html#writeToLog">writeToLog</a></li></ul></div>
|
||||
|
||||
</nav>
|
||||
</div>
|
||||
<div class="core" id="main-content-wrapper">
|
||||
<div class="content">
|
||||
<header class="page-title">
|
||||
<p>Source</p>
|
||||
<h1>modules/debugger.mjs</h1>
|
||||
</header>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="prettyprint source linenums"><code>// Import necessary modules
|
||||
import debug from "debug";
|
||||
import { config } from "dotenv";
|
||||
config();
|
||||
import { promises as fs } from "fs";
|
||||
import { join, dirname } from "path";
|
||||
import { inspect } from "util";
|
||||
|
||||
/**
|
||||
* Write a given message to the log file
|
||||
* @param {any} logMessage The message to write to the log file
|
||||
* @param {string} appName The app name that created the log entry
|
||||
*/
|
||||
const writeToLog = async (logMessage, appName) => {
|
||||
const logLocation = join(process.env.LOG_LOCATION ?? `./logs/${appName}.log`);
|
||||
|
||||
// Ensure the log directory exists
|
||||
try {
|
||||
await fs.mkdir(dirname(logLocation), { recursive: true });
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
|
||||
// Ensure the message is a string
|
||||
logMessage = `${String(logMessage)}\n`;
|
||||
|
||||
// Write to the file
|
||||
try {
|
||||
await fs.writeFile(logLocation, logMessage, {
|
||||
encoding: "utf-8",
|
||||
flag: "a+",
|
||||
});
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Create the different logging methods for a function
|
||||
* Namespace template = ("[app]:[fileName]:['INFO', 'WARNING', 'DEBUG', 'ERROR']")
|
||||
* @param {string} appName The name of the app to be used in the 'app' portion of the namespace
|
||||
* @param {string} fileName The name of the file calling the builder to be used in the 'fileName' portion of the namespace
|
||||
*/
|
||||
export class DebugBuilder {
|
||||
constructor(appName, fileName) {
|
||||
const buildLogger =
|
||||
(level) =>
|
||||
(...messageParts) => {
|
||||
const logger = debug(`${appName}:${fileName}:${level}`);
|
||||
logger(messageParts);
|
||||
|
||||
const timeStamp = new Date().toLocaleString("en-US", {
|
||||
timeZone: "America/New_York",
|
||||
});
|
||||
const message = `${timeStamp} - ${appName}:${fileName}:${level}\t-\t${messageParts.map((part) => inspect(part)).join(" ")}`;
|
||||
|
||||
// Write to console
|
||||
console.log(message);
|
||||
|
||||
// Write to logfile
|
||||
writeToLog(message, appName);
|
||||
};
|
||||
|
||||
this.INFO = buildLogger("INFO");
|
||||
this.DEBUG = buildLogger("DEBUG");
|
||||
this.VERBOSE = buildLogger("VERBOSE");
|
||||
this.WARN = buildLogger("WARNING");
|
||||
this.ERROR = (...messageParts) => {
|
||||
buildLogger("ERROR")(...messageParts);
|
||||
|
||||
if (process.env.EXIT_ON_ERROR && process.env.EXIT_ON_ERROR > 0) {
|
||||
writeToLog("!--- EXITING ---!", appName);
|
||||
const exitDelay = parseInt(process.env.EXIT_ON_ERROR_DELAY, 10) || 0;
|
||||
setTimeout(() => process.exit(1), exitDelay);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<footer class="footer">
|
||||
<div class="content has-text-centered">
|
||||
<p>Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a></p>
|
||||
<p class="sidebar-created-by">
|
||||
<a href="https://github.com/SoftwareBrothers/better-docs" target="_blank">BetterDocs theme</a> provided with <i class="fas fa-heart"></i> by
|
||||
<a href="http://softwarebrothers.co" target="_blank">SoftwareBrothers - JavaScript Development Agency</a>
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
</div>
|
||||
<div id="side-nav" class="side-nav">
|
||||
</div>
|
||||
</div>
|
||||
<script src="scripts/app.min.js"></script>
|
||||
<script>PR.prettyPrint();</script>
|
||||
<script src="scripts/linenumber.js"> </script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
491
modules_socketServerWrappers.mjs.html
Normal file
491
modules_socketServerWrappers.mjs.html
Normal file
@@ -0,0 +1,491 @@
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title> modules/socketServerWrappers.mjs</title>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js"></script>
|
||||
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
|
||||
<script src="./build/entry.js"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link href="https://fonts.googleapis.com/css?family=Roboto:100,400,700|Inconsolata,700" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
|
||||
<link type="text/css" rel="stylesheet" href="https://jmblog.github.io/color-themes-for-google-code-prettify/themes/tomorrow-night.min.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/app.min.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/iframe.css">
|
||||
<link type="text/css" rel="stylesheet" href="">
|
||||
<script async defer src="https://buttons.github.io/buttons.js"></script>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
|
||||
|
||||
<body class="layout small-header">
|
||||
<div id="stickyNavbarOverlay"></div>
|
||||
|
||||
|
||||
<div class="top-nav">
|
||||
<div class="inner">
|
||||
<a id="hamburger" role="button" class="navbar-burger" aria-label="menu" aria-expanded="false">
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
</a>
|
||||
<div class="logo">
|
||||
|
||||
|
||||
</div>
|
||||
<div class="menu">
|
||||
|
||||
<div class="navigation">
|
||||
<a
|
||||
href="index.html"
|
||||
class="link"
|
||||
>
|
||||
Documentation
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="main">
|
||||
<div
|
||||
class="sidebar "
|
||||
id="sidebarNav"
|
||||
>
|
||||
|
||||
<nav>
|
||||
|
||||
<h2><a href="index.html">Documentation</a></h2><div class="category"><h3>Classes</h3><ul><li><a href="DebugBuilder.html">DebugBuilder</a></li><li><a href="PresenceManager.html">PresenceManager</a></li></ul><h3>Global</h3><ul><li><a href="global.html#addEnabledCommands">addEnabledCommands</a></li><li><a href="global.html#addEnabledEventListeners">addEnabledEventListeners</a></li><li><a href="global.html#autocomplete">autocomplete</a></li><li><a href="global.html#checkIfNodeHasOpenDiscordClient">checkIfNodeHasOpenDiscordClient</a></li><li><a href="global.html#checkIfNodeIsConnectedToVC">checkIfNodeIsConnectedToVC</a></li><li><a href="global.html#execute">execute</a></li><li><a href="global.html#getAllSocketsConnectedToVC">getAllSocketsConnectedToVC</a></li><li><a href="global.html#getAvailableNodes">getAvailableNodes</a></li><li><a href="global.html#getNodeDiscordID">getNodeDiscordID</a></li><li><a href="global.html#getNodeDiscordUsername">getNodeDiscordUsername</a></li><li><a href="global.html#getSocketIdByNuid">getSocketIdByNuid</a></li><li><a href="global.html#getUserVoiceChannel">getUserVoiceChannel</a></li><li><a href="global.html#joinNode">joinNode</a></li><li><a href="global.html#nearbySystemsUpdateWraper">nearbySystemsUpdateWraper</a></li><li><a href="global.html#nodeDisconnectWrapper">nodeDisconnectWrapper</a></li><li><a href="global.html#nodeLoginWrapper">nodeLoginWrapper</a></li><li><a href="global.html#nodeUpdateWrapper">nodeUpdateWrapper</a></li><li><a href="global.html#promptNodeSelection">promptNodeSelection</a></li><li><a href="global.html#refreshActiveCommandsWrapper">refreshActiveCommandsWrapper</a></li><li><a href="global.html#requestBotLeaveServer">requestBotLeaveServer</a></li><li><a href="global.html#requestNodeJoinSystem">requestNodeJoinSystem</a></li><li><a href="global.html#requestNodeUpdate">requestNodeUpdate</a></li><li><a href="global.html#sendNodeCommand">sendNodeCommand</a></li><li><a href="global.html#unregisterAllCommands">unregisterAllCommands</a></li><li><a href="global.html#updateFeeds">updateFeeds</a></li><li><a href="global.html#writeToLog">writeToLog</a></li></ul></div>
|
||||
|
||||
</nav>
|
||||
</div>
|
||||
<div class="core" id="main-content-wrapper">
|
||||
<div class="content">
|
||||
<header class="page-title">
|
||||
<p>Source</p>
|
||||
<h1>modules/socketServerWrappers.mjs</h1>
|
||||
</header>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="prettyprint source linenums"><code>import { DebugBuilder } from "../modules/debugger.mjs";
|
||||
const log = new DebugBuilder("server", "socketServerWrappers");
|
||||
import {
|
||||
createNode,
|
||||
getNodeByNuid,
|
||||
updateNodeByNuid,
|
||||
} from "./mongo-wrappers/mongoNodesWrappers.mjs";
|
||||
import {
|
||||
createSystem,
|
||||
getSystemByName,
|
||||
updateSystemByName,
|
||||
getSystemsByNuid,
|
||||
deleteSystemByName,
|
||||
} from "./mongo-wrappers/mongoSystemsWrappers.mjs";
|
||||
|
||||
/**
|
||||
* Description
|
||||
* @param {any} socket
|
||||
* @param {any} command
|
||||
* @param {any} data
|
||||
* @returns {any}
|
||||
*/
|
||||
const sendNodeCommand = async (socket, command, data) => {
|
||||
// TODO - Check to see if the command exists
|
||||
// TODO - Check to see if the socket is alive?
|
||||
// TODO - Validate the given data
|
||||
socket.emit(command, data);
|
||||
};
|
||||
|
||||
/**
|
||||
* Log the node into the network
|
||||
* @param {object} data The data sent from the node
|
||||
* @param {any} socket The socket the node is connected from
|
||||
* @returns {any}
|
||||
*/
|
||||
export const nodeLoginWrapper = async (data, socket) => {
|
||||
log.INFO(`Login requested from node: ${data.nuid}`, data);
|
||||
// Check to see if node exists
|
||||
var node = await getNodeByNuid(data.nuid);
|
||||
if (!node) {
|
||||
const insertedId = await createNode(data);
|
||||
log.DEBUG("Added new node to the database:", insertedId);
|
||||
} else {
|
||||
// Check for updates
|
||||
const updatedNode = await updateNodeByNuid(data.nuid, data);
|
||||
log.DEBUG("Updated node:", updatedNode);
|
||||
}
|
||||
|
||||
node = await getNodeByNuid(data.nuid);
|
||||
|
||||
// Add the socket/node connection
|
||||
socket.node = node;
|
||||
|
||||
return;
|
||||
};
|
||||
|
||||
/**
|
||||
* Disconnect the client from the server
|
||||
* @param {string} socketId The socket ID that was disconnected
|
||||
* @returns {any}
|
||||
*/
|
||||
export const nodeDisconnectWrapper = async (socketId) => {
|
||||
// TODO - Let any server know that a bot has disconnected if the bot was joined to vc? might not be worth cpu lol
|
||||
return;
|
||||
};
|
||||
|
||||
/**
|
||||
* Update node data in the database
|
||||
* @param {object} nodeData The data object sent from the node
|
||||
* @returns {any}
|
||||
*/
|
||||
export const nodeUpdateWrapper = async (nodeData) => {
|
||||
log.DEBUG("Data update sent by node: ", nodeData);
|
||||
const updateResults = await updateNodeByNuid(nodeData.nuid, nodeData);
|
||||
return;
|
||||
};
|
||||
|
||||
/**
|
||||
* Wrapper to update the systems from the nearbySystems object passed from clients
|
||||
* @param {string} nuid The NUID of the node that sent the update
|
||||
* @param {object} nearbySystems The nearby systems object passed from the node to be updated
|
||||
*/
|
||||
export const nearbySystemsUpdateWraper = async (nuid, nearbySystems) => {
|
||||
log.DEBUG("System updates sent by node: ", nuid, nearbySystems);
|
||||
// Check to see if the node removed any systems
|
||||
const existingSystems = await getSystemsByNuid(nuid);
|
||||
log.DEBUG("Existing systems:", existingSystems);
|
||||
if (existingSystems !== nearbySystems) {
|
||||
for (const existingSystem of existingSystems) {
|
||||
if (existingSystem.name in nearbySystems) {
|
||||
// Skip this system if it's in the given systems update
|
||||
continue;
|
||||
}
|
||||
|
||||
log.DEBUG("System exists that was not given by node", existingSystem);
|
||||
// Check if this node was the only node on this system
|
||||
if (existingSystem.nodes.filter((node) => node !== nuid).length === 0) {
|
||||
// Remove the system if so
|
||||
log.INFO(
|
||||
"Given node was the only node on this system, removing the system...",
|
||||
);
|
||||
await deleteSystemByName(existingSystem.name);
|
||||
} else {
|
||||
// Remove the node from the array if there are other nodes with this system
|
||||
log.INFO("Other nodes found on this system, removing the given NUID");
|
||||
existingSystem.nodes = existingSystem.nodes.filter(
|
||||
(node) => node !== nuid,
|
||||
);
|
||||
log.DEBUG(existingSystem);
|
||||
await updateSystemByName(existingSystem.name, existingSystem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add and update the given systems
|
||||
for (const nearbySystem in nearbySystems) {
|
||||
// Check if the system exists already on another node
|
||||
const existingSystem = await getSystemByName(nearbySystem);
|
||||
if (existingSystem) {
|
||||
// Verify the frequencies match (to make sure the name isn't just the same)
|
||||
if (
|
||||
JSON.stringify(existingSystem.frequencies) ===
|
||||
JSON.stringify(nearbySystems[nearbySystem].frequencies)
|
||||
) {
|
||||
// The systems are the same
|
||||
|
||||
// Check if the current node is listed in the nodes, if not add it
|
||||
if (!existingSystem.nodes.includes(nuid)) {
|
||||
existingSystem.nodes.push(nuid);
|
||||
// Update the system with the added node
|
||||
const updateResults = await updateSystemByName(
|
||||
nearbySystem,
|
||||
existingSystem,
|
||||
);
|
||||
if (updateResults) log.INFO("System updated", nearbySystem);
|
||||
}
|
||||
} else {
|
||||
// The systems are not the same
|
||||
// TODO - Implement logic to handle if system names match, but they are for different frequencies or have additional freqs
|
||||
|
||||
// Check if the current node is listed in the nodes, if not add it
|
||||
if (!existingSystem.nodes.includes(nuid)) {
|
||||
existingSystem.nodes.push(nuid);
|
||||
nearbySystems[nearbySystem].nodes = existingSystem.nodes;
|
||||
}
|
||||
|
||||
// Update the system with the added node
|
||||
const updateResults = await updateSystemByName(
|
||||
nearbySystem,
|
||||
nearbySystems[nearbySystem],
|
||||
);
|
||||
if (updateResults) log.INFO("System updated", nearbySystem);
|
||||
}
|
||||
} else {
|
||||
// Create a new system
|
||||
const newSystem = await createSystem(
|
||||
nearbySystem,
|
||||
nearbySystems[nearbySystem],
|
||||
nuid,
|
||||
);
|
||||
log.INFO("New system created", nearbySystem, newSystem);
|
||||
}
|
||||
}
|
||||
return;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the open socket connection ID for a node from the NUID
|
||||
* @param {string} nuid The NUID to find within the open sockets
|
||||
* @returns {string|null} Will return the open socket ID or NULL
|
||||
*/
|
||||
export const getSocketIdByNuid = async (nodeIo, nuid) => {
|
||||
const openSockets = await nodeIo.allSockets();
|
||||
for (const openSocketId of openSockets) {
|
||||
log.DEBUG(openSockets);
|
||||
const openSocket = await nodeIo.sockets.sockets.get(openSocketId);
|
||||
if (openSocket.node.nuid == nuid) return openSocket;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get all nodes that are connected to a voice channel
|
||||
* @param {any} nodeIo The nodeIo object that contains the IO server
|
||||
* @param {string} guildId The guild ID string for the guild we are looking in
|
||||
* @returns {Array} The sockets connected to VC in a given server
|
||||
*/
|
||||
export const getAllSocketsConnectedToVC = async (nodeIo, guildId) => {
|
||||
// Get all open socket nodes
|
||||
// TODO - require a server guild to filter the results, ie this would be able to check what server the VCs the nodes are connected are in
|
||||
const openSockets = [...(await nodeIo.allSockets())]; // TODO - Filter the returned nodes to only nodes that have the radio capability
|
||||
// Check each open socket to see if the node has the requested system
|
||||
const socketsConnectedToVC = [];
|
||||
await Promise.all(
|
||||
openSockets.map(async (openSocket) => {
|
||||
openSocket = await nodeIo.sockets.sockets.get(openSocket);
|
||||
await new Promise((res) => {
|
||||
openSocket.emit("node-check-connected-status", guildId, (status) => {
|
||||
if (status) {
|
||||
log.INFO(
|
||||
"Socket is connected to VC:",
|
||||
openSocket.node.name,
|
||||
status,
|
||||
);
|
||||
socketsConnectedToVC.push(openSocket);
|
||||
} else {
|
||||
log.INFO("Socket is NOT connected to VC:", openSocket.node.name);
|
||||
}
|
||||
res();
|
||||
});
|
||||
});
|
||||
}),
|
||||
);
|
||||
|
||||
return socketsConnectedToVC;
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if the given node has an open discord client
|
||||
* @param {any} openSocket The open socket connection with the node to check
|
||||
* @returns {boolean} If the given node has an open discord client or not
|
||||
*/
|
||||
export const checkIfNodeHasOpenDiscordClient = async (openSocket) => {
|
||||
// Check the open socket to see if the node has an open discord client
|
||||
let hasOpenDiscordClient = false;
|
||||
await new Promise((res) => {
|
||||
log.INFO(
|
||||
"Checking if socket has an open connection:",
|
||||
openSocket.node.name,
|
||||
);
|
||||
openSocket.emit("node-check-discord-open-client", (status) => {
|
||||
if (status) {
|
||||
log.INFO(
|
||||
"Socket has an open discord client:",
|
||||
openSocket.node.name,
|
||||
status,
|
||||
);
|
||||
hasOpenDiscordClient = true;
|
||||
} else {
|
||||
log.INFO(
|
||||
"Socket does NOT have an open discord client:",
|
||||
openSocket.node.name,
|
||||
);
|
||||
}
|
||||
res();
|
||||
});
|
||||
});
|
||||
|
||||
return hasOpenDiscordClient;
|
||||
};
|
||||
|
||||
export const getNodeCurrentListeningSystem = async (openSocket) => {
|
||||
const hasOpenClient = checkIfNodeHasOpenDiscordClient(openSocket);
|
||||
if (!hasOpenClient) return undefined;
|
||||
|
||||
// check what system the socket is listening to
|
||||
let currentSystem = undefined;
|
||||
await new Promise((res) => {
|
||||
log.INFO(
|
||||
"Checking system node is currently listening to:",
|
||||
openSocket.node.name,
|
||||
);
|
||||
openSocket.emit("node-check-current-system", (system) => {
|
||||
if (system) {
|
||||
log.INFO(
|
||||
"Socket is listening to system:",
|
||||
openSocket.node.name,
|
||||
system,
|
||||
);
|
||||
currentSystem = system;
|
||||
} else {
|
||||
log.INFO(
|
||||
"Socket is not currently listening to a system:",
|
||||
openSocket.node.name,
|
||||
);
|
||||
}
|
||||
res();
|
||||
});
|
||||
});
|
||||
|
||||
return currentSystem;
|
||||
};
|
||||
|
||||
/**
|
||||
* Wrapper to check if the given NUID is connected to a VC
|
||||
* @param {any} nodeIo The nodeIo object that contains the IO server
|
||||
* @param {string} nuid The NUID string that we would like to find in the open socket connections
|
||||
* @returns {boolean} If the node is connected to VC in the given server
|
||||
*/
|
||||
export const checkIfNodeIsConnectedToVC = async (nodeIo, guildId, nuid) => {
|
||||
const socketsConnectedToVC = await getAllSocketsConnectedToVC(
|
||||
nodeIo,
|
||||
guildId,
|
||||
);
|
||||
for (const socket of socketsConnectedToVC) {
|
||||
if (socket.node.nuid === nuid) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the discord username from a given socket
|
||||
* @param {any} socket The socket object of the node to check the username of
|
||||
* * @param {string} guildId The guild ID to check the username in
|
||||
* @returns {string} The username of the bot in the requested server
|
||||
*/
|
||||
export const getNodeDiscordUsername = async (socket, guildId) => {
|
||||
return await new Promise((res) => {
|
||||
socket.emit("node-get-discord-username", guildId, (username) => {
|
||||
res(username);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the discord ID from a given socket
|
||||
* @param {any} socket The socket object of the node to check the ID of
|
||||
* @returns {string} The ID of the bot
|
||||
*/
|
||||
export const getNodeDiscordID = async (socket) => {
|
||||
return await new Promise((res) => {
|
||||
socket.emit("node-get-discord-id", (discordID) => {
|
||||
res(discordID);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Request a given socket node to join a given voice channel
|
||||
* @param {any} socket The socket object of the node the request should be sent to
|
||||
* @param {any} systemName The system preset name that we would like to listen to
|
||||
* @param {string} discordChanelId The Discord channel ID to join the listening bot to
|
||||
*/
|
||||
export const requestNodeJoinSystem = async (
|
||||
socket,
|
||||
systemName,
|
||||
discordChanelId,
|
||||
discordToken = "MTE5NjAwNTM2ODYzNjExMjk3Nw.GuCMXg.24iNNofNNumq46FIj68zMe9RmQgugAgfrvelEA",
|
||||
) => {
|
||||
// Join the system
|
||||
const joinData = {
|
||||
clientID: discordToken,
|
||||
channelID: discordChanelId,
|
||||
system: systemName,
|
||||
};
|
||||
// Send the command to the node
|
||||
await sendNodeCommand(socket, "node-join", joinData);
|
||||
};
|
||||
|
||||
/**
|
||||
* Request a given socket node to leave VC in a given server
|
||||
* @param {any} socket The socket object of the node the request should be sent to
|
||||
* @param {string} guildId The guild ID to disconnect the socket node from
|
||||
*/
|
||||
export const requestBotLeaveServer = async (socket, guildId) => {
|
||||
// Send the command to the node
|
||||
await sendNodeCommand(socket, "node-leave", guildId);
|
||||
};
|
||||
|
||||
/**
|
||||
* Requset a given socket node to update themselves
|
||||
* @param {any} socket The socket object of the node to request to update
|
||||
*/
|
||||
export const requestNodeUpdate = async (socket) => {
|
||||
await sendNodeCommand(socket, "node-update", (status) => {
|
||||
if (status) {
|
||||
log.INFO("Node is out of date, updating now", socket.node.name);
|
||||
} else {
|
||||
log.INFO("Node is up to date", socket.node.name);
|
||||
}
|
||||
});
|
||||
};
|
||||
</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<footer class="footer">
|
||||
<div class="content has-text-centered">
|
||||
<p>Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a></p>
|
||||
<p class="sidebar-created-by">
|
||||
<a href="https://github.com/SoftwareBrothers/better-docs" target="_blank">BetterDocs theme</a> provided with <i class="fas fa-heart"></i> by
|
||||
<a href="http://softwarebrothers.co" target="_blank">SoftwareBrothers - JavaScript Development Agency</a>
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
</div>
|
||||
<div id="side-nav" class="side-nav">
|
||||
</div>
|
||||
</div>
|
||||
<script src="scripts/app.min.js"></script>
|
||||
<script>PR.prettyPrint();</script>
|
||||
<script src="scripts/linenumber.js"> </script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
236
rss-manager_feedHandler.mjs.html
Normal file
236
rss-manager_feedHandler.mjs.html
Normal file
@@ -0,0 +1,236 @@
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title> rss-manager/feedHandler.mjs</title>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js"></script>
|
||||
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
|
||||
<script src="./build/entry.js"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<link href="https://fonts.googleapis.com/css?family=Roboto:100,400,700|Inconsolata,700" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
|
||||
<link type="text/css" rel="stylesheet" href="https://jmblog.github.io/color-themes-for-google-code-prettify/themes/tomorrow-night.min.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/app.min.css">
|
||||
<link type="text/css" rel="stylesheet" href="styles/iframe.css">
|
||||
<link type="text/css" rel="stylesheet" href="">
|
||||
<script async defer src="https://buttons.github.io/buttons.js"></script>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
|
||||
|
||||
<body class="layout small-header">
|
||||
<div id="stickyNavbarOverlay"></div>
|
||||
|
||||
|
||||
<div class="top-nav">
|
||||
<div class="inner">
|
||||
<a id="hamburger" role="button" class="navbar-burger" aria-label="menu" aria-expanded="false">
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
<span aria-hidden="true"></span>
|
||||
</a>
|
||||
<div class="logo">
|
||||
|
||||
|
||||
</div>
|
||||
<div class="menu">
|
||||
|
||||
<div class="navigation">
|
||||
<a
|
||||
href="index.html"
|
||||
class="link"
|
||||
>
|
||||
Documentation
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="main">
|
||||
<div
|
||||
class="sidebar "
|
||||
id="sidebarNav"
|
||||
>
|
||||
|
||||
<nav>
|
||||
|
||||
<h2><a href="index.html">Documentation</a></h2><div class="category"><h3>Classes</h3><ul><li><a href="DebugBuilder.html">DebugBuilder</a></li><li><a href="PresenceManager.html">PresenceManager</a></li></ul><h3>Global</h3><ul><li><a href="global.html#addEnabledCommands">addEnabledCommands</a></li><li><a href="global.html#addEnabledEventListeners">addEnabledEventListeners</a></li><li><a href="global.html#autocomplete">autocomplete</a></li><li><a href="global.html#checkIfNodeHasOpenDiscordClient">checkIfNodeHasOpenDiscordClient</a></li><li><a href="global.html#checkIfNodeIsConnectedToVC">checkIfNodeIsConnectedToVC</a></li><li><a href="global.html#execute">execute</a></li><li><a href="global.html#getAllSocketsConnectedToVC">getAllSocketsConnectedToVC</a></li><li><a href="global.html#getAvailableNodes">getAvailableNodes</a></li><li><a href="global.html#getNodeDiscordID">getNodeDiscordID</a></li><li><a href="global.html#getNodeDiscordUsername">getNodeDiscordUsername</a></li><li><a href="global.html#getSocketIdByNuid">getSocketIdByNuid</a></li><li><a href="global.html#getUserVoiceChannel">getUserVoiceChannel</a></li><li><a href="global.html#joinNode">joinNode</a></li><li><a href="global.html#nearbySystemsUpdateWraper">nearbySystemsUpdateWraper</a></li><li><a href="global.html#nodeDisconnectWrapper">nodeDisconnectWrapper</a></li><li><a href="global.html#nodeLoginWrapper">nodeLoginWrapper</a></li><li><a href="global.html#nodeUpdateWrapper">nodeUpdateWrapper</a></li><li><a href="global.html#promptNodeSelection">promptNodeSelection</a></li><li><a href="global.html#refreshActiveCommandsWrapper">refreshActiveCommandsWrapper</a></li><li><a href="global.html#requestBotLeaveServer">requestBotLeaveServer</a></li><li><a href="global.html#requestNodeJoinSystem">requestNodeJoinSystem</a></li><li><a href="global.html#requestNodeUpdate">requestNodeUpdate</a></li><li><a href="global.html#sendNodeCommand">sendNodeCommand</a></li><li><a href="global.html#unregisterAllCommands">unregisterAllCommands</a></li><li><a href="global.html#updateFeeds">updateFeeds</a></li><li><a href="global.html#writeToLog">writeToLog</a></li></ul></div>
|
||||
|
||||
</nav>
|
||||
</div>
|
||||
<div class="core" id="main-content-wrapper">
|
||||
<div class="content">
|
||||
<header class="page-title">
|
||||
<p>Source</p>
|
||||
<h1>rss-manager/feedHandler.mjs</h1>
|
||||
</header>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<section>
|
||||
<article>
|
||||
<pre class="prettyprint source linenums"><code>import {
|
||||
getAllFeeds,
|
||||
deleteFeedByLink,
|
||||
createPost,
|
||||
getPostByPostId,
|
||||
} from "../modules/mongo-wrappers/mongoFeedsWrappers.mjs";
|
||||
import crypto from "crypto";
|
||||
import { sendPost } from "../discordBot/modules/rssWrappers.mjs";
|
||||
import { DebugBuilder } from "../modules/debugger.mjs";
|
||||
import { removeSource } from "./sourceManager.mjs";
|
||||
import UserAgent from "user-agents";
|
||||
import Parser from "rss-parser";
|
||||
import PresenceManager from "../discordBot/modules/presenceManager.mjs";
|
||||
|
||||
import dotenv from "dotenv";
|
||||
dotenv.config();
|
||||
|
||||
// Initialize the User-Agent string
|
||||
process.env.USER_AGENT_STRING = new UserAgent({ platform: "Win32" }).toString();
|
||||
|
||||
const parser = new Parser({
|
||||
headers: {
|
||||
"User-Agent": process.env.USER_AGENT_STRING,
|
||||
Accept: "application/rss+xml,application/xhtml+xml,application/xml",
|
||||
},
|
||||
});
|
||||
|
||||
const log = new DebugBuilder("server", "feedHandler");
|
||||
|
||||
export const returnHash = (...stringsIncluded) => {
|
||||
return crypto
|
||||
.createHash("sha1")
|
||||
.update(stringsIncluded.join("-<<??//\\\\??>>-"))
|
||||
.digest("base64");
|
||||
};
|
||||
|
||||
/**
|
||||
* Update the active RSS feeds and send any new posts to their discord channels
|
||||
* @param {any} client The discord client to send posts with
|
||||
* @returns {any}
|
||||
*/
|
||||
export const updateFeeds = async (client) => {
|
||||
if (!client) throw new Error("Client object not passed");
|
||||
|
||||
// Setup presence manager
|
||||
const feedPm = new PresenceManager(client);
|
||||
await feedPm.setPresence("online", "WATCHING", "for RSS feed updates");
|
||||
|
||||
try {
|
||||
const records = await getAllFeeds();
|
||||
|
||||
const sourcePromiseArray = records.map(async (source) => {
|
||||
log.DEBUG("Processing source:", source.title);
|
||||
|
||||
try {
|
||||
const parsedFeed = await parser.parseURL(source.link);
|
||||
|
||||
if (parsedFeed?.items) {
|
||||
await Promise.all(
|
||||
parsedFeed.items.reverse().map(async (post) => {
|
||||
log.DEBUG("Processing post:", post.title);
|
||||
|
||||
if (!post.title || !post.link)
|
||||
throw new Error("Missing title or link in the post");
|
||||
if (!post.content && !post["content:encoded"])
|
||||
log.WARN("No content for post:", post.title);
|
||||
|
||||
post.postId =
|
||||
post.postId ??
|
||||
post.guid ??
|
||||
post.id ??
|
||||
returnHash(post.title, post.link, post.pubDate ?? Date.now());
|
||||
|
||||
const existingRecord = await getPostByPostId(post.postId);
|
||||
if (!existingRecord) {
|
||||
const channel = client.channels.cache.get(source.channel_id);
|
||||
const sendResults = await sendPost(post, source, channel);
|
||||
if (!sendResults) throw new Error("Failed to send post");
|
||||
|
||||
log.DEBUG(
|
||||
"Saving post to database:",
|
||||
post.title,
|
||||
source.channel_id,
|
||||
);
|
||||
|
||||
const postToSave = {
|
||||
title: post.title,
|
||||
link: post.link,
|
||||
pubDate: post.pubDate,
|
||||
author: post.author,
|
||||
contentSnippet: post.contentSnippet,
|
||||
id: post.id,
|
||||
isoDate: post.isoDate,
|
||||
postId: post.postId,
|
||||
};
|
||||
|
||||
await createPost(postToSave);
|
||||
log.DEBUG("Post saved:", postToSave);
|
||||
}
|
||||
}),
|
||||
);
|
||||
} else {
|
||||
await deleteFeedByLink(source.link);
|
||||
}
|
||||
} catch (err) {
|
||||
log.ERROR("Error processing source:", source.title, err);
|
||||
await removeSource(source.link);
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
|
||||
await Promise.all(sourcePromiseArray);
|
||||
log.DEBUG("All sources processed");
|
||||
await feedPm.resetToDefault();
|
||||
} catch (error) {
|
||||
log.ERROR("Error updating feeds:", error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
</code></pre>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<footer class="footer">
|
||||
<div class="content has-text-centered">
|
||||
<p>Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a></p>
|
||||
<p class="sidebar-created-by">
|
||||
<a href="https://github.com/SoftwareBrothers/better-docs" target="_blank">BetterDocs theme</a> provided with <i class="fas fa-heart"></i> by
|
||||
<a href="http://softwarebrothers.co" target="_blank">SoftwareBrothers - JavaScript Development Agency</a>
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
</div>
|
||||
<div id="side-nav" class="side-nav">
|
||||
</div>
|
||||
</div>
|
||||
<script src="scripts/app.min.js"></script>
|
||||
<script>PR.prettyPrint();</script>
|
||||
<script src="scripts/linenumber.js"> </script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
1
scripts/app.min.js
vendored
Normal file
1
scripts/app.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";$().ready(function(){});var sidebarIsVisible=!1,toggleSidebar=function(e){var a=!(0<arguments.length&&void 0!==e)||e;$("#sidebarNav").toggleClass("sticky",a),$("#stickyNavbarOverlay").toggleClass("active",a),$("#hamburger").toggleClass("is-active"),sidebarIsVisible=a};$().ready(function(){$("#hamburger").click(function(){toggleSidebar(!sidebarIsVisible)}),$("#stickyNavbarOverlay").click(function(){sidebarIsVisible&&toggleSidebar(!1)})});var OFFSET=150;$().ready(function(){var o=$("#side-nav"),c=[];if($(".vertical-section").length||o.hide(),$(".vertical-section").each(function(e,a){var i=$(a),t=i.find("> h1").text();if(t){o.append($("<h3/>").text(t));var s=$("<ul></ul>");i.find(".members h4.name").each(function(e,a){var i=$(a),t=i.find(".code-name").clone().children().remove().end().text(),n=i.find("a").attr("href"),r=$('<a href="'.concat(n,'" />')).text(t);s.append($("<li></li>").append(r)),c.push({link:r,offset:i.offset().top})}),o.append(s)}else i.find(".members h4.name").each(function(e,a){var i=$(a),t=i.find(".code-name").clone().children().remove().end().text(),n=i.find("a").attr("href"),r=$('<a href="'.concat(n,'" />')).text(t);o.append(r),c.push({link:r,offset:i.offset().top})})}),!$.trim(o.text()))return o.hide();function e(){for(var e=n.scrollTop(),a=!1,i=c.length-1;0<=i;i--){var t=c[i];t.link.removeClass("is-active"),e+OFFSET>=t.offset?a?t.link.addClass("is-past"):(t.link.addClass("is-active"),a=!0):t.link.removeClass("is-past")}}var n=$("#main-content-wrapper");n.on("scroll",e),e(),c.forEach(function(e){e.link.click(function(){n.animate({scrollTop:e.offset-OFFSET+1},500)})})}),$().ready(function(){$("#sidebarNav a").each(function(e,a){var i=$(a).attr("href");window.location.pathname.match("/"+i)&&($(a).addClass("active"),$("#sidebarNav").scrollTop($(a).offset().top-150))})});
|
||||
26
scripts/linenumber.js
Normal file
26
scripts/linenumber.js
Normal file
@@ -0,0 +1,26 @@
|
||||
/*global document */
|
||||
|
||||
(function() {
|
||||
var source = document.getElementsByClassName('prettyprint source linenums');
|
||||
var i = 0;
|
||||
var lineNumber = 0;
|
||||
var lineId;
|
||||
var lines;
|
||||
var totalLines;
|
||||
var anchorHash;
|
||||
|
||||
if (source && source[0]) {
|
||||
anchorHash = document.location.hash.substring(1);
|
||||
lines = source[0].getElementsByTagName('li');
|
||||
totalLines = lines.length;
|
||||
|
||||
for (; i < totalLines; i++) {
|
||||
lineNumber++;
|
||||
lineId = 'line' + lineNumber;
|
||||
lines[i].id = lineId;
|
||||
if (lineId === anchorHash) {
|
||||
lines[i].className += ' selected';
|
||||
}
|
||||
}
|
||||
}
|
||||
})();
|
||||
39
scripts/search.js
Normal file
39
scripts/search.js
Normal file
@@ -0,0 +1,39 @@
|
||||
(function() {
|
||||
const input = document.querySelector('#search')
|
||||
const targets = [ ...document.querySelectorAll('#sidebarNav li')]
|
||||
input.addEventListener('keyup', () => {
|
||||
// loop over each targets and hide the not corresponding ones
|
||||
targets.forEach(target => {
|
||||
if (!target.innerText.toLowerCase().includes(input.value.toLowerCase())) {
|
||||
target.style.display = 'none'
|
||||
|
||||
/**
|
||||
* Detects an empty list
|
||||
* Remove the list and the list's title if the list is not displayed
|
||||
*/
|
||||
const list = [...target.parentNode.childNodes].filter( elem => elem.style.display !== 'none')
|
||||
|
||||
if (!list.length) {
|
||||
target.parentNode.style.display = 'none'
|
||||
target.parentNode.previousSibling.style.display = 'none'
|
||||
}
|
||||
|
||||
/**
|
||||
* Detects empty category
|
||||
* Remove the entire category if no item is displayed
|
||||
*/
|
||||
const category = [...target.parentNode.parentNode.childNodes]
|
||||
.filter( elem => elem.tagName !== 'H2' && elem.style.display !== 'none')
|
||||
|
||||
if (!category.length) {
|
||||
target.parentNode.parentNode.style.display = 'none'
|
||||
}
|
||||
} else {
|
||||
target.parentNode.style.display = 'block'
|
||||
target.parentNode.previousSibling.style.display = 'block'
|
||||
target.parentNode.parentNode.style.display = 'block'
|
||||
target.style.display = 'block'
|
||||
}
|
||||
})
|
||||
})
|
||||
})()
|
||||
1
styles/app.min.css
vendored
Normal file
1
styles/app.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
13
styles/iframe.css
Normal file
13
styles/iframe.css
Normal file
@@ -0,0 +1,13 @@
|
||||
.bd__button {
|
||||
padding: 10px 0;
|
||||
text-align: right;
|
||||
}
|
||||
.bd__button > a{
|
||||
font-weight: 100;
|
||||
text-decoration: none;
|
||||
color: #BDC3CB;
|
||||
font-family: sans-serif;
|
||||
}
|
||||
.bd__button > a:hover {
|
||||
color: #798897;
|
||||
}
|
||||
111
styles/prettify-jsdoc.css
Normal file
111
styles/prettify-jsdoc.css
Normal file
@@ -0,0 +1,111 @@
|
||||
/* JSDoc prettify.js theme */
|
||||
|
||||
/* plain text */
|
||||
.pln {
|
||||
color: #000000;
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
/* string content */
|
||||
.str {
|
||||
color: #006400;
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
/* a keyword */
|
||||
.kwd {
|
||||
color: #000000;
|
||||
font-weight: bold;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
/* a comment */
|
||||
.com {
|
||||
font-weight: normal;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
/* a type name */
|
||||
.typ {
|
||||
color: #000000;
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
/* a literal value */
|
||||
.lit {
|
||||
color: #006400;
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
/* punctuation */
|
||||
.pun {
|
||||
color: #000000;
|
||||
font-weight: bold;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
/* lisp open bracket */
|
||||
.opn {
|
||||
color: #000000;
|
||||
font-weight: bold;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
/* lisp close bracket */
|
||||
.clo {
|
||||
color: #000000;
|
||||
font-weight: bold;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
/* a markup tag name */
|
||||
.tag {
|
||||
color: #006400;
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
/* a markup attribute name */
|
||||
.atn {
|
||||
color: #006400;
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
/* a markup attribute value */
|
||||
.atv {
|
||||
color: #006400;
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
/* a declaration */
|
||||
.dec {
|
||||
color: #000000;
|
||||
font-weight: bold;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
/* a variable name */
|
||||
.var {
|
||||
color: #000000;
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
/* a function name */
|
||||
.fun {
|
||||
color: #000000;
|
||||
font-weight: bold;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
/* Specify class=linenums on a pre to get line numbering */
|
||||
ol.linenums {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
132
styles/prettify-tomorrow.css
Normal file
132
styles/prettify-tomorrow.css
Normal file
@@ -0,0 +1,132 @@
|
||||
/* Tomorrow Theme */
|
||||
/* Original theme - https://github.com/chriskempson/tomorrow-theme */
|
||||
/* Pretty printing styles. Used with prettify.js. */
|
||||
/* SPAN elements with the classes below are added by prettyprint. */
|
||||
/* plain text */
|
||||
.pln {
|
||||
color: #4d4d4c; }
|
||||
|
||||
@media screen {
|
||||
/* string content */
|
||||
.str {
|
||||
color: #718c00; }
|
||||
|
||||
/* a keyword */
|
||||
.kwd {
|
||||
color: #8959a8; }
|
||||
|
||||
/* a comment */
|
||||
.com {
|
||||
color: #8e908c; }
|
||||
|
||||
/* a type name */
|
||||
.typ {
|
||||
color: #4271ae; }
|
||||
|
||||
/* a literal value */
|
||||
.lit {
|
||||
color: #f5871f; }
|
||||
|
||||
/* punctuation */
|
||||
.pun {
|
||||
color: #4d4d4c; }
|
||||
|
||||
/* lisp open bracket */
|
||||
.opn {
|
||||
color: #4d4d4c; }
|
||||
|
||||
/* lisp close bracket */
|
||||
.clo {
|
||||
color: #4d4d4c; }
|
||||
|
||||
/* a markup tag name */
|
||||
.tag {
|
||||
color: #c82829; }
|
||||
|
||||
/* a markup attribute name */
|
||||
.atn {
|
||||
color: #f5871f; }
|
||||
|
||||
/* a markup attribute value */
|
||||
.atv {
|
||||
color: #3e999f; }
|
||||
|
||||
/* a declaration */
|
||||
.dec {
|
||||
color: #f5871f; }
|
||||
|
||||
/* a variable name */
|
||||
.var {
|
||||
color: #c82829; }
|
||||
|
||||
/* a function name */
|
||||
.fun {
|
||||
color: #4271ae; } }
|
||||
/* Use higher contrast and text-weight for printable form. */
|
||||
@media print, projection {
|
||||
.str {
|
||||
color: #060; }
|
||||
|
||||
.kwd {
|
||||
color: #006;
|
||||
font-weight: bold; }
|
||||
|
||||
.com {
|
||||
color: #600;
|
||||
font-style: italic; }
|
||||
|
||||
.typ {
|
||||
color: #404;
|
||||
font-weight: bold; }
|
||||
|
||||
.lit {
|
||||
color: #044; }
|
||||
|
||||
.pun, .opn, .clo {
|
||||
color: #440; }
|
||||
|
||||
.tag {
|
||||
color: #006;
|
||||
font-weight: bold; }
|
||||
|
||||
.atn {
|
||||
color: #404; }
|
||||
|
||||
.atv {
|
||||
color: #060; } }
|
||||
/* Style */
|
||||
/*
|
||||
pre.prettyprint {
|
||||
background: white;
|
||||
font-family: Consolas, Monaco, 'Andale Mono', monospace;
|
||||
font-size: 12px;
|
||||
line-height: 1.5;
|
||||
border: 1px solid #ccc;
|
||||
padding: 10px; }
|
||||
*/
|
||||
|
||||
/* Specify class=linenums on a pre to get line numbering */
|
||||
ol.linenums {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0; }
|
||||
|
||||
/* IE indents via margin-left */
|
||||
li.L0,
|
||||
li.L1,
|
||||
li.L2,
|
||||
li.L3,
|
||||
li.L4,
|
||||
li.L5,
|
||||
li.L6,
|
||||
li.L7,
|
||||
li.L8,
|
||||
li.L9 {
|
||||
/* */ }
|
||||
|
||||
/* Alternate shading for lines */
|
||||
li.L1,
|
||||
li.L3,
|
||||
li.L5,
|
||||
li.L7,
|
||||
li.L9 {
|
||||
/* */ }
|
||||
44
styles/reset.css
Normal file
44
styles/reset.css
Normal file
@@ -0,0 +1,44 @@
|
||||
/* reset css */
|
||||
html, body, div, span, applet, object, iframe,
|
||||
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
|
||||
a, abbr, acronym, address, big, cite, code,
|
||||
del, dfn, em, img, ins, kbd, q, s, samp,
|
||||
small, strike, strong, sub, sup, tt, var,
|
||||
b, u, i, center,
|
||||
dl, dt, dd, ol, ul, li,
|
||||
fieldset, form, label, legend,
|
||||
table, caption, tbody, tfoot, thead, tr, th, td,
|
||||
article, aside, canvas, details, embed,
|
||||
figure, figcaption, footer, header, hgroup,
|
||||
menu, nav, output, ruby, section, summary,
|
||||
time, mark, audio, video {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
font-size: 100%;
|
||||
font: inherit;
|
||||
vertical-align: baseline;
|
||||
}
|
||||
/* HTML5 display-role reset for older browsers */
|
||||
article, aside, details, figcaption, figure,
|
||||
footer, header, hgroup, menu, nav, section {
|
||||
display: block;
|
||||
}
|
||||
body {
|
||||
line-height: 1;
|
||||
}
|
||||
ol, ul {
|
||||
list-style: none;
|
||||
}
|
||||
blockquote, q {
|
||||
quotes: none;
|
||||
}
|
||||
blockquote:before, blockquote:after,
|
||||
q:before, q:after {
|
||||
content: '';
|
||||
content: none;
|
||||
}
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
border-spacing: 0;
|
||||
}
|
||||
Reference in New Issue
Block a user