Hello There,
I want to send a custom message when a user join group.
But my code is not working, i guess it’s because channel id,
how can I find channel id of group?
this is my server code:
main.ts
initializer.registerAfterJoinGroup(afterJoinGroup);
hooks.ts
function afterJoinGroup(ctx: nkruntime.Context, logger: nkruntime.Logger, nk: nkruntime.Nakama, data: void, request: nkruntime.JoinGroupRequest) {
patchMetadata(nk, ctx.userId, {guildJoinDate: new Date()});
if (request.groupId == undefined)
return;
let user = nk.usersGetId([ctx.userId])[0];
nk.channelMessageSend(request,{
messageType:3,
displayName: user.displayName,
mainMessage:"",
reportedList:[],
isDeleted: false,
createdTime: new Date(),
channelId:"",
messageId:"",
isSelfMessage:false
} , ctx.userId, ctx.username, true);
}
function getChannelIdOfTeam(groupId: string) {
return "3." + groupId + "..";
}