DiscordRewards

DiscordRewards 0.2.4

Reward players with items, kits and commands for being a member of your Discord

- Users claim a token via chat command which they then DM to your bot in Discord, or post in a specific channel of your Discord guild to gain access to the reward store
- Set re-validation times so users must regularly validate via your discord to continue receiving rewards
- Give players groups and permissions when validated, and remove them when the re-validation period has expired
- Give players roles in your Discord when validated, and remove them when the re-validation period has expired
- Run commands when a user has been validated
- Give rewards via a UI reward selector, or disable it and only give groups/permissions or run commands
- Option for additional rewards for Nitro Boosters
- Add as many or as little items, kits and commands to the reward selector as you want
- Set cool down times for each reward or use a global cool down that affects all rewards, which allows users to either select 1 reward at a time, or have access to multiple rewards
- Set a custom status message for your bot


This plugin requires the Discord extension available on uMod -> https://umod.org/extensions/discord


Using the plugin
Users can access rewards by typing /discord in chat.


d955acc42453cce84cc96282df45fffe.png


785fec4bdca72f304c7e8a7c1002c779.png



If they have not yet validated they will be prompted to confirm their account by typing "/discord token" in chat. They will then be issued a token which they will need to DM to the bot on your server, or post in a designated channel.

bottoken.png


Once they have sent a DM to the bot with their validation token (a unique 6 digit number) the bot will notify them is it was a success and they can then type /discord in game to access the reward store.

Alternative rewards will be automatically applied to the player when they DM the bot. If they are not on the server when that happens alternative rewards will be applied when they next join the server


Creating a Bot account
In order to validate users in your Discord you must create a bot account. This is quite a simple task;

1) Make sure you are logged in on the Discord website -> https://discordapp.com/

2) Navigate to the Applications page -> https://discordapp.com/developers/applications/

3) Click "Create an application"
myapps.png


4) Name your application and save the changes

5) You should now see something like the picture below. Note the "CLIENT ID", this is the "Bot Client ID" field in your config
app2.png


6) Click the "Bot" button on the left hand side, then click "Add Bot". This will create a bot for your application

7) Name your bot, toggle "Public Bot" to the off position, and give the bot the "Send Messages" permission and the "Manage Roles" permission if you are planning on giving Discord roles as rewards.

8) Scroll down to the section labelled "Privileged Gateway Intents" and toggle on both "Presence Intent" and "Server Members Intent"
discordbotupdate2.png


9) Click to reveal the bots "Token". This is the "Bot Token" field in your config, so copy it to your config now.
bot.png


10) Save your changes and exit. Your bot is now ready to join your Discord.


Inviting your bot to your Discord
Now you have created your bot you need to invite it to your Discord server.

Code:
https://discordapp.com/oauth2/authorize?client_id=YOUR_CLIENT_ID&scope=bot&permissions=2048

Copy the link above and replace "YOUR_CLIENT_ID" with the client ID we saw in step 5. Paste this link in your browser and you will be prompted to select a server for the bot from the list of servers you own.

Select the server you want the bot to join and hit Authorize.
auth.png


Thats it, your bot is now on your server. Make sure you have pasted the required details in to your DiscordRewards config so the plugin can communicate with your Discord server!


Adding/Removing/Editing Rewards
The reward setup is very similar to ServerRewards if you are familiar with it. Using the console commands provided below you can add/remove/edit your rewards.

Item icons are used retrieved automatically via ImageLibrary, and Kit/Command icons can be set if you specify a URL. You can also replace item icons with custom images the same way.
Alternatively you can host these images on your Rust server in your "oxide/data/DiscordRewards/Images" folder. If you are using that method then only specify the filename in the icon field for that item

You can add or remove multiple commands in your command rewards after you have created the initial command by typing discord.rewards edit command edit <add/remove> "command"

Commands have 5 parameters you can insert in to them that will be replaced by the users information
$player.id - The users Steam ID
$player.name - The users display name
$player.x, $player.y, $player.z - The users position

By placing any of those in your command they will be replaced with the respective information of the player using the command

All rewards require a cooldown even if you are using the global cooldown option

To add rewards that only Nitro Boosters can claim, add the word "nitro" to the end of the add command

Alternative Rewards
Alternative rewards can include the user being added to specified user groups, giving them roles on your Discord, granting the user permissions, or running commands when the user has validated

Permissions, Groups and Discord Roles only last as long as the user has a valid token (see Revalidation Interval below). Once the validation time has expired users are automatically removed from the groups and the permissions are revoked until they perform the validation process again

To add Discord roles simply put the name of the role exactly as typed in Discord in the "Discord roles to grant on successful validation" section of your config

