Giter VIP home page Giter VIP logo

aws-discord-bot's Introduction

AWS-Discord-Bot
codebeat badge

Discord bot used for managing AWS instances including status and toggling on or off via chat commands in a Discord text channel Thanks to the writer of this article here for the very useful guide https://www.toptal.com/chatbot/how-to-make-a-discord-bot

To get started

  • Download node and aws-cli onto your machine https://nodejs.org/en/ https://aws.amazon.com/cli/
  • Run aws configure from command prompt on the machine you wish to host the bot from
  • Create a discord application here https://discordapp.com/developers/applications/ and create a bot user under it
  • Add the bot account to your discord server
  • Create a dedicated role on your discord server as well as a dedicated text channel for the bot
  • Gather the required credentials and IDs needed from AWS and Discord mentioned below

In the DiscordBot folder make a Json file called "config.json" and add the following values in this format

{
"BOT_TOKEN": "*Insert your discord bot token here*",
"ROLEID": "*Insert the Discord role ID of a role that only people you want using the bot have*",
"CHANNELID": "*Insert the Discord channel ID of the text channel where you want the bot to be controlled from*",
"ACCESSKEY": "*Insert the AWS generated access key here*",
"SECRETKEY": "*Insert the AWS generated secret key here*",
"SESSIONTOKEN": "*Insert the AWS session token here (may not be needed)*",
"INSTANCE": "*Insert the instance ID of the AWS instance you wish to toggle from the bot*"
"MESSAGELOGGING": "F" (or leave as 'T' if you want specific error messages logged to the Discord channel which may contain sensitive info like keys or instance IDs)
}

Command prompt into the DiscordBot folder and run

node src/Bot.js

Commands:

$aws start (Starts the specified instance)
$aws stop (Stops the specified instance)
$aws status (Returns information about the instance, i.e. if it is running, it's IP, it's last startTime)

You, and anyone else you give the role and channel access to, should be able to toggle the selected AWS instance on or off when needed as well as view instance information on demand.

aws-discord-bot's People

Contributors

jamesmatchett avatar robschn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

aws-discord-bot's Issues

I cannot run it in Centos 7.7.

I cannot run it in Centos 7.7.
nodejs and awscli are already installed.
The error log is as follows:
Unexpected string in JSON at position 321
at JSON.parse ()
at Object.Module._extensions..json (module.js:672:27)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object. (/root/DiscordBot/src/Bot.js:5:23)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)

$aws status error

When status is run in discord, the following is returned in discord:

Error getting status, TypeError: Cannot read property '0' of undefined

No difference if instance is running or not. Confirmed start and stop is working as expected.

Console error:

    at /home/ubuntu/AWS-Discord-Bot/DiscordBot/src/Bot.js:86:105
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

Instance name instead of Keypair Name

Thanks for building this, i'm using it at the moment.

One thing i noticed is that its returning key pair name for server name, thinking it might be better to get the instance name that's described through management console. The name is just a tag with the key 'Name'.

If you are accepting pull requests i can do it up.

Add command list to readme.md

Add the list of current commands to the readme so that the full functionality of the bot can be seen to any potential users.

Should be a continuously referenced issue each time a new feature is added, it should be added to the feature list on the readme

AWS CLI command forwarding

Allow commands for the AWS CLI to be forwarded from discord chat to the instance with resulting console output returned to the discord chat

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.