Giter Site home page Giter Site logo

swg-discord-bot's Introduction

Progor-Chat

Progor-Chat is a custom discord and SWGEMU client that links the two platforms together. Like Core3 is an SWG Server emulator, Progor-Chat acts as an SWG Client emulator. It sends the same packets the client would to login and select a character, then ignores all the packets the server sends about the world around the character, and only listens for packets related to Chat. When it receives chats in the channel specified, it forwards the content of those messages to the Discord client to post in it's specified channel. It also does the reverse - listens for discord messages and posts them in the in-game chat channel.

Since it's constantly in communication with the game server, it knows quickly when the server goes down. It will then post a message to a separate channel (can be the same or different) and mention a discord role - usually your staff / admin role - to quickly notify someone who can get the server back up.

Getting Started

First, create a discord bot. Go to https://discordapp.com/developers, fill out the name of your bot/app, make it public, give it a profile photo if you want, and save it. You don't need OAuth2 or Redirect URIs. This will give you the name and token you need later.

Then, invite the bot to your server. Use this link: https://discordapp.com/oauth2/authorize?client_id=CLIENT_ID&scope=bot but replace the Client_ID with the Client ID from the bot you just created.

Then, create a new game account (or use an existing non-admin account with a free character slot), with a character whose name will be present on every message that comes from discord. Relics of Corbantis named ours Discord. Log into this character, and leave them at the end of the tutorial in the instanced room where you select a planet. This is the quietest place in the galaxy (fewer stray packets to deal with), and a great place for aspiring bots to hide out. Finally, have this bot join the chat room you wish for it to speak in, and log out of your game client. For now, any time the server is rebooted, you'll need to stop the bot, log back into the character long enough for the client to join the channel, log back out, and restart the bot. This issue should be fixed in an upcoming release. One further note about the bot: it should NOT be an admin. Admin characters have additional text added to their chats, so the bot can't pick out it's own messages and ends up reposting them to discord. If a feature is added which requires an admin, additional config will be put in place to solve this issue.

Download this repository to a folder. cd to that folder and run

npm install

to install the necessary dependencies (like the discord client).

Create a file named config.json with these values populated with your server, account, character, and chat room / channel specifics. You can copy config.example.json to get you started. For instance:

{
    "SWG": {
        "LoginAddress": "my.server.com",
        "LoginPort": 44453,
        "Username": "SWGAccount",
        "Password": "SWGPassword",
        "Character": "Discord",
        "ChatRoom": "Genchat"
    },
    "Discord": {
        "BotName": "RoC-Bot",
        "BotToken": "<Bot-token-from-discordapp.com/developers>",
        "ServerName": "SWG Awesomeness",
        "ChatChannel": "general",
        "NotificationChannel": "admin-lounge",
        "NotificationMentionRole": "Staff"
    }
}
Field Explanation
SWG.LoginAddress The Address of the SWGEmu login server. This is what you point your launcher at.
SWG.LoginPort The Port of the SWGEmu login server. This is usually 44453
SWG.Username The Username you type in the SWG splash screen.
SWG.Password The Password you type in the SWG splash screen.
SWG.Character The Character you choose on the character select screen. First name only. Case matters.
SWG.ChatRoom The name of the ChatRoom it should replicate to/from. If nested in the tree, use dots, i.e. Chat.General.Main
Discord.BotName The App Name of the Bot you created in discordapp.com/developers
Discord.BotToken The App Bot User Token from the discordapp Bot page
Discord.ServerName The name of the discord server the Bot is monitoring
Discord.ChatChannel The name of the discord channel the Bot should replicate to/from
Discord.NotificationChannel The name of the discord channel that server up/down events should be posted to
Discord.NotificationMentionRole The name of the role that should be mentioned in up/down notifications

Finally run the bot with

node discordbot.js

Better yet, to handle any unexpected errors get forever

npm install -g forever

and run it with

forever start discordbot.js

Any issues? Add an Issue in github and I'll take a look as soon as I can.

swg-discord-bot's People

Contributors

dpwhittaker avatar reckoning-aso avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

swg-discord-bot's Issues

I must be missing something

I tried my best to follow the instructions. I am not a programmer and the instructions seem to be missing a few pieces.

  1. my computer doesnt recognize npm as a command nor any of the others at the bottom
  2. I have all your files in a folder like it said but nothing to run in the folder either.

not sure how to proceed

Upgrade Discord Bot

With the Latest SWGEmu updates, The discord bot seems to go offline within a few minutes, any updates? I've used the bot for a few years, after updating to the latest code it seems to bug out after just a few minutes, any help to resolve this issue ?

Bot stops working

Hey progor,
Hope you're doing well. So with the latest updates to Core3/engine3 it seems that the discord bot is having some major issues. The bot only works for 5 or so messages on average before it stops. The console doesn't seem to notice any issues and the bot stays connected. I'm attaching a log to see if anything jumps out at you
discordbot.log

Discord API Update

Hi,

I'm totally new to github and have near-zero programming experience in developer role so I'm posting here.

A recent change in the Discord API breaks the swg-discord-bot. It causes server.members.get(message.author.id).displayName to return "undefined". When I debugged, I found that the bot could only see itself when it pulled a list of members from the server/guild. I learned that the discord bot now needs to define its Intent in order to access members information.

Step 1: Go to the Discord Developer Portal, Select your swg-discord-bot App, Go to the Bot tab, turn on the switch for "Server Members Intent", and save the setting.

Step 2: Update the discord.js package using npm update discord.js

Step 3: Modify the discordbot.js source to declare the Intent

  1. Define a const "Intents" right after "Discord"
    const Discord = require('discord.js');
    const Intents = require('discord.js');

  2. Change the construct line to declare the Intent of the bot (I used Intents.ALL just to make it easy)
    //client = new Discord.Client();
    client = new Discord.Client({ws:{intents:Intents.ALL}});

I got the information about the Intents at the Discord.js Guide: https://discordjs.guide/popular-topics/intents.html#enabling-intents

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.