• Like 4

[ALL] Registration Discord Bot 2.0.0

   (2 reviews)

1 Screenshot

bot.png.948e66a743aba034607aafcd8a005da6.png

Ember's Discord Registration Bot

This is a Python bot that allows users to register a TrinityCore account by direct messaging a bot with specific commands. Users' Discord identifiers are tied to the game account and both the Discord identifier and the TrinityCore username are checked for duplicates.

Current Compatibility
- TrinityCore 3.3.5

- Azerothcore

- CMangos (untested)

- Ashamane (untested)

ANY core should work, provided they have the following commands AND SOAP in the config -

- account set <account> <password> <password>

- account set gmlevel <rank> <realms>

- account create <account> <password> <password>

Requirements
- Python3
   - Packages: `mysql.connector`, `discord`

Installation Instructions

Create a Discord Bot
1. Access Discord's Developer Portal and create a `New Application`.
2. Navigate to the `Bot` section of your application settings and click `Add Bot`.
   - Set the username and profile icon of the bot.
   - Reset and save your bots `Token`.
   - No permissions are required, as the bot interacts via direct messages with users.
3. Navigate to `OAuth2` -> `URL Generator`.
   - In the `Scopes` section:
      - [x] `bot`
   - Copy the `Generated URL` and paste it into your browser to invite it to your server.
4. The bot should now be visible (though offline) in the server you invited it to.

