Skip to main content

OnGuildChat

public ChatEventHandler OnGuildChat;

Argument

ValueTypeDescription
argsChatEventArgsMessages arrived at the connected channel / Errors occurred during message transmission

ChatEventArgs

ValueTypeDescription
ErrInfoErrorInfoSuccess/failure information
FromSessionInfoInformation on the chat message sender
MessagestringChat message content

Description

This event is called when the user sends a message to the chat channel.

  • It is called when the user themselves or another user sends a chat message.

In order for an event to be called, the message sending/receiving method must be called.

Example

// First way
Backend.Chat.OnGuildChat = (ChatEventArgs args) =>
{
Debug.Log(string.Format("OnGuildChat {0}", args.ErrInfo));

if(args.ErrInfo == ErrorInfo.Success)
{
if(!args.From.IsRemote)
{
Debug.Log("Me : " + args.Message);
}
else
{
Debug.Log(string.Format("{0} : {1}", args.From.NickName, args.Message));
}
}
else if(args.ErrInfo.Category == ErrorCode.BannedChat)
{
// Spam prevention message
if(args.ErrInfo.Detail == ErrorCode.BannedChat)
{
Debug.Log("You have entered too many messages. Please try again after some time.");
}
}
};

// Second way
Backend.Chat.OnGuildChat += (args) => {
// Same logic as the first way
}

Argument cases

When the chat message is received ErrInfo : ErrorInfo.Success
message : "Received chat message"

When the number of messages sent exceeds the spam prevention count set in BACKND Console ErrInfo.Category : ErrorCode.BannedChat ErrInfo.Detail : ErrorCode.BannedChat ErrInfo.Reason : "Spam prevention message that has been set"