Jump to content
RAGE Multiplayer Community

[C#]RAGE:MP Discord Integration 1.0.1

   (9 reviews)

1 Screenshot

About This File

RAGEMP-DiscordIntegration
This wrapper allows you easily create an instance of a discord bot within your RAGE:MP server.

Features:
1. Send messages to discord from your RAGE:MP Server.
2. Send messages to your RAGE:MP Server from your Discord server.
3. Register specific channel for the bot to listen. (Can be changed during runtime).
3. Remove specific channel for the bot to STOP listening. (Can be changed during runtime).
4. Update bot status on setup and/or during runtime

 

How to use the wrapper

1. Add the RAGEMP-DiscordIntegration.dll as a reference to your project in visual studio.

2. Make sure to place the three provided Discord.Net.xx.dll into your server/runtime folder.

3. Enjoy))))

How to set up
1. Create a new application on Discord Developers
2. Create a bot.
3. Invite bot to discord server.
4. Use the token from your bot to initialize the bot as shown in the example below.
5. Register/Remove channels from where your bot sends to all players.

Example script.

using GTANetworkAPI;
using System;
using System.Collections.Generic;
using System.Text;

public class Yes : Script
{
    public Yes()
    {
        NAPI.Util.ConsoleOutput("Loaded: yes");
    }

    [ServerEvent(Event.ResourceStart)]
    public void OnResourceStart()
    {
        Integration.DiscordIntegration.SetUpBotInstance("TOKEN_HERE", "RAGE:MP", Discord.ActivityType.Playing, Discord.UserStatus.DoNotDisturb);
    }

    [ServerEvent(Event.ChatMessage)]
    public async void OnChatMessage(Player player, string strMessage)
    {
        string strFormatted = $"[RAGE:MP] {player.Name}: {strMessage}";
        await Integration.DiscordIntegration.SendMessage(3897429387492374, strFormatted, true).ConfigureAwait(true);
    }

    [Command("registerchannel")]
    public void RegisterDiscord(Player player, ulong discordChannelID)
    {
        bool bSuccess = Integration.DiscordIntegration.RegisterChannelForListenting(discordChannelID);

        player.SendChatMessage(bSuccess ? "Success" : "No Success");
    }

    [Command("removechannel")]
    public void RemoveDiscordChannel(Player player, ulong discordChannelID)
    {
        bool bSuccess = Integration.DiscordIntegration.RemoveChannelFromListening(discordChannelID);

        player.SendChatMessage(bSuccess ? "Success" : "No Success");
    }

    [Command("botstatus")]
    public async void UpdateBotStatusCommand(Player player, string gameName, Discord.ActivityType eActivityType, Discord.UserStatus eUserStatus)
    {
        await Integration.DiscordIntegration.UpdateBotStatus(gameName, eActivityType, eUserStatus).ConfigureAwait(true);
    }

}

Source code can be found on my github: https://github.com/JeremyEspresso/RAGEMP-DiscordIntegration

Bugs or feature requests and what not. Just open an issue on the github and I will take a look soon™️.


What's New in Version 1.0.1   See changelog

Released

Separated 0.3.7 and 1.1 in two folders.

  • Like 1

User Feedback

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest

Captien

   3 of 3 members found this review helpful 3 / 3 members

Thanks, my can now kick rp players from my server while sleeping in my comfy bed)

  • Like 1
Link to comment
ryzenje

   2 of 2 members found this review helpful 2 / 2 members

pamoinas resource

Link to comment
Bonus

   2 of 4 members found this review helpful 2 / 4 members

So good & noob friendly

Response from the author:

my is glad u are liking tnx

  • Like 1
Link to comment
Dakay

   1 of 2 members found this review helpful 1 / 2 members

works on 1.1, but sucks at 0.3.7 not working 

Response from the author:

Can you open an issue on the github repository and tell me what the issues are?

Link to comment
attacking

   1 of 4 members found this review helpful 1 / 4 members

i was waiting for this 😀

Link to comment
×
×
  • Create New...