diff --git a/.prettierrc b/.prettierrc index 0a02bce..7f0d7f2 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,3 +1,11 @@ { - "tabWidth": 4 + "trailingComma": "all", + "tabWidth": 4, + "semi": true, + "arrowParens": "always", + "bracketSameLine": false, + "bracketSpacing": true, + "quoteProps": "as-needed", + "useTabs": true, + "singleQuote": false } diff --git a/.vscode/settings.json b/.vscode/settings.json index c280c9a..4a7669d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,9 +1,9 @@ { - "cSpell.words": [ - "Fosscord", - "landingpage", - "Middlewares", - "Roadmap", - "screenshare" - ] + "cSpell.words": [ + "Fosscord", + "landingpage", + "Middlewares", + "Roadmap", + "screenshare" + ] } diff --git a/docs/assets/extra.css b/docs/assets/extra.css index 9b9b1d6..8131c66 100644 --- a/docs/assets/extra.css +++ b/docs/assets/extra.css @@ -1,7 +1,7 @@ .md-typeset__table { - min-width: 100%; + min-width: 100%; } .md-typeset table:not([class]) { - display: table; + display: table; } diff --git a/docs/assets/js/rightsCalculator.js b/docs/assets/js/rightsCalculator.js index fae259d..66c53bb 100644 --- a/docs/assets/js/rightsCalculator.js +++ b/docs/assets/js/rightsCalculator.js @@ -1,65 +1,65 @@ (() => { - const NUM_COLUMNS = 3; + const NUM_COLUMNS = 3; - // Grab it from the above markdown table and parse it. Simply don't have multiple tables in the page lol - const rights = - // grab the table data elements - [...document.querySelectorAll("td")] - .map((x) => x.innerText) // get their content - .map((x, i) => - x.indexOf("<<") == 2 // if this column is the `value` column - ? x.split(" ").reverse()[0] // get the value we shift by - : x - ); // otherwise dont do anything - const mount = document.getElementById("rights-container"); - const outputMount = document.getElementById("rights-output"); - var calculated = 0n; + // Grab it from the above markdown table and parse it. Simply don't have multiple tables in the page lol + const rights = + // grab the table data elements + [...document.querySelectorAll("td")] + .map((x) => x.innerText) // get their content + .map((x, i) => + x.indexOf("<<") == 2 // if this column is the `value` column + ? x.split(" ").reverse()[0] // get the value we shift by + : x, + ); // otherwise dont do anything + const mount = document.getElementById("rights-container"); + const outputMount = document.getElementById("rights-output"); + var calculated = 0n; - for (var i = 0; i < rights.length; i += NUM_COLUMNS) { - const name = rights[i]; - const shift = rights[i + 1]; - const desc = rights[i + 2]; + for (var i = 0; i < rights.length; i += NUM_COLUMNS) { + const name = rights[i]; + const shift = rights[i + 1]; + const desc = rights[i + 2]; - const div = document.createElement("div"); - const input = document.createElement("input"); - input.setAttribute("type", "checkbox"); - input.setAttribute("id", shift); - const label = document.createElement("label"); - label.setAttribute("for", label.id); - label.innerText = name.toUpperCase(); + const div = document.createElement("div"); + const input = document.createElement("input"); + input.setAttribute("type", "checkbox"); + input.setAttribute("id", shift); + const label = document.createElement("label"); + label.setAttribute("for", label.id); + label.innerText = name.toUpperCase(); - div.appendChild(input); - div.appendChild(label); + div.appendChild(input); + div.appendChild(label); - mount.append(div); + mount.append(div); - input.addEventListener("click", (event) => { - const value = 1n << BigInt(event.target.getAttribute("id")); + input.addEventListener("click", (event) => { + const value = 1n << BigInt(event.target.getAttribute("id")); - // bit messy, oh well - if (value == 1n) { - if (event.target.checked) { - for (var elem of mount.children) { - elem.children[0].setAttribute("disabled", true); - } - event.target.removeAttribute("disabled"); + // bit messy, oh well + if (value == 1n) { + if (event.target.checked) { + for (var elem of mount.children) { + elem.children[0].setAttribute("disabled", true); + } + event.target.removeAttribute("disabled"); - outputMount.innerText = "1"; - return; - } else { - for (var elem of mount.children) { - elem.children[0].removeAttribute("disabled"); - } - outputMount.innerText = calculated; - return; - } - } + outputMount.innerText = "1"; + return; + } else { + for (var elem of mount.children) { + elem.children[0].removeAttribute("disabled"); + } + outputMount.innerText = calculated; + return; + } + } - calculated = event.target.checked - ? calculated + value - : calculated - value; + calculated = event.target.checked + ? calculated + value + : calculated - value; - outputMount.innerText = calculated; - }); - } + outputMount.innerText = calculated; + }); + } })(); diff --git a/docs/contributing/index.md b/docs/contributing/index.md index c9c6b6f..4e8884f 100644 --- a/docs/contributing/index.md +++ b/docs/contributing/index.md @@ -3,10 +3,11 @@ !!! info "[Have you read the Code of Conduct?](conduct.md)" ## Notable Technologies -* Typescript -* [Typeorm](https://www.npmjs.com/package/typeorm) -* [WS](https://www.npmjs.com/package/ws) -* [Express](https://www.npmjs.com/package/express) + +- Typescript +- [Typeorm](https://www.npmjs.com/package/typeorm) +- [WS](https://www.npmjs.com/package/ws) +- [Express](https://www.npmjs.com/package/express) ## Structure @@ -27,4 +28,4 @@ The API is a HTTP REST server which does the bulk of the database reads/writes. ## Documentation -Unfortunately writing documentation is quite annoying. There's tons of comments in the codebase tho, so don't worry :) \ No newline at end of file +Unfortunately writing documentation is quite annoying. There's tons of comments in the codebase tho, so don't worry :) diff --git a/docs/faq.md b/docs/faq.md index 0edfbd3..70c14e0 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -2,86 +2,86 @@ ??? info "Voice/Video when???" - Currently there is no voice or video support in any Fosscord instance. - This is a very difficult feature to get working, especially given that - we must implement it the exact same way as Discord.com for client compatibility. - [We would be incredibly thankful for any assistance.](/contributing) + Currently there is no voice or video support in any Fosscord instance. + This is a very difficult feature to get working, especially given that + we must implement it the exact same way as Discord.com for client compatibility. + [We would be incredibly thankful for any assistance.](/contributing) ??? info "Free Nitro???" - Please do not use Discord trademarks to refer to anything regarding Fosscord. - As an instance owner, you can grant yourself or others *premium* features which may be used to determine your abilities - *client-side*. However, Fosscord-server currently does not have any distinction between premium and free users. - All users can access all features, given they have the [right](security/rights.md) to do so. + Please do not use Discord trademarks to refer to anything regarding Fosscord. + As an instance owner, you can grant yourself or others *premium* features which may be used to determine your abilities + *client-side*. However, Fosscord-server currently does not have any distinction between premium and free users. + All users can access all features, given they have the [right](security/rights.md) to do so. - You cannot give yourself premium features on Discord.com using a Fosscord instance. + You cannot give yourself premium features on Discord.com using a Fosscord instance. ??? info "Can I log in with my Discord account?" - No. Fosscord and Discord are entirely separate services, with their own separate databases - and authentication. Fosscord cannot access any private data from Discord.com. - As always, you should not provide login credentials for Discord.com, or any other service, - to others. + No. Fosscord and Discord are entirely separate services, with their own separate databases + and authentication. Fosscord cannot access any private data from Discord.com. + As always, you should not provide login credentials for Discord.com, or any other service, + to others. ??? info "Does Fosscord use the same servers as Discord?" - No. Discord servers, as in the bare-metal running the service, are completely inaccessible - to people, outside of course the Discord.com service provided. It is impossible for us to use their - infrastructure. Fosscord is hosted entirely by you, the instance owner (or whoever is the owner of your instance). + No. Discord servers, as in the bare-metal running the service, are completely inaccessible + to people, outside of course the Discord.com service provided. It is impossible for us to use their + infrastructure. Fosscord is hosted entirely by you, the instance owner (or whoever is the owner of your instance). - If you mean Discord 'server' as in a *guild*, also no. Fosscord is not a proxy for - Discord guilds. Fosscord does not create Discord.com accounts, or ask for your own, at any time - (outside of a Discord.com account connection for your Fosscord user, which is still not us asking for your credentials). - If Fosscord was to try this, Discord's automated spam filters would surely block your instance. + If you mean Discord 'server' as in a *guild*, also no. Fosscord is not a proxy for + Discord guilds. Fosscord does not create Discord.com accounts, or ask for your own, at any time + (outside of a Discord.com account connection for your Fosscord user, which is still not us asking for your credentials). + If Fosscord was to try this, Discord's automated spam filters would surely block your instance. - Lastly, you can simply view [our codebase](https://github.com/fosscord/fosscord-server). - A simple proxy would not need to be this complex or large. - We implement the entire Discord.com API, Gateway, among others. - None of this would be necessary if we were simply abusing Discord.com. + Lastly, you can simply view [our codebase](https://github.com/fosscord/fosscord-server). + A simple proxy would not need to be this complex or large. + We implement the entire Discord.com API, Gateway, among others. + None of this would be necessary if we were simply abusing Discord.com. ??? info "Do you use Discord.com code?" - Absolutely not. If a potential contributor makes any indication of being a Discord employee, - or to have access to leaked Discord.com code, we take measures in line with our [Code of Conduct](/contributing/conduct.md) - to ensure the Fosscord codebase is free of any proprietary code. We want absolutely nothing to do with it. + Absolutely not. If a potential contributor makes any indication of being a Discord employee, + or to have access to leaked Discord.com code, we take measures in line with our [Code of Conduct](/contributing/conduct.md) + to ensure the Fosscord codebase is free of any proprietary code. We want absolutely nothing to do with it. ??? info "What about the test client? That's just the Discord.com one!" - Yes, this is true. However, this is purely for testing and development purposes. - Fosscord is first and foremost a *backend* server implementation, and we simply use Discord.com's client - to achieve our goals. Efforts are being made to move away from this with our own client, but as you may have guessed, - building a Discord-compatible client is difficult. + Yes, this is true. However, this is purely for testing and development purposes. + Fosscord is first and foremost a *backend* server implementation, and we simply use Discord.com's client + to achieve our goals. Efforts are being made to move away from this with our own client, but as you may have guessed, + building a Discord-compatible client is difficult. - You can read more about the test client [here](Test%20Client/index.md) + You can read more about the test client [here](Test%20Client/index.md) ??? info "Is this illegal?" - The person writing this does not believe it to be illegal, no. - The only aspect of Fosscord that is not entirely written by us is the test client which we simply proxy from Discord.com, - and we take measures to show that the client is purely for development and research purposes. + The person writing this does not believe it to be illegal, no. + The only aspect of Fosscord that is not entirely written by us is the test client which we simply proxy from Discord.com, + and we take measures to show that the client is purely for development and research purposes. ??? info "Why are you doing this, anyway?" - Personally, it's because it's fun. But if you ask 'Officially': + Personally, it's because it's fun. But if you ask 'Officially': - 1. We love free, open source software. - 2. There are many existing bots, applications, users, features, and ideas surrounding Discord.com. - 3. Fosscord allows these users and developers to maintain a familiar ecosystem with minimal friction. - 4. Reimplementing allows us to extend the Discord protocol in ways Discord.com may not deem feasible, economical, whateverical. - 5. This includes privacy features, such as end to end encryption for example. - 6. The reverse engineering effort by our team may be useful to outside developers looking to understand how similar services work. - 7. The Discord protocol despite it's API complexity is quite simple and linear, which makes this project more feasible. + 1. We love free, open source software. + 2. There are many existing bots, applications, users, features, and ideas surrounding Discord.com. + 3. Fosscord allows these users and developers to maintain a familiar ecosystem with minimal friction. + 4. Reimplementing allows us to extend the Discord protocol in ways Discord.com may not deem feasible, economical, whateverical. + 5. This includes privacy features, such as end to end encryption for example. + 6. The reverse engineering effort by our team may be useful to outside developers looking to understand how similar services work. + 7. The Discord protocol despite it's API complexity is quite simple and linear, which makes this project more feasible. ??? info "Editing the database is annoying, is there a graphical interface for this?" - Currently no, there is no graphical interface for managing your Fosscord instance. - An admin dashboard is planned, but we currently have higher priorities right now. + Currently no, there is no graphical interface for managing your Fosscord instance. + An admin dashboard is planned, but we currently have higher priorities right now. ??? info "When will this feature be available?" - We do not provide ETAs. Users tend to take them as deadlines, and for a small team of <5 maintainers - who do not get payment for their work, this is unreasonable. + We do not provide ETAs. Users tend to take them as deadlines, and for a small team of <5 maintainers + who do not get payment for their work, this is unreasonable. ??? info "It's pretty funny how you have a Discord.com guild for support." - We know. Also that's not a question. \ No newline at end of file + We know. Also that's not a question. diff --git a/docs/setup/bots/index.md b/docs/setup/bots/index.md index 8304bed..f291657 100644 --- a/docs/setup/bots/index.md +++ b/docs/setup/bots/index.md @@ -18,12 +18,12 @@ the endpoints used. const { Client } = require("discord.js"); const client = new Client({ - http: { - version: 9, - api: "https://api.fosscord.com", - cdn: "https://cdn.fosscord.com", - invite: "https://fosscord.com/invite", - }, + http: { + version: 9, + api: "https://api.fosscord.com", + cdn: "https://cdn.fosscord.com", + invite: "https://fosscord.com/invite", + }, }); client.login("your token here"); diff --git a/docs/setup/clients/index.md b/docs/setup/clients/index.md index ff6d8e8..9c7af0d 100644 --- a/docs/setup/clients/index.md +++ b/docs/setup/clients/index.md @@ -3,30 +3,33 @@ There are 3 options, all of which require the Fosscord server have [erlpack](https://npmjs.com/package/@yukikaze-bot/erlpack) installed. 1. The simpler one is to set the `DISCORD_WEBAPP_ENDPOINT` environment variable on the machine running the client -to the Fosscord web app URL. This assumes the Fosscord instance has the [test client](../server/Test%20Client/index.md) enabled. + to the Fosscord web app URL. This assumes the Fosscord instance has the [test client](../server/Test%20Client/index.md) enabled. 1. You may edit your desktop client's `settings.json` file at -`%appdata%/discord/settings.json`, -adding the following line + `%appdata%/discord/settings.json`, adding the following line + ```json "WEBAPP_ENDPOINT" : "https://your_fosscord_instance_url" ``` + such that it looks like this, as an example + ```json { - "IS_MAXIMIZED": true, - "IS_MINIMIZED": false, - "WINDOW_BOUNDS": { - "x": 335, - "y": 86, - "width": 940, - "height": 600 - }, - "BACKGROUND_COLOR": "#202225", - "WEBAPP_ENDPOINT" : "https://your_fosscord_instance_url" + "IS_MAXIMIZED": true, + "IS_MINIMIZED": false, + "WINDOW_BOUNDS": { + "x": 335, + "y": 86, + "width": 940, + "height": 600 + }, + "BACKGROUND_COLOR": "#202225", + "WEBAPP_ENDPOINT": "https://your_fosscord_instance_url" } ``` + This also assumes the Fosscord instance has enabled the test client. 1. If an instance does not have the test client enabled, you can [host the proxy yourself](https://github.com/fosscord/Discord-Client-Proxy), -and simply set it to use your desired Fosscord instance. \ No newline at end of file + and simply set it to use your desired Fosscord instance.