Use hooks for remove system messages from chat channel

For example, after GroupUsersPromote client recieved system message with empty Content and Code != 0.
I need to intercept a system message received from a client.

I try to use this logic, but not success.

if err := initializer.RegisterBeforeRt("ChannelMessageSend", beforeChannelMessageSendHook); err != nil {
	return err
func beforeChannelMessageSendHook(ctx context.Context, logger runtime.Logger, db *sql.DB, nk runtime.NakamaModule,
	in *rtapi.Envelope) (*rtapi.Envelope, error) {

	message := in.GetChannelMessageSend()
	if message == nil {
		return in, nil

	if len(message.Content) == 0 || message.Content == "{}" {
		return nil, runtime.NewError(fmt.Sprintf("Remove system message"), int(core.GRPC_ABORTED))

	return in, nil

What am i doing wrong?

Hello @DInjection,

The system message cannot be intercepted with the hook as ChannelMessageSend is only triggered when the function is invoked from a client, and not when a system message is sent.

If you’d like to not display the user promoted system message, you should ignore it from the client.

You can identify these messages through their code.


Thanks for answer