IMC Feature

Chikachi edited this page Mar 11, 2018 · 2 revisions

Other mods can use IMC with DiscordIntegration to allow for listening to Discord messages and sending messages to Discord.

Send message

To send a message to Discord, you send a NBTTagCompound message with the key sendMessage to DiscordIntegration.

NBTTagCompound sendDiscordMessageTagCompound = new NBTTagCompound();
sendDiscordMessageTagCompound.setString("message", "Hello Discord");
sendDiscordMessageTagCompound.setLong("channel", 323197486179287041);
FMLInterModComms.sendRuntimeMessage(this, "discordintegration", "sendMessage", sendDiscordMessageTagCompound);

The message on Discord will be prefixed with [YourModNameHere].

Listen for events

To begin listening for Discord events, you simply send a string message with the key registerListener to DiscordIntegration.

FMLInterModComms.sendRuntimeMessage(this, "discordintegration", "registerListener", "");

To stop listening for events, you simply send a string message with the key unregisterListener.

FMLInterModComms.sendRuntimeMessage(this, "discordintegration", "unregisterListener", "");

Events

Documented in JSON format until I find a better way to document them.

Chat message

{                              // NBTTagCompound
  "type": "message",           // String
  "user": {                    // NBTTagCompound
    "id": "86368887284719616", // String
    "username": "Chikachi",    // String
    "discriminator": "0001"    // String
  },
  "message": "Hello World"     // String
}

Response

Responses are sent with either success or error as key.

Success example

{                            // NBTTagCompound
  "method": "sendMessage",   // String
  "message": "Sent"          // String
}

Error example

{                               // NBTTagCompound
  "method": "sendMessage",      // String
  "message": "Missing channel"  // String
}
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.