Code Monkey home page Code Monkey logo

sadi's Introduction

S.A.D.I.

Self-Aware Digital Interface - A Discord Bot for a Star Citizen Discord

Currently built and hosted on repl.it

Public Functions

!sadi ship [SHIPNAME]

This will search the API for a released ship and display the information in the current channel.

[SHIPNAME] can be the ship's model (Constellation, Aurora) or a variant (Black, MR). It cannot be a full name (Constellation Taurus). Subsequent searches for the same model, whether by the original user or other users, will return the next variant in the list. When all variants have been returned, the list will loop back to the first.

Search variations

These shorthand switch variations allow for quicker input, and canbe used for advanced searching.

  • -n: Query by the name of the ship. Same as !sadi ship [SHIPNAME]
  • -m: Query my manufacturer name.
  • -r: Query by ship's assigned role.
  • -t: Query by ship type.

!sadi system [SYSTEM_NAME]

This searches the API for information about the provided star system. At the time of this update, there is only one playable system available (Stanton), although it seems that there are a lot of systems in the database.

You can use the -s switch in place of system in the command for shorthand.

!sadi object [OBJECT NAME]

This command will search the API for an object by name. An object in the API data refers to planets, stations, outposts, landing zones, etc. The success of this command will depend on the data backing the API, and at the time of this posting, the data was incomplete.

You can use the -o switch in place of object in the command shorthand.

Admin Functions

Currently, anyone who knows about the admin functions can execute them. It is an obvious oversight.

!setlobby [CHANNEL] [ROLE_TO_GRANT] | reset | remove

With this command, a channel can be set as the "lobby" for new members. Using standard Discord invite rules, new users should be landed to this channel with a default role that has no other access to the server.

Once the !setlobby command has been used, new visitors will be asked to review the EULA for the server (which you should provide in the landing channel) and given two reactions to click on: One to accept, and one to reject. If the user rejects the EULA, he should be kicked from the server (not currently implemened) and the action logged. If the user accepts the EULA, he is immediately granted the role specified in the [ROLE_TO_GRANT] parameter. This role should have wider access to the server.

Specifying the reset argument as the only argument to the comand will remove the existing post in the lobby channel and repost it at the very bottom of the channel. Use this to ensure that the reactions are placed as the last entry in the channel.

You can remove the post and the lobby reference from the bot by using the remove command as the only argument. This will de-register the channel as the lobby, and will remove the confirmation post.

!admin refresh [override]

Using the refresh command will attempt to re-download a local copy of the API data. By default, this is on a 24 hour limit timer so as not to overload good graces of the API. Adding the override parameter to the end of the command, however, will force the bot to pull a refresh regardless of the timer. Please use sparingly.

!admin cleanup

In order to prevent the bot from constantly pinging the API and to perform a data reorganization for the bot operations, S.A.D.I. will cache a local copy of the latest API data for ships, objects, and locations. Part of this process involves transforming the API data into a "flatter" structure that's quicker and easier for the bot to use. This process is called cleaning the data. This is automatically performed at the end of a refresh operation, but should you need to convert the raw data files into the useable format, this command can be executed manually. If the files are up to date, then this process will simply overwrite the useable files with the exact same data.

CONFIG.json Format

The config.json is simple: One node, specifying what the command prefix should be.

{ "prefix":"!" }

.env File Contents

There are several constants referenced in the .env file. As this is a more secure file, it's where the bot will pull things like the Discord and SCAPI client keys.

Note that you will need to set up your own Discord dev account and register your own Discord bot account to get your secret and key. You will also need to register with SCAPI to get a key for their service as well.

DISCORD_BOT_SECRET=[Discord issued secret key]

RSI_BASE_URI=https://www.robertsspaceindustries.com

SC_API_KEY=[SCAPI issued client key]

SC_API_SHIPS_URI=https://api.starcitizen-api.com/[SCAPI issued client key]/v1/cache/ships SC_API_SYSTEMS_URI=https://api.starcitizen-api.com/[SCAPI issued client key]/v1/cache/starmap/systems SC_API_TUNNELS_URI=https://api.starcitizen-api.com/[SCAPI issued client key]/v1/cache/starmap/tunnels SC_API_SPECIES_URI=https://api.starcitizen-api.com/[SCAPI issued client key]/v1/cache/starmap/species SC_API_AFFILIATIONS_URI=https://api.starcitizen-api.com/[SCAPI issued client key]/v1/cache/starmap/affiliations SC_API_OBJECTS_URI=https://api.starcitizen-api.com/[SCAPI issued client key]/v1/cache/starmap/object SC_API_SEARCHES_URI=https://api.starcitizen-api.com/[SCAPI issued client key]/v1/live/starmap/search

sadi's People

Contributors

scopique avatar

Watchers

 avatar

sadi's Issues

Error: Cannot find module './config/config.json'

I get the above error when I attempt to run this. Can you provide any guidance on what the config.json file should look like (warning... I'm a new to node.js and discord dev) or what I'm doing wrong.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.