This addon will send in-game chat to a discord channel. It will also take any messages (and commands) sent in that same discord channel and send it in-game.
As an example, imagine if someone talks to you on your linkshell 3. You can see the chat in Discord on your phone, and you can reply to them in the in-game linkshell with:
!l3 Hello.
Anything you message in Discord that starts with ! will be processed as a FF14 chatbox input. !l3 Hello becomes /l3 Hello
—-
The Discord Chat Plug-in window is under the FFXIVMinion menu.
You will likely want a private server for this plug-in, for your own privacy.
Each bot token needs to be activated once it's created, before it can be used by the Discord Chat addon. This only needs to be done once. This is to allow the token to send messages to the server, and the activation form below only sends your token to Discord.
Paste the token into the form below, then hit Activate. Note that you must do this from your primary web browser, and not MMOMinion's built-in browser.
Under Channels, you can select which in-game channels to send to discord. You can optionally change the name of the channel.
Under Configuration, you can find these options:
When an external addon registers itself with DiscordChat, the external addon's Discord usage can be enabled or disabled under External Plugins
You can configure the addon to send messages in different chat channels in FF14 (such as Say, FC, LS1, LS4) to go to a different channel in Discord.
You can create multiple channels in your Discord server, Copy ID in Discord, and paste them in the Channels configuration window.
You can also specify a hex color to distinguish between messages. For example, ff0000 would give a red color, and 00ff00 would give a green color. You can use any color picker to select colors in this format.
If you enable (Experimental) Listen on channel, you can enable Listen on channels in the Channels menu. This will let you reply directly in separate chat channels.
You can specify specific keywords, that when said in chat, will notify you in discord with an @ mention. These can be found under the Bot Token/Channel menu. Your User ID can be obtained by right clicking yourself on Discord's Member List and selecting Copy ID
If you want to program your own commands and responses, you can program simple ones with custom commands. (You can more easily make complex ones using the public API in the next section.)
Under Custom Commands, define a prefix, and a response. A return value will be send back to the channel the command was sent in. There are two additional commands you can use, message and SendMessage. message is the discord message that triggered the response (you can simply return this to see what the contents are), and SendMessage is a command to send additional messages beyond the return value.
Here are two examples:
Returns your current HP
Prefix: hp
Code:
return Player.hp.current
Returns your current map and position
Prefix: pos
Code:
return GetMapName(Player.localmapid)..": <"..Player.pos.x..", "..Player.pos.y..", "..Player.pos.z..">"
Other plugins can send messages and listen for messages through a public API. With DiscordChat installed, you can call
my_module.SendDiscordMessage = discord_chat_api.Register(Plugin Name, Command Prefix, Command Callback)
and it will return you a function to send messages with.
Here's an example addon that sends and listens for commands.
-- Discord chat API example. -- -- Look for a global discord_chat_api variable. -- discord_chat_api.Register(Plugin Name, Command Prefix, Command Callback) -- returns a function, SendMessage(message) -- -- SendMessage will let you send a message through the bot -- Command Callback is a single argument function that takes a message whenever -- a discord message is sent with the prefix -- -- Note that there is currently a ~5 second delay in receiving messages -- and a ~2 second delay in sending local test_discord_plugin = {} test_discord_plugin.gui_open = true test_discord_plugin.received = {} function test_discord_plugin.ModuleInit() -- Menu item ml_gui.ui_mgr:AddMember({ id = "FFXIVMINION##TEST_DISCORD_PLUGIN", name = "Test Discord Plugin", onClick = function() test_discord_plugin.gui_open = not test_discord_plugin.gui_open end}, "FFXIVMINION##MENU_HEADER") -- Register with discord chat if discord_chat_api ~= nil then test_discord_plugin.SendMessage = discord_chat_api.Register( "test discord plugin", "test", test_discord_plugin.ProcessMessage) else test_discord_plugin.SendMessage = function(message) d("DiscordChat not installed", message) end end end function test_discord_plugin.ProcessMessage(message) d("Received Message") d(message) table.insert(test_discord_plugin.received, message.content) end function test_discord_plugin.Draw(event, ticks) if test_discord_plugin.gui_open then GUI:SetNextWindowSize(100,50,GUI.SetCond_FirstUseEver) test_discord_plugin.visible, test_discord_plugin.gui_open = GUI:Begin( "Test Discord Chat", test_discord_plugin.gui_open) if test_discord_plugin.visible then local pushed = GUI:Button("Send Message") if pushed then test_discord_plugin.SendMessage("Test Message From Plugin") end for _, recv in pairs(test_discord_plugin.received) do GUI:Text(recv) end end GUI:End() end end RegisterEventHandler("Gameloop.Draw", test_discord_plugin.Draw, "Test Discord Plugin") RegisterEventHandler("Module.Initalize", test_discord_plugin.ModuleInit)
The message passed into your registered callback looks something like this:
{ attachments = { }, author = { avatar = "...", discriminator = "0000", id = "...", username = "(name)", }, channel_id = "...", content = "!test message", embeds = { }, id = "...", mention_everyone = false, mention_roles = { }, mentions = { }, pinned = false, timestamp = "2019-04-05T05:56:35.531000+00:00", tts = false, type = 0, }