public async Task KickFromGang(IGuildUser user) { if (!(await GangRepository.IsMemberOfAsync(Context.User.Id, Context.Guild.Id, user.Id))) { throw new Exception("This user is not a member of your gang!"); } var gang = await GangRepository.FetchGangAsync(Context); await GangRepository.RemoveMemberAsync(user.Id, Context.Guild.Id); await ReplyAsync($"{Context.User.Mention}, You have successfully kicked {user} from {gang.Name}"); var channel = await user.CreateDMChannelAsync(); await channel.SendMessageAsync($"You have been kicked from {gang.Name}."); }
public async Task KickFromGang([Remainder] IGuildUser gangMember) { if (gangMember.Id == Context.User.Id) { ReplyError("You may not kick yourself!"); } else if (!_gangRepo.IsMemberOfAsync(Context.Gang, gangMember.Id)) { ReplyError("This user is not a member of your gang!"); } await _gangRepo.RemoveMemberAsync(Context.Gang, gangMember.Id); await ReplyAsync($"You have successfully kicked {gangMember} from {Context.Gang.Name}."); await gangMember.Id.DMAsync(Context.Client, $"You have been kicked from {Context.Gang.Name}."); }
public async Task TransferLeadership(IGuildUser user) { if (user.Id == Context.User.Id) { throw new Exception("You are already the leader of this gang!"); } var gang = await GangRepository.FetchGangAsync(Context); if (!(await GangRepository.IsMemberOfAsync(Context.User.Id, Context.Guild.Id, user.Id))) { throw new Exception("This user is not a member of your gang!"); } await GangRepository.RemoveMemberAsync(Context.User.Id, Context.Guild.Id); await GangRepository.ModifyAsync(x => { x.LeaderId = user.Id; return(Task.CompletedTask); }, Context); await GangRepository.AddMemberAsync(Context.User.Id, Context.Guild.Id, Context.User.Id); await ReplyAsync($"{Context.User.Mention}, You have successfully transferred the leadership of {gang.Name} to {user.Mention}"); }