Awesome
Squire
Squire is a multitalented bot that interfaces with Discord and Twitter. Currently, this repo is heavily catered towards the needs of Bibliotheca DAO and the Lootverse in general.
However, further abstraction is needed to make this bot plug and playable by other teams. But by all means, fork him and customize.
What Squire currently does:
- Fetches Realm Information
- Fetches Crypts & Caverns Information
Contributing
Getting started
- Create a Discord App (bot) to test updates in your server.
- Visit the 'OAuth2' tab of the Discord Developer Portal and check the 'applications.commands' scope. Copy the generated URL and visit it to grant permissions to your bot.
- (optional) Request a Twitter Developer Account (with Elevated Access, then create a Twitter Developer App (make sure you change it to have both read/write permissions).
- (optional) Install Twurl and, using your Twitter Developer consumer key & secret, generate the access token & access secret.
Environment Setup
Edit example.env
with the following environment variables:
- DISCORD_TOKEN: A discord bot token created via the app's "Bot -> Build-a-bot" menu.
- DISCORD_CLIENT_ID: A discord bot client ID created via the app's "OAuth2" menu.
- DISCORD_GUILD_ID: A discord bot guild ID found via enabling Developer Mode.
- CONSUMER_KEY - Your Twitter Developer App's Consumer Key
- CONSUMER_SECRET - Your Twitter Developer App's Consumer Secret
- ACCESS_TOKEN_KEY - The Access Token Key of the Twitter Account your bot is posting from
- ACCESS_TOKEN_SECRET - The Access Token Secret of the Twitter Account your bot is posting from
- REALMS_CONTRACT_ADDRESS - The Ethereum address for the Realms contract. For example
0x7afe30cb3e53dba6801aa0ea647a0ecea7cbe18d
is the Mainnet contract address.
Running the bot
yarn && yarn start
How to make changes
Discord
Adding a slash command:
- Create new file in
/app/services/discord/commands
- Copy existing contents from another command (e.g. GA)
- Add a name to the function in the exports
- Include what you would like to return
- Add a graphql query to
/app/services/utils/graphql/index.ts
- Run locally and test on your own server
FAQ
Q: "I tried running my bot but get a 'Missing Access 50001' error"
A: This means that your application doesn't have permission for the discord server in question.
First, make sure you've granted the bot the applications.commands
OAuth2 scope Docs and visited the URL under the 'OAuth2' tab in the Discord developer dashboard for your bot.
Second, double check that your DISCORD_GUILD_ID
is set for the correct channel.
export NODE_TLS_REJECT_UNAUTHORIZED='0' export NODE_OPTIONS='--experimental-fetch'