Hello, Guest

By registering with us, you'll be able to discuss, share and private message with other members of our community.
What's new

Discord Integration | Discord Integration RAGE:MP

Alexalsaud

Administrative
Staff member
Admin
Joined
Aug 5, 2024
Messages
337
ICoins
1,301

Discord Integration | Discord Integration RAGE:MP


A library to link your RAGE:MP server to a Discord server (using a bot).

Library features:

  1. Sending messages to Discord from your RAGE: MP server.
  2. Sending messages to the RAGE:MP server from your Discord server.
  3. Ability for the bot to listen to a specific channel for further processing of messages
  4. Displaying the status of the bot
How to install and use:

  1. Add RAGEMP-DiscordIntegration.dll as a link to your project in Visual Studio.
    (How to do this - )
  2. Be sure to place the three provided Discord.Net.xx.dll in the runtime folder of your RAGE:MP server.
  3. Ready. Enjoy yourselves.
How to set up (connect Discord):

  1. Create a new app on .
  2. Also create a bot.
  3. Invite the bot to your Discord server.
  4. Use your bot's token to initialize your bot, as shown in the example below.
  5. Register/delete the channels where your bot sends messages to all players.
Script as an example of using this library:

JavaScript:
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)
{
// Обработка и отправка сообщений в дискорд при написании в чат сервера RAGE:MP
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);
}

}

 
Back
Top