A Discord social bot for [Pistols at 10 Blocks)[https://pistols.lootunder.world/] Dojo game.
Based on: dojo.js/examples/node/torii-bot
Torii exposes dynamically generated models based on your world's models. We can use this to generate a GraphQL SDK for easy querying of the world.
You can access the GraphQL dashboard by navigating to https://api.cartridge.gg/x/pistols/torii/graphql or http://0.0.0.0:8080/graphql if your Torii is running locally.
It is recommended that each developer create their own bot on Discord for testing.
Give it wour name so we can identify each one, like: pistols-bot-joe
Contact us to get the test server invite and roles.
Follow the steps below to obtain your Discord Token and Application ID. You will also need to acquire your Discord channel ID where you want to send messages. You can obtain this by right-clicking on a channel in your Discord and selecting 'Copy Channel ID'.
Copy .env.example
to .env
and edit it. Replace the tokens for your own on .env
.
DISCORD_TOKEN=<DISCORD_TOKEN>
APPLICATION_ID=<APPLICATION_ID>
TORII_URL=https://api.cartridge.gg/x/pistols/torii
CLIENT_URL=https://pistols.lootunder.world
SOCIAL_APP_URL=https://pistols-social-app.vercel.app
pnpm install
For every new or updated query in src/graphql/
, you need to run...
pnpm run codegen
Now you can access the sdk in your app like:
import { sdk } from "../config.js";
const { data } = await sdk.getChallenges({ state });
pnpm run serve
pnpm run build --watch
Now, try running it on your server. Remember to restart your bot after making changes.
Following is a generic guide for development and deployment of a Discord bot. It is not necessary for servers that want to use add the bot, only for contributing developers.
-
Step 1: Go to Discord Developers and create a new application.
-
Step 3: Select the 'Bot' sidebar item and reset and save the Auth token. Store it in a .env file within your application. Do not share or commit this token. Ensure its confidentiality.
-
Step 4: Enable the switches as shown in the image below. Your app will not function properly without doing this.
-
Step 5: Choose the 'OAuth2' sidebar item and make the selections as shown. Opt for additional choices if you understand their implications.
-
Step 6: Determine the permissions for the bot. As our goal is only to send messages, that's what we'll select.
-
Step 7: Navigate to the URL generated in the previous step and add the bot to your server.
Deploying these apps onto Railway is the easiest.
- Create Account
- Create a new project and deploy via git
- In your project settings
- Build is configured by
nixpacks.toml
OHAYO