About DiscordFB
This is a plugin for the game Rust that allows players to receive information about the server's Discord server.
Features:
- A join message that can be toggled on or off in the configuration file.
- A chat command called "discord" that players can use to receive the Discord server's invite link.
- A permission system to control who has access to the "discord" command.
Here's an explanation of the code:
The plugin uses the Oxide.Core and Oxide.Core.Libraries.Covalence libraries, as well as the Newtonsoft.Json and UnityEngine libraries.
The plugin's class is called "Discord" and inherits from the RustPlugin class.
The LoadDefaultConfig method is used to load the default configuration values for the plugin. It sets the values of showJoinMessage and discordInviteLink based on the values specified in the configuration file. If the values are not specified, it will use the default values specified in the method.
The LoadDefaultMessages method is used to load default messages for the plugin, which can be translated into different languages. In this case, it contains messages for "JoinMessage" and "NoPermission".
The plugin uses the "Chat Avatar" configuration value, which is set to "0" by default
The OnPlayerConnected method is called every time a player connects to the server. If showJoinMessage is set to true, the player will receive a message welcoming them to the server.
The TurboRankCommand method is the implementation of the "discord" chat command. It checks if the player has the "discord.use" permission before allowing them to use the command. If they do have the permission, they will receive the Discord server's invite link. If they do not have the permission, they will receive a message indicating that they do not have permission to use the command.
The GetConfig method is a helper method used to retrieve values from the configuration file. It takes a name and a default value as arguments, and returns the value associated with the name in the configuration file, or the default value if the name is not present in the configuration file.
The Lang method is a helper method used to retrieve messages from the plugin's messages file. It takes a key and an array of arguments as input and returns the formatted message.