# moodle-console

> This is a ConsoleClient based on the akora-moodle provides a Console to interact with

Latest version **1.0.1** (published 2021-02-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install moodle-console
pnpm add moodle-console
yarn add moodle-console
bun add moodle-console
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2021-02-24 |
| First published | 2021-02-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 11.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | dragoncat4012, akora-studios |
| Keywords | moodle, console, akora, typed, typings |

## Links

- npm: https://www.npmjs.com/package/moodle-console
- Repository: https://github.com/AKORA-Studios/MoodleConsole
- Homepage: https://github.com/AKORA-Studios/MoodleConsole#readme
- Issues: https://github.com/AKORA-Studios/MoodleConsole/issues
- npm.io page: https://npm.io/package/moodle-console

## Dependencies (1)

- [akora-moodle](https://npm.io/package/akora-moodle.md) ^1.0.2

## Alternatives

- [localforage](https://npm.io/package/localforage.md) — 6.2M weekly downloads
- [localforage-observable](https://npm.io/package/localforage-observable.md) — 30.8K weekly downloads
- [@y/y](https://npm.io/package/@y/y.md) — 30.1K weekly downloads
- [@metaobjectsdev/render](https://npm.io/package/@metaobjectsdev/render.md) — 3.5K weekly downloads
- [@ledgerhq/coin-algorand](https://npm.io/package/@ledgerhq/coin-algorand.md) — 1.1K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2021-02-24
- 1.0.0 — 2021-02-22

## README

[![NPM Version](https://img.shields.io/npm/v/moodle-console?color=00DEC8&style=for-the-badge)](https://www.npmjs.com/package/moodle-console)
[![NPM Downloads](https://img.shields.io/npm/dt/moodle-console?color=00DEC8&style=for-the-badge)](https://www.npmjs.com/package/moodle-console)
[![NPM License](https://img.shields.io/npm/l/moodle-console?color=00DEC8&style=for-the-badge)](https://www.npmjs.com/package/moodle-console)
[![Github Size](https://img.shields.io/github/repo-size/discord-card/levelcard?color=00DEC8&label=SIZE&style=for-the-badge)](https://www.npmjs.com/package/moodle-console)

# Moodle Client Console
This is a package provides you an event based Console in **Moodle** wich you can write and receive messages from. The Console is based on the `akora-moodle` package and has built-in typings, it is simple, fast and lightweight.

<br>

## How does it work?
This console works by sending messages to yourself on Moodle, the Client receives your new message and you can execute some code with the message.

<br>

## Why should i use this package?
Bcs implementing this on your own would take quite a while and it just would be faster to use this package.
You may ask, "What if i want to have a function that the package does not provide?", we would love to implement your hopefully usefull function and constantly improve our package, so feel free to [open a Issue or an Feature Request](https://github.com/AKORA-Studios/MoodleConsole/issues/new/choose!).

<br>

# Getting started
## Installation
```bash
npm install moodle-console
```

<br>

## Creating an instance
To create a instance of the `ConsoleClient`, first need a instance of a `Client` from the [akora-moodle](https://www.npmjs.com/package/akora-moodle) package, which you need provide in the constructor. More information on creating a `Client` can be found [here](https://www.npmjs.com/package/akora-moodle).

<details open><summary>The most basic setup would be</summary><p>

> ```js
> const { ConsoleClient } = require('moodle-console')
> const { Client } = require('akora-moodle');
> 
> Client.init({
>    wwwroot: 'https://moodle.your-school.de/',
>    token: 'yourtokengoesbrrrrrr'
> }).then(async client => {
>     var con = new ConsoleClient(client);
>     await con.initConsole();
> 
>     con.send({
>         text: 'Hello World'
>     })
> })
> ```
</p></details>
<br>

## Listening to messages
The `ConsoleClient` is a EventEmitter which means that you can listen to events with `.on('event', callback)`, currently only the `message` event is supported

<details open><summary>Ping Pong!</summary><p>

> ```js
> var con = new ConsoleClient(client);
> con.initConsole().then(async () => {
>     await con.send({
>         text: '**Started the Console!**'
>     })
>     
>     con.on('message', async (message) => {
>         await con.send({ text: 'Pong!' });
>     });
> })
> ```
</p></details>

This would write back Pong every time you send a message to yourself in moodle.

---
_Source: https://npm.io/package/moodle-console · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
