.clubtransfer added, transfer ownership of your club
This commit is contained in:
parent
44d78ffcfe
commit
2be7774f11
@ -26,6 +26,19 @@ namespace NadekoBot.Modules.Xp
|
|||||||
_client = client;
|
_client = client;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[NadekoCommand, Usage, Description, Aliases]
|
||||||
|
public async Task ClubTransfer([Remainder]IUser newOwner)
|
||||||
|
{
|
||||||
|
var club = _service.TransferClub(Context.User, newOwner);
|
||||||
|
|
||||||
|
if(club != null)
|
||||||
|
await ReplyConfirmLocalized("club_transfered",
|
||||||
|
Format.Bold(club.Name),
|
||||||
|
Format.Bold(newOwner.ToString())).ConfigureAwait(false);
|
||||||
|
else
|
||||||
|
await ReplyErrorLocalized("club_transfer_failed").ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
|
||||||
[NadekoCommand, Usage, Description, Aliases]
|
[NadekoCommand, Usage, Description, Aliases]
|
||||||
public async Task ClubAdmin([Remainder]IUser toAdmin)
|
public async Task ClubAdmin([Remainder]IUser toAdmin)
|
||||||
{
|
{
|
||||||
|
@ -51,6 +51,27 @@ namespace NadekoBot.Modules.Xp.Services
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ClubInfo TransferClub(IUser from, IUser newOwner)
|
||||||
|
{
|
||||||
|
ClubInfo club;
|
||||||
|
using (var uow = _db.UnitOfWork)
|
||||||
|
{
|
||||||
|
club = uow.Clubs.GetByOwner(from.Id);
|
||||||
|
var newOwnerUser = uow.DiscordUsers.GetOrCreate(newOwner);
|
||||||
|
|
||||||
|
if (club == null ||
|
||||||
|
club.Owner.UserId != from.Id ||
|
||||||
|
!club.Users.Contains(newOwnerUser))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
club.Owner.IsClubAdmin = true; // old owner will stay as admin
|
||||||
|
newOwnerUser.IsClubAdmin = true;
|
||||||
|
club.Owner = newOwnerUser;
|
||||||
|
uow.Complete();
|
||||||
|
}
|
||||||
|
return club;
|
||||||
|
}
|
||||||
|
|
||||||
public bool ToggleAdmin(IUser owner, IUser toAdmin)
|
public bool ToggleAdmin(IUser owner, IUser toAdmin)
|
||||||
{
|
{
|
||||||
bool newState;
|
bool newState;
|
||||||
@ -59,13 +80,13 @@ namespace NadekoBot.Modules.Xp.Services
|
|||||||
var club = uow.Clubs.GetByOwner(owner.Id);
|
var club = uow.Clubs.GetByOwner(owner.Id);
|
||||||
var adminUser = uow.DiscordUsers.GetOrCreate(toAdmin);
|
var adminUser = uow.DiscordUsers.GetOrCreate(toAdmin);
|
||||||
|
|
||||||
if (club.OwnerId == adminUser.Id)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if (club == null || club.Owner.UserId != owner.Id ||
|
if (club == null || club.Owner.UserId != owner.Id ||
|
||||||
!club.Users.Contains(adminUser))
|
!club.Users.Contains(adminUser))
|
||||||
throw new InvalidOperationException();
|
throw new InvalidOperationException();
|
||||||
|
|
||||||
|
if (club.OwnerId == adminUser.Id)
|
||||||
|
return true;
|
||||||
|
|
||||||
newState = adminUser.IsClubAdmin = !adminUser.IsClubAdmin;
|
newState = adminUser.IsClubAdmin = !adminUser.IsClubAdmin;
|
||||||
uow.Complete();
|
uow.Complete();
|
||||||
}
|
}
|
||||||
|
@ -925,5 +925,7 @@
|
|||||||
"administration_invalid": "Invalid / Can't be found ({0})",
|
"administration_invalid": "Invalid / Can't be found ({0})",
|
||||||
"administration_mass_kill_in_progress": "Mass Banning and Blacklisting of {0} users is in progress...",
|
"administration_mass_kill_in_progress": "Mass Banning and Blacklisting of {0} users is in progress...",
|
||||||
"administration_mass_kill_completed": "Mass Banning and Blacklisting of {0} users is complete.",
|
"administration_mass_kill_completed": "Mass Banning and Blacklisting of {0} users is complete.",
|
||||||
"searches_failed_finding_novel": "Can't find that novel. Make sure you've typed the exact full name, and that it exists on novelupdates.com"
|
"searches_failed_finding_novel": "Can't find that novel. Make sure you've typed the exact full name, and that it exists on novelupdates.com",
|
||||||
|
"xp_club_transfered": "Ownership of the club {0} has been transfered to {1}",
|
||||||
|
"xp_club_transfer_failed": "Transfer failed. You must be the club owner. Target must be a member of your club."
|
||||||
}
|
}
|
@ -2871,6 +2871,13 @@
|
|||||||
"{0}clubcreate b1nzy's friends"
|
"{0}clubcreate b1nzy's friends"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"clubtransfer": {
|
||||||
|
"Cmd": "clubtransfer",
|
||||||
|
"Desc": "Transfers the ownership of the club to another member of the club.",
|
||||||
|
"Usage": [
|
||||||
|
"{0}clubtransfer @b1nzy"
|
||||||
|
]
|
||||||
|
},
|
||||||
"clubinformation": {
|
"clubinformation": {
|
||||||
"Cmd": "clubinfo",
|
"Cmd": "clubinfo",
|
||||||
"Desc": "Shows information about the club.",
|
"Desc": "Shows information about the club.",
|
||||||
|
Loading…
Reference in New Issue
Block a user