Jump to content

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

Recommended Comments

Create an account or sign in to comment

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

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
×
×
  • Create New...