mirror of
				https://gitlab.com/Kwoth/nadekobot.git
				synced 2025-11-04 00:34:26 -05:00 
			
		
		
		
	Added .clubreject which lets you reject applications to the club. Updated some dependencies.
This commit is contained in:
		@@ -282,6 +282,24 @@ public partial class Xp
 | 
			
		||||
            else if(result == ClubAcceptResult.NotOwnerOrAdmin)
 | 
			
		||||
                await ReplyErrorLocalizedAsync(strs.club_admin_perms);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        [Cmd]
 | 
			
		||||
        [Priority(1)]
 | 
			
		||||
        public Task ClubReject(IUser user)
 | 
			
		||||
            => ClubReject(user.ToString());
 | 
			
		||||
 | 
			
		||||
        [Cmd]
 | 
			
		||||
        [Priority(0)]
 | 
			
		||||
        public async Task ClubReject([Leftover] string userName)
 | 
			
		||||
        {
 | 
			
		||||
            var result = _service.RejectApplication(ctx.User.Id, userName, out var discordUser);
 | 
			
		||||
            if (result == ClubDenyResult.Rejected)
 | 
			
		||||
                await ReplyConfirmLocalizedAsync(strs.club_rejected(Format.Bold(discordUser.ToString())));
 | 
			
		||||
            else if(result == ClubDenyResult.NoSuchApplicant)
 | 
			
		||||
                await ReplyErrorLocalizedAsync(strs.club_accept_invalid_applicant);
 | 
			
		||||
            else if(result == ClubDenyResult.NotOwnerOrAdmin)
 | 
			
		||||
                await ReplyErrorLocalizedAsync(strs.club_admin_perms);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [Cmd]
 | 
			
		||||
        public async Task ClubLeave()
 | 
			
		||||
 
 | 
			
		||||
@@ -185,6 +185,26 @@ public class ClubService : INService, IClubService
 | 
			
		||||
        uow.SaveChanges();
 | 
			
		||||
        return ClubAcceptResult.Accepted;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public ClubDenyResult RejectApplication(ulong clubOwnerUserId, string userName, out DiscordUser discordUser)
 | 
			
		||||
    {
 | 
			
		||||
        discordUser = null;
 | 
			
		||||
        using var uow = _db.GetDbContext();
 | 
			
		||||
        var club = uow.Clubs.GetByOwnerOrAdmin(clubOwnerUserId);
 | 
			
		||||
        if (club is null)
 | 
			
		||||
            return ClubDenyResult.NotOwnerOrAdmin;
 | 
			
		||||
 | 
			
		||||
        var applicant =
 | 
			
		||||
            club.Applicants.FirstOrDefault(x => x.User.ToString().ToUpperInvariant() == userName.ToUpperInvariant());
 | 
			
		||||
        if (applicant is null)
 | 
			
		||||
            return ClubDenyResult.NoSuchApplicant;
 | 
			
		||||
        
 | 
			
		||||
        club.Applicants.Remove(applicant);
 | 
			
		||||
        
 | 
			
		||||
        discordUser = applicant.User;
 | 
			
		||||
        uow.SaveChanges();
 | 
			
		||||
        return ClubDenyResult.Rejected;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public ClubInfo GetClubWithBansAndApplications(ulong ownerUserId)
 | 
			
		||||
    {
 | 
			
		||||
 
 | 
			
		||||
@@ -13,6 +13,7 @@ public interface IClubService
 | 
			
		||||
    bool GetClubByName(string clubName, out ClubInfo club);
 | 
			
		||||
    ClubApplyResult ApplyToClub(IUser user, ClubInfo club);
 | 
			
		||||
    ClubAcceptResult AcceptApplication(ulong clubOwnerUserId, string userName, out DiscordUser discordUser);
 | 
			
		||||
    ClubDenyResult RejectApplication(ulong clubOwnerUserId, string userName, out DiscordUser discordUser);
 | 
			
		||||
    ClubInfo? GetClubWithBansAndApplications(ulong ownerUserId);
 | 
			
		||||
    ClubLeaveResult LeaveClub(IUser user);
 | 
			
		||||
    bool SetDescription(ulong userId, string? desc);
 | 
			
		||||
 
 | 
			
		||||
@@ -5,4 +5,11 @@ public enum ClubAcceptResult
 | 
			
		||||
    Accepted,
 | 
			
		||||
    NotOwnerOrAdmin,
 | 
			
		||||
    NoSuchApplicant,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
public enum ClubDenyResult
 | 
			
		||||
{
 | 
			
		||||
    Rejected,
 | 
			
		||||
    NoSuchApplicant,
 | 
			
		||||
    NotOwnerOrAdmin
 | 
			
		||||
}
 | 
			
		||||
@@ -30,7 +30,7 @@
 | 
			
		||||
        <PackageReference Include="Discord.Net" Version="3.104.0" />
 | 
			
		||||
        <PackageReference Include="CoreCLR-NCalc" Version="2.2.110" />
 | 
			
		||||
        <PackageReference Include="Google.Apis.Urlshortener.v1" Version="1.41.1.138" />
 | 
			
		||||
        <PackageReference Include="Google.Apis.YouTube.v3" Version="1.57.0.2749" />
 | 
			
		||||
        <PackageReference Include="Google.Apis.YouTube.v3" Version="1.62.1.3205" />
 | 
			
		||||
        <PackageReference Include="Google.Apis.Customsearch.v1" Version="1.49.0.2084" />
 | 
			
		||||
        <PackageReference Include="Google.Protobuf" Version="3.21.2" />
 | 
			
		||||
        <PackageReference Include="Grpc.Net.ClientFactory" Version="2.47.0" />
 | 
			
		||||
@@ -52,7 +52,7 @@
 | 
			
		||||
        <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="6.0.0" />
 | 
			
		||||
        <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="6.0.0" />
 | 
			
		||||
        <PackageReference Include="Microsoft.SyndicationFeed.ReaderWriter" Version="1.0.2" />
 | 
			
		||||
        <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
 | 
			
		||||
        <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
 | 
			
		||||
        <PackageReference Include="NonBlocking" Version="2.1.0" />
 | 
			
		||||
        <PackageReference Include="OneOf" Version="3.0.223" />
 | 
			
		||||
        <PackageReference Include="Scrutor" Version="4.2.0" />
 | 
			
		||||
 
 | 
			
		||||
@@ -57,7 +57,7 @@ public sealed partial class GoogleApiService : IGoogleApiService, INService
 | 
			
		||||
        return (await query.ExecuteAsync()).Items.Select(i => i.Id.PlaylistId);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public async Task<IEnumerable<string>> GetRelatedVideosAsync(string id, int count = 1, string user = null)
 | 
			
		||||
    public async Task<IEnumerable<string>> GetRelatedVideosAsync(string id, int count = 2, string user = null)
 | 
			
		||||
    {
 | 
			
		||||
        if (string.IsNullOrWhiteSpace(id))
 | 
			
		||||
            throw new ArgumentNullException(nameof(id));
 | 
			
		||||
@@ -67,10 +67,14 @@ public sealed partial class GoogleApiService : IGoogleApiService, INService
 | 
			
		||||
        
 | 
			
		||||
        var query = _yt.Search.List("snippet");
 | 
			
		||||
        query.MaxResults = count;
 | 
			
		||||
        query.RelatedToVideoId = id;
 | 
			
		||||
        query.Q = id;
 | 
			
		||||
        // query.RelatedToVideoId = id;
 | 
			
		||||
        query.Type = "video";
 | 
			
		||||
        query.QuotaUser = user;
 | 
			
		||||
        return (await query.ExecuteAsync()).Items.Select(i => "https://www.youtube.com/watch?v=" + i.Id.VideoId);
 | 
			
		||||
        // bad workaround as there's no replacement for related video querying right now.
 | 
			
		||||
        // Query youtube with the id of the video, take a second video in the results
 | 
			
		||||
        // skip the first one as that's probably the same video.
 | 
			
		||||
        return (await query.ExecuteAsync()).Items.Select(i => "https://www.youtube.com/watch?v=" + i.Id.VideoId).Skip(1);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public async Task<IEnumerable<string>> GetVideoLinksByKeywordAsync(string keywords, int count = 1)
 | 
			
		||||
 
 | 
			
		||||
@@ -1116,6 +1116,8 @@ clubapply:
 | 
			
		||||
  - clubapply
 | 
			
		||||
clubaccept:
 | 
			
		||||
  - clubaccept
 | 
			
		||||
clubreject:
 | 
			
		||||
  - clubreject
 | 
			
		||||
clubleave:
 | 
			
		||||
  - clubleave
 | 
			
		||||
clubdisband:
 | 
			
		||||
 
 | 
			
		||||
@@ -1929,6 +1929,10 @@ clubaccept:
 | 
			
		||||
  desc: "Accept a user who applied to your club."
 | 
			
		||||
  args:
 | 
			
		||||
    - "user#1337"
 | 
			
		||||
clubreject:
 | 
			
		||||
  desc: "Reject a user who applied to your club."
 | 
			
		||||
  args:
 | 
			
		||||
    - "user#1337"
 | 
			
		||||
clubleave:
 | 
			
		||||
  desc: "Leaves the club you're currently in."
 | 
			
		||||
  args:
 | 
			
		||||
 
 | 
			
		||||
@@ -848,6 +848,7 @@
 | 
			
		||||
  "club_not_exists": "That club doesn't exist.",
 | 
			
		||||
  "club_applied": "You've applied for membership in {0} club.",
 | 
			
		||||
  "club_accepted": "Accepted user {0} to the club.",
 | 
			
		||||
  "club_rejected": "The application by {0} has been rejected.",
 | 
			
		||||
  "club_accept_invalid_applicant": "That user has not applied to your club.",
 | 
			
		||||
  "club_left": "You've left the club.",
 | 
			
		||||
  "club_not_in_a_club": "You are not in a club.",
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user