DiscordAPI

Moved

Total Downloads: 1,971 - First Release: Sep 21, 2016 - Last Update: Jun 8, 2017

5/5, 3 likes
  1. I dont use the plugin

    Setup
    To use this plugin the file Slack.cs must also be loaded from your server's plugin directory. Do this by dropping theSlack.cs file into the plugin directory, review that plugins notes for setup information. Repeat the steps with Discord.cs. These two steps are optional if you only want server notifications, but if you want to make use of Slack or Discord functionality then these two plugins will need to be loaded.

    Next drop RustNotifications.cs into the servers plugin directory, if the server is running it should automatically recognize and build the plugin and create the default configuration file. If the server isn't running, the config file will be created the next time the server is started.

    Configuration

    The default configuration file will look like this:
    Code:
    {
      "DiscordConfig": {
        "Active": false,
        "DoLinkSteamProfile": true,
        "DoNotifyWhenBaseAttacked": true,
        "DoNotifyWhenPlayerConnects": true,
        "DoNotifyWhenPlayerDisconnects": true,
        "NotificationCooldownInSeconds": 60
      },
      "ServerConfig": {
        "Active": true,
        "DoNotifyWhenBaseAttacked": true,
        "NotificationCooldownInSeconds": 60
      },
      "SlackConfig": {
        "Active": false,
        "DoLinkSteamProfile": true,
        "DoNotifyWhenBaseAttacked": true,
        "DoNotifyWhenPlayerConnects": true,
        "DoNotifyWhenPlayerDisconnects": true,
        "NotificationCooldownInSeconds": 60
      }
    }
    • Active: Switch to turn slack notifications on/off.

    • DoLinkSteamProfile: Switch to turn off link to steam profile on notifications (NOTE, this only works for Slack notifications right now).

    • DoNotifyWhenBaseAttacked: Switch to turn notifications for base attacks on/off.

    • BaseAttackedMessageTemplate: Template message to display on notifications for base attack. {Attacker} and{Defender} will be replaced with the Steam Display Names of the attacker and defender respectively. NOTE If the defender is online the message will send to them through the ingame chat command. If the player is offline it will go to the slack channel.

    • DoNotifyWhenPlayerConnects: Switch to turn notifications for player connections on/off.

    • PlayerConnectedMessageTemplate: Template message to display on player connections.

    • DoNotifyWhenPlayerDisconnects: Switch to turn notifications for player disconnections on/off.

    • PlayerDisconnectedMessageTemplate: Template message to display on player disconnections.

    • NotificationCooldownInSeconds: Time to wait between base attacked notifications. This is on a per player basis. Meaning if two players have their bases attacked inside the cooldown period, they will both receive messages.
    ServerConfig is more limited right now as there already plugins out there to notify the server when a player connects/disconnects.
     
  2. thank you but this is what my config looks like maybe someone running these plugins may be able to help:) very greatful for you help thou :)
    [DOUBLEPOST=1476844745][/DOUBLEPOST]and this is for the actual discord plug in not RustNotifications
     
  3. I checked out your Discord.json. It doesn't help me troubleshoot too much. Did you follow this guide to set up your Bot on your discord server?
    Discord - Free voice and text chat for gamers

    Also, it might be helpful to double check your setup with a program like Postman to actually make sure the authentication works outside of the plugin.
    The plugin basically translates to a POST method with the following details:

    Code:
    BaseURL: https://discordapp.com/api/channels/{{ChannelID}}/messagesHeader
    Authorization : "Bot <BotToken>"Body
    content : "This is a test message"
    
     
  4. yes i have already set the bot up and it is in my discord channel
    [DOUBLEPOST=1476889325][/DOUBLEPOST]
    and could i maybe get a link to postman?
     
  5. I'm getting
    {
    "code": 0,
    "message": "Invalid Request"
    }
    with the plugin and when testing with Postman
     
  6. Did you follow the tutorial and authorize the bot to post on your channel?
     
  7. Yea i did, did some research, turns out new bots need to have a successfull websocket connection before it will accept http requests.
    which required me to setup a seperate bot (i used MusicBot) had it make a connection to the server then the bot would accept http requests.
     
  8. Gotcha, thanks a bunch for looking into that. I think some others might've had that issue before too. I'm not sure why it didn't show up with me, I think I might've done it accidentally while testing connectivity at the start.
     
  9. Code:
    {
      "BotToken": "xxxxxID WAS HERE NOT THE PROBLEMxxxxxx",
      "ChannelID": XXXID WAS HERE NOT THE PROBLEMXXXX
    }
    [PluginReference]
    Plugin Discord;
    Discord.Call(
        "SendMessage",
        "<Your message text goes here>"
        );
    if(!Discord)
    {
      PrintWarning("Discord not loaded correctly, please check your plugin directory for Discord.cs file");
    }
    im not whats wrong but its not working am i missing something?

    Code:
    (17:54:34) | [Oxide] 17:51 [Info] Loaded plugin Discord v0.2.0 by seanbyrne88
    (17:54:34) | [Oxide] 17:51 [Error] Discord v0.2.0: Failed to load config file (is the config file corrupt?) (Additional text encountered after finished reading JSON content: [. Path '', line 5, position 0.)
    (17:54:34) | [Oxide] 17:51 [Error] Failed to initialize plugin 'Discord v0.2.0' (JsonReaderException: Additional text encountered after finished reading JSON content: [. Path '', line 5, position 0.)
    (17:54:34) | [Oxide] 17:51 [Debug]   at Newtonsoft.Json.JsonTextReader.Read () [0x00000] in <filename unknown>:0
      at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType, Boolean checkAdditionalContent) [0x00000] in <filename unknown>:0
     
  10. Wulf

    Wulf Community Admin

    Why are you editing the plugin itself? That error is saying that your .json config is invalid, as in not a valid JSON format.
     
  11. im very new to these stuff sorry i kinda understand where i need to put it on now thanks for the help
     
  12. Wulf

    Wulf Community Admin

    Make sure the final file after you changes is valid JSON. You can copy and test it on a site such as www.jsonlint.com. If it fails the test, there's something off with the formatting of it.
     
  13. alright here is some update on what i did / Installed Discord Plugin first then RustNotifications configed both of them and added the discord bot into my channel then get this on the console
    Code:
    19:34:15) | [Oxide] 19:31 [Warning] [Discord] Discord Api responded with 400: {"code": 0, "message": "Invalid Request"}
    i'm kinda still confused on where to add

    Code:
    [PluginReference]
    Plugin Discord;
    Discord.Call(
        "SendMessage",
        "<Your message text goes here>"
        );
    if(!Discord)
    {
      PrintWarning("Discord not loaded correctly, please check your plugin directory for Discord.cs file");
    }
    to the discord config or the Rust Notification ?
     
  14. Wulf

    Wulf Community Admin

    The config for this plugin, under oxide/config.
     
  15. so the file that has this correct?
    Code:
    {
      "BotToken": "xxxxxx",
      "ChannelID": xxxxxx
    }

    so if i add it ,it should look like this
    Code:
    {
      "BotToken": "xxxxxx",
      "ChannelID": xxxxxx
    }
    [PluginReference]
    Plugin Discord;
    Discord.Call(
        "SendMessage",
        "<Your message text goes here>"
        );
    if(!Discord)
    {
      PrintWarning("Discord not loaded correctly, please check your plugin directory for Discord.cs file");
    }
     
  16. Wulf

    Wulf Community Admin

    Do not edit or modify the Discord.cs file at all, only edit the Discord.json config file.
     
  17. that is the discord.json
    [DOUBLEPOST=1480477472][/DOUBLEPOST]so from what you're saying i added

    Code:
    }
    [PluginReference]
    Plugin Discord;
    Discord.Call(
        "SendMessage",
        "<Your message text goes here>"
        );
    if(!Discord)
    {
      PrintWarning("Discord not loaded correctly, please check your plugin directory for Discord.cs file");
    }
    to the config and use

    JSONLint - The JSON Validator.
    but it still shows an error
    [DOUBLEPOST=1480477540][/DOUBLEPOST]this is what it looks like after doing so
     

    Attached Files:

  18. Wulf

    Wulf Community Admin

    No, you are trying to paste part of the actual plugin into the config file, that's not what you should be doing. What you change is in the Discord.json, that's all you should be changing. You aren't adding new lines to it, you modify the existing lines with the information from your Discord channel.
     
  19. hmmm weird its because im getting this error
    Code:
    [Oxide] 19:51 [Warning] [Discord] Discord Api responded with 400: {"code": 0, "message": "Invalid Request"}
     
  20. See this reply from Dubz:


    With the Discord API it looks like you need to have a successful connection before accepting HTTP requests. I'm at work right now so I can't dig up too much info, but this is likely the problem you're facing.

    Also, thanks Wulf for helping out.