Jump to content

[C#]RAGE:MP Discord Integration 1.0.1

   (11 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

Create an account or sign in to leave a review

You need to be a member in order to leave a review

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Captien

   5 of 5 members found this review helpful 5 / 5 members

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

  • Like 1
Link to review
ryzenje

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

pamoinas resource

Link to review
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 review
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 review
Tom Harper

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

Good shit brother!

  • Like 1
Link to review
attacking

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

i was waiting for this 😀

Link to review
×
×
  • Create New...