Coder Social home page Coder Social logo

turnip-discord-bot's Introduction

Turnip Discord Bot

Helper chatbot for displaying useful information such as turnip prices, native fruit, fish and bug prices, seasonality, availability, and location to all users in the server

This discord bot came from the idea, to alleviate the need to ask all my friends twice a day for their current prices.

How it works

The working procedure is crudely described below:

  • Users tell bot their current price of turnips.
  • Users ask the bot to display everyone's current turnip price.
  • Users can use other commands to help easily display information for catching bugs and fishes.
  • Fetches relevant data from MongoDB Atlas and sends it back to the server channel.

Commands

!buying <price>
!fruit <fruit>
!shells <price>
!request <highest | username>
!fish <month> <location | price | time>
!bugs <month> <location | price | time>

How to set up

1. Get needed environment variables

You will need to set some environment variables corresponding to some API configurations

  1. TOKEN : The Discord bot application token
  2. MONGODB_URI : The MongoDB atlas connection string
  3. TZ : Timezone variable that should be set wherever your main user base is e.g (America/New_York)

You can store these variables in a file named .env inside your root project directory.

2. Importing data

Before deploying you will have to import the data json files into MongoDB for your relevant hemisphere. You can use mongoimport to make this task easy:

mongoimport --uri "mongodb+srv://{username}:{password}@{database}" --collection {fishes/bugs} --drop --jsonArray ./data/{north|south}/{fish/bug}.json

3. Deploy server

I personally used heroku since it was free and I didn't have many concurrent users.

yarn app.js

With Heroku we're using an addon called Heroku Scheduler that allows us to call node reset-bell-count.js every 12 hours to reset everyone's bell count in the database.

For heroku there is a Procfile that tells the dyno to spin up using a worker instead of web process type.

turnip-discord-bot's People

Contributors

depfu[bot] avatar maxhuebler avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

turnip-discord-bot's Issues

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.