message: Check if the user is in the room before kicking them
diff: @@ -281,6 +281,8 @@ export class MatrixHandler {
  return "You are not connected to any networks.";
  }
  + const intent = this.ircBridge.getAppServiceBridge().getIntent();
  +
  for (let i = 0; i < clients.length; i++) {
  const bridgedClient = clients[i];
  if (bridgedClient.chanList.length === 0) {
  @@ -305,7 +307,17 @@ export class MatrixHandler {
  // Don't wait for these to complete
  Promise.all([...uniqueRoomIds].map(async (roomId) => {
  + let state: {membership?: string};
  + try {
  + state = await intent.getStateEvent(roomId, "m.room.member", userId);
  + }
  + catch (ex) {
  + state = {};
  + }
  try {
  + // Only kick if the state is join or leave, ignore all else.
  + // https://github.com/matrix-org/matrix-appservice-irc/issues/1163
  + if (state.membership === "join" || state.membership === "invite" ) {
  await this.membershipQueue.leave(
  roomId,
  userId,
  @@ -315,6 +327,7 @@ export class MatrixHandler {
  this.ircBridge.appServiceUserId
  );
  }
  + }
  catch (err) {
  req.log.error(err);
  req.log.warn(
  