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 } }ServerConfig is more limited right now as there already plugins out there to notify the server when a player connects/disconnects.
- 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.
DiscordAPI
Moved
Total Downloads: 1,971 - First Release: Sep 21, 2016 - Last Update: Jun 8, 2017
- 5/5, 3 likes
-
very greatful for you help thou
[DOUBLEPOST=1476844745][/DOUBLEPOST]and this is for the actual discord plug in not RustNotifications -
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"
-
[DOUBLEPOST=1476889325][/DOUBLEPOST] -
I'm getting
{
"code": 0,
"message": "Invalid Request"
}
with the plugin and when testing with Postman -
Did you follow the tutorial and authorize the bot to post on your channel?
-
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. -
-
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"); }
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
-
Wulf Community Admin
-
-
Wulf Community Admin
-
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"}
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"); }
-
Wulf Community Admin
-
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"); }
-
Wulf Community Admin
-
[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"); }
JSONLint - The JSON Validator.
but it still shows an error
[DOUBLEPOST=1480477540][/DOUBLEPOST]this is what it looks like after doing soAttached Files:
-
-
Wulf Community Admin
-
Code:
[Oxide] 19:51 [Warning] [Discord] Discord Api responded with 400: {"code": 0, "message": "Invalid Request"}
-
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.