using LibMatrix.EventTypes.Spec.State.RoomInfo; using LibMatrix.Services; using LibMatrix.Utilities.Bot.Interfaces; namespace MiniUtils.Commands; public class JoinCommand(MiniUtilsConfiguration config, HomeserverProviderService hsProvider) : ICommand { public string Name => "join"; public string[]? Aliases => []; public string Description => "Redact all user's events"; public bool Unlisted => false; public async Task Invoke(CommandContext ctx) { var profile = config.ExternalProfiles[ctx.Args[0]]; var rhs = await hsProvider.GetAuthenticatedWithToken(profile.Homeserver, profile.AccessToken, enableServer: false, useGeneric: true); var joinRules = await ctx.Room.GetJoinRuleAsync(); if (joinRules?.JoinRule is not RoomJoinRulesEventContent.JoinRules.Public) { await ctx.Room.InviteUserAsync(rhs.UserId); } _ = rhs.GetRoom(ctx.Room.RoomId).JoinAsync([ctx.Homeserver.ServerName]); } }