Commands are run 1 time when the user has completed validation. Like the commands available via the reward selector there are 5 parameters you can insert in to them that will be replaced by the users information

$player.id - The users Steam ID
$player.name - The users display name
$player.x, $player.y, $player.z - The users position

Nitro Booster Rewards
Just like the alternative rewards, there are additional groups, permissions and commands that can be run on/given to nitro boosters.

To give rewards to Nitro Boosters simply enter the booster role name in the Settings/Nitro boost role name section of the config. You can then add groups, permissions and commands to the config.

If you want to give nitro specific item/kit/command rewards through the UI menu, simply add the word "nitro" to the end of any "add" command when adding the reward. The reward will appear in the UI with a pink button

Setting a custom bot status message
You can set a custom message for your bot by modifying the "Bot Status Message" option in the config. By default this is empty, and you can put what ever you like in there.

I have also included 3 variables that will get replaced with information when setting the message;
{playersMin} - Displays the current amount of players on your server
{playersMax} - Displays your server capacity
{rewardPlayers} - Displays the current amount of players who are receiving rewards from this plugin and have a valid token

ex 1. "Players Online {playersMin} / {playersMax}" will show "Players Online 10 / 100" if you have 10 players on a 100 slot server
ex 2. "Discord Members {rewardPlayers}" will show "Discord Members 500" if you have 500 users with valid tokens
ex 3. "Hello I am a bot" will show exactly that


Chat Commands
/discord - Opens the reward selector
/discord token - Request a validation token


Console Commands
discord.admin purge - Clear all users with expired tokens from the data file
discord.admin wipe - Revoke rewards from all players and invalidate their tokens
discord.admin revoke <player ID> - Revoke all rewards from the target player and invalidate their token

Reward Add/Edit/Delete Commands
discord.rewards - Shows help menu

--- List Rewards ---
discord.rewards list <items | kits | commands> - Display a list of rewards for the specified category, which information on each item

--- Add Rewards ---
discord.rewards add item <shortname> <skinId> <amount> <cooldown> <opt:bp> - Add a new reward item to the store (add "bp" to add the item as a blueprint)
discord.rewards add kit <name> <kitname> <cooldown> - Add a new reward kit to the store
discord.rewards add command <name> <command> <cooldown> - Add a new reward command to the store

To limit the reward to Nitro Boosters only, simply add the word "nitro" to the end of the command.
ex. "discord.rewards add item rifle.lr300 0 1 600 nitro"

--- Editing Rewards ---
discord.rewards edit item <ID> <name | amount | cooldown> "edit value" - Edit the specified field of the item with ID number <ID>
discord.rewards edit kit <ID> <name | description | icon | cooldown> "edit value" - Edit the specified field of the kit with ID number <ID>
discord.rewards edit command <ID> <name | amount | description | icon | add | remove | cooldown> "edit value" - Edit the specified field of the kit with ID number <ID>
Icon field : The icon field can either be a URL, or a image saved to disk under the folder "oxide/data/DiscordRewards/Images/"
Command add/remove field: Here you add additional commands or remove existing commands. Be sure to type the command inside quotation marks

--- Removing Rewards ---
discord.rewards remove item <ID #> - Removes the item with the specified ID number
discord.rewards remove kit <ID #> - Removes the kit with the specified ID number
discord.rewards remove command <ID #> - Removes the command with the specified ID number

--- Important Note ---
Removing rewards may change each rewards ID number. Be sure to list your rewards before removing them


Config Options
Token Lifetime (seconds) - This is the amount of time from when the Discord bot has sent a user their validation token until it expires

Revalidation Interval (seconds) - This is the amount of time from when a user has entered their validation token ingame until they will need to re-validate

Automatically try and re-validate users when their token has expired - When a users token has expired this will check to see if they are still in the Discord, if so it will automatically re-validate the user

Bot Token & Bot Client ID - Described above in the steps to set up your Discord bot

Bot Status Message - Allows you to set a custom status message for your bot (see above)

Use Global Cooldown - This will create a global cooldown on all items, so a user can only claim 1 reward at a time. If this is false then users can claim all rewards and will be limited by their individual cooldowns

Global Cooldown Time (seconds) - The cooldown time for a global cooldown

Enable Reward Menu - Enables the UI reward selector. Set this to false if you only want to grant permissions/groups

Require Re-validation - Enable the re-validation process, forcing users to go through the validation process at the interval you specify

Add user to user groups - A list of user groups to add the player to upon validation.
Example usage: "Add user to user groups": [ "group1", "group2" ],

Permissions to grant on successful validation
- A list of permissions to grant the user upon validation
Example usage: "Permissions to grant on successful validation": [ "rustnet.use", "grenadelauncher.spawn"],