Run the Bot
1. Edit the bot config file, [registration.cfg](/registration.cfg).
   - The `[mysql]` settings should match the database settings of the TrinityCore MySQL server.
      - There are potential issues with setting `host = localhost`. Use `127.0.0.1` instead.
      - A blank password will connect via the unix socket.
   - The `[discord]` settings should match the following:
      - `apiKey` is the bot `Token` generated above.
      - `targetServer` is the [ID of a Discord server](https://www.remote.tools/remote-work/how-to-find-discord-id) the bot is in.
      - `logsChannel` is the [ID of a Discord channel](https://www.remote.tools/remote-work/how-to-find-discord-id) in the server the bot is in.
      - `staff` is the [ID of a Discord role](https://www.remote.tools/remote-work/how-to-find-discord-id) required for "givemepowers"
   - The `[soap]` settings should match the following:
      - `host` is the SOAP.IP in worldserver.conf
      - `user` is a user capable of using account create, and set password commands in-game.
      - `pass` is the password for that user.
      - `port` is SOAP.Port in worldserver.conf
      - `soapRBAC` is the RBAC role provided when "givemepowers" is called.
2. Edit the worldserver config file, worldserver.conf
   - 1. Set SOAP.Enabled = 1
3. Run the bot.
   - Ensure [Requirements](#requirements) are met.
   - Run `discord_bot.py`

Registering via the Bot
1. Ensure the bot is online.
2. Direct message the bot using the following syntax:
   - `register <username> <password>`
3. If any errors occur during registration, the bot will let the user know.

Changing Password via the Bot
1. Ensure the bot is online.
2. Direct message the bot using the following syntax:
   - `account set password <newpassword> <newpassword>`
3. If any errors occur, the bot will inform the user.

Distributing Staff Powers via the Bot
1. Direct message the bot using the following syntax:
   - `givemepowers`
2. If any errors occur, the bot will inform the user.

To Do
- Give a command to authorize GM accounts under the right circumstances
- Add OS specific instructions
- Provide better instructions to maintain safe user permissions and practices

Disclaimer
Anyone who uses this on their server is capable of logging passwords. Encourage your users to provide throwaway passwords or unique passwords. This is a potential way to steal credentials, so it's ethical that all users should be aware and instructed to create unique passwords for your server.

 

This bot uses the SOAP API to register accounts. So long as your core can handle the above commands and can support SOAP, this bot will work with it.

 

Contribute
If you'd like to contribute, please fork and create a pull request via the GitHub. Your code will be reviewed and then merged with the main branch.

 

Your bot is now running. Congrats! If you have any errors, please post them here.

If you'd like, please join Ember, where this content will be actively used and further developed.

Thank you for reading, and thank you for your time.

 

OLD INSTRUCTIONS WITH PICTURES AND LINUX SPECIFIC COMMANDS -

Spoiler

 

What does this do?

This is a bot that allows user registration via direct messaging from a user to the bot. No longer does anyone need to make a website with some insecure method of creating a user.  This bot allows users to register by direct messaging the bot, and with a command, the users can create their in-game account. Their discord ID is also tied to the new account, and the bot checks for if the discord ID is already registered or if the username is also registered.

It is currently formatted to work with WotLK TrinityCore databases, but any experienced programmer can edit the queries in the file to work with any version.

The bot also runs off of python, so it should be easily accessible to any operating system.

 

 

How do I make a bot?

First you'll obviously need a bot. The link below takes you to the discord developer program, which you'll need to login to access.

https://discord.com/developers/applications

Then you'll need to click "New Application" in the top right corner of the apps screen that you'll be taken to.

image.thumb.png.212efba1541b42594e5af35383cfdde2.png

It will take you to a new screen where you can name your application. Name it whatever you want, give it whatever description you want, as the application and bot information are separate.

After that, click on the "Bot" option on the left side of the screen.

image.png.47bb581627cf3e6c05b7ca903e35a02d.png

Here you can edit your bot's profile icon, their username, and their permissions. 

There's also a "Token" button, which we will return to later. Keep in mind where it is.

image.thumb.png.494faba4e866ad395beb2bc6d7fe781c.png

At the bottom of the page, you can give your bot Administration permissions. However, it's easier to make a "Bots" role in your discord server to give to the bot when it joins Discord server.

In order for your bot to join your discord server, you will have to click on OAuth2 on the left side, and then URL Generator dropdown.

479b005e278a60b173e806dd5fb308d0.png

In order for your bot to work, you'll need the "bot" checkbox marked.

Here you can also add Administration privileges, but as stated earlier, it's easier to make a "Bots" role for your discord server instead.

e537ba6371c7c40db907c808a83888d0.png

Once done, a link will be generated at the bottom. Copy that link and paste it into your browser.

You'll then be prompted to invite your bot to a selectable discord server. In order to add a bot to your server, you'll need to make sure you have the "Manage Server" permission in your discord server first.

0967e25e4fa4e910eb1fb69411a74309.png

Once done, your bot should now be in your server! Make sure to apply the "Bots" role if you made one.

 

Now what?

So you've got your bot in your server, but it's offline! The bot will stay offline until a script connects to it via the bot token.

Remember that token? From earlier? Scroll up if you need a refresher!

But you will need to access your bot via the discord development portal and click "Reset Token". Make sure to copy this somewhere as it will be the only time you can access it.

Next, download the 2 files from this thread. Put them somewhere in your server.

 

You will need to edit the bot config file, "registrationconfig"

e1a27b3036d1fcfc7181f23a68a2ed9d.png

You can use the same login information that your worldserver uses. Make sure the auth database and characters database are named correctly, and that your ports are also correct.

Nerd shit - I've found success in keeping the password blank and keeping the host as 127.0.0.1. There seems to be issues using "localhost" as a host, so don't use that. A blank password will connect via the unix socket, which only allows local connections as well.

 

You will also need to get the IDs for the following information - Your API key (the token from earlier), your Discord server ID, and the log channel that the bot will output to.

To get the IDs for this information, you will need to go into your user settings on the bottom left. Click "Advanced" and make sure that "Developer Mode" is checked.

f04346598a0443a6d24957c23f284b92.png

Now that Developer Mode is enabled, right click your discord server and click "copy ID". Paste it into the config.

You can do this for the channel you want the logs to be in as well.

 

Booting the Bot

The following instructions are for linux:

- Change to your directory where the files are, using "cd <directory you put your files in>"

- Then you will need to install python. Make sure you have sudo available for this step. Type "sudo apt-get install python3"

- Once python is installed, you will need to install the required python packages. Use the following commands:

- "pip install mysql.connector"

- "pip install discord"

- Once that's all done, we can run the bot. Type "python3 discord_bot.py"

 

If you'd like to keep the bot running at all times so you can do something else on linux, check out "apt-get install screen" along with its manual pages.

 

Registering via bot

Now that the bot is running, it should be online.

Any user can direct message the bot, and with the syntax "register <username> <password>"

If any errors occur during the registration, the bot will let the user know.

 

To Do

Give a command to authorize GM accounts under the right circumstances

Add Windows instructions

Detail screen more and its usage

Provide better instructions to maintain safe user permissions and practices

 

Beware

Anyone who uses this on their server is capable of logging passwords. Please encourage your users to provide throwaway passwords or unique passwords. This is a potential way to steal credentials, so it's ethical that all users should be aware and instructed to create unique passwords for your server.

 

 

 





User Feedback