mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 01:38:27 -04:00
Clubleave errors clarified. Moved enum results to their own files
This commit is contained in:
@@ -46,6 +46,7 @@ public partial class Xp
|
|||||||
else
|
else
|
||||||
await ReplyConfirmLocalizedAsync(strs.club_admin_remove(Format.Bold(toAdmin.ToString())));
|
await ReplyConfirmLocalizedAsync(strs.club_admin_remove(Format.Bold(toAdmin.ToString())));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Cmd]
|
[Cmd]
|
||||||
public async Task ClubCreate([Leftover] string clubName)
|
public async Task ClubCreate([Leftover] string clubName)
|
||||||
{
|
{
|
||||||
@@ -242,7 +243,6 @@ public partial class Xp
|
|||||||
await ReplyErrorLocalizedAsync(strs.club_insuff_lvl);
|
await ReplyErrorLocalizedAsync(strs.club_insuff_lvl);
|
||||||
else if (result == ClubApplyResult.AlreadyInAClub)
|
else if (result == ClubApplyResult.AlreadyInAClub)
|
||||||
await ReplyErrorLocalizedAsync(strs.club_already_in);
|
await ReplyErrorLocalizedAsync(strs.club_already_in);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Cmd]
|
[Cmd]
|
||||||
@@ -263,10 +263,14 @@ public partial class Xp
|
|||||||
[Cmd]
|
[Cmd]
|
||||||
public async Task Clubleave()
|
public async Task Clubleave()
|
||||||
{
|
{
|
||||||
if (_service.LeaveClub(ctx.User))
|
var res = _service.LeaveClub(ctx.User);
|
||||||
|
|
||||||
|
if (res == ClubLeaveResult.Success)
|
||||||
await ReplyConfirmLocalizedAsync(strs.club_left);
|
await ReplyConfirmLocalizedAsync(strs.club_left);
|
||||||
|
else if (res == ClubLeaveResult.NotInAClub)
|
||||||
|
await ReplyErrorLocalizedAsync(strs.club_not_in_a_club);
|
||||||
else
|
else
|
||||||
await ReplyErrorLocalizedAsync(strs.club_not_in_club);
|
await ReplyErrorLocalizedAsync(strs.club_owner_cant_leave);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Cmd]
|
[Cmd]
|
||||||
|
10
src/NadekoBot/Modules/Xp/Club/ClubBanResult.cs
Normal file
10
src/NadekoBot/Modules/Xp/Club/ClubBanResult.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
namespace NadekoBot.Modules.Xp.Services;
|
||||||
|
|
||||||
|
public enum ClubBanResult
|
||||||
|
{
|
||||||
|
Success,
|
||||||
|
NotOwnerOrAdmin,
|
||||||
|
WrongUser,
|
||||||
|
Unbannable,
|
||||||
|
|
||||||
|
}
|
8
src/NadekoBot/Modules/Xp/Club/ClubLeaveResult.cs
Normal file
8
src/NadekoBot/Modules/Xp/Club/ClubLeaveResult.cs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
namespace NadekoBot.Modules.Xp.Services;
|
||||||
|
|
||||||
|
public enum ClubLeaveResult
|
||||||
|
{
|
||||||
|
Success,
|
||||||
|
OwnerCantLeave,
|
||||||
|
NotInAClub
|
||||||
|
}
|
@@ -178,17 +178,19 @@ public class ClubService : INService, IClubService
|
|||||||
return uow.Clubs.GetByOwnerOrAdmin(ownerUserId);
|
return uow.Clubs.GetByOwnerOrAdmin(ownerUserId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool LeaveClub(IUser user)
|
public ClubLeaveResult LeaveClub(IUser user)
|
||||||
{
|
{
|
||||||
using var uow = _db.GetDbContext();
|
using var uow = _db.GetDbContext();
|
||||||
var du = uow.GetOrCreateUser(user, x => x.Include(u => u.Club));
|
var du = uow.GetOrCreateUser(user, x => x.Include(u => u.Club));
|
||||||
if (du.Club is null || du.Club.OwnerId == du.Id)
|
if (du.Club is null)
|
||||||
return false;
|
return ClubLeaveResult.NotInAClub;
|
||||||
|
if (du.Club.OwnerId == du.Id)
|
||||||
|
return ClubLeaveResult.OwnerCantLeave;
|
||||||
|
|
||||||
du.Club = null;
|
du.Club = null;
|
||||||
du.IsClubAdmin = false;
|
du.IsClubAdmin = false;
|
||||||
uow.SaveChanges();
|
uow.SaveChanges();
|
||||||
return true;
|
return ClubLeaveResult.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool SetDescription(ulong userId, string desc)
|
public bool SetDescription(ulong userId, string desc)
|
||||||
@@ -299,19 +301,3 @@ public class ClubService : INService, IClubService
|
|||||||
return uow.Clubs.GetClubLeaderboardPage(page);
|
return uow.Clubs.GetClubLeaderboardPage(page);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ClubUnbanResult
|
|
||||||
{
|
|
||||||
Success,
|
|
||||||
NotOwnerOrAdmin,
|
|
||||||
WrongUser
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum ClubBanResult
|
|
||||||
{
|
|
||||||
Success,
|
|
||||||
NotOwnerOrAdmin,
|
|
||||||
WrongUser,
|
|
||||||
Unbannable,
|
|
||||||
|
|
||||||
}
|
|
8
src/NadekoBot/Modules/Xp/Club/ClubUnbanResult.cs
Normal file
8
src/NadekoBot/Modules/Xp/Club/ClubUnbanResult.cs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
namespace NadekoBot.Modules.Xp.Services;
|
||||||
|
|
||||||
|
public enum ClubUnbanResult
|
||||||
|
{
|
||||||
|
Success,
|
||||||
|
NotOwnerOrAdmin,
|
||||||
|
WrongUser
|
||||||
|
}
|
@@ -13,7 +13,7 @@ public interface IClubService
|
|||||||
ClubApplyResult ApplyToClub(IUser user, ClubInfo club);
|
ClubApplyResult ApplyToClub(IUser user, ClubInfo club);
|
||||||
bool AcceptApplication(ulong clubOwnerUserId, string userName, out DiscordUser discordUser);
|
bool AcceptApplication(ulong clubOwnerUserId, string userName, out DiscordUser discordUser);
|
||||||
ClubInfo? GetClubWithBansAndApplications(ulong ownerUserId);
|
ClubInfo? GetClubWithBansAndApplications(ulong ownerUserId);
|
||||||
bool LeaveClub(IUser user);
|
ClubLeaveResult LeaveClub(IUser user);
|
||||||
bool SetDescription(ulong userId, string? desc);
|
bool SetDescription(ulong userId, string? desc);
|
||||||
bool Disband(ulong userId, out ClubInfo club);
|
bool Disband(ulong userId, out ClubInfo club);
|
||||||
ClubBanResult Ban(ulong bannerId, string userName, out ClubInfo club);
|
ClubBanResult Ban(ulong bannerId, string userName, out ClubInfo club);
|
||||||
|
@@ -849,7 +849,8 @@
|
|||||||
"club_accepted": "Accepted user {0} to the club.",
|
"club_accepted": "Accepted user {0} to the club.",
|
||||||
"club_accept_error": "User not found",
|
"club_accept_error": "User not found",
|
||||||
"club_left": "You've left the club.",
|
"club_left": "You've left the club.",
|
||||||
"club_not_in_club": "You are not in a club, or you're trying to leave the club you're the owner of.",
|
"club_not_in_a_club": "You are not in a club.",
|
||||||
|
"club_owner_cant_leave": "Club owner can't leave the club - you must either transfer ownership or disband the club.",
|
||||||
"club_user_kick": "User {0} kicked from {1} club.",
|
"club_user_kick": "User {0} kicked from {1} club.",
|
||||||
"club_user_not_in_club": "{0} is not in a club.",
|
"club_user_not_in_club": "{0} is not in a club.",
|
||||||
"club_user_kick_fail": "Error kicking. You're either not the club owner, or that user is not in your club.",
|
"club_user_kick_fail": "Error kicking. You're either not the club owner, or that user is not in your club.",
|
||||||
|
Reference in New Issue
Block a user