Commands to run on successful validation
- A list of commands to run when a player is validated
Example usage: "Commands to run on successful validation": [ "spawncar $player.x $player.y $player.z"],

Discord roles to grant on successful validation -
A list of Discord roles to grant when a player is validated
Example usage: "Discord roles to grant on successful validation": [ "Test Role"],



Config
JSON:
{
  "Settings": {
    "Bot Token": "",
    "Bot Client ID": "",
    "Bot Status Messages": [],
    "Bot Status Cycle Time (seconds)": 120,
    "Log Level (Verbose, Debug, Info, Warning, Error, Exception, Off)": "Info"
  },
  "Alternative Rewards": {
    "Add user to user groups": [],
    "Commands to run on successful validation": [],
    "Permissions to grant on successful validation": [],
    "Discord roles to grant on successful validation": [],
    "Discord roles to revoke on successful validation": [],
    "[Nitro Boosters] Add user to user groups": [],
    "[Nitro Boosters] Commands to run on successful validation": [],
    "[Nitro Boosters] Permissions to grant on successful validation": []
  },
  "Validation Tokens": {
    "Token Lifetime (seconds)": 3600,
    "Require Re-validation": true,
    "Automatically try and re-validate users when their token has expired": true,
    "Revalidation Interval (seconds)": 84600,
    "Revoke rewards and wipe token data on map wipe": false,
    "Reset reward cooldowns on map wipe": false,
    "Validation channel": ""
  },
  "Global Cooldown": {
    "Use Global Cooldown": false,
    "Global Cooldown Time (seconds)": 84600
  },
  "UI Options": {
    "Enable Reward Menu": true,
    "Selected Button Color": {
      "Hex": "#6a8b38",
      "Alpha": 1.0
    },
    "Deselected Button Color": {
      "Hex": "#007acc",
      "Alpha": 1.0
    },
    "Close Button Color": {
      "Hex": "#d85540",
      "Alpha": 1.0
    },
    "Claim Button Color": {
      "Hex": "#d08822",
      "Alpha": 1.0
    },
    "Nitro Color": {
      "Hex": "#dc16f5",
      "Alpha": 1.0
    },
    "Background Color": {
      "Hex": "#2b2b2b",
      "Alpha": 1.0
    },
    "Panel Color": {
      "Hex": "#232323",
      "Alpha": 1.0
    }
  },
  "Version": {
    "Major": 0,
    "Minor": 2,
    "Patch": 0
  }
}
  • exa.png
    exa.png
    4.4 KB · Views: 10,077
  • valida.png
    valida.png
    6.5 KB · Views: 10,086
  • 616e453129d3e8c548c974cb622b7d74.png
    616e453129d3e8c548c974cb622b7d74.png
    164.8 KB · Views: 5,211

Information

Author
k1lly0u
First release
Last update
Rating
4.31 star(s) 13 ratings

Latest Release v0.2.4

Released
Dec 20, 2022 at 3:03 AM
Rating
0.00 star(s) 0 ratings


More resources from k1lly0u

  • Juggernaut
    Juggernaut
    A minigame where 1 player becomes a juggernaut and must make it to a set destination in order to win
  • PlayerSkins
    PlayerSkins
    Fully Customization Skin Management Plugin - Sell Skinned items or Skins!
  • Grenade Launcher
    Grenade Launcher
    Fire grenades from a shotgun
  • AlphaLoot Profile Editor
    AlphaLoot Profile Editor
    Unity based loot table editor for AlphaLoot
  • AlphaLoot
    AlphaLoot
    Provides complete control on loot contents of each available lootcontainer

DiscordRewards by k1lly0u
© chaoscode.io Dec 21, 2018

Latest reviews

I was using the free version of Discord Rewards and it stopped working so I thought it was worth the investment in the paid version because that means it will be maintained. Within a single update it stops working due to errors that eventually crash my server so i try and raise a support issue. I am a patreon of the Developer and respect his previous work but i can't even get a response. Its a great plugin when it worked. I am sure it will eventually get fixed when more people complain but in the meantime my players wait.
Great plugin - especially after adding the Nitro Booster features! We use this to grant VIP perks to Nitro Boosters and it greatly simplifies the process!
Been using this for the past year, helps to get players on the Discord and continue to give rewards to people who stay active on it.
Great plugin! So worth it. A must for server owners! - So more advance then the free ones. Buy it!!
This is a must plugin, more advanced than the free ones:)
took me a while to figure out but in the end worked as intended great resource.
This plugin is excellent! Everyone needs this plugin in their lives. Quality support from the dev.
No help or support for this Plugin and its not working how it should.
Great plugin and issues are actively fixed.
I've been waiting for a plugin like this for a while now. So glad you finally made it. Working great! Thank You!