Exemplo n.º 1
0
        public async Task LeaveGang()
        {
            if (Context.Gang.LeaderId == Context.User.Id)
            {
                ReplyError($"You may not leave a gang if you are the owner. Either destroy the gang with the `{Context.Prefix}DestroyGang` command, or " +
                           $"transfer the ownership of the gang to another member with the `{Context.Prefix}TransferLeadership` command.");
            }

            await _gangRepo.RemoveMemberAsync(Context.Gang, Context.User.Id);

            await ReplyAsync($"You have successfully left {Context.Gang.Name}.");

            await Context.Gang.LeaderId.DMAsync(Context.Client, $"{Context.User} has left {Context.Gang.Name}.");
        }
Exemplo n.º 2
0
        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}.");
        }
Exemplo n.º 3
0
        public async Task LeaveGang()
        {
            var gang = await GangRepository.FetchGangAsync(Context);

            var prefix = (await GuildRepository.FetchGuildAsync(Context.Guild.Id)).Prefix;

            if (gang.LeaderId == Context.User.Id)
            {
                throw new Exception($"You may not leave a gang if you are the owner. Either destroy the gang with the `{prefix}DestroyGang` command, or " +
                                    $"transfer the ownership of the gang to another member with the `{prefix}TransferLeadership` command.");
            }
            await GangRepository.RemoveMemberAsync(Context.User.Id, Context.Guild.Id);

            await ReplyAsync($"{Context.User.Mention}, You have successfully left {gang.Name}");

            var channel = await Context.Client.GetUser((ulong)gang.LeaderId).CreateDMChannelAsync();

            await channel.SendMessageAsync($"{Context.User} has left {gang.Name}.");
        }
Exemplo n.º 4
0
        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}");
        }