Giter Site home page Giter Site logo

limited-lemon / discord-chatbot Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lucasvianav/discord-chatbot

0.0 0.0 0.0 545 KB

Simple bot that'll reply to commands (prefix '>') and on_message() triggers specified in a Google Sheets.

License: MIT License

Shell 0.07% Python 99.93%

discord-chatbot's Introduction

Discord Chatbot

Simple bot that'll reply to commands (prefix '>') and on_message() triggers specified in a Google Sheets. The spreadsheet must have two worksheets named "triggers" and "commands", respectively.

The code is kinda chaotic and not too well commented. Sorry.

Config

You must provide your own Google Sheets API's credentials variables as well as your Discord token, spreadsheet key and MongoDB Atlas URI. The data may be provided as a credentials.json and .env on the project's root directory or as Heroku config variables (if you're hosting in Heroku, see image below).

If you don't know how to get Google's API credentials, I recommend this video.

The .env file should be as follows:

DISCORD_TOKEN =
SPREADSHEET_KEY =
MONGODB_ATLAS_URI =

Heroku's config variables should be set as follows:

Heroku Config Variables

DISCORD_TOKEN

You must create a discord application in here and a bot inside it. The token needed is the bot's one, that can be found in https://discord.com/developers/applications/<APPLICATION ID>/bot - as can be seen in the image below.

Where to get the DISCORD_TOKEN

SPREADSHEET_KEY

Get it from the spreadsheet's link: https://docs.google.com/spreadsheets/d/<SPREADSHEET_KEY>. You must share the spreadsheet with your bot's email (from the Google Sheets API, it should be specified in your credentials.json).

MONGODB_ATLAS_URI

Some commands I implemented - like the ones to track meetings and that use counters - depend on a database, for which I used MongoDB, specifically Mongo Atlas. For it to work right away, you just need to create a cluster of your own, put the connection URI in the .env and create in it a cluter, a database and a collection, all of them named discord-bot.

Inside the database, create three objects as in the images below - byProject and byDay being empty objects, roles being an empty array, and counters being an object in which the keys are the names of the commands in the Counters.py cog and the values are any int number.

Mongo Atlas Database Organization

Google Sheet

The spreadsheet must have a sheet named commands and a sheet named triggers with the specifications below.

Commands' worksheet

It must have the following columns:

  • "COMMAND CATEGORY"
    • All commands of a same category must be adjacent, otherwise only the last "block" will be used. "COMMAND NAME"
    • Can't contain special characters nor whitespace.
  • "COMMAND ALIASES"
    • Multiple aliases should be separated by a linebreak;
    • Do not include the command name.
  • "RESPONSE TEXT" - the reply's text content
  • "RESPONSE IMAGE"
    • Public links to the reply's image contents
    • Maximum of 10 images, separeted by linebreaks;
    • The links should take directly to the images
  • "TTS" - if that command should be read by discord's text-to-speech
  • "REPLY" - if the response should be sent as a reply

'commands' sheet

Triggers' worksheet

It must have the following columns:

  • "TRIGGER" - message content that'll trigger the reply below
    • Write it in lowercase - detection is not case-sensitive;
    • Multiple triggers should be separated by a linebreak (Alt + Enter).
  • "RESPONSE TEXT"
  • "RESPONSE IMAGE"
  • "TTS" - if that command should be read by discord's text-to-speech
  • "REPLY" - if the response should be sent as a reply

'triggers' sheet

Hosting

It was designed to be in a Heroku dyno, but you may do it however you prefer.

The >codenames command uses Selenium and to make it work with Heroku, you must add the following buildpacks to your app.

Heroku Buildpacks

If you are hosting outside Heroku, you may need to comment out the SuperMarselo.py cog's 17th line and integrate a Chrome webdriver to the code manually.

discord-chatbot's People

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.