Ejemplo n.º 1
0
        /// <inheritdoc />
        public async Task <Result <string> > Handle(Query request, CancellationToken cancellationToken)
        {
            var getGuildInvitesResult = await _guildApi.GetGuildInvitesAsync(request.GuildId, cancellationToken);

            if (!getGuildInvitesResult.IsSuccess)
            {
                return(Result <string> .FromError(getGuildInvitesResult));
            }

            var invites = getGuildInvitesResult.Entity;

            if (invites is null || !invites.Any())
            {
                return(new NotFoundError(
                           "Could not find an active invite link. Administrators should create an invite link in Discord guild settings that does not expire."));
            }

            var inv = invites[0].Code;

            return(Result <string> .FromSuccess(inv));
        }